Date: Wed, 27 Mar 2013 20:30:34 GMT From: Robert Watson <rwatson@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 227162 for review Message-ID: <201303272030.r2RKUYgv057885@skunkworks.freebsd.org>
index | next in thread | raw e-mail
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);help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201303272030.r2RKUYgv057885>
