libpayload: Add access to CMOS images in memory space
authorPatrick Georgi <patrick.georgi@secunet.com>
Thu, 2 Feb 2012 14:51:29 +0000 (15:51 +0100)
committerPatrick Georgi <patrick@georgi-clan.de>
Thu, 2 Feb 2012 16:48:05 +0000 (17:48 +0100)
Provide access to CMOS images in RAM or CBFS, such as cmos.defaults

Change-Id: Ifa70dea6206d94c0c271caf9ae1152fc76b5d51a
Signed-off-by: Patrick Georgi <patrick.georgi@secunet.com>
Reviewed-on: http://review.coreboot.org/584
Tested-by: build bot (Jenkins)
Reviewed-by: Patrick Georgi <patrick@georgi-clan.de>
payloads/libpayload/drivers/options.c
payloads/libpayload/include/libpayload.h

index 61e6cc565f425e31e431d1fa2842a9ca591deb59..36d8a9b5b09b9b2044ed4f643d93c7f80d599b8b 100644 (file)
 #include <libpayload.h>
 #include <coreboot_tables.h>
 
+u8 *mem_accessor_base;
+
+static u8 mem_read(u8 reg)
+{
+       return mem_accessor_base[reg];
+}
+
+static void mem_write(u8 val, u8 reg)
+{
+       mem_accessor_base[reg] = val;
+}
+
 struct nvram_accessor *use_nvram = &(struct nvram_accessor) {
        nvram_read,
        nvram_write
 };
 
+struct nvram_accessor *use_mem = &(struct nvram_accessor) {
+       mem_read,
+       mem_write
+};
+
 struct cb_cmos_option_table *get_system_option_table(void)
 {
        return phys_to_virt(lib_sysinfo.option_table);
index 91156e53df78a7ed11499064f31f0979341737b5..308d95c667f1122c9d39676fc52d1b4d94153b3a 100644 (file)
@@ -199,7 +199,8 @@ struct nvram_accessor {
        void (*write)(u8 val, u8 reg);
 };
 
-extern struct nvram_accessor *use_nvram;
+extern u8 *mem_accessor_base;
+extern struct nvram_accessor *use_nvram, *use_mem;
 
 struct cb_cmos_option_table *get_system_option_table(void);
 void fix_options_checksum_with(const struct nvram_accessor *nvram);