Hi all,
I'm working on implementing a version of the CIF chain service for SPARC64 and am trying to understand what to do with the arguments parameters. From the specification:
"chain: Frees size bytes of memory starting at virtual address virt, then executes another client program beginning at address entry. The argument buffer args, len is copied into the Open Firmware memory and passed to the other program. The address of the arguments in the Open Firmware memory is the client program’s second argument, and their length is its third argument. chain is used to free any remaining memory for a secondary boot program and begin executing the booted program."
How are the arguments passed to the next client program? A quick peek at the OpenBOOT source shows that (init-program) only sets up %o4 (CIF) and %o6 (stack) registers. Does that mean that the arguments should be copied onto the stack or somehow via the registers? Unfortunately I can't seem to find a suitable 64-bit SPARC IEEE1275 ISA document anywhere :(
ATB,
Mark.
On 2014-Apr-4, 09:53 , Mark Cave-Ayland wrote:
I'm working on implementing a version of the CIF chain service for SPARC64
Hmm. I note that in current Openboot, there is no CIF for "chain". It's commented out.
How are the arguments passed to the next client program? A quick peek at the OpenBOOT source shows that (init-program) only sets up %o4 (CIF) and %o6 (stack) registers. Does that mean that the arguments should be copied onto the stack or somehow via the registers? Unfortunately I can't seem to find a suitable 64-bit SPARC IEEE1275 ISA document anywhere :(
Where does your client program expect the arguments?
The client programs I'm familiar with all fetch their arguments from properties in /chosen, don't expect things on the stack.
On 04/04/14 19:15, Tarl Neustaedter wrote:
I'm working on implementing a version of the CIF chain service for SPARC64
Hmm. I note that in current Openboot, there is no CIF for "chain". It's commented out.
Yeah, that's what I saw :(
How are the arguments passed to the next client program? A quick peek at the OpenBOOT source shows that (init-program) only sets up %o4 (CIF) and %o6 (stack) registers. Does that mean that the arguments should be copied onto the stack or somehow via the registers? Unfortunately I can't seem to find a suitable 64-bit SPARC IEEE1275 ISA document anywhere :(
Where does your client program expect the arguments?
The client programs I'm familiar with all fetch their arguments from properties in /chosen, don't expect things on the stack.
The code comes from an older version of NetBSD. Browsing through the source, it appears that the kernel entry point as pointed to by "chain" expects the following register layout:
/* * Kernel entry point. * * The contract between bootloader and kernel is: * * %o0 OpenFirmware entry point, to keep Sun's updaters happy * %o1 Address of boot information vector (see bootinfo.h) * %o2 Length of the vector, in bytes * %o3 OpenFirmware entry point, to mimic Sun bootloader behavior * %o4 OpenFirmware, to meet earlier NetBSD kernels expectations */
Interestingly enough, my copy of 12751d1a.pdf contains the following section which (minus the OBP pointers) seems to agree with this:
5.2.3. Client program arguments
Registers %o1 and %o2 may be used to pass to the client program an array of bytes of arbitrary content, with %o1 containing the base address of the array and %o2 the length. If no such array is passed, %o1 and %o2 shall contain zero.
NOTE—The Open Firmware standard makes no provision for specifying such an array or its contents. Therefore, in the absence of implementation-dependent extensions, a client program executed directly from an Open Firmware implementation will not be passed such an array. However, intermediate boot programs that simulate or propagate the Open Firmware client interface to the programs that they load can provide such an array for their clients.
NOTE—Boot command line arguments, typically consisting of the name of a file to be loaded by a secondary boot program followed by flags selecting various secondary boot and operating system options, are provided to client programs via the “bootargs” and “bootpath” properties of the “/chosen” node.
I appreciate that the document referenced above is actually for a 32-bit SPARC ISA, however the indication is that something similar was in place for 64-bit SPARC. More amusingly is that the last few NetBSD releases simply call the kernel entry point directly rather than bothering to invoke "chain" via the CIF at all.
ATB,
Mark.
On 2014-Apr-8, 01:25 , Mark Cave-Ayland wrote:
[...] I appreciate that the document referenced above is actually for a 32-bit SPARC ISA, however the indication is that something similar was in place for 64-bit SPARC.
Not that I know of. I've been on the road for the past week, haven't had a chance to go looking. But two things: 1) I'll be surprised if I find a 64-bit version of chain documentation at Oracle. 2) If I do, I'd expect it to use the same registers. I wouldn't expect a change from the use of %o0-04 just because the register size changed.
The only thing I can think that's even remotely associated with such register use is how Openboot itself is started, with arguments in registers from the Hypervisor for sun4v.
More amusingly is that the last few NetBSD releases simply call the kernel entry point directly rather than bothering to invoke "chain" via the CIF at all.
Probably because Chain didn't work. Don't know when it was commented out, but was well over a decade ago. Possibly in the 32- to 64-bit transition (sun4m to sun4u).