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; }
void freevms_main(void) { char *command_line; # define ROOT_DEVICE_LENGTH 80 char root_device[ROOT_DEVICE_LENGTH]; # define CONSOLE_DEVICE_LENGTH 80 char console_device[CONSOLE_DEVICE_LENGTH]; L4_BootRec_t *boot_record; L4_KernelInterfacePage_t *kip; L4_ProcDesc_t *main_proc_desc; L4_ThreadId_t root_tid; L4_ThreadId_t s0_tid; L4_Word_t api_flags; L4_Word_t boot_info; L4_Word_t i; L4_Word_t kernel_id; L4_Word_t kernel_interface; L4_Word_t num_boot_info_entries; L4_Word_t num_processors; L4_Word_t page_bits; L4_Word_t pagesize; struct vms$meminfo mem_info; vms$pd_initialized = 0; notice("\n"); notice(">>> FreeVMS %s (R)\n", FREEVMS_VERSION); notice("\n"); kip = (L4_KernelInterfacePage_t *) L4_KernelInterface(&kernel_interface, &api_flags, &kernel_id); notice(SYSBOOT_I_SYSBOOT "leaving kernel privileges\n"); notice(SYSBOOT_I_SYSBOOT "launching FreeVMS kernel with executive " "privileges\n"); root_tid = L4_Myself(); s0_tid = L4_GlobalId(kip->ThreadInfo.X.UserBase, 1); notice(SYSBOOT_I_SYSBOOT "booting main processor\n"); for(page_bits = 0; !((1 << page_bits) & L4_PageSizeMask(kip)); page_bits++); pagesize = (((vms$pointer) 1) << page_bits); notice(SYSBOOT_I_SYSBOOT "computing page size: %d bytes\n", (int) pagesize); num_processors = L4_NumProcessors((void *) kip); switch(num_processors - 1) { case 0: break; case 1: notice(SYSBOOT_I_SYSBOOT "booting %d secondary processor\n", (int) (num_processors - 1)); break; default: notice(SYSBOOT_I_SYSBOOT "booting %d secondary processors\n", (int) (num_processors - 1)); break; } for(i = 0; i < num_processors; i++) { main_proc_desc = L4_ProcDesc((void *) kip, i); notice(SYSBOOT_I_SYSBOOT "CPU%d EXTFREQ=%d MHz, INTFREQ=%d MHz\n", (int) i, (int) (main_proc_desc->X.ExternalFreq / 1000), (int) (main_proc_desc->X.InternalFreq / 1000)); } L4_Sigma0_GetPage(L4_nilthread, L4_Fpage(L4_BootInfo(kip), pagesize)); boot_info = L4_BootInfo((void *) kip); num_boot_info_entries = L4_BootInfo_Entries((void *) boot_info); boot_record = L4_BootInfo_FirstEntry((void *) boot_info); for(i = 2; i < num_boot_info_entries; i++) { PANIC(L4_BootRec_Type(boot_record) != L4_BootInfo_SimpleExec); command_line = L4_SimpleExec_Cmdline(boot_record); if ((strstr(command_line, "vmskernel.sys") != NULL) && (i == 3)) { break; } boot_record = L4_BootRec_Next(boot_record); } PANIC(L4_BootRec_Type(boot_record) != L4_BootInfo_SimpleExec); command_line = L4_SimpleExec_Cmdline(boot_record); notice(SYSBOOT_I_SYSBOOT "parsing command line: %s\n", command_line); sys$parsing(command_line, (char *) "root", root_device, ROOT_DEVICE_LENGTH); notice(SYSBOOT_I_SYSBOOT "selecting root device: %s\n", root_device); sys$parsing(command_line, (char *) "console", console_device, CONSOLE_DEVICE_LENGTH); notice(SYSBOOT_I_SYSBOOT "selecting console device: %s\n", console_device); dbg$virtual_memory = (strstr(command_line, " dbg$virtual_memory") != NULL) ? 1 : 0; dbg$sys_pagefault = (strstr(command_line, " dbg$sys_pagefault") != NULL) ? 1 : 0; dbg$vms_pagefault = (strstr(command_line, " dbg$vms_pagefault") != NULL) ? 1 : 0; // Starting virtual memory subsystem sys$mem_init(kip, &mem_info, pagesize); sys$bootstrap(&mem_info, pagesize); sys$objtable_init(); sys$utcb_init(kip); sys$pd_init(&mem_info); sys$thread_init(kip); sys$populate_init_objects(&mem_info, pagesize); dev$init(); names$init(); sys$pager(kip, &mem_info, pagesize, root_device); sys$init(kip, &mem_info, pagesize, root_device); sys$loop(); notice(">>> System halted\n"); return; }
int main (void) { L4_Word_t total; printf("\n\nHasenpfeffer operating system\n"); printf("Copyright (C) 2005,2006. Senko Rasic <*****@*****.**>\n\n"); printf("Initializing root task...\n"); L4_KernelInterfacePage_t *kip = (L4_KernelInterfacePage_t *) L4_GetKernelInterface(); void *bi = (void *) L4_BootInfo(kip); // we need to preload these I/O pages // ATA L4_Sigma0_GetPage(L4_nilthread, L4_Fpage(0x0000, 4096)); // KIP L4_Sigma0_GetPage(L4_nilthread, L4_Fpage(L4_BootInfo(kip), 4096)); L4_BootRec_t *br = NULL; if (L4_BootInfo_Valid((void *) bi)) { int n = L4_BootInfo_Entries(bi); br = L4_BootInfo_FirstEntry(bi); while (--n) { /* touch roottask data from here, because sigma0 only gives pages to initial *thread* */ if (L4_BootRec_Type(br) == L4_BootInfo_SimpleExec) { 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)); } } br = L4_BootRec_Next(br); } } else { printf("panic: invalid bootinfo data\n"); return 0; } memory_init(); total = memory_get_free(); printf("Creating root memory manager...\n"); mman_tid = create_local_thread("root memory manager", kip, 1, memman, 4096); thread_init(mman_tid); printf("Initializing root task manager...\n"); HpfCapability full, newthread, newtask; task_manager_init(&full, &newtask, &newthread); dir_paths[0] = "/process/TaskManager"; dir_caps[0] = full; n_paths = 1; printf("Loading initial programs...\n"); int n = L4_BootInfo_Entries(bi); br = L4_BootInfo_FirstEntry(bi); int first_program = 1; while (--n) { if (L4_BootRec_Type(br) == L4_BootInfo_Module) { L4_ThreadId_t tid = launch(br); if (first_program) { first_program = 0; // this is the root directory server if (hermes_capability(tid, &(dir_caps[1]))) { // dir_paths[1] = "/process/DirectoryService"; dir_paths[1] = ""; // <- catch-all n_paths = 2; } } } br = L4_BootRec_Next(br); } printf("Init done, running...\n\n"); task_manager_main(); return 0; }