summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarshall Dawson <marshalldawson3rd@gmail.com>2019-05-22 08:08:23 -0600
committerMartin Roth <martinroth@google.com>2019-06-06 20:00:08 +0000
commit5d2e1d8023917a96f894dce5ee0b00838a6b4df2 (patch)
treedb5ab295ec1064f6fdd6506f54f3a8eaefb03b34
parent08462ce590009c951f0458e6303b97bebe759101 (diff)
downloadcoreboot-5d2e1d8023917a96f894dce5ee0b00838a6b4df2.tar.xz
soc/amd/common: Make biosram functions more readable
Modify the 16 and 32 bit BIOS RAM access functions that had been originally moved from stoneyridge. This was suggested in the review of 69486cac7: Create AcpiMmio functionality from stoneyridge Change-Id: I5b491da6f263cbab2b549301e16a7e19896f2428 Signed-off-by: Marshall Dawson <marshalldawson3rd@gmail.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/32932 Reviewed-by: Richard Spiegel <richard.spiegel@silverbackltd.com> Reviewed-by: Furquan Shaikh <furquan@google.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
-rw-r--r--src/soc/amd/common/block/acpimmio/mmio_util.c22
1 files changed, 7 insertions, 15 deletions
diff --git a/src/soc/amd/common/block/acpimmio/mmio_util.c b/src/soc/amd/common/block/acpimmio/mmio_util.c
index d6320d69d8..c8c69888c6 100644
--- a/src/soc/amd/common/block/acpimmio/mmio_util.c
+++ b/src/soc/amd/common/block/acpimmio/mmio_util.c
@@ -142,11 +142,7 @@ uint8_t biosram_read8(uint8_t reg)
uint16_t biosram_read16(uint8_t reg) /* Must be 1 byte at a time */
{
- int i;
- uint16_t value = 0;
- for (i = sizeof(value) - 1 ; i >= 0 ; i--)
- value = (value << 8) | biosram_read8(reg + i);
- return value;
+ return (biosram_read8(reg + sizeof(uint8_t)) << 8 | biosram_read8(reg));
}
uint32_t biosram_read32(uint8_t reg)
@@ -162,20 +158,16 @@ void biosram_write8(uint8_t reg, uint8_t value)
void biosram_write16(uint8_t reg, uint16_t value)
{
- int i;
- for (i = 0 ; i < sizeof(value) ; i++) {
- biosram_write8(reg + i, value & 0xff);
- value >>= 8;
- }
+ biosram_write8(reg, value & 0xff);
+ value >>= 8;
+ biosram_write8(reg + sizeof(uint8_t), value & 0xff);
}
void biosram_write32(uint8_t reg, uint32_t value)
{
- int i;
- for (i = 0 ; i < sizeof(value) ; i++) {
- biosram_write8(reg + i, value & 0xff);
- value >>= 8;
- }
+ biosram_write16(reg, value & 0xffff);
+ value >>= 16;
+ biosram_write16(reg + sizeof(uint16_t), value & 0xffff);
}
/* cmosram read/write - access registers at 0xfed80600 - currently unused */