ACPI: Clean up GNVS initialisation
With the common <soc/nvs.h> approach platform does not need to implement the common accessors or sizeof() function. Change-Id: I1050a252f765c763c1ae2d1610cbfb0d973ba026 Signed-off-by: Kyösti Mälkki <kyosti.malkki@gmail.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/49793 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Angel Pons <th3fanbus@gmail.com>
This commit is contained in:
@@ -4,11 +4,13 @@
|
||||
#include <acpi/acpigen.h>
|
||||
#include <cbmem.h>
|
||||
#include <console/console.h>
|
||||
#include <soc/nvs.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <types.h>
|
||||
#include <vendorcode/google/chromeos/gnvs.h>
|
||||
|
||||
static void *gnvs;
|
||||
static struct global_nvs *gnvs;
|
||||
|
||||
void *acpi_get_gnvs(void)
|
||||
{
|
||||
@@ -23,38 +25,18 @@ void *acpi_get_gnvs(void)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void gnvs_assign_cbmc(void)
|
||||
{
|
||||
uint32_t *gnvs_cbmc = gnvs_cbmc_ptr(gnvs);
|
||||
if (gnvs_cbmc)
|
||||
*gnvs_cbmc = (uintptr_t)cbmem_find(CBMEM_ID_CONSOLE);
|
||||
}
|
||||
|
||||
/* Needs implementation in platform code. */
|
||||
__weak uint32_t *gnvs_cbmc_ptr(struct global_nvs *gnvs_)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
__weak void soc_fill_gnvs(struct global_nvs *gnvs_) { }
|
||||
__weak void mainboard_fill_gnvs(struct global_nvs *gnvs_) { }
|
||||
|
||||
void *gnvs_get_or_create(void)
|
||||
void acpi_create_gnvs(void)
|
||||
{
|
||||
size_t gnvs_size;
|
||||
|
||||
if (gnvs)
|
||||
return gnvs;
|
||||
|
||||
gnvs = cbmem_find(CBMEM_ID_ACPI_GNVS);
|
||||
if (gnvs)
|
||||
return gnvs;
|
||||
|
||||
gnvs_size = gnvs_size_of_array();
|
||||
if (!gnvs_size)
|
||||
return NULL;
|
||||
if (cbmem_find(CBMEM_ID_ACPI_GNVS))
|
||||
return;
|
||||
|
||||
/* Match with OpRegion declared in global_nvs.asl. */
|
||||
gnvs_size = sizeof(struct global_nvs);
|
||||
if (gnvs_size < 0x100)
|
||||
gnvs_size = 0x100;
|
||||
if (gnvs_size > 0x1000)
|
||||
@@ -64,17 +46,15 @@ void *gnvs_get_or_create(void)
|
||||
|
||||
gnvs = cbmem_add(CBMEM_ID_ACPI_GNVS, gnvs_size);
|
||||
if (!gnvs)
|
||||
return NULL;
|
||||
return;
|
||||
|
||||
memset(gnvs, 0, gnvs_size);
|
||||
|
||||
if (CONFIG(CONSOLE_CBMEM))
|
||||
gnvs_assign_cbmc();
|
||||
gnvs->cbmc = (uintptr_t)cbmem_find(CBMEM_ID_CONSOLE);
|
||||
|
||||
if (CONFIG(CHROMEOS))
|
||||
gnvs_assign_chromeos((u8 *)gnvs + GNVS_CHROMEOS_ACPI_OFFSET);
|
||||
|
||||
return gnvs;
|
||||
}
|
||||
|
||||
void acpi_fill_gnvs(void)
|
||||
|
Reference in New Issue
Block a user