libacpi.h 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * Copyright (c) 2018, Intel Corporation
  3. * All rights reserved.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions
  7. * are met:
  8. *
  9. * * Redistributions of source code must retain the above copyright
  10. * notice, this list of conditions and the following disclaimer.
  11. * * Redistributions in binary form must reproduce the above copyright
  12. * notice, this list of conditions and the following disclaimer
  13. * in the documentation and/or other materials provided with the
  14. * distribution.
  15. *
  16. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  17. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  18. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  19. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  20. * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  21. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  22. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  23. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  24. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  25. * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  26. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
  27. * OF THE POSSIBILITY OF SUCH DAMAGE.
  28. *
  29. */
  30. #ifndef _LIBACPI_H
  31. #define _LIBACPI_H
  32. #include "libfdt.h"
  33. #pragma pack(1)
  34. typedef struct {
  35. uint32_t Signature; /* ASCII Table identifier */
  36. uint32_t Length; /* Length of the table, including the header */
  37. uint8_t Revision; /* Revision of the structure */
  38. uint8_t Checksum; /* Sum of all fields must be 0 */
  39. uint8_t OemId[6]; /* ASCII OEM identifier */
  40. uint64_t OemTableId; /* ASCII OEM table identifier */
  41. uint32_t OemRevision; /* OEM supplied revision number */
  42. uint32_t CreatorId; /* Vendor ID of utility creator of the table */
  43. uint32_t CreatorRevision; /* Revision of utility creator of the table */
  44. } EFI_ACPI_DESCRIPTION_HEADER;
  45. #pragma pack()
  46. /**********************************************************************/
  47. /* General functions */
  48. /**********************************************************************/
  49. #define acpi_get_header(acpi, field) \
  50. ((const EFI_ACPI_DESCRIPTION_HEADER *)(acpi))->field
  51. #define acpi_signature(acpi) (acpi_get_header(acpi, Signature))
  52. #define acpi_length(acpi) (acpi_get_header(acpi, Length))
  53. /* convert 2 bytes ASCII to uint16 */
  54. #define SIGNATURE_16(A, B) ((A) | (B << 8))
  55. /* convert 4 bytes ASCII to uint32 */
  56. #define SIGNATURE_32(A, B, C, D) ((SIGNATURE_16 (A, B)) | (SIGNATURE_16 (C, D) << 16))
  57. /* convert 8 bytes ASCII to uint64 */
  58. #define SIGNATURE_64(A, B, C, D, E, F, G, H) \
  59. (SIGNATURE_32 (A, B, C, D) | ((UINT64) (SIGNATURE_32 (E, F, G, H)) << 32))
  60. #define SSDT_MAGIC (const unsigned)SIGNATURE_32('S', 'S', 'D', 'T')
  61. #define DSDT_MAGIC (const unsigned)SIGNATURE_32('D', 'S', 'D', 'T')
  62. #define ACPI_TABLE_MAGIC 0x41435049
  63. /* checksum byte by byte for acpi table */
  64. uint8_t acpi_csum(const void *base, int n);
  65. #endif /* ifndef _LIBACPI_H */