James: (jvh@uclink4.berkeley.edu): Thanks for the hint on loading a Kernel, but:
Now I have a verified routine that loads the kernel (block by block) from my ATA-Disk into memory (at whatever I like. Currently at 0x00010000). I´m loading a zImage at 0x00010000, the bootsect at 0x9000, the setupsectors (4) at 0x9200. It´s just like the other loaders do it ...he?
I have the code like: static void (*v)() =(void *)KERNEL_START;
I start like: v();
and the machine (the openbios) throws me an exception 13. (general Protection Fault errorcode 0).
I tried nearly any combination of stack-location, entry-adress and kerneltype ... all fails ... I now read alot about descriptors and segments and so cause I suspect the problem is somewhere there ...
But I just dont get the point. What am I doing wrong now ?? I thought the kernel would just set up and start?
I figured out that already the jump done with the v(); is the one that causes the exception, no matter if there is a kernel or just dummy code (like: jmp $).
There must be something I misunderstood completely !! Help, I´m lost ...
greetinx, J.Winter
- To unsubscribe: send mail to majordomo@freiburg.linux.de with 'unsubscribe openbios' in the body of the message
As I understand it, the zImage has a whole lot of junk to boot the kernel at the start and it is compressd, so you can't just read it and jump to it. You first have to uncompress zImage (just gunzip zImage, I forget if you have to rename zImage zImage.gz). You then must strip the kernel's boot code. I always did this in a script like: objcopy -O binary -R .note -R .comment -S vmlinux /tmp/$$-tmp-linux You then must regunzip the image in a format that your gunzip program can read: gzip -f -3 /tmp/$$-tmp-linux
You must then use some C code (like inflate.c provided with the linux kernel (which is the same inflate.c from openbios)) to inflate the image. This is kinda tricky. I do it by first copying the image in at something like 0x20000 and then uncompressing that image to 0x100000 and then jumping to 0x100000. Oh yeah; the kernel won't just boot completely, it will get to somewhere (I think the bogomips test) and die because it is missing interrupts or something like that.
You may want to start more basically by taking the zImage, uncompressing it, stripping it, and then copying the big, uncompressed image straight to 0x100000 and jumping there.
- James
On Sat, 12 Feb 2000, [iso-8859-1] Winter J�rg wrote:
James: (jvh@uclink4.berkeley.edu): Thanks for the hint on loading a Kernel, but:
Now I have a verified routine that loads the kernel (block by block) from my ATA-Disk into memory (at whatever I like. Currently at 0x00010000). I�m loading a zImage at 0x00010000, the bootsect at 0x9000, the setupsectors (4) at 0x9200. It�s just like the other loaders do it ...he?
I have the code like: static void (*v)() =(void *)KERNEL_START;
I start like: v();
and the machine (the openbios) throws me an exception 13. (general Protection Fault errorcode 0).
I tried nearly any combination of stack-location, entry-adress and kerneltype ... all fails ... I now read alot about descriptors and segments and so cause I suspect the problem is somewhere there ...
But I just dont get the point. What am I doing wrong now ?? I thought the kernel would just set up and start?
I figured out that already the jump done with the v(); is the one that causes the exception, no matter if there is a kernel or just dummy code (like: jmp $).
There must be something I misunderstood completely !! Help, I�m lost ...
greetinx, J.Winter
To unsubscribe: send mail to majordomo@freiburg.linux.de with 'unsubscribe openbios' in the body of the message
- To unsubscribe: send mail to majordomo@freiburg.linux.de with 'unsubscribe openbios' in the body of the message
James wrote:
As I understand it, the zImage has a whole lot of junk to boot the kernel at the start and it is compressd, so you can't just read it and jump to it.
Sure you can, as long as the right boot code is attached. The final stage of the kernel build looks something like
make vmlinux make bootcode gzip -9 vmlinux cat bootcode vmlinux.gz > zImage
You can jump directly to zImage, which will trigger the uncompress code.
If you use the "make zdisk" target, Linux will boot straight from a floppy:
dd if=zdisk of=/dev/fd0
Regards,
Jeff
On Sat, 12 Feb 2000, Jeff Garzik wrote:
Sure you can, as long as the right boot code is attached. The final stage of the kernel build looks something like
make vmlinux make bootcode gzip -9 vmlinux cat bootcode vmlinux.gz > zImage
what a zimage is (in short): 1) 512 bytes of floppy boot block 2) 2048 bytes of secondary boot block. 3) linux kernel startup, with an uncompressed header and a compressed image. The uncompressed header does the gunzip. Since we use openbios gunzip, one of these two gunzips is useless and should be removed. For linuxbios we opt to remove the linux kernel gunzip -- it's dead code after boot, so why put it in? saves a few bytes.
startup: If you're on floppy, the first 512 bytes are read, which reads the second 2048 bytes, which reads the kernel. The start of the kernel is some setup and the 'unzipper'.
If you're on hard drive the standard booters skip the first 512 bytes and go for the secondary bootstrap.
When we build a kernel for bios, we just compress vmlinux itself, minus all the unzippers. I'm going to put this tree on the web page tomorrow.
Sorry if this is too short, isdn is screwing me up again.
ron
- To unsubscribe: send mail to majordomo@freiburg.linux.de with 'unsubscribe openbios' in the body of the message