[OpenBIOS] [PATCH 15/16] Switch remaining SPARC32 code over to OFMEM.

Blue Swirl blauwirbel at gmail.com
Thu Dec 30 19:55:21 CET 2010


On Thu, Dec 30, 2010 at 6:07 PM, Mark Cave-Ayland
<mark.cave-ayland at siriusit.co.uk> wrote:
> This patch removes the SPARC32-specific map_pages() function from the IOMMU driver, plus switches obp_dumb_memalloc()
> over to use OFMEM. OFMEM property generation is enabled for the /memory and /virtual-memory nodes, and any remaining
> traces of the old memory variables are removed.
>
> Signed-off-by: Mark Cave-Ayland <mark.cave-ayland at siriusit.co.uk>
> ---
>  openbios-devel/arch/sparc32/lib.c          |   69 +++++++++------------------
>  openbios-devel/drivers/iommu.c             |    2 +-
>  openbios-devel/include/libopenbios/ofmem.h |    1 -
>  3 files changed, 24 insertions(+), 48 deletions(-)
>
> diff --git a/openbios-devel/arch/sparc32/lib.c b/openbios-devel/arch/sparc32/lib.c
> index 74ac5e7..6b51f1c 100644
> --- a/openbios-devel/arch/sparc32/lib.c
> +++ b/openbios-devel/arch/sparc32/lib.c
> @@ -53,8 +53,6 @@ struct mem {
>     char *curp;
>  };
>
> -static struct mem cmem;         /* Current memory, virtual */
> -static struct mem cio;          /* Current I/O space */
>  struct mem cdvmem;              /* Current device virtual memory space */
>
>  unsigned int va_shift;
> @@ -190,7 +188,7 @@ find_pte(unsigned long va, int alloc)
>     return pa2va(pa);
>  }
>
> -void
> +static void
>  map_pages(phys_addr_t phys, unsigned long virt,
>                  unsigned long size, unsigned long mode)
>  {
> @@ -353,29 +351,19 @@ void ofmem_arch_early_map_pages(phys_addr_t phys, ucell virt, ucell size, ucell
>
>  char *obp_dumb_memalloc(char *va, unsigned int size)
>  {
> -    size = (size + 7) & ~7;
> -    // XXX should use normal memory alloc
> -    totavail[0].num_bytes -= size;
> -    DPRINTF("obp_dumb_memalloc va 0x%p size %x at 0x%x\n", va, size,
> -            totavail[0].num_bytes);
> -
> -    // If va is null, the allocator is supposed to pick a "suitable" address.
> -    // (See OpenSolaric prom_alloc.c)  There's not any real guidance as
> -    // to what might be "suitable".  So we mimic the behavior of a Sun boot
> -    // ROM.
> -
> -    if (va == NULL) {
> -        va = (char *)(totmap[0].start_adr - size);
> -        totmap[0].start_adr -= size;
> -        totmap[0].num_bytes += size;
> -        DPRINTF("obp_dumb_memalloc req null -> 0x%p\n", va);
> -    }
> +    phys_addr_t phys;
> +    ucell virt;
> +
> +    /* Claim physical memory */
> +    phys = ofmem_claim_phys(-1, size, CONFIG_OFMEM_MALLOC_ALIGN);
> +
> +    /* Claim virtual memory */
> +    virt = ofmem_claim_virt(pointer2cell(va), size, 0);
>
> -    map_pages(totavail[0].num_bytes, (unsigned long)va, size, ofmem_arch_default_translation_mode(totavail[0].num_bytes));
> +    /* Map the memory */
> +    ofmem_map(phys, virt, size, ofmem_arch_default_translation_mode(phys));
>
> -    update_memory_properties();
> -
> -    return va;
> +    return cell2pointer(virt);
>  }
>
>  void obp_dumb_memfree(__attribute__((unused))char *va,
> @@ -387,6 +375,9 @@ void obp_dumb_memfree(__attribute__((unused))char *va,
>  void
>  ob_init_mmu(void)
>  {
> +    ucell *reg;
> +    ofmem_t *ofmem;

This variable is not read after it has been initialized, so GCC 4.6.0 complains:
  CC    target/arch/sparc32/lib.o
../arch/sparc32/lib.c: In function 'ob_init_mmu':
../arch/sparc32/lib.c:379:14: error: variable 'ofmem' set but not used
[-Werror=unused-but-set-variable]

Please remove the variable:
diff --git a/arch/sparc32/lib.c b/arch/sparc32/lib.c
index 37b33f0..f9956ce 100644
--- a/arch/sparc32/lib.c
+++ b/arch/sparc32/lib.c
@@ -376,7 +376,6 @@ void
 ob_init_mmu(void)
 {
     ucell *reg;
-    ofmem_t *ofmem;

     init_romvec_mem();

@@ -394,7 +393,7 @@ ob_init_mmu(void)
     ofmem_register(s_phandle_memory, s_phandle_mmu);

     /* Setup /memory:reg (totphys) property */
-    ofmem = ofmem_arch_get_private();
+    ofmem_arch_get_private();
     reg = malloc(3 * sizeof(ucell));
     ofmem_arch_encode_physaddr(reg, 0); /* physical base */
     reg[2] = (ucell)ofmem_arch_get_phys_top(); /* size */



More information about the OpenBIOS mailing list