j
: Next unread message k
: Previous unread message j a
: Jump to all threads
j l
: Jump to MailingList overview
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@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 ===================================================================
On 09/02/14 22:59, Olivier Danet wrote:
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@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));
Hmmmm this doesn't look right at all. The obp_memalloc() function takes 3 parameters: va, size and align which should correspond with the equivalent parameters for the claim word.
The key here is the align parameter; if align == 0 then va is assumed to be valid, and the memory is allocated at the given address. If align != 0 then va is ignored, and OFMEM will follow the specification and return the next available memory region from the pool with an alignment specified by align.
You'll need to check this using a gdb breakpoint against your NextSTEP image, however what you should see is that align should always be != 0 when va == 0 and so OFMEM will follow the specification and ignore va. If this is not the case then NextSTEP is doing something very strange...
ATB,
Mark.