[OpenBIOS] [PATCH 3/5] Alter ofmem_malloc_align() so that the resulting pointer is aligned for both physical and virtual addresses.

Mark Cave-Ayland mark.cave-ayland at siriusit.co.uk
Tue Dec 28 12:47:39 CET 2010


On 22/12/10 12:53, Andreas Färber wrote:

> No. The virtual address on ppc64 is something like 80 bits, whereas the
> effective address (64 bits) really is what we want, similar differences
> for 32-bit, so it shouldn't be renamed. It may need to be wrapped.
>
> I don't think it belongs in io.h either. I wouldn't know where
> virt_offset is initialized, so I assume that during runtime (as opposed
> to forthstrap) it will be zero and all you're doing there is
> identity-mapping things, which buys us nothing.
>
> We do have ofmem_arch_translate() or similar for the virtual-to-physical
> direction. Maybe we need another ofmem_* one for the opposite direction?
> sparc implementations could then call their *va* macros from there if it
> suits them. The way we map OpenBIOS into RAM in ea2phys() should
> guarantee physical alignment of aligned effective addresses, so that
> there's no need to consider it in other functions (this is an ugly hack,
> in theory OpenBIOS would need to be fully relocatable and just copied
> there).

Hi Andreas,

I've had a play at using the following code in arch/ppc/qemu/ofmem.c 
(compared to the original patch which placed it in io.h) and it seems to 
work for me in tests here. It's based upon the code in ea2phys().


/* Private functions for mapping between physical/virtual addresses */
inline phys_addr_t
va2pa(unsigned long va)
{
	if (va >= OF_CODE_START && va < OF_CODE_START + OF_CODE_SIZE) {
         	return (phys_addr_t)get_rom_base() - OF_CODE_START + va;
	} else {
		return (phys_addr_t)va;
     	}
}

inline unsigned long
pa2va(phys_addr_t pa)
{
     if ((pa - get_rom_base() + OF_CODE_START >= OF_CODE_START) &&
         (pa - get_rom_base() + OF_CODE_START < OF_CODE_START + 
OF_CODE_SIZE))
         return (unsigned long)pa - get_rom_base() + OF_CODE_START;
     else
         return (unsigned long)pa;
}


The main reason I'm trying to get a resolution for this is because I've 
made some improvements based upon previous comments, and this is the 
only part remaining before I feel this patchset is ready for commit. 
Once this is then complete, it unblocks the SPARC32 OFMEM patchset which 
would be really good to get in before the end of the holidays :)


ATB,

Mark.

-- 
Mark Cave-Ayland - Senior Technical Architect
PostgreSQL - PostGIS
Sirius Corporation plc - control through freedom
http://www.siriusit.co.uk
t: +44 870 608 0063

Sirius Labs: http://www.siriusit.co.uk/labs



More information about the OpenBIOS mailing list