All of lore.kernel.org
 help / color / mirror / Atom feed
From: Edgar Hucek <hostmaster@ed-soft.at>
To: Linus Torvalds <torvalds@osdl.org>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>,
	"H. Peter Anvin" <hpa@zytor.com>,
	LKML <linux-kernel@vger.kernel.org>,
	akpm@osdl.org
Subject: [PATCH 1/1] Add efi e820 memory mapping on x86 [try #1]
Date: Sun, 16 Jul 2006 10:55:30 +0200	[thread overview]
Message-ID: <44B9FF02.3020600@ed-soft.at> (raw)
In-Reply-To: <Pine.LNX.4.64.0607140901200.5623@g5.osdl.org>

This Patch add an efi e820 memory mapping.

Signed-off-by: Edgar Hucek <hostmaster@ed-soft.at>


diff -uNr linux-2.6.18-rc2/arch/i386/kernel/setup.c
linux-2.6.18-rc2.mactel/arch/i386/kernel/setup.c
--- linux-2.6.18-rc2/arch/i386/kernel/setup.c    2006-07-16
10:38:10.000000000 +0200
+++ linux-2.6.18-rc2.mactel/arch/i386/kernel/setup.c    2006-07-16
10:16:12.000000000 +0200
@@ -414,19 +414,17 @@
 {
     int x;
 
-    if (!efi_enabled) {
-               x = e820.nr_map;
+    x = e820.nr_map;
 
-        if (x == E820MAX) {
-            printk(KERN_ERR "Ooops! Too many entries in the memory
map!\n");
-            return;
-        }
-
-        e820.map[x].addr = start;
-        e820.map[x].size = size;
-        e820.map[x].type = type;
-        e820.nr_map++;
+    if (x == E820MAX) {
+        printk(KERN_ERR "Ooops! Too many entries in the memory map!\n");
+        return;
     }
+
+    e820.map[x].addr = start;
+    e820.map[x].size = size;
+    e820.map[x].type = type;
+    e820.nr_map++;
 } /* add_memory_region */
 
 #define E820_DEBUG    1
@@ -1431,6 +1429,59 @@
 #endif
 
 /*
+ * Make a e820 memory map
+ */
+void __init efi_init_e820_map(void)
+{
+    efi_memory_desc_t *md;
+    unsigned long long start = 0;
+    unsigned long long end = 0;
+    unsigned long long size = 0;
+    void *p;
+
+    e820.nr_map = 0;
+
+    for (p = memmap.map; p < memmap.map_end;
+        p += memmap.desc_size) {
+        md = p;
+        switch (md->type) {
+        case EFI_ACPI_RECLAIM_MEMORY:
+            add_memory_region(md->phys_addr, md->num_pages <<
EFI_PAGE_SHIFT, E820_ACPI);
+            break;
+        case EFI_RUNTIME_SERVICES_CODE:
+        case EFI_RUNTIME_SERVICES_DATA:
+        case EFI_RESERVED_TYPE:
+        case EFI_MEMORY_MAPPED_IO:
+        case EFI_MEMORY_MAPPED_IO_PORT_SPACE:
+        case EFI_UNUSABLE_MEMORY:
+            add_memory_region(md->phys_addr, md->num_pages <<
EFI_PAGE_SHIFT, E820_RESERVED);
+            break;
+        case EFI_LOADER_CODE:
+        case EFI_LOADER_DATA:
+        case EFI_BOOT_SERVICES_CODE:
+        case EFI_BOOT_SERVICES_DATA:
+        case EFI_CONVENTIONAL_MEMORY:
+            start = md->phys_addr;
+            size = md->num_pages << EFI_PAGE_SHIFT;
+            end = start + size;
+            if (start < 0x100000ULL && end > 0xA0000ULL) {
+                if (start < 0xA0000ULL)
+                    add_memory_region(start, 0xA0000ULL-start, E820_RAM);
+                if (end <= 0x100000ULL)
+                    continue;
+                start = 0x100000ULL;
+                size = end - start;
+            }
+            add_memory_region(start, size, E820_RAM);
+            break;
+        case EFI_ACPI_MEMORY_NVS:
+            add_memory_region(md->phys_addr, md->num_pages <<
EFI_PAGE_SHIFT, E820_NVS);
+            break;
+        }
+    }
+}
+
+/*
  * Determine if we were loaded by an EFI loader.  If so, then we have
also been
  * passed the efi memmap, systab, etc., so we should use these data
structures
  * for initialization.  Note, the efi init code path is determined by the
@@ -1478,9 +1529,11 @@
     rd_doload = ((RAMDISK_FLAGS & RAMDISK_LOAD_FLAG) != 0);
 #endif
     ARCH_SETUP
-    if (efi_enabled)
+    if (efi_enabled) {
         efi_init();
-    else {
+        efi_init_e820_map();
+        print_memory_map("BIOS-EFI");
+    } else {
         printk(KERN_INFO "BIOS-provided physical RAM map:\n");
         print_memory_map(machine_specific_memory_setup());
     }


  reply	other threads:[~2006-07-16  8:55 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-06-26 21:19 [PATCH 1/1] Fix boot on efi 32 bit Machines [try #4] Edgar Hucek
2006-06-26 21:33 ` Linus Torvalds
2006-06-27  6:15   ` Edgar Hucek
2006-06-27  6:20     ` Linus Torvalds
2006-06-28 22:37       ` H. Peter Anvin
2006-07-02 17:39         ` Eric W. Biederman
2006-07-02 17:42           ` H. Peter Anvin
2006-07-02 18:26             ` Eric W. Biederman
2006-07-02 18:46               ` Arjan van de Ven
2006-07-05  9:38               ` Edgar Hucek
2006-07-05 15:52                 ` Eric W. Biederman
2006-07-13 21:46                   ` Edgar Hucek
2006-07-13 22:15                     ` Linus Torvalds
2006-07-14  4:23                       ` Eric W. Biederman
2006-07-14  6:22                         ` H. Peter Anvin
2006-07-14  6:20                       ` Edgar Hucek
2006-07-14 16:09                         ` Linus Torvalds
2006-07-16  8:55                           ` Edgar Hucek [this message]
2006-07-25  4:29                             ` [PATCH 1/1] Add efi e820 memory mapping on x86 [try #1] Andrew Morton
2006-07-25  5:17                               ` Eric W. Biederman
2006-07-25  5:32                               ` Linus Torvalds
2006-07-25  5:34                                 ` H. Peter Anvin
2006-07-25  5:44                                   ` Linus Torvalds
2006-07-25  6:26                                     ` H. Peter Anvin
2006-07-25  6:00                                 ` Linus Torvalds
2006-07-16  9:00                           ` [PATCH 1/1] Add force of use MMCONFIG " Edgar Hucek
2006-07-25  4:33                             ` Andrew Morton
2006-07-25  5:27                               ` Linus Torvalds
2006-07-26 15:05                                 ` 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=44B9FF02.3020600@ed-soft.at \
    --to=hostmaster@ed-soft.at \
    --cc=akpm@osdl.org \
    --cc=ebiederm@xmission.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@osdl.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.