[OpenBIOS] [commit] r1269 - trunk/openbios-devel/arch/sparc32
repository service
svn at openbios.org
Sun Feb 16 17:26:48 CET 2014
Author: mcayland
Date: Sun Feb 16 17:26:46 2014
New Revision: 1269
URL: http://tracker.coreboot.org/trac/openbios/changeset/1269
Log:
SPARC32: alter obp_dumb_memalloc() to handle allocation with va == 0
It seems that the obp_dumb_memalloc() function can be called with va == 0
which means that OpenBIOS should pick the next free virtual address itself.
Otherwise we end up accidentally mapping into zero page causing all sorts of
problems.
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland at ilande.co.uk>
Modified:
trunk/openbios-devel/arch/sparc32/lib.c
Modified: trunk/openbios-devel/arch/sparc32/lib.c
==============================================================================
--- trunk/openbios-devel/arch/sparc32/lib.c Sun Feb 16 17:26:43 2014 (r1268)
+++ trunk/openbios-devel/arch/sparc32/lib.c Sun Feb 16 17:26:46 2014 (r1269)
@@ -229,14 +229,28 @@
char *obp_dumb_memalloc(char *va, unsigned int size)
{
unsigned long align = size;
+ phys_addr_t phys;
+ ucell virt;
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
- ofmem_claim_phys() above. */
+ e.g. it is used for setting up page tables. */
- return obp_memalloc(va, size, align);
+ /* Claim physical memory */
+ phys = ofmem_claim_phys(-1, size, align);
+
+ /* Claim virtual memory - if va == NULL then we choose va address */
+ if (va == NULL) {
+ virt = ofmem_claim_virt((ucell)-1, size, align);
+ } else {
+ virt = ofmem_claim_virt(pointer2cell(va), size, 0);
+ }
+
+ /* Map the memory */
+ ofmem_map(phys, virt, size, ofmem_arch_default_translation_mode(phys));
+
+ return cell2pointer(virt);
}
void obp_dumb_memfree(char *va, unsigned size)
More information about the OpenBIOS
mailing list