This is a tidy-up and bugfix for the OFMEM available property issue raised by Olivier in his patch to the mailing list.
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@ilande.co.uk
Mark Cave-Ayland (3): SPARC32: reserve top of physical memory directly rather than with ofmem_arch_get_phys_top() OFMEM: remove ofmem_arch_get_phys_top() implementation OFMEM: fix off-by-one calculation in available property tail calculation
openbios-devel/arch/ppc/qemu/ofmem.c | 7 ------- openbios-devel/arch/sparc32/ofmem_sparc32.c | 11 +++-------- openbios-devel/arch/sparc64/ofmem_sparc64.c | 7 ------- openbios-devel/include/libopenbios/ofmem.h | 1 - openbios-devel/libopenbios/ofmem_common.c | 10 +++++----- 5 files changed, 8 insertions(+), 28 deletions(-)
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@ilande.co.uk --- openbios-devel/arch/sparc32/ofmem_sparc32.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/openbios-devel/arch/sparc32/ofmem_sparc32.c b/openbios-devel/arch/sparc32/ofmem_sparc32.c index d2935a8..bc3efaf 100644 --- a/openbios-devel/arch/sparc32/ofmem_sparc32.c +++ b/openbios-devel/arch/sparc32/ofmem_sparc32.c @@ -30,6 +30,8 @@ static union { #define OFMEM (&s_ofmem_data.ofmem) #define TOP_OF_RAM (s_ofmem_data.memory + MEMSIZE)
+#define OFMEM_PHYS_RESERVED 0x1000000 + translation_t **g_ofmem_translations = &s_ofmem_data.ofmem.trans;
extern uint32_t qemu_mem_size; @@ -251,7 +253,7 @@ void ofmem_init( void ) ofmem_claim_virt(0, PAGE_SIZE, 0); /* Claim reserved physical addresses at top of RAM */ - ofmem_claim_phys(ofmem_arch_get_phys_top(), s_ofmem_data.ofmem.ramsize - ofmem_arch_get_phys_top(), 0); + ofmem_claim_phys(s_ofmem_data.ofmem.ramsize - OFMEM_PHYS_RESERVED, OFMEM_PHYS_RESERVED, 0); /* Claim OpenBIOS reserved space */ ofmem_claim_virt(0xffd00000, 0x300000, 0);
Since the previous commit, the value of ofmem_arch_get_phys_top() is now the same across all architectures. Hence we can now remove this and just use the physical memory size directly.
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@ilande.co.uk --- openbios-devel/arch/ppc/qemu/ofmem.c | 7 ------- openbios-devel/arch/sparc32/ofmem_sparc32.c | 7 ------- openbios-devel/arch/sparc64/ofmem_sparc64.c | 7 ------- openbios-devel/include/libopenbios/ofmem.h | 1 - openbios-devel/libopenbios/ofmem_common.c | 6 +++--- 5 files changed, 3 insertions(+), 25 deletions(-)
diff --git a/openbios-devel/arch/ppc/qemu/ofmem.c b/openbios-devel/arch/ppc/qemu/ofmem.c index e03beaa..6f346a3 100644 --- a/openbios-devel/arch/ppc/qemu/ofmem.c +++ b/openbios-devel/arch/ppc/qemu/ofmem.c @@ -117,13 +117,6 @@ 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/sparc32/ofmem_sparc32.c b/openbios-devel/arch/sparc32/ofmem_sparc32.c index bc3efaf..1003c01 100644 --- a/openbios-devel/arch/sparc32/ofmem_sparc32.c +++ b/openbios-devel/arch/sparc32/ofmem_sparc32.c @@ -66,13 +66,6 @@ ucell ofmem_arch_get_virt_top(void) return (ucell)OFMEM_VIRT_TOP; }
-phys_addr_t ofmem_arch_get_phys_top(void) -{ - ofmem_t *ofmem = ofmem_arch_get_private(); - - return (uintptr_t)ofmem->ramsize - 0x1000000; -} - ucell ofmem_arch_get_iomem_base(void) { return pointer2cell(&_end); diff --git a/openbios-devel/arch/sparc64/ofmem_sparc64.c b/openbios-devel/arch/sparc64/ofmem_sparc64.c index 6e1bb05..bdfaf56 100644 --- a/openbios-devel/arch/sparc64/ofmem_sparc64.c +++ b/openbios-devel/arch/sparc64/ofmem_sparc64.c @@ -65,13 +65,6 @@ 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; -} - ucell ofmem_arch_get_iomem_base(void) { /* Currently unused */ diff --git a/openbios-devel/include/libopenbios/ofmem.h b/openbios-devel/include/libopenbios/ofmem.h index f2445e7..0b19db1 100644 --- a/openbios-devel/include/libopenbios/ofmem.h +++ b/openbios-devel/include/libopenbios/ofmem.h @@ -63,7 +63,6 @@ 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 ucell ofmem_arch_get_iomem_base(void); extern ucell ofmem_arch_get_iomem_top(void); extern retain_t* ofmem_arch_get_retained(void); diff --git a/openbios-devel/libopenbios/ofmem_common.c b/openbios-devel/libopenbios/ofmem_common.c index 3b8ca15..ef91119 100644 --- a/openbios-devel/libopenbios/ofmem_common.c +++ b/openbios-devel/libopenbios/ofmem_common.c @@ -348,7 +348,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, ofmem_arch_get_phys_top()); + &phys_range_prop, &phys_range_prop_size, &phys_range_prop_used, get_ram_size()); ofmem_update_memory_available(s_phandle_mmu, ofmem->virt_range, &virt_range_prop, &virt_range_prop_size, &virt_range_prop_used, (ucell)-1); ofmem_update_mmu_translations(); @@ -521,7 +521,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, ofmem_arch_get_phys_top(), 1 ); + return ofmem_claim_phys_( phys, size, align, 0, get_ram_size(), 1 ); }
static ucell ofmem_claim_virt_( ucell virt, ucell size, ucell align, @@ -634,7 +634,7 @@ ucell ofmem_claim( ucell addr, ucell size, ucell align ) } else { if( align < PAGE_SIZE ) align = PAGE_SIZE; - phys = ofmem_claim_phys_( -1, size, align, 0, ofmem_arch_get_phys_top(), 1 /* reverse */ ); + phys = ofmem_claim_phys_( -1, size, align, 0, get_ram_size(), 1 /* reverse */ ); virt = ofmem_claim_virt_( phys, size, 0, 0, 0, 0 ); if( phys == -1 || virt == -1 ) { OFMEM_TRACE("ofmem_claim failed\n");
Make sure that the final address of the range is passed into ofmem_update_memory_available() for physical ranges, rather than the physical memory size. This enables us to fix an off-by-one calculation in the tail entry for the available property.
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@ilande.co.uk --- openbios-devel/libopenbios/ofmem_common.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/openbios-devel/libopenbios/ofmem_common.c b/openbios-devel/libopenbios/ofmem_common.c index ef91119..052aa2f 100644 --- a/openbios-devel/libopenbios/ofmem_common.c +++ b/openbios-devel/libopenbios/ofmem_common.c @@ -334,8 +334,8 @@ static void ofmem_update_memory_available( phandle_t ph, range_t *range, }
/* tail */ - if (start < top_address) { - ofmem_arch_create_available_entry(ph, &prop[ncells], start, top_address - start); + if ((start - 1) < top_address) { + ofmem_arch_create_available_entry(ph, &prop[ncells], start, top_address - start + 1); ncells += ofmem_arch_get_available_entry_size(ph); }
@@ -348,7 +348,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, get_ram_size() - 1); ofmem_update_memory_available(s_phandle_mmu, ofmem->virt_range, &virt_range_prop, &virt_range_prop_size, &virt_range_prop_used, (ucell)-1); ofmem_update_mmu_translations();
On 10/05/2015 10:51, Mark Cave-Ayland wrote:
This is a tidy-up and bugfix for the OFMEM available property issue raised by Olivier in his patch to the mailing list.
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@ilande.co.uk
Reviewed-by: Olivier Danet odanet@caramail.com