[OpenBIOS] [PATCH 02/16] Introduce ofmem_arch_get_phys_top() for specifying the top of physical memory in OFMEM.

Mark Cave-Ayland mark.cave-ayland at siriusit.co.uk
Thu Dec 30 19:07:05 CET 2010


From: mcayland <mcayland at f158a5a8-5612-0410-a976-696ce0be7e32>

At the same time, teach OFMEM to make use of it when calculating the /memory available property.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland at siriusit.co.uk>

git-svn-id: svn://openbios.org/openbios/trunk@995 f158a5a8-5612-0410-a976-696ce0be7e32
---
 openbios-devel/arch/ppc/qemu/ofmem.c        |    7 +++++++
 openbios-devel/arch/sparc64/ofmem_sparc64.c |    7 +++++++
 openbios-devel/include/libopenbios/ofmem.h  |    1 +
 openbios-devel/libopenbios/ofmem_common.c   |    8 ++++----
 4 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/openbios-devel/arch/ppc/qemu/ofmem.c b/openbios-devel/arch/ppc/qemu/ofmem.c
index e41d47d..c0143a4 100644
--- a/openbios-devel/arch/ppc/qemu/ofmem.c
+++ b/openbios-devel/arch/ppc/qemu/ofmem.c
@@ -115,6 +115,13 @@ ucell ofmem_arch_get_virt_top(void)
     return IO_BASE;
 }
 
+phys_addr_t ofmem_arch_get_phys_top(void)
+{
+    ofmem_t *ofmem = ofmem_arch_get_private();
+
+    return ofmem->ramsize;
+}
+
 void ofmem_arch_unmap_pages(ucell virt, ucell size)
 {
     /* kill page mappings in provided range */
diff --git a/openbios-devel/arch/sparc64/ofmem_sparc64.c b/openbios-devel/arch/sparc64/ofmem_sparc64.c
index 4d13038..0ec8632 100644
--- a/openbios-devel/arch/sparc64/ofmem_sparc64.c
+++ b/openbios-devel/arch/sparc64/ofmem_sparc64.c
@@ -63,6 +63,13 @@ ucell ofmem_arch_get_virt_top(void)
 	return (ucell)TOP_OF_RAM;
 }
 
+phys_addr_t ofmem_arch_get_phys_top(void)
+{
+	ofmem_t *ofmem = ofmem_arch_get_private();
+
+	return ofmem->ramsize;
+}
+
 retain_t *ofmem_arch_get_retained(void)
 {
 	/* Retained area is at the top of physical RAM */
diff --git a/openbios-devel/include/libopenbios/ofmem.h b/openbios-devel/include/libopenbios/ofmem.h
index ebb4dba..54868e2 100644
--- a/openbios-devel/include/libopenbios/ofmem.h
+++ b/openbios-devel/include/libopenbios/ofmem.h
@@ -62,6 +62,7 @@ extern ofmem_t* 	ofmem_arch_get_private(void);
 extern void*    	ofmem_arch_get_malloc_base(void);
 extern ucell    	ofmem_arch_get_heap_top(void);
 extern ucell    	ofmem_arch_get_virt_top(void);
+extern phys_addr_t 	ofmem_arch_get_phys_top(void);
 extern retain_t*	ofmem_arch_get_retained(void);
 extern int			ofmem_arch_get_physaddr_cellsize(void);
 extern int			ofmem_arch_encode_physaddr(ucell *p, phys_addr_t value);
diff --git a/openbios-devel/libopenbios/ofmem_common.c b/openbios-devel/libopenbios/ofmem_common.c
index 48b0b17..e93b938 100644
--- a/openbios-devel/libopenbios/ofmem_common.c
+++ b/openbios-devel/libopenbios/ofmem_common.c
@@ -354,7 +354,7 @@ static void ofmem_update_translations( void )
 	ofmem_t *ofmem = ofmem_arch_get_private();
 
 	ofmem_update_memory_available(s_phandle_memory, ofmem->phys_range, 
-			&phys_range_prop, &phys_range_prop_size, &phys_range_prop_used, get_ram_size());
+			&phys_range_prop, &phys_range_prop_size, &phys_range_prop_used, ofmem_arch_get_phys_top());
 	ofmem_update_memory_available(s_phandle_mmu, ofmem->virt_range, 
 			&virt_range_prop, &virt_range_prop_size, &virt_range_prop_used, -1ULL);
 	ofmem_update_mmu_translations();
@@ -481,7 +481,7 @@ static ucell find_area( ucell align, ucell size, range_t *r,
 }
 
 static phys_addr_t ofmem_claim_phys_( phys_addr_t phys, ucell size, ucell align,
-		ucell min, ucell max, int reverse )
+		phys_addr_t min, phys_addr_t max, int reverse )
 {
 	ofmem_t *ofmem = ofmem_arch_get_private();
 	if( !align ) {
@@ -511,7 +511,7 @@ phys_addr_t ofmem_claim_phys( phys_addr_t phys, ucell size, ucell align )
                 " align=" FMT_ucellx "\n",
                 phys, size, align);
 
-	return ofmem_claim_phys_( phys, size, align, 0, get_ram_size(), 0 );
+	return ofmem_claim_phys_( phys, size, align, 0, ofmem_arch_get_phys_top(), 0 );
 }
 
 static ucell ofmem_claim_virt_( ucell virt, ucell size, ucell align,
@@ -591,7 +591,7 @@ ucell ofmem_claim( ucell addr, ucell size, ucell align )
 	} else {
 		if( align < 0x1000 )
 			align = 0x1000;
-		phys = ofmem_claim_phys_( addr, size, align, 0, get_ram_size(), 1 /* reverse */ );
+		phys = ofmem_claim_phys_( addr, size, align, 0, ofmem_arch_get_phys_top(), 1 /* reverse */ );
 		virt = ofmem_claim_virt_( addr, size, align, 0, get_ram_size(), 1 /* reverse */ );
 		if( phys == -1 || virt == -1 ) {
 			OFMEM_TRACE("ofmem_claim failed\n");
-- 
1.7.2.3




More information about the OpenBIOS mailing list