Print this page
loader: pass args along to unix in C
There's no reason why we can't pass the args gotten from the bootloader to
unix in C.
Note: loader's _start sets the ATAG pointer to 0x100.  This change simply
propagates it to unix.
bcm2835: we need a loader on this platform as well
As stated before, the Raspberry Pi loader is terrible.  It claims to
supporte ELF file loading, but what it does is crazy.  It loads the ELF file
into memory, gets the start address from the header, converts it into file
offset, adds it to the address where the file was loaded and jumps there.
This is very wrong.  So, instead of booting the loader as an ELF file, we
objcopy it into a plain ol' binary image.  This should be safe because (1)
the loader has no relocations left, (2) whatever benefit we lose from not
having the whole ELF file in memory is only temporary until the loader hands
off control to unix.
Finally, we force the entry point to appear at the beginning of the binary
file by moving _start into its own section (.text.init) and using the
mapfile to put that section before everything else.

*** 9,27 **** * http://www.illumos.org/license/CDDL. */ /* * Copyright 2013 (c) Joyent, Inc. All rights reserved. */ /* * Every story needs a beginning, this is the loader's. */ #include <sys/asm_linkage.h> ! ENTRY(_start) mov sp, #0x8000 /* * XXX manually fix up the tag start */ mov r2, #0x100 --- 9,36 ---- * http://www.illumos.org/license/CDDL. */ /* * Copyright 2013 (c) Joyent, Inc. All rights reserved. + * Copyright 2015 (c) Josef 'Jeff' Sipek <jeffpc@josefsipek.net> */ /* * Every story needs a beginning, this is the loader's. */ #include <sys/asm_linkage.h> ! /* ! * We put _start into the .text.init section so we can more easily shove it ! * at the front of the .text. ! */ ! .section .text.init ! .align 4 ! .globl _start ! .type _start, %function ! _start: mov sp, #0x8000 /* * XXX manually fix up the tag start */ mov r2, #0x100
*** 100,110 **** SET_SIZE(fakeload_mmu_enable) #endif /* __lint */ ENTRY(fakeload_exec) ! mov r4, r0 ! mov r2, #0x100 ! blx r4 /* We should never execute this. If we do we'll go back to a panic */ bx lr SET_SIZE(fakeload_exec) --- 109,117 ---- SET_SIZE(fakeload_mmu_enable) #endif /* __lint */ ENTRY(fakeload_exec) ! blx r3 /* We should never execute this. If we do we'll go back to a panic */ bx lr SET_SIZE(fakeload_exec)