Author: mcayland Date: Wed Sep 24 20:03:51 2014 New Revision: 1318 URL: http://tracker.coreboot.org/trac/openbios/changeset/1318
Log: OFMEM: change ofmem_claim() to always allocate addresses where phys == virt
The wording of the IEEE1275 specification for the CIF claim and release words contains the following:
claim IN: [address] virt, size, align OUT: [address] baseaddr
Allocates size bytes of memory. If align is zero, the allocated range begins at the virtual address virt.... The range of physical memory and virtual addresses affected by this operation will be unavailable for subsequent mapping or allocation operations until freed by release.
release IN: [address] virt, size OUT: none
Frees size bytes of physical memory starting at virtual address virt, making that physical memory and the corresponding range of virtual address space available for later use. That memory must have been previously allocated by claim.
Even though the claim word mentions virtual addresses, the implication from the release word mentioning physical memory is that allocations made by claim must have phys == virt. So change ofmem_claim() to ensure that addresses allocated via the CIF claim word always have phys == virt.
This fixes a bug in MorphOS boot where different physical and virtual addresses cause mixed accesses by the bootloader to fail.
Reported-by: BALATON Zoltan balaton@eik.bme.hu Tested-by: BALATON Zoltan balaton@eik.bme.hu Signed-off-by: Mark Cave-Ayland mark.cave-ayland@ilande.co.uk
Modified: trunk/openbios-devel/libopenbios/ofmem_common.c
Modified: trunk/openbios-devel/libopenbios/ofmem_common.c ============================================================================== --- trunk/openbios-devel/libopenbios/ofmem_common.c Wed Sep 24 20:03:48 2014 (r1317) +++ trunk/openbios-devel/libopenbios/ofmem_common.c Wed Sep 24 20:03:51 2014 (r1318) @@ -634,8 +634,8 @@ } else { if( align < PAGE_SIZE ) align = PAGE_SIZE; - phys = ofmem_claim_phys_( addr, size, align, 0, ofmem_arch_get_phys_top(), 1 /* reverse */ ); - virt = ofmem_claim_virt_( addr, size, align, 0, get_ram_size(), 1 /* reverse */ ); + phys = ofmem_claim_phys_( -1, size, align, 0, ofmem_arch_get_phys_top(), 1 /* reverse */ ); + virt = ofmem_claim_virt_( phys, size, 0, 0, 0, 0 ); if( phys == -1 || virt == -1 ) { OFMEM_TRACE("ofmem_claim failed\n"); return -1;