WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] [IA64] Update efi.c and efi.h to linux-2.

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] [IA64] Update efi.c and efi.h to linux-2.6.21
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Sat, 16 Jun 2007 05:37:29 -0700
Delivery-date: Sat, 16 Jun 2007 05:35:56 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Alex Williamson <alex.williamson@xxxxxx>
# Date 1180039394 21600
# Node ID 301267d0db1293a403da1d1afc11568f7e0abb87
# Parent  90f19b7667f755f3fda2132c490854baca70f33c
[IA64] Update efi.c and efi.h to linux-2.6.21

Signed-off-by: Akio Takebe <takebe_akio@xxxxxxxxxxxxxx>
---
 xen/arch/ia64/linux-xen/README.origin              |    4 
 xen/arch/ia64/linux-xen/efi.c                      |  520 +++++++++++++++++----
 xen/include/asm-ia64/linux-xen/linux/README.origin |    4 
 xen/include/asm-ia64/linux-xen/linux/efi.h         |   36 +
 4 files changed, 456 insertions(+), 108 deletions(-)

diff -r 90f19b7667f7 -r 301267d0db12 xen/arch/ia64/linux-xen/README.origin
--- a/xen/arch/ia64/linux-xen/README.origin     Thu May 24 14:20:19 2007 -0600
+++ b/xen/arch/ia64/linux-xen/README.origin     Thu May 24 14:43:14 2007 -0600
@@ -6,7 +6,6 @@
 # easily updated to future versions of the corresponding Linux files.
 
 cmdline.c              -> linux/lib/cmdline.c
-efi.c                  -> linux/arch/ia64/kernel/efi.c
 entry.h                        -> linux/arch/ia64/kernel/entry.h
 entry.S                        -> linux/arch/ia64/kernel/entry.S
 head.S                 -> linux/arch/ia64/kernel/head.S
@@ -42,3 +41,6 @@ perfmon_itanium.h     -> linux/arch/kernel/p
 perfmon_itanium.h      -> linux/arch/kernel/perfmon_itanium.h
 perfmon_mckinley.h     -> linux/arch/kernel/perfmon_mckinley.h
 perfmon_montecito.h    -> linux/arch/kernel/perfmon_montecito.h
+
+# The files below are from Linux-2.6.21
+efi.c                  -> linux/arch/ia64/kernel/efi.c
diff -r 90f19b7667f7 -r 301267d0db12 xen/arch/ia64/linux-xen/efi.c
--- a/xen/arch/ia64/linux-xen/efi.c     Thu May 24 14:20:19 2007 -0600
+++ b/xen/arch/ia64/linux-xen/efi.c     Thu May 24 14:43:14 2007 -0600
@@ -8,6 +8,8 @@
  * Copyright (C) 1999-2003 Hewlett-Packard Co.
  *     David Mosberger-Tang <davidm@xxxxxxxxxx>
  *     Stephane Eranian <eranian@xxxxxxxxxx>
+ * (c) Copyright 2006 Hewlett-Packard Development Company, L.P.
+ *     Bjorn Helgaas <bjorn.helgaas@xxxxxx>
  *
  * All EFI Runtime Services are not implemented yet as EFI only
  * supports physical mode addressing on SoftSDV. This is to be fixed
@@ -18,12 +20,14 @@
  * Goutham Rao: <goutham.rao@xxxxxxxxx>
  *     Skip non-WB memory and ignore empty memory ranges.
  */
-#include <linux/config.h>
 #include <linux/module.h>
+#include <linux/bootmem.h>
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/types.h>
 #include <linux/time.h>
+#include <linux/efi.h>
+#include <linux/kexec.h>
 
 #include <asm/io.h>
 #include <asm/kregs.h>
@@ -32,21 +36,24 @@
 #include <asm/processor.h>
 #include <asm/mca.h>
 
-#include <linux/efi.h>
-
 #define EFI_DEBUG      0
 
 extern efi_status_t efi_call_phys (void *, ...);
+#ifdef XEN
+/* this should be defined in linux/kernel.h */
 extern unsigned long long memparse (char *ptr, char **retptr);
