[coreboot-gerrit] Change in coreboot[master]: [wip] driver/option_table: add option table interface

Marcello Sylvester Bauer (Code Review) gerrit at coreboot.org
Wed Mar 28 14:16:16 CEST 2018


Marcello Sylvester Bauer has uploaded this change for review. ( https://review.coreboot.org/25397


Change subject: [wip] driver/option_table: add option table interface
......................................................................

[wip] driver/option_table: add option table interface

introduce an interface for option table,
so that other non-volatile storage can be used.
This will benefit machines without CMOS
as well as those without a battery-backed CMOS
TODO: Support VPD read-write section as option table

Change-Id: I19b0215170e940c4973e60cbad3d7186a3063cc2
Signed-off-by: Marcello Sylvester Bauer <marcello.bauer at 9elements.com>
---
M src/Kconfig
A src/drivers/option_table/Makefile.inc
A src/drivers/option_table/option_table_cmos.c
M src/drivers/pc80/rtc/mc146818rtc.c
M src/include/option.h
M src/include/pc80/mc146818rtc.h
6 files changed, 48 insertions(+), 8 deletions(-)



  git pull ssh://review.coreboot.org:29418/coreboot refs/changes/97/25397/1

diff --git a/src/Kconfig b/src/Kconfig
index 99a704d..38cf13a 100644
--- a/src/Kconfig
+++ b/src/Kconfig
@@ -113,11 +113,23 @@
 	  Otherwise, say N to use the provided pregenerated scanner/parser.
 
 config USE_OPTION_TABLE
-	bool "Use CMOS for configuration values"
+	bool "Use an option table for configuration values"
+	help
+	  Enable this option if coreboot shall use an option table
+	  instead of hard-coded values.
+
+choice
+	prompt "option table to use"
+	depends on USE_OPTION_TABLE
+	default USE_OPTION_TABLE_CMOS
+
+config USE_OPTION_TABLE_CMOS
+	bool "CMOS"
 	depends on HAVE_OPTION_TABLE
 	help
-	  Enable this option if coreboot shall read options from the "CMOS"
-	  NVRAM instead of using hard-coded values.
+	  read options from the "CMOS" NVRAM
+
+endchoice
 
 config STATIC_OPTION_TABLE
 	bool "Load default configuration values into CMOS on each boot"
diff --git a/src/drivers/option_table/Makefile.inc b/src/drivers/option_table/Makefile.inc
new file mode 100644
index 0000000..5c07e34
--- /dev/null
+++ b/src/drivers/option_table/Makefile.inc
@@ -0,0 +1,3 @@
+ifeq ($(CONFIG_USE_OPTION_TABLE_CMOS),y)
+ramstage-y += option_table_cmos.c
+endif
diff --git a/src/drivers/option_table/option_table_cmos.c b/src/drivers/option_table/option_table_cmos.c
new file mode 100644
index 0000000..b839f74
--- /dev/null
+++ b/src/drivers/option_table/option_table_cmos.c
@@ -0,0 +1,23 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright 2014 The Chromium OS Authors. All rights reserved.
+ * Copyright (C) 2015 Timothy Pearson <tpearson at raptorengineeringinc.com>, Raptor Engineering
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include <option.h>
+#include <pc80/mc146818rtc.h>
+
+enum cb_err get_option(void *dest, const char *name)
+{
+	return get_option_cmos(dest, name);
+}
diff --git a/src/drivers/pc80/rtc/mc146818rtc.c b/src/drivers/pc80/rtc/mc146818rtc.c
index 928b403..f75dd27 100644
--- a/src/drivers/pc80/rtc/mc146818rtc.c
+++ b/src/drivers/pc80/rtc/mc146818rtc.c
@@ -240,7 +240,7 @@
 	return CB_SUCCESS;
 }
 
-enum cb_err get_option(void *dest, const char *name)
+enum cb_err get_option_cmos(void *dest, const char *name)
 {
 	struct cmos_option_table *ct;
 	struct cmos_entries *ce;
diff --git a/src/include/option.h b/src/include/option.h
index f6ede96..07ee4b6 100644
--- a/src/include/option.h
+++ b/src/include/option.h
@@ -6,10 +6,12 @@
  * storage can be used. This will benefit machines without CMOS as well as those
  * without a battery-backed CMOS (e.g. some laptops).
  */
-#if IS_ENABLED(CONFIG_USE_OPTION_TABLE)
-#include <pc80/mc146818rtc.h>
-#else
+
 #include <types.h>
+
+#if IS_ENABLED(CONFIG_USE_OPTION_TABLE)
+enum cb_err get_option(void *dest, const char *name);
+#else
 static inline enum cb_err get_option(void *dest, const char *name)
 {
 	return CB_CMOS_OTABLE_DISABLED;
diff --git a/src/include/pc80/mc146818rtc.h b/src/include/pc80/mc146818rtc.h
index 5d7497d..bc6c99e 100644
--- a/src/include/pc80/mc146818rtc.h
+++ b/src/include/pc80/mc146818rtc.h
@@ -183,7 +183,7 @@
 void cmos_check_update_date(void);
 
 enum cb_err set_option(const char *name, void *val);
-enum cb_err get_option(void *dest, const char *name);
+enum cb_err get_option_cmos(void *dest, const char *name);
 unsigned int read_option_lowlevel(unsigned int start, unsigned int size,
 	unsigned int def);
 

-- 
To view, visit https://review.coreboot.org/25397
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I19b0215170e940c4973e60cbad3d7186a3063cc2
Gerrit-Change-Number: 25397
Gerrit-PatchSet: 1
Gerrit-Owner: Marcello Sylvester Bauer <marcello.bauer at 9elements.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.coreboot.org/pipermail/coreboot-gerrit/attachments/20180328/1aafd269/attachment.html>


More information about the coreboot-gerrit mailing list