]>
Commit | Line | Data |
---|---|---|
1da177e4 | 1 | /* |
1da177e4 LT |
2 | * Copyright (C) 1995 Linus Torvalds |
3 | * | |
4 | * Support of BIGMEM added by Gerhard Wichert, Siemens AG, July 1999 | |
5 | * | |
6 | * Memory region support | |
7 | * David Parsons <orc@pell.chi.il.us>, July-August 1999 | |
8 | * | |
9 | * Added E820 sanitization routine (removes overlapping memory regions); | |
10 | * Brian Moyle <bmoyle@mvista.com>, February 2001 | |
11 | * | |
12 | * Moved CPU detection code to cpu/${cpu}.c | |
13 | * Patrick Mochel <mochel@osdl.org>, March 2002 | |
14 | * | |
15 | * Provisions for empty E820 memory regions (reported by certain BIOSes). | |
16 | * Alex Achenbach <xela@slit.de>, December 2002. | |
17 | * | |
18 | */ | |
19 | ||
20 | /* | |
21 | * This file handles the architecture-dependent parts of initialization | |
22 | */ | |
23 | ||
24 | #include <linux/sched.h> | |
25 | #include <linux/mm.h> | |
05b79bdc | 26 | #include <linux/mmzone.h> |
894673ee | 27 | #include <linux/screen_info.h> |
1da177e4 LT |
28 | #include <linux/ioport.h> |
29 | #include <linux/acpi.h> | |
30 | #include <linux/apm_bios.h> | |
31 | #include <linux/initrd.h> | |
32 | #include <linux/bootmem.h> | |
33 | #include <linux/seq_file.h> | |
34 | #include <linux/console.h> | |
35 | #include <linux/mca.h> | |
36 | #include <linux/root_dev.h> | |
37 | #include <linux/highmem.h> | |
38 | #include <linux/module.h> | |
39 | #include <linux/efi.h> | |
40 | #include <linux/init.h> | |
41 | #include <linux/edd.h> | |
138fe4e0 | 42 | #include <linux/iscsi_ibft.h> |
1da177e4 | 43 | #include <linux/nodemask.h> |
1bc3b91a | 44 | #include <linux/kexec.h> |
2030eae5 | 45 | #include <linux/crash_dump.h> |
e9928674 | 46 | #include <linux/dmi.h> |
22a9835c | 47 | #include <linux/pfn.h> |
376ff035 | 48 | #include <linux/pci.h> |
f212ec4b | 49 | #include <linux/init_ohci1394_dma.h> |
790c73f6 | 50 | #include <linux/kvm_para.h> |
1bc3b91a | 51 | |
1da177e4 | 52 | #include <video/edid.h> |
1bc3b91a | 53 | |
093af8d7 | 54 | #include <asm/mtrr.h> |
9635b47d | 55 | #include <asm/apic.h> |
1da177e4 LT |
56 | #include <asm/e820.h> |
57 | #include <asm/mpspec.h> | |
91023300 | 58 | #include <asm/mmzone.h> |
1da177e4 LT |
59 | #include <asm/setup.h> |
60 | #include <asm/arch_hooks.h> | |
61 | #include <asm/sections.h> | |
62 | #include <asm/io_apic.h> | |
63 | #include <asm/ist.h> | |
64 | #include <asm/io.h> | |
7ce0bcfd | 65 | #include <asm/vmi.h> |
e75eac33 | 66 | #include <setup_arch.h> |
ce3fe6b2 | 67 | #include <asm/bios_ebda.h> |
00bf4098 | 68 | #include <asm/cacheflush.h> |
2fde61fd | 69 | #include <asm/processor.h> |
ecacf09f | 70 | #include <asm/efi.h> |
1da177e4 LT |
71 | |
72 | /* This value is set up by the early boot code to point to the value | |
73 | immediately after the boot time page tables. It contains a *physical* | |
74 | address, and must not be in the .bss segment! */ | |
f0d43100 | 75 | unsigned long init_pg_tables_start __initdata = ~0UL; |
1da177e4 LT |
76 | unsigned long init_pg_tables_end __initdata = ~0UL; |
77 | ||
1da177e4 LT |
78 | /* |
79 | * Machine setup.. | |
80 | */ | |
c9cce83d BW |
81 | static struct resource data_resource = { |
82 | .name = "Kernel data", | |
83 | .start = 0, | |
84 | .end = 0, | |
85 | .flags = IORESOURCE_BUSY | IORESOURCE_MEM | |
86 | }; | |
87 | ||
88 | static struct resource code_resource = { | |
89 | .name = "Kernel code", | |
90 | .start = 0, | |
91 | .end = 0, | |
92 | .flags = IORESOURCE_BUSY | IORESOURCE_MEM | |
93 | }; | |
94 | ||
95 | static struct resource bss_resource = { | |
96 | .name = "Kernel bss", | |
97 | .start = 0, | |
98 | .end = 0, | |
99 | .flags = IORESOURCE_BUSY | IORESOURCE_MEM | |
100 | }; | |
101 | ||
102 | static struct resource video_ram_resource = { | |
103 | .name = "Video RAM area", | |
104 | .start = 0xa0000, | |
105 | .end = 0xbffff, | |
106 | .flags = IORESOURCE_BUSY | IORESOURCE_MEM | |
107 | }; | |
108 | ||
109 | static struct resource standard_io_resources[] = { { | |
110 | .name = "dma1", | |
111 | .start = 0x0000, | |
112 | .end = 0x001f, | |
113 | .flags = IORESOURCE_BUSY | IORESOURCE_IO | |
114 | }, { | |
115 | .name = "pic1", | |
116 | .start = 0x0020, | |
117 | .end = 0x0021, | |
118 | .flags = IORESOURCE_BUSY | IORESOURCE_IO | |
119 | }, { | |
120 | .name = "timer0", | |
121 | .start = 0x0040, | |
122 | .end = 0x0043, | |
123 | .flags = IORESOURCE_BUSY | IORESOURCE_IO | |
124 | }, { | |
125 | .name = "timer1", | |
126 | .start = 0x0050, | |
127 | .end = 0x0053, | |
128 | .flags = IORESOURCE_BUSY | IORESOURCE_IO | |
129 | }, { | |
130 | .name = "keyboard", | |
131 | .start = 0x0060, | |
9096bd7a HW |
132 | .end = 0x0060, |
133 | .flags = IORESOURCE_BUSY | IORESOURCE_IO | |
134 | }, { | |
135 | .name = "keyboard", | |
136 | .start = 0x0064, | |
137 | .end = 0x0064, | |
c9cce83d BW |
138 | .flags = IORESOURCE_BUSY | IORESOURCE_IO |
139 | }, { | |
140 | .name = "dma page reg", | |
141 | .start = 0x0080, | |
142 | .end = 0x008f, | |
143 | .flags = IORESOURCE_BUSY | IORESOURCE_IO | |
144 | }, { | |
145 | .name = "pic2", | |
146 | .start = 0x00a0, | |
147 | .end = 0x00a1, | |
148 | .flags = IORESOURCE_BUSY | IORESOURCE_IO | |
149 | }, { | |
150 | .name = "dma2", | |
151 | .start = 0x00c0, | |
152 | .end = 0x00df, | |
153 | .flags = IORESOURCE_BUSY | IORESOURCE_IO | |
154 | }, { | |
155 | .name = "fpu", | |
156 | .start = 0x00f0, | |
157 | .end = 0x00ff, | |
158 | .flags = IORESOURCE_BUSY | IORESOURCE_IO | |
159 | } }; | |
1da177e4 LT |
160 | |
161 | /* cpu data as detected by the assembly code in head.S */ | |
4a5d107a | 162 | struct cpuinfo_x86 new_cpu_data __cpuinitdata = { 0, 0, 0, 0, -1, 1, 0, 0, -1 }; |
1da177e4 | 163 | /* common cpu data for all cpus */ |
c3d8c141 | 164 | struct cpuinfo_x86 boot_cpu_data __read_mostly = { 0, 0, 0, 0, -1, 1, 0, 0, -1 }; |
129f6946 | 165 | EXPORT_SYMBOL(boot_cpu_data); |
1da177e4 | 166 | |
0c254e38 AS |
167 | unsigned int def_to_bigsmp; |
168 | ||
551889a6 | 169 | #ifndef CONFIG_X86_PAE |
1da177e4 | 170 | unsigned long mmu_cr4_features; |
551889a6 IC |
171 | #else |
172 | unsigned long mmu_cr4_features = X86_CR4_PAE; | |
173 | #endif | |
1da177e4 | 174 | |
1da177e4 LT |
175 | /* for MCA, but anyone else can use it if they want */ |
176 | unsigned int machine_id; | |
177 | unsigned int machine_submodel_id; | |
178 | unsigned int BIOS_revision; | |
1da177e4 | 179 | |
1da177e4 LT |
180 | /* Boot loader ID as an integer, for the benefit of proc_dointvec */ |
181 | int bootloader_type; | |
182 | ||
183 | /* user-defined highmem size */ | |
184 | static unsigned int highmem_pages = -1; | |
185 | ||
186 | /* | |
187 | * Setup options | |
188 | */ | |
1da177e4 | 189 | struct screen_info screen_info; |
129f6946 | 190 | EXPORT_SYMBOL(screen_info); |
1da177e4 | 191 | struct apm_info apm_info; |
129f6946 | 192 | EXPORT_SYMBOL(apm_info); |
1da177e4 | 193 | struct edid_info edid_info; |
5e518d76 | 194 | EXPORT_SYMBOL_GPL(edid_info); |
1da177e4 | 195 | struct ist_info ist_info; |
129f6946 AD |
196 | #if defined(CONFIG_X86_SPEEDSTEP_SMI) || \ |
197 | defined(CONFIG_X86_SPEEDSTEP_SMI_MODULE) | |
198 | EXPORT_SYMBOL(ist_info); | |
199 | #endif | |
1da177e4 LT |
200 | |
201 | extern void early_cpu_init(void); | |
1da177e4 LT |
202 | extern int root_mountflags; |
203 | ||
e44b7b75 | 204 | unsigned long saved_video_mode; |
1da177e4 | 205 | |
cf8fa920 | 206 | #define RAMDISK_IMAGE_START_MASK 0x07FF |
1da177e4 | 207 | #define RAMDISK_PROMPT_FLAG 0x8000 |
cf8fa920 | 208 | #define RAMDISK_LOAD_FLAG 0x4000 |
1da177e4 | 209 | |
4e498b66 | 210 | static char __initdata command_line[COMMAND_LINE_SIZE]; |
1da177e4 | 211 | |
6d7d7433 | 212 | #ifndef CONFIG_DEBUG_BOOT_PARAMS |
48c7ae67 | 213 | struct boot_params __initdata boot_params; |
6d7d7433 HY |
214 | #else |
215 | struct boot_params boot_params; | |
216 | #endif | |
1da177e4 | 217 | |
1da177e4 LT |
218 | #if defined(CONFIG_EDD) || defined(CONFIG_EDD_MODULE) |
219 | struct edd edd; | |
220 | #ifdef CONFIG_EDD_MODULE | |
221 | EXPORT_SYMBOL(edd); | |
222 | #endif | |
223 | /** | |
224 | * copy_edd() - Copy the BIOS EDD information | |
225 | * from boot_params into a safe place. | |
226 | * | |
227 | */ | |
228 | static inline void copy_edd(void) | |
229 | { | |
30c82645 PA |
230 | memcpy(edd.mbr_signature, boot_params.edd_mbr_sig_buffer, |
231 | sizeof(edd.mbr_signature)); | |
232 | memcpy(edd.edd_info, boot_params.eddbuf, sizeof(edd.edd_info)); | |
233 | edd.mbr_signature_nr = boot_params.edd_mbr_sig_buf_entries; | |
234 | edd.edd_info_nr = boot_params.eddbuf_entries; | |
1da177e4 LT |
235 | } |
236 | #else | |
237 | static inline void copy_edd(void) | |
238 | { | |
239 | } | |
240 | #endif | |
241 | ||
1a3f239d RR |
242 | #ifdef CONFIG_PROC_VMCORE |
243 | /* elfcorehdr= specifies the location of elf core header | |
244 | * stored by the crashed kernel. | |
245 | */ | |
246 | static int __init parse_elfcorehdr(char *arg) | |
247 | { | |
248 | if (!arg) | |
249 | return -EINVAL; | |
66759a01 | 250 | |
1a3f239d RR |
251 | elfcorehdr_addr = memparse(arg, &arg); |
252 | return 0; | |
253 | } | |
254 | early_param("elfcorehdr", parse_elfcorehdr); | |
255 | #endif /* CONFIG_PROC_VMCORE */ | |
1da177e4 | 256 | |
1a3f239d RR |
257 | /* |
258 | * highmem=size forces highmem to be exactly 'size' bytes. | |
259 | * This works even on boxes that have no highmem otherwise. | |
260 | * This also works to reduce highmem size on bigger boxes. | |
261 | */ | |
262 | static int __init parse_highmem(char *arg) | |
263 | { | |
264 | if (!arg) | |
265 | return -EINVAL; | |
9635b47d | 266 | |
1a3f239d RR |
267 | highmem_pages = memparse(arg, &arg) >> PAGE_SHIFT; |
268 | return 0; | |
269 | } | |
270 | early_param("highmem", parse_highmem); | |
9635b47d | 271 | |
1a3f239d RR |
272 | /* |
273 | * vmalloc=size forces the vmalloc area to be exactly 'size' | |
274 | * bytes. This can be used to increase (or decrease) the | |
275 | * vmalloc area - the default is 128m. | |
276 | */ | |
277 | static int __init parse_vmalloc(char *arg) | |
278 | { | |
279 | if (!arg) | |
280 | return -EINVAL; | |
1bc3b91a | 281 | |
1a3f239d RR |
282 | __VMALLOC_RESERVE = memparse(arg, &arg); |
283 | return 0; | |
1da177e4 | 284 | } |
1a3f239d | 285 | early_param("vmalloc", parse_vmalloc); |
1da177e4 | 286 | |
461a9aff ZA |
287 | /* |
288 | * reservetop=size reserves a hole at the top of the kernel address space which | |
289 | * a hypervisor can load into later. Needed for dynamically loaded hypervisors, | |
290 | * so relocating the fixmap can be done before paging initialization. | |
291 | */ | |
292 | static int __init parse_reservetop(char *arg) | |
293 | { | |
294 | unsigned long address; | |
295 | ||
296 | if (!arg) | |
297 | return -EINVAL; | |
298 | ||
299 | address = memparse(arg, &arg); | |
300 | reserve_top_address(address); | |
301 | return 0; | |
302 | } | |
303 | early_param("reservetop", parse_reservetop); | |
304 | ||
1da177e4 LT |
305 | /* |
306 | * Determine low and high memory ranges: | |
307 | */ | |
308 | unsigned long __init find_max_low_pfn(void) | |
309 | { | |
310 | unsigned long max_low_pfn; | |
311 | ||
312 | max_low_pfn = max_pfn; | |
313 | if (max_low_pfn > MAXMEM_PFN) { | |
314 | if (highmem_pages == -1) | |
315 | highmem_pages = max_pfn - MAXMEM_PFN; | |
316 | if (highmem_pages + MAXMEM_PFN < max_pfn) | |
317 | max_pfn = MAXMEM_PFN + highmem_pages; | |
318 | if (highmem_pages + MAXMEM_PFN > max_pfn) { | |
319 | printk("only %luMB highmem pages available, ignoring highmem size of %uMB.\n", pages_to_mb(max_pfn - MAXMEM_PFN), pages_to_mb(highmem_pages)); | |
320 | highmem_pages = 0; | |
321 | } | |
322 | max_low_pfn = MAXMEM_PFN; | |
323 | #ifndef CONFIG_HIGHMEM | |
324 | /* Maximum memory usable is what is directly addressable */ | |
325 | printk(KERN_WARNING "Warning only %ldMB will be used.\n", | |
326 | MAXMEM>>20); | |
327 | if (max_pfn > MAX_NONPAE_PFN) | |
c673f1a9 | 328 | printk(KERN_WARNING "Use a HIGHMEM64G enabled kernel.\n"); |
1da177e4 LT |
329 | else |
330 | printk(KERN_WARNING "Use a HIGHMEM enabled kernel.\n"); | |
331 | max_pfn = MAXMEM_PFN; | |
332 | #else /* !CONFIG_HIGHMEM */ | |
c673f1a9 | 333 | #ifndef CONFIG_HIGHMEM64G |
1da177e4 LT |
334 | if (max_pfn > MAX_NONPAE_PFN) { |
335 | max_pfn = MAX_NONPAE_PFN; | |
336 | printk(KERN_WARNING "Warning only 4GB will be used.\n"); | |
c673f1a9 | 337 | printk(KERN_WARNING "Use a HIGHMEM64G enabled kernel.\n"); |
1da177e4 | 338 | } |
c673f1a9 | 339 | #endif /* !CONFIG_HIGHMEM64G */ |
1da177e4 LT |
340 | #endif /* !CONFIG_HIGHMEM */ |
341 | } else { | |
342 | if (highmem_pages == -1) | |
343 | highmem_pages = 0; | |
344 | #ifdef CONFIG_HIGHMEM | |
345 | if (highmem_pages >= max_pfn) { | |
346 | printk(KERN_ERR "highmem size specified (%uMB) is bigger than pages available (%luMB)!.\n", pages_to_mb(highmem_pages), pages_to_mb(max_pfn)); | |
347 | highmem_pages = 0; | |
348 | } | |
349 | if (highmem_pages) { | |
350 | if (max_low_pfn-highmem_pages < 64*1024*1024/PAGE_SIZE){ | |
351 | printk(KERN_ERR "highmem size %uMB results in smaller than 64MB lowmem, ignoring it.\n", pages_to_mb(highmem_pages)); | |
352 | highmem_pages = 0; | |
353 | } | |
354 | max_low_pfn -= highmem_pages; | |
355 | } | |
356 | #else | |
357 | if (highmem_pages) | |
358 | printk(KERN_ERR "ignoring highmem size on non-highmem kernel!\n"); | |
359 | #endif | |
360 | } | |
361 | return max_low_pfn; | |
362 | } | |
363 | ||
05b79bdc | 364 | #ifndef CONFIG_NEED_MULTIPLE_NODES |
a4928cff | 365 | static void __init setup_bootmem_allocator(void); |
1da177e4 LT |
366 | static unsigned long __init setup_memory(void) |
367 | { | |
368 | /* | |
369 | * partially used pages are not usable - thus | |
370 | * we are rounding upwards: | |
371 | */ | |
372 | min_low_pfn = PFN_UP(init_pg_tables_end); | |
373 | ||
1da177e4 LT |
374 | max_low_pfn = find_max_low_pfn(); |
375 | ||
376 | #ifdef CONFIG_HIGHMEM | |
377 | highstart_pfn = highend_pfn = max_pfn; | |
378 | if (max_pfn > max_low_pfn) { | |
379 | highstart_pfn = max_low_pfn; | |
380 | } | |
f19dc2f2 | 381 | memory_present(0, 0, highend_pfn); |
1da177e4 LT |
382 | printk(KERN_NOTICE "%ldMB HIGHMEM available.\n", |
383 | pages_to_mb(highend_pfn - highstart_pfn)); | |
ba9c231f JB |
384 | num_physpages = highend_pfn; |
385 | high_memory = (void *) __va(highstart_pfn * PAGE_SIZE - 1) + 1; | |
386 | #else | |
f19dc2f2 | 387 | memory_present(0, 0, max_low_pfn); |
ba9c231f JB |
388 | num_physpages = max_low_pfn; |
389 | high_memory = (void *) __va(max_low_pfn * PAGE_SIZE - 1) + 1; | |
390 | #endif | |
391 | #ifdef CONFIG_FLATMEM | |
392 | max_mapnr = num_physpages; | |
1da177e4 LT |
393 | #endif |
394 | printk(KERN_NOTICE "%ldMB LOWMEM available.\n", | |
395 | pages_to_mb(max_low_pfn)); | |
396 | ||
397 | setup_bootmem_allocator(); | |
398 | ||
399 | return max_low_pfn; | |
400 | } | |
401 | ||
a4928cff | 402 | static void __init zone_sizes_init(void) |
1da177e4 | 403 | { |
6391af17 MG |
404 | unsigned long max_zone_pfns[MAX_NR_ZONES]; |
405 | memset(max_zone_pfns, 0, sizeof(max_zone_pfns)); | |
406 | max_zone_pfns[ZONE_DMA] = | |
407 | virt_to_phys((char *)MAX_DMA_ADDRESS) >> PAGE_SHIFT; | |
408 | max_zone_pfns[ZONE_NORMAL] = max_low_pfn; | |
7b2a0a6c | 409 | remove_all_active_ranges(); |
1da177e4 | 410 | #ifdef CONFIG_HIGHMEM |
6391af17 | 411 | max_zone_pfns[ZONE_HIGHMEM] = highend_pfn; |
7b2a0a6c | 412 | e820_register_active_regions(0, 0, highend_pfn); |
4cfee88a | 413 | #else |
7b2a0a6c | 414 | e820_register_active_regions(0, 0, max_low_pfn); |
1da177e4 | 415 | #endif |
4cfee88a MG |
416 | |
417 | free_area_init_nodes(max_zone_pfns); | |
1da177e4 LT |
418 | } |
419 | #else | |
05b79bdc | 420 | extern unsigned long __init setup_memory(void); |
1da177e4 | 421 | extern void zone_sizes_init(void); |
05b79bdc | 422 | #endif /* !CONFIG_NEED_MULTIPLE_NODES */ |
1da177e4 | 423 | |
d62cc471 BW |
424 | static inline unsigned long long get_total_mem(void) |
425 | { | |
426 | unsigned long long total; | |
427 | ||
428 | total = max_low_pfn - min_low_pfn; | |
429 | #ifdef CONFIG_HIGHMEM | |
430 | total += highend_pfn - highstart_pfn; | |
431 | #endif | |
432 | ||
433 | return total << PAGE_SHIFT; | |
434 | } | |
435 | ||
436 | #ifdef CONFIG_KEXEC | |
437 | static void __init reserve_crashkernel(void) | |
438 | { | |
439 | unsigned long long total_mem; | |
440 | unsigned long long crash_size, crash_base; | |
441 | int ret; | |
442 | ||
443 | total_mem = get_total_mem(); | |
444 | ||
445 | ret = parse_crashkernel(boot_command_line, total_mem, | |
446 | &crash_size, &crash_base); | |
447 | if (ret == 0 && crash_size > 0) { | |
41c094fd | 448 | if (crash_base <= 0) { |
d62cc471 BW |
449 | printk(KERN_INFO "crashkernel reservation failed - " |
450 | "you have to specify a base address\n"); | |
41c094fd YL |
451 | return; |
452 | } | |
453 | ||
454 | if (reserve_bootmem_generic(crash_base, crash_size, | |
455 | BOOTMEM_EXCLUSIVE) < 0) { | |
456 | printk(KERN_INFO "crashkernel reservation failed - " | |
457 | "memory is in use\n"); | |
458 | return; | |
459 | } | |
460 | ||
461 | printk(KERN_INFO "Reserving %ldMB of memory at %ldMB " | |
462 | "for crashkernel (System RAM: %ldMB)\n", | |
463 | (unsigned long)(crash_size >> 20), | |
464 | (unsigned long)(crash_base >> 20), | |
465 | (unsigned long)(total_mem >> 20)); | |
466 | ||
467 | crashk_res.start = crash_base; | |
468 | crashk_res.end = crash_base + crash_size - 1; | |
469 | insert_resource(&iomem_resource, &crashk_res); | |
d62cc471 BW |
470 | } |
471 | } | |
472 | #else | |
473 | static inline void __init reserve_crashkernel(void) | |
474 | {} | |
475 | #endif | |
476 | ||
cf8fa920 PA |
477 | #ifdef CONFIG_BLK_DEV_INITRD |
478 | ||
479 | static bool do_relocate_initrd = false; | |
480 | ||
481 | static void __init reserve_initrd(void) | |
482 | { | |
ba5b14cc YL |
483 | u64 ramdisk_image = boot_params.hdr.ramdisk_image; |
484 | u64 ramdisk_size = boot_params.hdr.ramdisk_size; | |
485 | u64 ramdisk_end = ramdisk_image + ramdisk_size; | |
486 | u64 end_of_lowmem = max_low_pfn << PAGE_SHIFT; | |
487 | u64 ramdisk_here; | |
cf8fa920 | 488 | |
cf8fa920 PA |
489 | if (!boot_params.hdr.type_of_loader || |
490 | !ramdisk_image || !ramdisk_size) | |
491 | return; /* No initrd provided by bootloader */ | |
492 | ||
a4c81cf6 YL |
493 | initrd_start = 0; |
494 | ||
cf8fa920 | 495 | if (ramdisk_size >= end_of_lowmem/2) { |
3945e2c9 | 496 | free_early(ramdisk_image, ramdisk_end); |
cf8fa920 PA |
497 | printk(KERN_ERR "initrd too large to handle, " |
498 | "disabling initrd\n"); | |
499 | return; | |
500 | } | |
a4c81cf6 | 501 | |
f0d43100 YL |
502 | printk(KERN_INFO "old RAMDISK: %08llx - %08llx\n", ramdisk_image, |
503 | ramdisk_end); | |
504 | ||
505 | ||
cf8fa920 PA |
506 | if (ramdisk_end <= end_of_lowmem) { |
507 | /* All in lowmem, easy case */ | |
a4c81cf6 YL |
508 | /* |
509 | * don't need to reserve again, already reserved early | |
ba5b14cc | 510 | * in i386_start_kernel |
a4c81cf6 | 511 | */ |
cf8fa920 PA |
512 | initrd_start = ramdisk_image + PAGE_OFFSET; |
513 | initrd_end = initrd_start+ramdisk_size; | |
514 | return; | |
515 | } | |
516 | ||
517 | /* We need to move the initrd down into lowmem */ | |
ba5b14cc YL |
518 | ramdisk_here = find_e820_area(min_low_pfn<<PAGE_SHIFT, |
519 | end_of_lowmem, ramdisk_size, | |
520 | PAGE_SIZE); | |
cf8fa920 | 521 | |
3945e2c9 YL |
522 | if (ramdisk_here == -1ULL) |
523 | panic("Cannot find place for new RAMDISK of size %lld\n", | |
524 | ramdisk_size); | |
525 | ||
cf8fa920 PA |
526 | /* Note: this includes all the lowmem currently occupied by |
527 | the initrd, we rely on that fact to keep the data intact. */ | |
3945e2c9 | 528 | reserve_early(ramdisk_here, ramdisk_here + ramdisk_size, |
ba5b14cc | 529 | "NEW RAMDISK"); |
cf8fa920 PA |
530 | initrd_start = ramdisk_here + PAGE_OFFSET; |
531 | initrd_end = initrd_start + ramdisk_size; | |
f0d43100 YL |
532 | printk(KERN_INFO "Allocated new RAMDISK: %08llx - %08llx\n", |
533 | ramdisk_here, ramdisk_here + ramdisk_size); | |
cf8fa920 PA |
534 | |
535 | do_relocate_initrd = true; | |
536 | } | |
537 | ||
538 | #define MAX_MAP_CHUNK (NR_FIX_BTMAPS << PAGE_SHIFT) | |
539 | ||
540 | static void __init relocate_initrd(void) | |
541 | { | |
ba5b14cc YL |
542 | u64 ramdisk_image = boot_params.hdr.ramdisk_image; |
543 | u64 ramdisk_size = boot_params.hdr.ramdisk_size; | |
544 | u64 end_of_lowmem = max_low_pfn << PAGE_SHIFT; | |
545 | u64 ramdisk_here; | |
cf8fa920 PA |
546 | unsigned long slop, clen, mapaddr; |
547 | char *p, *q; | |
548 | ||
549 | if (!do_relocate_initrd) | |
550 | return; | |
551 | ||
552 | ramdisk_here = initrd_start - PAGE_OFFSET; | |
553 | ||
554 | q = (char *)initrd_start; | |
555 | ||
556 | /* Copy any lowmem portion of the initrd */ | |
557 | if (ramdisk_image < end_of_lowmem) { | |
558 | clen = end_of_lowmem - ramdisk_image; | |
559 | p = (char *)__va(ramdisk_image); | |
560 | memcpy(q, p, clen); | |
561 | q += clen; | |
a4c81cf6 | 562 | /* need to free these low pages...*/ |
ba5b14cc YL |
563 | printk(KERN_INFO "Freeing old partial RAMDISK %08llx-%08llx\n", |
564 | ramdisk_image, ramdisk_image + clen - 1); | |
a4c81cf6 | 565 | free_bootmem(ramdisk_image, clen); |
cf8fa920 PA |
566 | ramdisk_image += clen; |
567 | ramdisk_size -= clen; | |
568 | } | |
569 | ||
570 | /* Copy the highmem portion of the initrd */ | |
571 | while (ramdisk_size) { | |
572 | slop = ramdisk_image & ~PAGE_MASK; | |
573 | clen = ramdisk_size; | |
574 | if (clen > MAX_MAP_CHUNK-slop) | |
575 | clen = MAX_MAP_CHUNK-slop; | |
576 | mapaddr = ramdisk_image & PAGE_MASK; | |
beacfaac | 577 | p = early_ioremap(mapaddr, clen+slop); |
cf8fa920 | 578 | memcpy(q, p+slop, clen); |
beacfaac | 579 | early_iounmap(p, clen+slop); |
cf8fa920 PA |
580 | q += clen; |
581 | ramdisk_image += clen; | |
582 | ramdisk_size -= clen; | |
583 | } | |
a4c81cf6 | 584 | /* high pages is not converted by early_res_to_bootmem */ |
ba5b14cc YL |
585 | ramdisk_image = boot_params.hdr.ramdisk_image; |
586 | ramdisk_size = boot_params.hdr.ramdisk_size; | |
587 | printk(KERN_INFO "Copied RAMDISK from %016llx - %016llx to %08llx - %08llx\n", | |
588 | ramdisk_image, ramdisk_image + ramdisk_size - 1, | |
589 | ramdisk_here, ramdisk_here + ramdisk_size - 1); | |
9a27f5c5 YL |
590 | |
591 | /* need to free that, otherwise init highmem will reserve it again */ | |
592 | free_early(ramdisk_image, ramdisk_image+ramdisk_size); | |
cf8fa920 PA |
593 | } |
594 | ||
595 | #endif /* CONFIG_BLK_DEV_INITRD */ | |
596 | ||
1da177e4 LT |
597 | void __init setup_bootmem_allocator(void) |
598 | { | |
7b2a0a6c | 599 | int i; |
a4c81cf6 | 600 | unsigned long bootmap_size, bootmap; |
1da177e4 LT |
601 | /* |
602 | * Initialize the boot-time allocator (with low memory only): | |
603 | */ | |
a4c81cf6 YL |
604 | bootmap_size = bootmem_bootmap_pages(max_low_pfn)<<PAGE_SHIFT; |
605 | bootmap = find_e820_area(min_low_pfn<<PAGE_SHIFT, | |
6af61a76 | 606 | max_pfn_mapped<<PAGE_SHIFT, bootmap_size, |
a4c81cf6 YL |
607 | PAGE_SIZE); |
608 | if (bootmap == -1L) | |
609 | panic("Cannot find bootmem map of size %ld\n", bootmap_size); | |
3945e2c9 | 610 | reserve_early(bootmap, bootmap + bootmap_size, "BOOTMAP"); |
ba5b14cc YL |
611 | #ifdef CONFIG_BLK_DEV_INITRD |
612 | reserve_initrd(); | |
613 | #endif | |
a4c81cf6 | 614 | bootmap_size = init_bootmem(bootmap >> PAGE_SHIFT, max_low_pfn); |
6af61a76 YL |
615 | printk(KERN_INFO " mapped low ram: 0 - %08lx\n", |
616 | max_pfn_mapped<<PAGE_SHIFT); | |
ba5b14cc YL |
617 | printk(KERN_INFO " low ram: %08lx - %08lx\n", |
618 | min_low_pfn<<PAGE_SHIFT, max_low_pfn<<PAGE_SHIFT); | |
3945e2c9 YL |
619 | printk(KERN_INFO " bootmap %08lx - %08lx\n", |
620 | bootmap, bootmap + bootmap_size); | |
7b2a0a6c YL |
621 | for_each_online_node(i) |
622 | free_bootmem_with_active_regions(i, max_low_pfn); | |
a4c81cf6 | 623 | early_res_to_bootmem(0, max_low_pfn<<PAGE_SHIFT); |
1da177e4 | 624 | |
673d5b43 | 625 | #ifdef CONFIG_ACPI_SLEEP |
1da177e4 LT |
626 | /* |
627 | * Reserve low memory region for sleep support. | |
628 | */ | |
629 | acpi_reserve_bootmem(); | |
630 | #endif | |
631 | #ifdef CONFIG_X86_FIND_SMP_CONFIG | |
632 | /* | |
633 | * Find and reserve possible boot-time SMP configuration: | |
634 | */ | |
635 | find_smp_config(); | |
1da177e4 | 636 | #endif |
d62cc471 | 637 | reserve_crashkernel(); |
138fe4e0 KR |
638 | |
639 | reserve_ibft_region(); | |
1da177e4 LT |
640 | } |
641 | ||
642 | /* | |
643 | * The node 0 pgdat is initialized before all of these because | |
644 | * it's needed for bootmem. node>0 pgdats have their virtual | |
645 | * space allocated before the pagetables are in place to access | |
646 | * them, so they can't be cleared then. | |
647 | * | |
648 | * This should all compile down to nothing when NUMA is off. | |
649 | */ | |
10079ae3 | 650 | static void __init remapped_pgdat_init(void) |
1da177e4 LT |
651 | { |
652 | int nid; | |
653 | ||
654 | for_each_online_node(nid) { | |
655 | if (nid != 0) | |
656 | memset(NODE_DATA(nid), 0, sizeof(struct pglist_data)); | |
657 | } | |
658 | } | |
659 | ||
1da177e4 LT |
660 | #ifdef CONFIG_MCA |
661 | static void set_mca_bus(int x) | |
662 | { | |
663 | MCA_bus = x; | |
664 | } | |
665 | #else | |
666 | static void set_mca_bus(int x) { } | |
667 | #endif | |
668 | ||
ccf82085 GOC |
669 | #ifdef CONFIG_NUMA |
670 | /* | |
671 | * In the golden day, when everything among i386 and x86_64 will be | |
672 | * integrated, this will not live here | |
673 | */ | |
674 | void *x86_cpu_to_node_map_early_ptr; | |
675 | int x86_cpu_to_node_map_init[NR_CPUS] = { | |
676 | [0 ... NR_CPUS-1] = NUMA_NO_NODE | |
677 | }; | |
678 | DEFINE_PER_CPU(int, x86_cpu_to_node_map) = NUMA_NO_NODE; | |
679 | #endif | |
680 | ||
41c094fd YL |
681 | static void probe_roms(void); |
682 | ||
1da177e4 LT |
683 | /* |
684 | * Determine if we were loaded by an EFI loader. If so, then we have also been | |
685 | * passed the efi memmap, systab, etc., so we should use these data structures | |
686 | * for initialization. Note, the efi init code path is determined by the | |
687 | * global efi_enabled. This allows the same kernel image to be used on existing | |
688 | * systems (with a traditional BIOS) as well as on EFI systems. | |
689 | */ | |
690 | void __init setup_arch(char **cmdline_p) | |
691 | { | |
41c094fd | 692 | int i; |
1da177e4 LT |
693 | unsigned long max_low_pfn; |
694 | ||
695 | memcpy(&boot_cpu_data, &new_cpu_data, sizeof(new_cpu_data)); | |
696 | pre_setup_arch_hook(); | |
697 | early_cpu_init(); | |
beacfaac | 698 | early_ioremap_init(); |
c45a707d | 699 | reserve_setup_data(); |
1da177e4 | 700 | |
1da177e4 | 701 | #ifdef CONFIG_EFI |
e429795c | 702 | if (!strncmp((char *)&boot_params.efi_info.efi_loader_signature, |
ecacf09f | 703 | "EL32", 4)) { |
1da177e4 | 704 | efi_enabled = 1; |
ecacf09f HY |
705 | efi_reserve_early(); |
706 | } | |
1da177e4 LT |
707 | #endif |
708 | ||
30c82645 PA |
709 | ROOT_DEV = old_decode_dev(boot_params.hdr.root_dev); |
710 | screen_info = boot_params.screen_info; | |
711 | edid_info = boot_params.edid_info; | |
712 | apm_info.bios = boot_params.apm_bios_info; | |
713 | ist_info = boot_params.ist_info; | |
e44b7b75 | 714 | saved_video_mode = boot_params.hdr.vid_mode; |
30c82645 PA |
715 | if( boot_params.sys_desc_table.length != 0 ) { |
716 | set_mca_bus(boot_params.sys_desc_table.table[3] & 0x2); | |
717 | machine_id = boot_params.sys_desc_table.table[0]; | |
718 | machine_submodel_id = boot_params.sys_desc_table.table[1]; | |
719 | BIOS_revision = boot_params.sys_desc_table.table[2]; | |
1da177e4 | 720 | } |
30c82645 | 721 | bootloader_type = boot_params.hdr.type_of_loader; |
1da177e4 LT |
722 | |
723 | #ifdef CONFIG_BLK_DEV_RAM | |
30c82645 PA |
724 | rd_image_start = boot_params.hdr.ram_size & RAMDISK_IMAGE_START_MASK; |
725 | rd_prompt = ((boot_params.hdr.ram_size & RAMDISK_PROMPT_FLAG) != 0); | |
726 | rd_doload = ((boot_params.hdr.ram_size & RAMDISK_LOAD_FLAG) != 0); | |
1da177e4 LT |
727 | #endif |
728 | ARCH_SETUP | |
2215e69d | 729 | |
0dbfafa5 | 730 | setup_memory_map(); |
2215e69d | 731 | |
1da177e4 LT |
732 | copy_edd(); |
733 | ||
30c82645 | 734 | if (!boot_params.hdr.root_flags) |
1da177e4 LT |
735 | root_mountflags &= ~MS_RDONLY; |
736 | init_mm.start_code = (unsigned long) _text; | |
737 | init_mm.end_code = (unsigned long) _etext; | |
738 | init_mm.end_data = (unsigned long) _edata; | |
739 | init_mm.brk = init_pg_tables_end + PAGE_OFFSET; | |
740 | ||
741 | code_resource.start = virt_to_phys(_text); | |
742 | code_resource.end = virt_to_phys(_etext)-1; | |
743 | data_resource.start = virt_to_phys(_etext); | |
744 | data_resource.end = virt_to_phys(_edata)-1; | |
00bf4098 BW |
745 | bss_resource.start = virt_to_phys(&__bss_start); |
746 | bss_resource.end = virt_to_phys(&__bss_stop)-1; | |
1da177e4 | 747 | |
c45a707d HY |
748 | parse_setup_data(); |
749 | ||
1a3f239d | 750 | parse_early_param(); |
1da177e4 | 751 | |
0dbfafa5 | 752 | finish_e820_parsing(); |
1a3f239d | 753 | |
41c094fd YL |
754 | probe_roms(); |
755 | ||
756 | /* after parse_early_param, so could debug it */ | |
757 | insert_resource(&iomem_resource, &code_resource); | |
758 | insert_resource(&iomem_resource, &data_resource); | |
759 | insert_resource(&iomem_resource, &bss_resource); | |
760 | ||
4e498b66 | 761 | strlcpy(command_line, boot_command_line, COMMAND_LINE_SIZE); |
1a3f239d | 762 | *cmdline_p = command_line; |
99b7de33 | 763 | |
8b2cb7a8 HY |
764 | if (efi_enabled) |
765 | efi_init(); | |
766 | ||
7b2a0a6c YL |
767 | e820_register_active_regions(0, 0, -1UL); |
768 | /* | |
769 | * partially used pages are not usable - thus | |
770 | * we are rounding upwards: | |
771 | */ | |
772 | max_pfn = e820_end_of_ram(); | |
773 | ||
6780711e YL |
774 | /* preallocate 4k for mptable mpc */ |
775 | early_reserve_e820_mpc_new(); | |
093af8d7 YL |
776 | /* update e820 for memory not covered by WB MTRRs */ |
777 | mtrr_bp_init(); | |
7b2a0a6c YL |
778 | if (mtrr_trim_uncached_memory(max_pfn)) { |
779 | remove_all_active_ranges(); | |
780 | e820_register_active_regions(0, 0, -1UL); | |
781 | max_pfn = e820_end_of_ram(); | |
782 | } | |
76c32418 YL |
783 | |
784 | max_low_pfn = setup_memory(); | |
093af8d7 | 785 | |
790c73f6 GOC |
786 | #ifdef CONFIG_KVM_CLOCK |
787 | kvmclock_init(); | |
788 | #endif | |
789 | ||
7ce0bcfd ZA |
790 | #ifdef CONFIG_VMI |
791 | /* | |
792 | * Must be after max_low_pfn is determined, and before kernel | |
793 | * pagetables are setup. | |
794 | */ | |
795 | vmi_init(); | |
796 | #endif | |
0cf1bfd2 | 797 | kvm_guest_init(); |
7ce0bcfd | 798 | |
1da177e4 LT |
799 | /* |
800 | * NOTE: before this point _nobody_ is allowed to allocate | |
801 | * any memory using the bootmem allocator. Although the | |
27b46d76 | 802 | * allocator is now initialised only the first 8Mb of the kernel |
1da177e4 LT |
803 | * virtual address space has been mapped. All allocations before |
804 | * paging_init() has completed must use the alloc_bootmem_low_pages() | |
805 | * variant (which allocates DMA'able memory) and care must be taken | |
806 | * not to exceed the 8Mb limit. | |
807 | */ | |
808 | ||
1da177e4 | 809 | paging_init(); |
f212ec4b BK |
810 | |
811 | /* | |
812 | * NOTE: On x86-32, only from this point on, fixmaps are ready for use. | |
813 | */ | |
814 | ||
815 | #ifdef CONFIG_PROVIDE_OHCI1394_DMA_INIT | |
816 | if (init_ohci1394_dma_early) | |
817 | init_ohci1394_dma_on_all_controllers(); | |
818 | #endif | |
819 | ||
1da177e4 LT |
820 | /* |
821 | * NOTE: at this point the bootmem allocator is fully available. | |
822 | */ | |
823 | ||
cf8fa920 PA |
824 | #ifdef CONFIG_BLK_DEV_INITRD |
825 | relocate_initrd(); | |
826 | #endif | |
827 | ||
9a27f5c5 YL |
828 | remapped_pgdat_init(); |
829 | sparse_init(); | |
830 | zone_sizes_init(); | |
831 | ||
6996d3b6 JF |
832 | paravirt_post_allocator_init(); |
833 | ||
1da177e4 LT |
834 | dmi_scan_machine(); |
835 | ||
cf8fa920 | 836 | io_delay_init(); |
b02aae9c | 837 | |
ccf82085 GOC |
838 | #ifdef CONFIG_X86_SMP |
839 | /* | |
840 | * setup to use the early static init tables during kernel startup | |
841 | * X86_SMP will exclude sub-arches that don't deal well with it. | |
842 | */ | |
843 | x86_cpu_to_apicid_early_ptr = (void *)x86_cpu_to_apicid_init; | |
844 | x86_bios_cpu_apicid_early_ptr = (void *)x86_bios_cpu_apicid_init; | |
845 | #ifdef CONFIG_NUMA | |
846 | x86_cpu_to_node_map_early_ptr = (void *)x86_cpu_to_node_map_init; | |
847 | #endif | |
848 | #endif | |
849 | ||
1da177e4 | 850 | #ifdef CONFIG_X86_GENERICARCH |
1a3f239d | 851 | generic_apic_probe(); |
cf8fa920 | 852 | #endif |
1da177e4 | 853 | |
888ba6c6 | 854 | #ifdef CONFIG_ACPI |
1da177e4 LT |
855 | /* |
856 | * Parse the ACPI tables for possible boot-time SMP configuration. | |
857 | */ | |
858 | acpi_boot_table_init(); | |
d44647b0 AC |
859 | #endif |
860 | ||
54ef3400 | 861 | early_quirks(); |
d44647b0 AC |
862 | |
863 | #ifdef CONFIG_ACPI | |
1da177e4 | 864 | acpi_boot_init(); |
e0da3364 YL |
865 | #endif |
866 | #if defined(CONFIG_X86_MPPARSE) || defined(CONFIG_X86_VISWS) | |
867 | if (smp_found_config) | |
868 | get_smp_config(); | |
869 | #endif | |
911a62d4 VP |
870 | #if defined(CONFIG_SMP) && defined(CONFIG_X86_PC) |
871 | if (def_to_bigsmp) | |
872 | printk(KERN_WARNING "More than 8 CPUs detected and " | |
873 | "CONFIG_X86_PC cannot handle it.\nUse " | |
874 | "CONFIG_X86_GENERICARCH or CONFIG_X86_BIGSMP.\n"); | |
875 | #endif | |
1da177e4 | 876 | |
41c094fd | 877 | e820_reserve_resources(); |
bf62f398 | 878 | e820_mark_nosave_regions(max_low_pfn); |
1da177e4 | 879 | |
41c094fd YL |
880 | request_resource(&iomem_resource, &video_ram_resource); |
881 | /* request I/O space for devices used on all i[345]86 PCs */ | |
882 | for (i = 0; i < ARRAY_SIZE(standard_io_resources); i++) | |
883 | request_resource(&ioport_resource, &standard_io_resources[i]); | |
884 | ||
885 | e820_setup_gap(); | |
886 | ||
1da177e4 LT |
887 | #ifdef CONFIG_VT |
888 | #if defined(CONFIG_VGA_CONSOLE) | |
889 | if (!efi_enabled || (efi_mem_type(0xa0000) != EFI_CONVENTIONAL_MEMORY)) | |
890 | conswitchp = &vga_con; | |
891 | #elif defined(CONFIG_DUMMY_CONSOLE) | |
892 | conswitchp = &dummy_con; | |
893 | #endif | |
894 | #endif | |
895 | } | |
c9cce83d | 896 | |
41c094fd YL |
897 | static struct resource system_rom_resource = { |
898 | .name = "System ROM", | |
899 | .start = 0xf0000, | |
900 | .end = 0xfffff, | |
901 | .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM | |
902 | }; | |
903 | ||
904 | static struct resource extension_rom_resource = { | |
905 | .name = "Extension ROM", | |
906 | .start = 0xe0000, | |
907 | .end = 0xeffff, | |
908 | .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM | |
909 | }; | |
910 | ||
911 | static struct resource adapter_rom_resources[] = { { | |
912 | .name = "Adapter ROM", | |
913 | .start = 0xc8000, | |
914 | .end = 0, | |
915 | .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM | |
916 | }, { | |
917 | .name = "Adapter ROM", | |
918 | .start = 0, | |
919 | .end = 0, | |
920 | .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM | |
921 | }, { | |
922 | .name = "Adapter ROM", | |
923 | .start = 0, | |
924 | .end = 0, | |
925 | .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM | |
926 | }, { | |
927 | .name = "Adapter ROM", | |
928 | .start = 0, | |
929 | .end = 0, | |
930 | .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM | |
931 | }, { | |
932 | .name = "Adapter ROM", | |
933 | .start = 0, | |
934 | .end = 0, | |
935 | .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM | |
936 | }, { | |
937 | .name = "Adapter ROM", | |
938 | .start = 0, | |
939 | .end = 0, | |
940 | .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM | |
941 | } }; | |
942 | ||
943 | static struct resource video_rom_resource = { | |
944 | .name = "Video ROM", | |
945 | .start = 0xc0000, | |
946 | .end = 0xc7fff, | |
947 | .flags = IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM | |
948 | }; | |
949 | ||
950 | #define ROMSIGNATURE 0xaa55 | |
951 | ||
952 | static int __init romsignature(const unsigned char *rom) | |
953 | { | |
954 | const unsigned short * const ptr = (const unsigned short *)rom; | |
955 | unsigned short sig; | |
956 | ||
957 | return probe_kernel_address(ptr, sig) == 0 && sig == ROMSIGNATURE; | |
958 | } | |
959 | ||
960 | static int __init romchecksum(const unsigned char *rom, unsigned long length) | |
961 | { | |
962 | unsigned char sum, c; | |
963 | ||
964 | for (sum = 0; length && probe_kernel_address(rom++, c) == 0; length--) | |
965 | sum += c; | |
966 | return !length && !sum; | |
967 | } | |
968 | ||
969 | static void __init probe_roms(void) | |
c9cce83d | 970 | { |
41c094fd YL |
971 | const unsigned char *rom; |
972 | unsigned long start, length, upper; | |
973 | unsigned char c; | |
c9cce83d BW |
974 | int i; |
975 | ||
41c094fd YL |
976 | /* video rom */ |
977 | upper = adapter_rom_resources[0].start; | |
978 | for (start = video_rom_resource.start; start < upper; start += 2048) { | |
979 | rom = isa_bus_to_virt(start); | |
980 | if (!romsignature(rom)) | |
981 | continue; | |
c9cce83d | 982 | |
41c094fd | 983 | video_rom_resource.start = start; |
c9cce83d | 984 | |
41c094fd YL |
985 | if (probe_kernel_address(rom + 2, c) != 0) |
986 | continue; | |
987 | ||
988 | /* 0 < length <= 0x7f * 512, historically */ | |
989 | length = c * 512; | |
990 | ||
991 | /* if checksum okay, trust length byte */ | |
992 | if (length && romchecksum(rom, length)) | |
993 | video_rom_resource.end = start + length - 1; | |
994 | ||
995 | request_resource(&iomem_resource, &video_rom_resource); | |
996 | break; | |
997 | } | |
998 | ||
999 | start = (video_rom_resource.end + 1 + 2047) & ~2047UL; | |
1000 | if (start < upper) | |
1001 | start = upper; | |
1002 | ||
1003 | /* system rom */ | |
1004 | request_resource(&iomem_resource, &system_rom_resource); | |
1005 | upper = system_rom_resource.start; | |
1006 | ||
1007 | /* check for extension rom (ignore length byte!) */ | |
1008 | rom = isa_bus_to_virt(extension_rom_resource.start); | |
1009 | if (romsignature(rom)) { | |
1010 | length = extension_rom_resource.end - extension_rom_resource.start + 1; | |
1011 | if (romchecksum(rom, length)) { | |
1012 | request_resource(&iomem_resource, &extension_rom_resource); | |
1013 | upper = extension_rom_resource.start; | |
1014 | } | |
1015 | } | |
1016 | ||
1017 | /* check for adapter roms on 2k boundaries */ | |
1018 | for (i = 0; i < ARRAY_SIZE(adapter_rom_resources) && start < upper; start += 2048) { | |
1019 | rom = isa_bus_to_virt(start); | |
1020 | if (!romsignature(rom)) | |
1021 | continue; | |
1022 | ||
1023 | if (probe_kernel_address(rom + 2, c) != 0) | |
1024 | continue; | |
1025 | ||
1026 | /* 0 < length <= 0x7f * 512, historically */ | |
1027 | length = c * 512; | |
1028 | ||
1029 | /* but accept any length that fits if checksum okay */ | |
1030 | if (!length || start + length > upper || !romchecksum(rom, length)) | |
1031 | continue; | |
1032 | ||
1033 | adapter_rom_resources[i].start = start; | |
1034 | adapter_rom_resources[i].end = start + length - 1; | |
1035 | request_resource(&iomem_resource, &adapter_rom_resources[i]); | |
1036 | ||
1037 | start = adapter_rom_resources[i++].end & ~2047UL; | |
1038 | } | |
c9cce83d BW |
1039 | } |
1040 |