aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitmodules3
-rw-r--r--benchmarks/ioexample/ioexample_main.c84
m---------benchmarks/ioexample/libamf0
3 files changed, 5 insertions, 82 deletions
diff --git a/.gitmodules b/.gitmodules
index a557616..2765f62 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,3 +1,6 @@
[submodule "env"]
path = env
url = https://github.com/riscv/riscv-test-env.git
+[submodule "benchmarks/ioexample/libamf"]
+ path = benchmarks/ioexample/libamf
+ url = git://github.com/palmer-dabbelt/libamf.git
diff --git a/benchmarks/ioexample/ioexample_main.c b/benchmarks/ioexample/ioexample_main.c
index a2de7c1..bd411d8 100644
--- a/benchmarks/ioexample/ioexample_main.c
+++ b/benchmarks/ioexample/ioexample_main.c
@@ -1,6 +1,7 @@
// See LICENSE for license details.
#include "util.h"
+#include "libamf/src/amf.h"
const char *find_config_string(void)
{
@@ -10,67 +11,6 @@ const char *find_config_string(void)
return config_string;
}
-int isspace(int c)
-{
- if (c == ' ') return 1;
- if (c == '\t') return 1;
- if (c == '\n') return 1;
- if (c == '\r') return 1;
- return 0;
-}
-
-const char *advance_until_slash(const char *path)
-{
- while ((*path != '\0') && (*path != '/'))
- path++;
- if (*path == '/')
- path++;
-
- return path;
-}
-
-const char *advance_until_entered(const char *config_string)
-{
- while ((*config_string != '\0') && (*config_string != '{'))
- config_string++;
-
- if (*config_string == '{')
- config_string++;
-
- return config_string;
-}
-
-const char *advance_until_over(const char *config_string)
-{
- config_string = advance_until_entered(config_string);
- int open = 1;
- while ((*config_string != '\0') && (open > 0)) {
- if (*config_string == '{') open++;
- if (*config_string == '}') open--;
- config_string++;
- }
- if (*config_string == ';')
- config_string++;
-
- return config_string;
-}
-
-int compare_until_slash(const char *config_string, const char *path)
-{
- while (isspace(*config_string)) config_string++;
- while ((*path != '\0') && (*path != '/') && (*config_string != '\0')) {
- if (*path != *config_string)
- return 0;
- path++;
- config_string++;
- }
-
- if (!isspace(*config_string))
- return 0;
-
- return 1;
-}
-
long fromhex(char c)
{
if (c >= 'A' && c <= 'F') return c - 'A' + 10;
@@ -91,29 +31,9 @@ long tolong(const char *config_snippet)
return out;
}
-const char *find_in_config_string(const char *config_string, const char *path)
-{
- while (*path != '\0' && *config_string != '\0') {
- if (compare_until_slash(config_string, path)) {
- path = advance_until_slash(path);
- if (*path != '\0')
- config_string = advance_until_entered(config_string);
- } else {
- config_string = advance_until_over(config_string);
- }
- }
-
- /* Remove any whitespace from the config string, then strip off the key. */
- while (*config_string != '\0' && isspace(*config_string)) config_string++;
- while (*config_string != '\0' && !isspace(*config_string)) config_string++;
- while (*config_string != '\0' && isspace(*config_string)) config_string++;
-
- return config_string;
-}
-
int main( int argc, char* argv[] )
{
- volatile long *base = (long *)(tolong(find_in_config_string(find_config_string(), "smiexample/addr")));
+ volatile long *base = (long *)(tolong(amf_lookup(find_config_string(), "smiexample/addr")));
printf("smiexample/addr: %lx\n", base);
base[1] = 10; // Period
diff --git a/benchmarks/ioexample/libamf b/benchmarks/ioexample/libamf
new file mode 160000
+Subproject 9d28f8d3adbed4654a95ebbf383134db26be5d9