Browse Source

Plan 9 from Bell Labs 2010-10-08

David du Colombier 13 years ago
parent
commit
114b67a6fd

+ 0 - 1
sys/include/ape/draw.h

@@ -529,7 +529,6 @@ extern	void	_twiddlecompressed(uchar*, int);
 extern	int	_compblocksize(Rectangle, int);
 
 /* XXX backwards helps; should go */
-extern	int		log2[];
 extern	ulong	drawld2chan[];
 extern	void		drawsetdebug(int);
 

+ 1 - 1
sys/include/draw.h

@@ -522,6 +522,6 @@ extern	void	_twiddlecompressed(uchar*, int);
 extern	int	_compblocksize(Rectangle, int);
 
 /* XXX backwards helps; should go */
-extern	int		log2[];
+// extern	int		log2[];	/* was used by libmemlayer/line.c */
 extern	ulong	drawld2chan[];
 extern	void		drawsetdebug(int);

+ 0 - 1
sys/src/9/omap/clock.c

@@ -352,7 +352,6 @@ clockinit(void)
 	 * needed to consume 1 ms.  2 is min. instructions in the delay loop.
 	 */
 	m->delayloop = m->cpuhz / (1000 * 2);
-	m->delayloop = m->cpuhz / 1000;		/* overestimate for safety */
 //	iprint("m->delayloop = %lud\n", m->delayloop);
 
 	/*

+ 1 - 0
sys/src/9/omap/dat.h

@@ -218,6 +218,7 @@ extern register Proc* up;			/* R9 */
 extern uintptr kseg0;
 extern Mach* machaddr[MAXMACH];
 extern ulong memsize;
+extern int normalprint;
 
 /*
  *  a parsed plan9.ini line

+ 0 - 1
sys/src/9/omap/devcons.c

@@ -206,7 +206,6 @@ putstrn(char *str, int n)
 }
 
 int noprint;
-extern int normalprint;
 
 int
 print(char *fmt, ...)

+ 1 - 1
sys/src/9/omap/devuart.c

@@ -513,7 +513,6 @@ uartwrite(Chan *c, void *buf, long n, vlong)
 
 		qunlock(p);
 		poperror();
-		uartkick(p);		/* desperation */
 		break;
 	case Nctlqid:
 		cmd = malloc(n+1);
@@ -746,6 +745,7 @@ uartclock(void)
 			}
 			iunlock(&p->tlock);
 		}
+		uartkick(p);		/* keep it moving */
 	}
 	iunlock(&uartalloc);
 }

+ 1 - 1
sys/src/9/omap/main.c

@@ -445,7 +445,7 @@ init0(void)
 		panic("init0: nil kbdq");
 	if(serialoq == nil)
 		panic("init0: nil serialoq");
