summaryrefslogtreecommitdiffstats
path: root/sys/i386/isa
diff options
context:
space:
mode:
Diffstat (limited to 'sys/i386/isa')
-rw-r--r--sys/i386/isa/isa.c18
-rw-r--r--sys/i386/isa/isa_device.h7
-rw-r--r--sys/i386/isa/pcvt/pcvt_drv.c37
-rw-r--r--sys/i386/isa/pcvt/pcvt_hdr.h18
-rw-r--r--sys/i386/isa/pcvt/pcvt_out.c18
-rw-r--r--sys/i386/isa/syscons.c82
-rw-r--r--sys/i386/isa/syscons.h9
7 files changed, 128 insertions, 61 deletions
diff --git a/sys/i386/isa/isa.c b/sys/i386/isa/isa.c
index 1dd0fb9..51dd7f9 100644
--- a/sys/i386/isa/isa.c
+++ b/sys/i386/isa/isa.c
@@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* from: @(#)isa.c 7.2 (Berkeley) 5/13/91
- * $Id: isa.c,v 1.49 1995/05/13 00:09:38 jkh Exp $
+ * $Id: isa.c,v 1.50 1995/05/30 08:02:35 rgrimes Exp $
*/
/*
@@ -910,6 +910,22 @@ isa_strayintr(d)
}
/*
+ * Find the highest priority enabled display device. Since we can't
+ * distinguish display devices from ttys, depend on display devices
+ * being before serial ttys in the table.
+ */
+struct isa_device *
+find_display()
+{
+ struct isa_device *dvp;
+
+ for (dvp = isa_devtab_tty; dvp->id_driver != NULL; dvp++)
+ if (dvp->id_enabled)
+ return (dvp);
+ return (NULL);
+}
+
+/*
* find an ISA device in a given isa_devtab_* table, given
* the table to search, the expected id_driver entry, and the unit number.
*
diff --git a/sys/i386/isa/isa_device.h b/sys/i386/isa/isa_device.h
index 4e3c08c..d201dae 100644
--- a/sys/i386/isa/isa_device.h
+++ b/sys/i386/isa/isa_device.h
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* from: @(#)isa_device.h 7.1 (Berkeley) 5/9/91
- * $Id: isa_device.h,v 1.22 1995/05/11 02:15:55 jkh Exp $
+ * $Id: isa_device.h,v 1.23 1995/05/11 07:41:52 jkh Exp $
*/
#ifndef _I386_ISA_ISA_DEVICE_H_
@@ -134,14 +134,15 @@ inthand_t
IDTVEC(fastintr10), IDTVEC(fastintr11),
IDTVEC(fastintr12), IDTVEC(fastintr13),
IDTVEC(fastintr14), IDTVEC(fastintr15);
-struct isa_device *find_isadev __P((struct isa_device *table,
- struct isa_driver *driverp, int unit));
inthand_t
IDTVEC(intr0), IDTVEC(intr1), IDTVEC(intr2), IDTVEC(intr3),
IDTVEC(intr4), IDTVEC(intr5), IDTVEC(intr6), IDTVEC(intr7),
IDTVEC(intr8), IDTVEC(intr9), IDTVEC(intr10), IDTVEC(intr11),
IDTVEC(intr12), IDTVEC(intr13), IDTVEC(intr14), IDTVEC(intr15);
+struct isa_device *find_display __P((void));
+struct isa_device *find_isadev __P((struct isa_device *table,
+ struct isa_driver *driverp, int unit));
void isa_configure __P((void));
int haveseen_isadev __P((struct isa_device *dvp, u_int checkbits));
void isa_defaultirq __P((void));
diff --git a/sys/i386/isa/pcvt/pcvt_drv.c b/sys/i386/isa/pcvt/pcvt_drv.c
index cdf3073..dc91d47 100644
--- a/sys/i386/isa/pcvt/pcvt_drv.c
+++ b/sys/i386/isa/pcvt/pcvt_drv.c
@@ -105,6 +105,20 @@ static char vt_description[];
#define VT_DESCR_LEN 40
#endif /* PCVT_FREEBSD > 205 */
+static d_open_t pcopen;
+static d_close_t pcclose;
+static d_rdwr_t pcread;
+static d_rdwr_t pcwrite;
+static d_ioctl_t pcioctl;
+static d_ttycv_t pcdevtotty;
+static d_mmap_t pcmmap;
+
+static struct cdevsw pcdevsw = {
+ pcopen, pcclose, pcread, pcwrite,
+ pcioctl, nullstop, noreset, pcdevtotty,
+ ttselect, pcmmap, nostrategy,
+};
+
#if PCVT_NETBSD > 100 /* NetBSD-current Feb 20 1995 */
int
pcprobe(struct device *parent, void *match, void *aux)
@@ -309,6 +323,8 @@ pcattach(struct isa_device *dev)
kdc_vt[dev->id_unit].kdc_state =
pcvt_is_console? DC_IDLE: DC_BUSY;
vt_registerdev(dev, (char *)vga_string(vga_type));
+
+ register_cdev("vt", &pcdevsw);
#endif /* PCVT_FREEBSD > 205 */
#if PCVT_NETBSD > 9
@@ -1086,20 +1102,17 @@ int
#endif
pccnprobe(struct consdev *cp)
{
+ struct isa_device *dvp;
int maj;
- /* locate the major number */
-
- for (maj = 0; maj < nchrdev; maj++)
- {
- if ((u_int)cdevsw[maj].d_open == (u_int)pcopen)
- break;
- }
-
- if (maj == nchrdev)
- {
- /* we are not in cdevsw[], give up */
- panic("pcvt is not in cdevsw[]");
+ /*
+ * Take control if we are the highest priority enabled display device.
+ */
+ dvp = find_display();
+ maj = getmajorbyname("vt");
+ if (dvp->id_driver != &vtdriver || maj < 0) {
+ cp->cn_pri = CN_DEAD;
+ return;
}
/* initialize required fields */
diff --git a/sys/i386/isa/pcvt/pcvt_hdr.h b/sys/i386/isa/pcvt/pcvt_hdr.h
index 7f0ad9e..d84942a 100644
--- a/sys/i386/isa/pcvt/pcvt_hdr.h
+++ b/sys/i386/isa/pcvt/pcvt_hdr.h
@@ -132,7 +132,7 @@
#if PCVT_NETBSD > 9
#include "dev/cons.h"
#elif PCVT_FREEBSD >= 200
-#include <i386/i386/cons.h>
+#include <machine/cons.h>
#else
#include "i386/i386/cons.h"
#endif
@@ -943,7 +943,7 @@ int pcprobe ( struct isa_device *dev );
int pcattach ( struct isa_device *dev );
struct isa_driver vtdriver = { /* driver routines */
- pcprobe, pcattach, "vt",
+ pcprobe, pcattach, "vt", 1,
};
#endif /* PCVT_NETBSD > 9 */
@@ -959,7 +959,8 @@ u_char bgansitopc[] = { /* background ANSI color -> pc */
};
#if !PCVT_NETBSD
-u_short *Crtat = (u_short *)MONO_BUF; /* screen start address */
+/* XXX Crtat is shared with syscons. */
+u_short *Crtat; /* screen start address */
#if !(PCVT_FREEBSD > 110 && PCVT_FREEBSD < 200)
struct tty *pcconsp = &pccons[0]; /* ptr to current device */
#else /* PCVT_FREEBSD > 110 */
@@ -1210,20 +1211,11 @@ extern void bcopyb(void *from, void *to, u_int length);
extern void fillw(U_short value, void *addr, u_int length);
#endif
-int pcopen ( Dev_t dev, int flag, int mode, struct proc *p );
-int pcclose ( Dev_t dev, int flag, int mode, struct proc *p );
-int pcread ( Dev_t dev, struct uio *uio, int flag );
-int pcwrite ( Dev_t dev, struct uio *uio, int flag );
-int pcioctl ( Dev_t dev, int cmd, caddr_t data, int flag, struct proc *p );
-int pcmmap ( Dev_t dev, int offset, int nprot );
-#if PCVT_FREEBSD > 205
-struct tty *pcdevtotty ( Dev_t dev );
-#endif /* PCVT_FREEBSD > 205 */
int pcrint ( void );
int pcparam ( struct tty *tp, struct termios *t );
/*
- * In FreeBSD > 2.0.6, driver console functions are declared in i386/cons.h
+ * In FreeBSD > 2.0.6, driver console functions are declared in machine/cons.h
* and some return void, so don't declare them here.
*/
#if PCVT_FREEBSD <= 205
diff --git a/sys/i386/isa/pcvt/pcvt_out.c b/sys/i386/isa/pcvt/pcvt_out.c
index 945ee24..fc76517 100644
--- a/sys/i386/isa/pcvt/pcvt_out.c
+++ b/sys/i386/isa/pcvt/pcvt_out.c
@@ -892,13 +892,17 @@ sput (u_char *s, U_char kernel, int len, int page)
static void
vt_coldinit(void)
{
- u_short volatile *cp = Crtat + (CGA_BUF-MONO_BUF)/CHR;
+ u_short volatile *cp;
u_short was;
int nscr, charset;
int equipment;
- u_short *SaveCrtat = Crtat;
+ u_short *SaveCrtat;
struct video_state *svsp;
+ Crtat = (u_short *)MONO_BUF; /* XXX assume static relocation works */
+ SaveCrtat = Crtat;
+ cp = Crtat + (CGA_BUF-MONO_BUF)/CHR;
+
do_initialization = 0; /* reset init necessary flag */
/* get the equipment byte from the RTC chip */
@@ -1121,6 +1125,16 @@ vt_coldinit(void)
outb(addr_6845, CRTC_CURSORL);
cursorat |= inb(addr_6845+1);
+ /*
+ * Reject cursors that are more than one row off a
+ * 25-row screen. syscons sets the cursor offset
+ * to 0xffff. The scroll up fixup fails for this
+ * because the assignment to svsp->row overflows
+ * and perhaps for other reasons.
+ */
+ if (cursorat > 25 * svsp->maxcol)
+ cursorat = 25 * svsp->maxcol;
+
svsp->cur_offset = cursorat;
svsp->row = cursorat / svsp->maxcol;
svsp->col = cursorat % svsp->maxcol;
diff --git a/sys/i386/isa/syscons.c b/sys/i386/isa/syscons.c
index 8619dc9..8ab9c9c 100644
--- a/sys/i386/isa/syscons.c
+++ b/sys/i386/isa/syscons.c
@@ -25,7 +25,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $Id: syscons.c,v 1.123 1995/08/08 05:14:40 dyson Exp $
+ * $Id: syscons.c,v 1.124 1995/08/16 22:36:43 nate Exp $
*/
#include "sc.h"
@@ -47,6 +47,7 @@
#include <sys/devconf.h>
#include <machine/clock.h>
+#include <machine/cons.h>
#include <machine/console.h>
#include <machine/psl.h>
#include <machine/frame.h>
@@ -57,7 +58,6 @@
#include <i386/isa/isa_device.h>
#include <i386/isa/timerreg.h>
#include <i386/isa/kbdtables.h>
-#include <i386/i386/cons.h>
#include <i386/isa/syscons.h>
#if !defined(MAXCONS)
@@ -132,7 +132,7 @@ int nsccons = MAXCONS+1;
#endif
#define MONO_BUF pa_to_va(0xB0000)
#define CGA_BUF pa_to_va(0xB8000)
-u_short *Crtat = (u_short *)MONO_BUF;
+u_short *Crtat;
#define WRAPHIST(scp, pointer, offset)\
((scp->history) + ((((pointer) - (scp->history)) + (scp->history_size)\
@@ -142,6 +142,20 @@ struct isa_driver scdriver = {
scprobe, scattach, "sc", 1
};
+static d_open_t scopen;
+static d_close_t scclose;
+static d_rdwr_t scread;
+static d_rdwr_t scwrite;
+static d_ioctl_t scioctl;
+static d_ttycv_t scdevtotty;
+static d_mmap_t scmmap;
+
+static struct cdevsw scdevsw = {
+ scopen, scclose, scread, scwrite,
+ scioctl, nullstop, noreset, scdevtotty,
+ ttselect, scmmap, nostrategy,
+};
+
int
scprobe(struct isa_device *dev)
{
@@ -295,6 +309,9 @@ scattach(struct isa_device *dev)
scp->r_hook.ah_order = APM_MID_ORDER;
apm_hook_establish(APM_HOOK_RESUME , &scp->r_hook);
#endif
+
+ register_cdev("sc", &scdevsw);
+
return 0;
}
@@ -1107,14 +1124,20 @@ scstart(struct tty *tp)
}
void
-pccnprobe(struct consdev *cp)
+sccnprobe(struct consdev *cp)
{
+ struct isa_device *dvp;
int maj;
- /* locate the major number */
- for (maj = 0; maj < nchrdev; maj++)
- if ((void*)cdevsw[maj].d_open == (void*)scopen)
- break;
+ /*
+ * Take control if we are the highest priority enabled display device.
+ */
+ dvp = find_display();
+ maj = getmajorbyname("sc");
+ if (dvp->id_driver != &scdriver || maj < 0) {
+ cp->cn_pri = CN_DEAD;
+ return;
+ }
/* initialize required fields */
cp->cn_dev = makedev(maj, MAXCONS);
@@ -1122,13 +1145,13 @@ pccnprobe(struct consdev *cp)
}
void
-pccninit(struct consdev *cp)
+sccninit(struct consdev *cp)
{
scinit();
}
void
-pccnputc(dev_t dev, int c)
+sccnputc(dev_t dev, int c)
{
u_char buf[1];
scr_stat *scp = console[0];
@@ -1156,7 +1179,7 @@ pccnputc(dev_t dev, int c)
}
int
-pccngetc(dev_t dev)
+sccngetc(dev_t dev)
{
int s = spltty(); /* block scintr while we poll */
int c = scgetc(0);
@@ -1165,7 +1188,7 @@ pccngetc(dev_t dev)
}
int
-pccncheckc(dev_t dev)
+sccncheckc(dev_t dev)
{
return (scgetc(1) & 0xff);
}
@@ -1945,27 +1968,42 @@ outloop:
static void
scinit(void)
{
- u_short volatile *cp = Crtat + (CGA_BUF-MONO_BUF)/sizeof(u_short), was;
- unsigned hw_cursor;
+ u_short volatile *cp;
+ u_short was;
+ unsigned hw_cursor, startaddr;
int i;
if (init_done)
return;
init_done = TRUE;
/*
- * Crtat initialized to point to MONO buffer, if not present change
- * to CGA_BUF offset. ONLY add the difference since locore.s adds
- * in the remapped offset at the "right" time
+ * Finish defaulting crtc variables for a mono screen. Crtat is a
+ * bogus common variable so that it can be shared with pcvt, so it
+ * can't be statically initialized. XXX.
+ */
+ Crtat = (u_short *)MONO_BUF;
+ /*
+ * If CGA memory seems to work, switch to color.
*/
+ cp = (u_short *)CGA_BUF;
was = *cp;
*cp = (u_short) 0xA55A;
- if (*cp != 0xA55A)
- crtc_addr = MONO_BASE;
- else {
- *cp = was;
+ if (*cp == 0xA55A) {
+ Crtat = (u_short *)cp;
crtc_addr = COLOR_BASE;
- Crtat = Crtat + (CGA_BUF-MONO_BUF)/sizeof(u_short);
}
+ *cp = was;
+
+ /*
+ * Ensure a zero start address. This is mainly to recover after
+ * switching from pcvt using userconfig(). The registers are r/o
+ * for old hardware so it's too hard to relocate the active screen
+ * memory.
+ */
+ outb(crtc_addr, 12);
+ outb(crtc_addr + 1, 0);
+ outb(crtc_addr, 13);
+ outb(crtc_addr + 1, 0);
/* extract cursor location */
outb(crtc_addr, 14);
diff --git a/sys/i386/isa/syscons.h b/sys/i386/isa/syscons.h
index b09c57e..e660ba7 100644
--- a/sys/i386/isa/syscons.h
+++ b/sys/i386/isa/syscons.h
@@ -25,7 +25,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
- * $Id: syscons.h,v 1.9 1995/05/30 08:03:15 rgrimes Exp $
+ * $Id: syscons.h,v 1.10 1995/07/11 18:34:30 bde Exp $
*/
#ifndef _I386_ISA_SYSCONS_H_
@@ -168,18 +168,11 @@ typedef struct default_attr {
/* function prototypes */
int scprobe(struct isa_device *dev);
int scattach(struct isa_device *dev);
-int scopen(dev_t dev, int flag, int mode, struct proc *p);
-int scclose(dev_t dev, int flag, int mode, struct proc *p);
-int scread(dev_t dev, struct uio *uio, int flag);
-int scwrite(dev_t dev, struct uio *uio, int flag);
int scparam(struct tty *tp, struct termios *t);
-int scioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p);
void scstart(struct tty *tp);
void scintr(int unit);
-int pcmmap(dev_t dev, int offset, int nprot);
static void scinit(void);
static u_int scgetc(int noblock);
- struct tty *scdevtotty(dev_t dev);
static scr_stat *get_scr_stat(dev_t dev);
static scr_stat *alloc_scp(void);
static void init_scp(scr_stat *scp);
OpenPOWER on IntegriCloud