[OpenBIOS] Haiku/ppc progress - ofmem_claim misbehavior?

Andreas Färber andreas.faerber at web.de
Mon May 24 16:18:52 CEST 2010


Am 24.05.2010 um 11:23 schrieb Andreas Färber:

> Am 22.05.2010 um 15:37 schrieb Andreas Färber:
>
>> Comparison with Apple's OpenFirmware shows that:
>> * Apple's of_claim returns memory at 0x00400000 (vs. 0x07f00000)
>> * On the Mac I see an identity-mapped area at 0x00400000, length  
>> 4194304, mode 16 (vs. mode 2 and size 1048576 for 0x07f00000 from  
>> OpenBIOS)
>>
>> Haiku seems to actually claim 1048576 bytes for the new page table,  
>> [...]
>
> If I read QEMU code correctly (hw/ppc_{new,old}world.c, hw/ 
> ppc_mac.h) then OpenBIOS should be loaded at PROM_ADDR (0xfff00000)  
> of size BIOS_SIZE (1024 * 1024), i.e. the last 1 MiB of address  
> space. Yet I don't see a translation for that.
>
> Neither QEMU nor OpenBIOS have 0x07f00000 hardcoded anywhere. Where  
> is it coming from?

Gosh! 0x07f00000 is the RAM size (128 MiB = 0x08000000) minus the  
claimed size of 1048576. But that's exactly where arch/ppc/qemu/ 
ofmem.c:setup_mmu copies the OpenBIOS binary to from the QEMU- 
specified 0xfff00000 location!

So we are indeed overwriting OpenBIOS code, which explains the  
formerly printed invalid opcode warnings from QEMU.

With a hack such as the following, effectively using ppc's  
get_ram_top() as maximum, I can make a little visible progress.

diff --git a/libopenbios/ofmem_common.c b/libopenbios/ofmem_common.c
index 1e797b3..2219a91 100644
--- a/libopenbios/ofmem_common.c
+++ b/libopenbios/ofmem_common.c
@@ -492,8 +492,8 @@ ucell ofmem_claim( ucell addr, ucell size, ucell  
align )
  	} else {
  		if( align < 0x1000 )
  			align = 0x1000;
-		phys = ofmem_claim_phys_( addr, size, align, 0, get_ram_size(), 1 / 
* reverse */ );
-		virt = ofmem_claim_virt_( addr, size, align, 0, get_ram_size(), 1 / 
* reverse */ );
+		phys = ofmem_claim_phys_( addr, size, align, 0, get_ram_size() -  
0x00100000 - (2 << 15) - (32 + 32 + 64) * 1024, 1 /* reverse */ );
+		virt = ofmem_claim_virt_( addr, size, align, 0, get_ram_size() -  
0x00100000 - (2 << 15) - (32 + 32 + 64) * 1024, 1 /* reverse */ );
  		if( phys == -1 || virt == -1 ) {
  			OFMEM_TRACE("ofmem_claim failed\n");
  			return -1;

For http://haiku-files.org/ppc/haiku-r36919-ppc-haiku-boot-cd-ppc.zip  
leading to:

 >> =============================================================
 >> OpenBIOS 1.0 [May 24 2010 13:11]
 >> Configuration device id QEMU version 1 machine id 2
 >> CPUs: 1
 >> Memory: 128M
 >> UUID: 00000000-0000-0000-0000-000000000000
 >> CPU type PowerPC,750
Welcome to OpenBIOS v1.0 built on May 24 2010 13:11


checking for memory...
0: base = 0x00000000, size = 134217728
1: empty region
total physical memory = 128 MB
suggested page table size = 1048576
need new page table, size = 1048576!
 >> OFMEM: ofmem_map_page_range 07d00000 -> 07d00000 00100000 mode  
00000002
new table at: 0x07d00000
MSR: 0x00003030
found 4 translations
found exception handlers!
found page table!


Cheers,

Andreas


More information about the OpenBIOS mailing list