head32.c 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * linux/arch/i386/kernel/head32.c -- prepare to run common code
  3. *
  4. * Copyright (C) 2000 Andrea Arcangeli <andrea@suse.de> SuSE
  5. * Copyright (C) 2007 Eric Biederman <ebiederm@xmission.com>
  6. */
  7. #include <linux/init.h>
  8. #include <linux/start_kernel.h>
  9. #include <asm/setup.h>
  10. #include <asm/sections.h>
  11. #include <asm/e820.h>
  12. #include <asm/bios_ebda.h>
  13. #define BIOS_LOWMEM_KILOBYTES 0x413
  14. /*
  15. * The BIOS places the EBDA/XBDA at the top of conventional
  16. * memory, and usually decreases the reported amount of
  17. * conventional memory (int 0x12) too. This also contains a
  18. * workaround for Dell systems that neglect to reserve EBDA.
  19. * The same workaround also avoids a problem with the AMD768MPX
  20. * chipset: reserve a page before VGA to prevent PCI prefetch
  21. * into it (errata #56). Usually the page is reserved anyways,
  22. * unless you have no PS/2 mouse plugged in.
  23. */
  24. static void __init reserve_ebda_region(void)
  25. {
  26. unsigned int lowmem, ebda_addr;
  27. /* To determine the position of the EBDA and the */
  28. /* end of conventional memory, we need to look at */
  29. /* the BIOS data area. In a paravirtual environment */
  30. /* that area is absent. We'll just have to assume */
  31. /* that the paravirt case can handle memory setup */
  32. /* correctly, without our help. */
  33. if (paravirt_enabled())
  34. return;
  35. /* end of low (conventional) memory */
  36. lowmem = *(unsigned short *)__va(BIOS_LOWMEM_KILOBYTES);
  37. lowmem <<= 10;
  38. /* start of EBDA area */
  39. ebda_addr = get_bios_ebda();
  40. /* Fixup: bios puts an EBDA in the top 64K segment */
  41. /* of conventional memory, but does not adjust lowmem. */
  42. if ((lowmem - ebda_addr) <= 0x10000)
  43. lowmem = ebda_addr;
  44. /* Fixup: bios does not report an EBDA at all. */
  45. /* Some old Dells seem to need 4k anyhow (bugzilla 2990) */
  46. if ((ebda_addr == 0) && (lowmem >= 0x9f000))
  47. lowmem = 0x9f000;
  48. /* Paranoia: should never happen, but... */
  49. if ((lowmem == 0) || (lowmem >= 0x100000))
  50. lowmem = 0x9f000;
  51. /* reserve all memory between lowmem and the 1MB mark */
  52. reserve_early(lowmem, 0x100000, "BIOS reserved");
  53. }
  54. void __init i386_start_kernel(void)
  55. {
  56. reserve_early(__pa_symbol(&_text), __pa_symbol(&_end), "TEXT DATA BSS");
  57. #ifdef CONFIG_BLK_DEV_INITRD
  58. /* Reserve INITRD */
  59. if (boot_params.hdr.type_of_loader && boot_params.hdr.ramdisk_image) {
  60. u64 ramdisk_image = boot_params.hdr.ramdisk_image;
  61. u64 ramdisk_size = boot_params.hdr.ramdisk_size;
  62. u64 ramdisk_end = ramdisk_image + ramdisk_size;
  63. reserve_early(ramdisk_image, ramdisk_end, "RAMDISK");
  64. }
  65. #endif
  66. reserve_early(init_pg_tables_start, init_pg_tables_end,
  67. "INIT_PG_TABLE");
  68. reserve_ebda_region();
  69. /*
  70. * At this point everything still needed from the boot loader
  71. * or BIOS or kernel text should be early reserved or marked not
  72. * RAM in e820. All other memory is free game.
  73. */
  74. start_kernel();
  75. }