]> git.neil.brown.name Git - history.git/commitdiff
[PATCH] This patch against 2.4.18+ia64-020226 removes a legacy VGA
authorBjorn Helgaas <bjorn_helgaas@hp.com>
Wed, 10 Apr 2002 04:48:49 +0000 (21:48 -0700)
committerDavid Mosberger <davidm@wailua.hpl.hp.com>
Wed, 10 Apr 2002 04:48:49 +0000 (21:48 -0700)
dependency.  Non-legacy systems may have system memory
at 0xA0000, and if that's the case, we don't want to install the
VGA console.

Restructured conswitchp init slightly so that if both
CONFIG_DUMMY_CONSOLE and CONFIG_VGA_CONSOLE
are defined, conswitchp is always set to something, even if we
don't find VGA at 0xA0000.

This work is due to Alex Williamson (alex_williamson@hp.com).

arch/ia64/kernel/efi.c
arch/ia64/kernel/setup.c
include/asm-ia64/efi.h

index 5c7b4b193db45f4bce8675c6abf80c9952e855fc..06fef3ff841687827ca37c4e00e3485845561f92 100644 (file)
@@ -155,10 +155,10 @@ efi_memmap_walk (efi_freemem_callback_t callback, void *arg)
                      case EFI_CONVENTIONAL_MEMORY:
                        if (!(md->attribute & EFI_MEMORY_WB))
                                continue;
-                       if (md->phys_addr + (md->num_pages << 12) > mem_limit) {
+                       if (md->phys_addr + (md->num_pages << EFI_PAGE_SHIFT) > mem_limit) {
                                if (md->phys_addr > mem_limit)
                                        continue;
-                               md->num_pages = (mem_limit - md->phys_addr) >> 12;
+                               md->num_pages = (mem_limit - md->phys_addr) >> EFI_PAGE_SHIFT;
                        }
                        if (md->num_pages == 0) {
                                printk("efi_memmap_walk: ignoring empty region at 0x%lx",
@@ -167,7 +167,7 @@ efi_memmap_walk (efi_freemem_callback_t callback, void *arg)
                        }
 
                        curr.start = PAGE_OFFSET + md->phys_addr;
-                       curr.end   = curr.start + (md->num_pages << 12);
+                       curr.end   = curr.start + (md->num_pages << EFI_PAGE_SHIFT);
 
                        if (!prev_valid) {
                                prev = curr;
@@ -254,12 +254,12 @@ efi_map_pal_code (void)
                        continue;
                }
 
-               if (md->num_pages << 12 > IA64_GRANULE_SIZE)
+               if (md->num_pages << EFI_PAGE_SHIFT > IA64_GRANULE_SIZE)
                        panic("Woah!  PAL code size bigger than a granule!");
 
                mask  = ~((1 << IA64_GRANULE_SHIFT) - 1);
                printk("CPU %d: mapping PAL code [0x%lx-0x%lx) into [0x%lx-0x%lx)\n",
-                      smp_processor_id(), md->phys_addr, md->phys_addr + (md->num_pages << 12),
+                      smp_processor_id(), md->phys_addr, md->phys_addr + (md->num_pages << EFI_PAGE_SHIFT),
                       vaddr & mask, (vaddr & mask) + IA64_GRANULE_SIZE);
 
                /*
@@ -375,7 +375,7 @@ efi_init (void)
                        md = p;
                        printk("mem%02u: type=%u, attr=0x%lx, range=[0x%016lx-0x%016lx) (%luMB)\n",
                               i, md->type, md->attribute, md->phys_addr,
-                              md->phys_addr + (md->num_pages<<12) - 1, md->num_pages >> 8);
+                              md->phys_addr + (md->num_pages<<EFI_PAGE_SHIFT) - 1, md->num_pages >> 8);
                }
        }
 #endif
@@ -482,6 +482,26 @@ efi_get_iobase (void)
        return 0;
 }
 
+u32
+efi_mem_type (u64 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 ((md->phys_addr <= phys_addr) && (phys_addr <=
+                   (md->phys_addr + (md->num_pages << EFI_PAGE_SHIFT) - 1)))
+                        return md->type;
+       }
+       return 0;
+}
+
 static void __exit
 efivars_exit(void)
 {
index ea6021ae5514907dc3fe908abc0d4dea8d1b3beb..32676187e319784041ad81e60220ac2f089a1947 100644 (file)
@@ -351,11 +351,19 @@ setup_arch (char **cmdline_p)
        }
 
 #ifdef CONFIG_VT
-# if defined(CONFIG_VGA_CONSOLE)
-       conswitchp = &vga_con;
-# elif defined(CONFIG_DUMMY_CONSOLE)
+# if defined(CONFIG_DUMMY_CONSOLE)
        conswitchp = &dummy_con;
 # endif
+# if defined(CONFIG_VGA_CONSOLE)
+       /*
+        * Non-legacy systems may route legacy VGA MMIO range to system
+        * memory.  vga_con probes the MMIO hole, so memory looks like
+        * a VGA device to it.  The EFI memory map can tell us if it's
+        * memory so we can avoid this problem.
+        */
+       if (efi_mem_type(0xA0000) != EFI_CONVENTIONAL_MEMORY)
+               conswitchp = &vga_con;
+# endif
 #endif
 
 #ifdef CONFIG_IA64_MCA
index 189f7bcfd0350ec30268b3da8c834c8c1dc22427..b679cec86170c7f7fc2e2e12a43f3190684bad30 100644 (file)
@@ -87,6 +87,8 @@ typedef       struct {
 #define EFI_MEMORY_RUNTIME     0x8000000000000000      /* range requires runtime mapping */
 #define EFI_MEMORY_DESCRIPTOR_VERSION  1
 
+#define EFI_PAGE_SHIFT         12
+
 typedef struct {
        u32 type;
        u32 pad;
@@ -257,6 +259,7 @@ extern void efi_memmap_walk (efi_freemem_callback_t callback, void *arg);
 extern void efi_gettimeofday (struct timeval *tv);
 extern void efi_enter_virtual_mode (void);     /* switch EFI to virtual mode, if possible */
 extern u64  efi_get_iobase (void);
+extern u32  efi_mem_type (u64 phys_addr);
 
 /*
  * Variable Attributes