Pyrogenesis
trunk
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
source
lib
sysdep
acpi.h
Go to the documentation of this file.
1
/* Copyright (c) 2010 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
33
struct
AcpiTable
34
{
35
char
signature
[4];
36
u32
size
;
// table size [bytes], including header
37
u8
revision
;
38
u8
checksum
;
// to make sum of entire table == 0
39
char
oemId
[6];
40
char
oemTableId
[8];
41
u32
oemRevision
;
42
char
creatorId
[4];
43
u32
creatorRevision
;
44
};
45
46
enum
AcpiAddressSpace
47
{
48
// (these are not generally powers-of-two - some values have been omitted.)
49
ACPI_AS_MEMORY
= 0,
50
ACPI_AS_IO
= 1,
51
ACPI_AS_PCI_CONFIG
= 2,
52
ACPI_AS_SMBUS
= 4
53
};
54
55
// address of a struct or register
56
struct
AcpiGenericAddress
57
{
58
u8
addressSpaceId
;
59
u8
registerBitWidth
;
60
u8
registerBitOffset
;
61
u8
accessSize
;
62
u64
address
;
63
};
64
65
struct
FADT
// signature is FACP!
66
{
67
AcpiTable
header
;
68
u8
unused1[40];
69
u32
pmTimerPortAddress
;
70
u8
unused2[16];
71
u16
c2Latency
;
// [us]
72
u16
c3Latency
;
// [us]
73
u8
unused3[5];
74
u8
dutyWidth
;
75
u8
unused4[6];
76
u32
flags
;
77
// (ACPI4 defines additional fields after this)
78
79
bool
IsDutyCycleSupported
()
const
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
**/
104
LIB_API
const
AcpiTable
*
acpi_GetTable
(
const
char
*
signature
);
105
106
/**
107
* invalidates all pointers returned by acpi_GetTable.
108
**/
109
LIB_API
void
acpi_Shutdown
();
110
111
#endif // #ifndef INCLUDED_ACPI
acpi_Shutdown
LIB_API void acpi_Shutdown()
invalidates all pointers returned by acpi_GetTable.
Definition:
acpi.cpp:346
AcpiGenericAddress::registerBitOffset
u8 registerBitOffset
Definition:
acpi.h:60
FADT::c2Latency
u16 c2Latency
Definition:
acpi.h:71
AcpiTable::creatorRevision
u32 creatorRevision
Definition:
acpi.h:43
ACPI_AS_PCI_CONFIG
Definition:
acpi.h:51
u16
uint16_t u16
Definition:
types.h:38
AcpiGenericAddress::addressSpaceId
u8 addressSpaceId
Definition:
acpi.h:58
AcpiGenericAddress::accessSize
u8 accessSize
Definition:
acpi.h:61
AcpiTable::oemId
char oemId[6]
Definition:
acpi.h:39
FADT::c3Latency
u16 c3Latency
Definition:
acpi.h:72
AcpiGenericAddress::address
u64 address
Definition:
acpi.h:62
AcpiGenericAddress
Definition:
acpi.h:56
AcpiTable::signature
char signature[4]
Definition:
acpi.h:35
acpi_GetTable
LIB_API const AcpiTable * acpi_GetTable(const char *signature)
Definition:
acpi.cpp:362
u8
uint8_t u8
Definition:
types.h:37
AcpiTable::size
u32 size
Definition:
acpi.h:36
u64
uint64_t u64
Definition:
types.h:40
FADT::flags
u32 flags
Definition:
acpi.h:76
FADT::IsC3Supported
bool IsC3Supported() const
Definition:
acpi.h:89
AcpiAddressSpace
AcpiAddressSpace
Definition:
acpi.h:46
AcpiTable::oemRevision
u32 oemRevision
Definition:
acpi.h:41
ACPI_AS_MEMORY
Definition:
acpi.h:49
u32
uint32_t u32
Definition:
types.h:39
FADT::pmTimerPortAddress
u32 pmTimerPortAddress
Definition:
acpi.h:69
FADT::dutyWidth
u8 dutyWidth
Definition:
acpi.h:74
AcpiTable::creatorId
char creatorId[4]
Definition:
acpi.h:42
AcpiTable::checksum
u8 checksum
Definition:
acpi.h:38
ACPI_AS_SMBUS
Definition:
acpi.h:52
FADT::IsC2Supported
bool IsC2Supported() const
Definition:
acpi.h:84
ACPI_AS_IO
Definition:
acpi.h:50
AcpiTable::revision
u8 revision
Definition:
acpi.h:37
AcpiTable
Definition:
acpi.h:33
FADT::IsDutyCycleSupported
bool IsDutyCycleSupported() const
Definition:
acpi.h:79
FADT
Definition:
acpi.h:65
AcpiTable::oemTableId
char oemTableId[8]
Definition:
acpi.h:40
FADT::header
AcpiTable header
Definition:
acpi.h:67
AcpiGenericAddress::registerBitWidth
u8 registerBitWidth
Definition:
acpi.h:59
Generated by
1.8.11