2003-05-05 11:32:25

by S-n-e-a-k-e-r

[permalink] [raw]
Subject: questions regarding arch/i386/boot/setup.S

I write this to the kernel mailing list, because my question couldn't be
answered on irc (eg. irc.kernelnewbie.org):
____________________________________________________________________________
arch/i386/boot/setup.S:

164 trampoline: call start_of_setup
165 .space 1024
166 # End of setup header
#####################################################
167
168 start_of_setup:
169 # Bootlin depends on this being done early
170 movw $0x01500, %ax
____________________________________________________________________________
my questions are:

-) Why is there a call on line 164 and not a jmp?
-) Why does line 165 reserve 1024 bytes? what is it for?
-) On line 170: Why $0x01500 and not $0x1500?

I would appreciate if someone could answer this mail, or if someone can
provide ressources where I can find detailed description of the kernel code
(didn't find anything, just overall information)

regards,

andy

--
+++ GMX - Mail, Messaging & more http://www.gmx.net +++
Bitte l?cheln! Fotogalerie online mit GMX ohne eigene Homepage!


2003-05-05 12:46:17

by Richard B. Johnson

[permalink] [raw]
Subject: Re: questions regarding arch/i386/boot/setup.S

On Mon, 5 May 2003 [email protected] wrote:

> I write this to the kernel mailing list, because my question couldn't be
> answered on irc (eg. irc.kernelnewbie.org):
> ____________________________________________________________________________
> arch/i386/boot/setup.S:
>
> 164 trampoline: call start_of_setup
> 165 .space 1024
> 166 # End of setup header
> #####################################################
> 167
> 168 start_of_setup:
> 169 # Bootlin depends on this being done early
> 170 movw $0x01500, %ax
> ____________________________________________________________________________
> my questions are:
>
> -) Why is there a call on line 164 and not a jmp?
> -) Why does line 165 reserve 1024 bytes? what is it for?
> -) On line 170: Why $0x01500 and not $0x1500?
>
> I would appreciate if someone could answer this mail, or if someone can
> provide ressources where I can find detailed description of the kernel code
> (didn't find anything, just overall information)
>
> regards,
>
> andy

This is just one of life's little mysteries! Actually, if you
compile the code without the call, or just bypass with a jump
from the start to _start_of_setup, without the jump to trampoline,
it looks like it would sill work. But, LILO will declare that
the kernel is too big (large) because LILO, the usual boot loader,
assumes bad things about the starting code layout. Maybe the new
GRUB boot loader is better behaved, but the image, bzImage needs
to be able to do several things in addition to the obvious.

(1) Copy bzImage to a floppy and the floppy will boot.
(2) Be able to use `rdev` to modify the boot parameters.
(3) Use bzImage with LILO for a loader.
(4) Use bzImage with GRUB for a loader.
(5) Put the kernel image at it's start address by any other
means (embedded systems) and have it start when control
is passed to it in protected mode.
(5) Boot an intermediate RAM disk in the above circumstances.

All these requirements make it necessary for labels (locations)
to not be changed from the original boot methods. This means that
there may be some strange ways of accomplishing this. FYI, there
are several 'more correct' ways of maintaining the compatibility
of the startup code. If you are an expert in assembly-language,
you might want to clean up this area. I'm sure your help would
be appreciated. However, this stuff gets executed only once during
startup and then the RAM is used for kernel and user memory.
It might not be worthwhile to do very much with it.

Cheers,
Dick Johnson
Penguin : Linux version 2.4.20 on an i686 machine (797.90 BogoMips).
Why is the government concerned about the lunatic fringe? Think about it.

2003-05-05 16:53:08

by Antonio Vargas

[permalink] [raw]
Subject: Re: questions regarding arch/i386/boot/setup.S

On Mon, May 05, 2003 at 01:44:46PM +0200, [email protected] wrote:
> I write this to the kernel mailing list, because my question couldn't be
> answered on irc (eg. irc.kernelnewbie.org):
> ____________________________________________________________________________
> arch/i386/boot/setup.S:
>
> 164 trampoline: call start_of_setup
> 165 .space 1024
> 166 # End of setup header
> #####################################################
> 167
> 168 start_of_setup:
> 169 # Bootlin depends on this being done early
> 170 movw $0x01500, %ax
> ____________________________________________________________________________
> my questions are:
>
> -) Why is there a call on line 164 and not a jmp?
> -) Why does line 165 reserve 1024 bytes? what is it for?
> -) On line 170: Why $0x01500 and not $0x1500?
>
> I would appreciate if someone could answer this mail, or if someone can
> provide ressources where I can find detailed description of the kernel code
> (didn't find anything, just overall information)

Andy, "call" pushes �"eip" into the stack, so later on
you can do "mov [esp],edx" and use edx as a pointer
to this 1024-bytes space.

This is a way to perform pc-relative addressing on
architectures which don't allow it directly such as
i386 (if I remember correctly).

Compare this to, for example, m68k, where
you can do "move label(pc),d0" to perform pc-relative
addressing if "label" is located near the current pc.

Greetz, Antonio.