From c947adf07ce66cb85bd47abe4469f113c5b4e96c Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Sat, 16 Mar 2019 22:13:31 +0000 Subject: [PATCH] atarist: get the timers and console working No device drivers so you can't yet mount a file system --- Kernel/platform-atarist/devtty.c | 50 ++++++++++--------- Kernel/platform-atarist/main.c | 6 +-- Kernel/platform-atarist/p68000.S | 85 +++++++++++++++++++++----------- 3 files changed, 85 insertions(+), 56 deletions(-) diff --git a/Kernel/platform-atarist/devtty.c b/Kernel/platform-atarist/devtty.c index f914e047..e6393e63 100644 --- a/Kernel/platform-atarist/devtty.c +++ b/Kernel/platform-atarist/devtty.c @@ -167,16 +167,17 @@ struct vt_repeat keyrepeat; uint8_t keymap[16]; static uint8_t lastkey; static int keysdown = 0; +static uint8_t capslock; uint8_t keyboard[1][128] = { { 0, KEY_ESC, - '1','2','3','4','5','6','7','8','9', + '1','2','3','4','5','6','7','8','9','0', '-','=', KEY_BS, KEY_TAB, 'q','w','e','r','t','y','u','i','o','p', '[',']',KEY_ENTER, - 0, 'a','s','d','f','g','h','j','k','l',':',';', - 0,'\\','z','x','c','v','b','n','m','.',',','/',0, - 0,0,' ',0, /* caps lock */ + 0, 'a','s','d','f','g','h','j','k','l',';','\'','`', + 0,'\\','z','x','c','v','b','n','m',',','.','/',0, + 0,0,' ',KEY_CAPSLOCK, KEY_F1,KEY_F2,KEY_F3,KEY_F4,KEY_F5,KEY_F6,KEY_F7,KEY_F8,KEY_F9,KEY_F10, 0,0, KEY_HOME,KEY_UP,0,'-',KEY_LEFT,0,KEY_RIGHT,'+',0,KEY_DOWN, @@ -191,16 +192,15 @@ uint8_t keyboard[1][128] = { { '0','.', KEY_ENTER, } }; -/* TODO */ uint8_t shiftkeyboard[1][128] = { { 0, KEY_ESC, - '1','2','3','4','5','6','7','8','9', - '-','=', KEY_BS, KEY_TAB, - 'q','w','e','r','t','y','u','i','o','p', - '[',']',KEY_ENTER, - 0, 'a','s','d','f','g','h','j','k','l',':',';', - 0,'\\','z','x','c','v','b','n','m','.',',','/',0, - 0,0,' ',0/* caps lock */, + '!','@','#','$','%','^','&','*','(',')', + '~','+', KEY_BS, KEY_TAB, + 'Q','W','R','R','T','Y','U','I','O','P', + '{','}',KEY_ENTER, + 0, 'A','S','D','F','G','H','J','L','L',':','"','~', + 0,'|','Z','X','C','V','B','N','M','<','>','?',0, + 0,0,' ',KEY_CAPSLOCK, KEY_F1,KEY_F2,KEY_F3,KEY_F4,KEY_F5,KEY_F6,KEY_F7,KEY_F8,KEY_F9,KEY_F10, 0,0, KEY_HOME,KEY_UP,0,'-',KEY_LEFT,0,KEY_RIGHT,'+',0,KEY_DOWN, @@ -219,19 +219,23 @@ static void keydecode(void) { uint8_t c = lastkey; - if (c == 0 || !keysdown) + if (c == 0x3A) { + capslock ^= 1; return; + } + /* FIXME: wire up input layer */ - if ((keymap[5] & 0x02) || (keymap[6] & 0x40)) /* shifts */ + if ((keymap[5] & 0x04) || (keymap[6] & 0x40)) /* shifts */ c = shiftkeyboard[0][c]; - else if (keymap[7] & 0x02) { /* Caps lock */ + else + c = keyboard[0][c]; + + if (capslock) { /* Caps lock */ if (c >= 'a' && c <= 'z') c -= 32; } - if (keymap[2] & 0x10) /* Control */ + if (keymap[3] & 0x20) /* Control */ c &= 31; - else - c = keyboard[0][c]; /* What should we do with alt (0x38) */ /* FIXME: unicode */ vt_inproc(1, c); @@ -242,7 +246,7 @@ static void keydecode(void) static void keybop(uint8_t c) { - uint8_t i = c >> 3; + uint8_t i = (c & 0x7F) >> 3; uint8_t b = c & 7; uint8_t nonshift = 1; @@ -252,7 +256,7 @@ static void keybop(uint8_t c) if (c & 0x80) { keymap[i] &= ~ (1 << b); keysdown -= nonshift; - if (c == (lastkey | 0x8)) + if (c == (lastkey | 0x80)) lastkey = 0; return; } @@ -260,6 +264,7 @@ static void keybop(uint8_t c) lastkey = c; keysdown += nonshift; /* FIXME: autorepeat */ + /* And remember not to autorepeat capslock! */ if (keysdown && lastkey && keysdown < 3) keydecode(); } @@ -281,9 +286,10 @@ static void ikbd_message(void) ikbd_ct = 0; ikbd_len = 1; keybop(c); - } else + } else { ikbd_len = msg_len[c - 0xF6]; - return; + return; + } } /* A message completed */ ikbd_ct = 0; diff --git a/Kernel/platform-atarist/main.c b/Kernel/platform-atarist/main.c index 9c50cc10..3811848f 100644 --- a/Kernel/platform-atarist/main.c +++ b/Kernel/platform-atarist/main.c @@ -48,6 +48,8 @@ uint32_t screenbase; void pagemap_init(void) { + extern uint8_t _end; + uint32_t e = (uint32_t)&_end; hzticks = *(uint16_t *)0x448 ? 60 : 50; memtop = *(uint32_t *)0x42E; fdseek = *(uint16_t *)0x440; @@ -58,11 +60,7 @@ void pagemap_init(void) kputs("NTSC System\n"); if (cputype) kputs("Not a 68000\n"); - /* FIXME: 512K hackish setup to get going */ /* Linker provided end of kernel */ - extern uint8_t _end; - uint32_t e = (uint32_t)&_end; - kprintf("Kernel end %p\n", e); /* Allocate the rest of memory to the userspace */ kmemaddblk((void *)e, screenbase - e); } diff --git a/Kernel/platform-atarist/p68000.S b/Kernel/platform-atarist/p68000.S index fbfc5af9..9f984efe 100644 --- a/Kernel/platform-atarist/p68000.S +++ b/Kernel/platform-atarist/p68000.S @@ -15,6 +15,7 @@ .globl fontdata_8x8, screenbase .globl uarea_block + .globl acia_debug .mri 1 platform_reboot: platform_monitor: @@ -33,7 +34,7 @@ init_hardware: move.b $FFFA03,d0 btst #7,d0 - beq normal_monitor + bne normal_monitor move.w #0,videomode move.b #50,videorows ; 640x400 is special move.b #49,videobot @@ -87,6 +88,7 @@ mode_ok: move.l #int_mfp12,$130(a0) ; RX Data move.l #int_mfp14,$138(a0) ; RI + jsr vtinit rts palette: @@ -126,35 +128,47 @@ int4: add.w #1,vblankct tst.b vblankw beq int4_out - movem.l a0/a1/d0/d1,-(sp) + movem.l a0/a1/a5/d0/d1,-(sp) + move.l udata_shadow,a5 ; set up the register global pea vblankct bsr wakeup addq #4,sp - movem.l (sp)+,a0/a1/d0/d1 + movem.l (sp)+,a0/a1/a5/d0/d1 int4_out: rte ; ; The level 6 handlers are autovectored ; int_mfp1: ; DCD on the serial - movem.l a0/a1/d0/d1,-(sp) + movem.l a0/a1/a5/d0/d1,-(sp) + move.l udata_shadow,a5 ; set up the register global jsr ser_dcd - movem.l (sp)+,a0/a1/d0/d1 + movem.l (sp)+,a0/a1/a5/d0/d1 rte int_mfp2: ; CTS on the seriall - movem.l a0/a1/d0/d1,-(sp) + movem.l a0/a1/a5/d0/d1,-(sp) + move.l udata_shadow,a5 ; set up the register global jsr ser_cts - movem.l (sp)+,a0/a1/d0/d1 + movem.l (sp)+,a0/a1/a5/d0/d1 rte int_mfp5: ; 200Hz timer - movem.l a0/a1/d0/d1,-(sp) + movem.l a0/a1/a5/d0/d1,-(sp) + move.l udata_shadow,a5 ; set up the register global jsr timer_interrupt - movem.l (sp)+,a0/a1/d0/d1 + bclr.b #5,$fffa11 ; and clear service bit + movem.l (sp)+,a0/a1/a5/d0/d1 rte int_mfp6: ; ACIA interrupts - movem.l a0/a1/d0/d1,-(sp) + movem.l a0/a1/a5/d0/d1,-(sp) + move.l udata_shadow,a5 ; set up the register global +acia_loop: jsr acia_interrupt - movem.l (sp)+,a0/a1/d0/d1 +acia_debug: + lea.l $fffa00,a1 + btst.b #4,$1(a1) ; Still interrupting ? + beq acia_loop + bclr.b #6,$11(a1) ; Clear ACIA in service + movem.l (sp)+,a0/a1/a5/d0/d1 rte int_mfp9: ; MFP serial transmit error ; FIXME what do we need to do to clear down ? @@ -166,18 +180,20 @@ int_mfp11: ; MFP rx error ; FIXME: how to clear rte int_mfp12: ; MFP receive - movem.l a0/a1/d0/d1,-(sp) + movem.l a0/a1/a5/d0/d1,-(sp) move.b $FFFA2D,d0 + move.l udata_shadow,a5 ; set up the register global move.l d0,-(sp) pea.l 2 jsr tty_inproc addq #8,sp - movem.l (sp)+,a0/a1/d0/d1 + movem.l (sp)+,a0/a1/a5/d0/d1 rte int_mfp14: ; MFP ring indicate - movem.l a0/a1/d0/d1,-(sp) + movem.l a0/a1/a5/d0/d1,-(sp) + move.l udata_shadow,a5 ; set up the register global jsr ser_ri - movem.l (sp)+,a0/a1/d0/d1 + movem.l (sp)+,a0/a1/a5/d0/d1 rte ; outchar: Wait for UART TX idle, then print the char in d0 @@ -252,8 +268,7 @@ plotit: plotrow: move.b (a1),(a0) add.w #2,a0 -; FIXME; sort out why this isn't working yet -; dbra d1,plotrow + dbra d1,plotrow add.w d3,a0 ; line length for mode add.w #1,a1 dbra d0,plotit @@ -269,11 +284,11 @@ plotrow: scroll_up: move.l screenbase,a0 move.w #640,d0 - move.w #32000-640-1,d1 + move.w #7840-1,d1 tst.w videomode beq hires move.w #1280,d0 - move.w #32000-1280-1,d1 + move.w #7680-1,d1 hires: move.l a0,a1 add.w d0,a1 @@ -284,11 +299,11 @@ scrollu: move.l (a1)+,(a0)+ scroll_down: move.l screenbase+32000,a0 move.w #640,d0 - move.w #32000-640-1,d1 + move.w #7840-1,d1 tst.w videomode beq hiresd move.w #1280,d0 - move.w #32000-1280-1,d1 + move.w #7680-1,d1 hiresd: move.l a0,a1 sub.w d0,a1 @@ -297,19 +312,24 @@ scrolld: move.l -(a1),-(a0) rts clear_lines: - move.l 4(sp),d0 + move.b 7(sp),d0 move.l d2,-(sp) move.l d3,-(sp) - move.w #0,a1 + moveq #0,d1 bsr vaddr ; d2 is mode count, d3 is extra words/line, a0 is address - move.l 16(sp),d0 + move.b 19(sp),d0 + ext.w d0 + ; d0 is the number of character lines to wipe. We have to do 8 + ; times that for pixels so use vwidth which is 8 x char bytes + ; across + mulu.w vwidth,d0 + lsr.w #1,d0 bra wipen wipe: move.w d2,d1 wipe1: clr.w (a0)+ - dbra d2,wipe1 - add.w d3,a0 + dbra d1,wipe1 wipen: dbra d0,wipe move.l (sp)+,d3 @@ -321,18 +341,18 @@ clear_across: rts cursor_on: - rts move.b 7(sp),d0 ; check stacking move.b 11(sp),d1 move.l d2,-(sp) move.l d3,-(sp) bsr vaddr - moveq #7,d0 lea.l cursordata,a1 movem.l a0/d2/d3,(a1) ; ; Really we need to expand this per mode and to do colour ; +do_xor: + moveq #7,d0 xorit: move.w d2,d1 ; count by mode xorrow: @@ -346,12 +366,15 @@ xorrow: rts cursor_disable: cursor_off: - rts move.l d2,-(sp) move.l d3,-(sp) lea.l cursordata,a1 movem.l (a1),a0/d2/d3 - bra xorit + cmp #0,a0 + bne do_xor + move.l (sp)+,d3 + move.l (sp)+,d2 + rts vtattr_notify: rts @@ -364,6 +387,8 @@ cursordata: word 0 word 0 word 0 word 0 + word 0 + word 0 videorows: byte 0 videobot: -- 2.34.1