From ebde253fd5a710fc2a80baae97f3bfa106290097 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Sat, 9 Mar 2019 19:42:31 +0000 Subject: [PATCH] easyz80: Fix up all the IM2 handling and serial stuff --- Kernel/platform-easy-z80/config.h | 5 +- Kernel/platform-easy-z80/crt0.s | 2 + Kernel/platform-easy-z80/devtty.c | 7 +- Kernel/platform-easy-z80/easy-z80.s | 104 ++++++++++++++++------------ 4 files changed, 69 insertions(+), 49 deletions(-) diff --git a/Kernel/platform-easy-z80/config.h b/Kernel/platform-easy-z80/config.h index d830a30b..e4d59878 100644 --- a/Kernel/platform-easy-z80/config.h +++ b/Kernel/platform-easy-z80/config.h @@ -57,9 +57,10 @@ #define PROGBASE 0x0000 /* also data base */ #define PROGLOAD 0x0100 /* also data base */ #define PROGTOP 0xEA00 /* Top of program, base of U_DATA copy */ -/* FIXME: check this... for discard looks wrong */ #define KERNTOP 0xC000 /* Top of kernel (first 3 banks), base of shared bank */ +/* Adjust copy_common if you touch the above */ + //#define SWAPDEV (swap_dev) /* A variable for dynamic, or a device major/minor */ extern unsigned int swap_dev; #define SWAP_SIZE 0x76 /* Program + udata in blocks */ @@ -86,7 +87,7 @@ extern unsigned int swap_dev; #define NBUFS 32 /* Number of block buffers, keep in line with space reserved in zeta-v2.s */ #define NMOUNTS 4 /* Number of mounts at a time */ -#define MAX_BLKDEV 5 /* 1 floppy, 4 IDE */ +#define MAX_BLKDEV 2 /* 2 IDE */ /* On-board DS1302, we can read the time of day from it */ #define CONFIG_RTC diff --git a/Kernel/platform-easy-z80/crt0.s b/Kernel/platform-easy-z80/crt0.s index 820a7345..25f4ad7b 100644 --- a/Kernel/platform-easy-z80/crt0.s +++ b/Kernel/platform-easy-z80/crt0.s @@ -12,6 +12,8 @@ .area _CODE2 .area _CONST .area _INITIALIZED + .area _SERIAL + .area _SERIALDATA .area _DATA .area _BSEG .area _BSS diff --git a/Kernel/platform-easy-z80/devtty.c b/Kernel/platform-easy-z80/devtty.c index 135c340f..11a55463 100644 --- a/Kernel/platform-easy-z80/devtty.c +++ b/Kernel/platform-easy-z80/devtty.c @@ -146,8 +146,6 @@ int tty_carrier(uint8_t minor) return 0; } -typedef uint8_t (*sio_pollfunc_t)(void); - void tty_drain_sio(void) { static uint8_t old_ca[4]; @@ -190,6 +188,10 @@ void tty_drain_sio(void) void tty_putc(uint8_t minor, unsigned char c) { + irqflags_t irqflags; + + irqflags = di(); + switch(minor) { case 1: sioa_txqueue(c); @@ -204,6 +206,7 @@ void tty_putc(uint8_t minor, unsigned char c) siod_txqueue(c); break; } + irqrestore(irqflags); } void tty_sleeping(uint8_t minor) diff --git a/Kernel/platform-easy-z80/easy-z80.s b/Kernel/platform-easy-z80/easy-z80.s index 33a73e80..be4a61bd 100644 --- a/Kernel/platform-easy-z80/easy-z80.s +++ b/Kernel/platform-easy-z80/easy-z80.s @@ -83,47 +83,6 @@ init_hardware: call _program_vectors pop hl - ; IM2 vector for the CTC - ld hl, #spurious - ld (0x80),hl ; CTC vectors - ld (0x82),hl - ld (0x86),hl - ld hl, #interrupt_handler ; Standard tick handler - ld (0x84),hl - - ld hl,#siob_txd - ld (0x90),hl ; SIO B TX empty - ld hl,#siob_status - ld (0x92),hl ; SIO B External status - ld hl,#siob_rx_ring - ld (0x94),hl ; SIO B Receive - ld hl,#siob_special - ld (0x96),hl ; SIO B Special - ld hl,#sioa_txd - ld (0x98),hl ; SIO A TX empty - ld hl,#sioa_status - ld (0x9A),hl ; SIO A External status - ld hl,#sioa_rx_ring - ld (0x9C),hl ; SIO A Received - ld hl,#sioa_special - ld (0x9E),hl ; SIO A Special - - ld hl,#siod_txd - ld (0xA0),hl ; SIO2 B TX empty - ld hl,#siod_status - ld (0xA2),hl ; SIO2 B External status - ld hl,#siod_rx_ring - ld (0xA4),hl ; SIO2 B Receive - ld hl,#siod_special - ld (0xA6),hl ; SIO2 B Special - ld hl,#sioc_txd - ld (0xA8),hl ; SIO2 A TX empty - ld hl,#sioc_status - ld (0xAA),hl ; SIO2 A External status - ld hl,#sioc_rx_ring - ld (0xAC),hl ; SIO2 A Received - ld hl,#sioc_special - ld (0xAE),hl ; SIO2 A Special ; Stop floppy drive motors ld a, #0x0C @@ -280,7 +239,7 @@ sio_setup: .byte 0x04 .byte 0xC4 .byte 0x01 - .byte 0x18 + .byte 0x1F .byte 0x03 .byte 0xE1 .byte 0x05 @@ -357,6 +316,48 @@ _program_vectors: ld hl,#nmi_handler ld (0x0067),hl + ; IM2 vector for the CTC + ld hl, #spurious + ld (0x80),hl ; CTC vectors + ld (0x82),hl + ld (0x86),hl + ld hl, #interrupt_handler ; Standard tick handler + ld (0x84),hl + + ld hl,#siob_txd + ld (0x90),hl ; SIO B TX empty + ld hl,#siob_status + ld (0x92),hl ; SIO B External status + ld hl,#siob_rx_ring + ld (0x94),hl ; SIO B Receive + ld hl,#siob_special + ld (0x96),hl ; SIO B Special + ld hl,#sioa_txd + ld (0x98),hl ; SIO A TX empty + ld hl,#sioa_status + ld (0x9A),hl ; SIO A External status + ld hl,#sioa_rx_ring + ld (0x9C),hl ; SIO A Received + ld hl,#sioa_special + ld (0x9E),hl ; SIO A Special + + ld hl,#siod_txd + ld (0xA0),hl ; SIO2 B TX empty + ld hl,#siod_status + ld (0xA2),hl ; SIO2 B External status + ld hl,#siod_rx_ring + ld (0xA4),hl ; SIO2 B Receive + ld hl,#siod_special + ld (0xA6),hl ; SIO2 B Special + ld hl,#sioc_txd + ld (0xA8),hl ; SIO2 A TX empty + ld hl,#sioc_status + ld (0xAA),hl ; SIO2 A External status + ld hl,#sioc_rx_ring + ld (0xAC),hl ; SIO2 A Received + ld hl,#sioc_special + ld (0xAE),hl ; SIO2 A Special + jr map_kernel ;========================================================================= @@ -506,9 +507,9 @@ _copy_common: push hl ld a,e call map_for_swap - ld hl,#0xD300 - ld de,#0x4300 - ld bc,#0x2D00 + ld hl,#0xEA00 + ld de,#0x2A00 + ld bc,#0x1600 ldir jr map_kernel @@ -590,6 +591,8 @@ inchar_s: ; ;========================================================================= + .area _SERIALDATA + .globl _sio_state .globl _sio_dropdcd .globl _sio_rxl @@ -657,6 +660,17 @@ sio_ports a sio_ports b sio_ports c sio_ports d + + .area _COMMONMEM + +.macro switch + call map_save_kernel +.endm + +.macro switchback + call map_restore +.endm + sio_handler_im2 a, SIOA_C, SIOA_D, reti sio_handler_im2 b, SIOB_C, SIOB_D, reti sio_handler_im2 c, SIOC_C, SIOC_D, reti -- 2.34.1