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

repository service svn at openbios.org
Fri Apr 4 11:46:19 CEST 2014


Author: mcayland
Date: Fri Apr  4 11:46:18 2014
New Revision: 1284
URL: http://tracker.coreboot.org/trac/openbios/changeset/1284

Log:
OFMEM: allow remove_range_() to split memory ranges.

If a client tries to free a memory range that lies within one we have already
allocated (and doesn't match exactly), split the range so that we able to just
free the part of the range requested by the client.

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 Mar 30 19:31:19 2014	(r1283)
+++ trunk/openbios-devel/libopenbios/ofmem_common.c	Fri Apr  4 11:46:18 2014	(r1284)
@@ -887,6 +887,25 @@
 {
 	range_t **t, *u;
 
+	/* If not an exact match then split the range */
+	for (t = r; *t; t = &(**t).next) {
+		if (ea > (**t).start && ea < (**t).start + (**t).size - 1) {
+			u = (range_t*)malloc(sizeof(range_t));
+			u->start = ea;
+			u->size = size;
+			u->next = (**t).next;
+
+			OFMEM_TRACE("remove_range_ splitting range with addr=" FMT_plx
+					" size=" FMT_ucellx " -> addr=" FMT_plx " size=" FMT_ucellx ", "
+					"addr=" FMT_plx " size=" FMT_ucellx "\n",
+					(**t).start, (**t).size, (**t).start, (**t).size - size,
+					u->start, u->size);
+
+			(**t).size = (**t).size - size;
+			(**t).next = u;
+		}
+	}
+
 	for (t = r; *t; t = &(**t).next) {
 		if (ea >= (**t).start && ea + size <= (**t).start + (**t).size) {
 			OFMEM_TRACE("remove_range_ freeing range with addr=" FMT_plx



More information about the OpenBIOS mailing list