L4Re Operating System Framework
Interface and Usage Documentation
Loading...
Searching...
No Matches
examples/sys/ux-vhw/main.c

This example shows how to iterate the virtual hardware descriptors under Fiasco-UX.

This example shows how to iterate the virtual hardware descriptors under Fiasco-UX.

/*
* (c) 2008-2009 Adam Lackorzynski <adam@os.inf.tu-dresden.de>,
* Alexander Warg <warg@os.inf.tu-dresden.de>
* economic rights: Technische Universität Dresden (Germany)
*
* This file is part of TUD:OS and distributed under the terms of the
* GNU General Public License 2.
* Please see the COPYING-GPL-2 file for details.
*/
#include <l4/sys/ipc.h>
#include <l4/sys/vhw.h>
#include <l4/util/util.h>
#include <l4/util/kip.h>
#include <l4/re/env.h>
#include <stdlib.h>
#include <stdio.h>
static void print_entry(struct l4_vhw_entry *e)
{
printf("type: %d mem start: %08lx end: %08lx\n"
"irq: %d pid %d\n",
e->type, e->mem_start, e->mem_size,
}
int main(void)
{
l4_kernel_info_t const *kip = l4re_kip();
struct l4_vhw_descriptor *vhw;
int i;
if (!kip)
{
printf("KIP not available!\n");
return 1;
}
{
printf("This example is for Fiasco-UX only.\n");
return 1;
}
vhw = l4_vhw_get(kip);
printf("kip at %p, vhw at %p\n", kip, vhw);
printf("magic: %08x, version: %08x, count: %02d\n",
vhw->magic, vhw->version, vhw->count);
for (i = 0; i < vhw->count; i++)
print_entry(l4_vhw_get_entry(vhw, i));
return 0;
}
Environment interface.
l4_kernel_info_t const * l4re_kip(void) L4_NOTHROW
Get Kernel Info Page.
Definition env.h:194
int l4util_kip_kernel_is_ux(l4_kernel_info_t const *k)
Return whether the kernel is running natively or under UX.
L4 Kernel Interface Page.
Definition __kip-32bit.h:39
Virtual hardware devices description.
Definition vhw.h:70
l4_uint8_t version
Version of the descriptor.
Definition vhw.h:72
l4_uint8_t count
Number of entries.
Definition vhw.h:73
l4_uint32_t magic
Magic.
Definition vhw.h:71
Description of a device.
Definition vhw.h:55
l4_addr_t mem_size
Size of memory region.
Definition vhw.h:60
l4_uint32_t provider_pid
Host PID of the VHW provider.
Definition vhw.h:57
l4_uint32_t irq_no
IRQ number.
Definition vhw.h:62
l4_addr_t mem_start
Start of memory region.
Definition vhw.h:59
enum l4_vhw_entry_type type
Type of virtual hardware.
Definition vhw.h:56
Descriptors for virtual hardware (under UX).