head.c 1.8 KB

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