Re: Custom boot loader stub
Martin Husemann <[email protected]> Thu, 16 Oct 2025 14:40:24 +0200
| Newsgroups | gmane.os.netbsd.ports.sparc64 |
|---|---|
| Message-ID | <[email protected]> |
On Thu, Oct 16, 2025 at 12:22:36PM +0100, Sad Clouds wrote: > The layout of blocks on disk should look like this: > > 1 2 - 8 => 512-byte sector/block numbers > +----------------+---------------------+ > | Sun Disk Label | bootblk flat binary | > +----------------+---------------------+ > 0 511 512 8191 => LBA offsets in bytes > > > The first sector (1) is occupied by Sun disk label, which is padded to > 512 bytes. This must have the correct magic value, etc, otherwise > OpenBoot reports errors. > > Sectors 2 - 8 contain bootblk binary, which can be maximum 7.5 KiB in > size. Although I'm not sure how OpenBoot figures out its size so it can > correctly map text and data segments in memory for execution. That "flat binary" in our case is /usr/mdec/bootblk -r-xr-xr-x 1 builds builds 7550 Apr 25 09:58 bootblk* which is a tokenized FCode object file (created by $TOOLDIR/bin/nbfgen from the source I referenced earlier, src/sys/arch/sparc/stand/bootblk/bootblk.fth with a bit of constants generated automatically) > hexdump -C bootblk | head 00000000 fd 08 b4 9e 00 00 1d 7e cc a5 b6 0b 62 6f 6f 74 |.......~....boot| 00000010 2d 64 65 62 75 67 3f 08 00 b8 b6 02 4b 42 08 01 |-debug?.....KB..| 00000020 b7 10 00 00 04 00 20 c2 12 07 2f 63 68 6f 73 65 |...... .../chose| 00000030 6e 02 04 34 14 00 1a 12 13 43 61 6e 6e 6f 74 20 |n..4.....Cannot | 00000040 66 69 6e 64 20 2f 63 68 6f 73 65 6e 90 a5 b2 b6 |find /chosen....| 00000050 0e 63 68 6f 73 65 6e 2d 70 68 61 6e 64 6c 65 08 |.chosen-phandle.| 00000060 02 ba 12 19 2f 6f 70 65 6e 70 72 6f 6d 2f 63 6c |..../openprom/cl| 00000070 69 65 6e 74 2d 73 65 72 76 69 63 65 73 02 04 34 |ient-services..4| 00000080 14 00 24 12 1b 43 61 6e 6e 6f 74 20 66 69 6e 64 |..$..Cannot find| 00000090 20 63 6c 69 65 6e 74 2d 73 65 72 76 69 63 65 73 | client-services| and as far as I can tell it just finds the /ofwboot binary file and loads it into memory, then evaluates it. I can't see any ELF or a.out specific handling in there, so I guess OF must do binary format interpretation. Uwe certainly can tell us this in more details and w/o guessing. Martin