Author: mcayland
Date: Fri Apr 4 11:46:21 2014
New Revision: 1285
URL: http://tracker.coreboot.org/trac/openbios/changeset/1285
Log:
OFMEM: redefine OFMEM_TRACE macro so that it always compiles
Make sure that we always compile the OFMEM_TRACE macro regardless of whether
CONFIG_DEBUG_OFMEM is set, similar to the way in which the DEBUG macros work
in QEMU. This relies on the fact that the compiler optimiser will work out
that the compile-time "if" test is always true/false and optimise the result
out if is it not required.
This ensures that we always get proper debug argument checking and means that
certain sections of code don't keep giving unused variable warnings when they
only appear in debug codepaths.
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland(a)ilande.co.uk>
Modified:
trunk/openbios-devel/include/libopenbios/ofmem.h
Modified: trunk/openbios-devel/include/libopenbios/ofmem.h
==============================================================================
--- trunk/openbios-devel/include/libopenbios/ofmem.h Fri Apr 4 11:46:18 2014 (r1284)
+++ trunk/openbios-devel/include/libopenbios/ofmem.h Fri Apr 4 11:46:21 2014 (r1285)
@@ -132,9 +132,15 @@
#define PAGE_ALIGN(addr) (((addr) + PAGE_SIZE - 1) & PAGE_MASK)
#if defined(CONFIG_DEBUG_OFMEM)
-# define OFMEM_TRACE(fmt, ...) do { printk("OFMEM: " fmt, ## __VA_ARGS__); } while (0)
+ #define DEBUG_OFMEM 1
#else
-# define OFMEM_TRACE(fmt, ...) do {} while(0)
+ #define DEBUG_OFMEM 0
#endif
+#define OFMEM_TRACE(fmt, ...) do { \
+ if (DEBUG_OFMEM) { \
+ printk("OFMEM: " fmt, ## __VA_ARGS__); \
+ } \
+} while (0);
+
#endif /* _H_OFMEM */
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(a)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