+/* this should be defined in linux/efi.h */
+//#define EFI_INVALID_TABLE_ADDR          (void *)(~0UL)
+#endif
 
 struct efi efi;
 EXPORT_SYMBOL(efi);
 static efi_runtime_services_t *runtime;
 #if defined(XEN) && !defined(CONFIG_VIRTUAL_FRAME_TABLE)
 // this is a temporary hack to avoid CONFIG_VIRTUAL_MEM_MAP
-static unsigned long mem_limit = ~0UL, max_addr = 0x100000000;
+static unsigned long mem_limit = ~0UL, max_addr = 0x100000000UL, min_addr = 
0UL;
 #else
-static unsigned long mem_limit = ~0UL, max_addr = ~0UL;
+static unsigned long mem_limit = ~0UL, max_addr = ~0UL, min_addr = 0UL;
 #endif
 
 #define efi_call_virt(f, args...)      (*(f))(args)
@@ -232,7 +239,7 @@ efi_gettimeofday (struct timespec *ts)
 #endif
 
 static int
-is_available_memory (efi_memory_desc_t *md)
+is_memory_available (efi_memory_desc_t *md)
 {
        if (!(md->attribute & EFI_MEMORY_WB))
                return 0;
@@ -255,6 +262,32 @@ typedef struct kern_memdesc {
 } kern_memdesc_t;
 
 static kern_memdesc_t *kern_memmap;
+
+#define efi_md_size(md)        (md->num_pages << EFI_PAGE_SHIFT)
+
+static inline u64
+kmd_end(kern_memdesc_t *kmd)
+{
+       return (kmd->start + (kmd->num_pages << EFI_PAGE_SHIFT));
+}
+
+static inline u64
+efi_md_end(efi_memory_desc_t *md)
+{
+       return (md->phys_addr + efi_md_size(md));
+}
+
+static inline int
+efi_wb(efi_memory_desc_t *md)
+{
+       return (md->attribute & EFI_MEMORY_WB);
+}
+
+static inline int
+efi_uc(efi_memory_desc_t *md)
+{
+       return (md->attribute & EFI_MEMORY_UC);
+}
 
 static void
 walk (efi_freemem_callback_t callback, void *arg, u64 attr)
@@ -361,11 +394,10 @@ efi_get_pal_addr (void)
 #endif
                return __va(md->phys_addr);
        }
-       printk(KERN_WARNING "%s: no PAL-code memory-descriptor found",
+       printk(KERN_WARNING "%s: no PAL-code memory-descriptor found\n",
               __FUNCTION__);
        return NULL;
 }
-
 
 #ifdef XEN
 void *pal_vaddr = 0;
@@ -405,24 +437,22 @@ efi_init (void)
        efi_config_table_t *config_tables;
        efi_char16_t *c16;
        u64 efi_desc_size;
-       char *cp, *end, vendor[100] = "unknown";
+       char *cp, vendor[100] = "unknown";
+       int i;
+
+       /* it's too early to be able to use the standard kernel command line 
support... */
+#ifdef XEN
        extern char saved_command_line[];
