]>
git.ipfire.org Git - thirdparty/u-boot.git/blob - lib/acpi/acpi.c
939a638bb5b5c34b0cd82ddddb55bb9fb89ba59e
1 // SPDX-License-Identifier: GPL-2.0
3 * Utility functions for ACPI
5 * Copyright 2023 Google LLC
9 #include <acpi/acpi_table.h>
10 #include <asm/global_data.h>
12 DECLARE_GLOBAL_DATA_PTR
;
14 struct acpi_table_header
*acpi_find_table(const char *sig
)
16 struct acpi_rsdp
*rsdp
;
17 struct acpi_rsdt
*rsdt
;
18 struct acpi_xsdt
*xsdt
;
21 rsdp
= map_sysmem(gd_acpi_start(), 0);
24 if (rsdp
->xsdt_address
) {
25 xsdt
= map_sysmem(rsdp
->xsdt_address
, 0);
26 len
= xsdt
->header
.length
- sizeof(xsdt
->header
);
27 count
= len
/ sizeof(u64
);
29 if (!rsdp
->rsdt_address
)
31 rsdt
= map_sysmem(rsdp
->rsdt_address
, 0);
32 len
= rsdt
->header
.length
- sizeof(rsdt
->header
);
33 count
= len
/ sizeof(u32
);
35 for (i
= 0; i
< count
; i
++) {
36 struct acpi_table_header
*hdr
;
38 if (rsdp
->xsdt_address
)
39 hdr
= map_sysmem(xsdt
->entry
[i
], 0);
41 hdr
= map_sysmem(rsdt
->entry
[i
], 0);
42 if (!memcmp(hdr
->signature
, sig
, ACPI_NAME_LEN
))
44 if (!memcmp(hdr
->signature
, "FACP", ACPI_NAME_LEN
)) {
45 struct acpi_fadt
*fadt
= (struct acpi_fadt
*)hdr
;
47 if (!memcmp(sig
, "DSDT", ACPI_NAME_LEN
) && fadt
->dsdt
)
48 return map_sysmem(fadt
->dsdt
, 0);
49 if (!memcmp(sig
, "FACS", ACPI_NAME_LEN
) &&
51 return map_sysmem(fadt
->firmware_ctrl
, 0);