2 * Copyright (C) 2013-2018, The AROS Development Team
4 * Author: Jason S. McMullan <jason.mcmullan@gmail.com>
6 * Licensed under the AROS PUBLIC LICENSE (APL) Version 1.1
11 #include <proto/exec.h>
12 #include <proto/dos.h>
13 #include <proto/acpica.h>
15 #define SH_GLOBAL_SYSBASE 1
16 #define SH_GLOBAL_DOSBASE 1
18 #include <aros/shcommands.h>
19 #include <acpica/acnames.h>
21 const char * const TypeMap
[ACPI_TYPE_EXTERNAL_MAX
+1] = {
41 ACPI_STATUS
OnDescend (
47 ACPI_BUFFER buffer
= { ACPI_ALLOCATE_BUFFER
, NULL
};
48 ACPI_PNP_DEVICE_ID_LIST
*cIdList
;
49 ACPI_DEVICE_INFO
*info
;
51 ACPI_PNP_DEVICE_ID
*pnpid
;
57 for (i
= 0; i
< NestingLevel
; i
++)
60 err
= AcpiGetObjectInfo(Object
, &info
);
64 (info
->Name
>> 24) & 0xff,
65 (info
->Name
>> 16) & 0xff,
66 (info
->Name
>> 8) & 0xff,
67 (info
->Name
>> 0) & 0xff);
68 if (info
->Type
> ACPI_TYPE_EXTERNAL_MAX
) {
69 Printf("Type%ld", info
->Type
);
71 Printf("%s", TypeMap
[info
->Type
]);
73 if (info
->Type
== ACPI_TYPE_METHOD
) {
74 Printf("(%ld)", info
->ParamCount
);
76 if (AcpiGetInfoFlags(info
) & ACPI_PCI_ROOT_BRIDGE
) {
77 Printf(" [PCI Root Bridge]");
81 addr
= AcpiGetInfoAddress(info
);
83 for (i
= 0; i
< NestingLevel
; i
++)
85 Printf(" %s: 0x%llx\n", METHOD_NAME__ADR
, addr
);
88 pnpid
= AcpiGetInfoHardwareId(info
);
90 for (i
= 0; i
< NestingLevel
; i
++)
92 Printf(" %s: %s\n", METHOD_NAME__HID
, pnpid
->String
);
95 pnpid
= AcpiGetInfoUniqueId(info
);
97 for (i
= 0; i
< NestingLevel
; i
++)
99 Printf(" %s: %s\n", METHOD_NAME__UID
, pnpid
->String
);
102 cIdList
= AcpiGetInfoCompatIdList(info
);
104 for (i
= 0; i
< NestingLevel
; i
++)
106 Printf(" %s: [", METHOD_NAME__CID
);
107 for (i
= 0; i
< cIdList
->Count
; i
++) {
108 Printf(" %s", cIdList
->Ids
[i
].String
);
113 dstates
= AcpiGetInfoHighDstates(info
);
115 for (i
= 0; i
< NestingLevel
; i
++)
118 for (i
= 0; i
< 4; i
++) {
119 if (dstates
[i
] != 0xff)
120 Printf(" %d", dstates
[i
]);
124 dstates
= AcpiGetInfoLowDstates(info
);
126 for (i
= 0; i
< NestingLevel
; i
++)
129 for (i
= 0; i
< 5; i
++) {
130 if (dstates
[i
] != 0xff)
131 Printf(" %d", dstates
[i
]);
136 err
= AcpiEvaluateObject (Object
, METHOD_NAME__SUB
,
138 if (ACPI_SUCCESS(err
)) {
139 obj
= buffer
.Pointer
;
141 if (obj
->Type
== ACPI_TYPE_STRING
)
143 Printf("%s: %s\n", METHOD_NAME__SUB
, obj
->String
.Pointer
);
145 FreeVec(buffer
.Pointer
);
149 buffer
.Pointer
= NULL
;
150 err
= AcpiEvaluateObject (Object
, METHOD_NAME__STA
,
152 if (ACPI_SUCCESS(err
)) {
153 obj
= buffer
.Pointer
;
155 for (i
= 0; i
< NestingLevel
; i
++)
157 Printf(" %s: [", METHOD_NAME__STA
);
158 if (obj
->Integer
.Value
& ACPI_STA_DEVICE_PRESENT
)
160 if (obj
->Integer
.Value
& ACPI_STA_DEVICE_ENABLED
)
162 if (obj
->Integer
.Value
& ACPI_STA_DEVICE_UI
)
164 if (obj
->Integer
.Value
& ACPI_STA_DEVICE_OK
)
166 if (obj
->Integer
.Value
& ACPI_STA_BATTERY_PRESENT
)
169 FreeVec(buffer
.Pointer
);
178 ACPI_STATUS
OnAscend (
184 /* Nothing at the moment */
189 AROS_SH0(ACPIInfo
, 1.0)
193 AcpiWalkNamespace(ACPI_TYPE_ANY
, ACPI_ROOT_OBJECT
, (UINT32
)~0, OnDescend
, OnAscend
, NULL
, NULL
);