> Hi, I'm trying to find out in detail how sun4u > machines boot an operating system. > > I have Ultra 10 with a spare blank SCSI hard disk. I > would like to compile a few SPARC assembly > instructions into a flat binary, then boot this > binary file with the help of openfirmware. The binary > file will execute a few simple calculations and > display the result on the console. > > So a few questions: > > 1. Say I compile my assembly code into myboot binary > file. Can I boot and execute this file from openboot > menu via: > > ok boot myboot
Not in this way. The "boot" command takes a device pathname as an argument and performs a sequence of a "load" and an "go" OBP command to load the bootblock (first 16kB of the device) and then figure out whether what'd been loaded is ELF or FCode, jumping to the corresponding exec handler to actually run the stuff. > > Does the myboot have to be an ELF executable or can > it be a flat binary file? Where exactly on disk does > it have to be in order for openfirmware to be able to > load it? If you create an ELF executable that's freestanding (static and not attempting to make any sorts of external calls - save IEEE1275 client handler invocations) you can put it into the first 16kB (the bootblock) of any disk device and then just specify "boot /OBP-device-path/to/my/disk/with/the/binary/on". Executing a file (within a UFS filesystem) is also possible, you have to use the UFS OBP package to open the filesystem, load the file and then execute it. The bootblock sourcecode for OpenSolaris is somewhat helpful in understanding that: http://src.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/psm/stand/bootblks/ I'm saying "somewhat" because you need to read up on FORTH ... You can, via OBP low-level functionality, read a stretch of disk sectors in and execute that; try the OBP command "see boot" to do exactly that - see how the "boot" command is implemented. > > 2. How can my code access console and print text on > it? Are there any special instructions/memory mapped > locations for I/O on SPARC during boot? No, but OBP is a pretty capable operating system in its own right and it is possible to invoke OBP methods to do console output from within a boot program. To do so from within your own boot-time code, best link that with the static libraries for standalone code from: http://src.opensolaris.org/source/xref/onnv/onnv-gate/usr/src/psm/promif/ieee1275/common/ Or alternatively, if you want it really hardcore, invoke the client-handler directly (via trap 7f), details of that are in the OBP specs, see playground.sun.com in particular you need http://playground.sun.com/1275/bindings/sparc/d14a/12751d1a.ps - a sick sort of fun :) The way boot works on SPARC is usually 2-stage; the bootblock (1st stage) itself will be FCode (binary-encoded Forth) that implements a mini-filesystem-reader, which will load a file (the 2nd stage booter) that's a static ELF executable, and then transfer control into that. That's also the way how the SPARC Linux bootloader (silo) and the *BSD SPARC bootloaders work; the SILO sourcecode (find it in a SPARC linux source of your choice, again it's Forth) and/or the *BSDs would be another source of information you can look into. Have fun hacking, FrankH. -- This message posted from opensolaris.org _______________________________________________ opensolaris-code mailing list opensolaris-code@opensolaris.org http://mail.opensolaris.org/mailman/listinfo/opensolaris-code