#ifndef __L4__BOOTINFO_H__
#define __L4__BOOTINFO_H__
#include <l4/types.h>
#define L4_BOOTINFO_MAGIC ((L4_Word_t) 0x14b0021d)
#define L4_BOOTINFO_VERSION 1
#define L4_BootInfo_Module 0x0001
#define L4_BootInfo_SimpleExec 0x0002
#define L4_BootInfo_EFITables 0x0101
#define L4_BootInfo_Multiboot 0x0102
typedef struct {
L4_Word_t type;
L4_Word_t version;
L4_Word_t offset_next;
} L4_BootRec_t;
L4_INLINE L4_Word_t L4_BootRec_Type (const L4_BootRec_t * r)
{
return r->type;
}
L4_INLINE L4_BootRec_t * L4_BootRec_Next (const L4_BootRec_t * r)
{
return (L4_BootRec_t *) (((L4_Word_t) r) + r->offset_next);
}
#if defined(__cplusplus)
L4_INLINE L4_Word_t L4_Type (const L4_BootRec_t * r)
{
return L4_BootRec_Type (r);
}
L4_INLINE L4_BootRec_t * L4_Next (const L4_BootRec_t * r)
{
return L4_BootRec_Next (r);
}
#endif
typedef struct {
L4_Word_t type;
L4_Word_t version;
L4_Word_t offset_next;
L4_Word_t start;
L4_Word_t size;
L4_Word_t cmdline_offset;
} L4_Boot_Module_t;
L4_INLINE L4_Word_t L4_Module_Start (const L4_BootRec_t * ptr)
{
L4_Boot_Module_t * m = (L4_Boot_Module_t *) ptr;
return m->start;
}
L4_INLINE L4_Word_t L4_Module_Size (const L4_BootRec_t * ptr)
{
L4_Boot_Module_t * m = (L4_Boot_Module_t *) ptr;
return m->size;
}
L4_INLINE char * L4_Module_Cmdline (const L4_BootRec_t * ptr)
{
L4_Boot_Module_t * m = (L4_Boot_Module_t *) ptr;
if (m->cmdline_offset)
return (char *) ((L4_Word_t) m + m->cmdline_offset);
else
return (char *) 0;
}
typedef struct {
L4_Word_t type;
L4_Word_t version;
L4_Word_t offset_next;
L4_Word_t text_pstart;
L4_Word_t text_vstart;
L4_Word_t text_size;
L4_Word_t data_pstart;
L4_Word_t data_vstart;
L4_Word_t data_size;
L4_Word_t bss_pstart;
L4_Word_t bss_vstart;
L4_Word_t bss_size;
L4_Word_t initial_ip;
L4_Word_t flags;
L4_Word_t label;
L4_Word_t cmdline_offset;
} L4_Boot_SimpleExec_t;
L4_INLINE L4_Word_t L4_SimpleExec_TextVstart (const L4_BootRec_t * ptr)
{
L4_Boot_SimpleExec_t * e = (L4_Boot_SimpleExec_t *) ptr;
return e->text_vstart;
}
L4_INLINE L4_Word_t L4_SimpleExec_TextPstart (const L4_BootRec_t * ptr)
{
L4_Boot_SimpleExec_t * e = (L4_Boot_SimpleExec_t *) ptr;
return e->text_pstart;
}
L4_INLINE L4_Word_t L4_SimpleExec_TextSize (const L4_BootRec_t * ptr)
{
L4_Boot_SimpleExec_t * e = (L4_Boot_SimpleExec_t *) ptr;
return e->text_size;
}
L4_INLINE L4_Word_t L4_SimpleExec_DataVstart (const L4_BootRec_t * ptr)
{
L4_Boot_SimpleExec_t * e = (L4_Boot_SimpleExec_t *) ptr;
return e->data_vstart;
}
L4_INLINE L4_Word_t L4_SimpleExec_DataPstart (const L4_BootRec_t * ptr)
{
L4_Boot_SimpleExec_t * e = (L4_Boot_SimpleExec_t *) ptr;
return e->data_pstart;
}
L4_INLINE L4_Word_t L4_SimpleExec_DataSize (const L4_BootRec_t * ptr)
{
L4_Boot_SimpleExec_t * e = (L4_Boot_SimpleExec_t *) ptr;
return e->data_size;
}
L4_INLINE L4_Word_t L4_SimpleExec_BssVstart (const L4_BootRec_t * ptr)
{
L4_Boot_SimpleExec_t * e = (L4_Boot_SimpleExec_t *) ptr;
return e->bss_vstart;
}
L4_INLINE L4_Word_t L4_SimpleExec_BssPstart (const L4_BootRec_t * ptr)
{
L4_Boot_SimpleExec_t * e = (L4_Boot_SimpleExec_t *) ptr;
return e->bss_pstart;
}
L4_INLINE L4_Word_t L4_SimpleExec_BssSize (const L4_BootRec_t * ptr)
{
L4_Boot_SimpleExec_t * e = (L4_Boot_SimpleExec_t *) ptr;
return e->bss_size;
}
L4_INLINE L4_Word_t L4_SimpleExec_InitialIP (const L4_BootRec_t * ptr)
{
L4_Boot_SimpleExec_t * e = (L4_Boot_SimpleExec_t *) ptr;
return e->initial_ip;
}
L4_INLINE L4_Word_t L4_SimpleExec_Flags (const L4_BootRec_t * ptr)
{
L4_Boot_SimpleExec_t * e = (L4_Boot_SimpleExec_t *) ptr;
return e->flags;
}
L4_INLINE void L4_SimpleExec_Set_Flags (const L4_BootRec_t * ptr, L4_Word_t w)
{
L4_Boot_SimpleExec_t * e = (L4_Boot_SimpleExec_t *) ptr;
e->flags = w;
}
L4_INLINE L4_Word_t L4_SimpleExec_Label (const L4_BootRec_t * ptr)
{
L4_Boot_SimpleExec_t * e = (L4_Boot_SimpleExec_t *) ptr;
return e->label;
}
L4_INLINE void L4_SimpleExec_Set_Label (const L4_BootRec_t * ptr, L4_Word_t w)
{
L4_Boot_SimpleExec_t * e = (L4_Boot_SimpleExec_t *) ptr;
e->label = w;
}
L4_INLINE char * L4_SimpleExec_Cmdline (const L4_BootRec_t * ptr)
{
L4_Boot_SimpleExec_t * e = (L4_Boot_SimpleExec_t *) ptr;
if (e->cmdline_offset)
return (char *) ((L4_Word_t) e + e->cmdline_offset);
else
return (char *) 0;
}
typedef struct {
L4_Word_t type;
L4_Word_t version;
L4_Word_t offset_next;
L4_Word_t systab;
L4_Word_t memmap;
L4_Word_t memmap_size;
L4_Word_t memdesc_size;
L4_Word_t memdesc_version;
} L4_Boot_EFI_t;
L4_INLINE L4_Word_t L4_EFI_Systab (const L4_BootRec_t * ptr)
{
L4_Boot_EFI_t * e = (L4_Boot_EFI_t *) ptr;
return e->systab;
}
L4_INLINE L4_Word_t L4_EFI_Memmap (const L4_BootRec_t * ptr)
{
L4_Boot_EFI_t * e = (L4_Boot_EFI_t *) ptr;
return e->memmap;
}
L4_INLINE L4_Word_t L4_EFI_MemmapSize (const L4_BootRec_t * ptr)
{
L4_Boot_EFI_t * e = (L4_Boot_EFI_t *) ptr;
return e->memmap_size;
}
L4_INLINE L4_Word_t L4_EFI_MemdescSize (const L4_BootRec_t * ptr)
{
L4_Boot_EFI_t * e = (L4_Boot_EFI_t *) ptr;
return e->memdesc_size;
}
L4_INLINE L4_Word_t L4_EFI_MemdescVersion (const L4_BootRec_t * ptr)
{
L4_Boot_EFI_t * e = (L4_Boot_EFI_t *) ptr;
return e->memdesc_version;
}
typedef struct {
L4_Word_t type;
L4_Word_t version;
L4_Word_t offset_next;
L4_Word_t address;
} L4_Boot_MBI_t;
L4_INLINE L4_Word_t L4_MBI_Address (const L4_BootRec_t * ptr)
{
L4_Boot_MBI_t * m = (L4_Boot_MBI_t *) ptr;
return m->address;
}
typedef struct {
L4_Word_t magic;
L4_Word_t version;
L4_Word_t size;
L4_Word_t first_entry;
L4_Word_t num_entries;
L4_Word_t __reserved[3];
} L4_BootInfo_t;
L4_INLINE L4_Bool_t L4_BootInfo_Valid (const void * ptr)
{
L4_BootInfo_t * b = (L4_BootInfo_t *) ptr;
return (b->magic == L4_BOOTINFO_MAGIC) &&
(b->version == L4_BOOTINFO_VERSION);
}
L4_INLINE L4_Word_t L4_BootInfo_Size (const void * ptr)
{
L4_BootInfo_t * b = (L4_BootInfo_t *) ptr;
return b->size;
}
L4_INLINE L4_BootRec_t * L4_BootInfo_FirstEntry (const void * ptr)
{
L4_BootInfo_t * b = (L4_BootInfo_t *) ptr;
return (L4_BootRec_t *) (((L4_Word_t) b) + b->first_entry);
}
L4_INLINE L4_Word_t L4_BootInfo_Entries (const void * ptr)
{
L4_BootInfo_t * b = (L4_BootInfo_t *) ptr;
return b->num_entries;
}
#endif