diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2014-07-17 13:14:07 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2014-07-17 13:14:07 +0000 |
commit | e8e3326531da50b7488a70854e4caa055242fd59 (patch) | |
tree | 969420e5b425bf5b099942e24c8a91f1b2d81bd9 /sys/arch | |
parent | 90a89c511e216c51f5cb5e45edd923e49fa0e230 (diff) |
Turn the console code into regular cons_decl() ones, to better fit libsa
getchar/putchar and be able to link again. Crank minor version.
Diffstat (limited to 'sys/arch')
-rw-r--r-- | sys/arch/landisk/stand/boot/conf.c | 10 | ||||
-rw-r--r-- | sys/arch/landisk/stand/boot/devs.c | 5 | ||||
-rw-r--r-- | sys/arch/landisk/stand/boot/libsa.h | 9 | ||||
-rw-r--r-- | sys/arch/landisk/stand/boot/scifcons.c | 90 | ||||
-rw-r--r-- | sys/arch/landisk/stand/boot/srt0.S | 9 |
5 files changed, 58 insertions, 65 deletions
diff --git a/sys/arch/landisk/stand/boot/conf.c b/sys/arch/landisk/stand/boot/conf.c index 2430f706703..e151029685f 100644 --- a/sys/arch/landisk/stand/boot/conf.c +++ b/sys/arch/landisk/stand/boot/conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.c,v 1.7 2013/12/28 02:53:04 deraadt Exp $ */ +/* $OpenBSD: conf.c,v 1.8 2014/07/17 13:14:06 miod Exp $ */ /* * Copyright (c) 2006 Michael Shalayeff @@ -30,7 +30,7 @@ #endif #include <dev/cons.h> -const char version[] = "1.02"; +const char version[] = "1.03"; int debug = 1; struct fs_ops file_system[] = { @@ -51,3 +51,9 @@ struct devsw devsw[] = { { "dk", blkdevstrategy, blkdevopen, blkdevclose, noioctl }, }; int ndevs = nitems(devsw); + +struct consdev constab[] = { + { scif_cnprobe, scif_cninit, scif_cngetc, scif_cnputc }, + { NULL } +}; +struct consdev *cn_tab; diff --git a/sys/arch/landisk/stand/boot/devs.c b/sys/arch/landisk/stand/boot/devs.c index 8180dd106dc..3762e1e830d 100644 --- a/sys/arch/landisk/stand/boot/devs.c +++ b/sys/arch/landisk/stand/boot/devs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: devs.c,v 1.9 2014/07/13 09:26:08 jasper Exp $ */ +/* $OpenBSD: devs.c,v 1.10 2014/07/17 13:14:06 miod Exp $ */ /* * Copyright (c) 2006 Michael Shalayeff @@ -27,8 +27,7 @@ void machdep(void) { tick_init(); - - /* scif_init(9600); */ + cninit(); } int diff --git a/sys/arch/landisk/stand/boot/libsa.h b/sys/arch/landisk/stand/boot/libsa.h index 81a0853d3c8..28efc1c8be7 100644 --- a/sys/arch/landisk/stand/boot/libsa.h +++ b/sys/arch/landisk/stand/boot/libsa.h @@ -1,4 +1,4 @@ -/* $OpenBSD: libsa.h,v 1.6 2014/07/13 09:26:08 jasper Exp $ */ +/* $OpenBSD: libsa.h,v 1.7 2014/07/17 13:14:06 miod Exp $ */ /* * Copyright (c) 2006 Michael Shalayeff @@ -29,8 +29,13 @@ int readsects(int dev, uint32_t lba, void *buf, size_t size); int blkdevopen(struct open_file *, ...); int blkdevclose(struct open_file *); int blkdevstrategy(void *, int, daddr32_t, size_t, void *, size_t *); -void scif_init(unsigned int); int getc(void); void putc(int); void cache_flush(void); void cache_disable(void); + +void scif_cnprobe(struct consdev *); +void scif_cninit(struct consdev *); +int scif_cngetc(dev_t); +void scif_cnputc(dev_t, int); +void scif_init(unsigned int); diff --git a/sys/arch/landisk/stand/boot/scifcons.c b/sys/arch/landisk/stand/boot/scifcons.c index 1baf6d01781..14cde35532d 100644 --- a/sys/arch/landisk/stand/boot/scifcons.c +++ b/sys/arch/landisk/stand/boot/scifcons.c @@ -1,4 +1,4 @@ -/* $OpenBSD: scifcons.c,v 1.5 2014/07/13 09:26:08 jasper Exp $ */ +/* $OpenBSD: scifcons.c,v 1.6 2014/07/17 13:14:06 miod Exp $ */ /* $NetBSD: scifcons.c,v 1.1 2006/09/01 21:26:18 uwe Exp $ */ /* NetBSD: scif.c,v 1.38 2004/12/13 02:14:13 chs Exp */ @@ -92,6 +92,7 @@ */ #include <libsa.h> +#include <dev/cons.h> #include <arch/sh/dev/scifreg.h> @@ -161,13 +162,27 @@ scif_init(unsigned int bps) scif_ssr_write(scif_ssr_read() & SCSSR2_TDFE); /* Clear Status */ } +void +scif_cnprobe(struct consdev *cn) +{ + cn->cn_pri = CN_HIGHPRI; +} + +void +scif_cninit(struct consdev *cn) +{ + scif_init(9600); +} + int -getc(void) +scif_cngetc(dev_t dev) { unsigned char c, err_c; unsigned short err_c2; if (serbuf_read != serbuf_write) { + if (dev & 0x80) + return 1; c = serbuf[serbuf_read]; serbuf_read = (serbuf_read + 1) % SERBUFSIZE; return (c); @@ -175,28 +190,35 @@ getc(void) for (;;) { /* wait for ready */ - while ((scif_fdr_read() & SCFDR2_RECVCNT) == 0) - continue; - - c = scif_frdr_read(); - err_c = scif_ssr_read(); - scif_ssr_write(scif_ssr_read() - & ~(SCSSR2_ER | SCSSR2_BRK | SCSSR2_RDF | SCSSR2_DR)); - - err_c2 = scif_lsr_read(); - scif_lsr_write(scif_lsr_read() & ~SCLSR2_ORER); - - if ((err_c & (SCSSR2_ER | SCSSR2_BRK | SCSSR2_FER - | SCSSR2_PER)) == 0) { - if ((err_c2 & SCLSR2_ORER) == 0) { - return (c); + if ((scif_fdr_read() & SCFDR2_RECVCNT) != 0) { + c = scif_frdr_read(); + err_c = scif_ssr_read(); + scif_ssr_write(scif_ssr_read() & + ~(SCSSR2_ER | SCSSR2_BRK | SCSSR2_RDF | SCSSR2_DR)); + + err_c2 = scif_lsr_read(); + scif_lsr_write(scif_lsr_read() & ~SCLSR2_ORER); + + if ((err_c & (SCSSR2_ER | SCSSR2_BRK | SCSSR2_FER | + SCSSR2_PER)) == 0) { + if ((err_c2 & SCLSR2_ORER) == 0) { + if ((dev & 0x80) == 0) + return (c); + /* stuff char into preread buffer */ + serbuf[serbuf_write] = (u_char)c; + serbuf_write = (serbuf_write + 1) % + SERBUFSIZE; + return (1); + } } } + if (dev & 0x80) + return 0; } } void -putc(int c) +scif_cnputc(dev_t dev, int c) { /* wait for ready */ @@ -209,35 +231,3 @@ putc(int c) /* clear ready flag */ scif_ssr_write(scif_ssr_read() & ~(SCSSR2_TDFE | SCSSR2_TEND)); } - -int -cnischar(void) -{ - unsigned char c, err_c; - unsigned short err_c2; - - /* check if any preread input is already there */ - if (serbuf_read != serbuf_write) - return (1); - - if (scif_fdr_read() & SCFDR2_RECVCNT) { - c = scif_frdr_read(); - err_c = scif_ssr_read(); - scif_ssr_write(scif_ssr_read() - & ~(SCSSR2_ER | SCSSR2_BRK | SCSSR2_RDF | SCSSR2_DR)); - - err_c2 = scif_lsr_read(); - scif_lsr_write(scif_lsr_read() & ~SCLSR2_ORER); - - if ((err_c & (SCSSR2_ER | SCSSR2_BRK | SCSSR2_FER - | SCSSR2_PER)) == 0) { - if ((err_c2 & SCLSR2_ORER) == 0) { - /* stuff char into preread buffer */ - serbuf[serbuf_write] = (u_char)c; - serbuf_write = (serbuf_write + 1) % SERBUFSIZE; - return (1); - } - } - } - return (0); /* nothing out there... */ -} diff --git a/sys/arch/landisk/stand/boot/srt0.S b/sys/arch/landisk/stand/boot/srt0.S index 247513760bc..99a81f6fea2 100644 --- a/sys/arch/landisk/stand/boot/srt0.S +++ b/sys/arch/landisk/stand/boot/srt0.S @@ -1,4 +1,4 @@ -/* $OpenBSD: srt0.S,v 1.3 2006/10/29 14:47:59 drahn Exp $ */ +/* $OpenBSD: srt0.S,v 1.4 2014/07/17 13:14:06 miod Exp $ */ /* $NetBSD: boot.S,v 1.1 2006/09/01 21:26:18 uwe Exp $ */ /*- @@ -113,13 +113,6 @@ ENTRY(raise) rts nop -/* - * - */ -ENTRY(cnset) - rts - nop - /* * int readsects(int dev, uint32_t lba, void *buf, size_t size); */ |