Custom boot loader stub
Sad Clouds <[email protected]> Wed, 15 Oct 2025 08:24:05 +0100
| Newsgroups | gmane.os.netbsd.ports.sparc64 |
|---|---|
| Message-ID | <[email protected]> |
Hello, I'm attempting to design a small boot loader stub for sparc64 which can be loaded by OpenBoot and then it simply prints a test message. I'm not sure about a few items and if anyone could provide comments or suggestions, I would appreciate it. 1. Disk label I think sector 0 on boot disk must have a valid disk label, otherwise OpenBoot will refuse to load boot loader and print "invalid label" error. On Illumos/Solaris this seems to be defined in: src/uts/common/sys/vtoc.h So if I simply write a fake label to sector 0, then OpenBoot should start loading my code from sector 1. Each sector is 512 bytes. Is all of this correct? 2. Binary format Some information I've read states that the binary OpenBoot loads must be in the old a.out format. This may have been the case for older 32-bit sparc hardware, but for sun4u/sun4v does anyone know if OpenBoot also supports elf32 or elf64 formats? 3. Calling OpenBoot functions I'd like to call prom_printf() to print a test message. I think when OpenBoot loads my binary it jumps to a _start() function, passing pointer to promvec structure in %o0 register. If I save the value of this register somewhere on the stack, I can use the pointer to call prom_printf(). At this stage, OpenBoot had already initialised MMU, setup basic trap table and my code is running in OpenBoot virtual address space. Is all of this correct? Thanks.