diff options
| -rw-r--r-- | arch/x86/include/asm/probe_roms.h | 8 | ||||
| -rw-r--r-- | arch/x86/include/asm/setup.h | 2 | ||||
| -rw-r--r-- | arch/x86/kernel/Makefile | 2 | ||||
| -rw-r--r-- | arch/x86/kernel/head32.c | 1 | ||||
| -rw-r--r-- | arch/x86/kernel/probe_roms.c (renamed from arch/x86/kernel/probe_roms_32.c) | 101 | ||||
| -rw-r--r-- | arch/x86/kernel/x86_init.c | 2 |
6 files changed, 112 insertions, 4 deletions
diff --git a/arch/x86/include/asm/probe_roms.h b/arch/x86/include/asm/probe_roms.h new file mode 100644 index 000000000000..4950a0b1d09c --- /dev/null +++ b/arch/x86/include/asm/probe_roms.h | |||
| @@ -0,0 +1,8 @@ | |||
| 1 | #ifndef _PROBE_ROMS_H_ | ||
| 2 | #define _PROBE_ROMS_H_ | ||
| 3 | struct pci_dev; | ||
| 4 | |||
| 5 | extern void __iomem *pci_map_biosrom(struct pci_dev *pdev); | ||
| 6 | extern void pci_unmap_biosrom(void __iomem *rom); | ||
| 7 | extern size_t pci_biosrom_size(struct pci_dev *pdev); | ||
| 8 | #endif | ||
diff --git a/arch/x86/include/asm/setup.h b/arch/x86/include/asm/setup.h index db8aa19a08a2..03d3a32ace20 100644 --- a/arch/x86/include/asm/setup.h +++ b/arch/x86/include/asm/setup.h | |||
| @@ -104,10 +104,10 @@ void *extend_brk(size_t size, size_t align); | |||
| 104 | type *name; \ | 104 | type *name; \ |
| 105 | RESERVE_BRK(name, sizeof(type) * entries) | 105 | RESERVE_BRK(name, sizeof(type) * entries) |
| 106 | 106 | ||
| 107 | extern void probe_roms(void); | ||
| 107 | #ifdef __i386__ | 108 | #ifdef __i386__ |
| 108 | 109 | ||
| 109 | void __init i386_start_kernel(void); | 110 | void __init i386_start_kernel(void); |
| 110 | extern void probe_roms(void); | ||
| 111 | 111 | ||
| 112 | #else | 112 | #else |
| 113 | void __init x86_64_start_kernel(char *real_mode); | 113 | void __init x86_64_start_kernel(char *real_mode); |
diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile index 62445ba2f8a8..f33d738c8da9 100644 --- a/arch/x86/kernel/Makefile +++ b/arch/x86/kernel/Makefile | |||
| @@ -36,7 +36,7 @@ obj-y += traps.o irq.o irq_$(BITS).o dumpstack_$(BITS).o | |||
| 36 | obj-y += time.o ioport.o ldt.o dumpstack.o | 36 | obj-y += time.o ioport.o ldt.o dumpstack.o |
| 37 | obj-y += setup.o x86_init.o i8259.o irqinit.o jump_label.o | 37 | obj-y += setup.o x86_init.o i8259.o irqinit.o jump_label.o |
| 38 | obj-$(CONFIG_IRQ_WORK) += irq_work.o | 38 | obj-$(CONFIG_IRQ_WORK) += irq_work.o |
| 39 | obj-$(CONFIG_X86_32) += probe_roms_32.o | 39 | obj-y += probe_roms.o |
| 40 | obj-$(CONFIG_X86_32) += sys_i386_32.o i386_ksyms_32.o | 40 | obj-$(CONFIG_X86_32) += sys_i386_32.o i386_ksyms_32.o |
| 41 | obj-$(CONFIG_X86_64) += sys_x86_64.o x8664_ksyms_64.o | 41 | obj-$(CONFIG_X86_64) += sys_x86_64.o x8664_ksyms_64.o |
| 42 | obj-$(CONFIG_X86_64) += syscall_64.o vsyscall_64.o | 42 | obj-$(CONFIG_X86_64) += syscall_64.o vsyscall_64.o |
diff --git a/arch/x86/kernel/head32.c b/arch/x86/kernel/head32.c index 7f138b3c3c52..eab4940c7306 100644 --- a/arch/x86/kernel/head32.c +++ b/arch/x86/kernel/head32.c | |||
| @@ -23,7 +23,6 @@ | |||
| 23 | static void __init i386_default_early_setup(void) | 23 | static void __init i386_default_early_setup(void) |
| 24 | { | 24 | { |
| 25 | /* Initialize 32bit specific setup functions */ | 25 | /* Initialize 32bit specific setup functions */ |
| 26 | x86_init.resources.probe_roms = probe_roms; | ||
| 27 | x86_init.resources.reserve_resources = i386_reserve_resources; | 26 | x86_init.resources.reserve_resources = i386_reserve_resources; |
| 28 | x86_init.mpparse.setup_ioapic_ids = setup_ioapic_ids_from_mpc; | 27 | x86_init.mpparse.setup_ioapic_ids = setup_ioapic_ids_from_mpc; |
| 29 | 28 | ||
diff --git a/arch/x86/kernel/probe_roms_32.c b/arch/x86/kernel/probe_roms.c index 071e7fea42e5..ba0a4cce53be 100644 --- a/arch/x86/kernel/probe_roms_32.c +++ b/arch/x86/kernel/probe_roms.c | |||
| @@ -73,6 +73,107 @@ static struct resource video_rom_resource = { | |||
| 73 | .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM | 73 | .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM |
| 74 | }; | 74 | }; |
| 75 | 75 | ||
| 76 | /* does this oprom support the given pci device, or any of the devices | ||
| 77 | * that the driver supports? | ||
| 78 | */ | ||
| 79 | static bool match_id(struct pci_dev *pdev, unsigned short vendor, unsigned short device) | ||
| 80 | { | ||
| 81 | struct pci_driver *drv = pdev->driver; | ||
| 82 | const struct pci_device_id *id; | ||
| 83 | |||
| 84 | if (pdev->vendor == vendor && pdev->device == device) | ||
| 85 | return true; | ||
| 86 | |||
| 87 | for (id = drv ? drv->id_table : NULL; id && id->vendor; id++) | ||
| 88 | if (id->vendor == vendor && id->device == device) | ||
| 89 | break; | ||
| 90 | |||
| 91 | return id && id->vendor; | ||
| 92 | } | ||
| 93 | |||
| 94 | static bool probe_list(struct pci_dev *pdev, unsigned short vendor, | ||
| 95 | const unsigned char *rom_list) | ||
| 96 | { | ||
| 97 | unsigned short device; | ||
| 98 | |||
| 99 | do { | ||
| 100 | if (probe_kernel_address(rom_list, device) != 0) | ||
| 101 | device = 0; | ||
| 102 | |||
| 103 | if (device && match_id(pdev, vendor, device)) | ||
| 104 | break; | ||
| 105 | |||
| 106 | rom_list += 2; | ||
| 107 | } while (device); | ||
| 108 | |||
| 109 | return !!device; | ||
| 110 | } | ||
| 111 | |||
| 112 | static struct resource *find_oprom(struct pci_dev *pdev) | ||
| 113 | { | ||
| 114 | struct resource *oprom = NULL; | ||
| 115 | int i; | ||
| 116 | |||
| 117 | for (i = 0; i < ARRAY_SIZE(adapter_rom_resources); i++) { | ||
| 118 | struct resource *res = &adapter_rom_resources[i]; | ||
| 119 | unsigned short offset, vendor, device, list, rev; | ||
| 120 | const unsigned char *rom; | ||
| 121 | |||
| 122 | if (res->end == 0) | ||
| 123 | break; | ||
| 124 | |||
| 125 | rom = isa_bus_to_virt(res->start); | ||
| 126 | if (probe_kernel_address(rom + 0x18, offset) != 0) | ||
| 127 | continue; | ||
| 128 | |||
| 129 | if (probe_kernel_address(rom + offset + 0x4, vendor) != 0) | ||
| 130 | continue; | ||
| 131 | |||
| 132 | if (probe_kernel_address(rom + offset + 0x6, device) != 0) | ||
| 133 | continue; | ||
| 134 | |||
| 135 | if (match_id(pdev, vendor, device)) { | ||
| 136 | oprom = res; | ||
| 137 | break; | ||
| 138 | } | ||
| 139 | |||
| 140 | if (probe_kernel_address(rom + offset + 0x8, list) == 0 && | ||
| 141 | probe_kernel_address(rom + offset + 0xc, rev) == 0 && | ||
| 142 | rev >= 3 && list && | ||
| 143 | probe_list(pdev, vendor, rom + offset + list)) { | ||
| 144 | oprom = res; | ||
| 145 | break; | ||
| 146 | } | ||
| 147 | } | ||
| 148 | |||
| 149 | return oprom; | ||
| 150 | } | ||
| 151 | |||
| 152 | void *pci_map_biosrom(struct pci_dev *pdev) | ||
| 153 | { | ||
| 154 | struct resource *oprom = find_oprom(pdev); | ||
| 155 | |||
| 156 | if (!oprom) | ||
| 157 | return NULL; | ||
| 158 | |||
| 159 | return ioremap(oprom->start, resource_size(oprom)); | ||
| 160 | } | ||
| 161 | EXPORT_SYMBOL(pci_map_biosrom); | ||
| 162 | |||
| 163 | void pci_unmap_biosrom(void __iomem *image) | ||
| 164 | { | ||
| 165 | iounmap(image); | ||
| 166 | } | ||
| 167 | EXPORT_SYMBOL(pci_unmap_biosrom); | ||
| 168 | |||
| 169 | size_t pci_biosrom_size(struct pci_dev *pdev) | ||
| 170 | { | ||
| 171 | struct resource *oprom = find_oprom(pdev); | ||
| 172 | |||
| 173 | return oprom ? resource_size(oprom) : 0; | ||
| 174 | } | ||
| 175 | EXPORT_SYMBOL(pci_biosrom_size); | ||
| 176 | |||
| 76 | #define ROMSIGNATURE 0xaa55 | 177 | #define ROMSIGNATURE 0xaa55 |
| 77 | 178 | ||
| 78 | static int __init romsignature(const unsigned char *rom) | 179 | static int __init romsignature(const unsigned char *rom) |
diff --git a/arch/x86/kernel/x86_init.c b/arch/x86/kernel/x86_init.c index c11514e9128b..6eee0828e327 100644 --- a/arch/x86/kernel/x86_init.c +++ b/arch/x86/kernel/x86_init.c | |||
| @@ -35,7 +35,7 @@ void iommu_shutdown_noop(void) { } | |||
| 35 | struct x86_init_ops x86_init __initdata = { | 35 | struct x86_init_ops x86_init __initdata = { |
| 36 | 36 | ||
| 37 | .resources = { | 37 | .resources = { |
| 38 | .probe_roms = x86_init_noop, | 38 | .probe_roms = probe_roms, |
| 39 | .reserve_resources = reserve_standard_io_resources, | 39 | .reserve_resources = reserve_standard_io_resources, |
| 40 | .memory_setup = default_machine_specific_memory_setup, | 40 | .memory_setup = default_machine_specific_memory_setup, |
| 41 | }, | 41 | }, |
