Author: afaerber Date: Sun Oct 31 16:12:01 2010 New Revision: 938 URL: http://tracker.coreboot.org/trac/openbios/changeset/938
Log: ofmem: CIF release preparations
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
Modified: trunk/openbios-devel/arch/ppc/qemu/methods.c trunk/openbios-devel/arch/sparc64/lib.c trunk/openbios-devel/include/libopenbios/ofmem.h trunk/openbios-devel/libopenbios/ofmem_common.c
Modified: trunk/openbios-devel/arch/ppc/qemu/methods.c ============================================================================== --- trunk/openbios-devel/arch/ppc/qemu/methods.c Sun Oct 31 11:30:22 2010 (r937) +++ trunk/openbios-devel/arch/ppc/qemu/methods.c Sun Oct 31 16:12:01 2010 (r938) @@ -271,8 +271,9 @@ static void ciface_release( void ) { - POP(); - POP(); + ucell size = POP(); + ucell virt = POP(); + ofmem_release(virt, size); }
Modified: trunk/openbios-devel/arch/sparc64/lib.c ============================================================================== --- trunk/openbios-devel/arch/sparc64/lib.c Sun Oct 31 11:30:22 2010 (r937) +++ trunk/openbios-devel/arch/sparc64/lib.c Sun Oct 31 16:12:01 2010 (r938) @@ -584,8 +584,9 @@ static void ciface_release( void ) { - POP(); - POP(); + ucell size = POP(); + ucell virt = POP(); + ofmem_release(virt, size); }
DECLARE_NODE(memory, INSTALL_OPEN, 0, "/memory");
Modified: trunk/openbios-devel/include/libopenbios/ofmem.h ============================================================================== --- trunk/openbios-devel/include/libopenbios/ofmem.h Sun Oct 31 11:30:22 2010 (r937) +++ trunk/openbios-devel/include/libopenbios/ofmem.h Sun Oct 31 16:12:01 2010 (r938) @@ -101,6 +101,7 @@ 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 );
Modified: trunk/openbios-devel/libopenbios/ofmem_common.c ============================================================================== --- trunk/openbios-devel/libopenbios/ofmem_common.c Sun Oct 31 11:30:22 2010 (r937) +++ trunk/openbios-devel/libopenbios/ofmem_common.c Sun Oct 31 16:12:01 2010 (r938) @@ -770,13 +770,19 @@ 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 @@ 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); }
/************************************************************************/