You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

acpi.h 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. #ifndef _IPXE_ACPI_H
  2. #define _IPXE_ACPI_H
  3. /** @file
  4. *
  5. * ACPI data structures
  6. *
  7. */
  8. FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
  9. #include <stdint.h>
  10. #include <ipxe/interface.h>
  11. #include <ipxe/uaccess.h>
  12. /**
  13. * An ACPI description header
  14. *
  15. * This is the structure common to the start of all ACPI system
  16. * description tables.
  17. */
  18. struct acpi_description_header {
  19. /** ACPI signature (4 ASCII characters) */
  20. uint32_t signature;
  21. /** Length of table, in bytes, including header */
  22. uint32_t length;
  23. /** ACPI Specification minor version number */
  24. uint8_t revision;
  25. /** To make sum of entire table == 0 */
  26. uint8_t checksum;
  27. /** OEM identification */
  28. char oem_id[6];
  29. /** OEM table identification */
  30. char oem_table_id[8];
  31. /** OEM revision number */
  32. uint32_t oem_revision;
  33. /** ASL compiler vendor ID */
  34. char asl_compiler_id[4];
  35. /** ASL compiler revision number */
  36. uint32_t asl_compiler_revision;
  37. } __attribute__ (( packed ));
  38. /**
  39. * Build ACPI signature
  40. *
  41. * @v a First character of ACPI signature
  42. * @v b Second character of ACPI signature
  43. * @v c Third character of ACPI signature
  44. * @v d Fourth character of ACPI signature
  45. * @ret signature ACPI signature
  46. */
  47. #define ACPI_SIGNATURE( a, b, c, d ) \
  48. ( ( (a) << 0 ) | ( (b) << 8 ) | ( (c) << 16 ) | ( (d) << 24 ) )
  49. /** Root System Description Pointer signature */
  50. #define RSDP_SIGNATURE { 'R', 'S', 'D', ' ', 'P', 'T', 'R', ' ' }
  51. /** Root System Description Pointer */
  52. struct acpi_rsdp {
  53. /** Signature */
  54. char signature[8];
  55. /** To make sum of entire table == 0 */
  56. uint8_t checksum;
  57. /** OEM identification */
  58. char oem_id[6];
  59. /** Revision */
  60. uint8_t revision;
  61. /** Physical address of RSDT */
  62. uint32_t rsdt;
  63. } __attribute__ (( packed ));
  64. /** EBDA RSDP length */
  65. #define RSDP_EBDA_LEN 0x400
  66. /** Fixed BIOS area RSDP start address */
  67. #define RSDP_BIOS_START 0xe0000
  68. /** Fixed BIOS area RSDP length */
  69. #define RSDP_BIOS_LEN 0x20000
  70. /** Stride at which to search for RSDP */
  71. #define RSDP_STRIDE 16
  72. /** Root System Description Table (RSDT) signature */
  73. #define RSDT_SIGNATURE ACPI_SIGNATURE ( 'R', 'S', 'D', 'T' )
  74. /** ACPI Root System Description Table (RSDT) */
  75. struct acpi_rsdt {
  76. /** ACPI header */
  77. struct acpi_description_header acpi;
  78. /** ACPI table entries */
  79. uint32_t entry[0];
  80. } __attribute__ (( packed ));
  81. /** Fixed ACPI Description Table (FADT) signature */
  82. #define FADT_SIGNATURE ACPI_SIGNATURE ( 'F', 'A', 'C', 'P' )
  83. /** Fixed ACPI Description Table (FADT) */
  84. struct acpi_fadt {
  85. /** ACPI header */
  86. struct acpi_description_header acpi;
  87. /** Physical address of FACS */
  88. uint32_t facs;
  89. /** Physical address of DSDT */
  90. uint32_t dsdt;
  91. /** Unused by iPXE */
  92. uint8_t unused[20];
  93. /** PM1a Control Register Block */
  94. uint32_t pm1a_cnt_blk;
  95. /** PM1b Control Register Block */
  96. uint32_t pm1b_cnt_blk;
  97. } __attribute__ (( packed ));
  98. /** ACPI PM1 Control Register (within PM1a_CNT_BLK or PM1A_CNT_BLK) */
  99. #define ACPI_PM1_CNT 0
  100. #define ACPI_PM1_CNT_SLP_TYP(x) ( (x) << 10 ) /**< Sleep type */
  101. #define ACPI_PM1_CNT_SLP_EN ( 1 << 13 ) /**< Sleep enable */
  102. /** Differentiated System Description Table (DSDT) signature */
  103. #define DSDT_SIGNATURE ACPI_SIGNATURE ( 'D', 'S', 'D', 'T' )
  104. /** Secondary System Description Table (SSDT) signature */
  105. #define SSDT_SIGNATURE ACPI_SIGNATURE ( 'S', 'S', 'D', 'T' )
  106. extern int acpi_describe ( struct interface *interface,
  107. struct acpi_description_header *acpi, size_t len );
  108. #define acpi_describe_TYPE( object_type ) \
  109. typeof ( int ( object_type, \
  110. struct acpi_description_header *acpi, \
  111. size_t len ) )
  112. extern void acpi_fix_checksum ( struct acpi_description_header *acpi );
  113. extern userptr_t acpi_find_rsdt ( userptr_t ebda );
  114. extern userptr_t acpi_find ( userptr_t rsdt, uint32_t signature,
  115. unsigned int index );
  116. extern int acpi_sx ( userptr_t rsdt, uint32_t signature );
  117. #endif /* _IPXE_ACPI_H */