-       int i;
-
-       /* it's too early to be able to use the standard kernel command line 
support... */
        for (cp = saved_command_line; *cp; ) {
+#else
+       for (cp = boot_command_line; *cp; ) {
+#endif
                if (memcmp(cp, "mem=", 4) == 0) {
-                       cp += 4;
-                       mem_limit = memparse(cp, &end);
-                       if (end != cp)
-                               break;
-                       cp = end;
+                       mem_limit = memparse(cp + 4, &cp);
                } else if (memcmp(cp, "max_addr=", 9) == 0) {
-                       cp += 9;
-                       max_addr = GRANULEROUNDDOWN(memparse(cp, &end));
-                       if (end != cp)
-                               break;
-                       cp = end;
+                       max_addr = GRANULEROUNDDOWN(memparse(cp + 9, &cp));
+               } else if (memcmp(cp, "min_addr=", 9) == 0) {
+                       min_addr = GRANULEROUNDDOWN(memparse(cp + 9, &cp));
                } else {
                        while (*cp != ' ' && *cp)
                                ++cp;
@@ -430,6 +460,8 @@ efi_init (void)
                                ++cp;
                }
        }
+       if (min_addr != 0UL)
+               printk(KERN_INFO "Ignoring memory below %luMB\n", min_addr >> 
20);
        if (max_addr != ~0UL)
                printk(KERN_INFO "Ignoring memory above %luMB\n", max_addr >> 
20);
 
@@ -453,7 +485,7 @@ efi_init (void)
        /* Show what we know for posterity */
        c16 = __va(efi.systab->fw_vendor);
        if (c16) {
-               for (i = 0;i < (int) sizeof(vendor) && *c16; ++i)
+               for (i = 0;i < (int) sizeof(vendor) - 1 && *c16; ++i)
                        vendor[i] = *c16++;
                vendor[i] = '\0';
        }
@@ -461,6 +493,40 @@ efi_init (void)
        printk(KERN_INFO "EFI v%u.%.02u by %s:",
               efi.systab->hdr.revision >> 16, efi.systab->hdr.revision & 
0xffff, vendor);
 
+#ifndef XEN
+       efi.mps        = EFI_INVALID_TABLE_ADDR;
+       efi.acpi       = EFI_INVALID_TABLE_ADDR;
+       efi.acpi20     = EFI_INVALID_TABLE_ADDR;
+       efi.smbios     = EFI_INVALID_TABLE_ADDR;
+       efi.sal_systab = EFI_INVALID_TABLE_ADDR;
+       efi.boot_info  = EFI_INVALID_TABLE_ADDR;
+       efi.hcdp       = EFI_INVALID_TABLE_ADDR;
+       efi.uga        = EFI_INVALID_TABLE_ADDR;
+
+       for (i = 0; i < (int) efi.systab->nr_tables; i++) {
+               if (efi_guidcmp(config_tables[i].guid, MPS_TABLE_GUID) == 0) {
+                       efi.mps = config_tables[i].table;
+                       printk(" MPS=0x%lx", config_tables[i].table);
+               } else if (efi_guidcmp(config_tables[i].guid, 
ACPI_20_TABLE_GUID) == 0) {
+                       efi.acpi20 = config_tables[i].table;
+                       printk(" ACPI 2.0=0x%lx", config_tables[i].table);
+               } else if (efi_guidcmp(config_tables[i].guid, ACPI_TABLE_GUID) 
== 0) {
+                       efi.acpi = config_tables[i].table;
+                       printk(" ACPI=0x%lx", config_tables[i].table);
+               } else if (efi_guidcmp(config_tables[i].guid, 
SMBIOS_TABLE_GUID) == 0) {
+                       efi.smbios = config_tables[i].table;
+                       printk(" SMBIOS=0x%lx", config_tables[i].table);
+               } else if (efi_guidcmp(config_tables[i].guid, 
SAL_SYSTEM_TABLE_GUID) == 0) {
+                       efi.sal_systab = config_tables[i].table;
+                       printk(" SALsystab=0x%lx", config_tables[i].table);
+               } else if (efi_guidcmp(config_tables[i].guid, HCDP_TABLE_GUID) 
== 0) {
+                       efi.hcdp = config_tables[i].table;
+                       printk(" HCDP=0x%lx", config_tables[i].table);
+               }
+       }
+#else
+       /* Members of efi are set with virtual address in old linux code.
+          The latest linux set wiht physicall address. */
        for (i = 0; i < (int) efi.systab->nr_tables; i++) {
                if (efi_guidcmp(config_tables[i].guid, MPS_TABLE_GUID) == 0) {
                        efi.mps = __va(config_tables[i].table);
@@ -482,6 +548,7 @@ efi_init (void)
                        printk(" HCDP=0x%lx", config_tables[i].table);
                }
        }
+#endif
        printk("\n");
 
        runtime = __va(efi.systab->runtime);
@@ -616,8 +683,20 @@ efi_get_iobase (void)
        return 0;
 }
 
