From 62d6f1f9430151448b4e51c249e345f63bba4f97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ky=C3=B6sti=20M=C3=A4lkki?= Date: Wed, 27 Jan 2021 10:13:33 +0200 Subject: [PATCH] ACPI: Do minor improvements on GNVS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reorder the support functions to make a bit more sense, allocations happen first. Add related comments about the bootstate these are to be called from. Change-Id: Ie6d66f6e4c30519dee4520f6e9dec3c8c678ab57 Signed-off-by: Kyösti Mälkki Reviewed-on: https://review.coreboot.org/c/coreboot/+/50003 Tested-by: build bot (Jenkins) Reviewed-by: Angel Pons --- src/acpi/gnvs.c | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/src/acpi/gnvs.c b/src/acpi/gnvs.c index 4da830a5ad..63740d037f 100644 --- a/src/acpi/gnvs.c +++ b/src/acpi/gnvs.c @@ -12,27 +12,12 @@ static struct global_nvs *gnvs; -void *acpi_get_gnvs(void) -{ - if (gnvs) - return gnvs; - - gnvs = cbmem_find(CBMEM_ID_ACPI_GNVS); - if (gnvs) - return gnvs; - - printk(BIOS_ERR, "Unable to locate Global NVS\n"); - return NULL; -} - -__weak void soc_fill_gnvs(struct global_nvs *gnvs_) { } -__weak void mainboard_fill_gnvs(struct global_nvs *gnvs_) { } - void acpi_create_gnvs(void) { size_t gnvs_size; - if (cbmem_find(CBMEM_ID_ACPI_GNVS)) + gnvs = cbmem_find(CBMEM_ID_ACPI_GNVS); + if (gnvs) return; /* Match with OpRegion declared in global_nvs.asl. */ @@ -57,11 +42,29 @@ void acpi_create_gnvs(void) gnvs_assign_chromeos((u8 *)gnvs + GNVS_CHROMEOS_ACPI_OFFSET); } +void *acpi_get_gnvs(void) +{ + if (gnvs) + return gnvs; + + gnvs = cbmem_find(CBMEM_ID_ACPI_GNVS); + if (gnvs) + return gnvs; + + printk(BIOS_ERR, "Unable to locate Global NVS\n"); + return NULL; +} + void *acpi_get_device_nvs(void) { return (u8 *)gnvs + GNVS_DEVICE_NVS_OFFSET; } +/* Implemented under platform. */ +__weak void soc_fill_gnvs(struct global_nvs *gnvs_) { } +__weak void mainboard_fill_gnvs(struct global_nvs *gnvs_) { } + +/* Called from write_acpi_tables() only on normal boot path. */ void acpi_fill_gnvs(void) { if (!gnvs)