[OpenBIOS] [PATCH] OBP Memory allocation

Olivier Danet odanet at caramail.com
Sun Feb 9 23:59:48 CET 2014


When called with a null base address, char *obp_memalloc(va,size,align) 
shall
provide the address itself.

(and remove some trailing whitespaces)

Signed-off-by : Olivier Danet <odanet at caramail.com>

Index: arch/sparc32/lib.c
===================================================================
--- arch/sparc32/lib.c    (révision 1257)
+++ arch/sparc32/lib.c    (copie de travail)
@@ -212,13 +212,19 @@
      phys_addr_t phys;
      ucell virt;

-    DPRINTF("obp_memalloc: virta 0x%x, sz %d, align %d\n", (unsigned 
int)va, size, align);
-
+    DPRINTF("obp_memalloc: virta 0x%x, sz %d, align %d\n", (unsigned 
int)va, size, align);
+
+    /* Round to page size */
+    size = (size + 0xfff) & 0xFFFFF000;
+
      /* Claim physical memory */
      phys = ofmem_claim_phys(-1, size, align);

      /* Claim virtual memory */
-    virt = ofmem_claim_virt(pointer2cell(va), size, 0);
+    if (va)
+        virt = ofmem_claim_virt(pointer2cell(va), size, 0);
+    else
+        virt = ofmem_claim_virt(0, size, 0x1000);

      /* Map the memory */
      ofmem_map(phys, virt, size, 
ofmem_arch_default_translation_mode(phys));
@@ -230,7 +236,7 @@
  {
      unsigned long align = size;

-    DPRINTF("obp_dumb_memalloc: virta 0x%x, sz %d\n", (unsigned int)va, 
size);
+    DPRINTF("obp_dumb_memalloc: virta 0x%x, sz %d\n", (unsigned int)va, 
size);

      /* Solaris seems to assume that the returned value is physically 
aligned to size.
         e.g. it is used for setting up page tables. Fortunately this is 
now handled by
===================================================================




More information about the OpenBIOS mailing list