aboutsummaryrefslogtreecommitdiffstats
path: root/com32/lib/syslinux/zonelist.c
diff options
context:
space:
mode:
Diffstat (limited to 'com32/lib/syslinux/zonelist.c')
-rw-r--r--com32/lib/syslinux/zonelist.c29
1 files changed, 28 insertions, 1 deletions
diff --git a/com32/lib/syslinux/zonelist.c b/com32/lib/syslinux/zonelist.c
index 62b1cf3e..86db51e2 100644
--- a/com32/lib/syslinux/zonelist.c
+++ b/com32/lib/syslinux/zonelist.c
@@ -1,6 +1,6 @@
/* ----------------------------------------------------------------------- *
*
- * Copyright 2007-2008 H. Peter Anvin - All Rights Reserved
+ * Copyright 2007-2009 H. Peter Anvin - All Rights Reserved
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
@@ -201,6 +201,33 @@ int syslinux_memmap_largest(struct syslinux_memmap *list,
}
/*
+ * Find the first (lowest address) zone of a specific type and of
+ * a certain minimum size, with an optional starting address.
+ * The input values of start and len are used as minima.
+ */
+int syslinux_memmap_find(struct syslinux_memmap *list,
+ enum syslinux_memmap_types type,
+ addr_t *start, addr_t *len)
+{
+ addr_t min_start = *start;
+ addr_t min_len = *len;
+
+ while (list->type != SMT_END) {
+ if (list->type == type && list->next->start > min_start) {
+ addr_t xstart = min_start > list->start ? min_start : list->start;
+ addr_t xlen = list->next->start - xstart;
+ if (xlen >= min_len) {
+ *start = xstart;
+ *len = xlen;
+ return 0;
+ }
+ }
+ }
+
+ return -1; /* Not found */
+}
+
+/*
* Free a zonelist.
*/
void syslinux_free_memmap(struct syslinux_memmap *list)