void multiboot_main(unsigned int boot_info_pa) { int argc = 0; char **argv = 0; int ret; /* Copy the multiboot_info structure into our pre-reserved area. This avoids one loose fragment of memory that has to be avoided. */ boot_info = *(struct multiboot_info*)phystokv(boot_info_pa); /* * Initialize the processor tables. ie default handlers etc. */ base_cpu_setup(); /* * Initialize the floating point unit. */ /*base_fpu_init();*/ /* Initialize the memory allocator and find all available memory. */ base_multiboot_init_mem(); /* Parse the command line into nice POSIX-like args and environment. */ base_multiboot_init_cmdline(&argc, &argv); enable_interrupts(); /* Invoke the main program. */ ret = kernel_main(argc, argv, environ); printf( "base_multiboot_main.c: kernel main returned with code %d\n", ret ); while(1); }
void bootstrap (l4util_mb_info_t *mbi, unsigned int flag, char *rm_pointer) { l4_uint32_t vma_start, vma_end; struct { l4_uint32_t start; l4_uint16_t cs __attribute__((packed)); } far_ptr; l4_uint64_t mem_upper; // setup stuff for base_paging_init() base_cpu_setup(); #ifdef REALMODE_LOADING mem_upper = *(unsigned long*)(rm_pointer + 0x1e0); mem_upper = 1024 * (1024 + mem_upper); #else mem_upper = find_upper_mem(mbi); if (!mem_upper) mem_upper = 1024 * (1024 + mbi->mem_upper); #endif printf("Highest physical memory address found: %llx\n", mem_upper); // now do base_paging_init(): sets up paging with one-to-one mapping base_paging_init(round_superpage(mem_upper)); printf("Loading 64bit part...\n"); // switch from 32 Bit compatibility mode to 64 Bit mode far_ptr.cs = KERNEL_CS_64; far_ptr.start = load_elf(&_binary_bootstrap64_bin_start, &vma_start, &vma_end); asm volatile("ljmp *(%4)" :: "D"(mbi), "S"(flag), "d"(rm_pointer), "c"(&ptab64_mem_info), "r"(&far_ptr), "m"(far_ptr)); }
void multiboot_main(oskit_addr_t boot_info_pa) { int argc = 0; char **argv = 0; int i; char **ep; /* Copy the multiboot_info structure into our pre-reserved area. This avoids one loose fragment of memory that has to be avoided. */ boot_info = *(struct multiboot_info*)phystokv(boot_info_pa); /* Identify the CPU and get the processor tables set up. */ base_cpu_setup(); /* Initialize the memory allocator and find all available memory. */ base_multiboot_init_mem(); /* Parse the command line into nice POSIX-like args and environment. */ base_multiboot_init_cmdline(&argc, &argv); /* Remove the -d flag because we don't want to be debugged, we want to debug our kids. */ for (i = 0; i < oskit_bootargc; i++) if (strcmp(oskit_bootargv[i], "-d") == 0) { int j; enable_debug_arg = oskit_bootargv[i]; for (j = i; j < oskit_bootargc; j++) oskit_bootargv[j] = oskit_bootargv[j + 1]; oskit_bootargc--; break; } /* Likewise for a "GDB_COM" environment variable. */ for (ep = environ; *ep; ++ep) if (strncmp(*ep, "GDB_COM=", 8) == 0) { enable_debug_arg = *ep; i = 0; do ep[i] = ep[i + 1]; while (ep[i++]); break; } /* Look for a return address. */ for (i = 0; i < oskit_bootargc; i++) if (strcmp(oskit_bootargv[i], "-retaddr") == 0 && i+1 < oskit_bootargc) { return_address = strtoul(oskit_bootargv[i+1], 0, 0); break; } /* Enable interrupts, since we may be using remote gdb. */ sti(); /* Initialize the console */ base_console_init(oskit_bootargc, oskit_bootargv); #ifdef GPROF if (enable_gprof) base_gprof_init(); #endif #ifdef __ELF__ /* Make sure deinit code gets called on exit. */ atexit(__oskit_fini); /* Call init code. */ __oskit_init(); #endif /* Invoke the main program. */ exit(main(argc, argv, environ)); }