head.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #include <linux/kernel.h>
  2. #include <linux/init.h>
  3. #include <linux/memblock.h>
  4. #include <asm/setup.h>
  5. #include <asm/bios_ebda.h>
  6. #define BIOS_LOWMEM_KILOBYTES 0x413
  7. /*
  8. * The BIOS places the EBDA/XBDA at the top of conventional
  9. * memory, and usually decreases the reported amount of
  10. * conventional memory (int 0x12) too. This also contains a
  11. * workaround for Dell systems that neglect to reserve EBDA.
  12. * The same workaround also avoids a problem with the AMD768MPX
  13. * chipset: reserve a page before VGA to prevent PCI prefetch
  14. * into it (errata #56). Usually the page is reserved anyways,
  15. * unless you have no PS/2 mouse plugged in.
  16. */
  17. void __init reserve_ebda_region(void)
  18. {
  19. unsigned int lowmem, ebda_addr;
  20. /* To determine the position of the EBDA and the */
  21. /* end of conventional memory, we need to look at */
  22. /* the BIOS data area. In a paravirtual environment */
  23. /* that area is absent. We'll just have to assume */
  24. /* that the paravirt case can handle memory setup */
  25. /* correctly, without our help. */
  26. if (paravirt_enabled())
  27. return;
  28. /* end of low (conventional) memory */
  29. lowmem = *(unsigned short *)__va(BIOS_LOWMEM_KILOBYTES);
  30. lowmem <<= 10;
  31. /* start of EBDA area */
  32. ebda_addr = get_bios_ebda();
  33. /* Fixup: bios puts an EBDA in the top 64K segment */
  34. /* of conventional memory, but does not adjust lowmem. */
  35. if ((lowmem - ebda_addr) <= 0x10000)
  36. lowmem = ebda_addr;
  37. /* Fixup: bios does not report an EBDA at all. */
  38. /* Some old Dells seem to need 4k anyhow (bugzilla 2990) */
  39. if ((ebda_addr == 0) && (lowmem >= 0x9f000))
  40. lowmem = 0x9f000;
  41. /* Paranoia: should never happen, but... */
  42. if ((lowmem == 0) || (lowmem >= 0x100000))
  43. lowmem = 0x9f000;
  44. /* reserve all memory between lowmem and the 1MB mark */
  45. memblock_x86_reserve_range(lowmem, 0x100000, "* BIOS reserved");
  46. }