1 // Copyright 2017 The Fuchsia Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "util.h"
6
7 #include <acpica/acpi.h>
8
acpi_evaluate_integer(ACPI_HANDLE handle,const char * name,uint64_t * out)9 ACPI_STATUS acpi_evaluate_integer(ACPI_HANDLE handle, const char* name, uint64_t* out) {
10 ACPI_OBJECT obj = {
11 .Type = ACPI_TYPE_INTEGER,
12 };
13 ACPI_BUFFER buffer = {
14 .Length = sizeof(obj),
15 .Pointer = &obj,
16 };
17 ACPI_STATUS acpi_status = AcpiEvaluateObject(handle, (char*)name, NULL, &buffer);
18 if (acpi_status != AE_OK) {
19 return acpi_status;
20 }
21 *out = obj.Integer.Value;
22 return AE_OK;
23 }
24
25
acpi_evaluate_method_intarg(ACPI_HANDLE handle,const char * name,uint64_t arg)26 ACPI_STATUS acpi_evaluate_method_intarg(ACPI_HANDLE handle, const char* name, uint64_t arg) {
27 ACPI_OBJECT obj = {
28 .Integer.Type = ACPI_TYPE_INTEGER,
29 .Integer.Value = arg,
30 };
31 ACPI_OBJECT_LIST params = {
32 .Count = 1,
33 .Pointer = &obj,
34 };
35 return AcpiEvaluateObject(handle, (char*)name, ¶ms, NULL);
36 }
37