Module Name: src
Committed By: phx
Date: Tue Dec 25 17:02:35 UTC 2012
Modified Files:
src/sys/arch/sandpoint/stand/altboot: main.c
Log Message:
Add a DEBUG function to search the Flash for byte-streams, as U-Boot usually
doesn't offer a search function.
To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/sandpoint/stand/altboot/main.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/sandpoint/stand/altboot/main.c
diff -u src/sys/arch/sandpoint/stand/altboot/main.c:1.21 src/sys/arch/sandpoint/stand/altboot/main.c:1.22
--- src/sys/arch/sandpoint/stand/altboot/main.c:1.21 Mon May 21 21:34:16 2012
+++ src/sys/arch/sandpoint/stand/altboot/main.c Tue Dec 25 17:02:35 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.21 2012/05/21 21:34:16 dsl Exp $ */
+/* $NetBSD: main.c,v 1.22 2012/12/25 17:02:35 phx Exp $ */
/*-
* Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -111,6 +111,7 @@ static int parse_cmdline(char **, int, c
static int is_space(char);
#ifdef DEBUG
static void sat_test(void);
+static void findflash(void);
#endif
#define BNAME_DEFAULT "wd0:"
@@ -236,12 +237,21 @@ main(int argc, char *argv[], char *boota
n / 100);
if (tstchar()) {
#ifdef DEBUG
- if (toupper(getchar()) == 'C') {
+ unsigned c;
+
+ c = toupper(getchar());
+ if (c == 'C') {
/* controller test terminal */
sat_test();
n = 200;
continue;
}
+ else if (c == 'F') {
+ /* find strings in Flash ROM */
+ findflash();
+ n = 200;
+ continue;
+ }
#else
(void)getchar();
#endif
@@ -665,6 +675,40 @@ is_space(char c)
#ifdef DEBUG
static void
+findflash(void)
+{
+ char buf[256];
+ int i, n;
+ unsigned char c, *p;
+
+ for (;;) {
+ printf("\nfind> ");
+ gets(buf);
+ if (tolower((unsigned)buf[0]) == 'x')
+ break;
+ for (i = 0, n = 0, c = 0; buf[i]; i++) {
+ c <<= 4;
+ c |= hex2nibble(buf[i]);
+ if (i & 1)
+ buf[n++] = c;
+ }
+ printf("Searching for:");
+ for (i = 0; i < n; i++)
+ printf(" %02x", buf[i]);
+ printf("\n");
+ for (p = (unsigned char *)0xff000000;
+ p <= (unsigned char *)(0xffffffff-n); p++) {
+ for (i = 0; i < n; i++) {
+ if (p[i] != buf[i])
+ break;
+ }
+ if (i >= n)
+ printf("Found at %08x\n", (unsigned)p);
+ }
+ }
+}
+
+static void
sat_test(void)
{
char buf[1024];