Kyösti Mälkki has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/37175 )
Change subject: [TESTONLY] squashed kill CAR_GLOBAL_MIGRATION leftovers ......................................................................
[TESTONLY] squashed kill CAR_GLOBAL_MIGRATION leftovers
Change-Id: I3e4517ef14046696d66a73128997da563f95b9b9 Signed-off-by: Kyösti Mälkki kyosti.malkki@gmail.com --- D src/arch/arm/include/arch/early_variables.h D src/arch/arm64/include/arch/early_variables.h D src/arch/ppc64/include/arch/early_variables.h D src/arch/riscv/include/arch/early_variables.h M src/arch/x86/Kconfig M src/arch/x86/assembly_entry.S M src/arch/x86/car.ld M src/arch/x86/exception.c M src/arch/x86/include/arch/cache.h D src/arch/x86/include/arch/early_variables.h M src/commonlib/include/commonlib/cbmem_id.h M src/commonlib/storage/pci_sdhci.c M src/console/init.c M src/console/printk.c M src/cpu/Kconfig M src/cpu/intel/common/fsb.c M src/cpu/x86/Makefile.inc D src/cpu/x86/car.c M src/cpu/x86/lapic/apic_timer.c M src/cpu/x86/tsc/delay_tsc.c M src/drivers/amd/agesa/def_callouts.c M src/drivers/crb/tis.c M src/drivers/crb/tpm.c M src/drivers/elog/elog.c M src/drivers/i2c/tpm/cr50.c M src/drivers/i2c/tpm/tis.c M src/drivers/i2c/tpm/tis_atmel.c M src/drivers/i2c/tpm/tpm.c M src/drivers/pc80/pc/i8254.c M src/drivers/pc80/tpm/tis.c M src/drivers/spi/boot_device_rw_nommap.c M src/drivers/spi/flashconsole.c M src/drivers/spi/spi_flash.c M src/drivers/spi/tpm/tis.c M src/drivers/spi/tpm/tpm.c M src/drivers/uart/oxpcie_early.c M src/drivers/usb/ehci_debug.c M src/drivers/vpd/vpd.c M src/drivers/vpd/vpd.h M src/ec/google/chromeec/ec.c M src/ec/google/chromeec/ec_spi.c M src/include/rules.h M src/include/spd_bin.h M src/lib/cbmem_console.c M src/lib/cbmem_stage_cache.c M src/lib/ext_stage_cache.c M src/lib/fmap.c M src/lib/imd_cbmem.c M src/lib/spd_bin.c M src/lib/timestamp.c M src/security/tpm/tspi/log.c M src/security/tpm/tss/tcg-1.2/tss.c M src/security/tpm/tss/tcg-2.0/tss.c M src/security/tpm/tss/tcg-2.0/tss_marshaling.c M src/security/tpm/tss/vendor/cr50/cr50.c M src/security/vboot/common.c M src/security/vboot/misc.h M src/security/vboot/vbnv.c M src/security/vboot/vbnv_flash.c M src/security/vboot/vboot_loader.c M src/southbridge/intel/common/spi.c M src/vendorcode/siemens/hwilib/hwilib.c 62 files changed, 484 insertions(+), 1,072 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/75/37175/1
diff --git a/src/arch/arm/include/arch/early_variables.h b/src/arch/arm/include/arch/early_variables.h deleted file mode 100644 index 7002a88..0000000 --- a/src/arch/arm/include/arch/early_variables.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * This file is part of the coreboot project. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#ifndef ARCH_EARLY_VARIABLES_H -#define ARCH_EARLY_VARIABLES_H - -#define CAR_GLOBAL - -static inline void *car_get_var_ptr(void *var) { return var; } -#define car_get_var(var) (var) -#define car_set_var(var, val) do { (var) = (val); } while (0) - -#define car_get_ptr car_get_var -#define car_set_ptr car_set_var - -#endif diff --git a/src/arch/arm64/include/arch/early_variables.h b/src/arch/arm64/include/arch/early_variables.h deleted file mode 100644 index 7002a88..0000000 --- a/src/arch/arm64/include/arch/early_variables.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * This file is part of the coreboot project. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#ifndef ARCH_EARLY_VARIABLES_H -#define ARCH_EARLY_VARIABLES_H - -#define CAR_GLOBAL - -static inline void *car_get_var_ptr(void *var) { return var; } -#define car_get_var(var) (var) -#define car_set_var(var, val) do { (var) = (val); } while (0) - -#define car_get_ptr car_get_var -#define car_set_ptr car_set_var - -#endif diff --git a/src/arch/ppc64/include/arch/early_variables.h b/src/arch/ppc64/include/arch/early_variables.h deleted file mode 100644 index 05b8bc7..0000000 --- a/src/arch/ppc64/include/arch/early_variables.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * This file is part of the coreboot project. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#ifndef ARCH_EARLY_VARIABLES_H -#define ARCH_EARLY_VARIABLES_H - -#define CAR_GLOBAL - -#define CAR_MIGRATE(migrate_fn_) -static inline void *car_get_var_ptr(void *var) { return var; } -#define car_get_var(var) (var) -#define car_set_var(var, val) do { (var) = (val); } while (0) - -#define car_get_ptr car_get_var -#define car_set_ptr car_set_var - -#endif diff --git a/src/arch/riscv/include/arch/early_variables.h b/src/arch/riscv/include/arch/early_variables.h deleted file mode 100644 index a2da5f8..0000000 --- a/src/arch/riscv/include/arch/early_variables.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * This file is part of the coreboot project. - * - * Copyright (C) 2011 The ChromiumOS Authors. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#ifndef ARCH_EARLY_VARIABLES_H -#define ARCH_EARLY_VARIABLES_H - -#define CAR_GLOBAL - -#define CAR_MIGRATE(migrate_fn_) -static inline void *car_get_var_ptr(void *var) { return var; } -#define car_get_var(var) (var) -#define car_set_var(var, val) do { (var) = (val); } while (0) - -#define car_get_ptr car_get_var -#define car_set_ptr car_set_var - -#endif diff --git a/src/arch/x86/Kconfig b/src/arch/x86/Kconfig index 24a2065..3d2e001 100644 --- a/src/arch/x86/Kconfig +++ b/src/arch/x86/Kconfig @@ -219,7 +219,6 @@ config POSTCAR_STAGE def_bool y depends on ARCH_X86 - depends on !CAR_GLOBAL_MIGRATION
config VERSTAGE_DEBUG_SPINLOOP bool diff --git a/src/arch/x86/assembly_entry.S b/src/arch/x86/assembly_entry.S index d9d6d4e..b9d46af 100644 --- a/src/arch/x86/assembly_entry.S +++ b/src/arch/x86/assembly_entry.S @@ -19,7 +19,7 @@ * This path is for stages that are post bootblock when employing * CONFIG_C_ENVIRONMENT_BOOTBLOCK. The gdt is reloaded to accommodate * platforms that are executing out of CAR. In order to continue with - * C code execution one needs to set stack pointer and clear CAR_GLOBAL + * C code execution one needs to set stack pointer and clear .bss * variables that are stage specific. */ .section ".text._start", "ax", @progbits diff --git a/src/arch/x86/car.ld b/src/arch/x86/car.ld index 3680250..b83ec93 100644 --- a/src/arch/x86/car.ld +++ b/src/arch/x86/car.ld @@ -71,7 +71,7 @@ /* _bss and _ebss provide symbols to per-stage * variables that are not shared like the timestamp and the pre-ram * cbmem console. This is useful for clearing this area on a per-stage - * basis when more than one stage uses cache-as-ram for CAR_GLOBALs. */ + * basis when more than one stage uses cache-as-ram for .bss. */
. = ALIGN(ARCH_POINTER_ALIGN_SIZE); _bss = .; @@ -81,10 +81,6 @@ *(.bss.*) *(.sbss) *(.sbss.*) -#else - _car_global_start = .; - *(.car.global_data); - _car_global_end = .; #endif . = ALIGN(ARCH_POINTER_ALIGN_SIZE); _ebss = .; @@ -106,15 +102,6 @@ .illegal_globals . : { *(EXCLUDE_FILE ("*/libagesa.*.a:" "*/romstage*/buildOpts.o" "*/romstage*/agesawrapper.o" "*/vendorcode/amd/agesa/*" "*/vendorcode/amd/cimx/*") .data) *(EXCLUDE_FILE ("*/libagesa.*.a:" "*/romstage*/buildOpts.o" "*/romstage*/agesawrapper.o" "*/vendorcode/amd/agesa/*" "*/vendorcode/amd/cimx/*") .data.*) -#if CONFIG(CAR_GLOBAL_MIGRATION) - *(.bss) - *(.bss.*) - *(.sbss) - *(.sbss.*) -#else - /* In case something sneaks through when it shouldn't. */ - *(.car.global_data); -#endif }
_bogus = ASSERT((CONFIG_DCACHE_RAM_SIZE == 0) || (SIZEOF(.car.data) <= CONFIG_DCACHE_RAM_SIZE), "Cache as RAM area is too full"); diff --git a/src/arch/x86/exception.c b/src/arch/x86/exception.c index b88f4a7..a599e79 100644 --- a/src/arch/x86/exception.c +++ b/src/arch/x86/exception.c @@ -12,7 +12,6 @@ */
#include <arch/cpu.h> -#include <arch/early_variables.h> #include <arch/exception.h> #include <commonlib/helpers.h> #include <console/console.h> @@ -569,7 +568,7 @@ (uintptr_t)vec16, (uintptr_t)vec17, (uintptr_t)vec18, (uintptr_t)vec19, };
-static struct intr_gate idt[ARRAY_SIZE(intr_entries)] __aligned(8) CAR_GLOBAL; +static struct intr_gate idt[ARRAY_SIZE(intr_entries)] __aligned(8);
static inline uint16_t get_cs(void) { @@ -620,21 +619,19 @@ { int i; uint16_t segment; - struct intr_gate *gates;
segment = get_cs(); - gates = car_get_var_ptr(idt);
/* Initialize IDT. */ for (i = 0; i < ARRAY_SIZE(idt); i++) { - gates[i].offset_0 = intr_entries[i]; - gates[i].segsel = segment; - gates[i].flags = IGATE_FLAGS; - gates[i].offset_1 = intr_entries[i] >> 16; + idt[i].offset_0 = intr_entries[i]; + idt[i].segsel = segment; + idt[i].flags = IGATE_FLAGS; + idt[i].offset_1 = intr_entries[i] >> 16; #if ENV_X86_64 - gates[i].offset_2 = intr_entries[i] >> 32; + idt[i].offset_2 = intr_entries[i] >> 32; #endif }
- load_idt(gates, sizeof(idt)); + load_idt(idt, sizeof(idt)); } diff --git a/src/arch/x86/include/arch/cache.h b/src/arch/x86/include/arch/cache.h index c0d50e6..36476fd 100644 --- a/src/arch/x86/include/arch/cache.h +++ b/src/arch/x86/include/arch/cache.h @@ -31,13 +31,12 @@ #ifndef ARCH_CACHE_H #define ARCH_CACHE_H
-#include <arch/early_variables.h> #include <cpu/x86/cache.h>
/* Executing WBINVD when running out of CAR would not be good, prevent that. */ static inline void dcache_clean_invalidate_all(void) { - if (!car_active()) + if (!ENV_CACHE_AS_RAM) wbinvd(); } static inline void dcache_clean_all(void) @@ -47,7 +46,7 @@ } static inline void dcache_invalidate_all(void) { - if (!car_active()) + if (!ENV_CACHE_AS_RAM) invd(); }
diff --git a/src/arch/x86/include/arch/early_variables.h b/src/arch/x86/include/arch/early_variables.h deleted file mode 100644 index 7393cc9..0000000 --- a/src/arch/x86/include/arch/early_variables.h +++ /dev/null @@ -1,91 +0,0 @@ -/* - * This file is part of the coreboot project. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#ifndef ARCH_EARLY_VARIABLES_H -#define ARCH_EARLY_VARIABLES_H - -#include <arch/symbols.h> -#include <commonlib/helpers.h> -#include <stdlib.h> - -#if ENV_ROMSTAGE && CONFIG(CAR_GLOBAL_MIGRATION) - -/* - * The _car_global_[start|end]symbols cover CAR data which is relocatable - * once memory comes online. Variables with CAR_GLOBAL decoration - * reside within this region. - */ -extern char _car_global_start[]; -extern char _car_global_end[]; -#define _car_global_size (_car_global_end - _car_global_start) - -asm(".section .car.global_data,"w",@nobits"); -asm(".previous"); -#ifdef __clang__ -#define CAR_GLOBAL __attribute__((used, section(".car.global_data"))) -#else -#define CAR_GLOBAL __attribute__((used, section(".car.global_data#"))) -#endif /* __clang__ */ - -/* Get the correct pointer for the CAR global variable. */ -void *car_get_var_ptr(void *var); - -/* Return 1 when currently running with globals in Cache-as-RAM, 0 otherwise. */ -int car_active(void); - -/* Get and set a primitive type global variable. */ -#define car_get_var(var) \ - (*(typeof(var) *)car_get_var_ptr(&(var))) -#define car_set_var(var, val) car_get_var(var) = (val) - -/* Get and set a CAR_GLOBAL pointing elsewhere inside CAR. */ -#define car_get_ptr car_get_var -#define car_set_ptr car_set_var - -static inline size_t car_data_size(void) -{ - size_t car_size = _car_global_size; - return ALIGN(car_size, 64); -} - -static inline size_t car_object_offset(void *ptr) -{ - return (char *)ptr - &_car_global_start[0]; -} - -#else - -/* - * For all stages other than romstage, all CAR_GLOBAL variables are accessed - * unconditionally as there is no migration of symbols. - */ - -#define CAR_GLOBAL -#define car_get_var(var) (var) -#define car_set_var(var, val) (var) = (val) -#define car_get_ptr car_get_var -#define car_set_ptr car_set_var - -static inline void *car_get_var_ptr(void *var) -{ - return var; -} - -static inline int car_active(void) -{ - return ENV_CACHE_AS_RAM; -} - -#endif - -#endif /* ARCH_EARLY_VARIABLES_H */ diff --git a/src/commonlib/include/commonlib/cbmem_id.h b/src/commonlib/include/commonlib/cbmem_id.h index b063cd1..6835d86 100644 --- a/src/commonlib/include/commonlib/cbmem_id.h +++ b/src/commonlib/include/commonlib/cbmem_id.h @@ -20,7 +20,6 @@ #define CBMEM_ID_AFTER_CAR 0xc4787a93 #define CBMEM_ID_AGESA_RUNTIME 0x41474553 #define CBMEM_ID_AMDMCT_MEMINFO 0x494D454E -#define CBMEM_ID_CAR_GLOBALS 0xcac4e6a3 #define CBMEM_ID_CBTABLE 0x43425442 #define CBMEM_ID_CBTABLE_FWD 0x43425443 #define CBMEM_ID_CONSOLE 0x434f4e53 @@ -88,7 +87,6 @@ { CBMEM_ID_AGESA_RUNTIME, "AGESA RSVD " }, \ { CBMEM_ID_AFTER_CAR, "AFTER CAR " }, \ { CBMEM_ID_AMDMCT_MEMINFO, "AMDMEM INFO" }, \ - { CBMEM_ID_CAR_GLOBALS, "CAR GLOBALS" }, \ { CBMEM_ID_CBTABLE, "COREBOOT " }, \ { CBMEM_ID_CBTABLE_FWD, "COREBOOTFWD" }, \ { CBMEM_ID_CONSOLE, "CONSOLE " }, \ diff --git a/src/commonlib/storage/pci_sdhci.c b/src/commonlib/storage/pci_sdhci.c index abc093f..380f2db 100644 --- a/src/commonlib/storage/pci_sdhci.c +++ b/src/commonlib/storage/pci_sdhci.c @@ -12,7 +12,6 @@ * GNU General Public License for more details. */
-#include <arch/early_variables.h> #include <commonlib/sdhci.h> #include <device/pci.h> #include <device/pci_ops.h> @@ -32,22 +31,22 @@
struct sd_mmc_ctrlr *new_mem_sdhci_controller(void *ioaddr) { - static bool sdhci_init_done CAR_GLOBAL; - static struct sdhci_ctrlr sdhci_ctrlr CAR_GLOBAL; + static bool sdhci_init_done; + static struct sdhci_ctrlr sdhci_ctrlr;
- if (car_get_var(sdhci_init_done) == true) { + if (sdhci_init_done == true) { sdhc_error("Error: SDHCI is already initialized.\n"); return NULL; }
- if (sdhci_controller_init(car_get_var_ptr(&sdhci_ctrlr), ioaddr)) { + if (sdhci_controller_init(&sdhci_ctrlr, ioaddr)) { sdhc_error("Error: SDHCI initialization failed.\n"); return NULL; }
- car_set_var(sdhci_init_done, true); + sdhci_init_done = true;
- return car_get_var_ptr(&sdhci_ctrlr.sd_mmc_ctrlr); + return &sdhci_ctrlr.sd_mmc_ctrlr; }
struct sd_mmc_ctrlr *new_pci_sdhci_controller(pci_devfn_t dev) diff --git a/src/console/init.c b/src/console/init.c index d481858..911dbd0 100644 --- a/src/console/init.c +++ b/src/console/init.c @@ -12,7 +12,6 @@ * GNU General Public License for more details. */
-#include <arch/early_variables.h> #include <commonlib/helpers.h> #include <console/console.h> #include <console/uart.h> @@ -24,12 +23,12 @@ /* Mutable console log level only allowed when RAM comes online. */ #define CONSOLE_LEVEL_CONST !ENV_STAGE_HAS_DATA_SECTION
-static int console_inited CAR_GLOBAL; +static int console_inited; static int console_loglevel = CONFIG_DEFAULT_CONSOLE_LOGLEVEL;
static inline int get_log_level(void) { - if (car_get_var(console_inited) == 0) + if (console_inited == 0) return -1; if (CONSOLE_LEVEL_CONST) return get_console_loglevel(); @@ -78,14 +77,14 @@ init_log_level();
if (CONFIG(DEBUG_CONSOLE_INIT)) - car_set_var(console_inited, 1); + console_inited = 1;
if (CONFIG(EARLY_PCI_BRIDGE) && !ENV_SMM && !ENV_RAMSTAGE) pci_early_bridge_init();
console_hw_init();
- car_set_var(console_inited, 1); + console_inited = 1;
printk(BIOS_NOTICE, "\n\ncoreboot-%s%s %s " ENV_STRING " starting (log level: %i)...\n", coreboot_version, coreboot_extra_version, coreboot_build, diff --git a/src/console/printk.c b/src/console/printk.c index fd590fa..a08dd2f 100644 --- a/src/console/printk.c +++ b/src/console/printk.c @@ -25,8 +25,7 @@
DECLARE_SPIN_LOCK(console_lock)
-#define TRACK_CONSOLE_TIME (CONFIG(HAVE_MONOTONIC_TIMER) && \ - (ENV_RAMSTAGE || !CONFIG(CAR_GLOBAL_MIGRATION))) +#define TRACK_CONSOLE_TIME (CONFIG(HAVE_MONOTONIC_TIMER))
static struct mono_time mt_start, mt_stop; static long console_usecs; diff --git a/src/cpu/Kconfig b/src/cpu/Kconfig index 3c0bf89..1ad7ef1 100644 --- a/src/cpu/Kconfig +++ b/src/cpu/Kconfig @@ -6,14 +6,6 @@
if ARCH_X86
-config CAR_GLOBAL_MIGRATION - bool - default n - help - This option is selected if there is need to migrate CAR globals. - All stages which use CAR globals can directly access the variables - from their linked addresses. - config DCACHE_RAM_BASE hex
diff --git a/src/cpu/intel/common/fsb.c b/src/cpu/intel/common/fsb.c index 0004ead..29cadf4 100644 --- a/src/cpu/intel/common/fsb.c +++ b/src/cpu/intel/common/fsb.c @@ -11,7 +11,6 @@ * GNU General Public License for more details. */
-#include <arch/early_variables.h> #include <cpu/x86/msr.h> #include <cpu/x86/tsc.h> #include <cpu/intel/speedstep.h> @@ -20,8 +19,8 @@ #include <commonlib/helpers.h> #include <delay.h>
-static u32 g_timer_fsb CAR_GLOBAL; -static u32 g_timer_tsc CAR_GLOBAL; +static u32 g_timer_fsb; +static u32 g_timer_tsc;
/* This is not an architectural MSR. */ #define MSR_PLATFORM_INFO 0xce @@ -99,8 +98,8 @@ ret = get_fsb_tsc(&fsb, &ratio); if (ret == 0) { u32 tsc = 100 * DIV_ROUND_CLOSEST(ratio * fsb, 100); - car_set_var(g_timer_fsb, fsb); - car_set_var(g_timer_tsc, tsc); + g_timer_fsb = fsb; + g_timer_tsc = tsc; return; }
@@ -110,8 +109,8 @@ printk(BIOS_ERR, "CPU not supported\n");
/* Set some semi-ridiculous defaults. */ - car_set_var(g_timer_fsb, 500); - car_set_var(g_timer_tsc, 5000); + g_timer_fsb = 500; + g_timer_tsc = 5000; return; }
@@ -119,24 +118,24 @@ { u32 fsb;
- fsb = car_get_var(g_timer_fsb); + fsb = g_timer_fsb; if (fsb > 0) return fsb;
resolve_timebase(); - return car_get_var(g_timer_fsb); + return g_timer_fsb; }
unsigned long tsc_freq_mhz(void) { u32 tsc;
- tsc = car_get_var(g_timer_tsc); + tsc = g_timer_tsc; if (tsc > 0) return tsc;
resolve_timebase(); - return car_get_var(g_timer_tsc); + return g_timer_tsc; }
/** diff --git a/src/cpu/x86/Makefile.inc b/src/cpu/x86/Makefile.inc index 55d1fad..1191069 100644 --- a/src/cpu/x86/Makefile.inc +++ b/src/cpu/x86/Makefile.inc @@ -1,5 +1,3 @@ -romstage-$(CONFIG_CAR_GLOBAL_MIGRATION) += car.c - subdirs-y += pae subdirs-$(CONFIG_PARALLEL_MP) += name ramstage-$(CONFIG_PARALLEL_MP) += mp_init.c diff --git a/src/cpu/x86/car.c b/src/cpu/x86/car.c deleted file mode 100644 index b2dcdc8..0000000 --- a/src/cpu/x86/car.c +++ /dev/null @@ -1,99 +0,0 @@ -/* - * This file is part of the coreboot project. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ - -#include <string.h> -#include <stddef.h> -#include <console/console.h> -#include <cbmem.h> -#include <arch/early_variables.h> -#include <symbols.h> - -typedef void (* const car_migration_func_t)(void); - -extern car_migration_func_t _car_migrate_start; - -/* - * The car_migrated global variable determines if the cache-as-ram space has - * been migrated to real RAM. It does this by assuming the following things: - * 1. cache-as-ram space is zero'd out once it is set up. - * 2. Either the cache-as-ram space is memory-backed after getting torn down - * or the space returns 0xff's for each byte read. - * Based on these 2 attributes there is the ability to tell when the - * cache-as-ram region has been migrated. - */ -static int car_migrated CAR_GLOBAL; - -/** @brief returns pointer to a CAR variable, before or after migration. - * - * @param var pointer to the CAR variable - */ -void *car_get_var_ptr(void *var) -{ - char *migrated_base = NULL; - int offset; - void *_car_start = _car_global_start; - void *_car_end = _car_global_end; - - /* If the cache-as-ram has not been migrated return the pointer - * passed in. */ - if (!car_migrated) - return var; - - if (var < _car_start || var >= _car_end) { - printk(BIOS_ERR, - "Requesting CAR variable outside of CAR region: %p\n", - var); - return var; - } - - migrated_base = cbmem_find(CBMEM_ID_CAR_GLOBALS); - offset = (char *)var - (char *)_car_start; - - if (migrated_base == NULL) - die("CAR: Could not find migration base!\n"); - - return &migrated_base[offset]; -} - -int car_active(void) -{ - return !car_migrated; -} - -static void do_car_migrate_variables(void) -{ - void *migrated_base; - size_t car_size = car_data_size(); - - /* Check if already migrated. */ - if (car_migrated) - return; - - migrated_base = cbmem_add(CBMEM_ID_CAR_GLOBALS, car_size); - - if (migrated_base == NULL) { - printk(BIOS_ERR, "Could not migrate CAR data!\n"); - return; - } - - memcpy(migrated_base, _car_global_start, car_size); - - /* Mark that the data has been moved. */ - car_migrated = ~0; -} - -static void car_migrate_variables(int is_recovery) -{ - do_car_migrate_variables(); -} -ROMSTAGE_CBMEM_INIT_HOOK(car_migrate_variables) diff --git a/src/cpu/x86/lapic/apic_timer.c b/src/cpu/x86/lapic/apic_timer.c index 58836b5..8f0f7af 100644 --- a/src/cpu/x86/lapic/apic_timer.c +++ b/src/cpu/x86/lapic/apic_timer.c @@ -16,7 +16,6 @@ #include <delay.h> #include <thread.h> #include <arch/cpu.h> -#include <arch/early_variables.h> #include <cpu/x86/msr.h> #include <cpu/x86/lapic.h>
@@ -63,18 +62,15 @@ int initialized; struct mono_time time; uint32_t last_value; -} mono_counter_g CAR_GLOBAL; +} mono_counter_g;
void timer_monotonic_get(struct mono_time *mt) { uint32_t current_tick; uint32_t usecs_elapsed; uint32_t timer_fsb; - struct monotonic_counter *mono_counter;
- mono_counter = car_get_var_ptr(&mono_counter_g); - - if (!mono_counter->initialized) { + if (!mono_counter_g.initialized) { init_timer(); timer_fsb = get_timer_fsb(); /* An FSB frequency of 200Mhz provides a 20 second polling @@ -84,22 +80,22 @@ printk(BIOS_WARNING, "apic timer freq (%d) may be too fast.\n", timer_fsb); - mono_counter->last_value = lapic_read(LAPIC_TMCCT); - mono_counter->initialized = 1; + mono_counter_g.last_value = lapic_read(LAPIC_TMCCT); + mono_counter_g.initialized = 1; }
timer_fsb = get_timer_fsb(); current_tick = lapic_read(LAPIC_TMCCT); /* Note that the APIC timer counts down. */ - usecs_elapsed = (mono_counter->last_value - current_tick) / timer_fsb; + usecs_elapsed = (mono_counter_g.last_value - current_tick) / timer_fsb;
/* Update current time and tick values only if a full tick occurred. */ if (usecs_elapsed) { - mono_time_add_usecs(&mono_counter->time, usecs_elapsed); - mono_counter->last_value = current_tick; + mono_time_add_usecs(&mono_counter_g.time, usecs_elapsed); + mono_counter_g.last_value = current_tick; }
/* Save result. */ - *mt = mono_counter->time; + *mt = mono_counter_g.time; } #endif diff --git a/src/cpu/x86/tsc/delay_tsc.c b/src/cpu/x86/tsc/delay_tsc.c index 7aa887a..fe6ae5b 100644 --- a/src/cpu/x86/tsc/delay_tsc.c +++ b/src/cpu/x86/tsc/delay_tsc.c @@ -11,7 +11,6 @@ * GNU General Public License for more details. */
-#include <arch/early_variables.h> #include <cpu/x86/tsc.h> #include <pc80/i8254.h> #include <smp/spinlock.h> @@ -49,11 +48,11 @@ int initialized; struct mono_time time; uint64_t last_value; -} mono_counter_g CAR_GLOBAL; +} mono_counter_g;
static inline struct monotonic_counter *get_monotonic_context(void) { - return car_get_var_ptr(&mono_counter_g); + return &mono_counter_g; }
void timer_monotonic_get(struct mono_time *mt) diff --git a/src/drivers/amd/agesa/def_callouts.c b/src/drivers/amd/agesa/def_callouts.c index 4b78d63..bce90d9 100644 --- a/src/drivers/amd/agesa/def_callouts.c +++ b/src/drivers/amd/agesa/def_callouts.c @@ -175,7 +175,6 @@ #if HAS_AGESA_FCH_OEM_CALLOUT void agesa_fch_oem_config(uintptr_t Data, AMD_CONFIG_PARAMS *StdHeader) { - /* FIXME: CAR_GLOBAL needed here to pass sysinfo. */ struct sysinfo *cb_NA = NULL;
if (StdHeader->Func == AMD_INIT_RESET) { diff --git a/src/drivers/crb/tis.c b/src/drivers/crb/tis.c index b7a5df4..f2aba48 100644 --- a/src/drivers/crb/tis.c +++ b/src/drivers/crb/tis.c @@ -11,7 +11,6 @@ * GNU General Public License for more details. */
-#include <arch/early_variables.h> #include <console/console.h> #include <security/tpm/tis.h> #include <arch/acpigen.h> @@ -21,7 +20,7 @@ #include "tpm.h" #include "chip.h"
-static unsigned tpm_is_open CAR_GLOBAL; +static unsigned int tpm_is_open;
static const struct { uint16_t vid; @@ -45,7 +44,7 @@
int tis_open(void) { - if (car_get_var(tpm_is_open)) { + if (tpm_is_open) { printk(BIOS_ERR, "%s called twice.\n", __func__); return -1; } @@ -63,13 +62,13 @@
int tis_close(void) { - if (car_get_var(tpm_is_open)) { + if (tpm_is_open) {
/* * Do we need to do something here, like waiting for a * transaction to stop? */ - car_set_var(tpm_is_open, 0); + tpm_is_open = 0; }
return 0; diff --git a/src/drivers/crb/tpm.c b/src/drivers/crb/tpm.c index 0393417..f2b7903 100644 --- a/src/drivers/crb/tpm.c +++ b/src/drivers/crb/tpm.c @@ -15,7 +15,6 @@ */
#include <timer.h> -#include <arch/early_variables.h> #include <console/console.h> #include <arch/mmio.h> #include <delay.h> diff --git a/src/drivers/elog/elog.c b/src/drivers/elog/elog.c index c979e0c..768ea28 100644 --- a/src/drivers/elog/elog.c +++ b/src/drivers/elog/elog.c @@ -14,7 +14,6 @@ #if CONFIG(HAVE_ACPI_RESUME) #include <arch/acpi.h> #endif -#include <arch/early_variables.h> #include <bootstate.h> #include <cbmem.h> #include <console/console.h> @@ -66,21 +65,14 @@ enum elog_init_state elog_initialized; };
-static struct elog_state g_elog_state CAR_GLOBAL; +static struct elog_state g_elog_state;
#define ELOG_SIZE (4 * KiB) -static uint8_t elog_mirror_buf[ELOG_SIZE] CAR_GLOBAL; - -static void *get_elog_mirror_buffer(void) -{ - return car_get_var_ptr(elog_mirror_buf); -} +static uint8_t elog_mirror_buf[ELOG_SIZE];
static inline struct region_device *mirror_dev_get(void) { - struct elog_state *es = car_get_var_ptr(&g_elog_state); - - return &es->mirror_dev.rdev; + return &g_elog_state.mirror_dev.rdev; }
static size_t elog_events_start(void) @@ -91,9 +83,7 @@
static size_t elog_events_total_space(void) { - struct elog_state *es = car_get_var_ptr(&g_elog_state); - - return region_device_sz(&es->nv_dev) - elog_events_start(); + return region_device_sz(&g_elog_state.nv_dev) - elog_events_start(); }
static struct event_header *elog_get_event_buffer(size_t offset, size_t size) @@ -103,10 +93,8 @@
static struct event_header *elog_get_next_event_buffer(size_t size) { - struct elog_state *es = car_get_var_ptr(&g_elog_state); - - elog_debug("ELOG: new event at offset 0x%zx\n", es->mirror_last_write); - return elog_get_event_buffer(es->mirror_last_write, size); + elog_debug("ELOG: new event at offset 0x%zx\n", g_elog_state.mirror_last_write); + return elog_get_event_buffer(g_elog_state.mirror_last_write, size); }
static void elog_put_event_buffer(struct event_header *event) @@ -116,71 +104,54 @@
static size_t elog_mirror_reset_last_write(void) { - struct elog_state *es = car_get_var_ptr(&g_elog_state); /* Return previous write value. */ - size_t prev = es->mirror_last_write; + size_t prev = g_elog_state.mirror_last_write;
- es->mirror_last_write = 0; + g_elog_state.mirror_last_write = 0; return prev; }
static void elog_mirror_increment_last_write(size_t size) { - struct elog_state *es = car_get_var_ptr(&g_elog_state); - - es->mirror_last_write += size; + g_elog_state.mirror_last_write += size; }
static void elog_nv_reset_last_write(void) { - struct elog_state *es = car_get_var_ptr(&g_elog_state); - - es->nv_last_write = 0; + g_elog_state.nv_last_write = 0; }
static void elog_nv_increment_last_write(size_t size) { - struct elog_state *es = car_get_var_ptr(&g_elog_state); - - es->nv_last_write += size; + g_elog_state.nv_last_write += size; }
static void elog_nv_needs_possible_erase(void) { - struct elog_state *es = car_get_var_ptr(&g_elog_state); - /* If last write is 0 it means it is already erased. */ - if (es->nv_last_write != 0) - es->nv_last_write = NV_NEEDS_ERASE; + if (g_elog_state.nv_last_write != 0) + g_elog_state.nv_last_write = NV_NEEDS_ERASE; }
static bool elog_should_shrink(void) { - struct elog_state *es = car_get_var_ptr(&g_elog_state); - - return es->mirror_last_write >= es->full_threshold; + return g_elog_state.mirror_last_write >= g_elog_state.full_threshold; }
static bool elog_nv_needs_erase(void) { - struct elog_state *es = car_get_var_ptr(&g_elog_state); - - return es->nv_last_write == NV_NEEDS_ERASE; + return g_elog_state.nv_last_write == NV_NEEDS_ERASE; }
static bool elog_nv_needs_update(void) { - struct elog_state *es = car_get_var_ptr(&g_elog_state); - - return es->nv_last_write != es->mirror_last_write; + return g_elog_state.nv_last_write != g_elog_state.mirror_last_write; }
static size_t elog_nv_region_to_update(size_t *offset) { - struct elog_state *es = car_get_var_ptr(&g_elog_state); - - *offset = es->nv_last_write; - return es->mirror_last_write - es->nv_last_write; + *offset = g_elog_state.nv_last_write; + return g_elog_state.mirror_last_write - g_elog_state.nv_last_write; }
/* @@ -352,8 +323,6 @@ { void *address; const struct region_device *rdev = mirror_dev_get(); - struct elog_state *es = car_get_var_ptr(&g_elog_state); - if (!size) return;
@@ -366,7 +335,7 @@ return;
/* Write the data to flash */ - if (rdev_writeat(&es->nv_dev, address, offset, size) != size) + if (rdev_writeat(&g_elog_state.nv_dev, address, offset, size) != size) printk(BIOS_ERR, "ELOG: NV Write failed at 0x%zx, size 0x%zx\n", offset, size);
@@ -379,12 +348,11 @@ */ static void elog_nv_erase(void) { - struct elog_state *es = car_get_var_ptr(&g_elog_state); - size_t size = region_device_sz(&es->nv_dev); + size_t size = region_device_sz(&g_elog_state.nv_dev); elog_debug("%s()\n", __func__);
/* Erase the sectors in this region */ - if (rdev_eraseat(&es->nv_dev, 0, size) != size) + if (rdev_eraseat(&g_elog_state.nv_dev, 0, size) != size) printk(BIOS_ERR, "ELOG: erase failure.\n"); }
@@ -442,12 +410,12 @@ elog_debug("elog_scan_flash()\n"); void *mirror_buffer; const struct region_device *rdev = mirror_dev_get(); - struct elog_state *es = car_get_var_ptr(&g_elog_state); - size_t size = region_device_sz(&es->nv_dev); + + size_t size = region_device_sz(&g_elog_state.nv_dev);
/* Fill memory buffer by reading from SPI */ mirror_buffer = rdev_mmap_full(rdev); - if (rdev_readat(&es->nv_dev, mirror_buffer, 0, size) != size) { + if (rdev_readat(&g_elog_state.nv_dev, mirror_buffer, 0, size) != size) { rdev_munmap(rdev, mirror_buffer); printk(BIOS_ERR, "ELOG: NV read failure.\n"); return -1; @@ -611,10 +579,8 @@
static int elog_shrink(void) { - struct elog_state *es = car_get_var_ptr(&g_elog_state); - if (elog_should_shrink()) - return elog_shrink_by_size(es->shrink_size); + return elog_shrink_by_size(g_elog_state.shrink_size); return 0; }
@@ -623,18 +589,16 @@ */ static inline u8 *elog_flash_offset_to_address(void) { - struct elog_state *es = car_get_var_ptr(&g_elog_state); - /* Only support memory-mapped devices. */ if (!CONFIG(BOOT_DEVICE_MEMORY_MAPPED)) return NULL;
- if (!region_device_sz(&es->nv_dev)) + if (!region_device_sz(&g_elog_state.nv_dev)) return NULL;
/* Get a view into the read-only boot device. */ - return rdev_mmap(boot_device_ro(), region_device_offset(&es->nv_dev), - region_device_sz(&es->nv_dev)); + return rdev_mmap(boot_device_ro(), region_device_offset(&g_elog_state.nv_dev), + region_device_sz(&g_elog_state.nv_dev)); }
/* @@ -646,8 +610,8 @@ struct smbios_type15 *t = (struct smbios_type15 *)*current; int len = sizeof(struct smbios_type15); uintptr_t log_address; - struct elog_state *es = car_get_var_ptr(&g_elog_state); - size_t elog_size = region_device_sz(&es->nv_dev); + + size_t elog_size = region_device_sz(&g_elog_state.nv_dev);
if (CONFIG(ELOG_CBMEM)) { /* Save event log buffer into CBMEM for the OS to read */ @@ -701,8 +665,7 @@ { size_t total_size; size_t reserved_space = ELOG_MIN_AVAILABLE_ENTRIES * MAX_EVENT_SIZE; - struct elog_state *es = car_get_var_ptr(&g_elog_state); - struct region_device *rdev = &es->nv_dev; + struct region_device *rdev = &g_elog_state.nv_dev;
elog_debug("%s()\n", __func__);
@@ -725,10 +688,10 @@ total_size = MIN(ELOG_SIZE, region_device_sz(rdev)); rdev_chain(rdev, rdev, 0, total_size);
- es->full_threshold = total_size - reserved_space; - es->shrink_size = total_size * ELOG_SHRINK_PERCENTAGE / 100; + g_elog_state.full_threshold = total_size - reserved_space; + g_elog_state.shrink_size = total_size * ELOG_SHRINK_PERCENTAGE / 100;
- if (reserved_space > es->shrink_size) { + if (reserved_space > g_elog_state.shrink_size) { printk(BIOS_ERR, "ELOG: SHRINK_PERCENTAGE too small\n"); return -1; } @@ -741,8 +704,6 @@ size_t offset; size_t size; bool erase_needed; - struct elog_state *es = car_get_var_ptr(&g_elog_state); - /* Determine if any updates are required. */ if (!elog_nv_needs_update()) return 0; @@ -773,7 +734,7 @@ if (elog_scan_flash() < 0) { printk(BIOS_ERR, "ELOG: Sync back from NV storage failed.\n"); elog_debug_dump_buffer("ELOG: Buffer from NV:\n"); - es->elog_initialized = ELOG_BROKEN; + g_elog_state.elog_initialized = ELOG_BROKEN; return -1; }
@@ -815,9 +776,7 @@ { void *mirror_buffer; size_t elog_size; - struct elog_state *es = car_get_var_ptr(&g_elog_state); - - switch (es->elog_initialized) { + switch (g_elog_state.elog_initialized) { case ELOG_UNINITIALIZED: break; case ELOG_INITIALIZED: @@ -825,7 +784,7 @@ case ELOG_BROKEN: return -1; } - es->elog_initialized = ELOG_BROKEN; + g_elog_state.elog_initialized = ELOG_BROKEN;
elog_debug("elog_init()\n");
@@ -833,19 +792,19 @@ if (elog_find_flash() < 0) return -1;
- elog_size = region_device_sz(&es->nv_dev); - mirror_buffer = get_elog_mirror_buffer(); + elog_size = region_device_sz(&g_elog_state.nv_dev); + mirror_buffer = elog_mirror_buf; if (!mirror_buffer) { printk(BIOS_ERR, "ELOG: Unable to allocate backing store\n"); return -1; } - mem_region_device_rw_init(&es->mirror_dev, mirror_buffer, elog_size); + mem_region_device_rw_init(&g_elog_state.mirror_dev, mirror_buffer, elog_size);
/* * Mark as initialized to allow elog_init() to be called and deemed * successful in the prepare/shrink path which adds events. */ - es->elog_initialized = ELOG_INITIALIZED; + g_elog_state.elog_initialized = ELOG_INITIALIZED;
/* Load the log from flash and prepare the flash if necessary. */ if (elog_scan_flash() < 0 && elog_prepare_empty() < 0) { @@ -854,8 +813,8 @@ }
printk(BIOS_INFO, "ELOG: area is %zu bytes, full threshold %d," - " shrink size %d\n", region_device_sz(&es->nv_dev), - es->full_threshold, es->shrink_size); + " shrink size %d\n", region_device_sz(&g_elog_state.nv_dev), + g_elog_state.full_threshold, g_elog_state.shrink_size);
if (ENV_PAYLOAD_LOADER) elog_add_boot_count(); diff --git a/src/drivers/i2c/tpm/cr50.c b/src/drivers/i2c/tpm/cr50.c index 6714bd4..6ec073e 100644 --- a/src/drivers/i2c/tpm/cr50.c +++ b/src/drivers/i2c/tpm/cr50.c @@ -27,7 +27,6 @@ * instead of just reading header and determining the remainder */
-#include <arch/early_variables.h> #include <commonlib/endian.h> #include <string.h> #include <types.h> @@ -55,15 +54,15 @@ uint8_t buf[CR50_MAX_BUFSIZE + sizeof(uint8_t)]; };
-static struct tpm_inf_dev g_tpm_dev CAR_GLOBAL; +static struct tpm_inf_dev g_tpm_dev;
__weak int tis_plat_irq_status(void) { - static int warning_displayed CAR_GLOBAL; + static int warning_displayed;
- if (!car_get_var(warning_displayed)) { + if (!warning_displayed) { printk(BIOS_WARNING, "WARNING: tis_plat_irq_status() not implemented, wasting 20ms to wait on Cr50!\n"); - car_set_var(warning_displayed, 1); + warning_displayed = 1; } mdelay(CR50_TIMEOUT_NOIRQ_MS);
@@ -101,16 +100,14 @@ static int cr50_i2c_read(struct tpm_chip *chip, uint8_t addr, uint8_t *buffer, size_t len) { - struct tpm_inf_dev *tpm_dev = car_get_var_ptr(&g_tpm_dev); - - if (tpm_dev->addr == 0) + if (g_tpm_dev.addr == 0) return -1;
/* Clear interrupt before starting transaction */ tis_plat_irq_status();
/* Send the register address byte to the TPM */ - if (i2c_write_raw(tpm_dev->bus, tpm_dev->addr, &addr, 1)) { + if (i2c_write_raw(g_tpm_dev.bus, g_tpm_dev.addr, &addr, 1)) { printk(BIOS_ERR, "%s: Address write failed\n", __func__); return -1; } @@ -120,7 +117,7 @@ return -1;
/* Read response data from the TPM */ - if (i2c_read_raw(tpm_dev->bus, tpm_dev->addr, buffer, len)) { + if (i2c_read_raw(g_tpm_dev.bus, g_tpm_dev.addr, buffer, len)) { printk(BIOS_ERR, "%s: Read response failed\n", __func__); return -1; } @@ -145,22 +142,20 @@ static int cr50_i2c_write(struct tpm_chip *chip, uint8_t addr, uint8_t *buffer, size_t len) { - struct tpm_inf_dev *tpm_dev = car_get_var_ptr(&g_tpm_dev); - - if (tpm_dev->addr == 0) + if (g_tpm_dev.addr == 0) return -1; if (len > CR50_MAX_BUFSIZE) return -1;
/* Prepend the 'register address' to the buffer */ - tpm_dev->buf[0] = addr; - memcpy(tpm_dev->buf + 1, buffer, len); + g_tpm_dev.buf[0] = addr; + memcpy(g_tpm_dev.buf + 1, buffer, len);
/* Clear interrupt before starting transaction */ tis_plat_irq_status();
/* Send write request buffer with address */ - if (i2c_write_raw(tpm_dev->bus, tpm_dev->addr, tpm_dev->buf, len + 1)) { + if (i2c_write_raw(g_tpm_dev.bus, g_tpm_dev.addr, g_tpm_dev.buf, len + 1)) { printk(BIOS_ERR, "%s: Error writing to TPM\n", __func__); return -1; } @@ -491,7 +486,6 @@
int tpm_vendor_init(struct tpm_chip *chip, unsigned int bus, uint32_t dev_addr) { - struct tpm_inf_dev *tpm_dev = car_get_var_ptr(&g_tpm_dev); uint32_t did_vid = 0;
if (dev_addr == 0) { @@ -499,8 +493,8 @@ return -1; }
- tpm_dev->bus = bus; - tpm_dev->addr = dev_addr; + g_tpm_dev.bus = bus; + g_tpm_dev.addr = dev_addr;
cr50_vendor_init(chip);
diff --git a/src/drivers/i2c/tpm/tis.c b/src/drivers/i2c/tpm/tis.c index e466c45..d791a56 100644 --- a/src/drivers/i2c/tpm/tis.c +++ b/src/drivers/i2c/tpm/tis.c @@ -12,7 +12,6 @@ * GNU General Public License for more details. */
-#include <arch/early_variables.h> #include <stdint.h> #include <string.h> #include <assert.h> @@ -27,25 +26,24 @@ #include "tpm.h"
/* global structure for tpm chip data */ -static struct tpm_chip g_chip CAR_GLOBAL; +static struct tpm_chip g_chip;
#define TPM_CMD_COUNT_BYTE 2 #define TPM_CMD_ORDINAL_BYTE 6
int tis_open(void) { - struct tpm_chip *chip = car_get_var_ptr(&g_chip); int rc;
- if (chip->is_open) { + if (g_chip.is_open) { printk(BIOS_DEBUG, "tis_open() called twice.\n"); return -1; }
- rc = tpm_vendor_init(chip, CONFIG_DRIVER_TPM_I2C_BUS, + rc = tpm_vendor_init(&g_chip, CONFIG_DRIVER_TPM_I2C_BUS, CONFIG_DRIVER_TPM_I2C_ADDR); if (rc < 0) - chip->is_open = 0; + g_chip.is_open = 0;
if (rc) return -1; @@ -55,11 +53,9 @@
int tis_close(void) { - struct tpm_chip *chip = car_get_var_ptr(&g_chip); - - if (chip->is_open) { - tpm_vendor_cleanup(chip); - chip->is_open = 0; + if (g_chip.is_open) { + tpm_vendor_cleanup(&g_chip); + g_chip.is_open = 0; }
return 0; @@ -76,12 +72,11 @@ { int rc; uint32_t count; - struct tpm_chip *chip = car_get_var_ptr(&g_chip);
memcpy(&count, sbuf + TPM_CMD_COUNT_BYTE, sizeof(count)); count = be32_to_cpu(count);
- if (!chip->vendor.send || !chip->vendor.status || !chip->vendor.cancel) + if (!g_chip.vendor.send || !g_chip.vendor.status || !g_chip.vendor.cancel) return -1;
if (count == 0) { @@ -94,8 +89,8 @@ return -1; }
- ASSERT(chip->vendor.send); - rc = chip->vendor.send(chip, (uint8_t *) sbuf, count); + ASSERT(g_chip.vendor.send); + rc = g_chip.vendor.send(&g_chip, (uint8_t *) sbuf, count); if (rc < 0) { printk(BIOS_DEBUG, "tpm_transmit: tpm_send error\n"); goto out; @@ -103,14 +98,14 @@
int timeout = 2 * 60 * 1000; /* two minutes timeout */ while (timeout) { - ASSERT(chip->vendor.status); - uint8_t status = chip->vendor.status(chip); - if ((status & chip->vendor.req_complete_mask) == - chip->vendor.req_complete_val) { + ASSERT(g_chip.vendor.status); + uint8_t status = g_chip.vendor.status(&g_chip); + if ((status & g_chip.vendor.req_complete_mask) == + g_chip.vendor.req_complete_val) { goto out_recv; }
- if (status == chip->vendor.req_canceled) { + if (status == g_chip.vendor.req_canceled) { printk(BIOS_DEBUG, "tpm_transmit: Operation Canceled\n"); rc = -1; @@ -120,15 +115,15 @@ timeout--; }
- ASSERT(chip->vendor.cancel); - chip->vendor.cancel(chip); + ASSERT(g_chip.vendor.cancel); + g_chip.vendor.cancel(&g_chip); printk(BIOS_DEBUG, "tpm_transmit: Operation Timed out\n"); rc = -1; //ETIME; goto out;
out_recv:
- rc = chip->vendor.recv(chip, (uint8_t *) rbuf, rbufsiz); + rc = g_chip.vendor.recv(&g_chip, (uint8_t *) rbuf, rbufsiz); if (rc < 0) printk(BIOS_DEBUG, "tpm_transmit: tpm_recv: error %d\n", rc); out: diff --git a/src/drivers/i2c/tpm/tis_atmel.c b/src/drivers/i2c/tpm/tis_atmel.c index 42df292..793418a 100644 --- a/src/drivers/i2c/tpm/tis_atmel.c +++ b/src/drivers/i2c/tpm/tis_atmel.c @@ -12,7 +12,6 @@ * GNU General Public License for more details. */
-#include <arch/early_variables.h> #include <assert.h> #include <commonlib/endian.h> #include <console/console.h> diff --git a/src/drivers/i2c/tpm/tpm.c b/src/drivers/i2c/tpm/tpm.c index e095084..71641d0 100644 --- a/src/drivers/i2c/tpm/tpm.c +++ b/src/drivers/i2c/tpm/tpm.c @@ -28,7 +28,6 @@ */
-#include <arch/early_variables.h> #include <commonlib/endian.h> #include <stdint.h> #include <string.h> @@ -81,7 +80,7 @@ enum i2c_chip_type chip_type; };
-static struct tpm_inf_dev g_tpm_dev CAR_GLOBAL; +static struct tpm_inf_dev g_tpm_dev;
/* * iic_tpm_read() - read from TPM register @@ -99,24 +98,23 @@ */ static int iic_tpm_read(uint8_t addr, uint8_t *buffer, size_t len) { - struct tpm_inf_dev *tpm_dev = car_get_var_ptr(&g_tpm_dev); int rc; int count;
- if (tpm_dev->addr == 0) + if (g_tpm_dev.addr == 0) return -1;
- switch (tpm_dev->chip_type) { + switch (g_tpm_dev.chip_type) { case SLB9635: case UNKNOWN: /* slb9635 protocol should work in both cases */ for (count = 0; count < MAX_COUNT; count++) { - rc = i2c_write_raw(tpm_dev->bus, tpm_dev->addr, + rc = i2c_write_raw(g_tpm_dev.bus, g_tpm_dev.addr, &addr, 1); if (rc == 0) break; /* success, break to skip sleep */
- udelay(tpm_dev->sleep_short); + udelay(g_tpm_dev.sleep_short); }
if (rc) @@ -127,8 +125,8 @@ * retrieving the data */ for (count = 0; count < MAX_COUNT; count++) { - udelay(tpm_dev->sleep_short); - rc = i2c_read_raw(tpm_dev->bus, tpm_dev->addr, + udelay(g_tpm_dev.sleep_short); + rc = i2c_read_raw(g_tpm_dev.bus, g_tpm_dev.addr, buffer, len); if (rc == 0) break; /* success, break to skip sleep */ @@ -144,23 +142,23 @@ * retries should usually not be needed, but are kept just to * be safe on the safe side. */ - struct i2c_msg aseg = { .flags = 0, .slave = tpm_dev->addr, + struct i2c_msg aseg = { .flags = 0, .slave = g_tpm_dev.addr, .buf = &addr, .len = 1 }; struct i2c_msg dseg = { .flags = I2C_M_RD, - .slave = tpm_dev->addr, + .slave = g_tpm_dev.addr, .buf = buffer, .len = len }; for (count = 0; count < MAX_COUNT; count++) { - rc = i2c_transfer(tpm_dev->bus, &aseg, 1) || - i2c_transfer(tpm_dev->bus, &dseg, 1); + rc = i2c_transfer(g_tpm_dev.bus, &aseg, 1) || + i2c_transfer(g_tpm_dev.bus, &dseg, 1); if (rc == 0) break; /* break here to skip sleep */ - udelay(tpm_dev->sleep_short); + udelay(g_tpm_dev.sleep_short); } } }
/* take care of 'guard time' */ - udelay(tpm_dev->sleep_short); + udelay(g_tpm_dev.sleep_short); if (rc) return -1;
@@ -171,7 +169,6 @@ unsigned int sleep_time, uint8_t max_count) { - struct tpm_inf_dev *tpm_dev = car_get_var_ptr(&g_tpm_dev); int rc = 0; int count;
@@ -182,14 +179,14 @@ }
/* prepare send buffer */ - tpm_dev->buf[0] = addr; - memcpy(&(tpm_dev->buf[1]), buffer, len); + g_tpm_dev.buf[0] = addr; + memcpy(&(g_tpm_dev.buf[1]), buffer, len);
- if (tpm_dev->addr == 0) + if (g_tpm_dev.addr == 0) return -1; for (count = 0; count < max_count; count++) { - rc = i2c_write_raw(tpm_dev->bus, tpm_dev->addr, - tpm_dev->buf, len + 1); + rc = i2c_write_raw(g_tpm_dev.bus, g_tpm_dev.addr, + g_tpm_dev.buf, len + 1); if (rc == 0) break; /* success, break to skip sleep */
@@ -197,7 +194,7 @@ }
/* take care of 'guard time' */ - udelay(tpm_dev->sleep_short); + udelay(g_tpm_dev.sleep_short); if (rc) return -1;
@@ -222,8 +219,7 @@ */ static int iic_tpm_write(uint8_t addr, uint8_t *buffer, size_t len) { - struct tpm_inf_dev *tpm_dev = car_get_var_ptr(&g_tpm_dev); - return iic_tpm_write_generic(addr, buffer, len, tpm_dev->sleep_short, + return iic_tpm_write_generic(addr, buffer, len, g_tpm_dev.sleep_short, MAX_COUNT); }
@@ -233,8 +229,7 @@ * */ static int iic_tpm_write_long(uint8_t addr, uint8_t *buffer, size_t len) { - struct tpm_inf_dev *tpm_dev = car_get_var_ptr(&g_tpm_dev); - return iic_tpm_write_generic(addr, buffer, len, tpm_dev->sleep_long, + return iic_tpm_write_generic(addr, buffer, len, g_tpm_dev.sleep_long, MAX_COUNT_LONG); }
@@ -479,17 +474,16 @@
int tpm_vendor_probe(unsigned int bus, uint32_t addr) { - struct tpm_inf_dev *tpm_dev = car_get_var_ptr(&g_tpm_dev); struct stopwatch sw; uint8_t buf = 0; int ret; long sw_run_duration = SLEEP_DURATION_PROBE_MS;
- tpm_dev->chip_type = UNKNOWN; - tpm_dev->bus = bus; - tpm_dev->addr = addr; - tpm_dev->sleep_short = SLEEP_DURATION; - tpm_dev->sleep_long = SLEEP_DURATION_LONG; + g_tpm_dev.chip_type = UNKNOWN; + g_tpm_dev.bus = bus; + g_tpm_dev.addr = addr; + g_tpm_dev.sleep_short = SLEEP_DURATION; + g_tpm_dev.sleep_long = SLEEP_DURATION_LONG;
/* * Probe TPM. Check if the TPM_ACCESS register's ValidSts bit is set(1) @@ -521,7 +515,6 @@
int tpm_vendor_init(struct tpm_chip *chip, unsigned int bus, uint32_t dev_addr) { - struct tpm_inf_dev *tpm_dev = car_get_var_ptr(&g_tpm_dev); uint32_t vendor;
if (dev_addr == 0) { @@ -529,11 +522,11 @@ return -1; }
- tpm_dev->chip_type = UNKNOWN; - tpm_dev->bus = bus; - tpm_dev->addr = dev_addr; - tpm_dev->sleep_short = SLEEP_DURATION; - tpm_dev->sleep_long = SLEEP_DURATION_LONG; + g_tpm_dev.chip_type = UNKNOWN; + g_tpm_dev.bus = bus; + g_tpm_dev.addr = dev_addr; + g_tpm_dev.sleep_short = SLEEP_DURATION; + g_tpm_dev.sleep_long = SLEEP_DURATION_LONG;
memset(&chip->vendor, 0, sizeof(struct tpm_vendor_specific)); chip->is_open = 1; @@ -554,9 +547,9 @@ goto out_err;
if (vendor == TPM_TIS_I2C_DID_VID_9645) { - tpm_dev->chip_type = SLB9645; + g_tpm_dev.chip_type = SLB9645; } else if (be32_to_cpu(vendor) == TPM_TIS_I2C_DID_VID_9635) { - tpm_dev->chip_type = SLB9635; + g_tpm_dev.chip_type = SLB9635; } else { printk(BIOS_DEBUG, "Vendor ID 0x%08x not recognized.\n", vendor); @@ -564,8 +557,8 @@ }
printk(BIOS_DEBUG, "I2C TPM %u:%02x (chip type %s device-id 0x%X)\n", - tpm_dev->bus, tpm_dev->addr, - chip_name[tpm_dev->chip_type], vendor >> 16); + g_tpm_dev.bus, g_tpm_dev.addr, + chip_name[g_tpm_dev.chip_type], vendor >> 16);
/* * A timeout query to TPM can be placed here. diff --git a/src/drivers/pc80/pc/i8254.c b/src/drivers/pc80/pc/i8254.c index 5090f0c..9d23d46 100644 --- a/src/drivers/pc80/pc/i8254.c +++ b/src/drivers/pc80/pc/i8254.c @@ -11,7 +11,6 @@ * GNU General Public License for more details. */
-#include <arch/early_variables.h> #include <arch/io.h> #include <commonlib/helpers.h> #include <cpu/x86/tsc.h> @@ -107,23 +106,19 @@ }
#if CONFIG(UNKNOWN_TSC_RATE) -static u32 g_timer_tsc CAR_GLOBAL; +static u32 g_timer_tsc;
unsigned long tsc_freq_mhz(void) { - u32 tsc; + if (g_timer_tsc > 0) + return g_timer_tsc;
- tsc = car_get_var(g_timer_tsc); - if (tsc > 0) - return tsc; - - tsc = calibrate_tsc_with_pit(); + g_timer_tsc = calibrate_tsc_with_pit();
/* Set some semi-ridiculous rate if approximation fails. */ - if (tsc == 0) - tsc = 5000; + if (g_timer_tsc == 0) + g_timer_tsc = 5000;
- car_set_var(g_timer_tsc, tsc); - return tsc; + return g_timer_tsc; } #endif diff --git a/src/drivers/pc80/tpm/tis.c b/src/drivers/pc80/tpm/tis.c index 1baab26..39fa70d 100644 --- a/src/drivers/pc80/tpm/tis.c +++ b/src/drivers/pc80/tpm/tis.c @@ -31,7 +31,6 @@ #include <device/device.h> #include <console/console.h> #include <security/tpm/tis.h> -#include <arch/early_variables.h> #include <device/pnp.h> #include "chip.h"
@@ -162,7 +161,7 @@ * Cached vendor/device ID pair to indicate that the device has been already * discovered */ -static u32 vendor_dev_id CAR_GLOBAL; +static u32 vendor_dev_id;
static inline u8 tpm_read_status(int locality) { @@ -402,7 +401,7 @@ u16 vid, did; int i;
- if (car_get_var(vendor_dev_id)) + if (vendor_dev_id) return 0; /* Already probed. */
didvid = tpm_read_did_vid(0); @@ -411,7 +410,7 @@ return TPM_DRIVER_ERR; }
- car_set_var(vendor_dev_id, didvid); + vendor_dev_id = didvid;
vid = didvid & 0xffff; did = (didvid >> 16) & 0xffff; diff --git a/src/drivers/spi/boot_device_rw_nommap.c b/src/drivers/spi/boot_device_rw_nommap.c index 4768314..5de9a71 100644 --- a/src/drivers/spi/boot_device_rw_nommap.c +++ b/src/drivers/spi/boot_device_rw_nommap.c @@ -11,24 +11,18 @@ * GNU General Public License for more details. */
-#include <arch/early_variables.h> #include <boot_device.h> #include <spi_flash.h> #include <spi-generic.h> #include <stdint.h>
-static struct spi_flash sfg CAR_GLOBAL; -static bool sfg_init_done CAR_GLOBAL; +static struct spi_flash sfg; +static bool sfg_init_done;
static ssize_t spi_readat(const struct region_device *rd, void *b, size_t offset, size_t size) { - struct spi_flash *sf = car_get_var_ptr(&sfg); - - if (sf == NULL) - return -1; - - if (spi_flash_read(sf, offset, size, b)) + if (spi_flash_read(&sfg, offset, size, b)) return -1;
return size; @@ -37,12 +31,7 @@ static ssize_t spi_writeat(const struct region_device *rd, const void *b, size_t offset, size_t size) { - struct spi_flash *sf = car_get_var_ptr(&sfg); - - if (sf == NULL) - return -1; - - if (spi_flash_write(sf, offset, size, b)) + if (spi_flash_write(&sfg, offset, size, b)) return -1;
return size; @@ -51,12 +40,7 @@ static ssize_t spi_eraseat(const struct region_device *rd, size_t offset, size_t size) { - struct spi_flash *sf = car_get_var_ptr(&sfg); - - if (sf == NULL) - return -1; - - if (spi_flash_erase(sf, offset, size)) + if (spi_flash_erase(&sfg, offset, size)) return -1;
return size; @@ -76,14 +60,14 @@ const int bus = CONFIG_BOOT_DEVICE_SPI_FLASH_BUS; const int cs = 0;
- if (car_get_var(sfg_init_done) == true) + if (sfg_init_done == true) return;
/* Ensure any necessary setup is performed by the drivers. */ spi_init();
- if (!spi_flash_probe(bus, cs, car_get_var_ptr(&sfg))) - car_set_var(sfg_init_done, true); + if (!spi_flash_probe(bus, cs, &sfg)) + sfg_init_done = true; }
const struct region_device *boot_device_rw(void) @@ -91,7 +75,7 @@ /* Probe for the SPI flash device if not already done. */ boot_device_rw_init();
- if (car_get_var(sfg_init_done) != true) + if (sfg_init_done != true) return NULL;
return &spi_rw; @@ -101,10 +85,10 @@ { boot_device_rw_init();
- if (car_get_var(sfg_init_done) != true) + if (sfg_init_done != true) return NULL;
- return car_get_var_ptr(&sfg); + return &sfg; }
int boot_device_wp_region(const struct region_device *rd, @@ -122,7 +106,7 @@
if (type == MEDIA_WP) { if (spi_flash_is_write_protected(boot_dev, - region_device_region(rd)) != 1) { + region_device_region(rd)) != 1) { return spi_flash_set_write_protected(boot_dev, region_device_region(rd), true, SPI_WRITE_PROTECTION_REBOOT); diff --git a/src/drivers/spi/flashconsole.c b/src/drivers/spi/flashconsole.c index 8874812..991460f 100644 --- a/src/drivers/spi/flashconsole.c +++ b/src/drivers/spi/flashconsole.c @@ -11,7 +11,6 @@ * GNU General Public License for more details. */
-#include <arch/early_variables.h> #include <commonlib/region.h> #include <boot_device.h> #include <fmap.h> @@ -23,26 +22,25 @@ #define LINE_BUFFER_SIZE 128 #define READ_BUFFER_SIZE 0x100
-static const struct region_device *g_rdev_ptr CAR_GLOBAL; -static struct region_device g_rdev CAR_GLOBAL; -static uint8_t g_line_buffer[LINE_BUFFER_SIZE] CAR_GLOBAL; -static size_t g_offset CAR_GLOBAL; -static size_t g_line_offset CAR_GLOBAL; +static const struct region_device *g_rdev_ptr; +static struct region_device g_rdev; +static uint8_t g_line_buffer[LINE_BUFFER_SIZE]; +static size_t g_offset; +static size_t g_line_offset;
void flashconsole_init(void) { - struct region_device *rdev = car_get_var_ptr(&g_rdev); uint8_t buffer[READ_BUFFER_SIZE]; size_t size; size_t offset = 0; size_t len = READ_BUFFER_SIZE; size_t i;
- if (fmap_locate_area_as_rdev_rw("CONSOLE", rdev)) { + if (fmap_locate_area_as_rdev_rw("CONSOLE", &g_rdev)) { printk(BIOS_INFO, "Can't find 'CONSOLE' area in FMAP\n"); return; } - size = region_device_sz(rdev); + size = region_device_sz(&g_rdev);
/* * We need to check the region until we find a 0xff indicating @@ -58,7 +56,7 @@ // Fill the buffer on first iteration if (i == 0) { len = min(READ_BUFFER_SIZE, size - offset); - if (rdev_readat(rdev, buffer, offset, len) != len) + if (rdev_readat(&g_rdev, buffer, offset, len) != len) return; } if (buffer[i] == 0xff) { @@ -77,65 +75,49 @@ return; }
- car_set_var(g_offset, offset); - /* Set g_rdev_ptr last so tx_byte doesn't get executed early */ - car_set_var(g_rdev_ptr, rdev); + g_offset = offset; + g_rdev_ptr = &g_rdev; }
void flashconsole_tx_byte(unsigned char c) { - const struct region_device *rdev = car_get_var(g_rdev_ptr); - uint8_t *line_buffer; - size_t offset; - size_t len; - size_t region_size; + size_t region_size = region_device_sz(g_rdev_ptr);
- if (!rdev) - return; + g_line_buffer[g_line_offset++] = c;
- line_buffer = car_get_var_ptr(g_line_buffer); - offset = car_get_var(g_offset); - len = car_get_var(g_line_offset); - region_size = region_device_sz(rdev); - - line_buffer[len++] = c; - car_set_var(g_line_offset, len); - - if (len >= LINE_BUFFER_SIZE || - offset + len >= region_size || c == '\n') { + if (g_line_offset >= LINE_BUFFER_SIZE || + g_offset + g_line_offset >= region_size || c == '\n') { flashconsole_tx_flush(); } }
void flashconsole_tx_flush(void) { - const struct region_device *rdev = car_get_var(g_rdev_ptr); - uint8_t *line_buffer = car_get_var_ptr(g_line_buffer); - size_t offset = car_get_var(g_offset); - size_t len = car_get_var(g_line_offset); + size_t offset = g_offset; + size_t len = g_line_offset; size_t region_size; - - if (!rdev) - return; + static int busy;
/* Prevent any recursive loops in case the spi flash driver * calls printk (in case of transaction timeout or * any other error while writing) */ - car_set_var(g_rdev_ptr, NULL); + if (busy) + return;
- region_size = region_device_sz(rdev); + busy = 1; + region_size = region_device_sz(g_rdev_ptr); if (offset + len >= region_size) len = region_size - offset;
- if (rdev_writeat(rdev, line_buffer, offset, len) != len) - rdev = NULL; + if (rdev_writeat(&g_rdev, g_line_buffer, offset, len) != len) + return;
// If the region is full, stop future write attempts if (offset + len >= region_size) - rdev = NULL; + return;
- car_set_var(g_offset, offset + len); - car_set_var(g_line_offset, 0); + g_offset = offset + len; + g_line_offset = 0;
- car_set_var(g_rdev_ptr, rdev); + busy = 0; } diff --git a/src/drivers/spi/spi_flash.c b/src/drivers/spi/spi_flash.c index 7b5266a..f0d0159 100644 --- a/src/drivers/spi/spi_flash.c +++ b/src/drivers/spi/spi_flash.c @@ -12,7 +12,6 @@ * GNU General Public License for more details. */
-#include <arch/early_variables.h> #include <assert.h> #include <boot_device.h> #include <boot/coreboot_tables.h> @@ -522,7 +521,7 @@ return ret; }
-static uint32_t volatile_group_count CAR_GLOBAL; +static uint32_t volatile_group_count;
int spi_flash_volatile_group_begin(const struct spi_flash *flash) { @@ -532,12 +531,12 @@ if (!CONFIG(SPI_FLASH_HAS_VOLATILE_GROUP)) return ret;
- count = car_get_var(volatile_group_count); + count = volatile_group_count; if (count == 0) ret = chipset_volatile_group_begin(flash);
count++; - car_set_var(volatile_group_count, count); + volatile_group_count = count; return ret; }
@@ -549,10 +548,10 @@ if (!CONFIG(SPI_FLASH_HAS_VOLATILE_GROUP)) return ret;
- count = car_get_var(volatile_group_count); + count = volatile_group_count; assert(count == 0); count--; - car_set_var(volatile_group_count, count); + volatile_group_count = count;
if (count == 0) ret = chipset_volatile_group_end(flash); diff --git a/src/drivers/spi/tpm/tis.c b/src/drivers/spi/tpm/tis.c index b50ab0a..7d42b7c 100644 --- a/src/drivers/spi/tpm/tis.c +++ b/src/drivers/spi/tpm/tis.c @@ -4,13 +4,12 @@ * found in the LICENSE file. */
-#include <arch/early_variables.h> #include <console/console.h> #include <security/tpm/tis.h>
#include "tpm.h"
-static unsigned tpm_is_open CAR_GLOBAL; +static unsigned tpm_is_open;
static const struct { uint16_t vid; @@ -34,7 +33,7 @@
int tis_open(void) { - if (car_get_var(tpm_is_open)) { + if (tpm_is_open) { printk(BIOS_ERR, "tis_open() called twice.\n"); return -1; } @@ -43,13 +42,13 @@
int tis_close(void) { - if (car_get_var(tpm_is_open)) { + if (tpm_is_open) {
/* * Do we need to do something here, like waiting for a * transaction to stop? */ - car_set_var(tpm_is_open, 0); + tpm_is_open = 0; }
return 0; diff --git a/src/drivers/spi/tpm/tpm.c b/src/drivers/spi/tpm/tpm.c index 270b15b..d3d36c9 100644 --- a/src/drivers/spi/tpm/tpm.c +++ b/src/drivers/spi/tpm/tpm.c @@ -15,7 +15,6 @@ * Specification Revision 00.43". */
-#include <arch/early_variables.h> #include <assert.h> #include <commonlib/endian.h> #include <console/console.h> @@ -40,10 +39,10 @@ #define CR50_TIMEOUT_INIT_MS 30000 /* Very long timeout for TPM init */
/* SPI slave structure for TPM device. */ -static struct spi_slave g_spi_slave CAR_GLOBAL; +static struct spi_slave g_spi_slave;
/* Cached TPM device identification. */ -static struct tpm2_info g_tpm_info CAR_GLOBAL; +static struct tpm2_info g_tpm_info;
/* * TODO(vbendeb): make CONFIG_DEBUG_TPM an int to allow different level of @@ -61,16 +60,16 @@
void tpm2_get_info(struct tpm2_info *info) { - *info = car_get_var(g_tpm_info); + *info = g_tpm_info; }
__weak int tis_plat_irq_status(void) { - static int warning_displayed CAR_GLOBAL; + static int warning_displayed;
- if (!car_get_var(warning_displayed)) { + if (!warning_displayed) { printk(BIOS_WARNING, "WARNING: tis_plat_irq_status() not implemented, wasting 10ms to wait on Cr50!\n"); - car_set_var(warning_displayed, 1); + warning_displayed = 1; } mdelay(10);
@@ -109,9 +108,8 @@ uint8_t byte; int i; struct stopwatch sw; - static int tpm_sync_needed CAR_GLOBAL; - static struct stopwatch wake_up_sw CAR_GLOBAL; - struct spi_slave *spi_slave = car_get_var_ptr(&g_spi_slave); + static int tpm_sync_needed; + static struct stopwatch wake_up_sw; /* * First Cr50 access in each coreboot stage where TPM is used will be * prepended by a wake up pulse on the CS line. @@ -119,7 +117,7 @@ int wakeup_needed = 1;
/* Wait for TPM to finish previous transaction if needed */ - if (car_get_var(tpm_sync_needed)) { + if (tpm_sync_needed) { tpm_sync(); /* * During the first invocation of this function on each stage @@ -127,17 +125,17 @@ * value is zero), during all following invocations the * stopwatch below is guaranteed to be started. */ - if (!stopwatch_expired(car_get_var_ptr(&wake_up_sw))) + if (!stopwatch_expired(&wake_up_sw)) wakeup_needed = 0; } else { - car_set_var(tpm_sync_needed, 1); + tpm_sync_needed = 1; }
if (wakeup_needed) { /* Just in case Cr50 is asleep. */ - spi_claim_bus(spi_slave); + spi_claim_bus(&g_spi_slave); udelay(1); - spi_release_bus(spi_slave); + spi_release_bus(&g_spi_slave); udelay(100); }
@@ -146,7 +144,7 @@ * SPI slave activity, let's be conservative and limit the * window to 900 ms. */ - stopwatch_init_msecs_expire(car_get_var_ptr(&wake_up_sw), 900); + stopwatch_init_msecs_expire(&wake_up_sw, 900);
/* * The first byte of the frame header encodes the transaction type @@ -160,7 +158,7 @@ header.body[i + 1] = (addr >> (8 * (2 - i))) & 0xff;
/* CS assert wakes up the slave. */ - spi_claim_bus(spi_slave); + spi_claim_bus(&g_spi_slave);
/* * The TCG TPM over SPI specification introduces the notion of SPI @@ -187,7 +185,7 @@ * to require to stall the master, this would present an issue. * crosbug.com/p/52132 has been opened to track this. */ - spi_xfer(spi_slave, header.body, sizeof(header.body), NULL, 0); + spi_xfer(&g_spi_slave, header.body, sizeof(header.body), NULL, 0);
/* * Now poll the bus until TPM removes the stall bit. Give it up to 100 @@ -198,10 +196,10 @@ do { if (stopwatch_expired(&sw)) { printk(BIOS_ERR, "TPM flow control failure\n"); - spi_release_bus(spi_slave); + spi_release_bus(&g_spi_slave); return 0; } - spi_xfer(spi_slave, NULL, 0, &byte, 1); + spi_xfer(&g_spi_slave, NULL, 0, &byte, 1); } while (!(byte & 1)); return 1; } @@ -214,11 +212,10 @@ size_t bytes, const uint8_t *buffer, int force) { - static char prev_prefix CAR_GLOBAL; - static unsigned prev_reg CAR_GLOBAL; - static int current_char CAR_GLOBAL; + static char prev_prefix; + static unsigned int prev_reg; + static int current_char; const int BYTES_PER_LINE = 32; - int *current_char_ptr = car_get_var_ptr(¤t_char);
if (!force) { if (!debug_level_) @@ -232,12 +229,11 @@ * Do not print register address again if the last dump print was for * that register. */ - if ((car_get_var(prev_prefix) != *prefix) || - (car_get_var(prev_reg) != reg)) { - car_set_var(prev_prefix, *prefix); - car_set_var(prev_reg, reg); + if (prev_prefix != *prefix || (prev_reg != reg)) { + prev_prefix = *prefix; + prev_reg = reg; printk(BIOS_DEBUG, "\n%s %2.2x:", prefix, reg); - *current_char_ptr = 0; + current_char = 0; }
if ((reg != TPM_DATA_FIFO_REG) && (bytes == 4)) { @@ -254,12 +250,12 @@ * quantiites is printed byte at a time. */ for (i = 0; i < bytes; i++) { - if (*current_char_ptr && - !(*current_char_ptr % BYTES_PER_LINE)) { + if (current_char && + !(current_char % BYTES_PER_LINE)) { printk(BIOS_DEBUG, "\n "); - *current_char_ptr = 0; + current_char = 0; } - (*current_char_ptr)++; + (current_char)++; printk(BIOS_DEBUG, " %2.2x", buffer[i]); } } @@ -271,8 +267,7 @@ */ static void write_bytes(const void *buffer, size_t bytes) { - struct spi_slave *spi_slave = car_get_var_ptr(&g_spi_slave); - spi_xfer(spi_slave, buffer, bytes, NULL, 0); + spi_xfer(&g_spi_slave, buffer, bytes, NULL, 0); }
/* @@ -281,8 +276,7 @@ */ static void read_bytes(void *buffer, size_t bytes) { - struct spi_slave *spi_slave = car_get_var_ptr(&g_spi_slave); - spi_xfer(spi_slave, NULL, 0, buffer, bytes); + spi_xfer(&g_spi_slave, NULL, 0, buffer, bytes); }
/* @@ -293,12 +287,11 @@ */ static int tpm2_write_reg(unsigned int reg_number, const void *buffer, size_t bytes) { - struct spi_slave *spi_slave = car_get_var_ptr(&g_spi_slave); trace_dump("W", reg_number, bytes, buffer, 0); if (!start_transaction(false, bytes, reg_number)) return 0; write_bytes(buffer, bytes); - spi_release_bus(spi_slave); + spi_release_bus(&g_spi_slave); return 1; }
@@ -311,13 +304,12 @@ */ static int tpm2_read_reg(unsigned int reg_number, void *buffer, size_t bytes) { - struct spi_slave *spi_slave = car_get_var_ptr(&g_spi_slave); if (!start_transaction(true, bytes, reg_number)) { memset(buffer, 0, bytes); return 0; } read_bytes(buffer, bytes); - spi_release_bus(spi_slave); + spi_release_bus(&g_spi_slave); trace_dump("R", reg_number, bytes, buffer, 0); return 1; } @@ -424,10 +416,8 @@ uint32_t did_vid, status; uint8_t cmd; int retries; - struct tpm2_info *tpm_info = car_get_var_ptr(&g_tpm_info); - struct spi_slave *spi_slave = car_get_var_ptr(&g_spi_slave);
- memcpy(spi_slave, spi_if, sizeof(*spi_if)); + memcpy(&g_spi_slave, spi_if, sizeof(*spi_if));
/* clear any pending IRQs */ tis_plat_irq_status(); @@ -484,15 +474,15 @@ * structure. */ tpm2_read_reg(TPM_RID_REG, &cmd, sizeof(cmd)); - tpm_info->vendor_id = did_vid & 0xffff; - tpm_info->device_id = did_vid >> 16; - tpm_info->revision = cmd; + g_tpm_info.vendor_id = did_vid & 0xffff; + g_tpm_info.device_id = did_vid >> 16; + g_tpm_info.revision = cmd;
printk(BIOS_INFO, "Connected to device vid:did:rid of %4.4x:%4.4x:%2.2x\n", - tpm_info->vendor_id, tpm_info->device_id, tpm_info->revision); + g_tpm_info.vendor_id, g_tpm_info.device_id, g_tpm_info.revision);
/* Let's report device FW version if available. */ - if (tpm_info->vendor_id == 0x1ae0) { + if (g_tpm_info.vendor_id == 0x1ae0) { int chunk_count = 0; size_t chunk_size; /* @@ -619,10 +609,9 @@ uint8_t *rsp_body = tpm2_response; union fifo_transfer_buffer fifo_buffer; const int HEADER_SIZE = 6; - struct tpm2_info *tpm_info = car_get_var_ptr(&g_tpm_info);
/* Do not try using an uninitialized TPM. */ - if (!tpm_info->vendor_id) + if (!g_tpm_info.vendor_id) return 0;
/* Skip the two byte tag, read the size field. */ diff --git a/src/drivers/uart/oxpcie_early.c b/src/drivers/uart/oxpcie_early.c index f6b4040..d12b42a 100644 --- a/src/drivers/uart/oxpcie_early.c +++ b/src/drivers/uart/oxpcie_early.c @@ -14,12 +14,11 @@ #include <stdint.h> #include <stddef.h> #include <device/pci_ops.h> -#include <arch/early_variables.h> #include <console/uart.h> #include <device/pci.h> #include <device/pci_def.h>
-static unsigned int oxpcie_present CAR_GLOBAL; +static unsigned int oxpcie_present; static DEVTREE_CONST u32 uart0_base = CONFIG_EARLY_PCI_MMIO_BASE + 0x1000;
int pci_early_device_probe(u8 bus, u8 dev, u32 mmio_base) @@ -58,13 +57,13 @@ reg16 |= PCI_COMMAND_MEMORY; pci_s_write_config16(device, PCI_COMMAND, reg16);
- car_set_var(oxpcie_present, 1); + oxpcie_present = 1; return 0; }
static int oxpcie_uart_active(void) { - return (car_get_var(oxpcie_present)); + return oxpcie_present; }
uintptr_t uart_platform_base(int idx) diff --git a/src/drivers/usb/ehci_debug.c b/src/drivers/usb/ehci_debug.c index 398f5db..e77cd85 100644 --- a/src/drivers/usb/ehci_debug.c +++ b/src/drivers/usb/ehci_debug.c @@ -17,7 +17,6 @@ #include <arch/io.h> #include <device/mmio.h> #include <arch/symbols.h> -#include <arch/early_variables.h> #include <string.h> #include <cbmem.h>
@@ -59,12 +58,12 @@ static int dbgp_enabled(void); static void dbgp_print_data(struct ehci_dbg_port *ehci_debug);
-static struct ehci_debug_info glob_dbg_info CAR_GLOBAL; -static struct ehci_debug_info * glob_dbg_info_p CAR_GLOBAL; +static struct ehci_debug_info glob_dbg_info; +static struct ehci_debug_info * glob_dbg_info_p;
static inline struct ehci_debug_info *dbgp_ehci_info(void) { - if (car_get_ptr(glob_dbg_info_p) == NULL) { + if (glob_dbg_info_p == NULL) { struct ehci_debug_info *info; if (ENV_BOOTBLOCK || ENV_VERSTAGE || ENV_ROMSTAGE) { /* The message likely does not show if we hit this. */ @@ -74,9 +73,9 @@ } else { info = &glob_dbg_info; } - car_set_ptr(glob_dbg_info_p, info); + glob_dbg_info_p = info; } - return car_get_ptr(glob_dbg_info_p); + return glob_dbg_info_p; }
static int dbgp_wait_until_complete(struct ehci_dbg_port *ehci_debug) @@ -713,7 +712,7 @@ if (dbg_info_cbmem == NULL) return; memcpy(dbg_info_cbmem, dbg_info, sizeof(*dbg_info)); - car_set_ptr(glob_dbg_info_p, dbg_info_cbmem); + glob_dbg_info_p = dbg_info_cbmem; return; }
@@ -721,7 +720,7 @@ /* Use state in CBMEM. */ dbg_info_cbmem = cbmem_find(CBMEM_ID_EHCI_DEBUG); if (dbg_info_cbmem) - car_set_ptr(glob_dbg_info_p, dbg_info_cbmem); + glob_dbg_info_p = dbg_info_cbmem; }
rv = usbdebug_hw_init(false); diff --git a/src/drivers/vpd/vpd.c b/src/drivers/vpd/vpd.c index 10f5703..b81a719 100644 --- a/src/drivers/vpd/vpd.c +++ b/src/drivers/vpd/vpd.c @@ -4,7 +4,6 @@ * found in the LICENSE file. */
-#include <arch/early_variables.h> #include <assert.h> #include <console/console.h> #include <cbmem.h> @@ -24,7 +23,7 @@ int matched; };
-struct vpd_blob g_vpd_blob CAR_GLOBAL = {0}; +struct vpd_blob g_vpd_blob;
/* * returns the size of data in a VPD 2.0 formatted fmap region, or 0. @@ -86,13 +85,10 @@ if (ro_vpd_size == 0 && rw_vpd_size == 0) return;
- struct vpd_blob *blob = car_get_var_ptr(&g_vpd_blob); - if (!blob) - return; - blob->ro_base = NULL; - blob->ro_size = 0; - blob->rw_base = NULL; - blob->rw_size = 0; + g_vpd_blob.ro_base = NULL; + g_vpd_blob.ro_size = 0; + g_vpd_blob.rw_base = NULL; + g_vpd_blob.rw_size = 0;
struct region_device vpd;
@@ -105,9 +101,9 @@ } rdev_chain(&vpd, &vpd, GOOGLE_VPD_2_0_OFFSET, region_device_sz(&vpd) - GOOGLE_VPD_2_0_OFFSET); - blob->ro_base = (uint8_t *)(rdev_mmap_full(&vpd) + + g_vpd_blob.ro_base = (uint8_t *)(rdev_mmap_full(&vpd) + sizeof(struct google_vpd_info)); - blob->ro_size = ro_vpd_size; + g_vpd_blob.ro_size = ro_vpd_size; } if (rw_vpd_size) { if (fmap_locate_area_as_rdev("RW_VPD", &vpd)) { @@ -118,23 +114,19 @@ } rdev_chain(&vpd, &vpd, GOOGLE_VPD_2_0_OFFSET, region_device_sz(&vpd) - GOOGLE_VPD_2_0_OFFSET); - blob->rw_base = (uint8_t *)(rdev_mmap_full(&vpd) + + g_vpd_blob.rw_base = (uint8_t *)(rdev_mmap_full(&vpd) + sizeof(struct google_vpd_info)); - blob->rw_size = rw_vpd_size; + g_vpd_blob.rw_size = rw_vpd_size; } - blob->initialized = true; + g_vpd_blob.initialized = true; }
const struct vpd_blob *vpd_load_blob(void) { - struct vpd_blob *blob = NULL; - - blob = car_get_var_ptr(&g_vpd_blob); - - if (blob && blob->initialized == false) + if (g_vpd_blob.initialized == false) vpd_get_blob();
- return blob; + return &g_vpd_blob; }
static int vpd_gets_callback(const uint8_t *key, uint32_t key_len, diff --git a/src/drivers/vpd/vpd.h b/src/drivers/vpd/vpd.h index 1bae513..05b7db8 100644 --- a/src/drivers/vpd/vpd.h +++ b/src/drivers/vpd/vpd.h @@ -28,7 +28,7 @@ extern struct vpd_blob g_vpd_blob;
/* - * This function loads g_vpd_blob CAR_GLOBAL variable. + * This function loads g_vpd_blob global variable. * The variable is initialized if it was not. */ const struct vpd_blob *vpd_load_blob(void); diff --git a/src/ec/google/chromeec/ec.c b/src/ec/google/chromeec/ec.c index a992146..5dff162 100644 --- a/src/ec/google/chromeec/ec.c +++ b/src/ec/google/chromeec/ec.c @@ -17,7 +17,6 @@ #include <string.h> #include <cbmem.h> #include <console/console.h> -#include <arch/early_variables.h> #include <assert.h> #include <bootmode.h> #include <bootstate.h> @@ -231,7 +230,7 @@ #define UHEPI_SUPPORTED 1 #define UHEPI_NOT_SUPPORTED 2
- static int uhepi_support CAR_GLOBAL; + static int uhepi_support;
if (!uhepi_support) { uhepi_support = google_chromeec_check_feature diff --git a/src/ec/google/chromeec/ec_spi.c b/src/ec/google/chromeec/ec_spi.c index c47d419..84a605b 100644 --- a/src/ec/google/chromeec/ec_spi.c +++ b/src/ec/google/chromeec/ec_spi.c @@ -20,8 +20,6 @@ #include <spi-generic.h> #include <timer.h>
-/* This is assuming that this driver is not used on x86. If that changes, this - might need to become a CAR_GLOBAL or maybe even more complicated. */ static struct stopwatch cs_cooldown_sw; static const long cs_cooldown_us = 200;
diff --git a/src/include/rules.h b/src/include/rules.h index 9e13ee6..fa60ede 100644 --- a/src/include/rules.h +++ b/src/include/rules.h @@ -258,7 +258,7 @@ /* No .data sections with execute-in-place from ROM. */ #define ENV_STAGE_HAS_DATA_SECTION !ENV_CACHE_AS_RAM /* No .bss sections for stage with CAR teardown. */ -#define ENV_STAGE_HAS_BSS_SECTION !(ENV_ROMSTAGE && CONFIG(CAR_GLOBAL_MIGRATION)) +#define ENV_STAGE_HAS_BSS_SECTION 1 #else /* Both .data and .bss, sometimes SRAM not DRAM. */ #define ENV_STAGE_HAS_DATA_SECTION 1 diff --git a/src/include/spd_bin.h b/src/include/spd_bin.h index 3de60a9..f144b14 100644 --- a/src/include/spd_bin.h +++ b/src/include/spd_bin.h @@ -16,7 +16,6 @@ #ifndef SPD_BIN_H #define SPD_BIN_H
-#include <arch/early_variables.h> #include <stdint.h> #include <commonlib/region.h>
diff --git a/src/lib/cbmem_console.c b/src/lib/cbmem_console.c index 7876ff5..7bd247d 100644 --- a/src/lib/cbmem_console.c +++ b/src/lib/cbmem_console.c @@ -16,7 +16,6 @@ #include <console/cbmem_console.h> #include <console/uart.h> #include <cbmem.h> -#include <arch/early_variables.h> #include <symbols.h>
/* @@ -49,7 +48,7 @@ _Static_assert(CONFIG_CONSOLE_CBMEM_BUFFER_SIZE <= MAX_SIZE, "cbmem_console format cannot support buffers larger than 256MB!");
-static struct cbmem_console *cbmem_console_p CAR_GLOBAL; +static struct cbmem_console *cbmem_console_p;
/* * While running from ROM, before DRAM is initialized, some area in cache as @@ -65,14 +64,9 @@ #define STATIC_CONSOLE_SIZE 1024 static u8 static_console[STATIC_CONSOLE_SIZE];
-static struct cbmem_console *current_console(void) -{ - return car_get_ptr(cbmem_console_p); -} - static void current_console_set(struct cbmem_console *new_console_p) { - car_set_ptr(cbmem_console_p, new_console_p); + cbmem_console_p = new_console_p; }
static int buffer_valid(struct cbmem_console *cbm_cons_p, u32 total_space) @@ -112,21 +106,19 @@
void cbmemc_tx_byte(unsigned char data) { - struct cbmem_console *cbm_cons_p = current_console(); - - if (!cbm_cons_p || !cbm_cons_p->size) + if (!cbmem_console_p || !cbmem_console_p->size) return;
- u32 flags = cbm_cons_p->cursor & ~CURSOR_MASK; - u32 cursor = cbm_cons_p->cursor & CURSOR_MASK; + u32 flags = cbmem_console_p->cursor & ~CURSOR_MASK; + u32 cursor = cbmem_console_p->cursor & CURSOR_MASK;
- cbm_cons_p->body[cursor++] = data; - if (cursor >= cbm_cons_p->size) { + cbmem_console_p->body[cursor++] = data; + if (cursor >= cbmem_console_p->size) { cursor = 0; flags |= OVERFLOW; }
- cbm_cons_p->cursor = flags | cursor; + cbmem_console_p->cursor = flags | cursor; }
/* @@ -166,7 +158,7 @@ const size_t size = CONFIG_CONSOLE_CBMEM_BUFFER_SIZE; /* If CBMEM entry already existed, old contents are not altered. */ struct cbmem_console *cbmem_cons_p = cbmem_add(CBMEM_ID_CONSOLE, size); - struct cbmem_console *previous_cons_p = current_console(); + struct cbmem_console *previous_cons_p = cbmem_console_p;
init_console_ptr(cbmem_cons_p, size); copy_console_buffer(previous_cons_p); @@ -178,19 +170,16 @@ #if CONFIG(CONSOLE_CBMEM_DUMP_TO_UART) void cbmem_dump_console(void) { - struct cbmem_console *cbm_cons_p; u32 cursor; - - cbm_cons_p = current_console(); - if (!cbm_cons_p) + if (!cbmem_console_p) return;
uart_init(0); - if (cbm_cons_p->cursor & OVERFLOW) - for (cursor = cbm_cons_p->cursor & CURSOR_MASK; - cursor < cbm_cons_p->size; cursor++) - uart_tx_byte(0, cbm_cons_p->body[cursor]); - for (cursor = 0; cursor < (cbm_cons_p->cursor & CURSOR_MASK); cursor++) - uart_tx_byte(0, cbm_cons_p->body[cursor]); + if (cbmem_console_p->cursor & OVERFLOW) + for (cursor = cbmem_console_p->cursor & CURSOR_MASK; + cursor < cbmem_console_p->size; cursor++) + uart_tx_byte(0, cbmem_console_p->body[cursor]); + for (cursor = 0; cursor < (cbmem_console_p->cursor & CURSOR_MASK); cursor++) + uart_tx_byte(0, cbmem_console_p->body[cursor]); } #endif diff --git a/src/lib/cbmem_stage_cache.c b/src/lib/cbmem_stage_cache.c index 299cb00..dd56f62 100644 --- a/src/lib/cbmem_stage_cache.c +++ b/src/lib/cbmem_stage_cache.c @@ -13,7 +13,6 @@ * GNU General Public License for more details. */
-#include <arch/early_variables.h> #include <cbmem.h> #include <stage_cache.h> #include <string.h> diff --git a/src/lib/ext_stage_cache.c b/src/lib/ext_stage_cache.c index 354342d..466a65f 100644 --- a/src/lib/ext_stage_cache.c +++ b/src/lib/ext_stage_cache.c @@ -13,7 +13,6 @@ * GNU General Public License for more details. */
-#include <arch/early_variables.h> #include <bootstate.h> #include <cbmem.h> #include <console/console.h> @@ -21,12 +20,7 @@ #include <stage_cache.h> #include <string.h>
-static struct imd imd_stage_cache CAR_GLOBAL = { }; - -static inline struct imd *imd_get(void) -{ - return car_get_var_ptr(&imd_stage_cache); -} +static struct imd imd_stage_cache;
static void stage_cache_create_empty(void) { @@ -34,7 +28,7 @@ void *base; size_t size;
- imd = imd_get(); + imd = &imd_stage_cache; stage_cache_external_region(&base, &size); imd_handle_init(imd, (void *)(size + (uintptr_t)base));
@@ -50,7 +44,7 @@ void *base; size_t size;
- imd = imd_get(); + imd = &imd_stage_cache; stage_cache_external_region(&base, &size); imd_handle_init(imd, (void *)(size + (uintptr_t)base)); if (imd_recover(imd)) @@ -64,7 +58,7 @@ struct stage_cache *meta; void *c;
- imd = imd_get(); + imd = &imd_stage_cache; e = imd_entry_add(imd, CBMEM_ID_STAGEx_META + stage_id, sizeof(*meta));
if (e == NULL) { @@ -99,7 +93,7 @@ const struct imd_entry *e; void *c;
- imd = imd_get(); + imd = &imd_stage_cache; e = imd_entry_add(imd, CBMEM_ID_STAGEx_RAW + stage_id, size); if (e == NULL) { printk(BIOS_DEBUG, "Error: Can't add %x raw data to imd\n", @@ -122,7 +116,7 @@ struct imd *imd; const struct imd_entry *e;
- imd = imd_get(); + imd = &imd_stage_cache; e = imd_entry_find(imd, CBMEM_ID_STAGEx_RAW + stage_id); if (e == NULL) { printk(BIOS_DEBUG, "Error: Can't find %x raw data to imd\n", @@ -142,7 +136,7 @@ void *c; size_t size;
- imd = imd_get(); + imd = &imd_stage_cache; e = imd_entry_find(imd, CBMEM_ID_STAGEx_META + stage_id); if (e == NULL) { printk(BIOS_DEBUG, "Error: Can't find %x metadata in imd\n", diff --git a/src/lib/fmap.c b/src/lib/fmap.c index 48aab8f..af26152 100644 --- a/src/lib/fmap.c +++ b/src/lib/fmap.c @@ -13,7 +13,6 @@ * GNU General Public License for more details. */
-#include <arch/early_variables.h> #include <boot_device.h> #include <cbmem.h> #include <console/console.h> @@ -29,11 +28,11 @@ * See http://code.google.com/p/flashmap/ for more information on FMAP. */
-static int fmap_print_once CAR_GLOBAL; -static struct mem_region_device fmap_cache CAR_GLOBAL; +static int fmap_print_once; +static struct mem_region_device fmap_cache;
#define print_once(...) do { \ - if (!car_get_var(fmap_print_once)) \ + if (!fmap_print_once) \ printk(__VA_ARGS__); \ } while (0)
@@ -55,7 +54,7 @@ fmap->name, fmap->ver_major, fmap->ver_minor, FMAP_OFFSET); print_once(BIOS_DEBUG, "FMAP: base = %#llx size = %#x #areas = %d\n", (long long)fmap->base, fmap->size, fmap->nareas); - car_set_var(fmap_print_once, 1); + fmap_print_once = 1; }
static void setup_preram_cache(struct mem_region_device *cache_mrdev) @@ -114,15 +113,13 @@ { const struct region_device *boot; struct fmap *fmap; - struct mem_region_device *cache; size_t offset = FMAP_OFFSET;
/* Try FMAP cache first */ - cache = car_get_var_ptr(&fmap_cache); - if (!region_device_sz(&cache->rdev)) - setup_preram_cache(cache); - if (region_device_sz(&cache->rdev)) - return rdev_chain_full(fmrd, &cache->rdev); + if (!region_device_sz(&fmap_cache.rdev)) + setup_preram_cache(&fmap_cache); + if (region_device_sz(&fmap_cache.rdev)) + return rdev_chain_full(fmrd, &fmap_cache.rdev);
boot_device_init(); boot = boot_device_ro(); @@ -277,9 +274,6 @@ static void fmap_register_cbmem_cache(int unused) { const struct cbmem_entry *e; - struct mem_region_device *mdev; - - mdev = car_get_var_ptr(&fmap_cache);
/* Find the FMAP cache installed by previous stage */ e = cbmem_entry_find(CBMEM_ID_FMAP); @@ -287,7 +281,7 @@ if (!e) return;
- mem_region_device_ro_init(mdev, cbmem_entry_start(e), cbmem_entry_size(e)); + mem_region_device_ro_init(&fmap_cache, cbmem_entry_start(e), cbmem_entry_size(e)); }
/* diff --git a/src/lib/imd_cbmem.c b/src/lib/imd_cbmem.c index 6eb3e60..6fd48d5 100644 --- a/src/lib/imd_cbmem.c +++ b/src/lib/imd_cbmem.c @@ -22,28 +22,6 @@ #include <imd.h> #include <lib.h> #include <stdlib.h> -#include <arch/early_variables.h> - -/* - * We need special handling on x86 where CAR global migration is employed. One - * cannot use true globals in that circumstance because CAR is where the globals - * are backed -- creating a circular dependency. For non CAR platforms globals - * are free to be used as well as any stages that are purely executing out of - * RAM. For CAR platforms that don't migrate globals the as-linked globals can - * be used, but they need special decoration using CAR_GLOBAL. That ensures - * proper object placement in conjunction with the linker. - * - * For the CAR global migration platforms we have to always try to partially - * recover CBMEM from cbmem_top() whenever we try to access it. In other - * environments we're not so constrained and just keep the backing imd struct - * in a global. This also means that we can easily tell whether CBMEM has - * explicitly been initialized or recovered yet on those platforms, and don't - * need to put the burden on board or chipset code to tell us by returning - * NULL from cbmem_top() before that point. - */ -#define CAN_USE_GLOBALS \ - (!CONFIG(ARCH_X86) || ENV_RAMSTAGE || ENV_POSTCAR || \ - !CONFIG(CAR_GLOBAL_MIGRATION))
/* The program loader passes on cbmem_top and the program entry point has to fill in the _cbmem_top_ptr symbol based on the calling arguments. */ @@ -67,11 +45,8 @@
static inline struct imd *cbmem_get_imd(void) { - if (CAN_USE_GLOBALS) { - static struct imd imd_cbmem CAR_GLOBAL; - return &imd_cbmem; - } - return NULL; + static struct imd imd_cbmem; + return &imd_cbmem; }
static inline const struct cbmem_entry *imd_to_cbmem(const struct imd_entry *e) @@ -115,12 +90,6 @@ struct imd *imd;
imd = imd_init_backing(backing); - if (!CAN_USE_GLOBALS) { - /* Always partially recover if we can't keep track of whether - * we have already initialized CBMEM in this stage. */ - imd_handle_init(imd, cbmem_top()); - imd_handle_init_partial_recovery(imd); - }
return imd; } diff --git a/src/lib/spd_bin.c b/src/lib/spd_bin.c index 62e600b..71fe036 100644 --- a/src/lib/spd_bin.c +++ b/src/lib/spd_bin.c @@ -20,7 +20,7 @@ #include <device/early_smbus.h> #include <device/dram/ddr3.h>
-static u8 spd_data[CONFIG_DIMM_MAX * CONFIG_DIMM_SPD_SIZE] CAR_GLOBAL; +static u8 spd_data[CONFIG_DIMM_MAX * CONFIG_DIMM_SPD_SIZE];
void dump_spd_info(struct spd_block *blk) { @@ -258,12 +258,10 @@ void get_spd_smbus(struct spd_block *blk) { u8 i; - unsigned char *spd_data_ptr = car_get_var_ptr(&spd_data); - for (i = 0 ; i < CONFIG_DIMM_MAX; i++) { - get_spd(spd_data_ptr + i * CONFIG_DIMM_SPD_SIZE, + get_spd(&spd_data[i * CONFIG_DIMM_SPD_SIZE], blk->addr_map[i]); - blk->spd_array[i] = spd_data_ptr + i * CONFIG_DIMM_SPD_SIZE; + blk->spd_array[i] = &spd_data[i * CONFIG_DIMM_SPD_SIZE]; }
update_spd_len(blk); diff --git a/src/lib/timestamp.c b/src/lib/timestamp.c index dcb3124..7c7210c 100644 --- a/src/lib/timestamp.c +++ b/src/lib/timestamp.c @@ -22,7 +22,6 @@ #include <symbols.h> #include <timer.h> #include <timestamp.h> -#include <arch/early_variables.h> #include <smp/node.h>
#define MAX_TIMESTAMPS 192 @@ -31,7 +30,7 @@
/* This points to the active timestamp_table and can change within a stage as CBMEM comes available. */ -static struct timestamp_table *glob_ts_table CAR_GLOBAL; +static struct timestamp_table *glob_ts_table;
static void timestamp_cache_init(struct timestamp_table *ts_cache, uint64_t base) @@ -94,21 +93,17 @@
static struct timestamp_table *timestamp_table_get(void) { - struct timestamp_table *ts_table; + if (glob_ts_table) + return glob_ts_table;
- ts_table = car_get_ptr(glob_ts_table); - if (ts_table) - return ts_table; + glob_ts_table = timestamp_cache_get();
- ts_table = timestamp_cache_get(); - car_set_ptr(glob_ts_table, ts_table); - - return ts_table; + return glob_ts_table; }
static void timestamp_table_set(struct timestamp_table *ts) { - car_set_ptr(glob_ts_table, ts); + glob_ts_table = ts; }
static const char *timestamp_name(enum timestamp_id id) diff --git a/src/security/tpm/tspi/log.c b/src/security/tpm/tspi/log.c index 9986d9a..8a9cc88 100644 --- a/src/security/tpm/tspi/log.c +++ b/src/security/tpm/tspi/log.c @@ -15,7 +15,6 @@
#include <console/console.h> #include <security/tpm/tspi.h> -#include <arch/early_variables.h> #include <region_file.h> #include <string.h> #include <security/vboot/symbols.h> diff --git a/src/security/tpm/tss/tcg-1.2/tss.c b/src/security/tpm/tss/tcg-1.2/tss.c index b11d6a3..9bc72d2 100644 --- a/src/security/tpm/tss/tcg-1.2/tss.c +++ b/src/security/tpm/tss/tcg-1.2/tss.c @@ -14,7 +14,6 @@ * time. */
-#include <arch/early_variables.h> #include <assert.h> #include <string.h> #include <security/tpm/tis.h> @@ -148,12 +147,11 @@
/* Exported functions. */
-static uint8_t tlcl_init_done CAR_GLOBAL; +static uint8_t tlcl_init_done;
uint32_t tlcl_lib_init(void) { - uint8_t done = car_get_var(tlcl_init_done); - if (done) + if (tlcl_init_done) return VB2_SUCCESS;
if (tis_init()) @@ -161,7 +159,7 @@ if (tis_open()) return VB2_ERROR_UNKNOWN;
- car_set_var(tlcl_init_done, 1); + tlcl_init_done = 1;
return VB2_SUCCESS; } diff --git a/src/security/tpm/tss/tcg-2.0/tss.c b/src/security/tpm/tss/tcg-2.0/tss.c index 16e40fe..6bc3096 100644 --- a/src/security/tpm/tss/tcg-2.0/tss.c +++ b/src/security/tpm/tss/tcg-2.0/tss.c @@ -5,7 +5,6 @@ * found in the LICENSE file. */
-#include <arch/early_variables.h> #include <console/console.h> #include <endian.h> #include <string.h> @@ -30,11 +29,9 @@ size_t in_size; const uint8_t *sendb; /* Command/response buffer. */ - static uint8_t cr_buffer[TPM_BUFFER_SIZE] CAR_GLOBAL; + static uint8_t cr_buffer[TPM_BUFFER_SIZE];
- uint8_t *cr_buffer_ptr = car_get_var_ptr(cr_buffer); - - obuf_init(&ob, cr_buffer_ptr, sizeof(cr_buffer)); + obuf_init(&ob, cr_buffer, sizeof(cr_buffer));
if (tpm_marshal_command(command, command_body, &ob) < 0) { printk(BIOS_ERR, "command %#x\n", command); @@ -44,12 +41,12 @@ sendb = obuf_contents(&ob, &out_size);
in_size = sizeof(cr_buffer); - if (tis_sendrecv(sendb, out_size, cr_buffer_ptr, &in_size)) { + if (tis_sendrecv(sendb, out_size, cr_buffer, &in_size)) { printk(BIOS_ERR, "tpm transaction failed\n"); return NULL; }
- ibuf_init(&ib, cr_buffer_ptr, in_size); + ibuf_init(&ib, cr_buffer, in_size);
return tpm_unmarshal_response(command, &ib); } @@ -173,13 +170,12 @@ return TPM_SUCCESS; }
-static uint8_t tlcl_init_done CAR_GLOBAL; +static uint8_t tlcl_init_done;
/* This function is called directly by vboot, uses vboot return types. */ uint32_t tlcl_lib_init(void) { - uint8_t done = car_get_var(tlcl_init_done); - if (done) + if (tlcl_init_done) return VB2_SUCCESS;
if (tis_init()) { @@ -192,7 +188,7 @@ return VB2_ERROR_UNKNOWN; }
- car_set_var(tlcl_init_done, 1); + tlcl_init_done = 1;
return VB2_SUCCESS; } diff --git a/src/security/tpm/tss/tcg-2.0/tss_marshaling.c b/src/security/tpm/tss/tcg-2.0/tss_marshaling.c index 1bf211a..720e7c4 100644 --- a/src/security/tpm/tss/tcg-2.0/tss_marshaling.c +++ b/src/security/tpm/tss/tcg-2.0/tss_marshaling.c @@ -5,7 +5,6 @@ * found in the LICENSE file. */
-#include <arch/early_variables.h> #include <commonlib/iobuf.h> #include <console/console.h> #include <stdlib.h> @@ -15,7 +14,7 @@ #include <security/tpm/tss/vendor/cr50/cr50.h> #include <security/tpm/tss.h>
-static uint16_t tpm_tag CAR_GLOBAL; /* Depends on the command type. */ +static uint16_t tpm_tag; /* Depends on the command type. */
#define unmarshal_TPM_CAP(a, b) ibuf_read_be32(a, b) #define unmarshal_TPM_CC(a, b) ibuf_read_be32(a, b) @@ -165,7 +164,7 @@ struct tpm2_session_header session_header; int rc = 0;
- car_set_var(tpm_tag, TPM_ST_SESSIONS); + tpm_tag = TPM_ST_SESSIONS;
for (i = 0; i < handle_count; i++) rc |= marshal_TPM_HANDLE(ob, handles[i]); @@ -270,7 +269,7 @@ int rc = 0; struct tpm2_session_header session_header;
- car_set_var(tpm_tag, TPM_ST_SESSIONS); + tpm_tag = TPM_ST_SESSIONS;
rc |= marshal_TPM_HANDLE(ob, TPM_RH_PLATFORM); memset(&session_header, 0, sizeof(session_header)); @@ -335,7 +334,7 @@ const size_t hdr_sz = sizeof(uint16_t) + 2 * sizeof(uint32_t); int rc = 0;
- car_set_var(tpm_tag, TPM_ST_NO_SESSIONS); + tpm_tag = TPM_ST_NO_SESSIONS;
if (obuf_splice_current(ob, &ob_hdr, hdr_sz) < 0) return -1; @@ -407,7 +406,7 @@ return rc;
/* Fix up the command header with known values. */ - rc |= obuf_write_be16(&ob_hdr, car_get_var(tpm_tag)); + rc |= obuf_write_be16(&ob_hdr, tpm_tag); rc |= obuf_write_be32(&ob_hdr, obuf_nr_written(ob));
return rc; @@ -552,23 +551,22 @@
struct tpm2_response *tpm_unmarshal_response(TPM_CC command, struct ibuf *ib) { - static struct tpm2_response tpm2_static_resp CAR_GLOBAL; - struct tpm2_response *tpm2_resp = car_get_var_ptr(&tpm2_static_resp); + static struct tpm2_response tpm2_static_resp; int rc = 0;
- rc |= ibuf_read_be16(ib, &tpm2_resp->hdr.tpm_tag); - rc |= ibuf_read_be32(ib, &tpm2_resp->hdr.tpm_size); - rc |= unmarshal_TPM_CC(ib, &tpm2_resp->hdr.tpm_code); + rc |= ibuf_read_be16(ib, &tpm2_static_resp.hdr.tpm_tag); + rc |= ibuf_read_be32(ib, &tpm2_static_resp.hdr.tpm_size); + rc |= unmarshal_TPM_CC(ib, &tpm2_static_resp.hdr.tpm_code);
if (rc != 0) return NULL;
if (ibuf_remaining(ib) == 0) { - if (tpm2_resp->hdr.tpm_size != ibuf_nr_read(ib)) + if (tpm2_static_resp.hdr.tpm_size != ibuf_nr_read(ib)) printk(BIOS_ERR, "%s: size mismatch in response to command %#x\n", __func__, command); - return tpm2_resp; + return &tpm2_static_resp; }
switch (command) { @@ -577,11 +575,11 @@ break;
case TPM2_GetCapability: - rc |= unmarshal_get_capability(ib, &tpm2_resp->gc); + rc |= unmarshal_get_capability(ib, &tpm2_static_resp.gc); break;
case TPM2_NV_Read: - rc |= unmarshal_nv_read(ib, &tpm2_resp->nvr); + rc |= unmarshal_nv_read(ib, &tpm2_static_resp.nvr); break;
case TPM2_Hierarchy_Control: @@ -595,7 +593,7 @@ break;
case TPM2_CR50_VENDOR_COMMAND: - rc |= unmarshal_vendor_command(ib, &tpm2_resp->vcr); + rc |= unmarshal_vendor_command(ib, &tpm2_static_resp.vcr); break;
default: @@ -608,7 +606,7 @@ "Request to unmarshal unexpected command %#x," " code %#x", __func__, __LINE__, command, - tpm2_resp->hdr.tpm_code); + tpm2_static_resp.hdr.tpm_code);
sz_left = ibuf_remaining(ib); data = ibuf_oob_drain(ib, sz_left); @@ -627,7 +625,7 @@ printk(BIOS_INFO, "%s:%d got %d bytes back in response to %#x," " failed to parse (%zd)\n", - __func__, __LINE__, tpm2_resp->hdr.tpm_size, + __func__, __LINE__, tpm2_static_resp.hdr.tpm_size, command, ibuf_remaining(ib)); return NULL; } @@ -636,5 +634,5 @@ __func__);
/* The entire message have been parsed. */ - return tpm2_resp; + return &tpm2_static_resp; } diff --git a/src/security/tpm/tss/vendor/cr50/cr50.c b/src/security/tpm/tss/vendor/cr50/cr50.c index 4f128dc..ec69df4 100644 --- a/src/security/tpm/tss/vendor/cr50/cr50.c +++ b/src/security/tpm/tss/vendor/cr50/cr50.c @@ -4,7 +4,6 @@ * found in the LICENSE file. */
-#include <arch/early_variables.h> #include <console/console.h> #include <endian.h> #include <vb2_api.h> diff --git a/src/security/vboot/common.c b/src/security/vboot/common.c index bad01ff..290fa5e 100644 --- a/src/security/vboot/common.c +++ b/src/security/vboot/common.c @@ -25,7 +25,7 @@ #include <security/vboot/symbols.h> #include <security/vboot/vboot_common.h>
-static struct vb2_context *vboot_ctx CAR_GLOBAL; +static struct vb2_context *vboot_ctx;
struct vboot_working_data *vboot_get_working_data(void) { @@ -50,20 +50,19 @@
struct vb2_context *vboot_get_context(void) { - struct vb2_context **vboot_ctx_ptr = car_get_var_ptr(&vboot_ctx); struct vboot_working_data *wd;
/* Return if context has already been initialized/restored. */ - if (*vboot_ctx_ptr) - return *vboot_ctx_ptr; + if (vboot_ctx) + return vboot_ctx;
wd = vboot_get_working_data();
/* Restore context from a previous stage. */ if (vboot_logic_executed()) { assert(vb2api_reinit(vboot_get_workbuf(wd), - vboot_ctx_ptr) == VB2_SUCCESS); - return *vboot_ctx_ptr; + &vboot_ctx) == VB2_SUCCESS); + return vboot_ctx; }
assert(verification_should_run()); @@ -78,10 +77,10 @@ /* Initialize vb2_shared_data and friends. */ assert(vb2api_init(vboot_get_workbuf(wd), VB2_FIRMWARE_WORKBUF_RECOMMENDED_SIZE - - wd->buffer_offset, - vboot_ctx_ptr) == VB2_SUCCESS); + wd->buffer_offset, + &vboot_ctx) == VB2_SUCCESS);
- return *vboot_ctx_ptr; + return vboot_ctx; }
int vboot_locate_firmware(const struct vb2_context *ctx, @@ -116,7 +115,7 @@ vb2api_relocate(vboot_get_workbuf(wd_cbmem), vboot_get_workbuf(wd_preram), cbmem_size - wd_cbmem->buffer_offset, - car_get_var_ptr(&vboot_ctx)); + &vboot_ctx); } ROMSTAGE_CBMEM_INIT_HOOK(vboot_migrate_cbmem) #else diff --git a/src/security/vboot/misc.h b/src/security/vboot/misc.h index 1b14799..5d26392 100644 --- a/src/security/vboot/misc.h +++ b/src/security/vboot/misc.h @@ -17,7 +17,6 @@ #define __VBOOT_MISC_H__
#include <assert.h> -#include <arch/early_variables.h> #include <security/vboot/vboot_common.h>
struct vb2_context; @@ -101,7 +100,7 @@ need to check a global to see if verfication has run. */ if (verification_should_run() || (verstage_should_load() && CONFIG(VBOOT_RETURN_FROM_VERSTAGE))) - return car_get_var(vboot_executed); + return vboot_executed;
if (CONFIG(VBOOT_STARTS_IN_BOOTBLOCK)) { /* All other stages are "after the bootblock" */ diff --git a/src/security/vboot/vbnv.c b/src/security/vboot/vbnv.c index eccd743..be598ac 100644 --- a/src/security/vboot/vbnv.c +++ b/src/security/vboot/vbnv.c @@ -13,32 +13,13 @@ * GNU General Public License for more details. */
-#include <arch/early_variables.h> #include <string.h> #include <types.h> #include <security/vboot/vbnv.h> #include <security/vboot/vbnv_layout.h>
-static int vbnv_initialized CAR_GLOBAL; -static uint8_t vbnv[VBOOT_VBNV_BLOCK_SIZE] CAR_GLOBAL; - -/* Wrappers for accessing the variables marked as CAR_GLOBAL. */ -static inline int is_vbnv_initialized(void) -{ - return car_get_var(vbnv_initialized); -} - -static inline uint8_t *vbnv_data_addr(int index) -{ - uint8_t *vbnv_arr = car_get_var_ptr(vbnv); - - return &vbnv_arr[index]; -} - -static inline uint8_t vbnv_data(int index) -{ - return *vbnv_data_addr(index); -} +static int vbnv_initialized; +static uint8_t vbnv[VBOOT_VBNV_BLOCK_SIZE];
/* Return CRC-8 of the data, using x^8 + x^2 + x + 1 polynomial. */ static uint8_t crc8_vbnv(const uint8_t *data, int len) @@ -66,9 +47,9 @@ /* Read VBNV data into cache. */ static void vbnv_setup(void) { - if (!is_vbnv_initialized()) { - read_vbnv(vbnv_data_addr(0)); - car_set_var(vbnv_initialized, 1); + if (!vbnv_initialized) { + read_vbnv(vbnv); + vbnv_initialized = 1; } }
@@ -117,7 +98,7 @@ save_vbnv_flash(vbnv_copy);
/* Clear initialized flag to force cached data to be updated */ - car_set_var(vbnv_initialized, 0); + vbnv_initialized = 0; }
/* Save a recovery reason into VBNV. */ @@ -137,14 +118,14 @@ int get_recovery_mode_from_vbnv(void) { vbnv_setup(); - return vbnv_data(RECOVERY_OFFSET); + return vbnv[RECOVERY_OFFSET]; }
/* Read the USB Device Controller(UDC) enable flag from VBNV. */ int vbnv_udc_enable_flag(void) { vbnv_setup(); - return (vbnv_data(DEV_FLAGS_OFFSET) & DEV_ENABLE_UDC) ? 1 : 0; + return (vbnv[DEV_FLAGS_OFFSET] & DEV_ENABLE_UDC) ? 1 : 0; }
void vbnv_init(uint8_t *vbnv_copy) diff --git a/src/security/vboot/vbnv_flash.c b/src/security/vboot/vbnv_flash.c index 86c43cd..58d3aba 100644 --- a/src/security/vboot/vbnv_flash.c +++ b/src/security/vboot/vbnv_flash.c @@ -13,7 +13,6 @@ * GNU General Public License for more details. */
-#include <arch/early_variables.h> #include <commonlib/region.h> #include <console/console.h> #include <fmap.h> @@ -41,7 +40,7 @@ /* Cache of the current nvdata */ uint8_t cache[BLOB_SIZE]; }; -static struct vbnv_flash_ctx vbnv_flash CAR_GLOBAL; +static struct vbnv_flash_ctx vbnv_flash;
/* * This code assumes that flash is erased to 1-bits, and write operations can @@ -60,7 +59,7 @@
static int init_vbnv(void) { - struct vbnv_flash_ctx *ctx = car_get_var_ptr(&vbnv_flash); + struct vbnv_flash_ctx *ctx = &vbnv_flash; struct region_device *rdev = &ctx->vbnv_dev; uint8_t buf[BLOB_SIZE]; uint8_t empty_blob[BLOB_SIZE]; @@ -116,7 +115,7 @@
static int erase_nvram(void) { - struct vbnv_flash_ctx *ctx = car_get_var_ptr(&vbnv_flash); + struct vbnv_flash_ctx *ctx = &vbnv_flash; const struct region_device *rdev = &ctx->vbnv_dev;
if (rdev_eraseat(rdev, 0, region_device_sz(rdev)) < 0) { @@ -130,7 +129,7 @@
void read_vbnv_flash(uint8_t *vbnv_copy) { - struct vbnv_flash_ctx *ctx = car_get_var_ptr(&vbnv_flash); + struct vbnv_flash_ctx *ctx = &vbnv_flash;
if (!ctx->initialized) if (init_vbnv()) @@ -141,7 +140,7 @@
void save_vbnv_flash(const uint8_t *vbnv_copy) { - struct vbnv_flash_ctx *ctx = car_get_var_ptr(&vbnv_flash); + struct vbnv_flash_ctx *ctx = &vbnv_flash; int new_offset; int i; const struct region_device *rdev = &ctx->vbnv_dev; diff --git a/src/security/vboot/vboot_loader.c b/src/security/vboot/vboot_loader.c index 3e491a7..9aaaff2 100644 --- a/src/security/vboot/vboot_loader.c +++ b/src/security/vboot/vboot_loader.c @@ -13,8 +13,6 @@ * GNU General Public License for more details. */
-#include <arch/early_variables.h> -#include <boot_device.h> #include <cbfs.h> #include <console/console.h> #include <ec/google/chromeec/ec.h> @@ -34,14 +32,14 @@ CONFIG(VBOOT_SEPARATE_VERSTAGE), "return from verstage only makes sense for separate verstages");
-int vboot_executed CAR_GLOBAL; +int vboot_executed;
void vboot_run_logic(void) { if (verification_should_run()) { /* Note: this path is not used for VBOOT_RETURN_FROM_VERSTAGE */ verstage_main(); - car_set_var(vboot_executed, 1); + vboot_executed = 1; } else if (verstage_should_load()) { struct cbfsf file; struct prog verstage = @@ -68,7 +66,7 @@ if (!CONFIG(VBOOT_RETURN_FROM_VERSTAGE)) return;
- car_set_var(vboot_executed, 1); + vboot_executed = 1; } }
diff --git a/src/southbridge/intel/common/spi.c b/src/southbridge/intel/common/spi.c index a84a0df..7de8755 100644 --- a/src/southbridge/intel/common/spi.c +++ b/src/southbridge/intel/common/spi.c @@ -16,7 +16,6 @@ */
/* This file is derived from the flashrom project. */ -#include <arch/early_variables.h> #include <stdint.h> #include <stdlib.h> #include <string.h> @@ -110,7 +109,7 @@ uint8_t fpr_max; };
-static struct ich_spi_controller g_cntlr CAR_GLOBAL; +static struct ich_spi_controller g_cntlr;
enum { SPIS_SCIP = 0x0001, @@ -255,14 +254,13 @@
static void ich_set_bbar(uint32_t minaddr) { - struct ich_spi_controller *cntlr = car_get_var_ptr(&g_cntlr); const uint32_t bbar_mask = 0x00ffff00; uint32_t ichspi_bbar;
minaddr &= bbar_mask; - ichspi_bbar = readl_(cntlr->bbar) & ~bbar_mask; + ichspi_bbar = readl_(g_cntlr.bbar) & ~bbar_mask; ichspi_bbar |= minaddr; - writel_(ichspi_bbar, cntlr->bbar); + writel_(ichspi_bbar, g_cntlr.bbar); }
#if CONFIG(SOUTHBRIDGE_INTEL_I82801GX) @@ -273,7 +271,6 @@
void spi_init(void) { - struct ich_spi_controller *cntlr = car_get_var_ptr(&g_cntlr); uint8_t *rcrb; /* Root Complex Register Block */ uint32_t rcba; /* Root Complex Base Address */ uint8_t bios_cntl; @@ -292,42 +289,42 @@ rcrb = (uint8_t *)(rcba & 0xffffc000); if (CONFIG(SOUTHBRIDGE_INTEL_I82801GX)) { ich7_spi = (struct ich7_spi_regs *)(rcrb + 0x3020); - cntlr->ich7_spi = ich7_spi; - cntlr->opmenu = ich7_spi->opmenu; - cntlr->menubytes = sizeof(ich7_spi->opmenu); - cntlr->optype = &ich7_spi->optype; - cntlr->addr = &ich7_spi->spia; - cntlr->data = (uint8_t *)ich7_spi->spid; - cntlr->databytes = sizeof(ich7_spi->spid); - cntlr->status = (uint8_t *)&ich7_spi->spis; - cntlr->control = &ich7_spi->spic; - cntlr->bbar = &ich7_spi->bbar; - cntlr->preop = &ich7_spi->preop; - cntlr->fpr = &ich7_spi->pbr[0]; - cntlr->fpr_max = 3; + g_cntlr.ich7_spi = ich7_spi; + g_cntlr.opmenu = ich7_spi->opmenu; + g_cntlr.menubytes = sizeof(ich7_spi->opmenu); + g_cntlr.optype = &ich7_spi->optype; + g_cntlr.addr = &ich7_spi->spia; + g_cntlr.data = (uint8_t *)ich7_spi->spid; + g_cntlr.databytes = sizeof(ich7_spi->spid); + g_cntlr.status = (uint8_t *)&ich7_spi->spis; + g_cntlr.control = &ich7_spi->spic; + g_cntlr.bbar = &ich7_spi->bbar; + g_cntlr.preop = &ich7_spi->preop; + g_cntlr.fpr = &ich7_spi->pbr[0]; + g_cntlr.fpr_max = 3; } else { ich9_spi = (struct ich9_spi_regs *)(rcrb + 0x3800); - cntlr->ich9_spi = ich9_spi; + g_cntlr.ich9_spi = ich9_spi; hsfs = readw_(&ich9_spi->hsfs); - cntlr->hsfs = hsfs; - cntlr->opmenu = ich9_spi->opmenu; - cntlr->menubytes = sizeof(ich9_spi->opmenu); - cntlr->optype = &ich9_spi->optype; - cntlr->addr = &ich9_spi->faddr; - cntlr->data = (uint8_t *)ich9_spi->fdata; - cntlr->databytes = sizeof(ich9_spi->fdata); - cntlr->status = &ich9_spi->ssfs; - cntlr->control = (uint16_t *)ich9_spi->ssfc; - cntlr->bbar = &ich9_spi->bbar; - cntlr->preop = &ich9_spi->preop; - cntlr->fpr = &ich9_spi->pr[0]; - cntlr->fpr_max = 5; + g_cntlr.hsfs = hsfs; + g_cntlr.opmenu = ich9_spi->opmenu; + g_cntlr.menubytes = sizeof(ich9_spi->opmenu); + g_cntlr.optype = &ich9_spi->optype; + g_cntlr.addr = &ich9_spi->faddr; + g_cntlr.data = (uint8_t *)ich9_spi->fdata; + g_cntlr.databytes = sizeof(ich9_spi->fdata); + g_cntlr.status = &ich9_spi->ssfs; + g_cntlr.control = (uint16_t *)ich9_spi->ssfc; + g_cntlr.bbar = &ich9_spi->bbar; + g_cntlr.preop = &ich9_spi->preop; + g_cntlr.fpr = &ich9_spi->pr[0]; + g_cntlr.fpr_max = 5;
- if (cntlr->hsfs & HSFS_FDV) { + if (g_cntlr.hsfs & HSFS_FDV) { writel_(4, &ich9_spi->fdoc); - cntlr->flmap0 = readl_(&ich9_spi->fdod); + g_cntlr.flmap0 = readl_(&ich9_spi->fdod); writel_(0x1000, &ich9_spi->fdoc); - cntlr->flcomp = readl_(&ich9_spi->fdod); + g_cntlr.flcomp = readl_(&ich9_spi->fdod); } }
@@ -342,11 +339,10 @@
static int spi_locked(void) { - struct ich_spi_controller *cntlr = &g_cntlr; if (CONFIG(SOUTHBRIDGE_INTEL_I82801GX)) { - return !!(readw_(&cntlr->ich7_spi->spis) & HSFS_FLOCKDN); + return !!(readw_(&g_cntlr.ich7_spi->spis) & HSFS_FLOCKDN); } else { - return !!(readw_(&cntlr->ich9_spi->hsfs) & HSFS_FLOCKDN); + return !!(readw_(&g_cntlr.ich9_spi->hsfs) & HSFS_FLOCKDN); } }
@@ -415,7 +411,6 @@
static int spi_setup_opcode(spi_transaction *trans) { - struct ich_spi_controller *cntlr = car_get_var_ptr(&g_cntlr); uint16_t optypes; uint8_t opmenu[MENU_BYTES];
@@ -423,10 +418,10 @@ spi_use_out(trans, 1); if (!spi_locked()) { /* The lock is off, so just use index 0. */ - writeb_(trans->opcode, cntlr->opmenu); - optypes = readw_(cntlr->optype); + writeb_(trans->opcode, g_cntlr.opmenu); + optypes = readw_(g_cntlr.optype); optypes = (optypes & 0xfffc) | (trans->type & 0x3); - writew_(optypes, cntlr->optype); + writew_(optypes, g_cntlr.optype); return 0; }
@@ -438,7 +433,7 @@ if (trans->opcode == SPI_OPCODE_WREN) return 0;
- read_reg(cntlr->opmenu, opmenu, sizeof(opmenu)); + read_reg(g_cntlr.opmenu, opmenu, sizeof(opmenu)); for (opcode_index = 0; opcode_index < ARRAY_SIZE(opmenu); opcode_index++) { if (opmenu[opcode_index] == trans->opcode) break; @@ -450,7 +445,7 @@ return -1; }
- optypes = readw_(cntlr->optype); + optypes = readw_(g_cntlr.optype); optype = (optypes >> (opcode_index * 2)) & 0x3; if (trans->type == SPI_OPCODE_TYPE_WRITE_NO_ADDRESS && optype == SPI_OPCODE_TYPE_WRITE_WITH_ADDRESS && @@ -495,15 +490,14 @@ */ static int ich_status_poll(u16 bitmask, int wait_til_set) { - struct ich_spi_controller *cntlr = car_get_var_ptr(&g_cntlr); int timeout = 600000; /* This will result in 6 seconds */ u16 status = 0;
while (timeout--) { - status = readw_(cntlr->status); + status = readw_(g_cntlr.status); if (wait_til_set ^ ((status & bitmask) == 0)) { if (wait_til_set) - writew_((status & bitmask), cntlr->status); + writew_((status & bitmask), g_cntlr.status); return status; } udelay(10); @@ -516,16 +510,14 @@
static int spi_is_multichip(void) { - struct ich_spi_controller *cntlr = car_get_var_ptr(&g_cntlr); - if (!(cntlr->hsfs & HSFS_FDV)) + if (!(g_cntlr.hsfs & HSFS_FDV)) return 0; - return !!((cntlr->flmap0 >> 8) & 3); + return !!((g_cntlr.flmap0 >> 8) & 3); }
static int spi_ctrlr_xfer(const struct spi_slave *slave, const void *dout, size_t bytesout, void *din, size_t bytesin) { - struct ich_spi_controller *cntlr = car_get_var_ptr(&g_cntlr); uint16_t control; int16_t opcode_index; int with_address; @@ -551,7 +543,7 @@ if (ich_status_poll(SPIS_SCIP, 0) == -1) return -1;
- writew_(SPIS_CDS | SPIS_FCERR, cntlr->status); + writew_(SPIS_CDS | SPIS_FCERR, g_cntlr.status);
spi_setup_type(&trans); if ((opcode_index = spi_setup_opcode(&trans)) < 0) @@ -566,7 +558,7 @@ * issuing a transaction between WREN and DATA. */ if (!spi_locked()) - writew_(trans.opcode, cntlr->preop); + writew_(trans.opcode, g_cntlr.preop); return 0; }
@@ -574,13 +566,13 @@ control = SPIC_SCGO | ((opcode_index & 0x07) << 4);
/* Issue atomic preop cycle if needed */ - if (readw_(cntlr->preop)) + if (readw_(g_cntlr.preop)) control |= SPIC_ACS;
if (!trans.bytesout && !trans.bytesin) { /* SPI addresses are 24 bit only */ if (with_address) - writel_(trans.offset & 0x00FFFFFF, cntlr->addr); + writel_(trans.offset & 0x00FFFFFF, g_cntlr.addr);
/* * This is a 'no data' command (like Write Enable), its @@ -588,7 +580,7 @@ * spi_setup_opcode() above. Tell the chip to send the * command. */ - writew_(control, cntlr->control); + writew_(control, g_cntlr.control);
/* wait for the result */ status = ich_status_poll(SPIS_CDS | SPIS_FCERR, 1); @@ -610,7 +602,7 @@ * and followed by other SPI commands, and this sequence is controlled * by the SPI chip driver. */ - if (trans.bytesout > cntlr->databytes) { + if (trans.bytesout > g_cntlr.databytes) { printk(BIOS_DEBUG, "ICH SPI: Too much to write. Does your SPI chip driver use" " spi_crop_chunk()?\n"); return -1; @@ -624,28 +616,28 @@ uint32_t data_length;
/* SPI addresses are 24 bit only */ - writel_(trans.offset & 0x00FFFFFF, cntlr->addr); + writel_(trans.offset & 0x00FFFFFF, g_cntlr.addr);
if (trans.bytesout) - data_length = min(trans.bytesout, cntlr->databytes); + data_length = min(trans.bytesout, g_cntlr.databytes); else - data_length = min(trans.bytesin, cntlr->databytes); + data_length = min(trans.bytesin, g_cntlr.databytes);
/* Program data into FDATA0 to N */ if (trans.bytesout) { - write_reg(trans.out, cntlr->data, data_length); + write_reg(trans.out, g_cntlr.data, data_length); spi_use_out(&trans, data_length); if (with_address) trans.offset += data_length; }
/* Add proper control fields' values */ - control &= ~((cntlr->databytes - 1) << 8); + control &= ~((g_cntlr.databytes - 1) << 8); control |= SPIC_DS; control |= (data_length - 1) << 8;
/* write it */ - writew_(control, cntlr->control); + writew_(control, g_cntlr.control);
/* Wait for Cycle Done Status or Flash Cycle Error. */ status = ich_status_poll(SPIS_CDS | SPIS_FCERR, 1); @@ -658,7 +650,7 @@ }
if (trans.bytesin) { - read_reg(cntlr->data, trans.in, data_length); + read_reg(g_cntlr.data, trans.in, data_length); spi_use_in(&trans, data_length); if (with_address) trans.offset += data_length; @@ -667,7 +659,7 @@
spi_xfer_exit: /* Clear atomic preop now that xfer is done */ - writew_(0, cntlr->preop); + writew_(0, g_cntlr.preop);
return 0; } @@ -675,10 +667,9 @@ /* Sets FLA in FADDR to (addr & 0x01FFFFFF) without touching other bits. */ static void ich_hwseq_set_addr(uint32_t addr) { - struct ich_spi_controller *cntlr = car_get_var_ptr(&g_cntlr); - uint32_t addr_old = readl_(&cntlr->ich9_spi->faddr) & ~0x01FFFFFF; + uint32_t addr_old = readl_(&g_cntlr.ich9_spi->faddr) & ~0x01FFFFFF;
- writel_((addr & 0x01FFFFFF) | addr_old, &cntlr->ich9_spi->faddr); + writel_((addr & 0x01FFFFFF) | addr_old, &g_cntlr.ich9_spi->faddr); }
/* Polls for Cycle Done Status, Flash Cycle Error or timeout in 8 us intervals. @@ -688,22 +679,21 @@ static int ich_hwseq_wait_for_cycle_complete(unsigned int timeout, unsigned int len) { - struct ich_spi_controller *cntlr = car_get_var_ptr(&g_cntlr); uint16_t hsfs; uint32_t addr;
timeout /= 8; /* scale timeout duration to counter */ - while ((((hsfs = readw_(&cntlr->ich9_spi->hsfs)) & + while ((((hsfs = readw_(&g_cntlr.ich9_spi->hsfs)) & (HSFS_FDONE | HSFS_FCERR)) == 0) && --timeout) { udelay(8); } - writew_(readw_(&cntlr->ich9_spi->hsfs), &cntlr->ich9_spi->hsfs); + writew_(readw_(&g_cntlr.ich9_spi->hsfs), &g_cntlr.ich9_spi->hsfs);
if (!timeout) { uint16_t hsfc; - addr = readl_(&cntlr->ich9_spi->faddr) & 0x01FFFFFF; - hsfc = readw_(&cntlr->ich9_spi->hsfc); + addr = readl_(&g_cntlr.ich9_spi->faddr) & 0x01FFFFFF; + hsfc = readw_(&g_cntlr.ich9_spi->hsfc); printk(BIOS_ERR, "Transaction timeout between offset 0x%08x and " "0x%08x (= 0x%08x + %d) HSFC=%x HSFS=%x!\n", addr, addr + len - 1, addr, len - 1, @@ -713,8 +703,8 @@
if (hsfs & HSFS_FCERR) { uint16_t hsfc; - addr = readl_(&cntlr->ich9_spi->faddr) & 0x01FFFFFF; - hsfc = readw_(&cntlr->ich9_spi->hsfc); + addr = readl_(&g_cntlr.ich9_spi->faddr) & 0x01FFFFFF; + hsfc = readw_(&g_cntlr.ich9_spi->hsfc); printk(BIOS_ERR, "Transaction error between offset 0x%08x and " "0x%08x (= 0x%08x + %d) HSFC=%x HSFS=%x!\n", addr, addr + len - 1, addr, len - 1, @@ -728,7 +718,6 @@ static int ich_hwseq_erase(const struct spi_flash *flash, u32 offset, size_t len) { - struct ich_spi_controller *cntlr = car_get_var_ptr(&g_cntlr); u32 start, end, erase_size; int ret; uint16_t hsfc; @@ -751,17 +740,17 @@
while (offset < end) { /* make sure FDONE, FCERR, AEL are cleared by writing 1 to them */ - writew_(readw_(&cntlr->ich9_spi->hsfs), &cntlr->ich9_spi->hsfs); + writew_(readw_(&g_cntlr.ich9_spi->hsfs), &g_cntlr.ich9_spi->hsfs);
ich_hwseq_set_addr(offset);
offset += erase_size;
- hsfc = readw_(&cntlr->ich9_spi->hsfc); + hsfc = readw_(&g_cntlr.ich9_spi->hsfc); hsfc &= ~HSFC_FCYCLE; /* clear operation */ hsfc |= (0x3 << HSFC_FCYCLE_OFF); /* set erase operation */ hsfc |= HSFC_FGO; /* start */ - writew_(hsfc, &cntlr->ich9_spi->hsfc); + writew_(hsfc, &g_cntlr.ich9_spi->hsfc); if (ich_hwseq_wait_for_cycle_complete(timeout, len)) { printk(BIOS_ERR, "SF: Erase failed at %x\n", offset - erase_size); ret = -1; @@ -778,13 +767,12 @@
static void ich_read_data(uint8_t *data, int len) { - struct ich_spi_controller *cntlr = car_get_var_ptr(&g_cntlr); int i; uint32_t temp32 = 0;
for (i = 0; i < len; i++) { if ((i % 4) == 0) - temp32 = readl_(cntlr->data + i); + temp32 = readl_(g_cntlr.data + i);
data[i] = (temp32 >> ((i % 4) * 8)) & 0xff; } @@ -793,7 +781,6 @@ static int ich_hwseq_read(const struct spi_flash *flash, u32 addr, size_t len, void *buf) { - struct ich_spi_controller *cntlr = car_get_var_ptr(&g_cntlr); uint16_t hsfc; uint16_t timeout = 100 * 60; uint8_t block_len; @@ -807,20 +794,20 @@ }
/* clear FDONE, FCERR, AEL by writing 1 to them (if they are set) */ - writew_(readw_(&cntlr->ich9_spi->hsfs), &cntlr->ich9_spi->hsfs); + writew_(readw_(&g_cntlr.ich9_spi->hsfs), &g_cntlr.ich9_spi->hsfs);
while (len > 0) { - block_len = min(len, cntlr->databytes); + block_len = min(len, g_cntlr.databytes); if (block_len > (~addr & 0xff)) block_len = (~addr & 0xff) + 1; ich_hwseq_set_addr(addr); - hsfc = readw_(&cntlr->ich9_spi->hsfc); + hsfc = readw_(&g_cntlr.ich9_spi->hsfc); hsfc &= ~HSFC_FCYCLE; /* set read operation */ hsfc &= ~HSFC_FDBC; /* clear byte count */ /* set byte count */ hsfc |= (((block_len - 1) << HSFC_FDBC_OFF) & HSFC_FDBC); hsfc |= HSFC_FGO; /* start */ - writew_(hsfc, &cntlr->ich9_spi->hsfc); + writew_(hsfc, &g_cntlr.ich9_spi->hsfc);
if (ich_hwseq_wait_for_cycle_complete(timeout, block_len)) return 1; @@ -839,7 +826,6 @@ */ static void ich_fill_data(const uint8_t *data, int len) { - struct ich_spi_controller *cntlr = car_get_var_ptr(&g_cntlr); uint32_t temp32 = 0; int i;
@@ -853,17 +839,16 @@ temp32 |= ((uint32_t) data[i]) << ((i % 4) * 8);
if ((i % 4) == 3) /* 32 bits are full, write them to regs. */ - writel_(temp32, cntlr->data + (i - (i % 4))); + writel_(temp32, g_cntlr.data + (i - (i % 4))); } i--; if ((i % 4) != 3) /* Write remaining data to regs. */ - writel_(temp32, cntlr->data + (i - (i % 4))); + writel_(temp32, g_cntlr.data + (i - (i % 4))); }
static int ich_hwseq_write(const struct spi_flash *flash, u32 addr, size_t len, const void *buf) { - struct ich_spi_controller *cntlr = car_get_var_ptr(&g_cntlr); uint16_t hsfc; uint16_t timeout = 100 * 60; uint8_t block_len; @@ -877,24 +862,24 @@ }
/* clear FDONE, FCERR, AEL by writing 1 to them (if they are set) */ - writew_(readw_(&cntlr->ich9_spi->hsfs), &cntlr->ich9_spi->hsfs); + writew_(readw_(&g_cntlr.ich9_spi->hsfs), &g_cntlr.ich9_spi->hsfs);
while (len > 0) { - block_len = min(len, cntlr->databytes); + block_len = min(len, g_cntlr.databytes); if (block_len > (~addr & 0xff)) block_len = (~addr & 0xff) + 1;
ich_hwseq_set_addr(addr);
ich_fill_data(buf, block_len); - hsfc = readw_(&cntlr->ich9_spi->hsfc); + hsfc = readw_(&g_cntlr.ich9_spi->hsfc); hsfc &= ~HSFC_FCYCLE; /* clear operation */ hsfc |= (0x2 << HSFC_FCYCLE_OFF); /* set write operation */ hsfc &= ~HSFC_FDBC; /* clear byte count */ /* set byte count */ hsfc |= (((block_len - 1) << HSFC_FDBC_OFF) & HSFC_FDBC); hsfc |= HSFC_FGO; /* start */ - writew_(hsfc, &cntlr->ich9_spi->hsfc); + writew_(hsfc, &g_cntlr.ich9_spi->hsfc);
if (ich_hwseq_wait_for_cycle_complete(timeout, block_len)) { printk(BIOS_ERR, "SF: write failure at %x\n", @@ -919,7 +904,6 @@ static int spi_flash_programmer_probe(const struct spi_slave *spi, struct spi_flash *flash) { - struct ich_spi_controller *cntlr = car_get_var_ptr(&g_cntlr);
if (CONFIG(SOUTHBRIDGE_INTEL_I82801GX)) return spi_flash_generic_probe(spi, flash); @@ -932,7 +916,7 @@ flash->name = "Opaque HW-sequencing";
ich_hwseq_set_addr(0); - switch ((cntlr->hsfs >> 3) & 3) { + switch ((g_cntlr.hsfs >> 3) & 3) { case 0: flash->sector_size = 256; break; @@ -947,12 +931,12 @@ break; }
- flash->size = 1 << (19 + (cntlr->flcomp & 7)); + flash->size = 1 << (19 + (g_cntlr.flcomp & 7));
flash->ops = &spi_flash_ops;
- if ((cntlr->hsfs & HSFS_FDV) && ((cntlr->flmap0 >> 8) & 3)) - flash->size += 1 << (19 + ((cntlr->flcomp >> 3) & 7)); + if ((g_cntlr.hsfs & HSFS_FDV) && ((g_cntlr.flmap0 >> 8) & 3)) + flash->size += 1 << (19 + ((g_cntlr.flcomp >> 3) & 7)); printk(BIOS_DEBUG, "flash size 0x%x bytes\n", flash->size);
return 0; @@ -999,7 +983,6 @@ const struct region *region, const enum ctrlr_prot_type type) { - struct ich_spi_controller *cntlr = car_get_var_ptr(&g_cntlr); u32 start = region_offset(region); u32 end = start + region_sz(region) - 1; u32 reg; @@ -1007,16 +990,16 @@ int fpr; uint32_t *fpr_base;
- fpr_base = cntlr->fpr; + fpr_base = g_cntlr.fpr;
/* Find first empty FPR */ - for (fpr = 0; fpr < cntlr->fpr_max; fpr++) { + for (fpr = 0; fpr < g_cntlr.fpr_max; fpr++) { reg = read32(&fpr_base[fpr]); if (reg == 0) break; }
- if (fpr == cntlr->fpr_max) { + if (fpr == g_cntlr.fpr_max) { printk(BIOS_ERR, "ERROR: No SPI FPR free!\n"); return -1; } @@ -1057,7 +1040,6 @@
void spi_finalize_ops(void) { - struct ich_spi_controller *cntlr = car_get_var_ptr(&g_cntlr); u16 spi_opprefix; u16 optype = 0; struct intel_swseq_spi_config spi_config_default = { @@ -1106,12 +1088,12 @@
spi_opprefix = spi_config->opprefixes[0] | (spi_config->opprefixes[1] << 8); - writew_(spi_opprefix, cntlr->preop); + writew_(spi_opprefix, g_cntlr.preop); for (i = 0; i < ARRAY_SIZE(spi_config->ops); i++) { optype |= (spi_config->ops[i].type & 3) << (i * 2); - writeb_(spi_config->ops[i].op, &cntlr->opmenu[i]); + writeb_(spi_config->ops[i].op, &g_cntlr.opmenu[i]); } - writew_(optype, cntlr->optype); + writew_(optype, g_cntlr.optype); }
__weak void intel_southbridge_override_spi(struct intel_swseq_spi_config *spi_config) diff --git a/src/vendorcode/siemens/hwilib/hwilib.c b/src/vendorcode/siemens/hwilib/hwilib.c index a4d87ad..a4b8e54 100644 --- a/src/vendorcode/siemens/hwilib/hwilib.c +++ b/src/vendorcode/siemens/hwilib/hwilib.c @@ -17,7 +17,6 @@ #include <string.h> #include <console/console.h> #include <device/mmio.h> -#include <arch/early_variables.h> #include <types.h>
#include "hwilib.h" @@ -74,15 +73,15 @@ /* Storage for pointers to the different blocks. The contents will be filled * in hwilib_find_blocks(). */ -static uint8_t *all_blocks[MAX_BLOCK_NUM] CAR_GLOBAL; +static uint8_t *all_blocks[MAX_BLOCK_NUM];
/* As the length of extended block is variable, save all length to a global * variable so that they can be used later to check boundaries. */ -static uint16_t all_blk_size[MAX_BLOCK_NUM] CAR_GLOBAL; +static uint16_t all_blk_size[MAX_BLOCK_NUM];
/* Storage for the cbfs file name of the currently open hwi file. */ -static char current_hwi[HWI_MAX_NAME_LEN] CAR_GLOBAL; +static char current_hwi[HWI_MAX_NAME_LEN];
static uint32_t hwilib_read_bytes (const struct param_info *param, uint8_t *dst, @@ -405,16 +404,14 @@ uint32_t maxlen) { uint8_t i = 0, *blk = NULL; - uint8_t **blk_ptr = car_get_var_ptr(&all_blocks[0]); - uint16_t *all_blk_size_ptr = car_get_var_ptr(&all_blk_size[0]);
if (!param || !dst) return 0; /* Take the first valid block to get the parameter from */ do { if ((param->pos[i].len) && (param->pos[i].offset) && - (blk_ptr[param->pos[i].blk_type])) { - blk = blk_ptr[param->pos[i].blk_type]; + (all_blocks[param->pos[i].blk_type])) { + blk = all_blocks[param->pos[i].blk_type]; break; } i++; @@ -425,7 +422,7 @@ */ if ((!blk) || (param->pos[i].len > maxlen) || (param->pos[i].len + param->pos[i].offset > - all_blk_size_ptr[param->pos[i].blk_type])) + all_blk_size[param->pos[i].blk_type])) return 0; /* We can now copy the wanted data. */ memcpy(dst, (blk + param->pos[i].offset), param->pos[i].len); @@ -472,9 +469,6 @@ { uint8_t *ptr = NULL, *base = NULL; uint32_t next_offset = 1; - uint8_t **blk_ptr = car_get_var_ptr(&all_blocks[0]); - uint16_t *all_blk_size_ptr = car_get_var_ptr(&all_blk_size[0]); - char *curr_hwi_name_ptr = car_get_var_ptr(¤t_hwi); size_t filesize = 0;
/* Check for a valid parameter */ @@ -482,8 +476,7 @@ return CB_ERR_ARG; /* Check if this file is already open. If yes, just leave as there is nothing left to do here. */ - if (curr_hwi_name_ptr && - !strncmp(curr_hwi_name_ptr, hwi_filename, HWI_MAX_NAME_LEN)) { + if (!strncmp(current_hwi, hwi_filename, HWI_MAX_NAME_LEN)) { printk(BIOS_SPEW, "HWILIB: File "%s" already open.\n", hwi_filename); return CB_SUCCESS; @@ -504,15 +497,15 @@ * in prior calls to this function. * This way the caller do not need to "close" already opened blocks. */ - memset(blk_ptr, 0, (MAX_BLOCK_NUM * sizeof (uint8_t *))); + memset(all_blocks, 0, (MAX_BLOCK_NUM * sizeof (uint8_t *))); /* Check which blocks are available by examining the length field. */ base = ptr; /* Fill in sizes of all fixed length blocks. */ - all_blk_size_ptr[BLK_HIB] = LEN_HIB; - all_blk_size_ptr[BLK_SIB] = LEN_SIB; - all_blk_size_ptr[BLK_EIB] = LEN_EIB; + all_blk_size[BLK_HIB] = LEN_HIB; + all_blk_size[BLK_SIB] = LEN_SIB; + all_blk_size[BLK_EIB] = LEN_EIB; /* Length of BLK_XIB is variable and will be filled if block is found */ - all_blk_size_ptr[BLK_XIB] = 0; + all_blk_size[BLK_XIB] = 0; while(!(strncmp((char *)ptr, BLOCK_MAGIC, LEN_MAGIC_NUM)) && next_offset) { uint16_t len = read16(ptr + LEN_OFFSET); @@ -520,26 +513,26 @@ if ((ptr - base + len) > filesize) break; if (len == LEN_HIB) { - blk_ptr[BLK_HIB] = ptr; + all_blocks[BLK_HIB] = ptr; next_offset = read32(ptr + NEXT_OFFSET_HIB); if (next_offset) ptr = base + next_offset; } else if (len == LEN_SIB) { - blk_ptr[BLK_SIB] = ptr; + all_blocks[BLK_SIB] = ptr; next_offset = read32(ptr + NEXT_OFFSET_SIB); if (next_offset) ptr = base + next_offset; } else if (len == LEN_EIB) { /* Skip preliminary blocks */ if (!(read16(ptr + EIB_FEATRUE_OFFSET) & 0x01)) - blk_ptr[BLK_EIB] = ptr; + all_blocks[BLK_EIB] = ptr; next_offset = read32(ptr + NEXT_OFFSET_EIB); if (next_offset) ptr = base + next_offset; } else if (len >= MIN_LEN_XIB) { - blk_ptr[BLK_XIB] = ptr; + all_blocks[BLK_XIB] = ptr; next_offset = read32(ptr + NEXT_OFFSET_XIB); - all_blk_size_ptr[BLK_XIB] = len; + all_blk_size[BLK_XIB] = len; if (next_offset) ptr = base + next_offset; } else { @@ -547,10 +540,10 @@ } } /* We should have found at least one valid block */ - if (blk_ptr[BLK_HIB] || blk_ptr[BLK_SIB] || blk_ptr[BLK_EIB] || - blk_ptr[BLK_XIB]) { + if (all_blocks[BLK_HIB] || all_blocks[BLK_SIB] || all_blocks[BLK_EIB] || + all_blocks[BLK_XIB]) { /* Save currently opened hwi filename. */ - strncpy(curr_hwi_name_ptr, hwi_filename, HWI_MAX_NAME_LEN); + strncpy(current_hwi, hwi_filename, HWI_MAX_NAME_LEN); return CB_SUCCESS; } else
build bot (Jenkins) has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/37175 )
Change subject: [TESTONLY] squashed kill CAR_GLOBAL_MIGRATION leftovers ......................................................................
Patch Set 1:
(2 comments)
https://review.coreboot.org/c/coreboot/+/37175/1/src/drivers/spi/tpm/tis.c File src/drivers/spi/tpm/tis.c:
https://review.coreboot.org/c/coreboot/+/37175/1/src/drivers/spi/tpm/tis.c@1... PS1, Line 12: static unsigned tpm_is_open; Prefer 'unsigned int' to bare use of 'unsigned'
https://review.coreboot.org/c/coreboot/+/37175/1/src/drivers/usb/ehci_debug.... File src/drivers/usb/ehci_debug.c:
https://review.coreboot.org/c/coreboot/+/37175/1/src/drivers/usb/ehci_debug.... PS1, Line 62: static struct ehci_debug_info * glob_dbg_info_p; "foo * bar" should be "foo *bar"
Kyösti Mälkki has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/37175 )
Change subject: [TESTONLY] squashed kill CAR_GLOBAL_MIGRATION leftovers ......................................................................
Patch Set 1: Code-Review-2
This served its purpose, tree with CAR_GLOBAL removed built when we disabled the offending binaryPI boards.
Kyösti Mälkki has abandoned this change. ( https://review.coreboot.org/c/coreboot/+/37175 )
Change subject: [TESTONLY] squashed kill CAR_GLOBAL_MIGRATION leftovers ......................................................................
Abandoned