source: trunk/hal/x86_64/core/hal_acpi.h @ 217

Last change on this file since 217 was 145, checked in by max@…, 7 years ago

style

File size: 7.8 KB
Line 
1/*
2 * hal_acpi.h - ACPI-specific values and structures
3 *
4 * Copyright (c) 2017 Maxime Villard
5 * Inspired by ACPICA.
6 *
7 * This file is part of ALMOS-MKH.
8 *
9 * ALMOS-MKH is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; version 2.0 of the License.
12 *
13 * ALMOS-MKH is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with ALMOS-MKH.; if not, write to the Free Software Foundation,
20 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
23/*
24 * Copyright (C) 2000 - 2017, Intel Corp.
25 * All rights reserved.
26 *
27 * Redistribution and use in source and binary forms, with or without
28 * modification, are permitted provided that the following conditions
29 * are met:
30 * 1. Redistributions of source code must retain the above copyright
31 *    notice, this list of conditions, and the following disclaimer,
32 *    without modification.
33 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
34 *    substantially similar to the "NO WARRANTY" disclaimer below
35 *    ("Disclaimer") and any redistribution must be conditioned upon
36 *    including a substantially similar Disclaimer requirement for further
37 *    binary redistribution.
38 * 3. Neither the names of the above-listed copyright holders nor the names
39 *    of any contributors may be used to endorse or promote products derived
40 *    from this software without specific prior written permission.
41 *
42 * Alternatively, this software may be distributed under the terms of the
43 * GNU General Public License ("GPL") version 2 as published by the Free
44 * Software Foundation.
45 *
46 * NO WARRANTY
47 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
48 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
49 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
50 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
51 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
52 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
53 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
54 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
55 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
56 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
57 * POSSIBILITY OF SUCH DAMAGES.
58 */
59
60void hal_acpi_init();
61
62#define ACPI_RSDP_ALIGN 16
63#define ACPI_RSDP_SIGNATURE     "RSD PTR "
64#define ACPI_RSDP_SIGNATURE_SIZE        8
65
66#define ACPI_OEM_ID_SIZE        6
67
68#define ACPI_NAME_SIZE  4
69
70/* Sizes for ACPI table headers */
71#define ACPI_OEM_ID_SIZE                6
72#define ACPI_OEM_TABLE_ID_SIZE  8
73
74
75/*******************************************************************************
76 * RSDP - Root System Description Pointer (Signature is "RSD PTR ")
77 *        Version 2
78 ******************************************************************************/
79
80struct acpi_table_rsdp {
81        char Signature[8];            /* ACPI signature, contains "RSD PTR " */
82        uint8_t Checksum;             /* ACPI 1.0 checksum */
83        char OemId[ACPI_OEM_ID_SIZE]; /* OEM identification */
84        uint8_t Revision;             /* Must be (0) for ACPI 1.0 or (2) for ACPI 2.0+ */
85        uint32_t RsdtPhysicalAddress; /* 32-bit physical address of the RSDT */
86        uint32_t Length;              /* Table length in bytes, including header (ACPI 2.0+) */
87        uint64_t XsdtPhysicalAddress; /* 64-bit physical address of the XSDT (ACPI 2.0+) */
88        uint8_t ExtendedChecksum;     /* Checksum of entire table (ACPI 2.0+) */
89        uint8_t Reserved[3];          /* Reserved, must be zero */
90} __packed;
91typedef struct acpi_table_rsdp  rsdp_t;
92
93/*******************************************************************************
94 * Master ACPI Table Header. This common header is used by all ACPI tables
95 * except the RSDP and FACS.
96 ******************************************************************************/
97
98struct acpi_table_header {
99        char Signature[ACPI_NAME_SIZE];          /* ASCII table signature */
100        uint32_t Length;                         /* Length of table in bytes, including this header */
101        uint8_t Revision;                        /* ACPI Specification minor version number */
102        uint8_t Checksum;                        /* To make sum of entire table == 0 */
103        char OemId[ACPI_OEM_ID_SIZE];            /* ASCII OEM identification */
104        char OemTableId[ACPI_OEM_TABLE_ID_SIZE]; /* ASCII OEM table identification */
105        uint32_t OemRevision;                    /* OEM revision number */
106        char AslCompilerId[ACPI_NAME_SIZE];      /* ASCII ASL compiler vendor ID */
107        uint32_t AslCompilerRevision;            /* ASL compiler version */
108} __packed;
109typedef struct acpi_table_header        header_t;
110
111/*******************************************************************************
112 * RSDT - Root System Description Tables
113 *        Version 1
114 ******************************************************************************/
115
116struct acpi_table_rsdt {
117        header_t Header;              /* Common ACPI table header */
118    uint32_t TableOffsetEntry[1]; /* Array of pointers to ACPI tables */
119} __packed;
120typedef struct acpi_table_rsdt  rsdt_t;
121
122/*******************************************************************************
123 * Common subtable headers
124 ******************************************************************************/
125
126struct acpi_subtable_header {
127        uint8_t Type;
128        uint8_t Length;
129} __packed;
130typedef struct acpi_subtable_header     subheader_t;
131
132/*******************************************************************************
133 * MADT - Multiple APIC Description Table
134 *        Version 3
135 ******************************************************************************/
136
137struct acpi_table_madt {
138        header_t Header;  /* Common ACPI table header */
139        uint32_t Address; /* Physical address of local APIC */
140        uint32_t Flags;
141} __packed;
142typedef struct acpi_table_madt  madt_t;
143
144/*******************************************************************************
145 * MADT structures
146 ******************************************************************************/
147
148enum AcpiMadtType {
149        ACPI_MADT_TYPE_LOCAL_APIC            = 0,
150        ACPI_MADT_TYPE_IO_APIC               = 1,
151        ACPI_MADT_TYPE_INTERRUPT_OVERRIDE    = 2,
152        ACPI_MADT_TYPE_NMI_SOURCE            = 3,
153        ACPI_MADT_TYPE_LOCAL_APIC_NMI        = 4,
154        ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE   = 5,
155        ACPI_MADT_TYPE_IO_SAPIC              = 6,
156        ACPI_MADT_TYPE_LOCAL_SAPIC           = 7,
157        ACPI_MADT_TYPE_INTERRUPT_SOURCE      = 8,
158        ACPI_MADT_TYPE_LOCAL_X2APIC          = 9,
159        ACPI_MADT_TYPE_LOCAL_X2APIC_NMI      = 10,
160        ACPI_MADT_TYPE_GENERIC_INTERRUPT     = 11,
161        ACPI_MADT_TYPE_GENERIC_DISTRIBUTOR   = 12,
162        ACPI_MADT_TYPE_GENERIC_MSI_FRAME     = 13,
163        ACPI_MADT_TYPE_GENERIC_REDISTRIBUTOR = 14,
164        ACPI_MADT_TYPE_GENERIC_TRANSLATOR    = 15,
165        ACPI_MADT_TYPE_RESERVED              = 16  /* 16 and greater are reserved */
166};
167
168struct acpi_madt_local_apic {
169        subheader_t Header;
170        uint8_t ProcessorId; /* ACPI processor id */
171        uint8_t Id;          /* Processor's local APIC id */
172        uint32_t LapicFlags;
173} __packed;
174typedef struct acpi_madt_local_apic     madt_lapic_t;
175
176struct acpi_madt_local_apic_override {
177        subheader_t Header;
178        uint16_t Reserved; /* Reserved, must be zero */
179        uint64_t Address;  /* APIC physical address */
180} __packed;
181typedef struct acpi_madt_local_apic_override madt_lapic_override_t;
182
183struct acpi_madt_io_apic {
184        subheader_t Header;
185        uint8_t Id;             /* I/O APIC ID */
186        uint8_t Reserved;       /* Reserved - must be zero */
187        uint32_t Address;       /* APIC physical address */
188        uint32_t GlobalIrqBase; /* Global system interrupt where INTI lines start */
189} __packed;
190typedef struct acpi_madt_io_apic madt_ioapic_t;
191
Note: See TracBrowser for help on using the repository browser.