diff options
Diffstat (limited to 'arch/x86/kernel/e820_32.c')
-rw-r--r-- | arch/x86/kernel/e820_32.c | 192 |
1 files changed, 0 insertions, 192 deletions
diff --git a/arch/x86/kernel/e820_32.c b/arch/x86/kernel/e820_32.c index 8de3df9548db..1205ccf086d7 100644 --- a/arch/x86/kernel/e820_32.c +++ b/arch/x86/kernel/e820_32.c | |||
@@ -15,198 +15,6 @@ | |||
15 | #include <asm/e820.h> | 15 | #include <asm/e820.h> |
16 | #include <asm/setup.h> | 16 | #include <asm/setup.h> |
17 | 17 | ||
18 | static struct resource system_rom_resource = { | ||
19 | .name = "System ROM", | ||
20 | .start = 0xf0000, | ||
21 | .end = 0xfffff, | ||
22 | .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM | ||
23 | }; | ||
24 | |||
25 | static struct resource extension_rom_resource = { | ||
26 | .name = "Extension ROM", | ||
27 | .start = 0xe0000, | ||
28 | .end = 0xeffff, | ||
29 | .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM | ||
30 | }; | ||
31 | |||
32 | static struct resource adapter_rom_resources[] = { { | ||
33 | .name = "Adapter ROM", | ||
34 | .start = 0xc8000, | ||
35 | .end = 0, | ||
36 | .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM | ||
37 | }, { | ||
38 | .name = "Adapter ROM", | ||
39 | .start = 0, | ||
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 | |||
64 | static struct resource video_rom_resource = { | ||
65 | .name = "Video ROM", | ||
66 | .start = 0xc0000, | ||
67 | .end = 0xc7fff, | ||
68 | .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM | ||
69 | }; | ||
70 | |||
71 | #define ROMSIGNATURE 0xaa55 | ||
72 | |||
73 | static int __init romsignature(const unsigned char *rom) | ||
74 | { | ||
75 | const unsigned short * const ptr = (const unsigned short *)rom; | ||
76 | unsigned short sig; | ||
77 | |||
78 | return probe_kernel_address(ptr, sig) == 0 && sig == ROMSIGNATURE; | ||
79 | } | ||
80 | |||
81 | static int __init romchecksum(const unsigned char *rom, unsigned long length) | ||
82 | { | ||
83 | unsigned char sum, c; | ||
84 | |||
85 | for (sum = 0; length && probe_kernel_address(rom++, c) == 0; length--) | ||
86 | sum += c; | ||
87 | return !length && !sum; | ||
88 | } | ||
89 | |||
90 | static void __init probe_roms(void) | ||
91 | { | ||
92 | const unsigned char *rom; | ||
93 | unsigned long start, length, upper; | ||
94 | unsigned char c; | ||
95 | int i; | ||
96 | |||
97 | /* video rom */ | ||
98 | upper = adapter_rom_resources[0].start; | ||
99 | for (start = video_rom_resource.start; start < upper; start += 2048) { | ||
100 | rom = isa_bus_to_virt(start); | ||
101 | if (!romsignature(rom)) | ||
102 | continue; | ||
103 | |||
104 | video_rom_resource.start = start; | ||
105 | |||
106 | if (probe_kernel_address(rom + 2, c) != 0) | ||
107 | continue; | ||
108 | |||
109 | /* 0 < length <= 0x7f * 512, historically */ | ||
110 | length = c * 512; | ||
111 | |||
112 | /* if checksum okay, trust length byte */ | ||
113 | if (length && romchecksum(rom, length)) | ||
114 | video_rom_resource.end = start + length - 1; | ||
115 | |||
116 | request_resource(&iomem_resource, &video_rom_resource); | ||
117 | break; | ||
118 | } | ||
119 | |||
120 | start = (video_rom_resource.end + 1 + 2047) & ~2047UL; | ||
121 | if (start < upper) | ||
122 | start = upper; | ||
123 | |||
124 | /* system rom */ | ||
125 | request_resource(&iomem_resource, &system_rom_resource); | ||
126 | upper = system_rom_resource.start; | ||
127 | |||
128 | /* check for extension rom (ignore length byte!) */ | ||
129 | rom = isa_bus_to_virt(extension_rom_resource.start); | ||
130 | if (romsignature(rom)) { | ||
131 | length = extension_rom_resource.end - extension_rom_resource.start + 1; | ||
132 | if (romchecksum(rom, length)) { | ||
133 | request_resource(&iomem_resource, &extension_rom_resource); | ||
134 | upper = extension_rom_resource.start; | ||
135 | } | ||
136 | } | ||
137 | |||
138 | /* check for adapter roms on 2k boundaries */ | ||
139 | for (i = 0; i < ARRAY_SIZE(adapter_rom_resources) && start < upper; start += 2048) { | ||
140 | rom = isa_bus_to_virt(start); | ||
141 | if (!romsignature(rom)) | ||
142 | continue; | ||
143 | |||
144 | if (probe_kernel_address(rom + 2, c) != 0) | ||
145 | continue; | ||
146 | |||
147 | /* 0 < length <= 0x7f * 512, historically */ | ||
148 | length = c * 512; | ||
149 | |||
150 | /* but accept any length that fits if checksum okay */ | ||
151 | if (!length || start + length > upper || !romchecksum(rom, length)) | ||
152 | continue; | ||
153 | |||
154 | adapter_rom_resources[i].start = start; | ||
155 | adapter_rom_resources[i].end = start + length - 1; | ||
156 | request_resource(&iomem_resource, &adapter_rom_resources[i]); | ||
157 | |||
158 | start = adapter_rom_resources[i++].end & ~2047UL; | ||
159 | } | ||
160 | } | ||
161 | |||
162 | /* | ||
163 | * Request address space for all standard RAM and ROM resources | ||
164 | * and also for regions reported as reserved by the e820. | ||
165 | */ | ||
166 | void __init init_iomem_resources(struct resource *code_resource, | ||
167 | struct resource *data_resource, | ||
168 | struct resource *bss_resource) | ||
169 | { | ||
170 | int i; | ||
171 | |||
172 | probe_roms(); | ||
173 | for (i = 0; i < e820.nr_map; i++) { | ||
174 | struct resource *res; | ||
175 | #ifndef CONFIG_RESOURCES_64BIT | ||
176 | if (e820.map[i].addr + e820.map[i].size > 0x100000000ULL) | ||
177 | continue; | ||
178 | #endif | ||
179 | res = kzalloc(sizeof(struct resource), GFP_ATOMIC); | ||
180 | switch (e820.map[i].type) { | ||
181 | case E820_RAM: res->name = "System RAM"; break; | ||
182 | case E820_ACPI: res->name = "ACPI Tables"; break; | ||
183 | case E820_NVS: res->name = "ACPI Non-volatile Storage"; break; | ||
184 | default: res->name = "reserved"; | ||
185 | } | ||
186 | res->start = e820.map[i].addr; | ||
187 | res->end = res->start + e820.map[i].size - 1; | ||
188 | res->flags = IORESOURCE_MEM | IORESOURCE_BUSY; | ||
189 | if (request_resource(&iomem_resource, res)) { | ||
190 | kfree(res); | ||
191 | continue; | ||
192 | } | ||
193 | if (e820.map[i].type == E820_RAM) { | ||
194 | /* | ||
195 | * We don't know which RAM region contains kernel data, | ||
196 | * so we try it repeatedly and let the resource manager | ||
197 | * test it. | ||
198 | */ | ||
199 | request_resource(res, code_resource); | ||
200 | request_resource(res, data_resource); | ||
201 | request_resource(res, bss_resource); | ||
202 | #ifdef CONFIG_KEXEC | ||
203 | if (crashk_res.start != crashk_res.end) | ||
204 | request_resource(res, &crashk_res); | ||
205 | #endif | ||
206 | } | ||
207 | } | ||
208 | } | ||
209 | |||
210 | /* Overridden in paravirt.c if CONFIG_PARAVIRT */ | 18 | /* Overridden in paravirt.c if CONFIG_PARAVIRT */ |
211 | char * __init __attribute__((weak)) memory_setup(void) | 19 | char * __init __attribute__((weak)) memory_setup(void) |
212 | { | 20 | { |