-u32
-efi_mem_type (unsigned long phys_addr)
+static struct kern_memdesc *
+kern_memory_descriptor (unsigned long phys_addr)
+{
+       struct kern_memdesc *md;
+
+       for (md = kern_memmap; md->start != ~0UL; md++) {
+               if (phys_addr - md->start < (md->num_pages << EFI_PAGE_SHIFT))
+                        return md;
+       }
+       return NULL;
+}
+
+static efi_memory_desc_t *
+efi_memory_descriptor (unsigned long phys_addr)
 {
        void *efi_map_start, *efi_map_end, *p;
        efi_memory_desc_t *md;
@@ -631,57 +710,154 @@ efi_mem_type (unsigned long phys_addr)
                md = p;
 
                if (phys_addr - md->phys_addr < (md->num_pages << 
EFI_PAGE_SHIFT))
-                        return md->type;
-       }
+                        return md;
+       }
+       return NULL;
+}
+
+u32
+efi_mem_type (unsigned long phys_addr)
+{
+       efi_memory_desc_t *md = efi_memory_descriptor(phys_addr);
+
+       if (md)
+               return md->type;
        return 0;
 }
 
 u64
 efi_mem_attributes (unsigned long phys_addr)
 {
-       void *efi_map_start, *efi_map_end, *p;
-       efi_memory_desc_t *md;
-       u64 efi_desc_size;
-
-       efi_map_start = __va(ia64_boot_param->efi_memmap);
-       efi_map_end   = efi_map_start + ia64_boot_param->efi_memmap_size;
-       efi_desc_size = ia64_boot_param->efi_memdesc_size;
-
-       for (p = efi_map_start; p < efi_map_end; p += efi_desc_size) {
-               md = p;
-
-               if (phys_addr - md->phys_addr < (md->num_pages << 
EFI_PAGE_SHIFT))
-                       return md->attribute;
-       }
+       efi_memory_desc_t *md = efi_memory_descriptor(phys_addr);
+
+       if (md)
+               return md->attribute;
        return 0;
 }
 EXPORT_SYMBOL(efi_mem_attributes);
 
+u64
+efi_mem_attribute (unsigned long phys_addr, unsigned long size)
+{
+       unsigned long end = phys_addr + size;
+       efi_memory_desc_t *md = efi_memory_descriptor(phys_addr);
+       u64 attr;
+
+       if (!md)
+               return 0;
+
+       /*
+        * EFI_MEMORY_RUNTIME is not a memory attribute; it just tells
+        * the kernel that firmware needs this region mapped.
+        */
+       attr = md->attribute & ~EFI_MEMORY_RUNTIME;
+       do {
+               unsigned long md_end = efi_md_end(md);
+
+               if (end <= md_end)
+                       return attr;
+
+               md = efi_memory_descriptor(md_end);
+               if (!md || (md->attribute & ~EFI_MEMORY_RUNTIME) != attr)
+                       return 0;
+       } while (md);
+       return 0;
+}
+
+u64
+kern_mem_attribute (unsigned long phys_addr, unsigned long size)
+{
+       unsigned long end = phys_addr + size;
+       struct kern_memdesc *md;
+       u64 attr;
+
+       /*
+        * This is a hack for ioremap calls before we set up kern_memmap.
+        * Maybe we should do efi_memmap_init() earlier instead.
+        */
+       if (!kern_memmap) {
+               attr = efi_mem_attribute(phys_addr, size);
+               if (attr & EFI_MEMORY_WB)
+                       return EFI_MEMORY_WB;
+               return 0;
+       }
+
+       md = kern_memory_descriptor(phys_addr);
+       if (!md)
+               return 0;
+
+       attr = md->attribute;
+       do {
+               unsigned long md_end = kmd_end(md);
+
+               if (end <= md_end)
+                       return attr;
+
+               md = kern_memory_descriptor(md_end);
+               if (!md || md->attribute != attr)
+                       return 0;
+       } while (md);
+       return 0;
+}
+EXPORT_SYMBOL(kern_mem_attribute);
+
+#ifndef XEN
 int
