/* Given fname, find the bootinfo module associated with it. Return NULL on failure */ static L4_BootRec_t * find_bootrec(const char *fname) { L4_KernelInterfacePage_t *kip; L4_BootRec_t *rec; void *bootinfo; unsigned num_recs, objs; /* Iterate through bootinfo */ kip = L4_GetKernelInterface(); bootinfo = (void*) L4_BootInfo(kip); num_recs = L4_BootInfo_Entries(bootinfo); rec = L4_BootInfo_FirstEntry(bootinfo); while(num_recs > 0) { L4_Word_t type; /* find what type it is */ type = L4_BootRec_Type(rec); objs = 0; if (type == L4_BootInfo_Module && (strcmp(L4_Module_Cmdline(rec), fname) == 0)) { /* Found it! */ break; } rec = L4_BootRec_Next(rec); num_recs--; } if (num_recs > 0) { return rec; } else { return NULL; } }
static L4_ThreadId_t launch(L4_BootRec_t *br) { AddrSpace_t *as = task_new(mman_tid); if (!as) { debug("launch: can't create address space for %s\n", L4_Module_Cmdline(br)); return L4_nilthread; } /* we have to explicitly grab these from sigma0 */ L4_Word_t mi; for (mi = 0; mi < L4_Module_Size(br); mi += 4096) { L4_Sigma0_GetPage(L4_nilthread, L4_Fpage(L4_Module_Start(br) + mi, 4096)); } L4_Word_t start = elf_load32(as, L4_Module_Start(br), L4_Module_Size(br)); thread_start(as->tid, start, L4_Module_Cmdline(br), n_paths, dir_paths, dir_caps); printf(" %s\n", L4_Module_Cmdline(br)); return as->tid; }
static unsigned int sys$bootinfo_find_initial_objects(L4_KernelInterfacePage_t *kip, unsigned int max, struct initial_obj *initial_objs) { char data_name[INITIAL_NAME_MAX]; L4_BootRec_t *record; L4_Word_t dsize; L4_Word_t dstart; L4_Word_t tsize; L4_Word_t tstart; L4_Word_t type; unsigned int count; unsigned int flags; unsigned int num_recs; unsigned int objects; void *bootinfo; # define DIT_INITIAL 32L // Root task bootinfo = (void*) L4_BootInfo(kip); count = 0; // Check bootinfo validity if (L4_BootInfo_Valid(bootinfo) == 0) { return(0); } num_recs = L4_BootInfo_Entries(bootinfo); record = L4_BootInfo_FirstEntry(bootinfo); while(num_recs > 0) { PANIC(record == NULL); type = L4_BootRec_Type(record); objects = 0; switch(type) { case L4_BootInfo_Module: sys$add_initial_object(initial_objs++, L4_Module_Cmdline(record), L4_Module_Start(record), (L4_Module_Start(record) + L4_Module_Size(record)) - 1, 0, VMS$IOF_APP | VMS$IOF_PHYS); objects = 1; break; case L4_BootInfo_SimpleExec: if (L4_SimpleExec_Flags(record) & DIT_INITIAL) { flags = VMS$IOF_ROOT | VMS$IOF_VIRT; } else { flags = VMS$IOF_APP; } tstart = L4_SimpleExec_TextVstart(record); tsize = L4_SimpleExec_TextSize(record); dstart = L4_SimpleExec_DataVstart(record); dsize = L4_SimpleExec_DataSize(record); sys$add_initial_object(initial_objs++, L4_SimpleExec_Cmdline(record), tstart, (tstart + tsize) - 1, L4_SimpleExec_InitialIP(record), flags | VMS$IOF_PHYS); objects = 1; if ((!((dstart < (tstart + tsize) && dstart >= tstart))) && (dsize != 0)) { sys$strncpy(data_name, L4_SimpleExec_Cmdline(record), INITIAL_NAME_MAX - 5); sys$strncat(data_name, ".data", INITIAL_NAME_MAX); sys$add_initial_object(initial_objs++, data_name, dstart, dstart + dsize - 1, 0, VMS$IOF_ROOT | VMS$IOF_VIRT | VMS$IOF_PHYS); objects++; } break; case L4_BootInfo_Multiboot: sys$add_initial_object(initial_objs++, "MultiBoot information", L4_MBI_Address(record), L4_MBI_Address(record) + 0xFFF, 0, VMS$IOF_PHYS | VMS$IOF_BOOT | VMS$IOF_VIRT); objects = 1; break; default: PANIC(1); break; } if (objects > 0) { count += objects; if (count == max) goto overflow; } record = L4_BootRec_Next(record); num_recs--; } sys$add_initial_object(initial_objs++, "Boot", (vms$pointer) bootinfo, (vms$pointer) bootinfo + (L4_BootInfo_Size(bootinfo) - 1), 0, VMS$IOF_BOOT | VMS$IOF_PHYS | VMS$IOF_VIRT); count++; overflow: return count; }