summaryrefslogtreecommitdiff
path: root/internal.c
diff options
context:
space:
mode:
authorhailfinger <hailfinger@2b7e53f0-3cfb-0310-b3e9-8179ed1497e1>2009-05-17 15:49:24 +0000
committerhailfinger <hailfinger@2b7e53f0-3cfb-0310-b3e9-8179ed1497e1>2009-05-17 15:49:24 +0000
commitc1bc9ea8f3c3c71f320711d0dbda3cdb96ce1ef8 (patch)
tree81c15dc84a3217eb3359b300fea38bca68421ed0 /internal.c
parentdb3544ed4e996841a63936747cee4b24c2b204e0 (diff)
downloadflashrom-c1bc9ea8f3c3c71f320711d0dbda3cdb96ce1ef8.tar.gz
Use accessor functions for MMIO. Some MMIO accesses used volatile,
others didn't (and risked non-execution of side effects) and even with volatile, some accesses looked dubious. Since the MMIO accessor functions and the onboard flash accessor functions are functionally identical (but have different signatures), make the flash accessors wrappers for the MMIO accessors. For some of the conversions, I used Coccinelle. Semantic patch follows: @@ typedef uint8_t; expression a; volatile uint8_t *b; @@ - b[a] + *(b + a) @@ expression a; volatile uint8_t *b; @@ - *(b) |= (a); + *(b) = *(b) | (a); @@ expression a; volatile uint8_t *b; @@ - *(b) = (a); + mmio_writeb(a, b); @@ volatile uint8_t *b; @@ - *(b) + mmio_readb(b) @@ type T; T b; @@ ( mmio_readb | mmio_writeb ) (..., - (T) - (b) + b ) Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> Uwe tested read, write, erase with this patch on a random board to make sure nothing breaks. Acked-by: Uwe Hermann <uwe@hermann-uwe.de> git-svn-id: https://code.coreboot.org/svn/flashrom/trunk@524 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
Diffstat (limited to 'internal.c')
-rw-r--r--internal.c40
1 files changed, 35 insertions, 5 deletions
diff --git a/internal.c b/internal.c
index a9829a8..d2a9ae2 100644
--- a/internal.c
+++ b/internal.c
@@ -137,31 +137,61 @@ int internal_shutdown(void)
void internal_chip_writeb(uint8_t val, chipaddr addr)
{
- *(volatile uint8_t *) addr = val;
+ mmio_writeb(val, (void *) addr);
}
void internal_chip_writew(uint16_t val, chipaddr addr)
{
- *(volatile uint16_t *) addr = val;
+ mmio_writew(val, (void *) addr);
}
void internal_chip_writel(uint32_t val, chipaddr addr)
{
- *(volatile uint32_t *) addr = val;
+ mmio_writel(val, (void *) addr);
}
uint8_t internal_chip_readb(const chipaddr addr)
{
- return *(volatile uint8_t *) addr;
+ return mmio_readb((void *) addr);
}
uint16_t internal_chip_readw(const chipaddr addr)
{
- return *(volatile uint16_t *) addr;
+ return mmio_readw((void *) addr);
}
uint32_t internal_chip_readl(const chipaddr addr)
{
+ return mmio_readl((void *) addr);
+}
+
+void mmio_writeb(uint8_t val, void *addr)
+{
+ *(volatile uint8_t *) addr = val;
+}
+
+void mmio_writew(uint16_t val, void *addr)
+{
+ *(volatile uint16_t *) addr = val;
+}
+
+void mmio_writel(uint32_t val, void *addr)
+{
+ *(volatile uint32_t *) addr = val;
+}
+
+uint8_t mmio_readb(void *addr)
+{
+ return *(volatile uint8_t *) addr;
+}
+
+uint16_t mmio_readw(void *addr)
+{
+ return *(volatile uint16_t *) addr;
+}
+
+uint32_t mmio_readl(void *addr)
+{
return *(volatile uint32_t *) addr;
}