uCLinuxxuyuanchao@263.nethttp://xuyuanchao.ie.cnu.edu.cn
blobSrc/blob/start.S
Blobstart.sl KB0x00000000FlashS3C44B0BlobFlashSDRAM lKBtrampoline.sSDRAM63KBtrampolineBSSmain.c.
relocate: adr r0, _start
/* relocate the second stage loader */ add r2, r0, #(64 * 1024) /* blob maximum size is 64kB */ add r0, r0, #0x400 ldr r1, BLOB_START
/* r0 = source address * r1 = target address * r2 = source end address */copy_loop: ldmia r0!, {r3-r10} stmia r1!, {r3-r10} cmp r0, r2 ble copy_loop
adr r0, real_vectors add r2, r0, #1024 ldr r1, =0x0c000000 add r1, r1, #0x08vector_copy_loop: ldmia r0!, {r3-r10} stmia r1!, {r3-r10} cmp r0, r2 ble vector_copy_loop
/* turn off the LED. if it stays off it is an indication that * we didn't make it into the C code *//* bl led_off */
/* blob is copied to ram, so jump to it */ ldr r0, BLOB_START mov pc, r0
Trampoline.S mrs r0, cpsr bic r0, r0, #0x80 msr cpsr, r0
/* jump to C code */ bl main /* if main ever returns we just call it again */ b _trampoline
Main.c /* wait 10 seconds before starting autoboot */ SerialOutputString("Autoboot in progress, press any key to stop "); for(i = 0; i < blob_status.boot_delay; i++) { serial_write('.');
retval = SerialInputBlock(commandline, 1, 1); if(retval > 0) break; }
/* no key was pressed, so proceed booting the kernel */ if(retval == 0) { commandline[0] = '\0'; parse_command("boot"); }
Linux.cstatic int boot_linux(int argc, char *argv[]){ void (*theKernel)(int zero, int arch) = (void (*)(int, int))KERNEL_RAM_BASE;
clif(); setup_start_tag(); setup_memory_tags(); setup_commandline_tag(argc, argv); setup_initrd_tag(); setup_ramdisk_tag(); setup_end_tag();
/* we assume that the kernel is in place */ SerialOutputString("\nStarting kernel ...\n\n"); serial_flush_output();
/* disable subsystems that want to be disabled before kernel boot */ exit_subsystems();
/* start kernel */ theKernel(0, ARCH_NUMBER);
SerialOutputString("Hey, the kernel returned! This should not happen.\n");
return 0;}
Linux 2.4.x (tagged list) ATAG_CORE ATAG_NONE tag_header Linux Boot Loader ATAG_CORE ATAG_MEMATAG_CMDLINEATAG_RAMDISKATAG_INITRD.
1 CPU R00@R1 ID@R2 RAM 2 CPU IRQsFIQsCPU SVC 3 Cache MMU MMU Cache Cache .
ROMdecompress_kernel()misc.cmisc.cuClinux-2.4.x\arch\armnommu\boot\compressed
initinit
rest_initstatic void rest_init(void){kernel_thread(init, NULL, CLONE_FS | CLONE_FILES | CLONE_SIGNAL); //kernel_threadinit,main.cinitunlock_kernel(); //current->need_resched = 1; //need_resched1 cpu_idle(); //init,init()}
Initdo_basic_setup()init()prepare_namespace()rootRAMDISKinit()free_initmem()/dev/consoleexecveshellinit