Hi!
I've done some work on the kernel yesterday (btw, we use 2.6).
As on the x86, the startup code in a PPC kernel looks like this:
1 CPU initialization
2 machine initialization, information gathering through firmware
3 kernel relocation, decompression
4 (formerly compressed code:) kernel initialization
If we use a kernel in this format (bzImage), we have it in compressed
form, and we might not even need a bootloader. Other projects, like
tuxbox (dbox2 Linux), take the kernel in vmlinux.gz form (the
uncompressed code beginning of step 4) and make the bootloader
(ppcboot/u-boot) initialize the machine and decompress the kernel.
So I think we should try bzImage. The handy thing about it is that
compiling the kernel creates an ELF file, which can be loaded by the
"dolwin" GameCube emulator directly, or can easily be converted into
.DOL.
I have put together a kernel configuration that contains only a minimal
set of drivers and disables most of step 2 by using "CONFIG_PCORE" as
the platform, which doesn't do OpenFirmware information gathering (as I
understand the kernel, we have to start from there, creating
CONFIG_GAMECUBE in parallel to CONFIG_PCORE).
The resulting kernel (arch/ppc/boot/images/zImage.elf) is 517 KB in
size. When I run it in dolwin, the first code executes just fine
(dolwin has a nice debugger); then the emulator stays in a (big) loop
for some minutes (i haven't waited longer) - perhaps that's the
relocation, or perhaps it's just terribly wrong.
(The control flow goes like this:
* http://lxr.linux.no/source/arch/ppc/boot/simple/head.S?v=2.6.0
* http://lxr.linux.no/source/arch/ppc/boot/simple/relocate.S?v=2.6.0
* ???
)
What has to be found out is, what code this really is and whether it is
a good thing. If it is, a breakpoint needs to be set afterwards, and
stepping through the kernel needs to be continued there. Since we're
still in a non-paged environment, debug output using GCLIB code should
be possible, so it might also make sense to try on the real thing then.
tmbinc has told me on Monday that he had also done something similar.
Perhaps I have done duplicate work. Well, never mind, let's see. At
least we have some documentation now on where to start in the kernel.
Please feel invited to have a look at this yourselves as well! I have
uploaded the kernel configuration and the zImage.elf to
http://www.gc-linux.org/down/kernel/ - so you can even try stepping
through the kernel without compiling it.
By the way, I use Mandrake 9.1/PPC to compile, if anyone has advice on
how to best cross-compile a kernel on a PC, I think many people would
be interested.
Michael
|