-	normalprint = 0;	/* always use iprint, print to uart is broken */
+	normalprint = 1;
 
 	if(!waserror()){
 		snprint(buf, sizeof(buf), "%s %s", "ARM", conffile);

+ 16 - 15
sys/src/9/omap/screen.c

@@ -23,8 +23,6 @@
 #include "screen.h"
 // #include "gamma.h"
 
-#define MINX 8
-
 enum {
 	Tabstop	= 4,		/* should be 8 */
 	/*
@@ -54,7 +52,7 @@ enum {
 	EnableWakeup	= 1 << 2,
 	Autoidle	= 1 << 0,
 
-	/* dispc pool_freq  */
+	/* dispc pool_freq */
 	Ipc		= 1 << 14,
 	Ihs		= 1 << 13,
 	Ivs		= 1 << 12,
@@ -166,10 +164,14 @@ Cursor	arrow = {
 	},
 };
 
+#ifdef notdef
+#define MINX 8
+
 static struct {
 	Point	pos;
 	int	bwid;
 } out;
+#endif
 
 OScreen oscreen;
 OScreen settings[] = {
@@ -177,7 +179,7 @@ OScreen settings[] = {
 	0, 1024,  768, 60, RGB16,  65000, 159<<20, 23<<8, 135, 29<<20, 3<<8, 6,
 	0, 1280, 1024, 60, RGB16, 108000, 247<<20, 47<<8, 111, 38<<20, 1<<8, 3,
 };
-struct Omap3fb *framebuf;
+Omap3fb *framebuf;
 Memimage *gscreen;
 
 static Memdata xgdata;
@@ -232,8 +234,6 @@ lcdoff(void)
 	/* spin until the frame is complete, but not forever */
 	for(cnt = 50; !(dispc->irqstat1 & 1) && cnt-- > 0; )
 		delay(10);
-	if(cnt <= 0)
-		iprint("screen: lcd never came ready!\n");
 #endif
 	delay(20);			/* worst case for 1 frame, 50Hz */
 }
@@ -316,11 +316,10 @@ lcdinit(void)
 void
 screentest(void)
 {
-	int h = Ht, w = Wid, i, k;
+	int i;
 
-	for (i = 0; i < h; i++)
-		for (k = 0; k < w; k++)
-			framebuf->pixel[i*w + k] = 0x1f;
+	for (i = nelem(framebuf->pixel) - 1; i >= 0; i--)
+		framebuf->pixel[i] = 0x1f;			/* blue */
 //	memset(framebuf->pixel, ~0, sizeof framebuf->pixel);	/* white */
 }
 
@@ -331,7 +330,7 @@ screenpower(int on)
 }
 
 int
-cursoron(int)
+cursoron(int)		// TODO
 {
 	return 0;
 }
@@ -342,7 +341,7 @@ cursoroff(int)
 }
 
 void
-setcursor(Cursor* curs)
+setcursor(Cursor* curs)	// TODO
 {
 //	VGAscr *scr;
 
@@ -371,22 +370,24 @@ screeninit(void)
 	gscreen->r = Rect(0, 0, Wid, Ht);
 	gscreen->clipr = gscreen->r;
 	/* width, in words, of a single scan line */
-	gscreen->width = Wid*(Depth/BI2BY)/BY2WD;
+	gscreen->width = Wid * (Depth / BI2BY) / BY2WD;
 	flushmemscreen(gscreen->r);
 
-	iprint("on: blue for a few seconds...");
+	iprint("on: blue for 2 seconds...");
 	delay(2*1000);
 	iprint("\n");
 
 	memimageinit();
 	memdefont = getmemdefont();
 
+#ifdef notdef
 	out.pos.x = MINX;
 	out.pos.y = 0;
 	out.bwid = memdefont->info[' '].width;
+#endif
 	blanktime = 3;				/* minutes */
 
-	screenwin();
+	screenwin();			/* draw border & top orange bar */
 	screenputs = omapscreenputs;
 	iprint("screen: frame buffer at %#p\n", framebuf);
 }

+ 5 - 5
sys/src/9/omap/screen.h

@@ -1,5 +1,7 @@
 typedef struct Cursor Cursor;
 typedef struct Cursorinfo	Cursorinfo;
+typedef struct OScreen OScreen;
+typedef struct Omap3fb Omap3fb;
 typedef struct Scr	Scr;
 
 struct Cursorinfo
@@ -23,11 +25,12 @@ extern uchar*	attachscreen(Rectangle*, ulong*, int*, int*, int*);
 extern void	blankscreen(int);
 extern void	flushmemscreen(Rectangle);
 
-#define ishwimage(i)	0
+#define ishwimage(i)	0		/* for ../port/devdraw.c */
 
 /* for communication between devdss.c and screen.c */
 
