aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/mm/ioremap_32.c
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2008-01-30 07:33:45 -0500
committerIngo Molnar <mingo@elte.hu>2008-01-30 07:33:45 -0500
commit1b42f51630c7eebce6fb780b480731eb81afd325 (patch)
tree24505feab89996a27393947d014894b4abe7c271 /arch/x86/mm/ioremap_32.c
parent64a8f852a20e90bf3018d3ace5b7f514f39db4cd (diff)
x86: enhance early_ioremap()
- allow nesting of up to 4 levels Signed-off-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'arch/x86/mm/ioremap_32.c')
-rw-r--r--arch/x86/mm/ioremap_32.c36
1 files changed, 26 insertions, 10 deletions
diff --git a/arch/x86/mm/ioremap_32.c b/arch/x86/mm/ioremap_32.c
index bfd7b8b2fe60..63f76ecae44c 100644
--- a/arch/x86/mm/ioremap_32.c
+++ b/arch/x86/mm/ioremap_32.c
@@ -291,23 +291,28 @@ static inline void __init early_clear_fixmap(enum fixed_addresses idx)
291 __early_set_fixmap(idx, 0, __pgprot(0)); 291 __early_set_fixmap(idx, 0, __pgprot(0));
292} 292}
293 293
294
295int __initdata early_ioremap_nested;
296
294void __init *early_ioremap(unsigned long phys_addr, unsigned long size) 297void __init *early_ioremap(unsigned long phys_addr, unsigned long size)
295{ 298{
296 unsigned long offset, last_addr; 299 unsigned long offset, last_addr;
297 unsigned int nrpages; 300 unsigned int nrpages, nesting;
298 enum fixed_addresses idx; 301 enum fixed_addresses idx0, idx;
302
303 WARN_ON(system_state != SYSTEM_BOOTING);
304
305 nesting = early_ioremap_nested;
299 306
300 /* Don't allow wraparound or zero size */ 307 /* Don't allow wraparound or zero size */
301 last_addr = phys_addr + size - 1; 308 last_addr = phys_addr + size - 1;
302 if (!size || last_addr < phys_addr) 309 if (!size || last_addr < phys_addr)
303 return NULL; 310 return NULL;
304 311
305 /* 312 if (nesting >= FIX_BTMAPS_NESTING)
306 * Don't remap the low PCI/ISA area, it's always mapped.. 313 return NULL;
307 */
308 if (phys_addr >= ISA_START_ADDRESS && last_addr < ISA_END_ADDRESS)
309 return phys_to_virt(phys_addr);
310 314
315 early_ioremap_nested++;
311 /* 316 /*
312 * Mappings have to be page-aligned 317 * Mappings have to be page-aligned
313 */ 318 */
@@ -325,14 +330,16 @@ void __init *early_ioremap(unsigned long phys_addr, unsigned long size)
325 /* 330 /*
326 * Ok, go for it.. 331 * Ok, go for it..
327 */ 332 */
328 idx = FIX_BTMAP_BEGIN; 333 idx0 = FIX_BTMAP_BEGIN - NR_FIX_BTMAPS*nesting;
334 idx = idx0;
329 while (nrpages > 0) { 335 while (nrpages > 0) {
330 early_set_fixmap(idx, phys_addr); 336 early_set_fixmap(idx, phys_addr);
331 phys_addr += PAGE_SIZE; 337 phys_addr += PAGE_SIZE;
332 --idx; 338 --idx;
333 --nrpages; 339 --nrpages;
334 } 340 }
335 return (void*) (offset + fix_to_virt(FIX_BTMAP_BEGIN)); 341
342 return (void*) (offset + fix_to_virt(idx0));
336} 343}
337 344
338void __init early_iounmap(void *addr, unsigned long size) 345void __init early_iounmap(void *addr, unsigned long size)
@@ -341,17 +348,26 @@ void __init early_iounmap(void *addr, unsigned long size)
341 unsigned long offset; 348 unsigned long offset;
342 unsigned int nrpages; 349 unsigned int nrpages;
343 enum fixed_addresses idx; 350 enum fixed_addresses idx;
351 unsigned int nesting;
352
353 nesting = --early_ioremap_nested;
344 354
345 virt_addr = (unsigned long)addr; 355 virt_addr = (unsigned long)addr;
346 if (virt_addr < fix_to_virt(FIX_BTMAP_BEGIN)) 356 if (virt_addr < fix_to_virt(FIX_BTMAP_BEGIN))
347 return; 357 return;
358
348 offset = virt_addr & ~PAGE_MASK; 359 offset = virt_addr & ~PAGE_MASK;
349 nrpages = PAGE_ALIGN(offset + size - 1) >> PAGE_SHIFT; 360 nrpages = PAGE_ALIGN(offset + size - 1) >> PAGE_SHIFT;
350 361
351 idx = FIX_BTMAP_BEGIN; 362 idx = FIX_BTMAP_BEGIN - NR_FIX_BTMAPS*nesting;
352 while (nrpages > 0) { 363 while (nrpages > 0) {
353 early_clear_fixmap(idx); 364 early_clear_fixmap(idx);
354 --idx; 365 --idx;
355 --nrpages; 366 --nrpages;
356 } 367 }
357} 368}
369
370void __this_fixmap_does_not_exist(void)
371{
372 WARN_ON(1);
373}