More mouse cleanings.

Updated serial API to allow for new UART code.
This commit is contained in:
waltje
2018-04-20 15:10:05 -04:00
parent cb684ddc53
commit 756263d52e
5 changed files with 37 additions and 41 deletions

View File

@@ -49,7 +49,7 @@
* *
* Based on an early driver for MINIX 1.5. * Based on an early driver for MINIX 1.5.
* *
* Version: @(#)mouse_bus.c 1.0.4 2018/04/19 * Version: @(#)mouse_bus.c 1.0.5 2018/04/20
* *
* Author: Fred N. van Kempen, <decwiz@yahoo.com> * Author: Fred N. van Kempen, <decwiz@yahoo.com>
* *
@@ -624,8 +624,10 @@ bm_poll(int x, int y, int z, int b, void *priv)
return(1); return(1);
/* If we are not enabled, return. */ /* If we are not enabled, return. */
if (! (dev->flags & FLAG_ENABLED)) if (! (dev->flags & FLAG_ENABLED)) {
pclog("bm_poll(): Mouse not enabled\n"); pclog("bm_poll(): Mouse not enabled\n");
return(1);
}
#if 0 #if 0
pclog("%s: poll(%d,%d,%d,%02x) %d\n", pclog("%s: poll(%d,%d,%d,%02x) %d\n",
@@ -679,7 +681,7 @@ bm_poll(int x, int y, int z, int b, void *priv)
picint(1 << dev->irq); picint(1 << dev->irq);
} }
return(0); return(1);
} }

View File

@@ -8,7 +8,7 @@
* *
* Implementation of PS/2 series Mouse devices. * Implementation of PS/2 series Mouse devices.
* *
* Version: @(#)mouse_ps2.c 1.0.4 2018/04/19 * Version: @(#)mouse_ps2.c 1.0.5 2018/04/20
* *
* Authors: Fred N. van Kempen, <decwiz@yahoo.com> * Authors: Fred N. van Kempen, <decwiz@yahoo.com>
* Miran Grca, <mgrca8@gmail.com> * Miran Grca, <mgrca8@gmail.com>
@@ -192,11 +192,11 @@ ps2_poll(int x, int y, int z, int b, void *priv)
mouse_t *dev = (mouse_t *)priv; mouse_t *dev = (mouse_t *)priv;
uint8_t buff[3]; uint8_t buff[3];
if (!x && !y && !z && b == dev->b) return(0xff); if (!x && !y && !z && b == dev->b) return(1);
if (! (dev->flags & FLAG_ENABLED)) return(0xff); if (! (dev->flags & FLAG_ENABLED)) return(1);
if (! mouse_scan) return(0xff); if (! mouse_scan) return(1);
dev->x += x; dev->x += x;
dev->y -= y; dev->y -= y;
@@ -238,7 +238,7 @@ ps2_poll(int x, int y, int z, int b, void *priv)
dev->x = dev->y = dev->z = 0; dev->x = dev->y = dev->z = 0;
} }
return(0); return(1);
} }

View File

