1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
|
/*++
Copyright (c) Microsoft Corporation. All rights reserved.
Module Name:
acpispecific.c
Abstract:
This module defines global variables that are used by the common library
for the platform extension.
Environment:
Kernel mode
--*/
//
//-------------------------------------------------------------------- Includes
//
#include "pch.h"
#include "acpispecific.h"
#if defined(EVENT_TRACING)
#include "acpispecific.tmh"
#endif
//
// To add new devices that will be accepted by the platform extension,
// follow to the example below.
//
//
// Step 1: Define a unique device type for each new device.
// (See acpispecific.h for details)
//
//
// Step 2: Define a name for each new device.
// (See acpispecific.h for details)
//
//
//--------------------------------------------------------------------- Globals
//
//
// The common library will consume the PepDeviceMatchArray to determine
// whether a device should be accepted by the platform extension.
// And then the common library will consult PepDeviceDefinitionArray for
// the native methods and device-specific notification handlers of the accepted
// devices.
//
//
// Step 3: Edit the PepDeviceMatchArray to tell the common library which device
// should be accepted by the platform extension. For each accepted device,
// specify which kind of notification (ACPI/DPM/PPM) the platform extension
// will handle and also specify the way platform extension should match its
// name (partial match or full match) when identifying the device.
// In this example, the sample platform extension only handles ACPI
// notifications for all devices and all devices should be matched by their
// full names.
//
PEP_DEVICE_MATCH PepDeviceMatchArray[] = {
{PEP_DEVICE_TYPE_ROOT,
PEP_NOTIFICATION_CLASS_ACPI,
SAMPLE_ROOT_WCHAR,
PepDeviceIdMatchFull},
{PEP_DEVICE_TYPE_BUSD,
PEP_NOTIFICATION_CLASS_ACPI,
SAMPLE_BUSD_ACPI_NAME_WCHAR,
PepDeviceIdMatchFull},
{PEP_DEVICE_TYPE_GPIO,
PEP_NOTIFICATION_CLASS_ACPI,
SAMPLE_GPIO_ACPI_NAME_WCHAR,
PepDeviceIdMatchFull},
{PEP_DEVICE_TYPE_SPBD,
PEP_NOTIFICATION_CLASS_ACPI,
SAMPLE_SPBD_ACPI_NAME_WCHAR,
PepDeviceIdMatchFull},
{PEP_DEVICE_TYPE_TST1,
PEP_NOTIFICATION_CLASS_ACPI,
SAMPLE_TST1_ACPI_NAME_WCHAR,
PepDeviceIdMatchFull},
{PEP_DEVICE_TYPE_TST2,
PEP_NOTIFICATION_CLASS_ACPI,
SAMPLE_TST2_ACPI_NAME_WCHAR,
PepDeviceIdMatchFull},
{PEP_DEVICE_TYPE_TST3,
PEP_NOTIFICATION_CLASS_ACPI,
SAMPLE_TST3_ACPI_NAME_WCHAR,
PepDeviceIdMatchFull},
{PEP_DEVICE_TYPE_PWRR,
PEP_NOTIFICATION_CLASS_ACPI,
SAMPLE_PWRR_ACPI_NAME_WCHAR,
PepDeviceIdMatchFull}
};
ULONG PepDeviceMatchArraySize = ARRAYSIZE(PepDeviceMatchArray);
//
// Step 4: Define the list of native methods under each device.
// In this example, the platform extension natively handles:
// 1). _HID and _CID methods for \_SB.BUSD;
// 2). _HID method for \_SB.GPIO and \_SB.SPBD;
// 3). _ADR and _CRS methods for \_SB.BUSD.TST1;
// 4). _ADR, _CRS and _DEP methods for \_SB.BUSD.TST2;
// 5). _HID and _CRS methods for \_SB.TST3;
// 5). _HID, _STA, _ON, and _OFF methods for \_SB.PWRR.
//
PEP_OBJECT_INFORMATION RootNativeMethods[] =
{
//
// _Child Devices
//
{(ULONG)SAMPLE_BUSD_REAL_NAME, 0, 1, PepAcpiObjectTypeDevice},
{(ULONG)SAMPLE_GPIO_REAL_NAME, 0, 1, PepAcpiObjectTypeDevice},
{(ULONG)SAMPLE_SPBD_REAL_NAME, 0, 1, PepAcpiObjectTypeDevice},
{(ULONG)SAMPLE_TST3_REAL_NAME, 0, 1, PepAcpiObjectTypeDevice}
};
PEP_OBJECT_INFORMATION BusdNativeMethods[] =
{
// _HID
{ACPI_OBJECT_NAME_HID, 0, 1, PepAcpiObjectTypeMethod},
// _CID
{ACPI_OBJECT_NAME_CID, 0, 1, PepAcpiObjectTypeMethod},
//
// _Child Devices
//
{(ULONG)SAMPLE_TST1_REAL_NAME, 0, 1, PepAcpiObjectTypeDevice},
{(ULONG)SAMPLE_TST2_REAL_NAME, 0, 1, PepAcpiObjectTypeDevice},
};
PEP_OBJECT_INFORMATION GpioAndSpbdNativeMethods[] =
{
// _HID
{ACPI_OBJECT_NAME_HID, 0, 1, PepAcpiObjectTypeMethod},
// _CID
{ACPI_OBJECT_NAME_CID, 0, 1, PepAcpiObjectTypeMethod}
};
PEP_OBJECT_INFORMATION Tst1NativeMethods[] =
{
// _ADR
{ACPI_OBJECT_NAME_ADR, 0, 1, PepAcpiObjectTypeMethod},
// _CRS
{ACPI_OBJECT_NAME_CRS, 0, 1, PepAcpiObjectTypeMethod},
// _DEP
{ACPI_OBJECT_NAME_DEP, 0, 1, PepAcpiObjectTypeMethod}
};
PEP_OBJECT_INFORMATION Tst2NativeMethods[] =
{
// _ADR
{ACPI_OBJECT_NAME_ADR, 0, 1, PepAcpiObjectTypeMethod},
// _CRS
{ACPI_OBJECT_NAME_CRS, 0, 1, PepAcpiObjectTypeMethod}
};
PEP_OBJECT_INFORMATION Tst3NativeMethods[] =
{
// _HID
{ACPI_OBJECT_NAME_HID, 0, 1, PepAcpiObjectTypeMethod},
// _CID
{ACPI_OBJECT_NAME_CID, 0, 1, PepAcpiObjectTypeMethod},
};
PEP_OBJECT_INFORMATION PwrrNativeMethods[] =
{
// _HID
{ACPI_OBJECT_NAME_HID, 0, 1, PepAcpiObjectTypeMethod},
// _STA
{ACPI_OBJECT_NAME_STA, 0, 1, PepAcpiObjectTypeMethod},
// _ON
{ACPI_OBJECT_NAME_ON, 0, 1, PepAcpiObjectTypeMethod},
// _OFF
{ACPI_OBJECT_NAME_OFF, 0, 1, PepAcpiObjectTypeMethod},
};
//
// Step 5: Define the list of device-specific notification handlers
// for each device.
//
// In this example:
// 1) all devices define PEP_NOTIFY_ACPI_EVALUATE_CONTROL_METHOD;
// 2) for \_SB.BUSD, its _HID method will be handled synchronously
// while its _CID method will be handled asynchronously;
// 3) for \_SB.GPIO and \_SB.SPBD, their _HID method will both be
// handled synchronously;
// 4) for \_SB.BUSD.TST1 and \_SB.BUSD.TST2, their _ADR and _DEP
// methods will be handled synchronously while _CRS method
// will be handled asynchronously.
// 5) \_SB.BUSD.TST1 also synchronously handles
// PEP_NOTIFY_ACPI_QUERY_DEVICE_CONTROL_RESOURCES.
// 6) \_SB.TST3 synchronously handles all
// PEP_NOTIFY_ACPI_EVALUATE_CONTROL_METHOD except for _CID.
// The processing for _CID is done in a self-managed manner (i.e. it is
// processed asynchronously but does not rely on common library worker).
// Hence there is no async worker registered.
// 7) \_SB.PWRR synchronously handles all
// PEP_NOTIFY_ACPI_EVALUATE_CONTROL_METHOD.
//
PEP_DEVICE_NOTIFICATION_HANDLER RootNotificationHandler[] = {
{PEP_NOTIFY_ACPI_EVALUATE_CONTROL_METHOD,
RootSyncEvaluateControlMethod,
NULL}
};
PEP_DEVICE_NOTIFICATION_HANDLER BusdNotificationHandler[] = {
{PEP_NOTIFY_ACPI_EVALUATE_CONTROL_METHOD,
BusdSyncEvaluateControlMethod,
BusdWorkerCallbackEvaluateControlMethod}
};
PEP_DEVICE_NOTIFICATION_HANDLER GpioNotificationHandler[] = {
{PEP_NOTIFY_ACPI_EVALUATE_CONTROL_METHOD,
GpioSyncEvaluateControlMethod,
NULL}
};
PEP_DEVICE_NOTIFICATION_HANDLER SpbdNotificationHandler[] = {
{PEP_NOTIFY_ACPI_EVALUATE_CONTROL_METHOD,
SpbdSyncEvaluateControlMethod,
NULL}
};
PEP_DEVICE_NOTIFICATION_HANDLER Tst1NotificationHandler[] = {
{PEP_NOTIFY_ACPI_EVALUATE_CONTROL_METHOD,
Tst1SyncEvaluateControlMethod,
Tst1WorkerCallbackEvaluateControlMethod},
{PEP_NOTIFY_ACPI_QUERY_DEVICE_CONTROL_RESOURCES,
Tst1SyncQueryControlResources,
NULL}
};
PEP_DEVICE_NOTIFICATION_HANDLER Tst2NotificationHandler[] = {
{PEP_NOTIFY_ACPI_EVALUATE_CONTROL_METHOD,
Tst2SyncEvaluateControlMethod,
Tst2WorkerCallbackEvaluateControlMethod}
};
PEP_DEVICE_NOTIFICATION_HANDLER Tst3NotificationHandler[] = {
{PEP_NOTIFY_ACPI_EVALUATE_CONTROL_METHOD,
Tst3SyncEvaluateControlMethod,
NULL}
};
PEP_DEVICE_NOTIFICATION_HANDLER PwrrNotificationHandler[] = {
{PEP_NOTIFY_ACPI_EVALUATE_CONTROL_METHOD,
PwrrSyncEvaluateControlMethod,
NULL}
};
//
// Step 6: Edit the PepDeviceDefinitionArray to register any native methods
// and device-specific notification handlers.
//
PEP_DEVICE_DEFINITION PepDeviceDefinitionArray[] = {
// \_SB
{PEP_DEVICE_TYPE_ROOT,
sizeof(PEP_ACPI_DEVICE),
NULL,
ARRAYSIZE(RootNativeMethods),
RootNativeMethods,
ARRAYSIZE(RootNotificationHandler),
RootNotificationHandler,
0,
NULL},
// \_SB.BUSD
{PEP_DEVICE_TYPE_BUSD,
sizeof(PEP_ACPI_DEVICE),
NULL,
ARRAYSIZE(BusdNativeMethods),
BusdNativeMethods,
ARRAYSIZE(BusdNotificationHandler),
BusdNotificationHandler,
0,
NULL},
// \_SB.GPIO
{PEP_DEVICE_TYPE_GPIO,
sizeof(PEP_ACPI_DEVICE),
NULL,
ARRAYSIZE(GpioAndSpbdNativeMethods),
GpioAndSpbdNativeMethods,
ARRAYSIZE(GpioNotificationHandler),
GpioNotificationHandler,
0,
NULL},
// \_SB.SPBD
{PEP_DEVICE_TYPE_SPBD,
sizeof(PEP_ACPI_DEVICE),
NULL,
ARRAYSIZE(GpioAndSpbdNativeMethods),
GpioAndSpbdNativeMethods,
ARRAYSIZE(SpbdNotificationHandler),
SpbdNotificationHandler,
0,
NULL},
// \_SB.BUSD.TST1
{PEP_DEVICE_TYPE_TST1,
sizeof(PEP_ACPI_DEVICE),
NULL,
ARRAYSIZE(Tst1NativeMethods),
Tst1NativeMethods,
ARRAYSIZE(Tst1NotificationHandler),
Tst1NotificationHandler,
0,
NULL},
// \_SB.BUSD.TST2
{PEP_DEVICE_TYPE_TST2,
sizeof(PEP_ACPI_DEVICE),
NULL,
ARRAYSIZE(Tst2NativeMethods),
Tst2NativeMethods,
ARRAYSIZE(Tst2NotificationHandler),
Tst2NotificationHandler,
0,
NULL},
// \_SB.TST3
{PEP_DEVICE_TYPE_TST3,
sizeof(PEP_ACPI_DEVICE),
NULL,
ARRAYSIZE(Tst3NativeMethods),
Tst3NativeMethods,
ARRAYSIZE(Tst3NotificationHandler),
Tst3NotificationHandler,
0,
NULL},
// \_SB.PWRR
{PEP_DEVICE_TYPE_PWRR,
sizeof(PEP_ACPI_DEVICE),
NULL,
ARRAYSIZE(PwrrNativeMethods),
PwrrNativeMethods,
ARRAYSIZE(PwrrNotificationHandler),
PwrrNotificationHandler,
0,
NULL},
};
ULONG PepDeviceDefinitionArraySize = ARRAYSIZE(PepDeviceDefinitionArray);
//
// Step 7: Implement the device-specific notification handlers.
// (See testdevice.c for details)
//
//
// Debug
//
volatile BOOLEAN _SAMPLE_PEP_DEBUG_ENABLED = TRUE;
|