-valid_phys_addr_range (unsigned long phys_addr, unsigned long *size)
-{
-       void *efi_map_start, *efi_map_end, *p;
-       efi_memory_desc_t *md;
-       u64 efi_desc_size;
-
-       efi_map_start = __va(ia64_boot_param->efi_memmap);
-       efi_map_end   = efi_map_start + ia64_boot_param->efi_memmap_size;
-       efi_desc_size = ia64_boot_param->efi_memdesc_size;
-
-       for (p = efi_map_start; p < efi_map_end; p += efi_desc_size) {
-               md = p;
-
-               if (phys_addr - md->phys_addr < (md->num_pages << 
EFI_PAGE_SHIFT)) {
-                       if (!(md->attribute & EFI_MEMORY_WB))
-                               return 0;
-
-                       if (*size > md->phys_addr + (md->num_pages << 
EFI_PAGE_SHIFT) - phys_addr)
-                               *size = md->phys_addr + (md->num_pages << 
EFI_PAGE_SHIFT) - phys_addr;
-                       return 1;
-               }
-       }
+valid_phys_addr_range (unsigned long phys_addr, unsigned long size)
+{
+       u64 attr;
+
+       /*
+        * /dev/mem reads and writes use copy_to_user(), which implicitly
+        * uses a granule-sized kernel identity mapping.  It's really
+        * only safe to do this for regions in kern_memmap.  For more
+        * details, see Documentation/ia64/aliasing.txt.
+        */
+       attr = kern_mem_attribute(phys_addr, size);
+       if (attr & EFI_MEMORY_WB || attr & EFI_MEMORY_UC)
+               return 1;
        return 0;
 }
+
+int
+valid_mmap_phys_addr_range (unsigned long pfn, unsigned long size)
+{
+       /*
+        * MMIO regions are often missing from the EFI memory map.
+        * We must allow mmap of them for programs like X, so we
+        * currently can't do any useful validation.
+        */
+       return 1;
+}
+
+pgprot_t
+phys_mem_access_prot(struct file *file, unsigned long pfn, unsigned long size,
+                    pgprot_t vma_prot)
+{
+       unsigned long phys_addr = pfn << PAGE_SHIFT;
+       u64 attr;
+
+       /*
+        * For /dev/mem mmap, we use user mappings, but if the region is
+        * in kern_memmap (and hence may be covered by a kernel mapping),
+        * we must use the same attribute as the kernel mapping.
+        */
+       attr = kern_mem_attribute(phys_addr, size);
+       if (attr & EFI_MEMORY_WB)
+               return pgprot_cacheable(vma_prot);
+       else if (attr & EFI_MEMORY_UC)
+               return pgprot_noncached(vma_prot);
+
+       /*
+        * Some chipsets don't support UC access to memory.  If
+        * WB is supported, we prefer that.
+        */
+       if (efi_mem_attribute(phys_addr, size) & EFI_MEMORY_WB)
+               return pgprot_cacheable(vma_prot);
+
+       return pgprot_noncached(vma_prot);
+}
+#endif
 
 int __init
 efi_uart_console_only(void)
@@ -728,32 +904,6 @@ efi_uart_console_only(void)
        return 0;
 }
 
-#define efi_md_size(md)        (md->num_pages << EFI_PAGE_SHIFT)
-
-static inline u64
-kmd_end(kern_memdesc_t *kmd)
-{
-       return (kmd->start + (kmd->num_pages << EFI_PAGE_SHIFT));
-}
-
-static inline u64
-efi_md_end(efi_memory_desc_t *md)
-{
-       return (md->phys_addr + efi_md_size(md));
-}
-
-static inline int
-efi_wb(efi_memory_desc_t *md)
-{
-       return (md->attribute & EFI_MEMORY_WB);
-}
-
-static inline int
-efi_uc(efi_memory_desc_t *md)
-{
-       return (md->attribute & EFI_MEMORY_UC);
-}
-
 /*
  * Look for the first granule aligned memory descriptor memory
  * that is big enough to hold EFI memory map. Make sure this
@@ -799,14 +949,15 @@ find_memmap_space (void)
                        }
                        contig_high = GRANULEROUNDDOWN(contig_high);
                }
-               if (!is_available_memory(md) || md->type == EFI_LOADER_DATA)
+               if (!is_memory_available(md) || md->type == EFI_LOADER_DATA)
                        continue;
 
                /* Round ends inward to granule boundaries */
                as = max(contig_low, md->phys_addr);
                ae = min(contig_high, efi_md_end(md));
 
-               /* keep within max_addr= command line arg */
+               /* keep within max_addr= and min_addr= command line arg */
+               as = max(as, min_addr);
                ae = min(ae, max_addr);
                if (ae <= as)
                        continue;
