94589f35b8e03b7ed19080fba6d7c938f39f0706
[external/syslinux.git] / com32 / gplinclude / acpi / acpi.h
1 /* ----------------------------------------------------------------------- *
2  *
3  *   Copyright 2009-2011 Erwan Velu - All Rights Reserved
4  *
5  *   This program is free software; you can redistribute it and/or modify
6  *   it under the terms of the GNU General Public License as published by
7  *   the Free Software Foundation, Inc., 53 Temple Place Ste 330,
8  *   Boston MA 02111-1307, USA; either version 2 of the License, or
9  *   (at your option) any later version; incorporated herein by reference.
10  *
11  * ----------------------------------------------------------------------- */
12
13 #ifndef ACPI_H
14 #define ACPI_H
15
16 #define DEBUG_ACPI 0
17
18 void dbg_printf(const char *fmt, ...);
19 #define DEBUG_PRINT(x) do { if (DEBUG_ACPI) dbg_printf x; } while (0)
20
21 #include <inttypes.h>
22 #include <stdbool.h>
23 #include <acpi/structs.h>
24 #include <acpi/rsdp.h>
25 #include <acpi/rsdt.h>
26 #include <acpi/xsdt.h>
27 #include <acpi/fadt.h>
28 #include <acpi/madt.h>
29 #include <acpi/dsdt.h>
30 #include <acpi/ssdt.h>
31 #include <acpi/sbst.h>
32 #include <acpi/ecdt.h>
33 #include <acpi/facs.h>
34 #include <acpi/hpet.h>
35 #include <acpi/tcpa.h>
36 #include <acpi/mcfg.h>
37 #include <acpi/slic.h>
38 #include <acpi/boot.h>
39
40 enum { ACPI_FOUND = 1, ENO_ACPI = 2 , MADT_FOUND = 3 , ENO_MADT = 4 };
41
42 #define MAX_SSDT 128
43
44 /* Some other description HEADERS : ACPI doc: 5.2.6*/
45 #define OEMX "OEMx"
46 #define SRAR "SRAT"
47 #define BERT "BERT"
48 #define BOOT "BOOT"
49 #define CPEP "CPEP"
50 #define DBGP "DGBP"
51 #define DMAR "DMAR"
52 #define ERST "ERST"
53 #define ETDT "ETDT"
54 #define HEST "HEST"
55 #define HPET "HPET"
56 #define IBFT "IBFT"
57 #define MCFG "MCFG"
58 #define SPCR "SPCR"
59 #define SPMI "SPMI"
60 #define TCPA "TCPA"
61 #define UEFI "UEFI"
62 #define WAET "WAET"
63 #define WDAT "WDAT"
64 #define WDRT "WDRT"
65 #define WSPT "WSPT"
66 #define SLIC "SLIC"
67
68 /* This macro are used to extract ACPI structures 
69  * please be careful about the q (interator) naming */
70 #define cp_struct(dest) memcpy(dest,q,sizeof(*dest)); q+=sizeof(*dest)
71 #define cp_str_struct(dest) memcpy(dest,q,sizeof(dest)-1); dest[sizeof(dest)-1]=0;q+=sizeof(dest)-1
72
73 typedef struct {
74     s_rsdp rsdp;
75     s_rsdt rsdt;
76     s_xsdt xsdt;
77     s_fadt fadt;
78     s_madt madt;
79     s_dsdt dsdt;
80     s_ssdt *ssdt[MAX_SSDT];
81     uint8_t ssdt_count;
82     s_sbst sbst;
83     s_ecdt ecdt;
84     s_facs facs;
85     s_hpet hpet;
86     s_tcpa tcpa;
87     s_mcfg mcfg;
88     s_slic slic;
89     s_boot boot;
90 } s_acpi;
91
92 int parse_acpi(s_acpi * acpi);
93 int parse_xsdt(s_acpi * acpi);
94 void parse_madt(s_acpi * acpi);
95 int search_rsdp(s_acpi *acpi);
96 void get_acpi_description_header(uint8_t *q, s_acpi_description_header * adh);
97 bool parse_header(uint64_t *address, s_acpi *acpi);
98 #endif