Add an ofmem_release() function and stub out the implementation.
Hook it up for ppc and sparc64.
Cc: Mark Cave-Ayland mark.cave-ayland@siriusit.co.uk Signed-off-by: Andreas Färber andreas.faerber@web.de --- Hello Mark,
Would you be okay with me applying this as an intermediate step? I got lost in the logic of remove_range() at some point and won't get around to looking into this so soon.
BR, Andreas
arch/ppc/qemu/methods.c | 5 +++-- arch/sparc64/lib.c | 5 +++-- include/libopenbios/ofmem.h | 1 + libopenbios/ofmem_common.c | 28 ++++++++++++++++++++++++++-- 4 files changed, 33 insertions(+), 6 deletions(-)
diff --git a/arch/ppc/qemu/methods.c b/arch/ppc/qemu/methods.c index 12424e9..8219cff 100644 --- a/arch/ppc/qemu/methods.c +++ b/arch/ppc/qemu/methods.c @@ -271,8 +271,9 @@ ciface_claim( void ) static void ciface_release( void ) { - POP(); - POP(); + ucell size = POP(); + ucell virt = POP(); + ofmem_release(virt, size); }
diff --git a/arch/sparc64/lib.c b/arch/sparc64/lib.c index 874badb..03dc754 100644 --- a/arch/sparc64/lib.c +++ b/arch/sparc64/lib.c @@ -584,8 +584,9 @@ ciface_claim( void ) static void ciface_release( void ) { - POP(); - POP(); + ucell size = POP(); + ucell virt = POP(); + ofmem_release(virt, size); }
DECLARE_NODE(memory, INSTALL_OPEN, 0, "/memory"); diff --git a/include/libopenbios/ofmem.h b/include/libopenbios/ofmem.h index 0bd63a3..74f1efd 100644 --- a/include/libopenbios/ofmem.h +++ b/include/libopenbios/ofmem.h @@ -101,6 +101,7 @@ extern ucell ofmem_retain( ucell phys, ucell size, ucell align ); extern int ofmem_map( ucell phys, ucell virt, ucell size, ucell mode ); extern int ofmem_unmap( ucell virt, ucell size );
+extern void ofmem_release( ucell virt, ucell size ); extern void ofmem_release_phys( ucell phys, ucell size ); extern void ofmem_release_virt( ucell virt, ucell size ); extern ucell ofmem_translate( ucell virt, ucell *ret_mode ); diff --git a/libopenbios/ofmem_common.c b/libopenbios/ofmem_common.c index 22b268d..64695b6 100644 --- a/libopenbios/ofmem_common.c +++ b/libopenbios/ofmem_common.c @@ -770,13 +770,19 @@ ucell ofmem_translate( ucell virt, ucell *mode ) return -1; }
+static void remove_range( ucell ea, ucell size, range_t **r ) +{ + OFMEM_TRACE("%s: not implemented\n", __func__); +} + /* release memory allocated by ofmem_claim_phys */ void ofmem_release_phys( ucell phys, ucell size ) { OFMEM_TRACE("ofmem_release_phys addr=" FMT_ucellx " size=" FMT_ucellx "\n", phys, size);
- OFMEM_TRACE("ofmem_release_phys not implemented"); + ofmem_t *ofmem = ofmem_arch_get_private(); + remove_range(phys, size, &ofmem->phys_range); }
/* release memory allocated by ofmem_claim_virt */ @@ -785,7 +791,25 @@ void ofmem_release_virt( ucell virt, ucell size ) OFMEM_TRACE("ofmem_release_virt addr=" FMT_ucellx " size=" FMT_ucellx "\n", virt, size);
- OFMEM_TRACE("ofmem_release_virt not implemented"); + ofmem_t *ofmem = ofmem_arch_get_private(); + remove_range(virt, size, &ofmem->virt_range); +} + +/* release memory allocated by ofmem_claim - 6.3.2.4 */ +void ofmem_release( ucell virt, ucell size ) +{ + OFMEM_TRACE("%s addr=" FMT_ucellx " size=" FMT_ucellx "\n", + __func__, virt, size); + + ucell mode; + ucell phys = ofmem_translate(virt, &mode); + if (phys == (ucell)-1) { + OFMEM_TRACE("%s: no mapping\n", __func__); + return; + } + ofmem_unmap(virt, size); + ofmem_release_virt(virt, size); + ofmem_release_phys(phys, size); }
/************************************************************************/