From 6c82fee7ef55af1411b4c71e5a9fa724b2ec0173 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Wed, 25 Apr 2018 14:03:17 +0100 Subject: [PATCH] ubee: lay foundations for graphic mode support --- Kernel/platform-ubee/devices.c | 2 +- Kernel/platform-ubee/devtty.c | 85 +++++++++++++++++++++++++++++++++- Kernel/platform-ubee/devtty.h | 2 + 3 files changed, 87 insertions(+), 2 deletions(-) diff --git a/Kernel/platform-ubee/devices.c b/Kernel/platform-ubee/devices.c index 3b071348..fdc5e7fd 100644 --- a/Kernel/platform-ubee/devices.c +++ b/Kernel/platform-ubee/devices.c @@ -16,7 +16,7 @@ struct devsw dev_tab[] = /* The device driver switch table */ /* 1: /dev/hd Hard disc block devices */ { hd_open, no_close, hd_read, hd_write, no_ioctl }, /* 2: /dev/tty TTY devices */ - { tty_open, tty_close, tty_read, tty_write, tty_ioctl }, + { tty_open, tty_close, tty_read, tty_write, gfx_ioctl }, /* 3: /dev/lpr Printer devices */ { lpr_open, lpr_close, no_rdwr, lpr_write, no_ioctl }, /* 4: /dev/mem etc System devices (one offs) */ diff --git a/Kernel/platform-ubee/devtty.c b/Kernel/platform-ubee/devtty.c index 33ac3e26..e76df755 100644 --- a/Kernel/platform-ubee/devtty.c +++ b/Kernel/platform-ubee/devtty.c @@ -23,6 +23,10 @@ #include #include #include +#include +#include + +static uint8_t vmode; static char tbuf1[TTYSIZ]; @@ -50,7 +54,9 @@ uint8_t tty_writeready(uint8_t minor) void tty_putc(uint8_t minor, unsigned char c) { minor; - vtoutput(&c, 1); + /* FIXME: eventually add support for 64x16 text as well */ + if (vmode == 0) + vtoutput(&c, 1); } void tty_setup(uint8_t minor) @@ -253,3 +259,80 @@ void lpen_kbd_poll(void) tty_inproc(1, k); lpen_kbd_last = 0xFF; } + +static const struct display display[2] = { + /* 80 x 25 */ + { + 0, + 80,25, + 80,25, + 0xFF,0xFF, + FMT_UBEE, + HW_UNACCEL, + GFX_MAPPABLE|GFX_TEXT|GFX_MULTIMODE, + 0, + 0, + }, + { + 1, + 64, 16, + 64, 16, + 0xFF, 0xFF, + FMT_UBEE, + HW_UNACCEL, + GFX_MAPPABLE|GFX_MULTIMODE, /* We need to fix up text yet */ + 0, + 0, + }, + { + 2, + 40, 25, + 40, 25, + 0xFF, 0xFF, + FMT_UBEE, + HW_UNACCEL, + GFX_MAPPABLE|GFX_MULTIMODE, /* We need to fix up text yet */ + 0, + 0, + }, +}; + +static const struct videomap displaymap = { + 0, + 0, + 0x8000, + 0x1000, + 0, 0, + 0, + MAP_FBMEM +}; + + +int gfx_ioctl(uint8_t minor, uarg_t arg, char *ptr) +{ + /* Change this if we add multiple console support */ + if (minor != 1 || (arg >> 8) != 0x03) + return vt_ioctl(minor, arg, ptr); + switch(arg) { + case GFXIOC_GETINFO: + return uput(&display[vmode], ptr, sizeof(struct display)); + case GFXIOC_MAP: + return uput(&displaymap, ptr, sizeof(displaymap)); + case GFXIOC_UNMAP: + return 0; + case GFXIOC_GETMODE: + case GFXIOC_SETMODE: + { + uint8_t m = ugetc(ptr); + if (m > 1 || (m == 2 && ubee_model == UBEE_BASIC)) { + udata.u_error = EINVAL; + return -1; + } + if (arg == GFXIOC_GETMODE) + return uput(&display[m], ptr, sizeof(struct display)); +//TODO vt_modeset(m); + return 0; + } + } + return -1; +} diff --git a/Kernel/platform-ubee/devtty.h b/Kernel/platform-ubee/devtty.h index 3dc30a14..81b6cc7b 100644 --- a/Kernel/platform-ubee/devtty.h +++ b/Kernel/platform-ubee/devtty.h @@ -17,4 +17,6 @@ extern uint8_t vtchar; extern void vwrite(void); extern void do_cursor_on(void); +extern int gfx_ioctl(uint8_t minor, uarg_t arg, char *ptr); + #endif -- 2.34.1