diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2008-07-14 16:43:24 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-07-14 16:43:24 -0400 |
commit | a3da5bf84a97d48cfaf66c6842470fc403da5121 (patch) | |
tree | cdf66c0cff8c61eedd60601fc9dffdd1ed39b880 /arch/x86/kernel/probe_roms_32.c | |
parent | 3b23e665b68387f5ee7b21f7b75ceea4d9acae4a (diff) | |
parent | d59fdcf2ac501de99c3dfb452af5e254d4342886 (diff) |
Merge branch 'x86/for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip
* 'x86/for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip: (821 commits)
x86: make 64bit hpet_set_mapping to use ioremap too, v2
x86: get x86_phys_bits early
x86: max_low_pfn_mapped fix #4
x86: change _node_to_cpumask_ptr to return const ptr
x86: I/O APIC: remove an IRQ2-mask hack
x86: fix numaq_tsc_disable calling
x86, e820: remove end_user_pfn
x86: max_low_pfn_mapped fix, #3
x86: max_low_pfn_mapped fix, #2
x86: max_low_pfn_mapped fix, #1
x86_64: fix delayed signals
x86: remove conflicting nx6325 and nx6125 quirks
x86: Recover timer_ack lost in the merge of the NMI watchdog
x86: I/O APIC: Never configure IRQ2
x86: L-APIC: Always fully configure IRQ0
x86: L-APIC: Set IRQ0 as edge-triggered
x86: merge dwarf2 headers
x86: use AS_CFI instead of UNWIND_INFO
x86: use ignore macro instead of hash comment
x86: use matching CFI_ENDPROC
...
Diffstat (limited to 'arch/x86/kernel/probe_roms_32.c')
-rw-r--r-- | arch/x86/kernel/probe_roms_32.c | 166 |
1 files changed, 166 insertions, 0 deletions
diff --git a/arch/x86/kernel/probe_roms_32.c b/arch/x86/kernel/probe_roms_32.c new file mode 100644 index 000000000000..675a48c404a5 --- /dev/null +++ b/arch/x86/kernel/probe_roms_32.c | |||
@@ -0,0 +1,166 @@ | |||
1 | #include <linux/sched.h> | ||
2 | #include <linux/mm.h> | ||
3 | #include <linux/uaccess.h> | ||
4 | #include <linux/mmzone.h> | ||
5 | #include <linux/ioport.h> | ||
6 | #include <linux/seq_file.h> | ||
7 | #include <linux/console.h> | ||
8 | #include <linux/init.h> | ||
9 | #include <linux/edd.h> | ||
10 | #include <linux/dmi.h> | ||
11 | #include <linux/pfn.h> | ||
12 | #include <linux/pci.h> | ||
13 | #include <asm/pci-direct.h> | ||
14 | |||
15 | |||
16 | #include <asm/e820.h> | ||
17 | #include <asm/mmzone.h> | ||
18 | #include <asm/setup.h> | ||
19 | #include <asm/sections.h> | ||
20 | #include <asm/io.h> | ||
21 | #include <setup_arch.h> | ||
22 | |||
23 | static struct resource system_rom_resource = { | ||
24 | .name = "System ROM", | ||
25 | .start = 0xf0000, | ||
26 | .end = 0xfffff, | ||
27 | .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM | ||
28 | }; | ||
29 | |||
30 | static struct resource extension_rom_resource = { | ||
31 | .name = "Extension ROM", | ||
32 | .start = 0xe0000, | ||
33 | .end = 0xeffff, | ||
34 | .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM | ||
35 | }; | ||
36 | |||
37 | static struct resource adapter_rom_resources[] = { { | ||
38 | .name = "Adapter ROM", | ||
39 | .start = 0xc8000, | ||
40 | .end = 0, | ||
41 | .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM | ||
42 | }, { | ||
43 | .name = "Adapter ROM", | ||
44 | .start = 0, | ||
45 | .end = 0, | ||
46 | .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM | ||
47 | }, { | ||
48 | .name = "Adapter ROM", | ||
49 | .start = 0, | ||
50 | .end = 0, | ||
51 | .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM | ||
52 | }, { | ||
53 | .name = "Adapter ROM", | ||
54 | .start = 0, | ||
55 | .end = 0, | ||
56 | .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM | ||
57 | }, { | ||
58 | .name = "Adapter ROM", | ||
59 | .start = 0, | ||
60 | .end = 0, | ||
61 | .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM | ||
62 | }, { | ||
63 | .name = "Adapter ROM", | ||
64 | .start = 0, | ||
65 | .end = 0, | ||
66 | .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM | ||
67 | } }; | ||
68 | |||
69 | static struct resource video_rom_resource = { | ||
70 | .name = "Video ROM", | ||
71 | .start = 0xc0000, | ||
72 | .end = 0xc7fff, | ||
73 | .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM | ||
74 | }; | ||
75 | |||
76 | #define ROMSIGNATURE 0xaa55 | ||
77 | |||
78 | static int __init romsignature(const unsigned char *rom) | ||
79 | { | ||
80 | const unsigned short * const ptr = (const unsigned short *)rom; | ||
81 | unsigned short sig; | ||
82 | |||
83 | return probe_kernel_address(ptr, sig) == 0 && sig == ROMSIGNATURE; | ||
84 | } | ||
85 | |||
86 | static int __init romchecksum(const unsigned char *rom, unsigned long length) | ||
87 | { | ||
88 | unsigned char sum, c; | ||
89 | |||
90 | for (sum = 0; length && probe_kernel_address(rom++, c) == 0; length--) | ||
91 | sum += c; | ||
92 | return !length && !sum; | ||
93 | } | ||
94 | |||
95 | void __init probe_roms(void) | ||
96 | { | ||
97 | const unsigned char *rom; | ||
98 | unsigned long start, length, upper; | ||
99 | unsigned char c; | ||
100 | int i; | ||
101 | |||
102 | /* video rom */ | ||
103 | upper = adapter_rom_resources[0].start; | ||
104 | for (start = video_rom_resource.start; start < upper; start += 2048) { | ||
105 | rom = isa_bus_to_virt(start); | ||
106 | if (!romsignature(rom)) | ||
107 | continue; | ||
108 | |||
109 | video_rom_resource.start = start; | ||
110 | |||
111 | if (probe_kernel_address(rom + 2, c) != 0) | ||
112 | continue; | ||
113 | |||
114 | /* 0 < length <= 0x7f * 512, historically */ | ||
115 | length = c * 512; | ||
116 | |||
117 | /* if checksum okay, trust length byte */ | ||
118 | if (length && romchecksum(rom, length)) | ||
119 | video_rom_resource.end = start + length - 1; | ||
120 | |||
121 | request_resource(&iomem_resource, &video_rom_resource); | ||
122 | break; | ||
123 | } | ||
124 | |||
125 | start = (video_rom_resource.end + 1 + 2047) & ~2047UL; | ||
126 | if (start < upper) | ||
127 | start = upper; | ||
128 | |||
129 | /* system rom */ | ||
130 | request_resource(&iomem_resource, &system_rom_resource); | ||
131 | upper = system_rom_resource.start; | ||
132 | |||
133 | /* check for extension rom (ignore length byte!) */ | ||
134 | rom = isa_bus_to_virt(extension_rom_resource.start); | ||
135 | if (romsignature(rom)) { | ||
136 | length = extension_rom_resource.end - extension_rom_resource.start + 1; | ||
137 | if (romchecksum(rom, length)) { | ||
138 | request_resource(&iomem_resource, &extension_rom_resource); | ||
139 | upper = extension_rom_resource.start; | ||
140 | } | ||
141 | } | ||
142 | |||
143 | /* check for adapter roms on 2k boundaries */ | ||
144 | for (i = 0; i < ARRAY_SIZE(adapter_rom_resources) && start < upper; start += 2048) { | ||
145 | rom = isa_bus_to_virt(start); | ||
146 | if (!romsignature(rom)) | ||
147 | continue; | ||
148 | |||
149 | if (probe_kernel_address(rom + 2, c) != 0) | ||
150 | continue; | ||
151 | |||
152 | /* 0 < length <= 0x7f * 512, historically */ | ||
153 | length = c * 512; | ||
154 | |||
155 | /* but accept any length that fits if checksum okay */ | ||
156 | if (!length || start + length > upper || !romchecksum(rom, length)) | ||
157 | continue; | ||
158 | |||
159 | adapter_rom_resources[i].start = start; | ||
160 | adapter_rom_resources[i].end = start + length - 1; | ||
161 | request_resource(&iomem_resource, &adapter_rom_resources[i]); | ||
162 | |||
163 | start = adapter_rom_resources[i++].end & ~2047UL; | ||
164 | } | ||
165 | } | ||
166 | |||