Commit 1162d036 authored by Alessandro Rubini's avatar Alessandro Rubini

tools: added '-g' option to specmem

parent 4355020e
......@@ -41,7 +41,7 @@ int main(int argc, char **argv)
exit(1);
}
base = spec_get_base();
base = spec_get_base(BASE_BAR0);
if (base == (typeof(base))-1) {
fprintf(stderr, "%s: spec_get_base(): %s\n", argv[0],
strerror(errno));
......
uint32_t spec_get_base(void);
uint32_t spec_get_base(int basenr);
enum {
BASE_BAR0 = 0, /* for wrpc etc (but lm32 is at 0x80000 offset) */
BASE_BAR2,
BASE_BAR4 /* for gennum-internal registers */
};
/*
* Trivial library function to return the first spec memory address
* Trivial library function to return one of the spec memory addresses
*/
#include <stdint.h>
#include <string.h>
#include <stdio.h>
#include <errno.h>
uint32_t spec_get_base(void)
#include "spec-tools.h"
uint32_t spec_get_base(int base)
{
FILE *f;
int found = 0;
......@@ -21,9 +23,10 @@ uint32_t spec_get_base(void)
if (strstr(s, "Device 10dc:018d"))
found = 1;
}
if (found) {
if (sscanf(s, " Memory at %x", &res) == 1)
if (found && sscanf(s, " Memory at %x", &res) == 1) {
if (!base)
break;
base--;
}
}
pclose(f);
......
......@@ -17,15 +17,22 @@
int main(int argc, char **argv)
{
int i, fd;
int i, fd, bar = BASE_BAR0;
uint32_t base, *ptr;
uint32_t uarg[3];
void *map_base;
char *end;
if (argc > 1 && !strcmp(argv[1], "-g")) {
bar = BASE_BAR4;
argv[1] = argv[0];
argc--; argv++;
}
if (argc < 2 || argc > 3) {
fprintf(stderr,
"Use: \"%s <offset> [<value>]\" (I/O is 32 bits)\n",
"Use: \"%s [-g] <offset> [<value>]\" "
"(-g selects gennum memory, I/O is 32 bits)\n",
argv[0]);
exit(1);
}
......@@ -36,7 +43,7 @@ int main(int argc, char **argv)
exit(1);
}
base = spec_get_base();
base = spec_get_base(bar);
if (base == (typeof(base))-1) {
fprintf(stderr, "%s: spec_get_base(): %s\n", argv[0],
strerror(errno));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment