diff options
author | bibo,mao <bibo.mao@intel.com> | 2006-12-06 20:14:06 -0500 |
---|---|---|
committer | Andi Kleen <andi@basil.nowhere.org> | 2006-12-06 20:14:06 -0500 |
commit | 269c2d81ed66af7c09a1619ffe165f03e7470a5b (patch) | |
tree | d613830e37d539f41582a213544c70c26d9a5fb1 /arch/i386/kernel/setup.c | |
parent | 8e3de538eec95b57a5b86038988451c38ba83f7e (diff) |
[PATCH] i386: i386 create e820.c to handle standard io/mem resources
This patch creates new file named e820.c to hanle standard io/mem
resources, moving request_standard_resources function from setup.c
to e820.c. Also this patch modifies Makfile to compile file e820.c.
Signed-off-by: bibo,mao <bibo.mao@intel.com>
Signed-off-by: Andi Kleen <ak@suse.de>
Makefile | 2
arch/i386/kernel/Makefile | 2
arch/i386/kernel/e820.c | 289 ++++++++++++++++++++++++++++++++++++++++++++++
arch/i386/kernel/setup.c | 276 -------------------------------------------
3 files changed, 293 insertions(+), 274 deletions(-)
Diffstat (limited to 'arch/i386/kernel/setup.c')
-rw-r--r-- | arch/i386/kernel/setup.c | 276 |
1 files changed, 3 insertions, 273 deletions
diff --git a/arch/i386/kernel/setup.c b/arch/i386/kernel/setup.c index 61539afbdf23..acd2d9392abb 100644 --- a/arch/i386/kernel/setup.c +++ b/arch/i386/kernel/setup.c | |||
@@ -76,11 +76,9 @@ int disable_pse __devinitdata = 0; | |||
76 | /* | 76 | /* |
77 | * Machine setup.. | 77 | * Machine setup.. |
78 | */ | 78 | */ |
79 | 79 | extern struct e820map e820; | |
80 | #ifdef CONFIG_EFI | 80 | extern struct resource code_resource; |
81 | int efi_enabled = 0; | 81 | extern struct resource data_resource; |
82 | EXPORT_SYMBOL(efi_enabled); | ||
83 | #endif | ||
84 | 82 | ||
85 | /* cpu data as detected by the assembly code in head.S */ | 83 | /* cpu data as detected by the assembly code in head.S */ |
86 | struct cpuinfo_x86 new_cpu_data __initdata = { 0, 0, 0, 0, -1, 1, 0, 0, -1 }; | 84 | struct cpuinfo_x86 new_cpu_data __initdata = { 0, 0, 0, 0, -1, 1, 0, 0, -1 }; |
@@ -134,7 +132,6 @@ struct ist_info ist_info; | |||
134 | defined(CONFIG_X86_SPEEDSTEP_SMI_MODULE) | 132 | defined(CONFIG_X86_SPEEDSTEP_SMI_MODULE) |
135 | EXPORT_SYMBOL(ist_info); | 133 | EXPORT_SYMBOL(ist_info); |
136 | #endif | 134 | #endif |
137 | struct e820map e820; | ||
138 | 135 | ||
139 | extern void early_cpu_init(void); | 136 | extern void early_cpu_init(void); |
140 | extern int root_mountflags; | 137 | extern int root_mountflags; |
@@ -149,203 +146,6 @@ static char command_line[COMMAND_LINE_SIZE]; | |||
149 | 146 | ||
150 | unsigned char __initdata boot_params[PARAM_SIZE]; | 147 | unsigned char __initdata boot_params[PARAM_SIZE]; |
151 | 148 | ||
152 | static struct resource data_resource = { | ||
153 | .name = "Kernel data", | ||
154 | .start = 0, | ||
155 | .end = 0, | ||
156 | .flags = IORESOURCE_BUSY | IORESOURCE_MEM | ||
157 | }; | ||
158 | |||
159 | static struct resource code_resource = { | ||
160 | .name = "Kernel code", | ||
161 | .start = 0, | ||
162 | .end = 0, | ||
163 | .flags = IORESOURCE_BUSY | IORESOURCE_MEM | ||
164 | }; | ||
165 | |||
166 | static struct resource system_rom_resource = { | ||
167 | .name = "System ROM", | ||
168 | .start = 0xf0000, | ||
169 | .end = 0xfffff, | ||
170 | .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM | ||
171 | }; | ||
172 | |||
173 | static struct resource extension_rom_resource = { | ||
174 | .name = "Extension ROM", | ||
175 | .start = 0xe0000, | ||
176 | .end = 0xeffff, | ||
177 | .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM | ||
178 | }; | ||
179 | |||
180 | static struct resource adapter_rom_resources[] = { { | ||
181 | .name = "Adapter ROM", | ||
182 | .start = 0xc8000, | ||
183 | .end = 0, | ||
184 | .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM | ||
185 | }, { | ||
186 | .name = "Adapter ROM", | ||
187 | .start = 0, | ||
188 | .end = 0, | ||
189 | .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM | ||
190 | }, { | ||
191 | .name = "Adapter ROM", | ||
192 | .start = 0, | ||
193 | .end = 0, | ||
194 | .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM | ||
195 | }, { | ||
196 | .name = "Adapter ROM", | ||
197 | .start = 0, | ||
198 | .end = 0, | ||
199 | .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM | ||
200 | }, { | ||
201 | .name = "Adapter ROM", | ||
202 | .start = 0, | ||
203 | .end = 0, | ||
204 | .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM | ||
205 | }, { | ||
206 | .name = "Adapter ROM", | ||
207 | .start = 0, | ||
208 | .end = 0, | ||
209 | .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM | ||
210 | } }; | ||
211 | |||
212 | static struct resource video_rom_resource = { | ||
213 | .name = "Video ROM", | ||
214 | .start = 0xc0000, | ||
215 | .end = 0xc7fff, | ||
216 | .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM | ||
217 | }; | ||
218 | |||
219 | static struct resource video_ram_resource = { | ||
220 | .name = "Video RAM area", | ||
221 | .start = 0xa0000, | ||
222 | .end = 0xbffff, | ||
223 | .flags = IORESOURCE_BUSY | IORESOURCE_MEM | ||
224 | }; | ||
225 | |||
226 | static struct resource standard_io_resources[] = { { | ||
227 | .name = "dma1", | ||
228 | .start = 0x0000, | ||
229 | .end = 0x001f, | ||
230 | .flags = IORESOURCE_BUSY | IORESOURCE_IO | ||
231 | }, { | ||
232 | .name = "pic1", | ||
233 | .start = 0x0020, | ||
234 | .end = 0x0021, | ||
235 | .flags = IORESOURCE_BUSY | IORESOURCE_IO | ||
236 | }, { | ||
237 | .name = "timer0", | ||
238 | .start = 0x0040, | ||
239 | .end = 0x0043, | ||
240 | .flags = IORESOURCE_BUSY | IORESOURCE_IO | ||
241 | }, { | ||
242 | .name = "timer1", | ||
243 | .start = 0x0050, | ||
244 | .end = 0x0053, | ||
245 | .flags = IORESOURCE_BUSY | IORESOURCE_IO | ||
246 | }, { | ||
247 | .name = "keyboard", | ||
248 | .start = 0x0060, | ||
249 | .end = 0x006f, | ||
250 | .flags = IORESOURCE_BUSY | IORESOURCE_IO | ||
251 | }, { | ||
252 | .name = "dma page reg", | ||
253 | .start = 0x0080, | ||
254 | .end = 0x008f, | ||
255 | .flags = IORESOURCE_BUSY | IORESOURCE_IO | ||
256 | }, { | ||
257 | .name = "pic2", | ||
258 | .start = 0x00a0, | ||
259 | .end = 0x00a1, | ||
260 | .flags = IORESOURCE_BUSY | IORESOURCE_IO | ||
261 | }, { | ||
262 | .name = "dma2", | ||
263 | .start = 0x00c0, | ||
264 | .end = 0x00df, | ||
265 | .flags = IORESOURCE_BUSY | IORESOURCE_IO | ||
266 | }, { | ||
267 | .name = "fpu", | ||
268 | .start = 0x00f0, | ||
269 | .end = 0x00ff, | ||
270 | .flags = IORESOURCE_BUSY | IORESOURCE_IO | ||
271 | } }; | ||
272 | |||
273 | #define romsignature(x) (*(unsigned short *)(x) == 0xaa55) | ||
274 | |||
275 | static int __init romchecksum(unsigned char *rom, unsigned long length) | ||
276 | { | ||
277 | unsigned char *p, sum = 0; | ||
278 | |||
279 | for (p = rom; p < rom + length; p++) | ||
280 | sum += *p; | ||
281 | return sum == 0; | ||
282 | } | ||
283 | |||
284 | static void __init probe_roms(void) | ||
285 | { | ||
286 | unsigned long start, length, upper; | ||
287 | unsigned char *rom; | ||
288 | int i; | ||
289 | |||
290 | /* video rom */ | ||
291 | upper = adapter_rom_resources[0].start; | ||
292 | for (start = video_rom_resource.start; start < upper; start += 2048) { | ||
293 | rom = isa_bus_to_virt(start); | ||
294 | if (!romsignature(rom)) | ||
295 | continue; | ||
296 | |||
297 | video_rom_resource.start = start; | ||
298 | |||
299 | /* 0 < length <= 0x7f * 512, historically */ | ||
300 | length = rom[2] * 512; | ||
301 | |||
302 | /* if checksum okay, trust length byte */ | ||
303 | if (length && romchecksum(rom, length)) | ||
304 | video_rom_resource.end = start + length - 1; | ||
305 | |||
306 | request_resource(&iomem_resource, &video_rom_resource); | ||
307 | break; | ||
308 | } | ||
309 | |||
310 | start = (video_rom_resource.end + 1 + 2047) & ~2047UL; | ||
311 | if (start < upper) | ||
312 | start = upper; | ||
313 | |||
314 | /* system rom */ | ||
315 | request_resource(&iomem_resource, &system_rom_resource); | ||
316 | upper = system_rom_resource.start; | ||
317 | |||
318 | /* check for extension rom (ignore length byte!) */ | ||
319 | rom = isa_bus_to_virt(extension_rom_resource.start); | ||
320 | if (romsignature(rom)) { | ||
321 | length = extension_rom_resource.end - extension_rom_resource.start + 1; | ||
322 | if (romchecksum(rom, length)) { | ||
323 | request_resource(&iomem_resource, &extension_rom_resource); | ||
324 | upper = extension_rom_resource.start; | ||
325 | } | ||
326 | } | ||
327 | |||
328 | /* check for adapter roms on 2k boundaries */ | ||
329 | for (i = 0; i < ARRAY_SIZE(adapter_rom_resources) && start < upper; start += 2048) { | ||
330 | rom = isa_bus_to_virt(start); | ||
331 | if (!romsignature(rom)) | ||
332 | continue; | ||
333 | |||
334 | /* 0 < length <= 0x7f * 512, historically */ | ||
335 | length = rom[2] * 512; | ||
336 | |||
337 | /* but accept any length that fits if checksum okay */ | ||
338 | if (!length || start + length > upper || !romchecksum(rom, length)) | ||
339 | continue; | ||
340 | |||
341 | adapter_rom_resources[i].start = start; | ||
342 | adapter_rom_resources[i].end = start + length - 1; | ||
343 | request_resource(&iomem_resource, &adapter_rom_resources[i]); | ||
344 | |||
345 | start = adapter_rom_resources[i++].end & ~2047UL; | ||
346 | } | ||
347 | } | ||
348 | |||
349 | static void __init limit_regions(unsigned long long size) | 149 | static void __init limit_regions(unsigned long long size) |
350 | { | 150 | { |
351 | unsigned long long current_addr = 0; | 151 | unsigned long long current_addr = 0; |
@@ -1200,77 +1000,7 @@ void __init remapped_pgdat_init(void) | |||
1200 | } | 1000 | } |
1201 | } | 1001 | } |
1202 | 1002 | ||
1203 | /* | ||
1204 | * Request address space for all standard RAM and ROM resources | ||
1205 | * and also for regions reported as reserved by the e820. | ||
1206 | */ | ||
1207 | static void __init | ||
1208 | legacy_init_iomem_resources(struct resource *code_resource, struct resource *data_resource) | ||
1209 | { | ||
1210 | int i; | ||
1211 | |||
1212 | probe_roms(); | ||
1213 | for (i = 0; i < e820.nr_map; i++) { | ||
1214 | struct resource *res; | ||
1215 | #ifndef CONFIG_RESOURCES_64BIT | ||
1216 | if (e820.map[i].addr + e820.map[i].size > 0x100000000ULL) | ||
1217 | continue; | ||
1218 | #endif | ||
1219 | res = kzalloc(sizeof(struct resource), GFP_ATOMIC); | ||
1220 | switch (e820.map[i].type) { | ||
1221 | case E820_RAM: res->name = "System RAM"; break; | ||
1222 | case E820_ACPI: res->name = "ACPI Tables"; break; | ||
1223 | case E820_NVS: res->name = "ACPI Non-volatile Storage"; break; | ||
1224 | default: res->name = "reserved"; | ||
1225 | } | ||
1226 | res->start = e820.map[i].addr; | ||
1227 | res->end = res->start + e820.map[i].size - 1; | ||
1228 | res->flags = IORESOURCE_MEM | IORESOURCE_BUSY; | ||
1229 | if (request_resource(&iomem_resource, res)) { | ||
1230 | kfree(res); | ||
1231 | continue; | ||
1232 | } | ||
1233 | if (e820.map[i].type == E820_RAM) { | ||
1234 | /* | ||
1235 | * We don't know which RAM region contains kernel data, | ||
1236 | * so we try it repeatedly and let the resource manager | ||
1237 | * test it. | ||
1238 | */ | ||
1239 | request_resource(res, code_resource); | ||
1240 | request_resource(res, data_resource); | ||
1241 | #ifdef CONFIG_KEXEC | ||
1242 | request_resource(res, &crashk_res); | ||
1243 | #endif | ||
1244 | } | ||
1245 | } | ||
1246 | } | ||
1247 | |||
1248 | /* | ||
1249 | * Request address space for all standard resources | ||
1250 | * | ||
1251 | * This is called just before pcibios_init(), which is also a | ||
1252 | * subsys_initcall, but is linked in later (in arch/i386/pci/common.c). | ||
1253 | */ | ||
1254 | static int __init request_standard_resources(void) | ||
1255 | { | ||
1256 | int i; | ||
1257 | |||
1258 | printk("Setting up standard PCI resources\n"); | ||
1259 | if (efi_enabled) | ||
1260 | efi_initialize_iomem_resources(&code_resource, &data_resource); | ||
1261 | else | ||
1262 | legacy_init_iomem_resources(&code_resource, &data_resource); | ||
1263 | |||
1264 | /* EFI systems may still have VGA */ | ||
1265 | request_resource(&iomem_resource, &video_ram_resource); | ||
1266 | |||
1267 | /* request I/O space for devices used on all i[345]86 PCs */ | ||
1268 | for (i = 0; i < ARRAY_SIZE(standard_io_resources); i++) | ||
1269 | request_resource(&ioport_resource, &standard_io_resources[i]); | ||
1270 | return 0; | ||
1271 | } | ||
1272 | 1003 | ||
1273 | subsys_initcall(request_standard_resources); | ||
1274 | 1004 | ||
1275 | static void __init register_memory(void) | 1005 | static void __init register_memory(void) |
1276 | { | 1006 | { |