[OpenBIOS] [commit] r1201 - trunk/openbios-devel/libopenbios

repository service svn at openbios.org
Sun Aug 11 09:24:31 CEST 2013


Author: mcayland
Date: Sun Aug 11 09:24:30 2013
New Revision: 1201
URL: http://tracker.coreboot.org/trac/openbios/changeset/1201

Log:
OFMEM: implement missing remove_range() function

This means that when we call the OFMEM release functions, we actually return
the memory range back to the pool for re-use rather than constantly
allocating a new range every time.

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

Modified:
   trunk/openbios-devel/libopenbios/ofmem_common.c

Modified: trunk/openbios-devel/libopenbios/ofmem_common.c
==============================================================================
--- trunk/openbios-devel/libopenbios/ofmem_common.c	Sun Aug 11 09:24:27 2013	(r1200)
+++ trunk/openbios-devel/libopenbios/ofmem_common.c	Sun Aug 11 09:24:30 2013	(r1201)
@@ -878,9 +878,35 @@
 	return -1;
 }
 
-static void remove_range( ucell ea, ucell size, range_t **r )
+static void remove_range_( phys_addr_t ea, ucell size, range_t **r )
 {
-    OFMEM_TRACE("%s: not implemented\n", __func__);
+	range_t *cr;
+
+	/* Handle special case if we're removing the first entry */
+	if ((**r).start >= ea) {
+		cr = *r;
+		*r = (**r).next;
+		free(cr);
+
+		return;
+	}
+
+	for( ; *r && ((**r).next)->start < ea; r=&(**r).next ) {
+	}
+
+	cr = (**r).next;
+	(**r).next = cr->next;
+	free(cr);
+}
+
+static int remove_range( phys_addr_t ea, ucell size, range_t **r )
+{
+	if( is_free( ea, size, *r ) ) {
+		OFMEM_TRACE("remove_range: range isn't occupied\n");
+		return -1;
+	}
+	remove_range_( ea, size, r );
+	return 0;
 }
 
 /* release memory allocated by ofmem_claim_phys */



More information about the OpenBIOS mailing list