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.
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@ilande.co.uk --- openbios-devel/libopenbios/ofmem_common.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/openbios-devel/libopenbios/ofmem_common.c b/openbios-devel/libopenbios/ofmem_common.c index 157ca87..3b8ca15 100644 --- a/openbios-devel/libopenbios/ofmem_common.c +++ b/openbios-devel/libopenbios/ofmem_common.c @@ -634,8 +634,8 @@ ucell ofmem_claim( ucell addr, ucell size, ucell align ) } 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;