|
|
About
TODO
Blog
RSS
Old blog
Projects
Gallery
Notes
Mon, 28 May 2007
I know kung-fu or how to write your own bootlaoder.
I never did that before, so it is completely new task for me.
My testing system is SuperH board, which already has initial bootloader,
which jumps into MBR of the compact flash for execution. I found LILO
port for SuperH CPU, but it does not work (and all
documentation is in japanese,
and google can not translate that page), which required very old LILO
versions, since recent ones (22 and higher) just write x86 boot sector
into MBR no matter what you ask it to do (i.e. what boot.b
is being used). So obvious step from my point of view is to write own
bootloader.
"How is it supposed to work?" - I asked myself and found an answer -
it will be pretty small stuff without several stages like in LILO
or GRUB, my bootloader will just read fixed size Linux kernel image from fixed
offset into memory and jump into it, it is quite simple task since the whole
initialization and helper code is already written and stored on the NAND flash
in IPL (Initial Program Loader).
My code, which starts from MBR and prints greeting message into serial port for that board is very simple (not including
initialization of the base registers):
mova message, r0
mov r0, r4
mov #17, r5
mov #0, r0
trapa #0x3f
SuperH asm is a bit fun sometimes compared to x86 and ppc (small) bits I know.
It is so simple because of IPL-SH code running from the NAND flash (Initial Program Loader),
which handles exceptions (trapa traps an execption). Read sector calls (very
similar to x86 BIOS ones) are handled exacltly the same way in LILO port.
I will start with reading and running simple code from Compact Flash, and then will move
tothe real kernel.
Because of this hacks I have not moved to climbing area today, which is quite a bit of crap,
but I could not resist...
/devel/sh :: Link / Comments (0)
Please solve this captcha to be allowed to post (need to reload in a minute): 13 - 5
|