Browse Source

With this, boots and works

But not if I change boot.c for replacing actual consoles.

Signed-off-by: Álvaro Jurado <elbingmiss@gmail.com>
Álvaro Jurado 7 years ago
parent
commit
ac3755a752
5 changed files with 3 additions and 336 deletions
  1. 0 1
      sys/src/9/amd64/BUILD
  2. 3 137
      sys/src/9/port/devcons.c
  3. 0 84
      sys/src/9/port/devuart.c
  4. 0 1
      sys/src/9/port/port.json
  5. 0 113
      sys/src/9/port/rdb.c

+ 0 - 1
sys/src/9/amd64/BUILD

@@ -107,7 +107,6 @@ PORT_SRCS = [
 	"//sys/src/9/port/qio.c",
 	"//sys/src/9/port/qlock.c",
 	"//sys/src/9/port/random.c",
-	"//sys/src/9/port/rdb.c",
 	"//sys/src/9/port/rebootcmd.c",
 	"//sys/src/9/port/rmap.c",
 	"//sys/src/9/port/sdscsi.c",

+ 3 - 137
sys/src/9/port/devcons.c

@@ -18,7 +18,7 @@
 
 enum
 {
-	Nconsdevs	= 64,		/* max number of consoles */
+	Nconsdevs	= 3,		/* max number of consoles */
 
 	/* Consdev flags */
 	Ciprint		= 2,		/* call this fn from iprint */
@@ -50,7 +50,6 @@ static	Consdev	consdevs[Nconsdevs] =			/* keep this order */
 {
 	{nil, nil,	kmesgputs,	0},			/* kmesg */
 	{nil, nil,	kprintputs,	Ciprint},		/* kprint */
-	{nil, nil,	uartputs,	Ciprint|Cntorn},	/* serial */
 };
 
 static	int	nkbdqs;
@@ -283,6 +282,7 @@ kmesgputs(char *str, int n)
 	iunlock(&kmesg.lk);
 }
 
+/*
 static void
 consdevputs(Consdev *c, char *s, int n, int usewrite)
 {
@@ -299,6 +299,7 @@ consdevputs(Consdev *c, char *s, int n, int usewrite)
 	else if(c->fn != nil)
 		c->fn(s, n);
 }
+*/
 
 /*
  *   Print a string on the console.  Convert \n to \r\n for serial
@@ -521,112 +522,6 @@ pprint(char *fmt, ...)
 	return n;
 }
 
-static void
-echo(char *buf, int n)
-{
-	Mpl pl;
-	static int ctrlt;
-	char *e, *p;
-
-	if(n == 0)
-		return;
-
-	e = buf+n;
-	for(p = buf; p < e; p++){
-		switch(*p){
-		case 0x10:	/* ^P */
-			if(cpuserver && !kbd.ctlpoff){
-				active.exiting = 1;
-				return;
-			}
-			break;
-		case 0x14:	/* ^T */
-			ctrlt++;
-			if(ctrlt > 2)
-				ctrlt = 2;
-			continue;
-		}
-
-		if(ctrlt != 2)
-			continue;
-
-		/* ^T escapes */
-		ctrlt = 0;
-		switch(*p){
-		case 'S':
-			pl = splhi();
-			dumpstack();
-			procdump();
-			splx(pl);
-			return;
-		case 's':
-			dumpstack();
-			return;
-		case 'x':
-			ixsummary();
-			mallocsummary();
-//			memorysummary();
-			pagersummary();
-			return;
-		case 'd':
-			if(consdebug == nil)
-				consdebug = rdb;
-			else
-				consdebug = nil;
-			print("consdebug now %#p\n", consdebug);
-			return;
-		case 'D':
-			if(consdebug == nil)
-				consdebug = rdb;
-			consdebug();
-			return;
-		case 'p':
-			pl = spllo();
-			procdump();
-			splx(pl);
-			return;
-		case 'q':
-			scheddump();
-			return;
-		case 'k':
-			killbig("^t ^t k");
-			return;
-		case 'r':
-			exit(0);
-			return;
-		}
-	}
-
-	if(kbdq != nil)
-		qproduce(kbdq, buf, n);
-	if(kbd.raw == 0)
-		putstrn(buf, n);
-}
-
-/*
- *  Called by a uart interrupt for console input.
- *
- *  turn '\r' into '\n' before putting it into the queue.
- */
-int
-kbdcr2nl(Queue* q, int ch)
-{
-	char *next;
-
-	ilock(&kbd.lockputc);		/* just a mutex */
-	if(ch == '\r' && !kbd.raw)
-		ch = '\n';
-	next = kbd.iw+1;
-	if(next >= kbd.ie)
-		next = kbd.istage;
-	if(next != kbd.ir){
-		*kbd.iw = ch;
-		kbd.iw = next;
-	}
-	iunlock(&kbd.lockputc);
-	return 0;
-}
-
 /*
  *  Put character, possibly a rune, into read queue at interrupt time.
  *  Called at interrupt time to process a character.
@@ -658,29 +553,6 @@ kbdputc(Queue *q, int ch)
 	return 0;
 }
 
-/*
- *  we save up input characters till clock time to reduce
- *  per character interrupt overhead.
- */
-static void
-kbdputcclock(void)
-{
-	char *iw;
-
-	/* this amortizes cost of qproduce */
-	if(kbd.iw != kbd.ir){
-		iw = kbd.iw;
-		if(iw < kbd.ir){
-			echo(kbd.ir, kbd.ie-kbd.ir);
-			kbd.ir = kbd.istage;
-		}
-		if(kbd.ir != iw){
-			echo(kbd.ir, iw-kbd.ir);
-			kbd.ir = iw;
-		}
-	}
-}
-
 enum{
 	Qdir,
 	Qbintime,
@@ -788,12 +660,6 @@ static void
 consinit(void)
 {
 	todinit();
-	/*
-	 * at 115200 baud, the 1024 char buffer takes 56 ms to process,
-	 * processing it every 22 ms should be fine
-	 */
-	addclock0link(kbdputcclock, 22);
-	kickkbdq();
 }
 
 static Chan*

+ 0 - 84
sys/src/9/port/devuart.c

@@ -131,35 +131,6 @@ uartdisable(Uart *p)
 	unlock(&uartalloc.Lock);
 }
 
