Module Name:    src
Committed By:   phx
Date:           Sun Nov  6 20:20:57 UTC 2011

Modified Files:
        src/sys/arch/sandpoint/stand/altboot: brdsetup.c globals.h main.c

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


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/sandpoint/stand/altboot/brdsetup.c
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/sandpoint/stand/altboot/globals.h
cvs rdiff -u -r1.14 -r1.15 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/brdsetup.c
diff -u src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.20 src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.21
--- src/sys/arch/sandpoint/stand/altboot/brdsetup.c:1.20	Tue Nov  1 16:32:57 2011
+++ src/sys/arch/sandpoint/stand/altboot/brdsetup.c	Sun Nov  6 20:20:57 2011
@@ -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 @@ iomegabrdfix(struct brdprop *brd)
 
 	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 @@ getchar(void)
 int
 tstchar(void)
 {
+
 	return (UART_READ(uart1base, LSR) & LSR_DRDY) != 0;
 }
 
@@ -1101,3 +1102,35 @@ read_mac_from_flash(uint8_t *mac)
 	/* 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 */

Index: src/sys/arch/sandpoint/stand/altboot/globals.h
diff -u src/sys/arch/sandpoint/stand/altboot/globals.h:1.13 src/sys/arch/sandpoint/stand/altboot/globals.h:1.14
--- src/sys/arch/sandpoint/stand/altboot/globals.h:1.13	Sun Oct 30 21:08:33 2011
+++ src/sys/arch/sandpoint/stand/altboot/globals.h	Sun Nov  6 20:20:57 2011
@@ -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 @@ extern uint32_t cpuclock, busclock;
 /* 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 *);
 

Index: src/sys/arch/sandpoint/stand/altboot/main.c
diff -u src/sys/arch/sandpoint/stand/altboot/main.c:1.14 src/sys/arch/sandpoint/stand/altboot/main.c:1.15
--- src/sys/arch/sandpoint/stand/altboot/main.c:1.14	Mon Apr 25 18:29:33 2011
+++ src/sys/arch/sandpoint/stand/altboot/main.c	Sun Nov  6 20:20:57 2011
@@ -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 check_bootname(char *);
 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 @@ main(int argc, char *argv[], char *boota
 			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 @@ parse_cmdline(char **argv, int maxargc, 
 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

Reply via email to