From: Arjan van de Ven <arjan@linux.intel.com>
To: linux-kernel@vger.kernel.org, ak@suse.de
Subject: [patch 2 of 4] Introduce e820_all_mapped
Date: Sat, 25 Mar 2006 17:24:04 +0100 [thread overview]
Message-ID: <1143303845.2898.7.camel@laptopd505.fenrus.org> (raw)
In-Reply-To: <1143303796.2898.6.camel@laptopd505.fenrus.org>
Introduce a e820_all_mapped() function which checks if the entire
range <start,end> is mapped with type. This is done by moving the local
start variable to the end of each known-good region; if at the end
of the function the start address is still before end, there must be
a part that's not of the correct type; otherwise it's a good region.
Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
---
arch/x86_64/kernel/e820.c | 32 ++++++++++++++++++++++++++++++++
include/asm-x86_64/e820.h | 1 +
2 files changed, 33 insertions(+)
Index: linux-2.6.16-mmconfig/arch/x86_64/kernel/e820.c
===================================================================
--- linux-2.6.16-mmconfig.orig/arch/x86_64/kernel/e820.c
+++ linux-2.6.16-mmconfig/arch/x86_64/kernel/e820.c
@@ -80,6 +80,9 @@ static inline int bad_addr(unsigned long
return 0;
}
+/*
+ * This function checks if any part of the range <start,end> is mapped with type.
+ */
int __init e820_any_mapped(unsigned long start, unsigned long end, unsigned type)
{
int i;
@@ -94,6 +97,35 @@ int __init e820_any_mapped(unsigned long
return 0;
}
+/*
+ * This function checks if the entire range <start,end> is mapped with type.
+ *
+ * Note: this function only works correct if the e820 table is sorted and
+ * not-overlapping, which is the case
+ */
+int __init e820_all_mapped(unsigned long start, unsigned long end, unsigned type)
+{
+ int i;
+ for (i = 0; i < e820.nr_map; i++) {
+ struct e820entry *ei = &e820.map[i];
+ if (type && ei->type != type)
+ continue;
+ /* is the region (part) in overlap with the current region ?*/
+ if (ei->addr >= end || ei->addr + ei->size <= start)
+ continue;
+
+ /* if the region is at the beginning of <start,end> we move
+ * start to the end of the region since it's ok until there
+ */
+ if (ei->addr <= start)
+ start = ei->addr + ei->size;
+ /* if start is now at or beyond end, we're done, full coverage */
+ if (start >= end)
+ return 1; /* we're done */
+ }
+ return 0;
+}
+
/*
* Find a free area in a specific range.
*/
Index: linux-2.6.16-mmconfig/include/asm-x86_64/e820.h
===================================================================
--- linux-2.6.16-mmconfig.orig/include/asm-x86_64/e820.h
+++ linux-2.6.16-mmconfig/include/asm-x86_64/e820.h
@@ -48,6 +48,7 @@ extern unsigned long e820_end_of_ram(voi
extern void e820_reserve_resources(void);
extern void e820_print_map(char *who);
extern int e820_any_mapped(unsigned long start, unsigned long end, unsigned type);
+extern int e820_all_mapped(unsigned long start, unsigned long end, unsigned type);
extern void e820_bootmem_free(pg_data_t *pgdat, unsigned long start,unsigned long end);
extern void e820_setup_gap(void);
next prev parent reply other threads:[~2006-03-25 16:26 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-03-25 16:23 [patch 1 of 4] Rename e820_map to e820_any_map to reflect its behavior better Arjan van de Ven
2006-03-25 16:24 ` Arjan van de Ven [this message]
2006-03-25 16:24 ` [patch 3 of 4] MCFG sanity check Arjan van de Ven
2006-03-25 16:25 ` [patch 4 of 4] i386 version of the changes Arjan van de Ven
2006-03-25 16:50 ` [patch 1 of 4] Rename e820_map to e820_any_map to reflect its behavior better Andi Kleen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1143303845.2898.7.camel@laptopd505.fenrus.org \
--to=arjan@linux.intel.com \
--cc=ak@suse.de \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®