-Uart*
-uartconsole(int i, char *cmd)
-{
-	Uart *p;
-
-	if(i >= uartnuart || (p = uart[i]) == nil)
-		return nil;
-
-	qlock(&p->ql);
-	if(!p->console){
-		if(p->opens == 0 && uartenable(p) == nil){
-			qunlock(&p->ql);
-			return nil;
-		}
-		p->opens++;
-
-		addkbdq(p->iq, -1);
-		addconsdev(p->oq, uartputs, 2, 0);
-		p->putc = kbdcr2nl;
-		if(cmd != nil && *cmd != '\0')
-			uartctl(p, cmd);
-
-		p->console = 1;
-	}
-	qunlock(&p->ql);
-
-	return p;
-}
-
 static void
 uartsetlength(int i)
 {
@@ -230,23 +201,6 @@ uartreset(void)
 		dp->perm = 0444;
 		dp++;
 
-		uart[i] = p;
-		p->dev = i;
-		if(p->console || p->special){
-			/*
-			 * No qlock here, only called at boot time.
-			 */
-			if(uartenable(p) != nil){
-				if(p->console){
-					addkbdq(p->iq, -1);
-					addconsdev(p->oq, uartputs, 2, 0);
-					p->putc = kbdcr2nl;
-				}
-				p->opens++;
-			}
-		}
-		p = p->next;
-
 		uart[i] = p;
 		p->dev = i;
 		p = p->next;
@@ -770,41 +724,3 @@ uartclock(void)
 	}
 	unlock(&uartalloc.Lock);
 }
-
-/*
- * polling console input, output
- */
-
-Uart* consuart;
-
-int
-uartgetc(void)
-{
-	if(consuart == nil || consuart->phys->getc == nil)
-		return -1;
-	return consuart->phys->getc(consuart);
-}
-
-void
-uartputc(int c)
-{
-	if(consuart == nil || consuart->phys->putc == nil)
-		return;
-	consuart->phys->putc(consuart, c);
-}
-
-void
-uartputs(char *s, int n)
-{
-	char *e;
-
-	if(consuart == nil || consuart->phys->putc == nil)
-		return;
-
-	e = s+n;
-	for(; s<e; s++){
-		if(*s == '\n')
-			consuart->phys->putc(consuart, '\r');
-		consuart->phys->putc(consuart, *s);
-	}
-}

+ 0 - 1
sys/src/9/port/port.json

@@ -67,7 +67,6 @@
 			"../port/qlock.c",
 			"../port/random.c",
 			"../port/rebootcmd.c",
-			"../port/rdb.c",
 			"../port/rmap.c",
 			"../port/sdscsi.c",
 			"../port/segment.c",

+ 0 - 113
sys/src/9/port/rdb.c

@@ -1,113 +0,0 @@
-/*
- * This file is part of the UCB release of Plan 9. It is subject to the license
- * terms in the LICENSE file found in the top-level directory of this
- * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
- * part of the UCB release of Plan 9, including this file, may be copied,
- * modified, propagated, or distributed except according to the terms contained
- * in the LICENSE file.
- */
-
-#include "u.h"
-#include "../port/lib.h"
-#include "mem.h"
-#include "dat.h"
-#include "fns.h"
-
-#include "ureg.h"
-
-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)
-{
-	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;
-		}
-	}
-}
-
-static void*
-addr(char *s, Ureg *ureg, char **p)
-{
-	uint64_t a;
-
-	a = strtoul(s, p, 16);
-	if(a < sizeof(Ureg))
-		return ((uint8_t*)ureg)+a;
-	return (void*)a;
-}
-
-static void
-talkrdb(Ureg *ureg)
-{
-	uint8_t *a;
-	char *p, *req;
-
-	delconsdevs();		/* turn off serial console and kprint */
-//	scrprint("Plan 9 debugger\n");
-	iprint("Edebugger reset\n");
-	for(;;){
-		req = getline();
-		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]);
-			break;
-
-		case 'w':
-			a = addr(req+1, ureg, &p);
-			*(uint32_t*)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;
-		}
-	}
-}
-
-void
-rdb(void)
-{
-	splhi();
-	iprint("rdb...");
-	callwithureg(talkrdb);
-}