@@ -10,7 +10,7 @@
* *
* TODO: Add the Genius Serial Mouse. * TODO: Add the Genius Serial Mouse.
* *
* Version: @(#)mouse_serial.c 1.0.4 2018/04/19 * Version: @(#)mouse_serial.c 1.0.6 2018/04/20
* *
* Author: Fred N. van Kempen, <decwiz@yahoo.com> * Author: Fred N. van Kempen, <decwiz@yahoo.com>
* *
@@ -97,6 +97,7 @@ static void
ser_timer(void *priv) ser_timer(void *priv)
{ {
mouse_t *dev = (mouse_t *)priv; mouse_t *dev = (mouse_t *)priv;
uint8_t b[2];
dev->delay = 0LL; dev->delay = 0LL;
@@ -106,27 +107,24 @@ ser_timer(void *priv)
switch(dev->type) { switch(dev->type) {
case MOUSE_MSYSTEMS: case MOUSE_MSYSTEMS:
/* Identifies Mouse Systems serial mouse. */ /* Identifies Mouse Systems serial mouse. */
dev->serial->write_fifo(dev->serial, 'H'); b[0] = 'H';
dev->serial->write_fifo(dev->serial, b, 1);
break; break;
case MOUSE_MICROSOFT: case MOUSE_MICROSOFT:
/* Identifies a Microsoft Serial mouse. */
dev->serial->write_fifo(dev->serial, 'M');
if (dev->flags & FLAG_3BTN)
dev->serial->write_fifo(dev->serial, '3');
break;
case MOUSE_LOGITECH: case MOUSE_LOGITECH:
/* Identifies a Logitech Serial mouse. */ /* Identifies a Microsoft/Logitech Serial mouse. */
dev->serial->write_fifo(dev->serial, 'M'); b[0] = 'M'; b[1] = '3';
if (dev->flags & FLAG_3BTN) if (dev->flags & FLAG_3BTN)
dev->serial->write_fifo(dev->serial, '3'); dev->serial->write_fifo(dev->serial, b, 2);
else
dev->serial->write_fifo(dev->serial, b, 1);
break; break;
case MOUSE_MSWHEEL: case MOUSE_MSWHEEL:
/* Identifies multi-button Microsoft Wheel Mouse. */ /* Identifies multi-button Microsoft Wheel Mouse. */
dev->serial->write_fifo(dev->serial, 'M'); b[0] = 'M'; b[1] = 'Z';
dev->serial->write_fifo(dev->serial, 'Z'); dev->serial->write_fifo(dev->serial, b, 2);
break; break;
default: default:
@@ -196,12 +194,10 @@ ser_poll(int x, int y, int z, int b, void *priv)
} }
/* Send the packet to the bottom-half of the attached port. */ /* Send the packet to the bottom-half of the attached port. */
if (dev->serial != NULL) { if (dev->serial != NULL)
for (b = 0; b < len; b++) dev->serial->write_fifo(dev->serial, buff, len);
dev->serial->write_fifo(dev->serial, buff[b]);
}
return(0); return(1);
} }
@@ -211,10 +207,8 @@ ser_close(void *priv)
mouse_t *dev = (mouse_t *)priv; mouse_t *dev = (mouse_t *)priv;
/* Detach serial port from the mouse. */ /* Detach serial port from the mouse. */
if ((dev != NULL) && (dev->serial != NULL)) { if ((dev != NULL) && (dev->serial != NULL))
dev->serial->rts_callback = NULL; (void)serial_attach(dev->port + 1, NULL, NULL);
dev->serial->rts_callback_p = NULL;
}
free(dev); free(dev);
} }

View File

@@ -8,7 +8,7 @@
* *
* Implementation of 8250-style serial port. * Implementation of 8250-style serial port.
* *
* Version: @(#)serial.c 1.0.2 2018/04/19 * Version: @(#)serial.c 1.0.3 2018/04/20
* *
* Authors: Fred N. van Kempen, <decwiz@yahoo.com> * Authors: Fred N. van Kempen, <decwiz@yahoo.com>
* Miran Grca, <mgrca8@gmail.com> * Miran Grca, <mgrca8@gmail.com>
@@ -117,10 +117,14 @@ clear_fifo(SERIAL *dev)
static void static void
write_fifo(SERIAL *dev, uint8_t dat) write_fifo(SERIAL *dev, uint8_t *ptr, uint8_t len)
{ {
dev->fifo[dev->fifo_write] = dat; while (len-- > 0) {
dev->fifo[dev->fifo_write] = *ptr++;
dev->fifo_write = (dev->fifo_write + 1) & 0xff; dev->fifo_write = (dev->fifo_write + 1) & 0xff;
/*OVERFLOW NOT DETECTED*/
}
if (! (dev->lsr & 1)) { if (! (dev->lsr & 1)) {
dev->lsr |= 1; dev->lsr |= 1;
dev->int_status |= SERIAL_INT_RECEIVE; dev->int_status |= SERIAL_INT_RECEIVE;
@@ -182,7 +186,7 @@ serial_write(uint16_t addr, uint8_t val, void *priv)
dev->int_status |= SERIAL_INT_TRANSMIT; dev->int_status |= SERIAL_INT_TRANSMIT;
update_ints(dev); update_ints(dev);
if (dev->mcr & 0x10) if (dev->mcr & 0x10)
write_fifo(dev, val); write_fifo(dev, &val, 1);
break; break;
case 1: case 1:

View File

@@ -8,7 +8,7 @@
* *
* Definitions for the SERIAL card. * Definitions for the SERIAL card.
* *
* Version: @(#)serial.h 1.0.3 2018/04/19 * Version: @(#)serial.h 1.0.4 2018/04/20
* *
* Author: Fred N. van Kempen, <decwiz@yahoo.com> * Author: Fred N. van Kempen, <decwiz@yahoo.com>
* *
@@ -83,11 +83,7 @@ typedef struct SERIAL {
/* Access to internal functions. */ /* Access to internal functions. */
void (*clear_fifo)(struct SERIAL *); void (*clear_fifo)(struct SERIAL *);
#ifdef WALTJE_SERIAL void (*write_fifo)(struct SERIAL *, uint8_t *, uint8_t);
void (*write_fifo)(struct SERIAL *, uint8_t, int);
#else
void (*write_fifo)(struct SERIAL *, uint8_t);
#endif
/* Data for the RTS-toggle callback. */ /* Data for the RTS-toggle callback. */
void (*rts_callback)(struct SERIAL *, void *); void (*rts_callback)(struct SERIAL *, void *);