shithub: riscv

Download patch

ref: a87ce74d606e1384f43b0afb39e1f17e2e635a1c
parent: 9eb192f586316361a78cf399b410716ee20ed132
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sun Nov 7 12:58:52 EST 2021

kernel/rdb: need to reenable polling mode on the uart, remove cruft

--- a/sys/src/9/port/rdb.c
+++ b/sys/src/9/port/rdb.c
@@ -6,23 +6,6 @@
 #include "io.h"
 #include "ureg.h"
 
-#define DBG	if(0)scrprint
-#pragma varargck argpos scrprint 1
-static Ureg ureg;
-
-static void
-scrprint(char *fmt, ...)
-{
-	char buf[128];
-	va_list va;
-	int n;
-
-	va_start(va, fmt);
-	n = vseprint(buf, buf+sizeof buf, fmt, va)-buf;
-	va_end(va);
-	putstrn(buf, n);
-}
-
 static char*
 getline(void)
 {
@@ -29,28 +12,21 @@
 	static char buf[128];
 	int i, c;
 
-	for(;;){
-		for(i=0; i<nelem(buf) && (c=uartgetc()) != '\n'; i++){
-			DBG("%c...", c);
-			buf[i] = c;
-		}
-
-		if(i < nelem(buf)){
-			buf[i] = 0;
-			return buf;
-		}
-	}
+	for(i = 0; i < sizeof(buf)-1 && (c=uartgetc()) != '\n'; i++)
+		buf[i] = c;
+	buf[i] = 0;
+	return buf;
 }
 
 static void*
 addr(char *s, Ureg *ureg, char **p)
 {
-	ulong a;
+	uvlong a;
 
-	a = strtoul(s, p, 16);
+	a = strtoull(s, p, 16);
 	if(a < sizeof(Ureg))
 		return ((uchar*)ureg)+a;
-	return (void*)a;
+	return (void*)(uintptr)a;
 }
 
 static void
@@ -59,9 +35,19 @@
 	uchar *a;
 	char *p, *req;
 
-	serialoq = nil;		/* turn off serial console */
+	if(consuart == nil)
+		return;
+
+	if(serialoq != nil){
+		qhangup(serialoq, nil);
+		if(consuart->phys->disable != nil)
+			consuart->phys->disable(consuart);
+		if(consuart->phys->enable != nil)
+			consuart->phys->enable(consuart, 0);
+		serialoq = nil;
+	}
 	kprintoq = nil;		/* turn off /dev/kprint if active */
-//	scrprint("Plan 9 debugger\n");
+
 	iprint("Edebugger reset\n");
 	for(;;){
 		req = getline();
@@ -68,9 +54,8 @@
 		switch(*req){
 		case 'r':
 			a = addr(req+1, ureg, nil);
-			DBG("read %p\n", a);
-			iprint("R%.8lux %.2ux %.2ux %.2ux %.2ux\n",
-				strtoul(req+1, 0, 16), a[0], a[1], a[2], a[3]);
+			iprint("R%.8zux %.2ux %.2ux %.2ux %.2ux\n",
+				(uintptr)a, a[0], a[1], a[2], a[3]);
 			break;
 
 		case 'w':
@@ -78,22 +63,8 @@
 			*(ulong*)a = strtoul(p, nil, 16);
 			iprint("W\n");
 			break;
-/*
- *		case Tmput:
-			n = min[4];
-			if(n > 4){
-				mesg(Rerr, Ecount);
-				break;
-			}
-			a = addr(min+0);
-			scrprint("mput %.8lux\n", a);
-			memmove(a, min+5, n);
-			mesg(Rmput, mout);
-			break;
- *
- */
+
 		default:
-			DBG("unknown %c\n", *req);
 			iprint("Eunknown message\n");
 			break;
 		}