@@ -835,7 +986,7 @@ void
 void
 efi_memmap_init(unsigned long *s, unsigned long *e)
 {
-       struct kern_memdesc *k, *prev = 0;
+       struct kern_memdesc *k, *prev = NULL;
        u64     contig_low=0, contig_high=0;
        u64     as, ae, lim;
        void *efi_map_start, *efi_map_end, *p, *q;
@@ -882,9 +1033,14 @@ efi_memmap_init(unsigned long *s, unsign
                        }
                        contig_high = GRANULEROUNDDOWN(contig_high);
                }
-               if (!is_available_memory(md))
-                       continue;
-
+               if (!is_memory_available(md))
+                       continue;
+
+#ifdef CONFIG_CRASH_DUMP
+               /* saved_max_pfn should ignore max_addr= command line arg */
+               if (saved_max_pfn < (efi_md_end(md) >> PAGE_SHIFT))
+                       saved_max_pfn = (efi_md_end(md) >> PAGE_SHIFT);
+#endif
                /*
                 * Round ends inward to granule boundaries
                 * Give trimmings to uncached allocator
@@ -924,7 +1080,8 @@ efi_memmap_init(unsigned long *s, unsign
                } else
                        ae = efi_md_end(md);
 
-               /* keep within max_addr= command line arg */
+               /* keep within max_addr= and min_addr= command line arg */
+               as = max(as, min_addr);
                ae = min(ae, max_addr);
                if (ae <= as)
                        continue;
@@ -952,3 +1109,174 @@ efi_memmap_init(unsigned long *s, unsign
        *s = (u64)kern_memmap;
        *e = (u64)++k;
 }
