diff options
author | Jonathan Neuschäfer <j.neuschaefer@gmx.net> | 2017-11-20 00:57:32 +0100 |
---|---|---|
committer | Martin Roth <martinroth@google.com> | 2017-12-02 05:25:00 +0000 |
commit | c0c31b6d1a91d8e69bce847a21884944dc679587 (patch) | |
tree | df097599c145e4e0b41028d7a6b203a67702daaf | |
parent | 3ca8b598ed4ea16fd55d0d8108749c1da537a036 (diff) | |
download | coreboot-c0c31b6d1a91d8e69bce847a21884944dc679587.tar.xz |
riscv: Remove config string support
The code dealing with the old config string isn't needed anymore,
because the config string has been deprecated in favor of
OpenFirmware-derived devicetrees.
Change-Id: I71398fb4861dbaf7eefc6e6f222bb7159798fafa
Signed-off-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
Reviewed-on: https://review.coreboot.org/22594
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Ronald G. Minnich <rminnich@gmail.com>
-rw-r--r-- | src/arch/riscv/Kconfig | 5 | ||||
-rw-r--r-- | src/arch/riscv/Makefile.inc | 9 | ||||
-rw-r--r-- | src/arch/riscv/boot.c | 3 | ||||
-rw-r--r-- | src/arch/riscv/trap_handler.c | 1 | ||||
-rw-r--r-- | src/commonlib/configstring.c | 52 | ||||
-rw-r--r-- | src/commonlib/include/commonlib/configstring.h | 209 | ||||
-rw-r--r-- | src/soc/ucb/riscv/cbmem.c | 1 |
7 files changed, 4 insertions, 276 deletions
diff --git a/src/arch/riscv/Kconfig b/src/arch/riscv/Kconfig index f05a98b106..a30cb7091b 100644 --- a/src/arch/riscv/Kconfig +++ b/src/arch/riscv/Kconfig @@ -19,8 +19,3 @@ config ARCH_ROMSTAGE_RISCV config ARCH_RAMSTAGE_RISCV bool default n - -config RISCV_CONFIGSTRING - hex "Location of pointer to RISCV config string" - default 0x100c - depends on ARCH_RISCV diff --git a/src/arch/riscv/Makefile.inc b/src/arch/riscv/Makefile.inc index 057088acd4..d2b6cce11d 100644 --- a/src/arch/riscv/Makefile.inc +++ b/src/arch/riscv/Makefile.inc @@ -43,8 +43,7 @@ bootblock-y += \ $(top)/src/lib/memcmp.c \ $(top)/src/lib/memcpy.c \ $(top)/src/lib/memmove.c \ - $(top)/src/lib/memset.c \ - $(top)/src/commonlib/configstring.c + $(top)/src/lib/memset.c $(objcbfs)/bootblock.debug: $$(bootblock-objs) @printf " LINK $(subst $(obj)/,,$(@))\n" @@ -70,8 +69,7 @@ romstage-y += \ $(top)/src/lib/memcmp.c \ $(top)/src/lib/memcpy.c \ $(top)/src/lib/memmove.c \ - $(top)/src/lib/memset.c \ - $(top)/src/commonlib/configstring.c + $(top)/src/lib/memset.c romstage-$(CONFIG_COLLECT_TIMESTAMPS) += timestamp.c @@ -103,8 +101,7 @@ ramstage-y += \ $(top)/src/lib/memcmp.c \ $(top)/src/lib/memcpy.c \ $(top)/src/lib/memmove.c \ - $(top)/src/lib/memset.c \ - $(top)/src/commonlib/configstring.c + $(top)/src/lib/memset.c $(eval $(call create_class_compiler,rmodules,riscv)) diff --git a/src/arch/riscv/boot.c b/src/arch/riscv/boot.c index 9483c48177..ac095bbee1 100644 --- a/src/arch/riscv/boot.c +++ b/src/arch/riscv/boot.c @@ -18,13 +18,12 @@ #include <arch/encoding.h> #include <rules.h> #include <console/console.h> -#include <commonlib/configstring.h> void arch_prog_run(struct prog *prog) { void (*doit)(void *) = prog_entry(prog); void riscvpayload(const char *configstring, void *payload); - const char *config = configstring(); + const char *config = NULL; if (ENV_RAMSTAGE && prog_type(prog) == PROG_PAYLOAD) { printk(BIOS_SPEW, "Config string: '%s'\n", config); diff --git a/src/arch/riscv/trap_handler.c b/src/arch/riscv/trap_handler.c index b64505cc87..8fd037507a 100644 --- a/src/arch/riscv/trap_handler.c +++ b/src/arch/riscv/trap_handler.c @@ -18,7 +18,6 @@ #include <console/console.h> #include <string.h> #include <vm.h> -#include <commonlib/configstring.h> static uint64_t *time; static uint64_t *timecmp; diff --git a/src/commonlib/configstring.c b/src/commonlib/configstring.c deleted file mode 100644 index fc91a4b9de..0000000000 --- a/src/commonlib/configstring.c +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2013-2016, The Regents of the University of California - *(Regents). - * All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Regents nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, - * SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, - * ARISING - * OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS - * BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED - * HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE - * MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. - */ - -#include <string.h> -#include <commonlib/configstring.h> - -void query_mem(const char *config_string, uintptr_t *base, size_t *size) -{ - query_result res = query_config_string(config_string, "ram{0{addr"); - *base = get_uint(res); - res = query_config_string(config_string, "ram{0{size"); - *size = get_uint(res); -} - -/* query_rtc returns the physical address of the rtc. */ -void query_rtc(const char *config_string, uintptr_t *mtime) -{ - query_result res = query_config_string(config_string, "rtc{addr"); - *mtime = (uintptr_t)get_uint(res); -} - -const char *configstring(void) -{ - uint32_t addr = *(uint32_t *)CONFIG_RISCV_CONFIGSTRING; - return (const char *)(uintptr_t)addr; -} diff --git a/src/commonlib/include/commonlib/configstring.h b/src/commonlib/include/commonlib/configstring.h deleted file mode 100644 index 8aacbda909..0000000000 --- a/src/commonlib/include/commonlib/configstring.h +++ /dev/null @@ -1,209 +0,0 @@ -/* - * Copyright (c) 2013-2016, The Regents of the University of California - *(Regents). - * All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the Regents nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, - * SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, - * ARISING - * OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF REGENTS HAS - * BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED - * HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE - * MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. - */ - -#ifndef RISCV_CONFIG_STRING_H -#define RISCV_CONFIG_STRING_H - -#include <stddef.h> -#include <stdint.h> - -static const char *skip_whitespace(const char *str) -{ - while (*str && *str <= ' ') - str++; - return str; -} - -static const char *skip_string(const char *str) -{ - while (*str && *str++ != '"') - ; - return str; -} - -static int is_hex(char ch) -{ - return (ch >= '0' && ch <= '9') || (ch >= 'a' && ch <= 'f') || - (ch >= 'A' && ch <= 'F'); -} - -static int parse_hex(char ch) -{ - return (ch >= '0' && ch <= '9') ? ch - '0' : (ch >= 'a' && ch <= 'f') - ? ch - 'a' + 10 - : ch - 'A' + 10; -} - -static const char *skip_key(const char *str) -{ - while (*str >= 35 && *str <= 122 && *str != ';') - str++; - return str; -} - -typedef struct { - const char *start; - const char *end; -} query_result; - -static inline query_result query_config_string(const char *str, const char *k) -{ - size_t ksize = 0; - while (k[ksize] && k[ksize] != '{') - ksize++; - int last = !k[ksize]; - - query_result res = {0, 0}; - while (1) { - const char *key_start = str = skip_whitespace(str); - const char *key_end = str = skip_key(str); - int match = (size_t)(key_end - key_start) == ksize; - if (match) - for (size_t i = 0; i < ksize; i++) - if (key_start[i] != k[i]) - match = 0; - const char *value_start = str = skip_whitespace(str); - while (*str != ';') { - if (!*str) { - return res; - } else if (*str == '"') { - str = skip_string(str + 1); - } else if (*str == '{') { - const char *search_key = - match && !last ? k + ksize + 1 : ""; - query_result inner_res = - query_config_string(str + 1, search_key); - if (inner_res.start) - return inner_res; - str = inner_res.end + 1; - } else { - str = skip_key(str); - } - str = skip_whitespace(str); - } - res.end = str; - if (match && last) { - res.start = value_start; - return res; - } - str = skip_whitespace(str + 1); - if (*str == '}') { - res.end = str; - return res; - } - } -} - -static void parse_string(query_result r, char *buf) -{ - if (r.start < r.end) { - if (*r.start == '"') { - for (const char *p = r.start + 1; - p < r.end && *p != '"'; p++) { - char ch = p[0]; - if (ch == '\\' && p[1] == 'x' && is_hex(p[2])) { - ch = parse_hex(p[2]); - if (is_hex(p[3])) { - ch = - (ch << 4) + parse_hex(p[3]); - p++; - } - p += 2; - } - *buf++ = ch; - } - } else { - for (const char *p = r.start; p < r.end && *p > ' '; - p++) - *buf++ = *p; - } - } - *buf = 0; -} - -static uint64_t __get_uint_hex(const char *s) -{ - uint64_t res = 0; - while (*s) { - if (is_hex(*s)) - res = (res << 4) + parse_hex(*s); - else if (*s != '_') - break; - s++; - } - return res; -} - -static uint64_t __get_uint_dec(const char *s) -{ - uint64_t res = 0; - while (*s) { - if (*s >= '0' && *s <= '9') - res = res * 10 + (*s - '0'); - else - break; - s++; - } - return res; -} - -static uint64_t __get_uint(const char *s) -{ - if (s[0] == '0' && s[1] == 'x') - return __get_uint_hex(s + 2); - return __get_uint_dec(s); -} - -// This is nasty. But the original code used a much nastier thing, -// an array declared as an automatic, which triggered gcc warnings -// as it was sized by the res.end - res.start. We'll need a better -// solution, long term. Malloc is probably not it. -static char name[1024]; -static inline uint64_t get_uint(query_result res) -{ - uint64_t v; - parse_string(res, name); - v = __get_uint(name); - return v; -} - -static inline int64_t get_sint(query_result res) -{ - int64_t v; - parse_string(res, name); - if (name[0] == '-') - return -__get_uint(name + 1); - v = __get_uint(name); - return v; -} - -const char *configstring(void); -void query_mem(const char *config_string, uintptr_t *base, size_t *size); -void query_rtc(const char *config_string, uintptr_t *mtime); -#endif diff --git a/src/soc/ucb/riscv/cbmem.c b/src/soc/ucb/riscv/cbmem.c index f8f4098d75..2ee400ab8b 100644 --- a/src/soc/ucb/riscv/cbmem.c +++ b/src/soc/ucb/riscv/cbmem.c @@ -12,7 +12,6 @@ */ #include <cbmem.h> -#include <commonlib/configstring.h> void *cbmem_top(void) { |