tools: delete legacy amldecode tool
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
TOOL_LIST := e64patch amldecode
|
TOOL_LIST := e64patch
|
||||||
|
|
||||||
all:
|
all:
|
||||||
@for prog in $(TOOL_LIST); do \
|
@for prog in $(TOOL_LIST); do \
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
TOOL_NAME := amldecode
|
|
||||||
|
|
||||||
include ../tool-config.mk
|
|
||||||
|
|
||||||
CFLAGS := -g
|
|
||||||
LDFLAGS := -g
|
|
||||||
|
|
||||||
include ../tool-template.mk
|
|
||||||
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@@ -1,598 +0,0 @@
|
|||||||
/*
|
|
||||||
* Bochs/QEMU ACPI DSDT ASL definition
|
|
||||||
*
|
|
||||||
* Copyright (c) 2006 Fabrice Bellard
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License version 2 as published by the Free Software Foundation.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
DefinitionBlock (
|
|
||||||
"acpi-dsdt.aml", // Output Filename
|
|
||||||
"DSDT", // Signature
|
|
||||||
0x01, // DSDT Compliance Revision
|
|
||||||
"BXPC", // OEMID
|
|
||||||
"BXDSDT", // TABLE ID
|
|
||||||
0x1 // OEM Revision
|
|
||||||
)
|
|
||||||
{
|
|
||||||
Scope (\)
|
|
||||||
{
|
|
||||||
/* Debug Output */
|
|
||||||
OperationRegion (DBG, SystemIO, 0xb044, 0x04)
|
|
||||||
Field (DBG, DWordAcc, NoLock, Preserve)
|
|
||||||
{
|
|
||||||
DBGL, 32,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* PCI Bus definition */
|
|
||||||
Scope(\_SB) {
|
|
||||||
Device(PCI0) {
|
|
||||||
Name (_HID, EisaId ("PNP0A03"))
|
|
||||||
Name (_ADR, 0x00)
|
|
||||||
Name (_UID, 1)
|
|
||||||
Name(_PRT, Package() {
|
|
||||||
/* PCI IRQ routing table, example from ACPI 2.0a specification,
|
|
||||||
section 6.2.8.1 */
|
|
||||||
/* Note: we provide the same info as the PCI routing
|
|
||||||
table of the Bochs BIOS */
|
|
||||||
#define prt_slot(nr, lnk0, lnk1, lnk2, lnk3) \
|
|
||||||
Package() { nr##ffff, 0, lnk0, 0 }, \
|
|
||||||
Package() { nr##ffff, 1, lnk1, 0 }, \
|
|
||||||
Package() { nr##ffff, 2, lnk2, 0 }, \
|
|
||||||
Package() { nr##ffff, 3, lnk3, 0 }
|
|
||||||
|
|
||||||
#define prt_slot0(nr) prt_slot(nr, LNKD, LNKA, LNKB, LNKC)
|
|
||||||
#define prt_slot1(nr) prt_slot(nr, LNKA, LNKB, LNKC, LNKD)
|
|
||||||
#define prt_slot2(nr) prt_slot(nr, LNKB, LNKC, LNKD, LNKA)
|
|
||||||
#define prt_slot3(nr) prt_slot(nr, LNKC, LNKD, LNKA, LNKB)
|
|
||||||
prt_slot0(0x0000),
|
|
||||||
prt_slot1(0x0001),
|
|
||||||
prt_slot2(0x0002),
|
|
||||||
prt_slot3(0x0003),
|
|
||||||
prt_slot0(0x0004),
|
|
||||||
prt_slot1(0x0005),
|
|
||||||
prt_slot2(0x0006),
|
|
||||||
prt_slot3(0x0007),
|
|
||||||
prt_slot0(0x0008),
|
|
||||||
prt_slot1(0x0009),
|
|
||||||
prt_slot2(0x000a),
|
|
||||||
prt_slot3(0x000b),
|
|
||||||
prt_slot0(0x000c),
|
|
||||||
prt_slot1(0x000d),
|
|
||||||
prt_slot2(0x000e),
|
|
||||||
prt_slot3(0x000f),
|
|
||||||
prt_slot0(0x0010),
|
|
||||||
prt_slot1(0x0011),
|
|
||||||
prt_slot2(0x0012),
|
|
||||||
prt_slot3(0x0013),
|
|
||||||
prt_slot0(0x0014),
|
|
||||||
prt_slot1(0x0015),
|
|
||||||
prt_slot2(0x0016),
|
|
||||||
prt_slot3(0x0017),
|
|
||||||
prt_slot0(0x0018),
|
|
||||||
prt_slot1(0x0019),
|
|
||||||
prt_slot2(0x001a),
|
|
||||||
prt_slot3(0x001b),
|
|
||||||
prt_slot0(0x001c),
|
|
||||||
prt_slot1(0x001d),
|
|
||||||
prt_slot2(0x001e),
|
|
||||||
prt_slot3(0x001f),
|
|
||||||
})
|
|
||||||
|
|
||||||
Name (_CRS, ResourceTemplate ()
|
|
||||||
{
|
|
||||||
WordBusNumber (ResourceProducer, MinFixed, MaxFixed, PosDecode,
|
|
||||||
0x0000, // Address Space Granularity
|
|
||||||
0x0000, // Address Range Minimum
|
|
||||||
0x00FF, // Address Range Maximum
|
|
||||||
0x0000, // Address Translation Offset
|
|
||||||
0x0100, // Address Length
|
|
||||||
,, )
|
|
||||||
IO (Decode16,
|
|
||||||
0x0CF8, // Address Range Minimum
|
|
||||||
0x0CF8, // Address Range Maximum
|
|
||||||
0x01, // Address Alignment
|
|
||||||
0x08, // Address Length
|
|
||||||
)
|
|
||||||
WordIO (ResourceProducer, MinFixed, MaxFixed, PosDecode, EntireRange,
|
|
||||||
0x0000, // Address Space Granularity
|
|
||||||
0x0000, // Address Range Minimum
|
|
||||||
0x0CF7, // Address Range Maximum
|
|
||||||
0x0000, // Address Translation Offset
|
|
||||||
0x0CF8, // Address Length
|
|
||||||
,, , TypeStatic)
|
|
||||||
WordIO (ResourceProducer, MinFixed, MaxFixed, PosDecode, EntireRange,
|
|
||||||
0x0000, // Address Space Granularity
|
|
||||||
0x0D00, // Address Range Minimum
|
|
||||||
0xFFFF, // Address Range Maximum
|
|
||||||
0x0000, // Address Translation Offset
|
|
||||||
0xF300, // Address Length
|
|
||||||
,, , TypeStatic)
|
|
||||||
DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, Cacheable, ReadWrite,
|
|
||||||
0x00000000, // Address Space Granularity
|
|
||||||
0x000A0000, // Address Range Minimum
|
|
||||||
0x000BFFFF, // Address Range Maximum
|
|
||||||
0x00000000, // Address Translation Offset
|
|
||||||
0x00020000, // Address Length
|
|
||||||
,, , AddressRangeMemory, TypeStatic)
|
|
||||||
DWordMemory (ResourceProducer, PosDecode, MinFixed, MaxFixed, NonCacheable, ReadWrite,
|
|
||||||
0x00000000, // Address Space Granularity
|
|
||||||
0xC0000000, // Address Range Minimum
|
|
||||||
0xFEBFFFFF, // Address Range Maximum
|
|
||||||
0x00000000, // Address Translation Offset
|
|
||||||
0x3EC00000, // Address Length
|
|
||||||
,, , AddressRangeMemory, TypeStatic)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
Device(HPET) {
|
|
||||||
Name(_HID, EISAID("PNP0103"))
|
|
||||||
Name(_UID, 0)
|
|
||||||
Method (_STA, 0, NotSerialized) {
|
|
||||||
Return(0x0F)
|
|
||||||
}
|
|
||||||
Name(_CRS, ResourceTemplate() {
|
|
||||||
DWordMemory(
|
|
||||||
ResourceConsumer, PosDecode, MinFixed, MaxFixed,
|
|
||||||
NonCacheable, ReadWrite,
|
|
||||||
0x00000000,
|
|
||||||
0xFED00000,
|
|
||||||
0xFED003FF,
|
|
||||||
0x00000000,
|
|
||||||
0x00000400 /* 1K memory: FED00000 - FED003FF */
|
|
||||||
)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Scope(\_SB.PCI0) {
|
|
||||||
Device (VGA) {
|
|
||||||
Name (_ADR, 0x00020000)
|
|
||||||
Method (_S1D, 0, NotSerialized)
|
|
||||||
{
|
|
||||||
Return (0x00)
|
|
||||||
}
|
|
||||||
Method (_S2D, 0, NotSerialized)
|
|
||||||
{
|
|
||||||
Return (0x00)
|
|
||||||
}
|
|
||||||
Method (_S3D, 0, NotSerialized)
|
|
||||||
{
|
|
||||||
Return (0x00)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* PIIX3 ISA bridge */
|
|
||||||
Device (ISA) {
|
|
||||||
Name (_ADR, 0x00010000)
|
|
||||||
|
|
||||||
/* PIIX PCI to ISA irq remapping */
|
|
||||||
OperationRegion (P40C, PCI_Config, 0x60, 0x04)
|
|
||||||
|
|
||||||
/* Real-time clock */
|
|
||||||
Device (RTC)
|
|
||||||
{
|
|
||||||
Name (_HID, EisaId ("PNP0B00"))
|
|
||||||
Name (_CRS, ResourceTemplate ()
|
|
||||||
{
|
|
||||||
IO (Decode16, 0x0070, 0x0070, 0x10, 0x02)
|
|
||||||
IRQNoFlags () {8}
|
|
||||||
IO (Decode16, 0x0072, 0x0072, 0x02, 0x06)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Keyboard seems to be important for WinXP install */
|
|
||||||
Device (KBD)
|
|
||||||
{
|
|
||||||
Name (_HID, EisaId ("PNP0303"))
|
|
||||||
Method (_STA, 0, NotSerialized)
|
|
||||||
{
|
|
||||||
Return (0x0f)
|
|
||||||
}
|
|
||||||
|
|
||||||
Method (_CRS, 0, NotSerialized)
|
|
||||||
{
|
|
||||||
Name (TMP, ResourceTemplate ()
|
|
||||||
{
|
|
||||||
IO (Decode16,
|
|
||||||
0x0060, // Address Range Minimum
|
|
||||||
0x0060, // Address Range Maximum
|
|
||||||
0x01, // Address Alignment
|
|
||||||
0x01, // Address Length
|
|
||||||
)
|
|
||||||
IO (Decode16,
|
|
||||||
0x0064, // Address Range Minimum
|
|
||||||
0x0064, // Address Range Maximum
|
|
||||||
0x01, // Address Alignment
|
|
||||||
0x01, // Address Length
|
|
||||||
)
|
|
||||||
IRQNoFlags ()
|
|
||||||
{1}
|
|
||||||
})
|
|
||||||
Return (TMP)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* PS/2 mouse */
|
|
||||||
Device (MOU)
|
|
||||||
{
|
|
||||||
Name (_HID, EisaId ("PNP0F13"))
|
|
||||||
Method (_STA, 0, NotSerialized)
|
|
||||||
{
|
|
||||||
Return (0x0f)
|
|
||||||
}
|
|
||||||
|
|
||||||
Method (_CRS, 0, NotSerialized)
|
|
||||||
{
|
|
||||||
Name (TMP, ResourceTemplate ()
|
|
||||||
{
|
|
||||||
IRQNoFlags () {12}
|
|
||||||
})
|
|
||||||
Return (TMP)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* PS/2 floppy controller */
|
|
||||||
Device (FDC0)
|
|
||||||
{
|
|
||||||
Name (_HID, EisaId ("PNP0700"))
|
|
||||||
Method (_STA, 0, NotSerialized)
|
|
||||||
{
|
|
||||||
Return (0x0F)
|
|
||||||
}
|
|
||||||
Method (_CRS, 0, NotSerialized)
|
|
||||||
{
|
|
||||||
Name (BUF0, ResourceTemplate ()
|
|
||||||
{
|
|
||||||
IO (Decode16, 0x03F2, 0x03F2, 0x00, 0x04)
|
|
||||||
IO (Decode16, 0x03F7, 0x03F7, 0x00, 0x01)
|
|
||||||
IRQNoFlags () {6}
|
|
||||||
DMA (Compatibility, NotBusMaster, Transfer8) {2}
|
|
||||||
})
|
|
||||||
Return (BUF0)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Parallel port */
|
|
||||||
Device (LPT)
|
|
||||||
{
|
|
||||||
Name (_HID, EisaId ("PNP0400"))
|
|
||||||
Method (_STA, 0, NotSerialized)
|
|
||||||
{
|
|
||||||
Store (\_SB.PCI0.PX13.DRSA, Local0)
|
|
||||||
And (Local0, 0x80000000, Local0)
|
|
||||||
If (LEqual (Local0, 0))
|
|
||||||
{
|
|
||||||
Return (0x00)
|
|
||||||
}
|
|
||||||
Else
|
|
||||||
{
|
|
||||||
Return (0x0F)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Method (_CRS, 0, NotSerialized)
|
|
||||||
{
|
|
||||||
Name (BUF0, ResourceTemplate ()
|
|
||||||
{
|
|
||||||
IO (Decode16, 0x0378, 0x0378, 0x08, 0x08)
|
|
||||||
IRQNoFlags () {7}
|
|
||||||
})
|
|
||||||
Return (BUF0)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Serial Ports */
|
|
||||||
Device (COM1)
|
|
||||||
{
|
|
||||||
Name (_HID, EisaId ("PNP0501"))
|
|
||||||
Name (_UID, 0x01)
|
|
||||||
Method (_STA, 0, NotSerialized)
|
|
||||||
{
|
|
||||||
Store (\_SB.PCI0.PX13.DRSC, Local0)
|
|
||||||
And (Local0, 0x08000000, Local0)
|
|
||||||
If (LEqual (Local0, 0))
|
|
||||||
{
|
|
||||||
Return (0x00)
|
|
||||||
}
|
|
||||||
Else
|
|
||||||
{
|
|
||||||
Return (0x0F)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Method (_CRS, 0, NotSerialized)
|
|
||||||
{
|
|
||||||
Name (BUF0, ResourceTemplate ()
|
|
||||||
{
|
|
||||||
IO (Decode16, 0x03F8, 0x03F8, 0x00, 0x08)
|
|
||||||
IRQNoFlags () {4}
|
|
||||||
})
|
|
||||||
Return (BUF0)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Device (COM2)
|
|
||||||
{
|
|
||||||
Name (_HID, EisaId ("PNP0501"))
|
|
||||||
Name (_UID, 0x02)
|
|
||||||
Method (_STA, 0, NotSerialized)
|
|
||||||
{
|
|
||||||
Store (\_SB.PCI0.PX13.DRSC, Local0)
|
|
||||||
And (Local0, 0x80000000, Local0)
|
|
||||||
If (LEqual (Local0, 0))
|
|
||||||
{
|
|
||||||
Return (0x00)
|
|
||||||
}
|
|
||||||
Else
|
|
||||||
{
|
|
||||||
Return (0x0F)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Method (_CRS, 0, NotSerialized)
|
|
||||||
{
|
|
||||||
Name (BUF0, ResourceTemplate ()
|
|
||||||
{
|
|
||||||
IO (Decode16, 0x02F8, 0x02F8, 0x00, 0x08)
|
|
||||||
IRQNoFlags () {3}
|
|
||||||
})
|
|
||||||
Return (BUF0)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* PIIX4 PM */
|
|
||||||
Device (PX13) {
|
|
||||||
Name (_ADR, 0x00010003)
|
|
||||||
|
|
||||||
OperationRegion (P13C, PCI_Config, 0x5c, 0x24)
|
|
||||||
Field (P13C, DWordAcc, NoLock, Preserve)
|
|
||||||
{
|
|
||||||
DRSA, 32,
|
|
||||||
DRSB, 32,
|
|
||||||
DRSC, 32,
|
|
||||||
DRSE, 32,
|
|
||||||
DRSF, 32,
|
|
||||||
DRSG, 32,
|
|
||||||
DRSH, 32,
|
|
||||||
DRSI, 32,
|
|
||||||
DRSJ, 32
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* PCI IRQs */
|
|
||||||
Scope(\_SB) {
|
|
||||||
Field (\_SB.PCI0.ISA.P40C, ByteAcc, NoLock, Preserve)
|
|
||||||
{
|
|
||||||
PRQ0, 8,
|
|
||||||
PRQ1, 8,
|
|
||||||
PRQ2, 8,
|
|
||||||
PRQ3, 8
|
|
||||||
}
|
|
||||||
|
|
||||||
Device(LNKA){
|
|
||||||
Name(_HID, EISAID("PNP0C0F")) // PCI interrupt link
|
|
||||||
Name(_UID, 1)
|
|
||||||
Name(_PRS, ResourceTemplate(){
|
|
||||||
IRQ (Level, ActiveLow, Shared)
|
|
||||||
{3,4,5,6,7,9,10,11,12}
|
|
||||||
})
|
|
||||||
Method (_STA, 0, NotSerialized)
|
|
||||||
{
|
|
||||||
Store (0x0B, Local0)
|
|
||||||
If (And (0x80, PRQ0, Local1))
|
|
||||||
{
|
|
||||||
Store (0x09, Local0)
|
|
||||||
}
|
|
||||||
Return (Local0)
|
|
||||||
}
|
|
||||||
Method (_DIS, 0, NotSerialized)
|
|
||||||
{
|
|
||||||
Or (PRQ0, 0x80, PRQ0)
|
|
||||||
}
|
|
||||||
Method (_CRS, 0, NotSerialized)
|
|
||||||
{
|
|
||||||
Name (PRR0, ResourceTemplate ()
|
|
||||||
{
|
|
||||||
IRQ (Level, ActiveLow, Shared)
|
|
||||||
{1}
|
|
||||||
})
|
|
||||||
CreateWordField (PRR0, 0x01, TMP)
|
|
||||||
Store (PRQ0, Local0)
|
|
||||||
If (LLess (Local0, 0x80))
|
|
||||||
{
|
|
||||||
ShiftLeft (One, Local0, TMP)
|
|
||||||
}
|
|
||||||
Else
|
|
||||||
{
|
|
||||||
Store (Zero, TMP)
|
|
||||||
}
|
|
||||||
Return (PRR0)
|
|
||||||
}
|
|
||||||
Method (_SRS, 1, NotSerialized)
|
|
||||||
{
|
|
||||||
CreateWordField (Arg0, 0x01, TMP)
|
|
||||||
FindSetRightBit (TMP, Local0)
|
|
||||||
Decrement (Local0)
|
|
||||||
Store (Local0, PRQ0)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Device(LNKB){
|
|
||||||
Name(_HID, EISAID("PNP0C0F")) // PCI interrupt link
|
|
||||||
Name(_UID, 2)
|
|
||||||
Name(_PRS, ResourceTemplate(){
|
|
||||||
IRQ (Level, ActiveLow, Shared)
|
|
||||||
{3,4,5,6,7,9,10,11,12}
|
|
||||||
})
|
|
||||||
Method (_STA, 0, NotSerialized)
|
|
||||||
{
|
|
||||||
Store (0x0B, Local0)
|
|
||||||
If (And (0x80, PRQ1, Local1))
|
|
||||||
{
|
|
||||||
Store (0x09, Local0)
|
|
||||||
}
|
|
||||||
Return (Local0)
|
|
||||||
}
|
|
||||||
Method (_DIS, 0, NotSerialized)
|
|
||||||
{
|
|
||||||
Or (PRQ1, 0x80, PRQ1)
|
|
||||||
}
|
|
||||||
Method (_CRS, 0, NotSerialized)
|
|
||||||
{
|
|
||||||
Name (PRR0, ResourceTemplate ()
|
|
||||||
{
|
|
||||||
IRQ (Level, ActiveLow, Shared)
|
|
||||||
{1}
|
|
||||||
})
|
|
||||||
CreateWordField (PRR0, 0x01, TMP)
|
|
||||||
Store (PRQ1, Local0)
|
|
||||||
If (LLess (Local0, 0x80))
|
|
||||||
{
|
|
||||||
ShiftLeft (One, Local0, TMP)
|
|
||||||
}
|
|
||||||
Else
|
|
||||||
{
|
|
||||||
Store (Zero, TMP)
|
|
||||||
}
|
|
||||||
Return (PRR0)
|
|
||||||
}
|
|
||||||
Method (_SRS, 1, NotSerialized)
|
|
||||||
{
|
|
||||||
CreateWordField (Arg0, 0x01, TMP)
|
|
||||||
FindSetRightBit (TMP, Local0)
|
|
||||||
Decrement (Local0)
|
|
||||||
Store (Local0, PRQ1)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Device(LNKC){
|
|
||||||
Name(_HID, EISAID("PNP0C0F")) // PCI interrupt link
|
|
||||||
Name(_UID, 3)
|
|
||||||
Name(_PRS, ResourceTemplate(){
|
|
||||||
IRQ (Level, ActiveLow, Shared)
|
|
||||||
{3,4,5,6,7,9,10,11,12}
|
|
||||||
})
|
|
||||||
Method (_STA, 0, NotSerialized)
|
|
||||||
{
|
|
||||||
Store (0x0B, Local0)
|
|
||||||
If (And (0x80, PRQ2, Local1))
|
|
||||||
{
|
|
||||||
Store (0x09, Local0)
|
|
||||||
}
|
|
||||||
Return (Local0)
|
|
||||||
}
|
|
||||||
Method (_DIS, 0, NotSerialized)
|
|
||||||
{
|
|
||||||
Or (PRQ2, 0x80, PRQ2)
|
|
||||||
}
|
|
||||||
Method (_CRS, 0, NotSerialized)
|
|
||||||
{
|
|
||||||
Name (PRR0, ResourceTemplate ()
|
|
||||||
{
|
|
||||||
IRQ (Level, ActiveLow, Shared)
|
|
||||||
{1}
|
|
||||||
})
|
|
||||||
CreateWordField (PRR0, 0x01, TMP)
|
|
||||||
Store (PRQ2, Local0)
|
|
||||||
If (LLess (Local0, 0x80))
|
|
||||||
{
|
|
||||||
ShiftLeft (One, Local0, TMP)
|
|
||||||
}
|
|
||||||
Else
|
|
||||||
{
|
|
||||||
Store (Zero, TMP)
|
|
||||||
}
|
|
||||||
Return (PRR0)
|
|
||||||
}
|
|
||||||
Method (_SRS, 1, NotSerialized)
|
|
||||||
{
|
|
||||||
CreateWordField (Arg0, 0x01, TMP)
|
|
||||||
FindSetRightBit (TMP, Local0)
|
|
||||||
Decrement (Local0)
|
|
||||||
Store (Local0, PRQ2)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Device(LNKD){
|
|
||||||
Name(_HID, EISAID("PNP0C0F")) // PCI interrupt link
|
|
||||||
Name(_UID, 4)
|
|
||||||
Name(_PRS, ResourceTemplate(){
|
|
||||||
IRQ (Level, ActiveLow, Shared)
|
|
||||||
{3,4,5,6,7,9,10,11,12}
|
|
||||||
})
|
|
||||||
Method (_STA, 0, NotSerialized)
|
|
||||||
{
|
|
||||||
Store (0x0B, Local0)
|
|
||||||
If (And (0x80, PRQ3, Local1))
|
|
||||||
{
|
|
||||||
Store (0x09, Local0)
|
|
||||||
}
|
|
||||||
Return (Local0)
|
|
||||||
}
|
|
||||||
Method (_DIS, 0, NotSerialized)
|
|
||||||
{
|
|
||||||
Or (PRQ3, 0x80, PRQ3)
|
|
||||||
}
|
|
||||||
Method (_CRS, 0, NotSerialized)
|
|
||||||
{
|
|
||||||
Name (PRR0, ResourceTemplate ()
|
|
||||||
{
|
|
||||||
IRQ (Level, ActiveLow, Shared)
|
|
||||||
{1}
|
|
||||||
})
|
|
||||||
CreateWordField (PRR0, 0x01, TMP)
|
|
||||||
Store (PRQ3, Local0)
|
|
||||||
If (LLess (Local0, 0x80))
|
|
||||||
{
|
|
||||||
ShiftLeft (One, Local0, TMP)
|
|
||||||
}
|
|
||||||
Else
|
|
||||||
{
|
|
||||||
Store (Zero, TMP)
|
|
||||||
}
|
|
||||||
Return (PRR0)
|
|
||||||
}
|
|
||||||
Method (_SRS, 1, NotSerialized)
|
|
||||||
{
|
|
||||||
CreateWordField (Arg0, 0x01, TMP)
|
|
||||||
FindSetRightBit (TMP, Local0)
|
|
||||||
Decrement (Local0)
|
|
||||||
Store (Local0, PRQ3)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* S3 (suspend-to-ram), S4 (suspend-to-disk) and S5 (power-off) type codes:
|
|
||||||
* must match piix4 emulation.
|
|
||||||
*/
|
|
||||||
Name (\_S3, Package (0x04)
|
|
||||||
{
|
|
||||||
0x01, /* PM1a_CNT.SLP_TYP */
|
|
||||||
0x01, /* PM1b_CNT.SLP_TYP */
|
|
||||||
Zero, /* reserved */
|
|
||||||
Zero /* reserved */
|
|
||||||
})
|
|
||||||
Name (\_S4, Package (0x04)
|
|
||||||
{
|
|
||||||
Zero, /* PM1a_CNT.SLP_TYP */
|
|
||||||
Zero, /* PM1b_CNT.SLP_TYP */
|
|
||||||
Zero, /* reserved */
|
|
||||||
Zero /* reserved */
|
|
||||||
})
|
|
||||||
Name (\_S5, Package (0x04)
|
|
||||||
{
|
|
||||||
Zero, /* PM1a_CNT.SLP_TYP */
|
|
||||||
Zero, /* PM1b_CNT.SLP_TYP */
|
|
||||||
Zero, /* reserved */
|
|
||||||
Zero /* reserved */
|
|
||||||
})
|
|
||||||
}
|
|
||||||
Binary file not shown.
Binary file not shown.
@@ -1,6 +0,0 @@
|
|||||||
#ifndef AML_CONSTANTS_H_
|
|
||||||
#define AML_CONSTANTS_H_
|
|
||||||
|
|
||||||
#define ACPI_OBJECT_NAME_MAX 5
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,138 +0,0 @@
|
|||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include "object.h"
|
|
||||||
|
|
||||||
struct acpi_namespace *acpi_namespace_create(void)
|
|
||||||
{
|
|
||||||
struct acpi_namespace *ns = malloc(sizeof *ns);
|
|
||||||
if (!ns) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
memset(ns, 0x00, sizeof *ns);
|
|
||||||
|
|
||||||
ns->root = acpi_object_create("\\", ACPI_OBJECT_NAMESPACE);
|
|
||||||
return ns;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct acpi_object *acpi_namespace_get_object(struct acpi_namespace *ns, const char *path)
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct acpi_object *acpi_object_create(const char name[ACPI_OBJECT_NAME_MAX], enum acpi_object_type type)
|
|
||||||
{
|
|
||||||
struct acpi_object *object = malloc(sizeof *object);
|
|
||||||
if (!object) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
memset(object, 0x00, sizeof *object);
|
|
||||||
|
|
||||||
object->ref = 1;
|
|
||||||
object->type = type;
|
|
||||||
|
|
||||||
if (name) {
|
|
||||||
strncpy(object->name, name, sizeof object->name - 1);
|
|
||||||
object->name[ACPI_OBJECT_NAME_MAX - 1] = '\0';
|
|
||||||
}
|
|
||||||
|
|
||||||
return object;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct acpi_object *acpi_object_ref(struct acpi_object *object)
|
|
||||||
{
|
|
||||||
object->ref++;
|
|
||||||
return object;
|
|
||||||
}
|
|
||||||
|
|
||||||
void acpi_object_deref(struct acpi_object *object)
|
|
||||||
{
|
|
||||||
if (object->ref > 1) {
|
|
||||||
object->ref--;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
object->ref = 0;
|
|
||||||
free(object);
|
|
||||||
}
|
|
||||||
|
|
||||||
void acpi_object_add_child(struct acpi_object *parent, struct acpi_object *child)
|
|
||||||
{
|
|
||||||
if (child->parent) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
child->parent = parent;
|
|
||||||
if (!parent->first_child) {
|
|
||||||
parent->first_child = acpi_object_ref(child);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct acpi_object *cur = parent->first_child;
|
|
||||||
while (cur->next_sibling) {
|
|
||||||
cur = cur->next_sibling;
|
|
||||||
}
|
|
||||||
|
|
||||||
cur->next_sibling = acpi_object_ref(child);
|
|
||||||
}
|
|
||||||
|
|
||||||
struct acpi_object *acpi_object_get_child(struct acpi_object *object, const char *name)
|
|
||||||
{
|
|
||||||
struct acpi_object *cur = object->first_child;
|
|
||||||
while (cur) {
|
|
||||||
if (!strcmp(cur->name, name)) {
|
|
||||||
return acpi_object_ref(cur);
|
|
||||||
}
|
|
||||||
|
|
||||||
cur = cur->next_sibling;
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void acpi_object_print(struct acpi_object *object, int depth)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < depth; i++) {
|
|
||||||
fputs(" ", stdout);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (object->name[0] == 0) {
|
|
||||||
printf("<unnamed> [%s]\n", acpi_object_type_string(object->type));
|
|
||||||
} else {
|
|
||||||
printf("%s [%s]\n", object->name, acpi_object_type_string(object->type));
|
|
||||||
}
|
|
||||||
|
|
||||||
struct acpi_object *cur = object->first_child;
|
|
||||||
while (cur) {
|
|
||||||
acpi_object_print(cur, depth + 1);
|
|
||||||
cur = cur->next_sibling;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#define OBJECT_TYPE_STRING(type) \
|
|
||||||
case type: \
|
|
||||||
return #type;
|
|
||||||
|
|
||||||
const char *acpi_object_type_string(enum acpi_object_type type)
|
|
||||||
{
|
|
||||||
switch (type) {
|
|
||||||
OBJECT_TYPE_STRING(ACPI_OBJECT_NONE)
|
|
||||||
OBJECT_TYPE_STRING(ACPI_OBJECT_VALUE)
|
|
||||||
OBJECT_TYPE_STRING(ACPI_OBJECT_NAMESPACE)
|
|
||||||
OBJECT_TYPE_STRING(ACPI_OBJECT_PROCESSOR)
|
|
||||||
OBJECT_TYPE_STRING(ACPI_OBJECT_DEVICE)
|
|
||||||
OBJECT_TYPE_STRING(ACPI_OBJECT_METHOD)
|
|
||||||
OBJECT_TYPE_STRING(ACPI_OBJECT_POWER_RESOURCE)
|
|
||||||
OBJECT_TYPE_STRING(ACPI_OBJECT_OPERATION_REGION)
|
|
||||||
OBJECT_TYPE_STRING(ACPI_OBJECT_THERMAL_ZONE)
|
|
||||||
OBJECT_TYPE_STRING(ACPI_OBJECT_FIELD)
|
|
||||||
OBJECT_TYPE_STRING(ACPI_OBJECT_PACKAGE)
|
|
||||||
OBJECT_TYPE_STRING(ACPI_OBJECT_BUFFER)
|
|
||||||
OBJECT_TYPE_STRING(ACPI_OBJECT_ALIAS)
|
|
||||||
OBJECT_TYPE_STRING(ACPI_OBJECT_MUTEX)
|
|
||||||
default:
|
|
||||||
return "<unknown>";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,55 +0,0 @@
|
|||||||
#ifndef AML_OBJECT_H_
|
|
||||||
#define AML_OBJECT_H_
|
|
||||||
|
|
||||||
#include <stddef.h>
|
|
||||||
#include "constants.h"
|
|
||||||
|
|
||||||
enum acpi_object_type {
|
|
||||||
ACPI_OBJECT_NONE = 0,
|
|
||||||
ACPI_OBJECT_VALUE,
|
|
||||||
ACPI_OBJECT_NAMESPACE,
|
|
||||||
ACPI_OBJECT_PROCESSOR,
|
|
||||||
ACPI_OBJECT_DEVICE,
|
|
||||||
ACPI_OBJECT_METHOD,
|
|
||||||
ACPI_OBJECT_POWER_RESOURCE,
|
|
||||||
ACPI_OBJECT_OPERATION_REGION,
|
|
||||||
ACPI_OBJECT_THERMAL_ZONE,
|
|
||||||
ACPI_OBJECT_FIELD,
|
|
||||||
ACPI_OBJECT_PACKAGE,
|
|
||||||
ACPI_OBJECT_BUFFER,
|
|
||||||
ACPI_OBJECT_ALIAS,
|
|
||||||
ACPI_OBJECT_MUTEX,
|
|
||||||
ACPI_OBJECT_EVENT,
|
|
||||||
};
|
|
||||||
|
|
||||||
struct acpi_object {
|
|
||||||
int ref;
|
|
||||||
enum acpi_object_type type;
|
|
||||||
union {
|
|
||||||
char name[ACPI_OBJECT_NAME_MAX];
|
|
||||||
char *publish_path;
|
|
||||||
};
|
|
||||||
|
|
||||||
size_t scope_end;
|
|
||||||
|
|
||||||
struct acpi_object *parent;
|
|
||||||
struct acpi_object *first_child, *next_sibling;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct acpi_namespace {
|
|
||||||
struct acpi_object *root;
|
|
||||||
};
|
|
||||||
|
|
||||||
extern struct acpi_namespace *acpi_namespace_create(void);
|
|
||||||
extern struct acpi_object *acpi_namespace_get_object(struct acpi_namespace *ns, const char *path);
|
|
||||||
|
|
||||||
extern struct acpi_object *acpi_object_create(const char name[ACPI_OBJECT_NAME_MAX], enum acpi_object_type type);
|
|
||||||
extern struct acpi_object *acpi_object_ref(struct acpi_object *object);
|
|
||||||
extern void acpi_object_deref(struct acpi_object *object);
|
|
||||||
extern void acpi_object_add_child(struct acpi_object *parent, struct acpi_object *child);
|
|
||||||
extern struct acpi_object *acpi_object_get_child(struct acpi_object *object, const char *name);
|
|
||||||
extern void acpi_object_print(struct acpi_object *object, int depth);
|
|
||||||
|
|
||||||
extern const char *acpi_object_type_string(enum acpi_object_type type);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,190 +0,0 @@
|
|||||||
#ifndef AML_OPCODE_H_
|
|
||||||
#define AML_OPCODE_H_
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
#include "parser.h"
|
|
||||||
|
|
||||||
struct aml_parser;
|
|
||||||
struct aml_value;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Primary OpCode
|
|
||||||
//
|
|
||||||
#define AML_ZERO_OP 0x00
|
|
||||||
#define AML_ONE_OP 0x01
|
|
||||||
#define AML_ALIAS_OP 0x06
|
|
||||||
#define AML_NAME_OP 0x08
|
|
||||||
#define AML_BYTE_PREFIX 0x0a
|
|
||||||
#define AML_WORD_PREFIX 0x0b
|
|
||||||
#define AML_DWORD_PREFIX 0x0c
|
|
||||||
#define AML_STRING_PREFIX 0x0d
|
|
||||||
#define AML_QWORD_PREFIX 0x0e
|
|
||||||
#define AML_SCOPE_OP 0x10
|
|
||||||
#define AML_BUFFER_OP 0x11
|
|
||||||
#define AML_PACKAGE_OP 0x12
|
|
||||||
#define AML_VAR_PACKAGE_OP 0x13
|
|
||||||
#define AML_METHOD_OP 0x14
|
|
||||||
#define AML_EXTERNAL_OP 0x15
|
|
||||||
#define AML_DUAL_NAME_PREFIX 0x2e
|
|
||||||
#define AML_MULTI_NAME_PREFIX 0x2f
|
|
||||||
#define AML_NAME_CHAR_A 0x41
|
|
||||||
#define AML_NAME_CHAR_B 0x42
|
|
||||||
#define AML_NAME_CHAR_C 0x43
|
|
||||||
#define AML_NAME_CHAR_D 0x44
|
|
||||||
#define AML_NAME_CHAR_E 0x45
|
|
||||||
#define AML_NAME_CHAR_F 0x46
|
|
||||||
#define AML_NAME_CHAR_G 0x47
|
|
||||||
#define AML_NAME_CHAR_H 0x48
|
|
||||||
#define AML_NAME_CHAR_I 0x49
|
|
||||||
#define AML_NAME_CHAR_J 0x4a
|
|
||||||
#define AML_NAME_CHAR_K 0x4b
|
|
||||||
#define AML_NAME_CHAR_L 0x4c
|
|
||||||
#define AML_NAME_CHAR_M 0x4d
|
|
||||||
#define AML_NAME_CHAR_N 0x4e
|
|
||||||
#define AML_NAME_CHAR_O 0x4f
|
|
||||||
#define AML_NAME_CHAR_P 0x50
|
|
||||||
#define AML_NAME_CHAR_Q 0x51
|
|
||||||
#define AML_NAME_CHAR_R 0x52
|
|
||||||
#define AML_NAME_CHAR_S 0x53
|
|
||||||
#define AML_NAME_CHAR_T 0x54
|
|
||||||
#define AML_NAME_CHAR_U 0x55
|
|
||||||
#define AML_NAME_CHAR_V 0x56
|
|
||||||
#define AML_NAME_CHAR_W 0x57
|
|
||||||
#define AML_NAME_CHAR_X 0x58
|
|
||||||
#define AML_NAME_CHAR_Y 0x59
|
|
||||||
#define AML_NAME_CHAR_Z 0x5a
|
|
||||||
#define AML_ROOT_CHAR 0x5c
|
|
||||||
#define AML_PARENT_PREFIX_CHAR 0x5e
|
|
||||||
#define AML_NAME_CHAR__ 0x5f
|
|
||||||
#define AML_LOCAL0 0x60
|
|
||||||
#define AML_LOCAL1 0x61
|
|
||||||
#define AML_LOCAL2 0x62
|
|
||||||
#define AML_LOCAL3 0x63
|
|
||||||
#define AML_LOCAL4 0x64
|
|
||||||
#define AML_LOCAL5 0x65
|
|
||||||
#define AML_LOCAL6 0x66
|
|
||||||
#define AML_LOCAL7 0x67
|
|
||||||
#define AML_ARG0 0x68
|
|
||||||
#define AML_ARG1 0x69
|
|
||||||
#define AML_ARG2 0x6a
|
|
||||||
#define AML_ARG3 0x6b
|
|
||||||
#define AML_ARG4 0x6c
|
|
||||||
#define AML_ARG5 0x6d
|
|
||||||
#define AML_ARG6 0x6e
|
|
||||||
#define AML_STORE_OP 0x70
|
|
||||||
#define AML_REF_OF_OP 0x71
|
|
||||||
#define AML_ADD_OP 0x72
|
|
||||||
#define AML_CONCAT_OP 0x73
|
|
||||||
#define AML_SUBTRACT_OP 0x74
|
|
||||||
#define AML_INCREMENT_OP 0x75
|
|
||||||
#define AML_DECREMENT_OP 0x76
|
|
||||||
#define AML_MULTIPLY_OP 0x77
|
|
||||||
#define AML_DIVIDE_OP 0x78
|
|
||||||
#define AML_SHIFT_LEFT_OP 0x79
|
|
||||||
#define AML_SHIFT_RIGHT_OP 0x7a
|
|
||||||
#define AML_AND_OP 0x7b
|
|
||||||
#define AML_NAND_OP 0x7c
|
|
||||||
#define AML_OR_OP 0x7d
|
|
||||||
#define AML_NOR_OP 0x7e
|
|
||||||
#define AML_XOR_OP 0x7f
|
|
||||||
#define AML_NOT_OP 0x80
|
|
||||||
#define AML_FIND_SET_LEFT_BIT_OP 0x81
|
|
||||||
#define AML_FIND_SET_RIGHT_BIT_OP 0x82
|
|
||||||
#define AML_DEREF_OF_OP 0x83
|
|
||||||
#define AML_CONCAT_RES_OP 0x84
|
|
||||||
#define AML_MOD_OP 0x85
|
|
||||||
#define AML_NOTIFY_OP 0x86
|
|
||||||
#define AML_SIZE_OF_OP 0x87
|
|
||||||
#define AML_INDEX_OP 0x88
|
|
||||||
#define AML_MATCH_OP 0x89
|
|
||||||
#define AML_CREATE_DWORD_FIELD_OP 0x8a
|
|
||||||
#define AML_CREATE_WORD_FIELD_OP 0x8b
|
|
||||||
#define AML_CREATE_BYTE_FIELD_OP 0x8c
|
|
||||||
#define AML_CREATE_BIT_FIELD_OP 0x8d
|
|
||||||
#define AML_OBJECT_TYPE_OP 0x8e
|
|
||||||
#define AML_CREATE_QWORD_FIELD_OP 0x8f
|
|
||||||
#define AML_LAND_OP 0x90
|
|
||||||
#define AML_LOR_OP 0x91
|
|
||||||
#define AML_LNOT_OP 0x92
|
|
||||||
#define AML_LEQUAL_OP 0x93
|
|
||||||
#define AML_LGREATER_OP 0x94
|
|
||||||
#define AML_LLESS_OP 0x95
|
|
||||||
#define AML_TO_BUFFER_OP 0x96
|
|
||||||
#define AML_TO_DEC_STRING_OP 0x97
|
|
||||||
#define AML_TO_HEX_STRING_OP 0x98
|
|
||||||
#define AML_TO_INTEGER_OP 0x99
|
|
||||||
#define AML_TO_STRING_OP 0x9c
|
|
||||||
#define AML_COPY_OBJECT_OP 0x9d
|
|
||||||
#define AML_MID_OP 0x9e
|
|
||||||
#define AML_CONTINUE_OP 0x9f
|
|
||||||
#define AML_IF_OP 0xa0
|
|
||||||
#define AML_ELSE_OP 0xa1
|
|
||||||
#define AML_WHILE_OP 0xa2
|
|
||||||
#define AML_NOOP_OP 0xa3
|
|
||||||
#define AML_RETURN_OP 0xa4
|
|
||||||
#define AML_BREAK_OP 0xa5
|
|
||||||
#define AML_BREAK_POINT_OP 0xcc
|
|
||||||
#define AML_ONES_OP 0xff
|
|
||||||
|
|
||||||
//
|
|
||||||
// Extended OpCode
|
|
||||||
//
|
|
||||||
#define AML_EXT_OP 0x5b
|
|
||||||
|
|
||||||
#define AML_EXT_MUTEX_OP 0x01
|
|
||||||
#define AML_EXT_EVENT_OP 0x02
|
|
||||||
#define AML_EXT_COND_REF_OF_OP 0x12
|
|
||||||
#define AML_EXT_CREATE_FIELD_OP 0x13
|
|
||||||
#define AML_EXT_LOAD_TABLE_OP 0x1f
|
|
||||||
#define AML_EXT_LOAD_OP 0x20
|
|
||||||
#define AML_EXT_STALL_OP 0x21
|
|
||||||
#define AML_EXT_SLEEP_OP 0x22
|
|
||||||
#define AML_EXT_ACQUIRE_OP 0x23
|
|
||||||
#define AML_EXT_SIGNAL_OP 0x24
|
|
||||||
#define AML_EXT_WAIT_OP 0x25
|
|
||||||
#define AML_EXT_RESET_OP 0x26
|
|
||||||
#define AML_EXT_RELEASE_OP 0x27
|
|
||||||
#define AML_EXT_FROM_BCD_OP 0x28
|
|
||||||
#define AML_EXT_TO_BCD_OP 0x29
|
|
||||||
#define AML_EXT_UNLOAD_OP 0x2a
|
|
||||||
#define AML_EXT_REVISION_OP 0x30
|
|
||||||
#define AML_EXT_DEBUG_OP 0x31
|
|
||||||
#define AML_EXT_FATAL_OP 0x32
|
|
||||||
#define AML_EXT_TIMER_OP 0x33
|
|
||||||
#define AML_EXT_REGION_OP 0x80
|
|
||||||
#define AML_EXT_FIELD_OP 0x81
|
|
||||||
#define AML_EXT_DEVICE_OP 0x82
|
|
||||||
#define AML_EXT_PROCESSOR_OP 0x83
|
|
||||||
#define AML_EXT_POWER_RES_OP 0x84
|
|
||||||
#define AML_EXT_THERMAL_ZONE_OP 0x85
|
|
||||||
#define AML_EXT_INDEX_FIELD_OP 0x86
|
|
||||||
#define AML_EXT_BANK_FIELD_OP 0x87
|
|
||||||
#define AML_EXT_DATA_REGION_OP 0x88
|
|
||||||
|
|
||||||
//
|
|
||||||
// FieldElement OpCode
|
|
||||||
//
|
|
||||||
#define AML_FIELD_RESERVED_OP 0x00
|
|
||||||
#define AML_FIELD_ACCESS_OP 0x01
|
|
||||||
#define AML_FIELD_CONNECTION_OP 0x02
|
|
||||||
#define AML_FIELD_EXT_ACCESS_OP 0x03
|
|
||||||
|
|
||||||
//
|
|
||||||
// AML Name segment definitions
|
|
||||||
//
|
|
||||||
#define AML_NAME_SEG_SIZE 4
|
|
||||||
|
|
||||||
typedef enum parse_status(*aml_bytecode_parser)(struct aml_parser *, struct aml_value *);
|
|
||||||
|
|
||||||
struct aml_byte_encoding {
|
|
||||||
uint8_t opcode;
|
|
||||||
uint8_t sub_opcode;
|
|
||||||
|
|
||||||
aml_bytecode_parser parser;
|
|
||||||
|
|
||||||
const char *name;
|
|
||||||
};
|
|
||||||
|
|
||||||
extern enum parse_status parse_opcode(struct aml_parser *parser, struct aml_value *out);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,290 +0,0 @@
|
|||||||
#include <string.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include "parser.h"
|
|
||||||
#include "opcode.h"
|
|
||||||
#include "object.h"
|
|
||||||
#include "value.h"
|
|
||||||
#include "../table.h"
|
|
||||||
|
|
||||||
void aml_parser_init(struct aml_parser *parser, void *p, size_t len)
|
|
||||||
{
|
|
||||||
memset(parser, 0x0, sizeof *parser);
|
|
||||||
|
|
||||||
parser->start = parser->ptr = p;
|
|
||||||
parser->end = parser->start + len;
|
|
||||||
}
|
|
||||||
|
|
||||||
void aml_parser_set_namespace(struct aml_parser *parser, struct acpi_namespace *ns)
|
|
||||||
{
|
|
||||||
parser->ns = ns;
|
|
||||||
}
|
|
||||||
|
|
||||||
int aml_parser_peek(struct aml_parser *parser)
|
|
||||||
{
|
|
||||||
if (parser->ptr >= parser->end) {
|
|
||||||
return PARSE_EOF;
|
|
||||||
}
|
|
||||||
|
|
||||||
return *parser->ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
int aml_parser_peek_next(struct aml_parser *parser)
|
|
||||||
{
|
|
||||||
if (parser->ptr + 1 >= parser->end) {
|
|
||||||
return PARSE_EOF;
|
|
||||||
}
|
|
||||||
|
|
||||||
return *(parser->ptr + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
int aml_parser_advance(struct aml_parser *parser)
|
|
||||||
{
|
|
||||||
if (parser->ptr >= parser->end) {
|
|
||||||
return PARSE_EOF;
|
|
||||||
}
|
|
||||||
|
|
||||||
return *(parser->ptr++);
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int aml_parser_cursorpos(struct aml_parser *parser)
|
|
||||||
{
|
|
||||||
if (parser->ptr < parser->start) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return parser->ptr - parser->start;
|
|
||||||
}
|
|
||||||
|
|
||||||
void aml_parser_save_cursor(struct aml_parser *parser)
|
|
||||||
{
|
|
||||||
parser->saved_ptr = parser->ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
void aml_parser_load_cursor(struct aml_parser *parser)
|
|
||||||
{
|
|
||||||
parser->ptr = parser->saved_ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool object_name_is_always_root(const char *name)
|
|
||||||
{
|
|
||||||
return (!strcmp(name, "_SB_") || !strcmp(name, "GPE_") || !strcmp(name, "_PR_") || !strcmp(name, "_TZ_"));
|
|
||||||
}
|
|
||||||
|
|
||||||
void aml_parser_add_object(struct aml_parser *parser, struct acpi_object *object)
|
|
||||||
{
|
|
||||||
if (object->parent) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
char *publish_path = object->publish_path;
|
|
||||||
char *rpath = publish_path;
|
|
||||||
|
|
||||||
//printf("adding object '%s'. current scope=%s\n", publish_path, parser->cur_scope ? parser->cur_scope->scope_object->name : "<none>");
|
|
||||||
|
|
||||||
struct acpi_object *cur = parser->cur_scope ? parser->cur_scope->scope_object : NULL;
|
|
||||||
if (*rpath == '\\') {
|
|
||||||
cur = parser->ns->root;
|
|
||||||
rpath++;
|
|
||||||
}
|
|
||||||
|
|
||||||
char *sp;
|
|
||||||
char *tok = strtok_r(rpath, ".", &sp);
|
|
||||||
if (object_name_is_always_root(tok)) {
|
|
||||||
cur = parser->ns->root;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!cur) {
|
|
||||||
fprintf(stderr, "cannot add object with relative path: no scope!\n");
|
|
||||||
abort();
|
|
||||||
}
|
|
||||||
|
|
||||||
while (1) {
|
|
||||||
if (!tok || *tok == '\0') {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
char *next_tok = strtok_r(NULL, ".", &sp);
|
|
||||||
if (!next_tok) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct acpi_object *next = acpi_object_get_child(cur, tok);
|
|
||||||
if (!next) {
|
|
||||||
//printf("auto-creating scope '%s' under '%s'\n", tok, cur->name);
|
|
||||||
next = acpi_object_create(tok, ACPI_OBJECT_NAMESPACE);
|
|
||||||
acpi_object_add_child(cur, next);
|
|
||||||
}
|
|
||||||
|
|
||||||
tok = next_tok;
|
|
||||||
cur = next;
|
|
||||||
}
|
|
||||||
|
|
||||||
strncpy(object->name, tok, sizeof object->name - 1);
|
|
||||||
object->name[sizeof object->name - 1] = '\0';
|
|
||||||
|
|
||||||
acpi_object_add_child(cur, object);
|
|
||||||
free(publish_path);
|
|
||||||
}
|
|
||||||
|
|
||||||
void aml_parser_push_scope(struct aml_parser *parser, struct acpi_object *object)
|
|
||||||
{
|
|
||||||
struct aml_parser_scope *scope = malloc(sizeof *scope);
|
|
||||||
if (!scope) {
|
|
||||||
perror("aml_parser_push_scope: malloc");
|
|
||||||
abort();
|
|
||||||
}
|
|
||||||
|
|
||||||
scope->scope_object = object;
|
|
||||||
scope->scope_end = object->scope_end;
|
|
||||||
scope->next = parser->cur_scope;
|
|
||||||
object->scope_end = 0;
|
|
||||||
parser->cur_scope = scope;
|
|
||||||
|
|
||||||
//printf("## 0x%04x: moving into scope '%s' (ends at 0x%04zx)\n", aml_parser_cursorpos(parser), parser->cur_scope->scope_object->name, scope->scope_end);
|
|
||||||
}
|
|
||||||
|
|
||||||
void aml_parser_pop_scope(struct aml_parser *parser)
|
|
||||||
{
|
|
||||||
if (!parser->cur_scope) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!strcmp(parser->cur_scope->scope_object->name, "\\") && !parser->cur_scope->next) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
printf("## 0x%04x: moving out of scope '%s' up to scope '%s' (ends at 0x%04zx)\n",
|
|
||||||
aml_parser_cursorpos(parser),
|
|
||||||
parser->cur_scope ? parser->cur_scope->scope_object->name : "<none>",
|
|
||||||
parser->cur_scope->next ? parser->cur_scope->next->scope_object->name : "<none>",
|
|
||||||
parser->cur_scope->next ? parser->cur_scope->next->scope_end : 0xFFFF);
|
|
||||||
*/
|
|
||||||
|
|
||||||
struct aml_parser_scope *previous_scope = parser->cur_scope;
|
|
||||||
parser->cur_scope = parser->cur_scope->next;
|
|
||||||
free(previous_scope);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void add_object_to_parser(struct aml_parser *parser, struct acpi_object *object)
|
|
||||||
{
|
|
||||||
if (!object->parent && object != parser->ns->root) {
|
|
||||||
aml_parser_add_object(parser, object);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (object->scope_end != 0) {
|
|
||||||
aml_parser_push_scope(parser, object);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool should_pop_current_scope(struct aml_parser *parser)
|
|
||||||
{
|
|
||||||
if (!parser->cur_scope) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!strcmp(parser->cur_scope->scope_object->name, "\\") && !parser->cur_scope->next) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return parser->cur_scope->scope_end <= aml_parser_cursorpos(parser);
|
|
||||||
}
|
|
||||||
|
|
||||||
enum parse_status aml_parser_parse_into_namespace(struct aml_parser *parser, struct acpi_namespace *ns)
|
|
||||||
{
|
|
||||||
parser->ns = ns;
|
|
||||||
aml_parser_push_scope(parser, ns->root);
|
|
||||||
enum parse_status status = PARSE_OK;
|
|
||||||
|
|
||||||
while (1) {
|
|
||||||
struct aml_value value;
|
|
||||||
status = parse_opcode(parser, &value);
|
|
||||||
if (status != PARSE_OK) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (value.type == AML_VALUE_OBJECT) {
|
|
||||||
struct acpi_object *object = value.value.object;
|
|
||||||
add_object_to_parser(parser, object);
|
|
||||||
}
|
|
||||||
|
|
||||||
while (should_pop_current_scope(parser)) {
|
|
||||||
aml_parser_pop_scope(parser);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (status == PARSE_EOF && !parser->cur_scope->next) {
|
|
||||||
status = PARSE_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (status != PARSE_OK) {
|
|
||||||
fprintf(stderr, "parse error at 0x%04lx: %s\n",
|
|
||||||
aml_parser_cursorpos(parser) + sizeof(struct acpi_table), parse_status_string(status));
|
|
||||||
}
|
|
||||||
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct acpi_object *aml_parser_resolve_path(struct aml_parser *parser, const char *path)
|
|
||||||
{
|
|
||||||
struct acpi_object *cur = parser->cur_scope ? parser->cur_scope->scope_object : NULL;
|
|
||||||
if (*path == '\\') {
|
|
||||||
path++;
|
|
||||||
cur = parser->ns->root;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t path_len = strlen(path);
|
|
||||||
char *rpath = malloc(path_len + 1);
|
|
||||||
char *token_buf = rpath;
|
|
||||||
strcpy(rpath, path);
|
|
||||||
|
|
||||||
while (*token_buf == '^') {
|
|
||||||
cur = cur->parent;
|
|
||||||
token_buf++;
|
|
||||||
}
|
|
||||||
|
|
||||||
char *sp;
|
|
||||||
char *tok = strtok_r(token_buf, ".", &sp);
|
|
||||||
if (tok && object_name_is_always_root(tok)) {
|
|
||||||
cur = parser->ns->root;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!cur) {
|
|
||||||
free(rpath);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (tok) {
|
|
||||||
struct acpi_object *child = acpi_object_get_child(cur, tok);
|
|
||||||
if (!child) {
|
|
||||||
free(rpath);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
cur = child;
|
|
||||||
tok = strtok_r(NULL, ".", &sp);
|
|
||||||
}
|
|
||||||
|
|
||||||
free(rpath);
|
|
||||||
return cur;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define STATUS_STRING(code) \
|
|
||||||
case code: \
|
|
||||||
return #code;
|
|
||||||
|
|
||||||
const char *parse_status_string(enum parse_status status)
|
|
||||||
{
|
|
||||||
switch (status) {
|
|
||||||
STATUS_STRING(PARSE_OK)
|
|
||||||
STATUS_STRING(PARSE_EOF)
|
|
||||||
STATUS_STRING(PARSE_NOMEM)
|
|
||||||
STATUS_STRING(PARSE_BADSTRING)
|
|
||||||
STATUS_STRING(PARSE_UNKNOWNOP)
|
|
||||||
STATUS_STRING(PARSE_BADTYPE)
|
|
||||||
STATUS_STRING(PARSE_BADREF)
|
|
||||||
default:
|
|
||||||
return "<unknown>";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
#ifndef AML_PARSER_H_
|
|
||||||
#define AML_PARSER_H_
|
|
||||||
|
|
||||||
#include <stddef.h>
|
|
||||||
|
|
||||||
struct acpi_namespace;
|
|
||||||
|
|
||||||
enum parse_status {
|
|
||||||
PARSE_OK = 0,
|
|
||||||
PARSE_EOF = -1,
|
|
||||||
PARSE_NOMEM = -2,
|
|
||||||
PARSE_BADSTRING = -3,
|
|
||||||
PARSE_UNKNOWNOP = -4,
|
|
||||||
PARSE_BADTYPE = -5,
|
|
||||||
PARSE_BADREF = -6,
|
|
||||||
};
|
|
||||||
|
|
||||||
struct aml_parser_scope {
|
|
||||||
struct acpi_object *scope_object;
|
|
||||||
size_t scope_end;
|
|
||||||
struct aml_parser_scope *next;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct aml_parser {
|
|
||||||
int revision;
|
|
||||||
unsigned char *start, *end;
|
|
||||||
unsigned char *ptr, *saved_ptr;
|
|
||||||
struct acpi_namespace *ns;
|
|
||||||
struct aml_parser_scope *cur_scope;
|
|
||||||
};
|
|
||||||
|
|
||||||
extern void aml_parser_init(struct aml_parser *parser, void *p, size_t len);
|
|
||||||
extern void aml_parser_set_namespace(struct aml_parser *parser, struct acpi_namespace *ns);
|
|
||||||
extern int aml_parser_peek(struct aml_parser *parser);
|
|
||||||
extern int aml_parser_peek_next(struct aml_parser *parser);
|
|
||||||
extern int aml_parser_advance(struct aml_parser *parser);
|
|
||||||
extern unsigned int aml_parser_cursorpos(struct aml_parser *parser);
|
|
||||||
extern void aml_parser_save_cursor(struct aml_parser *parser);
|
|
||||||
extern void aml_parser_load_cursor(struct aml_parser *parser);
|
|
||||||
extern void aml_parser_add_object(struct aml_parser *parser, struct acpi_object *object);
|
|
||||||
extern void aml_parser_push_scope(struct aml_parser *parser, struct acpi_object *object);
|
|
||||||
extern void aml_parser_pop_scope(struct aml_parser *parser);
|
|
||||||
|
|
||||||
extern enum parse_status aml_parser_parse_into_namespace(struct aml_parser *parser, struct acpi_namespace *ns);
|
|
||||||
extern struct acpi_object *aml_parser_resolve_path(struct aml_parser *parser, const char *path);
|
|
||||||
|
|
||||||
extern const char *parse_status_string(enum parse_status status);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
#include "value.h"
|
|
||||||
|
|
||||||
uint64_t aml_value_get_integer(const struct aml_value *value)
|
|
||||||
{
|
|
||||||
switch (value->type) {
|
|
||||||
case AML_VALUE_UINT8:
|
|
||||||
return value->value.uint8;
|
|
||||||
case AML_VALUE_UINT16:
|
|
||||||
return value->value.uint8;
|
|
||||||
case AML_VALUE_UINT32:
|
|
||||||
return value->value.uint8;
|
|
||||||
case AML_VALUE_UINT64:
|
|
||||||
return value->value.uint8;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,47 +0,0 @@
|
|||||||
#ifndef AML_VALUE_H_
|
|
||||||
#define AML_VALUE_H_
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include "constants.h"
|
|
||||||
|
|
||||||
struct acpi_object;
|
|
||||||
|
|
||||||
enum aml_value_type {
|
|
||||||
AML_VALUE_NONE,
|
|
||||||
AML_VALUE_UINT8,
|
|
||||||
AML_VALUE_UINT16,
|
|
||||||
AML_VALUE_UINT32,
|
|
||||||
AML_VALUE_UINT64,
|
|
||||||
AML_VALUE_OBJECT,
|
|
||||||
AML_VALUE_NAME,
|
|
||||||
AML_VALUE_STRING,
|
|
||||||
};
|
|
||||||
|
|
||||||
struct aml_value {
|
|
||||||
enum aml_value_type type;
|
|
||||||
|
|
||||||
union {
|
|
||||||
uint8_t uint8;
|
|
||||||
uint16_t uint16;
|
|
||||||
uint32_t uint32;
|
|
||||||
uint64_t uint64;
|
|
||||||
struct acpi_object *object;
|
|
||||||
const char *name;
|
|
||||||
const char *str;
|
|
||||||
} value;
|
|
||||||
};
|
|
||||||
|
|
||||||
static inline bool aml_value_is_integer(const struct aml_value *value)
|
|
||||||
{
|
|
||||||
return value->type == AML_VALUE_UINT8 || value->type == AML_VALUE_UINT16 || value->type == AML_VALUE_UINT32 || value->type == AML_VALUE_UINT64;
|
|
||||||
}
|
|
||||||
static inline bool aml_value_is_name(const struct aml_value *value)
|
|
||||||
{
|
|
||||||
return value->type == AML_VALUE_NAME;
|
|
||||||
}
|
|
||||||
|
|
||||||
extern uint64_t aml_value_get_integer(const struct aml_value *value);
|
|
||||||
extern void aml_value_destroy(struct aml_value *value);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,155 +0,0 @@
|
|||||||
#include <stdio.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include "aml/parser.h"
|
|
||||||
#include "aml/object.h"
|
|
||||||
#include "table.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
static struct acpi_table_header *read_table(FILE *fp)
|
|
||||||
{
|
|
||||||
fseek(fp, 0, SEEK_END);
|
|
||||||
size_t len = ftell(fp);
|
|
||||||
fseek(fp, 0, SEEK_SET);
|
|
||||||
|
|
||||||
struct acpi_table_header *table = malloc(len);
|
|
||||||
if (!table) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
fread(table, 1, len, fp);
|
|
||||||
|
|
||||||
return table;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, const char **argv)
|
|
||||||
{
|
|
||||||
if (argc < 2) {
|
|
||||||
fprintf(stderr, "usage: %s <AML file>\n", argv[0]);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *filepath = argv[1];
|
|
||||||
FILE *fp = fopen(filepath, "rb");
|
|
||||||
if (!fp) {
|
|
||||||
perror("open");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct acpi_table_header *table = read_table(fp);
|
|
||||||
fclose(fp);
|
|
||||||
|
|
||||||
if (!table) {
|
|
||||||
perror("read_table");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct aml_object *root;
|
|
||||||
|
|
||||||
parse_aml(table, &root);
|
|
||||||
|
|
||||||
printf("\n\n");
|
|
||||||
aml_object_print(root, 0);
|
|
||||||
free(table);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
static struct acpi_namespace *create_test_namespace(void)
|
|
||||||
{
|
|
||||||
struct acpi_namespace *ns = acpi_namespace_create();
|
|
||||||
|
|
||||||
struct acpi_object *root = acpi_object_create("\\", ACPI_OBJECT_NAMESPACE);
|
|
||||||
ns->root = root;
|
|
||||||
|
|
||||||
struct acpi_object *pr = acpi_object_create("_PR", ACPI_OBJECT_NAMESPACE);
|
|
||||||
struct acpi_object *cpu0 = acpi_object_create("CPU0", ACPI_OBJECT_CPU);
|
|
||||||
acpi_object_add_child(pr, cpu0);
|
|
||||||
|
|
||||||
struct acpi_object *sb = acpi_object_create("_SB", ACPI_OBJECT_NAMESPACE);
|
|
||||||
struct acpi_object *lid0 = acpi_object_create("LID0", ACPI_OBJECT_DEVICE);
|
|
||||||
struct acpi_object *lid0_hid = acpi_object_create("_HID", ACPI_OBJECT_VALUE);
|
|
||||||
struct acpi_object *lid0_sta = acpi_object_create("_STA", ACPI_OBJECT_METHOD);
|
|
||||||
acpi_object_add_child(lid0, lid0_hid);
|
|
||||||
acpi_object_add_child(lid0, lid0_sta);
|
|
||||||
|
|
||||||
struct acpi_object *pci0 = acpi_object_create("PCI0", ACPI_OBJECT_DEVICE);
|
|
||||||
struct acpi_object *pci0_hid = acpi_object_create("_HID", ACPI_OBJECT_VALUE);
|
|
||||||
struct acpi_object *pci0_cid = acpi_object_create("_CID", ACPI_OBJECT_VALUE);
|
|
||||||
struct acpi_object *pci0_rp03 = acpi_object_create("RP03", ACPI_OBJECT_NAMESPACE);
|
|
||||||
struct acpi_object *pci0_rp03_pxp3 = acpi_object_create("PXP3", ACPI_OBJECT_POWER_RESOURCE);
|
|
||||||
struct acpi_object *pci0_gfx0 = acpi_object_create("GFX0", ACPI_OBJECT_DEVICE);
|
|
||||||
struct acpi_object *pci0_gfx0_adr = acpi_object_create("_ADR", ACPI_OBJECT_VALUE);
|
|
||||||
struct acpi_object *pci0_gfx0_dd01 = acpi_object_create("DD01", ACPI_OBJECT_DEVICE);
|
|
||||||
struct acpi_object *pci0_gfx0_dd01_bcl = acpi_object_create("_BCL", ACPI_OBJECT_METHOD);
|
|
||||||
acpi_object_add_child(pci0_gfx0_dd01, pci0_gfx0_dd01_bcl);
|
|
||||||
acpi_object_add_child(pci0_gfx0, pci0_gfx0_adr);
|
|
||||||
acpi_object_add_child(pci0_gfx0, pci0_gfx0_dd01);
|
|
||||||
acpi_object_add_child(pci0_rp03, pci0_rp03_pxp3);
|
|
||||||
acpi_object_add_child(pci0, pci0_hid);
|
|
||||||
acpi_object_add_child(pci0, pci0_cid);
|
|
||||||
acpi_object_add_child(pci0, pci0_rp03);
|
|
||||||
acpi_object_add_child(pci0, pci0_gfx0);
|
|
||||||
|
|
||||||
acpi_object_add_child(sb, lid0);
|
|
||||||
acpi_object_add_child(sb, pci0);
|
|
||||||
|
|
||||||
struct acpi_object *tz = acpi_object_create("_TZ", ACPI_OBJECT_NAMESPACE);
|
|
||||||
struct acpi_object *tz_fn00 = acpi_object_create("FN00", ACPI_OBJECT_POWER_RESOURCE);
|
|
||||||
struct acpi_object *tz_fan0 = acpi_object_create("FAN0", ACPI_OBJECT_DEVICE);
|
|
||||||
struct acpi_object *tz_fan0_hid = acpi_object_create("_HID", ACPI_OBJECT_VALUE);
|
|
||||||
struct acpi_object *tz_tz00 = acpi_object_create("TZ00", ACPI_OBJECT_THERMAL_ZONE);
|
|
||||||
acpi_object_add_child(tz_fan0, tz_fan0_hid);
|
|
||||||
acpi_object_add_child(tz, tz_fn00);
|
|
||||||
acpi_object_add_child(tz, tz_fan0);
|
|
||||||
acpi_object_add_child(tz, tz_tz00);
|
|
||||||
|
|
||||||
struct acpi_object *gpe = acpi_object_create("_GPE", ACPI_OBJECT_NAMESPACE);
|
|
||||||
|
|
||||||
acpi_object_add_child(root, pr);
|
|
||||||
acpi_object_add_child(root, sb);
|
|
||||||
acpi_object_add_child(root, tz);
|
|
||||||
acpi_object_add_child(root, gpe);
|
|
||||||
|
|
||||||
return ns;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
int main(int argc, const char **argv)
|
|
||||||
{
|
|
||||||
if (argc < 2) {
|
|
||||||
fprintf(stderr, "usage: %s <AML file>\n", argv[0]);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct acpi_table *table;
|
|
||||||
enum loader_status loader_status = acpi_table_load(argv[1], &table);
|
|
||||||
if (loader_status != LOADER_OK) {
|
|
||||||
fprintf(stderr, "cannot load '%s': %s\n", argv[1], loader_status_string(loader_status));
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void *table_payload;
|
|
||||||
size_t payload_len;
|
|
||||||
acpi_table_get_payload(table, &table_payload, &payload_len);
|
|
||||||
|
|
||||||
struct acpi_namespace *ns = acpi_namespace_create();
|
|
||||||
|
|
||||||
struct aml_parser parser;
|
|
||||||
aml_parser_init(&parser, table_payload, payload_len);
|
|
||||||
parser.revision = table->revision;
|
|
||||||
|
|
||||||
enum parse_status parser_status = aml_parser_parse_into_namespace(&parser, ns);
|
|
||||||
if (parser_status != PARSE_OK) {
|
|
||||||
fprintf(stderr, "error occurred while parsing '%s': %s\n", argv[1], parse_status_string(parser_status));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ns->root) {
|
|
||||||
acpi_object_print(ns->root, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
acpi_table_destroy(table);
|
|
||||||
return parser_status == PARSE_OK ? 0 : -1;
|
|
||||||
}
|
|
||||||
@@ -1,72 +0,0 @@
|
|||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include "table.h"
|
|
||||||
|
|
||||||
enum loader_status acpi_table_load(const char *path, struct acpi_table **out)
|
|
||||||
{
|
|
||||||
FILE *fp = fopen(path, "rb");
|
|
||||||
if (!fp) {
|
|
||||||
return LOADER_IOERR;
|
|
||||||
}
|
|
||||||
|
|
||||||
fseek(fp, 0, SEEK_END);
|
|
||||||
size_t len = ftell(fp);
|
|
||||||
fseek(fp, 0, SEEK_SET);
|
|
||||||
|
|
||||||
unsigned char *buf = malloc(len);
|
|
||||||
if (!buf) {
|
|
||||||
fclose(fp);
|
|
||||||
return LOADER_NOMEM;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t r = fread(buf, 1, len, fp);
|
|
||||||
if (r != len) {
|
|
||||||
free(buf);
|
|
||||||
fclose(fp);
|
|
||||||
return LOADER_IOERR;
|
|
||||||
}
|
|
||||||
|
|
||||||
fclose(fp);
|
|
||||||
|
|
||||||
size_t sum = 0;
|
|
||||||
for (size_t i = 0; i < len; i++) {
|
|
||||||
sum += buf[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((sum % 0x100) != 0) {
|
|
||||||
free(buf);
|
|
||||||
return LOADER_BADSUM;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct acpi_table *table = (struct acpi_table *)buf;
|
|
||||||
*out = table;
|
|
||||||
|
|
||||||
return LOADER_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
void acpi_table_destroy(struct acpi_table *table)
|
|
||||||
{
|
|
||||||
free(table);
|
|
||||||
}
|
|
||||||
|
|
||||||
void acpi_table_get_payload(struct acpi_table *table, void **p, size_t *len)
|
|
||||||
{
|
|
||||||
*p = (unsigned char *)table + sizeof *table;
|
|
||||||
*len = table->length;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define STATUS_STRING(code) \
|
|
||||||
case code: \
|
|
||||||
return #code;
|
|
||||||
|
|
||||||
const char *loader_status_string(enum loader_status status)
|
|
||||||
{
|
|
||||||
switch (status) {
|
|
||||||
STATUS_STRING(LOADER_OK)
|
|
||||||
STATUS_STRING(LOADER_IOERR)
|
|
||||||
STATUS_STRING(LOADER_BADSUM)
|
|
||||||
STATUS_STRING(LOADER_NOMEM)
|
|
||||||
default:
|
|
||||||
return "<unknown>";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
#ifndef TABLE_H_
|
|
||||||
#define TABLE_H_
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <stddef.h>
|
|
||||||
|
|
||||||
enum loader_status {
|
|
||||||
LOADER_OK = 0,
|
|
||||||
LOADER_IOERR,
|
|
||||||
LOADER_BADSUM,
|
|
||||||
LOADER_NOMEM,
|
|
||||||
};
|
|
||||||
|
|
||||||
struct acpi_table {
|
|
||||||
char sig[4];
|
|
||||||
uint32_t length;
|
|
||||||
uint8_t revision;
|
|
||||||
uint8_t checksum;
|
|
||||||
char oem_id[6];
|
|
||||||
char oem_table_id[8];
|
|
||||||
uint32_t oem_revision;
|
|
||||||
uint32_t creator_id;
|
|
||||||
uint32_t creator_revision;
|
|
||||||
};
|
|
||||||
|
|
||||||
extern enum loader_status acpi_table_load(const char *path, struct acpi_table **out);
|
|
||||||
extern void acpi_table_destroy(struct acpi_table *table);
|
|
||||||
extern void acpi_table_get_payload(struct acpi_table *table, void **p, size_t *len);
|
|
||||||
|
|
||||||
extern const char *loader_status_string(enum loader_status status);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
Reference in New Issue
Block a user