[OpenBIOS] [PATCH 3/6] Introduce va2pa() and pa2va() functions for PPC for subsequent use by OFMEM.
Mark Cave-Ayland
mark.cave-ayland at siriusit.co.uk
Wed Dec 29 12:07:59 CET 2010
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland at siriusit.co.uk>
---
openbios-devel/arch/ppc/qemu/ofmem.c | 21 +++++++++++++++++++++
1 files changed, 21 insertions(+), 0 deletions(-)
diff --git a/openbios-devel/arch/ppc/qemu/ofmem.c b/openbios-devel/arch/ppc/qemu/ofmem.c
index c21a112..44b5ef4 100644
--- a/openbios-devel/arch/ppc/qemu/ofmem.c
+++ b/openbios-devel/arch/ppc/qemu/ofmem.c
@@ -180,6 +180,27 @@ void ofmem_arch_create_translation_entry(ucell *transentry, translation_t *t)
/* OF private allocations */
/************************************************************************/
+/* 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;
+}
+
void *
malloc(int size)
{
--
1.7.2.3
More information about the OpenBIOS
mailing list