Hi, On Thu, Dec 29, 2011 at 11:20 PM, David Laight <da...@l8s.co.uk> wrote: > On Thu, Dec 29, 2011 at 07:55:18PM +0100, Antoine LECA wrote: >> >> David Laight wrote: >> > The actual 'pc' boot sequence is: >> > Stages 1-3 (and maybe 4) are common to all OS. >> <...> >> > 3) The pbr code has to determine where it was loaded from, it could: >> > a) reread sector zero and look for a partition of the relevant type >> > b) have the sector number previously written into the sector data. >> >> c) >> > The netbsd bootselect mbr passes the sector number in a register >> > (non-standard) and the pbr code scans the partitions looking for >> > one that starts in the correct place. > ... >> I am not sure whether NetBSD currently uses a or c (or a combination of >> both); ... > > Last time I rewrote it, it reread the mbr and located the partition > (following the extended/logical partition chain) looking for the > one that starts in the sector passed in (IIRC) %esi. If not found > it rescans looking for thr first netbsd partition. > > I used %esi because it reduced the number of instructions in the mbr! > The mbr is a work of art!
Magic too :-) I fall into trouble with it. In generated listing (mbr.S): 518 00f1 E9FE7B jmp BOOTADDR In obj file: f1: e9 fe 7b 5a 8a jmp 8a5a7cf4 <bss_end+0x8a5a76e4> In mbr (i.e. after linking): 00000f0 5a e9 0c f3 5a 8a 74 01 ^^^^ Address has changed. I'm porting mbr to MINIX and address isn't changed there. What does happen in NetBSD on linking stage? -- Evgeniy