1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <acpi/acpi_gnvs.h>
4 #include <acpi/acpigen.h>
7 #include <console/console.h>
12 static struct global_nvs
*gnvs
;
15 static void acpi_create_gnvs(void *unused
)
17 const size_t gnvs_size
= ALIGN_UP(sizeof(struct global_nvs
), sizeof(uint64_t));
18 const size_t dnvs_size
= ALIGN_UP(size_of_dnvs(), sizeof(uint64_t));
20 gnvs
= cbmem_find(CBMEM_ID_ACPI_GNVS
);
24 /* Allocate for both GNVS and DNVS OpRegions. */
25 gnvs
= cbmem_add(CBMEM_ID_ACPI_GNVS
, gnvs_size
+ dnvs_size
);
29 memset(gnvs
, 0, gnvs_size
+ dnvs_size
);
32 dnvs
= (char *)gnvs
+ gnvs_size
;
35 BOOT_STATE_INIT_ENTRY(BS_PRE_DEVICE
, BS_ON_EXIT
, acpi_create_gnvs
, NULL
);
37 void *acpi_get_gnvs(void)
42 gnvs
= cbmem_find(CBMEM_ID_ACPI_GNVS
);
46 printk(BIOS_ERR
, "Unable to locate Global NVS\n");
50 void *acpi_get_device_nvs(void)
55 /* Implemented under platform. */
56 __weak
void soc_fill_gnvs(struct global_nvs
*gnvs_
) { }
57 __weak
void mainboard_fill_gnvs(struct global_nvs
*gnvs_
) { }
58 __weak
size_t size_of_dnvs(void) { return 0; }
60 /* Called from write_acpi_tables() only on normal boot path. */
61 void acpi_fill_gnvs(void)
63 const struct opregion gnvs_op
= OPREGION("GNVS", SYSTEMMEMORY
, (uintptr_t)gnvs
,
64 sizeof(struct global_nvs
));
65 const struct opregion dnvs_op
= OPREGION("DNVS", SYSTEMMEMORY
, (uintptr_t)dnvs
,
72 mainboard_fill_gnvs(gnvs
);
74 acpigen_write_scope("\\");
75 acpigen_write_opregion(&gnvs_op
);
77 acpigen_write_opregion(&dnvs_op
);
81 int acpi_reset_gnvs_for_wake(struct global_nvs
**gnvs_
)
86 /* Set unknown wake source */