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 31 #ifndef _LIBACPI_H 32 #define _LIBACPI_H 33 34 #include "libfdt.h" 35 36 #pragma pack(1) 37 typedef struct { 38 uint32_t Signature; /* ASCII Table identifier */ 39 uint32_t Length; /* Length of the table, including the header */ 40 uint8_t Revision; /* Revision of the structure */ 41 uint8_t Checksum; /* Sum of all fields must be 0 */ 42 uint8_t OemId[6]; /* ASCII OEM identifier */ 43 uint64_t OemTableId; /* ASCII OEM table identifier */ 44 uint32_t OemRevision; /* OEM supplied revision number */ 45 uint32_t CreatorId; /* Vendor ID of utility creator of the table */ 46 uint32_t CreatorRevision; /* Revision of utility creator of the table */ 47 } EFI_ACPI_DESCRIPTION_HEADER; 48 #pragma pack() 49 50 /**********************************************************************/ 51 /* General functions */ 52 /**********************************************************************/ 53 #define acpi_get_header(acpi, field) \ 54 ((const EFI_ACPI_DESCRIPTION_HEADER *)(acpi))->field 55 #define acpi_signature(acpi) (acpi_get_header(acpi, Signature)) 56 #define acpi_length(acpi) (acpi_get_header(acpi, Length)) 57 58 /* convert 2 bytes ASCII to uint16 */ 59 #define SIGNATURE_16(A, B) ((A) | (B << 8)) 60 /* convert 4 bytes ASCII to uint32 */ 61 #define SIGNATURE_32(A, B, C, D) ((SIGNATURE_16 (A, B)) | (SIGNATURE_16 (C, D) << 16)) 62 /* convert 8 bytes ASCII to uint64 */ 63 #define SIGNATURE_64(A, B, C, D, E, F, G, H) \ 64 (SIGNATURE_32 (A, B, C, D) | ((UINT64) (SIGNATURE_32 (E, F, G, H)) << 32)) 65 66 #define SSDT_MAGIC (const unsigned)SIGNATURE_32('S', 'S', 'D', 'T') 67 #define DSDT_MAGIC (const unsigned)SIGNATURE_32('D', 'S', 'D', 'T') 68 69 #define ACPI_TABLE_MAGIC 0x41435049 70 71 /* checksum byte by byte for acpi table */ 72 uint8_t acpi_csum(const void *base, int n); 73 74 #endif /* ifndef _LIBACPI_H */ 75