[OpenBIOS] [PATCH 3/6] Introduce va2pa() and pa2va() functions for PPC for subsequent use by OFMEM.

Blue Swirl blauwirbel at gmail.com
Wed Dec 29 19:54:46 CET 2010


On Wed, Dec 29, 2010 at 11:07 AM, Mark Cave-Ayland
<mark.cave-ayland at siriusit.co.uk> wrote:
> 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

I'd remove 'inline' from both.

> +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
>
>
> --
> OpenBIOS                 http://openbios.org/
> Mailinglist:  http://lists.openbios.org/mailman/listinfo
> Free your System - May the Forth be with you
>



More information about the OpenBIOS mailing list