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 Added a test terminal for c...



details:   https://anonhg.NetBSD.org/src/rev/76e6c1a202c7
branches:  trunk
changeset: 771059:76e6c1a202c7
user:      phx <phx%NetBSD.org@localhost>
date:      Sun Nov 06 20:20:57 2011 +0000

description:
Added a test terminal for communicating with the satellite microcontroller.
When compiled with DEBUG option it can be entered by typing 'C'.

diffstat:

 sys/arch/sandpoint/stand/altboot/brdsetup.c |  37 ++++++++++++++-
 sys/arch/sandpoint/stand/altboot/globals.h  |   7 ++-
 sys/arch/sandpoint/stand/altboot/main.c     |  70 ++++++++++++++++++++++++++++-
 3 files changed, 110 insertions(+), 4 deletions(-)

diffs (181 lines):

diff -r 708cc6b84b1f -r 76e6c1a202c7 sys/arch/sandpoint/stand/altboot/brdsetup.c
--- a/sys/arch/sandpoint/stand/altboot/brdsetup.c       Sun Nov 06 19:50:46 2011 +0000
+++ b/sys/arch/sandpoint/stand/altboot/brdsetup.c       Sun Nov 06 20:20:57 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: brdsetup.c,v 1.20 2011/11/01 16:32:57 phx Exp $ */
+/* $NetBSD: brdsetup.c,v 1.21 2011/11/06 20:20:57 phx Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -695,7 +695,7 @@
 
        init_uart(uart2base, 9600, LCR_8BITS | LCR_PNONE);
        /* illuminate LEDs */
-       (void)send_iomega('b', 'd', 2, 'a', 60, 50, NULL);
+       if (0) (void)send_iomega('b', 'd', 2, 'a', 60, 50, NULL);
 }
 
 void
@@ -950,6 +950,7 @@
 int
 tstchar(void)
 {
+
        return (UART_READ(uart1base, LSR) & LSR_DRDY) != 0;
 }
 
@@ -1101,3 +1102,35 @@
        /* set to 00:00:00:00:00:00 in case of error */
        memset(mac, 0, 6);
 }
+
+#ifdef DEBUG
+void
+sat_write(char *p, int len)
+{
+       unsigned savedbase;
+
+       savedbase = uart1base;
+       uart1base = uart2base;
+       while (len--)
+               putchar(*p++);
+       uart1base = savedbase;
+}
+
+int
+sat_getch(void)
+{
+       unsigned lsr;
+
+       do {
+               lsr = UART_READ(uart2base, LSR);
+       } while ((lsr & LSR_DRDY) == 0);
+       return UART_READ(uart2base, RBR);
+}
+
+int
+sat_tstch(void)
+{
+
+       return (UART_READ(uart2base, LSR) & LSR_DRDY) != 0;
+}
+#endif /* DEBUG */
diff -r 708cc6b84b1f -r 76e6c1a202c7 sys/arch/sandpoint/stand/altboot/globals.h
--- a/sys/arch/sandpoint/stand/altboot/globals.h        Sun Nov 06 19:50:46 2011 +0000
+++ b/sys/arch/sandpoint/stand/altboot/globals.h        Sun Nov 06 20:20:57 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: globals.h,v 1.13 2011/10/30 21:08:33 phx Exp $ */
+/* $NetBSD: globals.h,v 1.14 2011/11/06 20:20:57 phx Exp $ */
 
 #ifdef DEBUG
 #define        DPRINTF(x)      printf x
@@ -43,6 +43,11 @@
 /* board specific support code */
 struct brdprop *brd_lookup(int);
 int tstchar(void);
+#ifdef DEBUG
+void sat_write(char *, int);
+int sat_getch(void);
+int sat_tstch(void);
+#endif
 unsigned mpc107memsize(void);
 void read_mac_from_flash(uint8_t *);
 
diff -r 708cc6b84b1f -r 76e6c1a202c7 sys/arch/sandpoint/stand/altboot/main.c
--- a/sys/arch/sandpoint/stand/altboot/main.c   Sun Nov 06 19:50:46 2011 +0000
+++ b/sys/arch/sandpoint/stand/altboot/main.c   Sun Nov 06 20:20:57 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.14 2011/04/25 18:29:33 phx Exp $ */
+/* $NetBSD: main.c,v 1.15 2011/11/06 20:20:57 phx Exp $ */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -106,6 +106,9 @@
 static int input_cmdline(char **, int);
 static int parse_cmdline(char **, int, char *, char *);
 static int is_space(char);
+#ifdef DEBUG
+static void sat_test(void);
+#endif
 
 #define        BNAME_DEFAULT "wd0:"
 #define MAX_ARGS 10
@@ -206,7 +209,17 @@
                        printf("Hit any key to enter interactive mode: %d\r",
                            n / 100);
                if (tstchar()) {
+#ifdef DEBUG
+                       if (toupper(getchar()) == 'C') {
+                               /* controller test terminal */
+                               sat_test();
+                               n = 200;
+                               continue;
+                       }
+#else
                        (void)getchar();
+#endif
+                       /* enter command line */
                        argv = new_argv;
                        argc = input_cmdline(argv, MAX_ARGS);
                        break;
@@ -617,5 +630,60 @@
 static int
 is_space(char c)
 {
+
        return c > '\0' && c <= ' ';
 }
+
+#ifdef DEBUG
+static void
+sat_test(void)
+{
+       char buf[1024];
+       int i, j, n, pos;
+       unsigned char c;
+
+       putchar('\n');
+       for (;;) {
+               do {
+                       for (pos = 0; pos < 1024 && sat_tstch() != 0; pos++)
+                               buf[pos] = sat_getch();
+                       if (pos > 1023)
+                               break;
+                       delay(100000);
+               } while (sat_tstch());
+
+               for (i = 0; i < pos; i += 16) {
+                       if ((n = i + 16) > pos)
+                               n = pos;
+                       for (j = 0; j < n; j++)
+                               printf("%02x ", (unsigned)buf[i + j]);
+                       for (; j < 16; j++)
+                               printf("   ");
+                       putchar('\"');
+                       for (j = 0; j < n; j++) {
+                               c = buf[i + j];
+                               putchar((c >= 0x20 && c <= 0x7e) ? c : '.');
+                       }
+                       printf("\"\n");
+               }
+
+               printf("controller> ");
+               gets(buf);
+               if (buf[0] == '*' && buf[1] == 'X')
+                       break;
+
+               if (buf[0] == '0' && tolower((unsigned)buf[1]) == 'x') {
+                       for (i = 2, n = 0, c = 0; buf[i]; i++) {
+                               c <<= 4;
+                               c |= hex2nibble(buf[i]);
+                               if (i & 1)
+                                       buf[n++] = c;
+                       }
+               } else
+                       n = strlen(buf);
+
+               if (n > 0)
+                       sat_write(buf, n);
+       }
+}
+#endif



Home | Main Index | Thread Index | Old Index