public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Hariprasad Nellitheertha <hari@in.ibm.com>
To: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	fastboot <fastboot@lists.osdl.org>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>,
	Andrew Morton <akpm@osdl.org>
Subject: Re: [RFC][PATCH 6/7] i386 code for the activemem map
Date: Thu, 24 Mar 2005 11:28:50 +0530	[thread overview]
Message-ID: <4242571A.4020608@in.ibm.com> (raw)
In-Reply-To: <424256BA.2060901@in.ibm.com>

[-- Attachment #1: Type: text/plain, Size: 14 bytes --]

Regards, Hari

[-- Attachment #2: activemem-i386.patch --]
[-- Type: text/plain, Size: 5739 bytes --]


---

This patch contains the i386 specific code to generate the
/proc/activemem view.
---

Signed-off-by: Hariprasad Nellitheertha <hari@in.ibm.com>
---

 linux-2.6.12-rc1-hari/arch/i386/kernel/efi.c   |   31 +++++++++++++++
 linux-2.6.12-rc1-hari/arch/i386/kernel/setup.c |   50 +++++++++++++++++++++++++
 linux-2.6.12-rc1-hari/include/linux/efi.h      |    2 +
 linux-2.6.12-rc1-hari/include/linux/ioport.h   |    1 
 4 files changed, 84 insertions(+)

diff -puN arch/i386/kernel/efi.c~activemem-i386 arch/i386/kernel/efi.c
--- linux-2.6.12-rc1/arch/i386/kernel/efi.c~activemem-i386	2005-03-23 17:48:22.000000000 +0530
+++ linux-2.6.12-rc1-hari/arch/i386/kernel/efi.c	2005-03-23 17:48:22.000000000 +0530
@@ -630,6 +630,37 @@ void __init efi_initialize_physmem_resou
 	}
 }
 
+void __init efi_initialize_activemem_resources(struct resource *code_resource,
+					       struct resource *data_resource)
+{
+	struct resource *res, *code_resource_copy, *data_resource_copy;
+	efi_memory_desc_t *md;
+	int i;
+#ifdef CONFIG_KEXEC
+	struct resource *crashk_res_copy;
+
+	crashk_res_copy = alloc_bootmem_low(sizeof(struct resource));
+	memcpy(crashk_res_copy, &crashk_res, sizeof(struct resource));
+#endif
+
+	code_resource_copy = alloc_bootmem_low(2*sizeof(struct resource));
+	data_resource_copy = code_resource_copy + sizeof(struct resource);
+	memcpy(code_resource_copy, code_resource, sizeof(struct resource));
+	memcpy(data_resource_copy, data_resource, sizeof(struct resource));
+
+	for (i = 0; i < memmap.nr_map; i++) {
+		md = &memmap.map[i];
+		res = alloc_efi_resource(md, &activemem_resource, i);
+		if (md->type == EFI_CONVENTIONAL_MEMORY) {
+			request_resource(res, code_resource_copy);
+			request_resource(res, data_resource_copy);
+#ifdef CONFIG_KEXEC
+			request_resource(res, crashk_res_copy);
+#endif
+		}
+	}
+}
+
 /*
  * Make a copy of memmap for creating the physmem resources later.
  */
diff -puN arch/i386/kernel/setup.c~activemem-i386 arch/i386/kernel/setup.c
--- linux-2.6.12-rc1/arch/i386/kernel/setup.c~activemem-i386	2005-03-23 17:48:22.000000000 +0530
+++ linux-2.6.12-rc1-hari/arch/i386/kernel/setup.c	2005-03-23 17:48:22.000000000 +0530
@@ -1303,6 +1303,39 @@ static void __init legacy_init_physmem_r
 }
 
 /*
+ * Request address space for standard ROM and RAM resources. In i386, this is
+ * similar to the entries in iomem_resources. But we still do this so we have
+ * consistent views across architectures.
+ */
+static void __init legacy_init_activemem_resources(void)
+{
+	int i;
+	struct resource *res, *code_resource_copy, *data_resource_copy;
+#ifdef CONFIG_KEXEC
+	struct resource *crashk_res_copy;
+
+	crashk_res_copy = alloc_bootmem_low(sizeof(struct resource));
+	memcpy(crashk_res_copy, &crashk_res, sizeof(struct resource));
+#endif
+
+	code_resource_copy = alloc_bootmem_low(2*sizeof(struct resource));
+	data_resource_copy = code_resource_copy + sizeof(struct resource);
+	memcpy(code_resource_copy, &code_resource, sizeof(struct resource));
+	memcpy(data_resource_copy, &data_resource, sizeof(struct resource));
+
+	for (i = 0; i < e820.nr_map; i++) {
+		res = alloc_e820_resource(&e820, &activemem_resource, i);
+		if (e820.map[i].type == E820_RAM) {
+			request_resource(res, code_resource_copy);
+			request_resource(res, data_resource_copy);
+#ifdef CONFIG_KEXEC
+			request_resource(res, crashk_res_copy);
+#endif
+		}
+	}
+}
+
+/*
  * Request address space for all standard resources
  */
 static void __init register_memory(void)
