bios_ebda.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #ifndef _ASM_X86_BIOS_EBDA_H
  2. #define _ASM_X86_BIOS_EBDA_H
  3. #include <asm/io.h>
  4. /*
  5. * Returns physical address of EBDA. Returns 0 if there is no EBDA.
  6. */
  7. static inline unsigned int get_bios_ebda(void)
  8. {
  9. /*
  10. * There is a real-mode segmented pointer pointing to the
  11. * 4K EBDA area at 0x40E.
  12. */
  13. unsigned int address = *(unsigned short *)phys_to_virt(0x40E);
  14. address <<= 4;
  15. return address; /* 0 means none */
  16. }
  17. /*
  18. * Return the sanitized length of the EBDA in bytes, if it exists.
  19. */
  20. static inline unsigned int get_bios_ebda_length(void)
  21. {
  22. unsigned int address;
  23. unsigned int length;
  24. address = get_bios_ebda();
  25. if (!address)
  26. return 0;
  27. /* EBDA length is byte 0 of the EBDA (stored in KiB) */
  28. length = *(unsigned char *)phys_to_virt(address);
  29. length <<= 10;
  30. /* Trim the length if it extends beyond 640KiB */
  31. length = min_t(unsigned int, (640 * 1024) - address, length);
  32. return length;
  33. }
  34. void reserve_ebda_region(void);
  35. #ifdef CONFIG_X86_CHECK_BIOS_CORRUPTION
  36. /*
  37. * This is obviously not a great place for this, but we want to be
  38. * able to scatter it around anywhere in the kernel.
  39. */
  40. void check_for_bios_corruption(void);
  41. void start_periodic_check_for_corruption(void);
  42. #else
  43. static inline void check_for_bios_corruption(void)
  44. {
  45. }
  46. static inline void start_periodic_check_for_corruption(void)
  47. {
  48. }
  49. #endif
  50. #endif /* _ASM_X86_BIOS_EBDA_H */