+
+#ifndef XEN
+void
+efi_initialize_iomem_resources(struct resource *code_resource,
+                              struct resource *data_resource)
+{
+       struct resource *res;
+       void *efi_map_start, *efi_map_end, *p;
+       efi_memory_desc_t *md;
+       u64 efi_desc_size;
+       char *name;
+       unsigned long flags;
+
+       efi_map_start = __va(ia64_boot_param->efi_memmap);
+       efi_map_end   = efi_map_start + ia64_boot_param->efi_memmap_size;
+       efi_desc_size = ia64_boot_param->efi_memdesc_size;
+
+       res = NULL;
+
+       for (p = efi_map_start; p < efi_map_end; p += efi_desc_size) {
+               md = p;
+
+               if (md->num_pages == 0) /* should not happen */
+                       continue;
+
+               flags = IORESOURCE_MEM;
+               switch (md->type) {
+
+                       case EFI_MEMORY_MAPPED_IO:
+                       case EFI_MEMORY_MAPPED_IO_PORT_SPACE:
+                               continue;
+
+                       case EFI_LOADER_CODE:
+                       case EFI_LOADER_DATA:
+                       case EFI_BOOT_SERVICES_DATA:
+                       case EFI_BOOT_SERVICES_CODE:
+                       case EFI_CONVENTIONAL_MEMORY:
+                               if (md->attribute & EFI_MEMORY_WP) {
+                                       name = "System ROM";
+                                       flags |= IORESOURCE_READONLY;
+                               } else {
+                                       name = "System RAM";
+                               }
+                               break;
+
+                       case EFI_ACPI_MEMORY_NVS:
+                               name = "ACPI Non-volatile Storage";
+                               flags |= IORESOURCE_BUSY;
+                               break;
+
+                       case EFI_UNUSABLE_MEMORY:
+                               name = "reserved";
+                               flags |= IORESOURCE_BUSY | IORESOURCE_DISABLED;
+                               break;
+
+                       case EFI_RESERVED_TYPE:
+                       case EFI_RUNTIME_SERVICES_CODE:
+                       case EFI_RUNTIME_SERVICES_DATA:
+                       case EFI_ACPI_RECLAIM_MEMORY:
+                       default:
+                               name = "reserved";
+                               flags |= IORESOURCE_BUSY;
+                               break;
+               }
+
+               if ((res = kzalloc(sizeof(struct resource), GFP_KERNEL)) == 
NULL) {
+                       printk(KERN_ERR "failed to alocate resource for 
iomem\n");
+                       return;
+               }
+
+               res->name = name;
+               res->start = md->phys_addr;
+               res->end = md->phys_addr + (md->num_pages << EFI_PAGE_SHIFT) - 
1;
+               res->flags = flags;
+
+               if (insert_resource(&iomem_resource, res) < 0)
+                       kfree(res);
+               else {
+                       /*
+                        * We don't know which region contains
+                        * kernel data so we try it repeatedly and
+                        * let the resource manager test it.
+                        */
+                       insert_resource(res, code_resource);
+                       insert_resource(res, data_resource);
+#ifdef CONFIG_KEXEC
+                        insert_resource(res, &efi_memmap_res);
+                        insert_resource(res, &boot_param_res);
+                       if (crashk_res.end > crashk_res.start)
+                               insert_resource(res, &crashk_res);
+#endif
+               }
+       }
+}
+
+#ifdef CONFIG_KEXEC
+/* find a block of memory aligned to 64M exclude reserved regions
+   rsvd_regions are sorted
+ */
+unsigned long __init
+kdump_find_rsvd_region (unsigned long size,
+               struct rsvd_region *r, int n)
+{
+  int i;
+  u64 start, end;
+  u64 alignment = 1UL << _PAGE_SIZE_64M;
+  void *efi_map_start, *efi_map_end, *p;
+  efi_memory_desc_t *md;
+  u64 efi_desc_size;
+
+  efi_map_start = __va(ia64_boot_param->efi_memmap);
+  efi_map_end   = efi_map_start + ia64_boot_param->efi_memmap_size;
+  efi_desc_size = ia64_boot_param->efi_memdesc_size;
+
+  for (p = efi_map_start; p < efi_map_end; p += efi_desc_size) {
+         md = p;
+         if (!efi_wb(md))
+                 continue;
+         start = ALIGN(md->phys_addr, alignment);
+         end = efi_md_end(md);
+         for (i = 0; i < n; i++) {
+               if (__pa(r[i].start) >= start && __pa(r[i].end) < end) {
+                       if (__pa(r[i].start) > start + size)
+                               return start;
+                       start = ALIGN(__pa(r[i].end), alignment);
+                       if (i < n-1 && __pa(r[i+1].start) < start + size)
+                               continue;
+                       else
+                               break;
+               }
+         }
+         if (end > start + size)
+               return start;
+  }
+
+  printk(KERN_WARNING "Cannot reserve 0x%lx byte of memory for crashdump\n",
+       size);
+  return ~0UL;
+}
+#endif
+
+#ifdef CONFIG_PROC_VMCORE
+/* locate the size find a the descriptor at a certain address */
+unsigned long
+vmcore_find_descriptor_size (unsigned long address)
+{
+       void *efi_map_start, *efi_map_end, *p;
+       efi_memory_desc_t *md;
+       u64 efi_desc_size;
+       unsigned long ret = 0;
+
+       efi_map_start = __va(ia64_boot_param->efi_memmap);
+       efi_map_end   = efi_map_start + ia64_boot_param->efi_memmap_size;
+       efi_desc_size = ia64_boot_param->efi_memdesc_size;
+
+       for (p = efi_map_start; p < efi_map_end; p += efi_desc_size) {
+               md = p;
+               if (efi_wb(md) && md->type == EFI_LOADER_DATA
+                   && md->phys_addr == address) {
+                       ret = efi_md_size(md);
+                       break;
+               }
+       }
+
+       if (ret == 0)
+               printk(KERN_WARNING "Cannot locate EFI vmcore descriptor\n");
+
+       return ret;
+}
+#endif
+#endif /* XEN */
diff -r 90f19b7667f7 -r 301267d0db12 
xen/include/asm-ia64/linux-xen/linux/README.origin
--- a/xen/include/asm-ia64/linux-xen/linux/README.origin        Thu May 24 
14:20:19 2007 -0600
+++ b/xen/include/asm-ia64/linux-xen/linux/README.origin        Thu May 24 
14:43:14 2007 -0600
@@ -5,7 +5,6 @@
 # (e.g. with #ifdef XEN or XEN in a comment) so that they can be
 # easily updated to future versions of the corresponding Linux files.
 
-efi.h                  -> linux/include/linux/efi.h
 gfp.h                  -> linux/include/linux/gfp.h
 hardirq.h              -> linux/include/linux/hardirq.h
 interrupt.h            -> linux/include/linux/interrupt.h
@@ -17,3 +16,6 @@ pci.h                 -> linux/include/linux/pci.h
 pci.h                  -> linux/include/linux/pci.h
 kobject.h              -> linux/include/linux/kobject.h
 device.h               -> linux/include/linux/device.h
+
+# The files below are from Linux-2.6.21
+efi.h                  -> linux/include/linux/efi.h
diff -r 90f19b7667f7 -r 301267d0db12 xen/include/asm-ia64/linux-xen/linux/efi.h
--- a/xen/include/asm-ia64/linux-xen/linux/efi.h        Thu May 24 14:20:19 
2007 -0600
+++ b/xen/include/asm-ia64/linux-xen/linux/efi.h        Thu May 24 14:43:14 
2007 -0600
@@ -91,11 +91,6 @@ typedef      struct {
 
 #define EFI_PAGE_SHIFT         12
 
-/*
- * For current x86 implementations of EFI, there is
- * additional padding in the mem descriptors.  This is not
- * the case in ia64.  Need to have this fixed in the f/w.
- */
 typedef struct {
        u32 type;
        u32 pad;
@@ -103,9 +98,6 @@ typedef struct {
        u64 virt_addr;
        u64 num_pages;
        u64 attribute;
-#if defined (__i386__)
-       u64 pad1;
-#endif
 } efi_memory_desc_t;
 
 typedef int (*efi_freemem_callback_t) (unsigned long start, unsigned long end, 
void *arg);
@@ -240,17 +232,36 @@ typedef struct {
 } efi_system_table_t;
 
 struct efi_memory_map {
+#ifndef XEN
+       void *phys_map;
+       void *map;
+#else
        efi_memory_desc_t *phys_map;
        efi_memory_desc_t *map;
+#endif
+       void *map_end;
        int nr_map;
        unsigned long desc_version;
+       unsigned long desc_size;
 };
+
+#define EFI_INVALID_TABLE_ADDR         (~0UL)
 
 /*
  * All runtime access to EFI goes through this structure:
  */
 extern struct efi {
        efi_system_table_t *systab;     /* EFI system table */
+#ifndef XEN
+       unsigned long mps;              /* MPS table */
+       unsigned long acpi;             /* ACPI table  (IA64 ext 0.71) */
+       unsigned long acpi20;           /* ACPI table  (ACPI 2.0) */
+       unsigned long smbios;           /* SM BIOS table */
+       unsigned long sal_systab;       /* SAL system table */
+       unsigned long boot_info;        /* boot info table */
+       unsigned long hcdp;             /* HCDP table */
+       unsigned long uga;              /* UGA table */
+#else
        void *mps;                      /* MPS table */
        void *acpi;                     /* ACPI table  (IA64 ext 0.71) */
        void *acpi20;                   /* ACPI table  (ACPI 2.0) */
@@ -259,6 +270,7 @@ extern struct efi {
        void *boot_info;                /* boot info table */
        void *hcdp;                     /* HCDP table */
        void *uga;                      /* UGA table */
+#endif
        efi_get_time_t *get_time;
        efi_set_time_t *set_time;
        efi_get_wakeup_time_t *get_wakeup_time;
@@ -302,11 +314,15 @@ extern u64 efi_get_iobase (void);
 extern u64 efi_get_iobase (void);
 extern u32 efi_mem_type (unsigned long phys_addr);
 extern u64 efi_mem_attributes (unsigned long phys_addr);
+extern u64 efi_mem_attribute (unsigned long phys_addr, unsigned long size);
+extern int efi_mem_attribute_range (unsigned long phys_addr, unsigned long 
size,
+                                   u64 attr);
 extern int __init efi_uart_console_only (void);
 extern void efi_initialize_iomem_resources(struct resource *code_resource,
                                        struct resource *data_resource);
-extern unsigned long __init efi_get_time(void);
-extern int __init efi_set_rtc_mmss(unsigned long nowtime);
+extern unsigned long efi_get_time(void);
+extern int efi_set_rtc_mmss(unsigned long nowtime);
+extern int is_available_memory(efi_memory_desc_t * md);
 extern struct efi_memory_map memmap;
 
 /**

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] [IA64] Update efi.c and efi.h to linux-2.6.21, Xen patchbot-unstable <=