From: Alan Cox Date: Thu, 4 Jan 2018 22:18:16 +0000 (+0000) Subject: v65c816: add support for the new kbd/framebuffer code in v65c816 X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=6e6d7bf977050a3d00b8e05afff3d6b95f54b5b2;p=FUZIX.git v65c816: add support for the new kbd/framebuffer code in v65c816 So we can start the console work. --- diff --git a/Kernel/platform-v65c816/Makefile b/Kernel/platform-v65c816/Makefile index 39c60134..aaca518a 100644 --- a/Kernel/platform-v65c816/Makefile +++ b/Kernel/platform-v65c816/Makefile @@ -43,6 +43,6 @@ image: ../syscall_proc.o ../syscall_other.o ../mm.o ../bank65c816.o \ ../tty.o ../devsys.o ../syscall_fs2.o ../syscall_fs3.o \ ../syscall_exec16.o ../usermem.o ../usermem_std-65c816.o devtty.o \ - ../syscall_net.o net_native.o + ../syscall_net.o net_native.o ../vt.o ../font8x8.o dd if=../fuzix.bin of=fuzix.img bs=256 skip=255 count=1 - dd if=../fuzix.bin of=fuzix.img bs=256 seek=1 skip=1 conv=notrunc \ No newline at end of file + dd if=../fuzix.bin of=fuzix.img bs=256 seek=1 skip=1 conv=notrunc diff --git a/Kernel/platform-v65c816/config.h b/Kernel/platform-v65c816/config.h index 266f6ab2..a38f6ecb 100644 --- a/Kernel/platform-v65c816/config.h +++ b/Kernel/platform-v65c816/config.h @@ -17,6 +17,12 @@ #define CONFIG_NET #define CONFIG_NET_NATIVE +#define CONFIG_VT +#define CONFIG_FONT8X8 +#define CONFIG_FONT8X8SMALL /* for now until fix loaders */ +#define VT_RIGHT 79 +#define VT_BOTTOM 24 + /* * We have 512K of RAM and have to allocate it in banks due to the CPU * bank granularity. That gives us 7 processes plus kernel and more @@ -43,10 +49,10 @@ #define CMDLINE NULL /* Location of root dev name */ /* Device parameters */ -#define NUM_DEV_TTY 1 +#define NUM_DEV_TTY 2 #define TTYDEV BOOT_TTY /* Device used by kernel for messages, panics */ -#define NBUFS 8 /* Number of block buffers */ -#define NMOUNTS 4 /* Number of mounts at a time */ +#define NBUFS 7 /* Number of block buffers */ +#define NMOUNTS 3 /* Number of mounts at a time */ #define platform_discard() /* for now - wants fixing */ diff --git a/Kernel/platform-v65c816/devices.c b/Kernel/platform-v65c816/devices.c index 8f2563d7..c6a101f5 100644 --- a/Kernel/platform-v65c816/devices.c +++ b/Kernel/platform-v65c816/devices.c @@ -4,6 +4,7 @@ #include #include #include +#include #include struct devsw dev_tab[] = /* The device driver switch table */ @@ -15,7 +16,7 @@ struct devsw dev_tab[] = /* The device driver switch table */ /* 1: /dev/hd Hard disc block devices (absent) */ { nxio_open, no_close, no_rdwr, no_rdwr, 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, vt_ioctl }, /* 3: /dev/lpr Printer devices */ { no_open, no_close, no_rdwr, no_rdwr, no_ioctl }, /* 4: /dev/mem etc System devices (one offs) */ diff --git a/Kernel/platform-v65c816/devtty.c b/Kernel/platform-v65c816/devtty.c index abc9c33a..6acaeb16 100644 --- a/Kernel/platform-v65c816/devtty.c +++ b/Kernel/platform-v65c816/devtty.c @@ -7,18 +7,66 @@ #include #include +extern void charprint(uint8_t ch); +extern void do_clear_bytes(void); +extern void do_cursor_on(void); + static volatile uint8_t *uart = (volatile uint8_t *)0xFE20; static volatile uint8_t *timer = (volatile uint8_t *)0xFE10; static char tbuf1[TTYSIZ]; +static char tbuf2[TTYSIZ]; PTY_BUFFERS; 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}, + {tbuf2, tbuf2, tbuf2, TTYSIZ, 0, TTYSIZ / 2}, PTY_QUEUES }; +/* VT support logic */ + +uint16_t fb_off; +uint16_t fb_count; + +uint8_t vtattr_cap; + +void vtattr_notify(void) +{ +} + +void clear_across(int8_t y, int8_t x, int16_t ct) +{ + int i; + fb_off = y * 640 + x; + fb_count = ct; + for (i = 0; i < 8; i++) { + do_clear_bytes(); + fb_off += 80; + } +} + +void clear_lines(int8_t y, int8_t ct) +{ + fb_off = y * 640; + fb_count = ct * 640; /* 8 lines of pixels per line */ + do_clear_bytes(); +} + +void plot_char(int8_t y, int8_t x, uint16_t c) +{ + fb_off = y * 640 + x; + charprint(c); + uart[0] = c; +} + +void cursor_on(int8_t y, int8_t x) +{ + fb_off = y * 640 + x; + do_cursor_on(); +} + /* Output for the system console (kprintf etc) */ void kputchar(uint8_t c) { @@ -34,24 +82,23 @@ ttyready_t tty_writeready(uint8_t minor) void tty_putc(uint8_t minor, unsigned char c) { - minor; - uart[0] = c; + if (minor == 2) + uart[0] = c; + else + vtoutput(&c, 1); } void tty_setup(uint8_t minor) { - minor; } void tty_sleeping(uint8_t minor) { - minor; } /* For the moment */ int tty_carrier(uint8_t minor) { - minor; return 1; } @@ -59,10 +106,15 @@ void tty_poll(void) { uint8_t x; + x = uart[3] & 1; + if (x) { + x = uart[2]; + tty_inproc(1, x); + } x = uart[1] & 1; if (x) { x = uart[0]; - tty_inproc(1, x); + tty_inproc(/*2*/1, x); } } diff --git a/Kernel/platform-v65c816/v65.s b/Kernel/platform-v65c816/v65.s index fb407304..f0418bfc 100644 --- a/Kernel/platform-v65c816/v65.s +++ b/Kernel/platform-v65c816/v65.s @@ -18,6 +18,7 @@ .import _procmem .import nmi_handler .import syscall_vector + .import _vtinit .import kstack_top .import istack_switched_sp .import istack_top @@ -122,6 +123,8 @@ init_hardware: sep #$10 .i8 + jsr _vtinit + rts ; ; We did this at early boot when we set up the vectors and copied @@ -218,5 +221,185 @@ hd_wpatch: rts +; +; Frame buffer driver. On entry A is the char +; + .import _fb_off + .import _fontdata_8x8 + .import _fb_count + + .export _charprint + .export _scroll_up + .export _scroll_down + .export _do_clear_bytes + .export _cursor_off + .export _do_cursor_on + +_charprint: + rep #$30 + .a16 + .i16 + and #$ff + asl + asl + asl + tax + + ldy _fb_off + + sep #$20 + .a8 + + phb + lda #$fe + pha + plb + +; +; For a bank 0 kernel or at least font we could maybe instead +; of the tax do phd pha pld and use 0-7 of ZP as the font +; source (saves 16 clocks minus the extra setup costs). Otherwise it +; saves one clock per 1 byte if you can put the font in the same +; bank as the video ram by using AI/X not ALI/X +; + + ; 5 clocks + lda f:KERNEL_FAR+_fontdata_8x8-32*8,x + ; 5 clocks + sta a:0,y + lda f:KERNEL_FAR+_fontdata_8x8-32*8+1,x + sta a:80,y + lda f:KERNEL_FAR+_fontdata_8x8-32*8+2,x + sta a:160,y + lda f:KERNEL_FAR+_fontdata_8x8-32*8+3,x + sta a:240,y + lda f:KERNEL_FAR+_fontdata_8x8-32*8+4,x + sta a:320,y + lda f:KERNEL_FAR+_fontdata_8x8-32*8+5,x + sta a:400,y + lda f:KERNEL_FAR+_fontdata_8x8-32*8+6,x + sta a:480,y + lda f:KERNEL_FAR+_fontdata_8x8-32*8+7,x + sta a:560,y + + plb + + sep #$10 + .i8 + rts + +_scroll_up: + phb + rep #$30 + .a16 + .i16 + ; + ; Do the scroll. For once something we are good at + ; + ldx #640 + ldy #0 + lda #15360-1 ; 192 pixel rows + mvn $FE,$FE + sep #$30 + .a8 + .i8 + plb + rts + +_scroll_down: + phb + rep #$30 + .a16 + .i16 + ldx #16000-1 + ldy #15360-1 + lda #15360-1 + mvp $FE,$FE + sep #$30 + .a8 + .i8 + plb + rts + +; +; We use this both to clear short bursts 8 times (clear across) +; and to clear lines (80 bytes * 8 per row * lines) +; +_do_clear_bytes: + rep #$10 + .i16 + ldx _fb_off + ldy _fb_off + iny + lda #0 + sta f:$FE0000,x + rep #$20 + .a16 + lda _fb_count + phb + mvn $FE,$FE + sep #$30 + .a8 + .i8 + plb + rts + + .a8 + .i8 + +_cursor_off: + rep #$10 + .i16 + ldx cursorpos + bra cursormod + + .a8 + .i8 + +_do_cursor_on: + rep #$10 + .i16 + ldx _fb_off + stx cursorpos +cursormod: + phb + lda #$fe + pha + plb + lda #$ff + eor a:0,x + sta a:0,x + lda #$ff + eor a:80,x + sta a:80,x + lda #$ff + eor a:160,x + sta a:160,x + lda #$ff + eor a:240,x + sta a:240,x + + lda #$ff + eor a:320,x + sta a:320,x + lda #$ff + eor a:400,x + sta a:400,x + lda #$ff + eor a:480,x + sta a:480,x + lda #$ff + eor a:560,x + sta a:560,x + + plb + sep #$10 + .i8 + rts + + .data + +cursorpos: + .word $7FF0 ; off screen bytes to poop on _hd_kmap: .res 1