[OpenBIOS] [commit] r1009 - in trunk/openbios-devel: arch/sparc32 drivers include/libopenbios
repository service
svn at openbios.org
Sun Jan 2 01:07:29 CET 2011
Author: mcayland
Date: Sun Jan 2 01:07:26 2011
New Revision: 1009
URL: http://tracker.coreboot.org/trac/openbios/changeset/1009
Log:
Switch remaining SPARC32 code over to OFMEM.
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>
Tested-by: Blue Swirl <blauwirbel at gmail.com>
Reviewed-by: Blue Swirl <blauwirbel at gmail.com>
Modified:
trunk/openbios-devel/arch/sparc32/lib.c
trunk/openbios-devel/drivers/iommu.c
trunk/openbios-devel/include/libopenbios/ofmem.h
Modified: trunk/openbios-devel/arch/sparc32/lib.c
==============================================================================
--- trunk/openbios-devel/arch/sparc32/lib.c Sun Jan 2 01:07:19 2011 (r1008)
+++ trunk/openbios-devel/arch/sparc32/lib.c Sun Jan 2 01:07:26 2011 (r1009)
@@ -53,8 +53,6 @@
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 @@
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 @@
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;
- map_pages(totavail[0].num_bytes, (unsigned long)va, size, ofmem_arch_default_translation_mode(totavail[0].num_bytes));
+ /* Claim physical memory */
+ phys = ofmem_claim_phys(-1, size, CONFIG_OFMEM_MALLOC_ALIGN);
- update_memory_properties();
+ /* Claim virtual memory */
+ virt = ofmem_claim_virt(pointer2cell(va), size, 0);
- return va;
+ /* Map the memory */
+ ofmem_map(phys, virt, size, ofmem_arch_default_translation_mode(phys));
+
+ return cell2pointer(virt);
}
void obp_dumb_memfree(__attribute__((unused))char *va,
@@ -387,6 +375,8 @@
void
ob_init_mmu(void)
{
+ ucell *reg;
+
init_romvec_mem();
/* Find the phandles for the /memory and /virtual-memory nodes */
@@ -400,30 +390,18 @@
POP();
s_phandle_mmu = POP();
- /* Setup /memory:reg (totphys) property */
- push_str("/memory");
- fword("find-device");
- PUSH(pointer2cell(mem_reg));
- PUSH(3 * sizeof(ucell));
- push_str("reg");
- PUSH_ph(s_phandle_memory);
- fword("encode-property");
+ ofmem_register(s_phandle_memory, s_phandle_mmu);
- /* Setup /virtual-memory:avail (totmap) property */
- push_str("/virtual-memory");
- fword("find-device");
- PUSH(pointer2cell(virt_avail));
- PUSH(3 * sizeof(ucell));
- push_str("available");
- PUSH_ph(s_phandle_mmu);
- fword("encode-property");
+ /* Setup /memory:reg (totphys) property */
+ reg = malloc(3 * sizeof(ucell));
+ ofmem_arch_encode_physaddr(reg, 0); /* physical base */
+ reg[2] = (ucell)ofmem_arch_get_phys_top(); /* size */
- /* Setup /memory:avail (totavail) property */
push_str("/memory");
fword("find-device");
- PUSH(pointer2cell(mem_avail));
+ PUSH(pointer2cell(reg));
PUSH(3 * sizeof(ucell));
- push_str("available");
+ push_str("reg");
PUSH_ph(s_phandle_memory);
fword("encode-property");
@@ -444,9 +422,6 @@
unsigned long pa, va;
int size;
- mem_init(&cmem, (char *) &_vmem, (char *)&_evmem);
- mem_init(&cio, (char *)&_end, (char *)&_iomem);
-
ofmem_posix_memalign((void *)&context_table, NCTX_SWIFT * sizeof(int),
NCTX_SWIFT * sizeof(int));
ofmem_posix_memalign((void *)&l1, 256 * sizeof(int), 256 * sizeof(int));
Modified: trunk/openbios-devel/drivers/iommu.c
==============================================================================
--- trunk/openbios-devel/drivers/iommu.c Sun Jan 2 01:07:19 2011 (r1008)
+++ trunk/openbios-devel/drivers/iommu.c Sun Jan 2 01:07:26 2011 (r1009)
@@ -68,7 +68,7 @@
*/
mva = (unsigned int) va;
mpa = (unsigned int) pa;
- map_pages(mpa, mva, npages * PAGE_SIZE, ofmem_arch_io_translation_mode(mpa));
+ ofmem_arch_early_map_pages(mpa, mva, npages * PAGE_SIZE, ofmem_arch_io_translation_mode(mpa));
/*
* Map into IOMMU page table.
Modified: trunk/openbios-devel/include/libopenbios/ofmem.h
==============================================================================
--- trunk/openbios-devel/include/libopenbios/ofmem.h Sun Jan 2 01:07:19 2011 (r1008)
+++ trunk/openbios-devel/include/libopenbios/ofmem.h Sun Jan 2 01:07:26 2011 (r1009)
@@ -135,7 +135,6 @@
void mem_init(struct mem *t, char *begin, char *limit);
void *mem_alloc(struct mem *t, int size, int align);
-void map_pages(phys_addr_t phys, unsigned long virt, unsigned long size, unsigned long mode);
#endif
#ifdef PAGE_SHIFT
More information about the OpenBIOS
mailing list