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

Andreas Färber andreas.faerber at web.de
Tue Dec 21 22:30:27 CET 2010


Am 21.12.2010 um 11:38 schrieb Mark Cave-Ayland:

> Some uses of ofmem_malloc_align() need to ensure that the alignment  
> requirement is for physical as well as virtual addresses,
> e.g. for MMU page tables.
>
> Signed-off-by: Mark Cave-Ayland <mark.cave-ayland at siriusit.co.uk>
> ---
> openbios-devel/include/arch/ppc/io.h      |   20 ++++++++++++++++++++
> openbios-devel/libopenbios/ofmem_common.c |   11 ++++++++---
> 2 files changed, 28 insertions(+), 3 deletions(-)
>
> diff --git a/openbios-devel/include/arch/ppc/io.h b/openbios-devel/ 
> include/arch/ppc/io.h
> index 3449c5b..20586e4 100644
> --- a/openbios-devel/include/arch/ppc/io.h
> +++ b/openbios-devel/include/arch/ppc/io.h
> @@ -9,6 +9,26 @@
> extern char _start, _end;
> extern unsigned long virt_offset;
>
> +static inline unsigned long
> +va2pa(unsigned long va)
> +{
> +    if ((va >= (unsigned long)&_start) &&
> +        (va < (unsigned long)&_end))
> +        return va - virt_offset;
> +    else
> +        return va;
> +}
> +
> +static inline unsigned long
> +pa2va(unsigned long pa)
> +{
> +    if ((pa + virt_offset >= (unsigned long)&_start) &&
> +        (pa + virt_offset < (unsigned long)&_end))
> +        return pa + virt_offset;
> +    else
> +        return pa;
> +}

--verbose please! What is this supposed to do? Seems like a duplicate  
of ofmem.c:ea_to_phys() but different?

Andreas

> +
> #define phys_to_virt(phys) ((void *) ((unsigned long) (phys) -  
> virt_offset))
> #define virt_to_phys(virt) ((unsigned long) (virt) + virt_offset)
>





More information about the OpenBIOS mailing list