Add cmos helper functions for reading/writing a dword
authorDuncan Laurie <dlaurie@chromium.org>
Mon, 26 Sep 2011 20:24:40 +0000 (13:24 -0700)
committerStefan Reinauer <stefan.reinauer@coreboot.org>
Wed, 28 Mar 2012 19:35:10 +0000 (21:35 +0200)
These get used later for saving/restoring the MRC scrambler
seed values on each boot.

Change-Id: I6e23f17649bea6d22c4b279ed8d0e5cb6c0885e7
Signed-off-by: Duncan Laurie <dlaurie@google.com>
Reviewed-on: http://review.coreboot.org/717
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
src/include/pc80/mc146818rtc.h

index 3e5a61a7067aacf7f7619011b2362ec87b27fcaf..24dac2c098dcc39aad769fabd141b82457440813 100644 (file)
@@ -104,6 +104,22 @@ static inline void cmos_write(unsigned char val, unsigned char addr)
        outb(addr, RTC_BASE_PORT + offs + 0);
        outb(val, RTC_BASE_PORT + offs + 1);
 }
+
+static inline u32 cmos_read32(u8 offset)
+{
+       u32 value = 0;
+       u8 i;
+       for (i = 0; i < sizeof(value); ++i)
+               value |= cmos_read(offset + i) << (i << 3);
+       return value;
+}
+
+static inline void cmos_write32(u8 offset, u32 value)
+{
+       u8 i;
+       for (i = 0; i < sizeof(value); ++i)
+               cmos_write((value >> (i << 3)) & 0xff, offset + i);
+}
 #endif
 
 #if !defined(__ROMCC__)