1
2
3
4
5
6
7
8
9
10#include <acpi/acpi.h>
11#include "accommon.h"
12
13#define _COMPONENT ACPI_UTILITIES
14ACPI_MODULE_NAME("utosi")
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
53static struct acpi_interface_info acpi_default_supported_interfaces[] = {
54
55
56 {"Windows 2000", NULL, 0, ACPI_OSI_WIN_2000},
57 {"Windows 2001", NULL, 0, ACPI_OSI_WIN_XP},
58 {"Windows 2001 SP1", NULL, 0, ACPI_OSI_WIN_XP_SP1},
59 {"Windows 2001.1", NULL, 0, ACPI_OSI_WINSRV_2003},
60 {"Windows 2001 SP2", NULL, 0, ACPI_OSI_WIN_XP_SP2},
61 {"Windows 2001.1 SP1", NULL, 0, ACPI_OSI_WINSRV_2003_SP1},
62 {"Windows 2006", NULL, 0, ACPI_OSI_WIN_VISTA},
63 {"Windows 2006.1", NULL, 0, ACPI_OSI_WINSRV_2008},
64 {"Windows 2006 SP1", NULL, 0, ACPI_OSI_WIN_VISTA_SP1},
65 {"Windows 2006 SP2", NULL, 0, ACPI_OSI_WIN_VISTA_SP2},
66 {"Windows 2009", NULL, 0, ACPI_OSI_WIN_7},
67 {"Windows 2012", NULL, 0, ACPI_OSI_WIN_8},
68 {"Windows 2013", NULL, 0, ACPI_OSI_WIN_8_1},
69 {"Windows 2015", NULL, 0, ACPI_OSI_WIN_10},
70 {"Windows 2016", NULL, 0, ACPI_OSI_WIN_10_RS1},
71 {"Windows 2017", NULL, 0, ACPI_OSI_WIN_10_RS2},
72 {"Windows 2017.2", NULL, 0, ACPI_OSI_WIN_10_RS3},
73 {"Windows 2018", NULL, 0, ACPI_OSI_WIN_10_RS4},
74 {"Windows 2018.2", NULL, 0, ACPI_OSI_WIN_10_RS5},
75 {"Windows 2019", NULL, 0, ACPI_OSI_WIN_10_19H1},
76 {"Windows 2020", NULL, 0, ACPI_OSI_WIN_10_20H1},
77
78
79
80 {"Extended Address Space Descriptor", NULL, ACPI_OSI_FEATURE, 0},
81
82
83
84
85
86
87
88
89 {"Module Device", NULL, ACPI_OSI_OPTIONAL_FEATURE, 0},
90 {"Processor Device", NULL, ACPI_OSI_OPTIONAL_FEATURE, 0},
91 {"3.0 Thermal Model", NULL, ACPI_OSI_OPTIONAL_FEATURE, 0},
92 {"3.0 _SCP Extensions", NULL, ACPI_OSI_OPTIONAL_FEATURE, 0},
93 {"Processor Aggregator Device", NULL, ACPI_OSI_OPTIONAL_FEATURE, 0}
94};
95
96
97
98
99
100
101
102
103
104
105
106
107
108acpi_status acpi_ut_initialize_interfaces(void)
109{
110 acpi_status status;
111 u32 i;
112
113 status = acpi_os_acquire_mutex(acpi_gbl_osi_mutex, ACPI_WAIT_FOREVER);
114 if (ACPI_FAILURE(status)) {
115 return (status);
116 }
117
118 acpi_gbl_supported_interfaces = acpi_default_supported_interfaces;
119
120
121
122 for (i = 0;
123 i < (ACPI_ARRAY_LENGTH(acpi_default_supported_interfaces) - 1);
124 i++) {
125 acpi_default_supported_interfaces[i].next =
126 &acpi_default_supported_interfaces[(acpi_size)i + 1];
127 }
128
129 acpi_os_release_mutex(acpi_gbl_osi_mutex);
130 return (AE_OK);
131}
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146acpi_status acpi_ut_interface_terminate(void)
147{
148 acpi_status status;
149 struct acpi_interface_info *next_interface;
150
151 status = acpi_os_acquire_mutex(acpi_gbl_osi_mutex, ACPI_WAIT_FOREVER);
152 if (ACPI_FAILURE(status)) {
153 return (status);
154 }
155
156 next_interface = acpi_gbl_supported_interfaces;
157 while (next_interface) {
158 acpi_gbl_supported_interfaces = next_interface->next;
159
160 if (next_interface->flags & ACPI_OSI_DYNAMIC) {
161
162
163
164 ACPI_FREE(next_interface->name);
165 ACPI_FREE(next_interface);
166 } else {
167
168
169 if (next_interface->flags & ACPI_OSI_DEFAULT_INVALID) {
170 next_interface->flags |= ACPI_OSI_INVALID;
171 } else {
172 next_interface->flags &= ~ACPI_OSI_INVALID;
173 }
174 }
175
176 next_interface = acpi_gbl_supported_interfaces;
177 }
178
179 acpi_os_release_mutex(acpi_gbl_osi_mutex);
180 return (AE_OK);
181}
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196acpi_status acpi_ut_install_interface(acpi_string interface_name)
197{
198 struct acpi_interface_info *interface_info;
199
200
201
202 interface_info =
203 ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_interface_info));
204 if (!interface_info) {
205 return (AE_NO_MEMORY);
206 }
207
208 interface_info->name = ACPI_ALLOCATE_ZEROED(strlen(interface_name) + 1);
209 if (!interface_info->name) {
210 ACPI_FREE(interface_info);
211 return (AE_NO_MEMORY);
212 }
213
214
215
216 strcpy(interface_info->name, interface_name);
217 interface_info->flags = ACPI_OSI_DYNAMIC;
218 interface_info->next = acpi_gbl_supported_interfaces;
219
220 acpi_gbl_supported_interfaces = interface_info;
221 return (AE_OK);
222}
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237acpi_status acpi_ut_remove_interface(acpi_string interface_name)
238{
239 struct acpi_interface_info *previous_interface;
240 struct acpi_interface_info *next_interface;
241
242 previous_interface = next_interface = acpi_gbl_supported_interfaces;
243 while (next_interface) {
244 if (!strcmp(interface_name, next_interface->name)) {
245
246
247
248
249 if (next_interface->flags & ACPI_OSI_DYNAMIC) {
250
251
252
253 if (previous_interface == next_interface) {
254 acpi_gbl_supported_interfaces =
255 next_interface->next;
256 } else {
257 previous_interface->next =
258 next_interface->next;
259 }
260
261 ACPI_FREE(next_interface->name);
262 ACPI_FREE(next_interface);
263 } else {
264
265
266
267
268 if (next_interface->flags & ACPI_OSI_INVALID) {
269 return (AE_NOT_EXIST);
270 }
271
272 next_interface->flags |= ACPI_OSI_INVALID;
273 }
274
275 return (AE_OK);
276 }
277
278 previous_interface = next_interface;
279 next_interface = next_interface->next;
280 }
281
282
283
284 return (AE_NOT_EXIST);
285}
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302acpi_status acpi_ut_update_interfaces(u8 action)
303{
304 struct acpi_interface_info *next_interface;
305
306 next_interface = acpi_gbl_supported_interfaces;
307 while (next_interface) {
308 if (((next_interface->flags & ACPI_OSI_FEATURE) &&
309 (action & ACPI_FEATURE_STRINGS)) ||
310 (!(next_interface->flags & ACPI_OSI_FEATURE) &&
311 (action & ACPI_VENDOR_STRINGS))) {
312 if (action & ACPI_DISABLE_INTERFACES) {
313
314
315
316 next_interface->flags |= ACPI_OSI_INVALID;
317 } else {
318
319
320 next_interface->flags &= ~ACPI_OSI_INVALID;
321 }
322 }
323
324 next_interface = next_interface->next;
325 }
326
327 return (AE_OK);
328}
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343struct acpi_interface_info *acpi_ut_get_interface(acpi_string interface_name)
344{
345 struct acpi_interface_info *next_interface;
346
347 next_interface = acpi_gbl_supported_interfaces;
348 while (next_interface) {
349 if (!strcmp(interface_name, next_interface->name)) {
350 return (next_interface);
351 }
352
353 next_interface = next_interface->next;
354 }
355
356 return (NULL);
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
384acpi_status acpi_ut_osi_implementation(struct acpi_walk_state *walk_state)
385{
386 union acpi_operand_object *string_desc;
387 union acpi_operand_object *return_desc;
388 struct acpi_interface_info *interface_info;
389 acpi_interface_handler interface_handler;
390 acpi_status status;
391 u64 return_value;
392
393 ACPI_FUNCTION_TRACE(ut_osi_implementation);
394
395
396
397 string_desc = walk_state->arguments[0].object;
398 if (!string_desc || (string_desc->common.type != ACPI_TYPE_STRING)) {
399 return_ACPI_STATUS(AE_TYPE);
400 }
401
402
403
404 return_desc = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER);
405 if (!return_desc) {
406 return_ACPI_STATUS(AE_NO_MEMORY);
407 }
408
409
410
411 return_value = 0;
412 status = acpi_os_acquire_mutex(acpi_gbl_osi_mutex, ACPI_WAIT_FOREVER);
413 if (ACPI_FAILURE(status)) {
414 acpi_ut_remove_reference(return_desc);
415 return_ACPI_STATUS(status);
416 }
417
418
419
420 interface_info = acpi_ut_get_interface(string_desc->string.pointer);
421 if (interface_info && !(interface_info->flags & ACPI_OSI_INVALID)) {
422
423
424
425
426
427 if (interface_info->value > acpi_gbl_osi_data) {
428 acpi_gbl_osi_data = interface_info->value;
429 }
430
431 return_value = ACPI_UINT64_MAX;
432 }
433
434 acpi_os_release_mutex(acpi_gbl_osi_mutex);
435
436
437
438
439
440
441 interface_handler = acpi_gbl_interface_handler;
442 if (interface_handler) {
443 if (interface_handler
444 (string_desc->string.pointer, (u32)return_value)) {
445 return_value = ACPI_UINT64_MAX;
446 }
447 }
448
449 ACPI_DEBUG_PRINT_RAW((ACPI_DB_INFO,
450 "ACPI: BIOS _OSI(\"%s\") is %ssupported\n",
451 string_desc->string.pointer,
452 return_value == 0 ? "not " : ""));
453
454
455
456 return_desc->integer.value = return_value;
457 walk_state->return_desc = return_desc;
458 return_ACPI_STATUS(AE_OK);
459}
460