Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
acpi.h
Go to the documentation of this file.
1/* Copyright (C) 2022 Wildfire Games.
2 *
3 * Permission is hereby granted, free of charge, to any person obtaining
4 * a copy of this software and associated documentation files (the
5 * "Software"), to deal in the Software without restriction, including
6 * without limitation the rights to use, copy, modify, merge, publish,
7 * distribute, sublicense, and/or sell copies of the Software, and to
8 * permit persons to whom the Software is furnished to do so, subject to
9 * the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included
12 * in all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
18 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 */
22
23/*
24 * minimal subset of ACPI
25 */
26
27#ifndef INCLUDED_ACPI
28#define INCLUDED_ACPI
29
30#pragma pack(push, 1)
31
32// common header for all ACPI tables
34{
35 char signature[4];
36 u32 size; // table size [bytes], including header
38 u8 checksum; // to make sum of entire table == 0
39 char oemId[6];
40 char oemTableId[8];
42 char creatorId[4];
44};
45
47{
48 // (these are not generally powers-of-two - some values have been omitted.)
53};
54
55// address of a struct or register
57{
63};
64
65struct FADT // signature is FACP!
66{
71 u16 c2Latency; // [us]
72 u16 c3Latency; // [us]
77 // (ACPI4 defines additional fields after this)
78
80 {
81 return dutyWidth != 0;
82 }
83
84 bool IsC2Supported() const
85 {
86 return c2Latency <= 100; // magic value specified by ACPI
87 }
88
89 bool IsC3Supported() const
90 {
91 return c3Latency <= 1000; // see above
92 }
93};
94
95#pragma pack(pop)
96
97/**
98 * @param signature e.g. "RSDT"
99 * @return pointer to internal storage (valid until acpi_Shutdown())
100 *
101 * note: the first call may be slow, e.g. if a kernel-mode driver is
102 * loaded. subsequent requests will be faster since tables are cached.
103 **/
104const AcpiTable* acpi_GetTable(const char* signature);
105
106/**
107 * invalidates all pointers returned by acpi_GetTable.
108 **/
109void acpi_Shutdown();
110
111#endif // #ifndef INCLUDED_ACPI
const AcpiTable * acpi_GetTable(const char *signature)
Definition: acpi.cpp:155
void acpi_Shutdown()
invalidates all pointers returned by acpi_GetTable.
Definition: acpi.cpp:143
AcpiAddressSpace
Definition: acpi.h:47
@ ACPI_AS_PCI_CONFIG
Definition: acpi.h:51
@ ACPI_AS_IO
Definition: acpi.h:50
@ ACPI_AS_SMBUS
Definition: acpi.h:52
@ ACPI_AS_MEMORY
Definition: acpi.h:49
Definition: acpi.h:57
u8 accessSize
Definition: acpi.h:61
u8 addressSpaceId
Definition: acpi.h:58
u8 registerBitWidth
Definition: acpi.h:59
u8 registerBitOffset
Definition: acpi.h:60
u64 address
Definition: acpi.h:62
Definition: acpi.h:34
u32 creatorRevision
Definition: acpi.h:43
u32 size
Definition: acpi.h:36
char creatorId[4]
Definition: acpi.h:42
char signature[4]
Definition: acpi.h:35
u8 revision
Definition: acpi.h:37
u32 oemRevision
Definition: acpi.h:41
char oemId[6]
Definition: acpi.h:39
char oemTableId[8]
Definition: acpi.h:40
u8 checksum
Definition: acpi.h:38
Definition: acpi.h:66
u32 flags
Definition: acpi.h:76
u8 unused2[16]
Definition: acpi.h:70
bool IsC2Supported() const
Definition: acpi.h:84
AcpiTable header
Definition: acpi.h:67
u16 c3Latency
Definition: acpi.h:72
u8 dutyWidth
Definition: acpi.h:74
u8 unused3[5]
Definition: acpi.h:73
u8 unused4[6]
Definition: acpi.h:75
u32 pmTimerPortAddress
Definition: acpi.h:69
bool IsC3Supported() const
Definition: acpi.h:89
bool IsDutyCycleSupported() const
Definition: acpi.h:79
u8 unused1[40]
Definition: acpi.h:68
u16 c2Latency
Definition: acpi.h:71
uint64_t u64
Definition: types.h:40
uint8_t u8
Definition: types.h:37
uint16_t u16
Definition: types.h:38
uint32_t u32
Definition: types.h:39