From bc17b6f98f50a9c295d59290328f439b49defc8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ky=C3=B6sti=20M=C3=A4lkki?= Date: Fri, 20 Dec 2019 04:19:46 +0200 Subject: amdblocks/biosram: Force use of abstraction MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Hide the fundamental BIOSRAM accessors to force use of the memory space via abstraction functions. Change-Id: I774b6640cdd9873f52e446c4ca41b7c537a87883 Signed-off-by: Kyösti Mälkki Reviewed-on: https://review.coreboot.org/c/coreboot/+/37862 Reviewed-by: Marshall Dawson Reviewed-by: Angel Pons Reviewed-by: Richard Spiegel Tested-by: build bot (Jenkins) --- src/soc/amd/common/block/acpimmio/biosram.c | 50 +++++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 2 deletions(-) (limited to 'src/soc/amd/common/block/acpimmio/biosram.c') diff --git a/src/soc/amd/common/block/acpimmio/biosram.c b/src/soc/amd/common/block/acpimmio/biosram.c index e33f02d02c..814fdf3b00 100644 --- a/src/soc/amd/common/block/acpimmio/biosram.c +++ b/src/soc/amd/common/block/acpimmio/biosram.c @@ -11,9 +11,55 @@ * GNU General Public License for more details. */ -#include -#include +#include #include +#include +#include +#include + +/* BiosRam Ranges at 0xfed80500 or I/O 0xcd4/0xcd5 */ +#define BIOSRAM_AP_ENTRY 0xe8 /* 8 bytes */ +#define BIOSRAM_CBMEM_TOP 0xf0 /* 4 bytes */ +#define BIOSRAM_UMA_SIZE 0xf4 /* 4 bytes */ +#define BIOSRAM_UMA_BASE 0xf8 /* 8 bytes */ + +static uint8_t biosram_read8(uint8_t reg) +{ + return read8((void *)(ACPIMMIO_BIOSRAM_BASE + reg)); +} + +static void biosram_write8(uint8_t reg, uint8_t value) +{ + write8((void *)(ACPIMMIO_BIOSRAM_BASE + reg), value); +} + +static uint16_t biosram_read16(uint8_t reg) /* Must be 1 byte at a time */ +{ + return (biosram_read8(reg + sizeof(uint8_t)) << 8 | biosram_read8(reg)); +} + +static uint32_t biosram_read32(uint8_t reg) +{ + uint32_t value = biosram_read16(reg + sizeof(uint16_t)) << 16; + return value | biosram_read16(reg); +} + +static void biosram_write16(uint8_t reg, uint16_t value) +{ + biosram_write8(reg, value & 0xff); + value >>= 8; + biosram_write8(reg + sizeof(uint8_t), value & 0xff); +} + +static void biosram_write32(uint8_t reg, uint32_t value) +{ + biosram_write16(reg, value & 0xffff); + value >>= 16; + biosram_write16(reg + sizeof(uint16_t), value & 0xffff); +} + + +/* Access to BIOSRAM is only allowed through the abstractions below. */ void *get_ap_entry_ptr(void) { -- cgit v1.2.3