j
: Next unread message k
: Previous unread message j a
: Jump to all threads
j l
: Jump to MailingList overview
Author: mcayland Date: Thu Dec 30 14:56:17 2010 New Revision: 993 URL: http://tracker.coreboot.org/trac/openbios/changeset/993
Log: Introduce va2pa() and pa2va() functions for PPC for subsequent use by OFMEM.
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@siriusit.co.uk
Modified: trunk/openbios-devel/arch/ppc/qemu/ofmem.c
Modified: trunk/openbios-devel/arch/ppc/qemu/ofmem.c ============================================================================== --- trunk/openbios-devel/arch/ppc/qemu/ofmem.c Thu Dec 30 14:56:14 2010 (r992) +++ trunk/openbios-devel/arch/ppc/qemu/ofmem.c Thu Dec 30 14:56:17 2010 (r993) @@ -180,6 +180,27 @@ /* OF private allocations */ /************************************************************************/
+/* Private functions for mapping between physical/virtual addresses */ +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; + } +} + +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; +} + void * malloc(int size) {