void __init x86_64_start_kernel(char * real_mode_data) { char *s; clear_bss(); pda_init(0); copy_bootdata(real_mode_data); #ifdef CONFIG_SMP cpu_set(0, cpu_online_map); #endif /* default console: */ if (!strstr(saved_command_line, "console=")) strcat(saved_command_line, " console=tty0"); s = strstr(saved_command_line, "earlyprintk="); if (s != NULL) setup_early_printk(s); #ifdef CONFIG_DISCONTIGMEM s = strstr(saved_command_line, "numa="); if (s != NULL) numa_setup(s+5); #endif #ifdef CONFIG_X86_IO_APIC if (strstr(saved_command_line, "disableapic")) disable_apic = 1; #endif /* You need early console to see that */ if (__pa_symbol(&_end) >= KERNEL_TEXT_SIZE) panic("Kernel too big for kernel mapping\n"); setup_boot_cpu_data(); start_kernel(); }
void mem_init(struct multiboot_info *mb) { uint64_t max_avail = 0; multiboot_module_t *kernel; size_t i; /* the loader should really do this for us */ clear_bss(); for (i = 0; i < mb->mmap_length; i += sizeof(multiboot_memory_map_t)) { multiboot_memory_map_t *m; m = (multiboot_memory_map_t *)(mb->mmap_addr + i); max_addr = m->addr + m->len; if ( m->type == MULTIBOOT_MEMORY_AVAILABLE ) max_avail = max_addr; } kernel = (multiboot_module_t *)((uint64_t)mb->mods_addr); kernel_start = kernel->mod_start; kernel_end = kernel->mod_end; page_table_area = (kernel_end & PAGE_MASK) + PAGE_SIZE; page_bitmap_init(mb->mmap_addr, mb->mmap_length); heap_start = (page_bitmap_area + PGBITS_SIZE(max_addr) + PAGE_SIZE - 1) & PAGE_MASK; heap_top = heap_start; allocate_stack(max_avail - 8); }
static void sys_reset(void) { copy_initialized(); clear_bss(); main(); while(1); }
void __init x86_64_start_kernel(char * real_mode_data) { int i; /* clear bss before set_intr_gate with early_idt_handler */ clear_bss(); /* Make NULL pointers segfault */ zap_identity_mappings(); for (i = 0; i < IDT_ENTRIES; i++) set_intr_gate(i, early_idt_handler); load_idt((const struct desc_ptr *)&idt_descr); early_printk("Kernel alive\n"); for (i = 0; i < NR_CPUS; i++) cpu_pda(i) = &boot_cpu_pda[i]; pda_init(0); copy_bootdata(__va(real_mode_data)); #ifdef CONFIG_SMP cpu_set(0, cpu_online_map); #endif start_kernel(); }
void __init x86_64_start_kernel(char * real_mode_data) { char *s; clear_bss(); pda_init(0); copy_bootdata(real_mode_data); /* default console: */ if (!strstr(saved_command_line, "console=")) strcat(saved_command_line, " console=tty0"); s = strstr(saved_command_line, "earlyprintk="); if (s != NULL) setup_early_printk(s+12); #ifdef CONFIG_DISCONTIGMEM s = strstr(saved_command_line, "numa="); if (s != NULL) numa_setup(s+5); #endif #ifdef CONFIG_X86_IO_APIC if (strstr(saved_command_line, "disableapic")) disable_apic = 1; #endif setup_boot_cpu_data(); start_kernel(); }
extern "C" void _start(uint32 _unused1, uint32 _unused3, void *openFirmwareEntry) { // According to the PowerPC bindings, OpenFirmware should have created // a stack of 32kB or higher for us at this point clear_bss(); call_ctors(); // call C++ constructors before doing anything else start(openFirmwareEntry); }
static void sys_reset(void) { copy_initialized(); clear_bss(); enable_fault_exceptions(); start_hse_clock(); use_pll(); main(); while(1); }
void x86_64_start_kernel(char * real_mode_data) { extern void kinit(); clear_bss(); /* must be the first thing in C and must not depend on .bss to be zero */ early_printk("booting amd64 k42...\n"); copy_bootdata(real_mode_data); setup_boot_cpu_data(); pda_init(0); kinit(); }
extern "C" uint32 _start(uint64 handle, uint64 entry, uint32 _unused, uint32 signature) { if (signature != CFE_EPTSEAL) return 123;//XXX:something? clear_bss(); call_ctors(); // call C++ constructors before doing anything else //return 456; start(handle, entry); }
asmlinkage __visible void __init x86_64_start_kernel(char * real_mode_data) { int i; /* * Build-time sanity checks on the kernel image and module * area mappings. (these are purely build-time and produce no code) */ BUILD_BUG_ON(MODULES_VADDR < __START_KERNEL_map); BUILD_BUG_ON(MODULES_VADDR - __START_KERNEL_map < KERNEL_IMAGE_SIZE); BUILD_BUG_ON(MODULES_LEN + KERNEL_IMAGE_SIZE > 2*PUD_SIZE); BUILD_BUG_ON((__START_KERNEL_map & ~PMD_MASK) != 0); BUILD_BUG_ON((MODULES_VADDR & ~PMD_MASK) != 0); BUILD_BUG_ON(!(MODULES_VADDR > __START_KERNEL)); BUILD_BUG_ON(!(((MODULES_END - 1) & PGDIR_MASK) == (__START_KERNEL & PGDIR_MASK))); BUILD_BUG_ON(__fix_to_virt(__end_of_fixed_addresses) <= MODULES_END); cr4_init_shadow(); /* Kill off the identity-map trampoline */ reset_early_page_tables(); clear_bss(); clear_page(init_level4_pgt); kasan_early_init(); for (i = 0; i < NUM_EXCEPTION_VECTORS; i++) set_intr_gate(i, early_idt_handler_array[i]); load_idt((const struct desc_ptr *)&idt_descr); copy_bootdata(__va(real_mode_data)); /* * Load microcode early on BSP. */ load_ucode_bsp(); /* set init_level4_pgt kernel high mapping*/ init_level4_pgt[511] = early_level4_pgt[511]; x86_64_start_reservations(real_mode_data); }
void __init x86_64_start_kernel(char * real_mode_data) { int i; /* * Build-time sanity checks on the kernel image and module * area mappings. (these are purely build-time and produce no code) */ BUILD_BUG_ON(MODULES_VADDR < KERNEL_IMAGE_START); BUILD_BUG_ON(MODULES_VADDR-KERNEL_IMAGE_START < KERNEL_IMAGE_SIZE); BUILD_BUG_ON(MODULES_LEN + KERNEL_IMAGE_SIZE > 2*PUD_SIZE); BUILD_BUG_ON((KERNEL_IMAGE_START & ~PMD_MASK) != 0); BUILD_BUG_ON((MODULES_VADDR & ~PMD_MASK) != 0); BUILD_BUG_ON(!(MODULES_VADDR > __START_KERNEL)); BUILD_BUG_ON(!(((MODULES_END - 1) & PGDIR_MASK) == (__START_KERNEL & PGDIR_MASK))); BUILD_BUG_ON(__fix_to_virt(__end_of_fixed_addresses) <= MODULES_END); /* clear bss before set_intr_gate with early_idt_handler */ clear_bss(); /* Make NULL pointers segfault */ zap_identity_mappings(); /* Cleanup the over mapped high alias */ cleanup_highmap(); for (i = 0; i < NUM_EXCEPTION_VECTORS; i++) { #ifdef CONFIG_EARLY_PRINTK set_intr_gate(i, &early_idt_handlers[i]); #else set_intr_gate(i, early_idt_handler); #endif } load_idt((const struct desc_ptr *)&idt_descr); early_printk("Kernel alive\n"); x86_64_init_pda(); early_printk("Kernel really alive\n"); x86_64_start_reservations(real_mode_data); }
void __init x86_64_start_kernel(char * real_mode_data) { int i; /* * Build-time sanity checks on the kernel image and module * area mappings. (these are purely build-time and produce no code) */ /* 문제 있으면 BUILD_BUG_ON 매크로로 컴파일시 에러가 뜬다. */ /* 커널 이미지 크기가 커서 모듈 주소를 침범하면 에러발생 */ BUILD_BUG_ON(MODULES_VADDR < KERNEL_IMAGE_START); BUILD_BUG_ON(MODULES_VADDR-KERNEL_IMAGE_START < KERNEL_IMAGE_SIZE); BUILD_BUG_ON(MODULES_LEN + KERNEL_IMAGE_SIZE > 2*PUD_SIZE); BUILD_BUG_ON((KERNEL_IMAGE_START & ~PMD_MASK) != 0); BUILD_BUG_ON((MODULES_VADDR & ~PMD_MASK) != 0); BUILD_BUG_ON(!(MODULES_VADDR > __START_KERNEL)); BUILD_BUG_ON(!(((MODULES_END - 1) & PGDIR_MASK) == (__START_KERNEL & PGDIR_MASK))); BUILD_BUG_ON(__fix_to_virt(__end_of_fixed_addresses) <= MODULES_END); /* clear bss before set_intr_gate with early_idt_handler */ /* bss 초기화 (__bss_start부터 __bss_stop) */ clear_bss(); /* Make NULL pointers segfault */ zap_identity_mappings(); max_pfn_mapped = KERNEL_IMAGE_SIZE >> PAGE_SHIFT; /* 512M / 4K 매핑되는 최대 페이지 프레임 넘버*/ /* 예외 처리 인터럽트들 설정 */ for (i = 0; i < NUM_EXCEPTION_VECTORS; i++) { #ifdef CONFIG_EARLY_PRINTK set_intr_gate(i, &early_idt_handlers[i]); /* 인터럽트 예외처리 루틴들을 쓴다. */ #else set_intr_gate(i, early_idt_handler); #endif } load_idt((const struct desc_ptr *)&idt_descr); /* lidt로 interrupt descriptor table을 읽어온다. */ if (console_loglevel == 10) early_printk("Kernel alive\n"); x86_64_start_reservations(real_mode_data); }
void __init x86_64_start_kernel(char * real_mode_data) { char *s; clear_bss(); /* must be the first thing in C and must not depend on .bss to be zero */ pda_init(0); copy_bootdata(real_mode_data); s = strstr(saved_command_line, "earlyprintk="); if (s != NULL) setup_early_printk(s+12); #ifdef CONFIG_DISCONTIGMEM extern int numa_setup(char *); s = strstr(saved_command_line, "numa="); if (s != NULL) numa_setup(s+5); #endif early_printk("booting x86_64 kernel... "); setup_boot_cpu_data(); start_kernel(); }
/* * init_cpu() - intialise the CPU * * This function initialises those parts of the CPU that have not already been * initialised by the assembler code in rom-entry. This function is called before * the bss and data sections are initialised, because the RAM may not be visible * until the initialisation done here. * * On Tricore we can intialise almost everything - except the SDRAM controller * and the context management systems. * * Assumptions: interrupts are disabled globally. ENDINIT is clear. */ void init_cpu(void) { /* Initialise the BCU and EBU */ BCU->bcu_bcucon = INIT_BCUCON; EBU->ebu_ebucon = INIT_EBUCON; /* We only initialise the chip selects that have address ranges defined. */ #if defined(INIT_ADDSEL0) && defined(INIT_BUSCON0) EBU->ebu_addsel0 = INIT_ADDSEL0; EBU->ebu_buscon0 = INIT_BUSCON0; #endif #if defined(INIT_ADDSEL1) && defined(INIT_BUSCON1) EBU->ebu_addsel1 = INIT_ADDSEL1; EBU->ebu_buscon1 = INIT_BUSCON1; #endif #if defined(INIT_ADDSEL2) && defined(INIT_BUSCON2) EBU->ebu_addsel2 = INIT_ADDSEL2; EBU->ebu_buscon2 = INIT_BUSCON2; #endif #if defined(INIT_ADDSEL3) && defined(INIT_BUSCON3) EBU->ebu_addsel3 = INIT_ADDSEL3; EBU->ebu_buscon3 = INIT_BUSCON3; #endif /* From here we can assume that all external memory and I/O is visible * on the bus. * We set the CPU clock frequency here. This function should be called with * ENDINIT set, since it manipulates ENDINIT as required. */ cpu_clock_rate(CLOCK_RATE); /* Now we're running at full speed, we can zero the bss section and * copy the ROM image of the data section out to RAM */ #if 0 /* FIXME: running in RAM at the moment */ clear_bss(); copy_data(); #endif }
static void sys_reset(void) { unsigned int volatile *d; d = dummy; /* turn on the internal oscillator */ RCC->CR |= RCC_CR_HSION; /* turn off the external oscillator, the clock security system, and the PLL */ RCC->CR &= (uint32_t)0xFEF6FFFF; /* disable and clear any pending interrupts */ RCC->CIR = RCC_CIR_LSIRDYC | RCC_CIR_LSERDYC | RCC_CIR_HSIRDYC | RCC_CIR_HSERDYC | RCC_CIR_PLLRDYC | RCC_CIR_CSSC; /* turn on the flash pre-fetch buffer and set its wait state to 2 */ FLASH->ACR |= FLASH_ACR_PRFTBE; FLASH->ACR = (FLASH->ACR & ~FLASH_ACR_LATENCY) | FLASH_ACR_LATENCY_2; copy_initialized(); clear_bss(); enable_fault_exceptions(); clock_config(); start_hse_clock(); flash_config(); use_pll(); main(); while(1); }
void pi_start(void) { #warning IMPLEMENT _start stage2_args args; clear_bss(); call_ctors(); cpu_init(); gpio_init(); // Flick on "OK" led GPIO_CLR(16); mmu_init(); serial_init(); console_init(); args.heap_size = HEAP_SIZE; args.arguments = NULL; main(&args); }
/* init5272 -- * Initialize MCF5272 on-chip modules * * PARAMETERS: * none * * RETURNS: * none */ void init5272(void) { extern void clear_bss(void); extern void start_csb360(void); /* Invalidate the cache - WARNING: It won't complete for 64 clocks */ m68k_set_cacr(MCF5272_CACR_CINV); /* Set Module Base Address register */ m68k_set_mbar((BSP_MBAR & MCF5272_MBAR_BA) | MCF5272_MBAR_V); /* Set RAM Base Address register */ m68k_set_srambar((BSP_RAMBAR & MCF5272_RAMBAR_BA) | MCF5272_RAMBAR_V); /* Set System Control Register: * Enet has highest priority, 16384 bus cycles before timeout */ g_sim_regs->scr = (MCF5272_SCR_HWR_16384); /* System Protection Register: * Enable Hardware watchdog timer. */ g_sim_regs->spr = MCF5272_SPR_HWTEN; /* Clear and mask all interrupts */ g_intctrl_regs->icr1 = 0x88888888; g_intctrl_regs->icr2 = 0x88888888; g_intctrl_regs->icr3 = 0x88888888; g_intctrl_regs->icr4 = 0x88880000; /* Copy the interrupt vector table to SRAM */ { extern void INTERRUPT_VECTOR(); uint32_t *inttab = (uint32_t *)&INTERRUPT_VECTOR; uint32_t *intvec = (uint32_t *)BSP_RAMBAR; register int i; for (i = 0; i < 256; i++) { *(intvec++) = *(inttab++); } } m68k_set_vbr(BSP_RAMBAR); /* * Setup ACRs so that if cache turned on, periphal accesses * are not messed up. (Non-cacheable, serialized) */ m68k_set_acr0(MCF5272_ACR_BASE(BSP_MEM_ADDR_SDRAM) | MCF5272_ACR_MASK(BSP_MEM_MASK_SDRAM) | MCF5272_ACR_EN | MCF5272_ACR_SM_ANY); /* m68k_set_acr1 (MCF5206E_ACR_BASE(BSP_MEM_ADDR_FLASH) | MCF5206E_ACR_MASK(BSP_MEM_MASK_FLASH) | MCF5206E_ACR_EN | MCF5206E_ACR_SM_ANY); */ /* Enable the caches */ m68k_set_cacr(MCF5272_CACR_CENB | MCF5272_CACR_DCM); /* Default is not cached */ /* * Copy data, clear BSS, switch stacks and call boot_card() */ /* CopyDataClearBSSAndStart(BSP_MEM_SIZE_ESRAM - 0x400); */ clear_bss(); start_csb360(); }
extern "C" int start_gen(int argc, const char **argv, struct image_header *uimage, void *fdt) { stage2_args args; clear_bss(); // call C++ constructors before doing anything else call_ctors(); args.heap_size = HEAP_SIZE; args.arguments = NULL; args.arguments_count = 0; args.platform.boot_tgz_data = NULL; args.platform.boot_tgz_size = 0; args.platform.fdt_data = NULL; args.platform.fdt_size = 0; gUImage = uimage; gFDT = fdt; //XXX: make a copy? // TODO: check for atags instead and convert them if (argv) { // skip the kernel name ++argv; --argc; } // TODO: Ensure cmdline is mapped into memory by MMU before usage. // if we get passed a uimage, try to find the third blob // only if we do not have FDT data yet if (gUImage != NULL && !gFDT && image_multi_getimg(gUImage, 2, (uint32*)&args.platform.fdt_data, &args.platform.fdt_size)) { // found a blob, assume it is FDT data, when working on a platform // which does not have an FDT enabled U-Boot gFDT = args.platform.fdt_data; } // We have to cpu_init *before* calling FDT functions cpu_init(); serial_init(gFDT); #if defined(__ARM__) arch_mailbox_init(); #endif // initialize the OpenFirmware wrapper of_init(NULL); console_init(); // if we get passed an FDT, check /chosen for initrd and bootargs if (gFDT != NULL) { int node = fdt_path_offset(gFDT, "/chosen"); const void *prop; int len; phys_addr_t initrd_start = 0, initrd_end = 0; if (node >= 0) { prop = fdt_getprop(gFDT, node, "linux,initrd-start", &len); if (prop && len == 4) initrd_start = fdt32_to_cpu(*(uint32_t *)prop); prop = fdt_getprop(gFDT, node, "linux,initrd-end", &len); if (prop && len == 4) initrd_end = fdt32_to_cpu(*(uint32_t *)prop); if (initrd_end > initrd_start) { args.platform.boot_tgz_data = (void *)initrd_start; args.platform.boot_tgz_size = initrd_end - initrd_start; dprintf("Found boot tgz from FDT @ %p, %" B_PRIu32 " bytes\n", args.platform.boot_tgz_data, args.platform.boot_tgz_size); } // we check for bootargs after remapping the FDT } } // if we get passed a uimage, try to find the second blob if (gUImage != NULL && image_multi_getimg(gUImage, 1, (uint32*)&args.platform.boot_tgz_data, &args.platform.boot_tgz_size)) { dprintf("Found boot tgz from uimage @ %p, %" B_PRIu32 " bytes\n", args.platform.boot_tgz_data, args.platform.boot_tgz_size); } { //DEBUG: int i; dprintf("argc = %d\n", argc); for (i = 0; i < argc; i++) dprintf("argv[%d] @%lx = '%s'\n", i, (uint32)argv[i], argv[i]); dprintf("os: %d\n", (int)gUBootOS); dprintf("gd @ %p\n", gUBootGlobalData); if (gUBootGlobalData) { dprintf("gd->bd @ %p\n", gUBootGlobalData->bd); dprintf("gd->fb_base @ %p\n", (void*)gUBootGlobalData->fb_base); } if (gUImage) dump_uimage(gUImage); if (gFDT) dump_fdt(gFDT); } if (args.platform.boot_tgz_size > 0) { insert_physical_allocated_range((addr_t)args.platform.boot_tgz_data, args.platform.boot_tgz_size); } // save the size of the FDT so we can map it easily after mmu_init size_t fdtSize = gFDT ? fdt_totalsize(gFDT) : 0; dprintf("fdtSize: 0x%" B_PRIxSIZE "\n", fdtSize); mmu_init(); // Handle our tarFS post-mmu if (args.platform.boot_tgz_size > 0) { args.platform.boot_tgz_data = (void*)mmu_map_physical_memory((addr_t) args.platform.boot_tgz_data, args.platform.boot_tgz_size, kDefaultPageFlags); } // .. and our FDT if (gFDT != NULL) gFDT = (void*)mmu_map_physical_memory((addr_t)gFDT, fdtSize, kDefaultPageFlags); // if we get passed an FDT, check /chosen for bootargs now // to avoid having to copy them. if (gFDT != NULL) { int node = fdt_path_offset(gFDT, "/chosen"); const void *prop; int len; if (node >= 0) { prop = fdt_getprop(gFDT, node, "bootargs", &len); if (prop) { dprintf("Found bootargs: %s\n", (const char *)prop); static const char *sArgs[] = { NULL, NULL }; sArgs[0] = (const char *)prop; // override main() args args.arguments = sArgs; args.arguments_count = 1; } } dprintf("args.arguments_count = %" B_PRId32 "\n", args.arguments_count); for (int i = 0; i < args.arguments_count; i++) dprintf("args.arguments[%d] @%lx = '%s'\n", i, (uint32)args.arguments[i], args.arguments[i]); } // wait a bit to give the user the opportunity to press a key // spin(750000); // reading the keyboard doesn't seem to work in graphics mode // (maybe a bochs problem) // sBootOptions = check_for_boot_keys(); //if (sBootOptions & BOOT_OPTION_DEBUG_OUTPUT) serial_enable(); main(&args); return 0; }
void __init x86_64_start_kernel(char * real_mode_data) { int i; /* * Build-time sanity checks on the kernel image and module * area mappings. (these are purely build-time and produce no code) */ BUILD_BUG_ON(MODULES_VADDR < KERNEL_IMAGE_START); BUILD_BUG_ON(MODULES_VADDR-KERNEL_IMAGE_START < KERNEL_IMAGE_SIZE); BUILD_BUG_ON(MODULES_LEN + KERNEL_IMAGE_SIZE > 2*PUD_SIZE); BUILD_BUG_ON((KERNEL_IMAGE_START & ~PMD_MASK) != 0); BUILD_BUG_ON((MODULES_VADDR & ~PMD_MASK) != 0); BUILD_BUG_ON(!(MODULES_VADDR > __START_KERNEL)); BUILD_BUG_ON(!(((MODULES_END - 1) & PGDIR_MASK) == (__START_KERNEL & PGDIR_MASK))); /* clear bss before set_intr_gate with early_idt_handler */ clear_bss(); /* Make NULL pointers segfault */ zap_identity_mappings(); /* Cleanup the over mapped high alias */ cleanup_highmap(); for (i = 0; i < NUM_EXCEPTION_VECTORS; i++) { #ifdef CONFIG_EARLY_PRINTK set_intr_gate(i, &early_idt_handlers[i]); #else set_intr_gate(i, early_idt_handler); #endif } load_idt((const struct desc_ptr *)&idt_descr); early_printk("Kernel alive\n"); for (i = 0; i < NR_CPUS; i++) cpu_pda(i) = &boot_cpu_pda[i]; pda_init(0); copy_bootdata(__va(real_mode_data)); reserve_early(__pa_symbol(&_text), __pa_symbol(&_end), "TEXT DATA BSS"); #ifdef CONFIG_BLK_DEV_INITRD /* Reserve INITRD */ if (boot_params.hdr.type_of_loader && boot_params.hdr.ramdisk_image) { unsigned long ramdisk_image = boot_params.hdr.ramdisk_image; unsigned long ramdisk_size = boot_params.hdr.ramdisk_size; unsigned long ramdisk_end = ramdisk_image + ramdisk_size; reserve_early(ramdisk_image, ramdisk_end, "RAMDISK"); } #endif reserve_ebda_region(); reserve_setup_data(); /* * At this point everything still needed from the boot loader * or BIOS or kernel text should be early reserved or marked not * RAM in e820. All other memory is free game. */ start_kernel(); }
/* * Bootstrap-CPU start; we came from head.S */ void __no_return kernel_start(void) { /* Before anything else, zero the bss section. As said by C99: * “All objects with static storage duration shall be inited * before program startup”, and that the implicit init is done * with zero. Kernel assembly code also assumes a zeroed BSS * space */ clear_bss(); /* * Very-early setup: Do not call any code that will use * printk(), `current', per-CPU vars, or a spin lock. */ setup_idt(); schedulify_this_code_path(BOOTSTRAP); /* * Memory Management init */ print_info(); /* First, don't override the ramdisk area (if any) */ ramdisk_init(); /* Then discover our physical memory map .. */ e820_init(); /* and tokenize the available memory into allocatable pages */ pagealloc_init(); /* With the page allocator in place, git rid of our temporary * early-boot page tables and setup dynamic permanent ones */ vm_init(); /* MM basics done, enable dynamic heap memory to kernel code * early on .. */ kmalloc_init(); /* * Secondary-CPUs startup */ /* Discover our secondary-CPUs and system IRQs layout before * initializing the local APICs */ mptables_init(); /* Remap and mask the PIC; it's just a disturbance */ serial_init(); pic_init(); /* Initialize the APICs (and map their MMIO regs) before enabling * IRQs, and before firing other cores using Inter-CPU Interrupts */ apic_init(); ioapic_init(); /* SMP infrastructure ready, fire the CPUs! */ smpboot_init(); keyboard_init(); /* Startup finished, roll-in the scheduler! */ sched_init(); local_irq_enable(); /* * Second part of kernel initialization (Scheduler is now on!) */ ext2_init(); // Signal the secondary cores to run their own test-cases code. // They've been waiting for us (thread 0) till all of kernel // subsystems has been properly initialized. Wait No More! smpboot_trigger_secondary_cores_testcases(); run_test_cases(); halt(); }
extern "C" int start_raw(int argc, const char **argv) { stage2_args args; clear_bss(); // call C++ constructors before doing anything else call_ctors(); args.heap_size = HEAP_SIZE; args.arguments = NULL; args.platform.boot_tgz_data = NULL; args.platform.boot_tgz_size = 0; args.platform.fdt_data = NULL; args.platform.fdt_size = 0; // if we get passed a uimage, try to find the third blob only if we do not have FDT data yet if (gUImage != NULL && !gFDT && image_multi_getimg(gUImage, 2, (uint32*)&args.platform.fdt_data, &args.platform.fdt_size)) { // found a blob, assume it is FDT data, when working on a platform // which does not have an FDT enabled U-Boot gFDT = args.platform.fdt_data; } serial_init(gFDT); console_init(); cpu_init(); if (args.platform.fdt_data) { dprintf("Found FDT from uimage @ %p, %" B_PRIu32 " bytes\n", args.platform.fdt_data, args.platform.fdt_size); } else if (gFDT) { /* Fixup args so we can pass the gFDT on to the kernel */ args.platform.fdt_data = gFDT; args.platform.fdt_size = fdt_totalsize(gFDT); } // if we get passed an FDT, check /chosen for initrd if (gFDT != NULL) { int node = fdt_path_offset(gFDT, "/chosen"); const void *prop; int len; phys_addr_t initrd_start = 0, initrd_end = 0; if (node >= 0) { prop = fdt_getprop(gFDT, node, "linux,initrd-start", &len); if (prop && len == 4) initrd_start = fdt32_to_cpu(*(uint32_t *)prop); prop = fdt_getprop(gFDT, node, "linux,initrd-end", &len); if (prop && len == 4) initrd_end = fdt32_to_cpu(*(uint32_t *)prop); if (initrd_end > initrd_start) { args.platform.boot_tgz_data = (void *)initrd_start; args.platform.boot_tgz_size = initrd_end - initrd_start; dprintf("Found boot tgz from FDT @ %p, %" B_PRIu32 " bytes\n", args.platform.boot_tgz_data, args.platform.boot_tgz_size); } } } // if we get passed a uimage, try to find the second blob if (gUImage != NULL && image_multi_getimg(gUImage, 1, (uint32*)&args.platform.boot_tgz_data, &args.platform.boot_tgz_size)) { dprintf("Found boot tgz from uimage @ %p, %" B_PRIu32 " bytes\n", args.platform.boot_tgz_data, args.platform.boot_tgz_size); } { //DEBUG: int i; dprintf("argc = %d\n", argc); for (i = 0; i < argc; i++) dprintf("argv[%d] @%lx = '%s'\n", i, (uint32)argv[i], argv[i]); dprintf("os: %d\n", (int)gUBootOS); dprintf("gd @ %p\n", gUBootGlobalData); if (gUBootGlobalData) dprintf("gd->bd @ %p\n", gUBootGlobalData->bd); //dprintf("fb_base %p\n", (void*)gUBootGlobalData->fb_base); if (gUImage) dump_uimage(gUImage); if (gFDT) dump_fdt(gFDT); } mmu_init(); // wait a bit to give the user the opportunity to press a key // spin(750000); // reading the keyboard doesn't seem to work in graphics mode // (maybe a bochs problem) // sBootOptions = check_for_boot_keys(); //if (sBootOptions & BOOT_OPTION_DEBUG_OUTPUT) serial_enable(); main(&args); return 0; }