From 739158454027d3cc993079a8024fd382b6e1131e Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Tue, 5 Mar 2019 23:03:06 +0000 Subject: [PATCH] zx: tidy tty references --- Kernel/dev/zx/zxkeyboard.c | 1 - Kernel/dev/zx/zxmmc.c | 1 - Kernel/dev/zx/zxtty.c | 158 +++++++++++++++++++++++++++++++++++++ 3 files changed, 158 insertions(+), 2 deletions(-) create mode 100644 Kernel/dev/zx/zxtty.c diff --git a/Kernel/dev/zx/zxkeyboard.c b/Kernel/dev/zx/zxkeyboard.c index 3eb9df0a..c501a866 100644 --- a/Kernel/dev/zx/zxkeyboard.c +++ b/Kernel/dev/zx/zxkeyboard.c @@ -5,7 +5,6 @@ #include #include #include -#include #include #include diff --git a/Kernel/dev/zx/zxmmc.c b/Kernel/dev/zx/zxmmc.c index 0d013619..d9d3756c 100644 --- a/Kernel/dev/zx/zxmmc.c +++ b/Kernel/dev/zx/zxmmc.c @@ -1,7 +1,6 @@ #include #include #include -#include /* FIXME: optimise by unrolling inir and otir 16 ways */ diff --git a/Kernel/dev/zx/zxtty.c b/Kernel/dev/zx/zxtty.c new file mode 100644 index 00000000..278644e3 --- /dev/null +++ b/Kernel/dev/zx/zxtty.c @@ -0,0 +1,158 @@ +/* + * TTY driver for general ZX spectrum style systems + * + * Set CONFIG_GFXBASE if the video is directly mapped + * Set CONFIG_TIMEX if Timex modes are available + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static char tbuf1[TTYSIZ]; + +uint8_t vtattr_cap = VTA_INVERSE|VTA_FLASH|VTA_UNDERLINE; +uint8_t vtborder; +uint8_t curattr = 7; + +static tcflag_t console_mask[4] = { + _ISYS, + _OSYS, + _CSYS, + _LSYS +}; + +tcflag_t *termios_mask[NUM_DEV_TTY + 1] = { + NULL, + console_mask +}; + + +struct s_queue ttyinq[NUM_DEV_TTY + 1] = { /* ttyinq[0] is never used */ + {NULL, NULL, NULL, 0, 0, 0}, + {tbuf1, tbuf1, tbuf1, TTYSIZ, 0, TTYSIZ / 2}, +}; + +/* tty1 is the screen */ + +/* Output for the system console (kprintf etc) */ +void kputchar(char c) +{ + if (c == '\n') + tty_putc(0, '\r'); + tty_putc(0, c); +} + +/* Both console and debug port are always ready */ +ttyready_t tty_writeready(uint8_t minor) +{ + minor; + return TTY_READY_NOW; +} + +void tty_putc(uint8_t minor, unsigned char c) +{ + minor; + vtoutput(&c, 1); +} + +int tty_carrier(uint8_t minor) +{ + minor; + return 1; +} + +void tty_setup(uint8_t minor, uint8_t flags) +{ + minor; +} + +void tty_sleeping(uint8_t minor) +{ + minor; +} + +void tty_data_consumed(uint8_t minor) +{ +} + + +/* This is used by the vt asm code, but needs to live in the kernel */ +uint16_t cursorpos; + +#ifdef CONFIG_GFXBASE + +static struct display specdisplay = { + 0, + 256, 192, + 256, 192, + 0xFF, 0xFF, + FMT_SPECTRUM, + HW_UNACCEL, + GFX_VBLANK|GFX_MAPPABLE|GFX_TEXT, + 0 +}; + +static struct videomap specmap = { + 0, + 0, + CONFIG_GFXBASE, + 6912, + 0, + 0, + 0, + MAP_FBMEM|MAP_FBMEM_SIMPLE +}; + +/* + * Graphics ioctls. Very minimal for this platform. It's a single fixed + * mode with direct memory mapping. + */ +int gfx_ioctl(uint8_t minor, uarg_t arg, char *ptr) +{ + if (minor != 1 || arg >> 8 != 0x03) + return vt_ioctl(minor, arg, ptr); + switch(arg) { + case GFXIOC_GETINFO: + return uput(&specdisplay, ptr, sizeof(struct display)); + case GFXIOC_MAP: + return uput(&specmap, ptr, sizeof(struct videomap)); + case GFXIOC_UNMAP: + return 0; + case GFXIOC_WAITVB: + /* Our system clock is vblank */ + timer_wait++; + psleep(&timer_interrupt); + timer_wait--; + chksigs(); + if (udata.u_cursig) { + udata.u_error = EINTR; + return -1; + } + return 0; + } + return -1; +} +#endif + +void vtattr_notify(void) +{ + /* Attribute byte fixups: not hard as the colours map directly + to the spectrum ones */ + if (vtattr & VTA_INVERSE) + curattr = ((vtink & 7) << 3) | (vtpaper & 7); + else + curattr = (vtink & 7) | ((vtpaper & 7) << 3); + if (vtattr & VTA_FLASH) + curattr |= 0x80; + /* How to map the bright bit - we go by either */ + if ((vtink | vtpaper) & 0x10) + curattr |= 0x40; +} -- 2.34.1