Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 08 Dec 2008 20:48:35 -0800
From:      Maxim Sobolev <sobomax@FreeBSD.org>
To:        Luigi Rizzo <rizzo@iet.unipi.it>
Cc:        Luigi Rizzo <luigi@FreeBSD.org>, hackers@FreeBSD.org, "current@freebsd.org" <current@FreeBSD.org>
Subject:   Re: Enhancing cdboot [patch for review]
Message-ID:  <493DF8A3.6070905@FreeBSD.org>
In-Reply-To: <20081209034456.GA54569@onelab2.iet.unipi.it>
References:  <493DA269.2070805@FreeBSD.org> <20081208235119.GA46608@onelab2.iet.unipi.it> <493DBBD0.5080705@FreeBSD.org> <20081209034456.GA54569@onelab2.iet.unipi.it>

next in thread | previous in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?493DF8A3.6070905>