Example of an interrupt service routine.
Example of an interrupt service routine.
#include <l4/sys/utcb.h>
#include <stdio.h>
int main(void)
{
int const irqno = 0;
long err;
{
printf("Did not find the Vlog ICU.\n");
return 1;
}
{
printf("Cannot allocate capability slot.\n");
return 1;
}
{
printf("Could not create IRQ object: %ld (%s).\n", err, l4sys_errtostr(err));
return 1;
}
{
printf("Could not bind IRQ%d to ICU: %ld (%s).\n", irqno, err, l4sys_errtostr(err));
return 1;
}
{
printf("Could not get Vcon attributes: %ld (%s).\n", err, l4sys_errtostr(err));
return 1;
}
{
printf("Could not set Vcon attributes: %ld (%s).\n", err, l4sys_errtostr(err));
return 1;
}
printf("Vcon echo disabled.\n");
{
printf("Could not bind to IRQ%d: %ld (%s).\n", irqno, err, l4sys_errtostr(err));
return 1;
}
printf("Attached to key IRQ %d.\nPress keys now, Shift-Q to exit.\n", irqno);
while (1)
{
printf("Could not receive IRQ: %ld (%s).\n", err, l4sys_errtostr(err));
else
{
char buf[128];
int n;
if (label != 0x1234)
{
printf("Unexpected label %0lx -- ignoring interrupt.\n", label);
continue;
}
printf("Got IRQ with expected label 0x%lX.\n", label);
if (n < 0)
printf("Could not read from Vcon interface: %d (%s).\n", n, l4sys_errtostr(n));
else
{
unsigned i;
int terminate = 0;
for (i = 0; i < (unsigned)n && i < sizeof(buf); ++i)
{
int c = (unsigned char)buf[i];
if (c >= 32 && c < 128)
printf("Got key '%c'.\n", c);
else
printf("Got keycode %d.\n", c);
if (buf[i] == 'Q')
terminate = 1;
}
if (terminate)
break;
}
}
}
printf("Could not detach from IRQ: %ld (%s).\n", err, l4sys_errtostr(err));
printf("Application terminated.\n");
return 0;
}
Capability allocator C interface.
Common factory related definitions.
l4_cap_idx_t l4re_util_cap_alloc(void) L4_NOTHROW
Get free capability index at capability allocator.
l4re_env_t * l4re_env(void) L4_NOTHROW
Get L4Re initial environment.
unsigned long l4_umword_t
Unsigned machine word.
unsigned long l4_cap_idx_t
Capability selector type.
unsigned l4_is_invalid_cap(l4_cap_idx_t c) L4_NOTHROW
Test if a capability selector is the invalid capability.
l4_msgtag_t l4_factory_create_irq(l4_cap_idx_t factory, l4_cap_idx_t target_cap) L4_NOTHROW
Create a new IRQ sender.
l4_msgtag_t l4_icu_bind(l4_cap_idx_t icu, unsigned irqnum, l4_cap_idx_t irq) L4_NOTHROW
Bind an interrupt line of an interrupt controller to an interrupt object.
long l4_error(l4_msgtag_t tag) L4_NOTHROW
Get IPC error code if any or message tag label otherwise for an IPC call.
l4_msgtag_t l4_irq_detach(l4_cap_idx_t irq) L4_NOTHROW
Detach from an interrupt source.
l4_msgtag_t l4_irq_wait(l4_cap_idx_t irq, l4_umword_t *label, l4_timeout_t to) L4_NOTHROW
Unmask IRQ and wait for any message.
l4_msgtag_t l4_rcv_ep_bind_thread(l4_cap_idx_t ep, l4_cap_idx_t thread, l4_umword_t label)
Bind the IPC receive endpoint to a thread.
#define L4_IPC_NEVER
never timeout
int l4_vcon_read(l4_cap_idx_t vcon, char *buf, unsigned size) L4_NOTHROW
Read data from virtual console.
l4_msgtag_t l4_vcon_set_attr(l4_cap_idx_t vcon, l4_vcon_attr_t const *attr) L4_NOTHROW
Set attributes of a Vcon.
l4_msgtag_t l4_vcon_get_attr(l4_cap_idx_t vcon, l4_vcon_attr_t *attr) L4_NOTHROW
Get attributes of a Vcon.
Namespace functions, C interface.
Vcon attribute structure.
l4_umword_t l_flags
local flags
l4_cap_idx_t log
Logging object-capability.
Virtual console interface.