Re: Enhancing cdboot [patch for review]

From: Maxim Sobolev <sobomax_at_FreeBSD.org>
Date: Mon, 08 Dec 2008 20:48:35 -0800
Luigi Rizzo wrote:
> On Mon, Dec 08, 2008 at 04:29:04PM -0800, Maxim Sobolev wrote:
>> Luigi Rizzo wrote:
> ...
>>> 4. another nitpick -- the value you pass in %si to the MBR does not
>>>   seem to point to anything useful. As discussed about boot0.S and
>>>   the followup in the mailing lists, there seems to be no standard
>>>   but at least some MBR expect %si to point to a partition entry,
>>>   so you should probably initialize one in a way similar way to that
>>>   used by boot0.S
>> Hmm, maybe I misunderstood it then. What do you mean by "point to 
>> partition entry exactly"? Right now it points to the beginning on MBR.
> 
> ok, so here is what I know.
> 
> Even though there is no standard, at least ldlinux.sys and perhaps
> other bootloaders expect %si to point to a 16-byte record containing
> the partition descriptor (same structure as one of the 4 records
> at 0x1be in the MBR) for the partition they were loaded from.
> 
> ldlinux.sys uses this info to "relocate": it knows the location of the
> other sectors of ldlinux.sys relative to the beginning of the partition,
> and uses the start-of-partition from the record at %si to compute
> these locations in terms of absolute disk positions.
> 
> Note that in principle a MBR does not need this info -- even if it
> is a multi-sector boot code such as boot0ext, it may well assume to
> be located at offset 0.
> 
> On the other hand if the code on the MBR uses %si, then you should
> set the entry so that at least the starting CHS and LBA info point
> to the first sector on disk, i.e. CHS=0,0,1 and LBA=0.
> 
> In practical terms -- make %si point to a 16-byte area of memory
> containing all 0's except for the byte representing the sector
> number for the start of the partition.
> See the code in a recent sys/boot/i386/boot0/boot0.S which gives
> some details on this.

I see, thank you for the explanation. It looks like it only makes sense 
for multi-stage boot loaders, when the stage has been loaded from some 
location within the disk and it needs some clue to determine where it 
has came from. In this case we simply emulate BIOS loading MBR, and from 
what I've read here MBR code should make no assumptions with regard to 
%si, so that I would just set it to zero. Do you think it could create 
any issues?

-Maxim
Received on Tue Dec 09 2008 - 03:49:10 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:39:38 UTC