Re: [RFC][i386] Comma parsing for the memmap= kernel command lineoption

From: Hariprasad Nellitheertha
Date: Thu Apr 28 2005 - 06:03:32 EST


Regards, Hari
This patch adds comma parsing ability to the i386
memmap= kernel command line option. With this, multiple
entries to memmap can be separated by a comma instead of
separate entries.

For example, memmap=exactmap,640k@0M,1024M@1M

Signed-off-by: Hariprasad Nellitheertha <hari@xxxxxxxxxx>
---

linux-2.6.12-rc2-hari/arch/i386/kernel/setup.c | 79 +++++++++++++------------
1 files changed, 43 insertions(+), 36 deletions(-)

diff -puN arch/i386/kernel/setup.c~i386-memmap-comma-parsing arch/i386/kernel/setup.c
--- linux-2.6.12-rc2/arch/i386/kernel/setup.c~i386-memmap-comma-parsing 2005-04-27 16:30:05.000000000 +0530
+++ linux-2.6.12-rc2-hari/arch/i386/kernel/setup.c 2005-04-28 15:04:42.000000000 +0530
@@ -716,45 +716,52 @@ static void __init parse_cmdline_early (
}

else if (!memcmp(from, "memmap=", 7)) {
- if (to != command_line)
- to--;
- if (!memcmp(from+7, "exactmap", 8)) {
+ from += 7;
+ do {
+ if (to != command_line)
+ to--;
+ if (!memcmp(from, "exactmap", 8)) {
#ifdef CONFIG_CRASH_DUMP
- /* If we are doing a crash dump, we
- * still need to know the real mem
- * size before original memory map is
- * reset.
- */
- find_max_pfn();
- saved_max_pfn = max_pfn;
-#endif
- from += 8+7;
- e820.nr_map = 0;
- userdef = 1;
- } else {
- /* If the user specifies memory size, we
- * limit the BIOS-provided memory map to
- * that size. exactmap can be used to specify
- * the exact map. mem=number can be used to
- * trim the existing memory map.
- */
- unsigned long long start_at, mem_size;
-
- mem_size = memparse(from+7, &from);
- if (*from == '@') {
- start_at = memparse(from+1, &from);
- add_memory_region(start_at, mem_size, E820_RAM);
- } else if (*from == '#') {
- start_at = memparse(from+1, &from);
- add_memory_region(start_at, mem_size, E820_ACPI);
- } else if (*from == '$') {
- start_at = memparse(from+1, &from);
- add_memory_region(start_at, mem_size, E820_RESERVED);
+ /* If we are doing a crash dump, we
+ * still need to know the real mem
+ * size before original memory map is
+ * reset.
+ */
+ find_max_pfn();
+ saved_max_pfn = max_pfn;
+#endif
+ from += 8;
+ e820.nr_map = 0;
+ userdef = 1;
} else {
- limit_regions(mem_size);
- userdef=1;
+ /* If the user specifies memory size, we
+ * limit the BIOS-provided memory map to
+ * that size. exactmap can be used to specify
+ * the exact map. mem=number can be used to
+ * trim the existing memory map.
+ */
+ unsigned long long start_at, mem_size;
+
+ mem_size = memparse(from, &from);
+ if (*from == '@') {
+ start_at = memparse(from+1, &from);
+ add_memory_region(start_at, mem_size, E820_RAM);
+ } else if (*from == '#') {
+ start_at = memparse(from+1, &from);
+ add_memory_region(start_at, mem_size, E820_ACPI);
+ } else if (*from == '$') {
+ start_at = memparse(from+1, &from);
+ add_memory_region(start_at, mem_size, E820_RESERVED);
+ } else {
+ limit_regions(mem_size);
+ userdef=1;
+ }
}
- }
+ if (*from != ',')
+ break;
+ else
+ from += 1;
+ } while(1);
}

else if (!memcmp(from, "noexec=", 7))
_