revert between 56095 -> 55830 in arch
[AROS.git] / arch / all-pc / acpica / ACPIInfo.c
blob97cd936c2f3f9a2cba19fa7641d3d6e2bb26268f
1 /*
2 * Copyright (C) 2013-2018, The AROS Development Team
3 * All right reserved.
4 * Author: Jason S. McMullan <jason.mcmullan@gmail.com>
6 * Licensed under the AROS PUBLIC LICENSE (APL) Version 1.1
7 *
8 * $Id$
9 */
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] = {
22 "Any",
23 "Integer",
24 "String",
25 "Buffer",
26 "Package",
27 "FieldUnit",
28 "Device",
29 "Event",
30 "Method",
31 "Mutex",
32 "Region",
33 "Power",
34 "Processor",
35 "Thermal",
36 "BufferField",
37 "DDBHandle",
38 "DebugObject"
41 ACPI_STATUS OnDescend (
42 ACPI_HANDLE Object,
43 UINT32 NestingLevel,
44 void *Context,
45 void **ReturnValue)
47 ACPI_BUFFER buffer = { ACPI_ALLOCATE_BUFFER, NULL };
48 ACPI_PNP_DEVICE_ID_LIST *cIdList;
49 ACPI_DEVICE_INFO *info;
50 ACPI_OBJECT *obj;
51 ACPI_PNP_DEVICE_ID *pnpid;
52 ACPI_STATUS err;
53 UINT64 addr;
54 char *dstates;
55 int i;
57 for (i = 0; i < NestingLevel; i++)
58 Printf(" ");
60 err = AcpiGetObjectInfo(Object, &info);
61 if (err == AE_OK) {
63 Printf("%c%c%c%c.",
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);
70 } else {
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]");
79 Printf("\n");
81 addr = AcpiGetInfoAddress(info);
82 if (addr) {
83 for (i = 0; i < NestingLevel; i++)
84 Printf(" ");
85 Printf(" %s: 0x%llx\n", METHOD_NAME__ADR, addr);
88 pnpid = AcpiGetInfoHardwareId(info);
89 if (pnpid) {
90 for (i = 0; i < NestingLevel; i++)
91 Printf(" ");
92 Printf(" %s: %s\n", METHOD_NAME__HID, pnpid->String);
95 pnpid = AcpiGetInfoUniqueId(info);
96 if (pnpid) {
97 for (i = 0; i < NestingLevel; i++)
98 Printf(" ");
99 Printf(" %s: %s\n", METHOD_NAME__UID, pnpid->String);
102 cIdList = AcpiGetInfoCompatIdList(info);
103 if (cIdList) {
104 for (i = 0; i < NestingLevel; i++)
105 Printf(" ");
106 Printf(" %s: [", METHOD_NAME__CID);
107 for (i = 0; i < cIdList->Count; i++) {
108 Printf(" %s", cIdList->Ids[i].String);
110 Printf(" ]\n");
113 dstates = AcpiGetInfoHighDstates(info);
114 if (dstates) {
115 for (i = 0; i < NestingLevel; i++)
116 Printf(" ");
117 Printf(" _SxD:");
118 for (i = 0; i < 4; i++) {
119 if (dstates[i] != 0xff)
120 Printf(" %d", dstates[i]);
122 Printf("\n");
124 dstates = AcpiGetInfoLowDstates(info);
125 if (dstates) {
126 for (i = 0; i < NestingLevel; i++)
127 Printf(" ");
128 Printf(" _SxW:");
129 for (i = 0; i < 5; i++) {
130 if (dstates[i] != 0xff)
131 Printf(" %d", dstates[i]);
133 Printf("\n");
136 err = AcpiEvaluateObject (Object, METHOD_NAME__SUB,
137 NULL, &buffer);
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);
148 #if (0)
149 buffer.Pointer = NULL;
150 err = AcpiEvaluateObject (Object, METHOD_NAME__STA,
151 NULL, &buffer);
152 if (ACPI_SUCCESS(err)) {
153 obj = buffer.Pointer;
155 for (i = 0; i < NestingLevel; i++)
156 Printf(" ");
157 Printf(" %s: [", METHOD_NAME__STA);
158 if (obj->Integer.Value & ACPI_STA_DEVICE_PRESENT)
159 Printf(" Present");
160 if (obj->Integer.Value & ACPI_STA_DEVICE_ENABLED)
161 Printf(" Enabled");
162 if (obj->Integer.Value & ACPI_STA_DEVICE_UI)
163 Printf(" UI");
164 if (obj->Integer.Value & ACPI_STA_DEVICE_OK)
165 Printf(" Ok");
166 if (obj->Integer.Value & ACPI_STA_BATTERY_PRESENT)
167 Printf(" Battery");
168 Printf(" ]\n");
169 FreeVec(buffer.Pointer);
171 #endif
172 FreeVec(info);
175 return err;
178 ACPI_STATUS OnAscend (
179 ACPI_HANDLE Object,
180 UINT32 NestingLevel,
181 void *Context,
182 void **ReturnValue)
184 /* Nothing at the moment */
186 return AE_OK;
189 AROS_SH0(ACPIInfo, 1.0)
191 AROS_SHCOMMAND_INIT
193 AcpiWalkNamespace(ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, (UINT32)~0, OnDescend, OnAscend, NULL, NULL);
195 return RETURN_OK;
197 AROS_SHCOMMAND_EXIT