Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/sandpoint/stand/altboot Add a DEBUG function to sea...



details:   https://anonhg.NetBSD.org/src/rev/89475691a672
branches:  trunk
changeset: 783490:89475691a672
user:      phx <phx%NetBSD.org@localhost>
date:      Tue Dec 25 17:02:35 2012 +0000

description:
Add a DEBUG function to search the Flash for byte-streams, as U-Boot usually
doesn't offer a search function.

diffstat:

 sys/arch/sandpoint/stand/altboot/main.c |  48 +++++++++++++++++++++++++++++++-
 1 files changed, 46 insertions(+), 2 deletions(-)

diffs (81 lines):

diff -r 07d2f360c6c5 -r 89475691a672 sys/arch/sandpoint/stand/altboot/main.c
--- a/sys/arch/sandpoint/stand/altboot/main.c   Tue Dec 25 10:51:03 2012 +0000
+++ b/sys/arch/sandpoint/stand/altboot/main.c   Tue Dec 25 17:02:35 2012 +0000
@@ -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 is_space(char);
 #ifdef DEBUG
 static void sat_test(void);
+static void findflash(void);
 #endif
 
 #define        BNAME_DEFAULT "wd0:"
@@ -236,12 +237,21 @@
                            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 @@
 
 #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];



Home | Main Index | Thread Index | Old Index