From owner-p4-projects@FreeBSD.ORG Wed Mar 27 20:30:35 2013 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 9267ECC1; Wed, 27 Mar 2013 20:30:35 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 23819CBF for ; Wed, 27 Mar 2013 20:30:35 +0000 (UTC) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: from skunkworks.freebsd.org (skunkworks.freebsd.org [IPv6:2001:1900:2254:2068::682:0]) by mx1.freebsd.org (Postfix) with ESMTP id 1398FE47 for ; Wed, 27 Mar 2013 20:30:35 +0000 (UTC) Received: from skunkworks.freebsd.org ([127.0.1.74]) by skunkworks.freebsd.org (8.14.6/8.14.6) with ESMTP id r2RKUYQw057888 for ; Wed, 27 Mar 2013 20:30:34 GMT (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: (from perforce@localhost) by skunkworks.freebsd.org (8.14.6/8.14.6/Submit) id r2RKUYgv057885 for perforce@freebsd.org; Wed, 27 Mar 2013 20:30:34 GMT (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Date: Wed, 27 Mar 2013 20:30:34 GMT Message-Id: <201303272030.r2RKUYgv057885@skunkworks.freebsd.org> X-Authentication-Warning: skunkworks.freebsd.org: perforce set sender to bb+lists.freebsd.perforce@cyrus.watson.org using -f From: Robert Watson Subject: PERFORCE change 227162 for review To: Perforce Change Reviews Precedence: bulk X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.14 List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 Mar 2013 20:30:35 -0000 http://p4web.freebsd.org/@@227162?ac=10 Change 227162 by rwatson@rwatson_zenith_cl_cam_ac_uk on 2013/03/27 20:29:53 Make the top-end of the BERI-specific code in boot2 look more like the top-end of i386-specific code, so that we get more compatible semantics for serial input. This appears to work and I can now list (and possibly load) kernels driven by keyboard input in simulation. Next stop, hardware. Affected files ... .. //depot/projects/ctsrd/beribsd/src/sys/boot/mips/beri/boot2/altera_jtag_uart.c#3 edit .. //depot/projects/ctsrd/beribsd/src/sys/boot/mips/beri/boot2/boot2.c#6 edit .. //depot/projects/ctsrd/beribsd/src/sys/boot/mips/beri/boot2/cons.h#3 edit Differences ... ==== //depot/projects/ctsrd/beribsd/src/sys/boot/mips/beri/boot2/altera_jtag_uart.c#3 (text+ko) ==== @@ -164,23 +164,21 @@ { register_t stoptime; - stoptime = cp0_count_get() + seconds * 100000000; - while (cp0_count_get() < stoptime) { + stoptime = cp0_count_get() + seconds * 100000000; /* 100 MHz. */ + do { if (uart_readable()) return (1); - } + } while (cp0_count_get() < stoptime); return (0); } int -getc(int seconds) +getc(void) { - if (keyhit(seconds)) { - buffer_valid = 0; - return (buffer_data); - } - return (0); + while (!(uart_readable())); + buffer_valid = 0; + return (buffer_data); } void ==== //depot/projects/ctsrd/beribsd/src/sys/boot/mips/beri/boot2/boot2.c#6 (text+ko) ==== @@ -62,7 +62,7 @@ #define IO_KEYBOARD 1 #define IO_SERIAL 2 -#define SECOND 18 /* Circa that many ticks in a second. */ +#define SECOND 1 /* Circa that many ticks in a second. */ #define RBX_ASKNAME 0x0 /* -a */ #define RBX_SINGLE 0x1 /* -s */ @@ -170,15 +170,8 @@ static int dskread(void *, unsigned, unsigned); static void printf(const char *,...); static void putchar(int); -#if 0 -static int drvread(void *, unsigned, unsigned); -static int keyhit(unsigned); -#endif static int xputc(int); static int xgetc(int); -#if 0 -static inline int getc(int); -#endif #if 0 void memcpy(void *, const void *, int); @@ -631,51 +624,7 @@ xputc(c); } -#if 0 static int -drvread(void *buf, unsigned lba, unsigned nblk) -{ - static unsigned c = 0x2d5c7c2f; - - if (!OPT_CHECK(RBX_QUIET)) - printf("%c\b", c = c << 8 | c >> 24); - v86.ctl = V86_ADDR | V86_CALLF | V86_FLAGS; - v86.addr = XREADORG; /* call to xread in boot1 */ - v86.es = VTOPSEG(buf); - v86.eax = lba; - v86.ebx = VTOPOFF(buf); - v86.ecx = lba >> 16; - v86.edx = nblk << 8 | dsk.drive; - v86int(); - v86.ctl = V86_FLAGS; - if (V86_CY(v86.efl)) { - printf("error %u lba %u\n", v86.eax >> 8 & 0xff, lba); - return -1; - } - return 0; -} - -static int -keyhit(unsigned ticks) -{ - uint32_t t0, t1; - - if (OPT_CHECK(RBX_NOINTR)) - return 0; - t0 = 0; - for (;;) { - if (xgetc(1)) - return 1; - t1 = *(uint32_t *)PTOV(0x46c); - if (!t0) - t0 = t1; - if ((uint32_t)(t1 - t0) >= ticks) - return 0; - } -} -#endif - -static int xputc(int c) { if (ioctrl & IO_KEYBOARD) @@ -693,8 +642,8 @@ if (OPT_CHECK(RBX_NOINTR)) return 0; for (;;) { - if (ioctrl & IO_KEYBOARD && getc(1)) - return fn ? 1 : getc(0); + if (ioctrl & IO_KEYBOARD && keyhit(0)) + return fn ? 1 : getc(); #if 0 if (ioctrl & IO_SERIAL && sio_ischar()) return fn ? 1 : sio_getc(); ==== //depot/projects/ctsrd/beribsd/src/sys/boot/mips/beri/boot2/cons.h#3 (text+ko) ==== @@ -31,7 +31,7 @@ #ifndef _CONS_H_ #define _CONS_H_ -int getc(int); +int getc(void); int keyhit(int); void putc(int);