@@ -1491,6 +1524,21 @@ static void __init register_physmem_reso
 		legacy_init_physmem_resources();
 }
 
+/*
+ * This is similar to the entries in iomem. But we create this
+ * to ensure consistency across archs. activemem contains a list
+ * RAM resources that are used by the current kernel. Is different
+ * from physmem when the kernel is booted with mem= or memmap=
+ * options.
+ */
+static void __init register_activemem_resources(void)
+{
+	if (efi_enabled)
+		efi_initialize_activemem_resources(&code_resource, &data_resource);
+	else
+		legacy_init_activemem_resources();
+}
+
 
 /*
  * Determine if we were loaded by an EFI loader.  If so, then we have also been
@@ -1590,6 +1638,8 @@ void __init setup_arch(char **cmdline_p)
 
 	register_physmem_resources();
 
+	register_activemem_resources();
+
 #ifdef CONFIG_EARLY_PRINTK
 	{
 		char *s = strstr(*cmdline_p, "earlyprintk=");
diff -puN include/linux/efi.h~activemem-i386 include/linux/efi.h
--- linux-2.6.12-rc1/include/linux/efi.h~activemem-i386	2005-03-23 17:48:22.000000000 +0530
+++ linux-2.6.12-rc1-hari/include/linux/efi.h	2005-03-23 17:48:22.000000000 +0530
@@ -302,6 +302,8 @@ extern int __init efi_uart_console_only 
 extern void efi_initialize_iomem_resources(struct resource *code_resource,
 					struct resource *data_resource);
 extern void efi_initialize_physmem_resources(void);
+extern void efi_initialize_activemem_resources(struct resource *code_resource,
+					struct resource *data_resource);
 extern void preserve_memmap(void);
 extern unsigned long __init efi_get_time(void);
 extern int __init efi_set_rtc_mmss(unsigned long nowtime);
diff -puN include/linux/ioport.h~activemem-i386 include/linux/ioport.h
--- linux-2.6.12-rc1/include/linux/ioport.h~activemem-i386	2005-03-23 17:48:22.000000000 +0530
+++ linux-2.6.12-rc1-hari/include/linux/ioport.h	2005-03-23 17:48:22.000000000 +0530
@@ -92,6 +92,7 @@ struct resource_list {
 extern struct resource ioport_resource;
 extern struct resource iomem_resource;
 extern struct resource physmem_resource;
+extern struct resource activemem_resource;
 
 extern int request_resource(struct resource *root, struct resource *new);
 extern struct resource * ____request_resource(struct resource *root, struct resource *new);
_

  reply	other threads:[~2005-03-24  6:01 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-03-24  5:49 [RFC] Obtaining memory information for kexec/kdump Hariprasad Nellitheertha
2005-03-24  5:52 ` [RFC][PATCH 1/7] Converting resource struct fields to 64 bit Hariprasad Nellitheertha
2005-03-24  5:53   ` [RFC][PATCH 2/7] Common code for the physmem map Hariprasad Nellitheertha
2005-03-24  5:55     ` [RFC][PATCH 3/7] i386 " Hariprasad Nellitheertha
2005-03-24  5:56       ` [RFC][PATCH 4/7] x86_64 " Hariprasad Nellitheertha
2005-03-24  5:57         ` [RFC][PATCH 5/7] Common code for the activemem map Hariprasad Nellitheertha
2005-03-24  5:58           ` Hariprasad Nellitheertha [this message]
2005-03-24  6:00             ` [RFC][PATCH 7/7] x86_64 " Hariprasad Nellitheertha
2005-03-24  7:50 ` [RFC] Obtaining memory information for kexec/kdump Dave Hansen
2005-03-24 10:19   ` Hariprasad Nellitheertha
2005-03-24 15:32     ` Dave Hansen
2005-03-28 13:00       ` Hariprasad Nellitheertha
2005-03-28 16:18         ` Dave Hansen

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=4242571A.4020608@in.ibm.com \
    --to=hari@in.ibm.com \
    --cc=akpm@osdl.org \
    --cc=ebiederm@xmission.com \
    --cc=fastboot@lists.osdl.org \
    --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