This commit is contained in:
waltje
2017-06-03 01:05:47 -04:00
parent d159eb26cb
commit e28bf400f5
2 changed files with 40 additions and 39 deletions

View File

@@ -32,7 +32,7 @@
* Based on an early driver for MINIX 1.5. * Based on an early driver for MINIX 1.5.
* Based on the 86Box PS/2 mouse driver as a framework. * Based on the 86Box PS/2 mouse driver as a framework.
* *
* Version: @(#)mouse_bus.c 1.0.4 2017/05/17 * Version: @(#)mouse_bus.c 1.0.5 2017/06/02
* *
* Author: Fred N. van Kempen, <decwiz@yahoo.com> * Author: Fred N. van Kempen, <decwiz@yahoo.com>
* Copyright 1989-2017 Fred N. van Kempen. * Copyright 1989-2017 Fred N. van Kempen.
@@ -108,7 +108,7 @@ typedef struct {
static void static void
ms_write(mouse_bus_t *ms, uint16_t port, uint8_t val) ms_write(mouse_bus_t *ms, uint16_t port, uint8_t val)
{ {
#if 1 #if 0
pclog("BUSMOUSE: ms_write(%d,%02x)\n", port, val); pclog("BUSMOUSE: ms_write(%d,%02x)\n", port, val);
#endif #endif
@@ -151,7 +151,7 @@ lt_write(mouse_bus_t *ms, uint16_t port, uint8_t val)
{ {
uint8_t b = (ms->r_ctrl ^ val); uint8_t b = (ms->r_ctrl ^ val);
#if 1 #if 0
pclog("BUSMOUSE: lt_write(%d,%02x)\n", port, val); pclog("BUSMOUSE: lt_write(%d,%02x)\n", port, val);
#endif #endif
@@ -248,7 +248,7 @@ ms_read(mouse_bus_t *ms, uint16_t port)
break; break;
} }
#if 1 #if 0
pclog("BUSMOUSE: ms_read(%d): %02x\n", port, r); pclog("BUSMOUSE: ms_read(%d): %02x\n", port, r);
#endif #endif
@@ -367,7 +367,7 @@ lt_read(mouse_bus_t *ms, uint16_t port)
break; break;
} }
#if 1 #if 0
pclog("BUSMOUSE: lt_read(%d): %02x\n", port, r); pclog("BUSMOUSE: lt_read(%d): %02x\n", port, r);
#endif #endif

View File

@@ -33,11 +33,12 @@
* *
* Based on the 86Box serial port driver as a framework. * Based on the 86Box serial port driver as a framework.
* *
* Version: @(#)serial.c 1.0.5 2017/05/17 * Version: @(#)serial.c 1.0.6 2017/06/02
* *
* Author: Fred N. van Kempen, <decwiz@yahoo.com> * Author: Fred N. van Kempen, <decwiz@yahoo.com>
* Copyright 2017 Fred N. van Kempen. * Copyright 2017 Fred N. van Kempen.
*/ */
#include <stdarg.h>
#include "ibm.h" #include "ibm.h"
#include "io.h" #include "io.h"
#include "pic.h" #include "pic.h"
@@ -46,6 +47,11 @@
#include "plat_serial.h" #include "plat_serial.h"
#ifdef WALTJE
# define ENABLE_SERIAL_LOG 2
#endif
enum { enum {
SERINT_LSR = 1, SERINT_LSR = 1,
SERINT_RECEIVE = 2, SERINT_RECEIVE = 2,
@@ -138,21 +144,25 @@ enum {
static SERIAL serial1, /* serial port 1 data */ static SERIAL serial1, /* serial port 1 data */
serial2; /* serial port 2 data */ serial2; /* serial port 2 data */
#if ENABLE_SERIAL_LOG
static int serial_do_log = ENABLE_SERIAL_LOG;
#else
static int serial_do_log = 0;
#endif
int serial_do_log = 0; static void
serial_log(int lvl, const char *fmt, ...)
void serial_log(const char *format, ...)
{ {
#ifdef ENABLE_SERIAL_LOG #ifdef ENABLE_SERIAL_LOG
if (serial_do_log) va_list ap;
{
va_list ap; if (serial_do_log >= lvl) {
va_start(ap, format); va_start(ap, fmt);
vprintf(format, ap); vprintf(fmt, ap);
va_end(ap); va_end(ap);
fflush(stdout); fflush(stdout);
} }
#endif #endif
} }
@@ -256,7 +266,7 @@ serial_write(uint16_t addr, uint8_t val, void *priv)
long speed; long speed;
#if 0 #if 0
serial_log("Serial%d: write(%04x, %02x)\n", sp->port, addr, val); serial_log(2, "Serial%d: write(%04x, %02x)\n", sp->port, addr, val);
#endif #endif
switch (addr & 0x07) { switch (addr & 0x07) {
case 0: /* DATA / DLAB1 */ case 0: /* DATA / DLAB1 */
@@ -305,25 +315,19 @@ serial_write(uint16_t addr, uint8_t val, void *priv)
baud = ((sp->dlab2<<8) | sp->dlab1); baud = ((sp->dlab2<<8) | sp->dlab1);
if (baud > 0) { if (baud > 0) {
speed = 115200UL/baud; speed = 115200UL/baud;
#if 0 serial_log(2, "Serial%d: divisor %u, baudrate %ld\n",
serial_log("Serial%d: divisor %u, baudrate %ld\n",
sp->port, baud, speed); sp->port, baud, speed);
#endif
if ((sp->bh != NULL) && (speed > 0)) if ((sp->bh != NULL) && (speed > 0))
bhtty_speed((BHTTY *)sp->bh, speed); bhtty_speed((BHTTY *)sp->bh, speed);
#if 0
} else { } else {
serial_log("Serial%d: divisor %u invalid!\n", serial_log(1, "Serial%d: divisor %u invalid!\n",
sp->port, baud); sp->port, baud);
#endif
} }
} }
wl = (val & LCR_WLS) + 5; /* databits */ wl = (val & LCR_WLS) + 5; /* databits */
sb = (val & LCR_SBS) ? 2 : 1; /* stopbits */ sb = (val & LCR_SBS) ? 2 : 1; /* stopbits */
pa = (val & (LCR_PE|LCR_EP|LCR_PS)) >> 3; pa = (val & (LCR_PE|LCR_EP|LCR_PS)) >> 3;
#if 0 serial_log(2, "Serial%d: WL=%d SB=%d PA=%d\n", sp->port, wl, sb, pa);
serial_log("Serial%d: WL=%d SB=%d PA=%d\n", sp->port, wl, sb, pa);
#endif
if (sp->bh != NULL) if (sp->bh != NULL)
bhtty_params((BHTTY *)sp->bh, wl, pa, sb); bhtty_params((BHTTY *)sp->bh, wl, pa, sb);
sp->lcr = val; sp->lcr = val;
@@ -339,9 +343,7 @@ serial_write(uint16_t addr, uint8_t val, void *priv)
*/ */
if (sp->rts_callback) { if (sp->rts_callback) {
sp->rts_callback(sp->rts_callback_p); sp->rts_callback(sp->rts_callback_p);
#if 0 serial_log(1, "RTS raised; sending ID\n");
serial_log("RTS raised; sending ID\n");
#endif
} }
} }
@@ -354,9 +356,7 @@ serial_write(uint16_t addr, uint8_t val, void *priv)
timer_add(serial_timer, timer_add(serial_timer,
&sp->receive_delay, &sp->receive_delay,
&sp->receive_delay, sp); &sp->receive_delay, sp);
#if 0 serial_log(1, "Serial%d: RX timer started!\n",sp->port);
serial_log("Serial%d: RX timer started!\n",sp->port);
#endif
} }
} }
sp->mctrl = val; sp->mctrl = val;
@@ -411,9 +411,7 @@ static void
serial_rd_done(void *arg, int num) serial_rd_done(void *arg, int num)
{ {
SERIAL *sp = (SERIAL *)arg; SERIAL *sp = (SERIAL *)arg;
#if 0 serial_log(0, "%04x: %d bytes available: %02x (%c)\n",sp->addr,num,sp->hold,sp->hold);
serial_log("%04x: %d bytes available: %02x (%c)\n",sp->addr,num,sp->hold,sp->hold);
#endif
/* Stuff the byte in the FIFO and set intr. */ /* Stuff the byte in the FIFO and set intr. */
serial_write_fifo(sp, sp->hold); serial_write_fifo(sp, sp->hold);
@@ -507,7 +505,7 @@ serial_setup(int port, uint16_t addr, int irq)
{ {
SERIAL *sp; SERIAL *sp;
serial_log("Serial%d: I/O=%04x, IRQ=%d\n", port, addr, irq); serial_log(0, "Serial%d: I/O=%04x, IRQ=%d\n", port, addr, irq);
/* Grab the desired port block. */ /* Grab the desired port block. */
sp = (port == 2) ? &serial2 : &serial1; sp = (port == 2) ? &serial2 : &serial1;
@@ -575,6 +573,9 @@ serial_init(void)
memset(&serial1, 0x00, sizeof(SERIAL)); memset(&serial1, 0x00, sizeof(SERIAL));
serial1.port = 1; serial1.port = 1;
serial_setup(1, SERIAL1_ADDR, SERIAL1_IRQ); serial_setup(1, SERIAL1_ADDR, SERIAL1_IRQ);
#ifdef WALTJE
serial_link(1, "COM2");
#endif
memset(&serial2, 0x00, sizeof(SERIAL)); memset(&serial2, 0x00, sizeof(SERIAL));
serial2.port = 2; serial2.port = 2;
@@ -611,14 +612,14 @@ serial_link(int port, char *arg)
if (arg != NULL) { if (arg != NULL) {
/* Make sure we're not already linked. */ /* Make sure we're not already linked. */
if (sp->bh != NULL) { if (sp->bh != NULL) {
serial_log("Serial%d already linked!\n", port); serial_log(0, "Serial%d already linked!\n", port);
return(-1); return(-1);
} }
/* Request a port from the host system. */ /* Request a port from the host system. */
bh = bhtty_open(arg, 0); bh = bhtty_open(arg, 0);
if (bh == NULL) { if (bh == NULL) {
serial_log("Serial%d unable to link to '%s' !\n", port, arg); serial_log(0, "Serial%d unable to link to '%s' !\n", port, arg);
return(-1); return(-1);
} }
sp->bh = bh; sp->bh = bh;