-enum {					/* maxima */
+enum {
+	/* maxima */
 	Wid		= 1280,
 	Ht		= 1024,
 	Depth		= 16,		/* bits per pixel */
@@ -41,9 +44,6 @@ enum {					/* maxima */
 	Pwhite		= 0xFF,
 };
 
-typedef struct OScreen OScreen;
-typedef struct Omap3fb Omap3fb;
-
 struct OScreen {
 	int	open;
 	uint	wid;

+ 5 - 10
sys/src/9/omap/uarti8250.c

@@ -3,9 +3,6 @@
  *
  * we ignore the first 2 uarts on the omap35 (see below) and use the
  * third one but call it 0.
- *
- * TODO: uart output other than from iprint never appears.
- *	are we not getting tx interrupts?
  */
 
 #include "u.h"
@@ -130,7 +127,6 @@ typedef struct Ctlr {
 } Ctlr;
 
 extern PhysUart i8250physuart;
-extern int normalprint;
 
 static Ctlr i8250ctlr[] = {
 {	.io	= (u32int*)PHYSCONS,		/* UART3 in TI terminology */
@@ -481,7 +477,7 @@ i8250kick(Uart* uart)
 	if(/* uart->cts == 0 || */ uart->blocked)
 		return;
 
-	if(!normalprint) {
+	if(!normalprint) {			/* early */
 		if (uart->op < uart->oe)
 			emptyoutstage(uart, uart->oe - uart->op);
 		while ((i = uartstageoutput(uart)) > 0)
@@ -491,7 +487,8 @@ i8250kick(Uart* uart)
 
 	/* nothing more to send? then disable xmit intr */
 	ctlr = uart->regs;
-	if (uart->op >= uart->oe && csr8r(ctlr, Lsr) & Temt) {
+	if (uart->op >= uart->oe && qlen(uart->oq) == 0 &&
+	    csr8r(ctlr, Lsr) & Temt) {
 		ctlr->sticky[Ier] &= ~Ethre;
 		csr8w(ctlr, Ier, 0);
 		return;
@@ -528,7 +525,6 @@ i8250interrupt(Ureg*, void* arg)
 	int iir, lsr, old, r;
 
 	uart = arg;
-
 	ctlr = uart->regs;
 	for(iir = csr8r(ctlr, Iir); !(iir & Ip); iir = csr8r(ctlr, Iir)){
 		switch(iir & IirMASK){
@@ -582,7 +578,7 @@ i8250interrupt(Ureg*, void* arg)
 			break;
 
 		default:
-			iprint("weird uart interrupt %#2.2uX\n", iir);
+			iprint("weird uart interrupt type %#2.2uX\n", iir);
 			break;
 		}
 	}
@@ -665,7 +661,6 @@ i8250enable(Uart* uart, int ie)
 			irqenable(ctlr->irq, i8250interrupt, uart, uart->name);
 			ctlr->iena = 1;
 		}
-//		ctlr->sticky[Ier] = Ethre|Erda;		/* tx intr broken */
 		ctlr->sticky[Ier] = Erda;
 //		ctlr->sticky[Mcr] |= Ie;		/* not on omap */
 		ctlr->sticky[Mcr] = 0;
@@ -816,7 +811,7 @@ i8250console(void)
 		return -1;			/* too early */
 
 	if(uartenable(uart) != nil /* && uart->console */){
-iprint("i8250console: enabling console uart\n");
+		// iprint("i8250console: enabling console uart\n");
 		kbdq = uart->iq;
 		serialoq = uart->oq;
 		uart->putc = kbdcr2nl;

+ 2 - 5
sys/src/9/omap/words

@@ -118,12 +118,9 @@ There are a few rough edges:
 timers are complex, but one could eventually do better (or just let
 timesync compensate).
 
-- Serial console printing is rudimentary and polled.  It looks like
-we're not getting uart transmit interrupts or something similar.
-
-- User processes are limited to 512MB (mainly by the IGEPv2 Ethernet
+- User processes are limited to 512MB virtual (mainly by the IGEPv2 Ethernet
 being at 0x2c000000), which isn't a problem since Beagleboards only
-have 256MB of dram and IGEPv2s have 512MB.
+have 256MB of dram and IGEPv2s have 512MB, and we don't want to swap.
 
 - might use ucalloc.c to allocate uncached scratch space for generated code
 in coproc.c.

+ 19 - 7
sys/src/boot/pc/devbios.c

@@ -135,6 +135,7 @@ biosdiskcall(Ureg *rp, uchar op, ulong bx, ulong dx, ulong si)
 			print("\nbiosdiskcall: int 0x13 op 0x%ux drive 0x%lux "
 				"failed, ah error code 0x%ux\n",
 				op, dx, (uchar)(rp->ax >> 8));
+		biosload = 0;		/* stop trying before we wedge */
 		return -1;
 	}
 	return 0;
@@ -147,7 +148,7 @@ biosdiskcall(Ureg *rp, uchar op, ulong bx, ulong dx, ulong si)
 int
 biosinit(void)
 {
-	int devid, lba, mask, lastbit;
+	int devid, lba, mask, lastbit, ndrive;
 	Devbytes size;
 	char type;
 	Biosdev *bdp;
@@ -158,6 +159,9 @@ biosinit(void)
 		return 0;
 	beenhere = 1;
 
+	ndrive = *(uchar *)KADDR(0x475);
+	if (Debug)
+		print("bios claims %d drive(s)\n", ndrive);
 	mask = lastbit = 0;
 	for (devid = Baseid; devid < (1 << 8) && bdrive.ndevs < Maxdevs;
 	     devid++) {
@@ -190,6 +194,12 @@ biosinit(void)
 	USED(lastbit);
 //	islba(Baseid);	/* do a successful operation to make bios happy again */
 
+	if (Debug && ndrive != bdrive.ndevs)
+		print("bios: ndrive %d != bdrive.ndevs %d\n",
+			ndrive, bdrive.ndevs);
+	if (ndrive < bdrive.ndevs)
+		bdrive.ndevs = ndrive;		/* use smaller estimate */
+
 	/*
 	 * some bioses seem to only be able to read from drive number 0x80
 	 * and certainly can't read from the highest drive number when we
@@ -275,11 +285,13 @@ sectread(Biosdev *bdp, void *a, long n, Devsects offset)
 		/* scribble on the buffer to provoke trouble */
 		memset((uchar *)BIOSXCHG, 'r', bdp->sectsz);
 
-//	if(Debug)
-//		print("drive ready %#ux...", bdp->id);
-//	memset(&regs, 0, sizeof regs);
-//	if (biosdiskcall(&regs, Biosdrvrdy, 0, bdp->id, 0) < 0)
-//		print("not ready\n");
+	if(Debug)
+		print("drive ready %#ux...", bdp->id);
+	memset(&regs, 0, sizeof regs);
+	if (biosdiskcall(&regs, Biosdrvrdy, 0, bdp->id, 0) < 0) {
+		print("not ready\n");
+		return -1;
+	}
 
 	/* space for a big, optical-size sector, just in case... */
 	biosparam = (uchar *)BIOSXCHG + 2*1024;
@@ -425,7 +437,7 @@ biosread(Fs *fs, void *a, long n)
 	Devbytes offset;
 	Biosdev *bdp;
 
-	if(fs->dev > bdrive.ndevs)
+	if(!biosload || fs->dev > bdrive.ndevs)
 		return -1;
 	if (n <= 0)
 		return n;

+ 5 - 2
sys/src/boot/pc/load.c

@@ -370,8 +370,11 @@ main(void)
 	if (!pxe)
 		debug = 0;		/* stop the flood of output */
 	debugload = getconf("*debugload") != nil;
-	/* hack for soekris-like machines */
-	if(!vga || getconf("*nobiosload") != nil)
+	/*
+	 * !vga is a hack for soekris-like machines.
+	 * 9pxeload can't use bios int 13 calls; they wedge the machine.
+	 */
+	if(!vga || pxe || getconf("*nobiosload") != nil)
 		biosload = 0;
 	if((p = getconf("console")) != nil)
 		consinit(p, getconf("baud"));

+ 1 - 1
sys/src/boot/pc/mem.h

@@ -29,7 +29,7 @@
 /*
  * Fundamental addresses
  */
-/* edd 4 draft says BDA is at 40:00 = 0x400 */
+/* edd says BDA (bios data area) is at 40:00 = 0x400 - 0x500 */
 #define IDTADDR		0x80000800		/* idt */
 #define APBOOTSTRAP	0x80001000		/* AP bootstrap code */
 #define CONFADDR	0x80001200		/* info passed from boot loader */

+ 6 - 0
sys/src/cmd/jpg/writegif.c

@@ -192,6 +192,12 @@ getcolormap(void)
 	}
 }
 
+/* imported from libdraw/arith.c to permit an extern log2 function */
+static int log2[] = {
+	-1, 0, 1, -1, 2, -1, -1, -1, 3, -1, -1, -1, -1, -1, -1, -1, 4,
+	-1, -1, -1, -1, -1, -1, -1, 4 /* BUG */, -1, -1, -1, -1, -1, -1, -1, 5
+};
+
 /*
  * Write header, logical screen descriptor, and color map
  */

+ 6 - 0
sys/src/cmd/jpg/writeppm.c

@@ -6,6 +6,12 @@
 
 #define	MAXLINE	70
 
+/* imported from libdraw/arith.c to permit an extern log2 function */
+static int log2[] = {
+	-1, 0, 1, -1, 2, -1, -1, -1, 3, -1, -1, -1, -1, -1, -1, -1, 4,
+	-1, -1, -1, -1, -1, -1, -1, 4 /* BUG */, -1, -1, -1, -1, -1, -1, -1, 5
+};
+
 /*
  * Write data
  */

+ 5 - 0
sys/src/cmd/proof/font.c

@@ -109,6 +109,11 @@ dochar(Rune r[])
 	string(screen, p, display->black, ZP, f, s);
 }
 
+/* imported from libdraw/arith.c to permit an extern log2 function */
+static int log2[] = {
+	-1, 0, 1, -1, 2, -1, -1, -1, 3, -1, -1, -1, -1, -1, -1, -1, 4,
+	-1, -1, -1, -1, -1, -1, -1, 4 /* BUG */, -1, -1, -1, -1, -1, -1, -1, 5
+};
 
 static void
 loadfont(int n, int s)

+ 6 - 0
sys/src/cmd/tweak.c

@@ -377,6 +377,12 @@ drawall(void)
 		drawthing(t, 0);
 }
 
+/* imported from libdraw/arith.c to permit an extern log2 function */
+static int log2[] = {
+	-1, 0, 1, -1, 2, -1, -1, -1, 3, -1, -1, -1, -1, -1, -1, -1, 4,
+	-1, -1, -1, -1, -1, -1, -1, 4 /* BUG */, -1, -1, -1, -1, -1, -1, -1, 5
+};
+
 int
 value(Image *b, int x)
 {

+ 5 - 1
sys/src/libdraw/arith.c

@@ -166,7 +166,11 @@ ulong drawld2chan[] = {
 	CMAP8,
 };
 
-int log2[] = { -1, 0, 1, -1, 2, -1, -1, -1, 3, -1, -1, -1, -1, -1, -1, -1, 4, -1, -1, -1, -1, -1, -1, -1, 4 /* BUG */, -1, -1, -1, -1, -1, -1, -1, 5 };
+/*
+ * was used by libmemlayer/line.c; made static, instead of deleting it,
+ * to avoid updating many binaries on sources.
+ */
+static int log2[] = { -1, 0, 1, -1, 2, -1, -1, -1, 3, -1, -1, -1, -1, -1, -1, -1, 4, -1, -1, -1, -1, -1, -1, -1, 4 /* BUG */, -1, -1, -1, -1, -1, -1, -1, 5 };
 
 ulong
 setalpha(ulong color, uchar alpha)