On Tue, Aug 24, 2010 at 9:19 PM, Mark Cave-Ayland mark.cave-ayland@siriusit.co.uk wrote:
Blue Swirl wrote:
The problem was that ELF loader didn't allocate the areas. Now with r858 OpenBSD gets into kernel: Loading FCode image... Loaded 4893 bytes entry point is 0x4000 OpenBSD IEEE 1275 Bootblock 1.1 .. Jumping to entry point 0000000000800000 for type 0000000000000001... switching to new context: entry point 0x800000 stack 0x00000000ffe02b59
OpenBSD BOOT 1.2
Trying bsd... Booting cdrom:f/bsd 2590536@0x1000000+3236576@0x1800000+957728@0x1b162e0 symbols @ 0x200241c0 36 start=0x1000000 CHAINprom_get_msgbuf: test failed prom_get_msgbuf: allocated new buf at ffffffff prom_get_msgbuf: claiming new buf at ffffffff Unhandled Exception 0x0000000000000032 PC = 0x0000000001080bc4 NPC = 0x0000000001080bc8 Stopping execution
I noticed that MilaX had problems with allocation happening, so I made the loader ignore the failures. That is probably not correct.
Re-reading the IEEE-1275 spec again, I'm thinking that what we have at the moment is wrong. To quote from the definition of the "load" command:
If the “load” method succeeds, and the beginning of the loaded image is a valid client program header for the system, allocate memory at the address and of the size specified in that header, move the loaded image to the address, and perform the function of init-program to initialize saved-program-state so that a subsequent go command will begin execution of that program.
This sounds to me as if "load" as opposed to "init-program" should do the relocation if pointed at an ELF file (allocating memory as necessary), otherwise as in the case of the Solaris Fcode loader and the BSD source given above then all memory setup is managed by the loader itself. Hence the invocation of "init-program" is practically a no-op since the memory allocations should be already handled.
If you quickly rearrange elf_load.c in this way, does that solve the boot problem for both openBSD and Milax?
I don't think so, OpenBSD crashes again when clearing BSS. Milax is unchanged.
I moved ofmem_claim() call to load_segments().