From: Alan Cox Date: Sat, 9 Feb 2019 21:55:02 +0000 (+0000) Subject: v8080: Various pieces of work to bring us closer to testing X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=1245b75ea23675e4e48df1d1a0668046ed8a0337;p=FUZIX.git v8080: Various pieces of work to bring us closer to testing We now have a disk driver and a serial driver. --- diff --git a/Kernel/platform-v8080/Makefile b/Kernel/platform-v8080/Makefile index 3ffcf46c..445cdd26 100644 --- a/Kernel/platform-v8080/Makefile +++ b/Kernel/platform-v8080/Makefile @@ -1,14 +1,14 @@ LIBPATH=../../Library/libs LIBC=$(LIBPATH)/libc8080.a $(ACK_ROOT)/share/ack/cpm/libem.a -CSRCS += devices.c main.c devtty.c +CSRCS += devices.c main.c devtty.c devfd.c ASRCS = crt0.s commonmem.s v8080.s tricks.s end.s AOBJS = $(ASRCS:.s=.o) COBJS = $(CSRCS:.c=.o) -OBJS = $(AOBJS) $(COBJS) $(DOBJS) $(NOBJS) +OBJS = $(AOBJS) $(COBJS) JUNK = *.o *.lst *.asm *.sym *.rst @@ -21,19 +21,15 @@ $(COBJS): %.o: %.c $(CROSS_CC) $(CROSS_CCOPTS) $< clean: - rm -f $(OBJS) $(JUNK) core *~ + rm -f $(OBJS) $(JUNK) core *~ bootblock.bin bootblock -image: - $(CROSS_LD) -o fuzix.bin crt0.o devices.o main.o \ - commonmem.o tricks.o v8080.o devtty.o \ - ../start.o ../version.o ../lowlevel-8080.o \ - ../bankfixed.o ../timer.o ../kdata.o \ - ../devio.o ../filesys.o ../process.o ../inode.o ../syscall_fs.o \ - ../syscall_proc.o ../syscall_other.o ../mm.o ../swap.o \ - ../tty.o ../devsys.o ../usermem.o ../syscall_fs2.o \ - ../syscall_fs3.o ../syscall_exec16.o \ - ../usermem_std-8080.o $(LIBC) end.o - ack -o fuzix.raw crt0.o devices.o main.o \ +bootblock: + ack -mfuzix -c bootblock.s + $(ACK_ROOT)/lib/ack/em_led -btext:0 -o bootblock.bin -s bootblock.o + aslod bootblock + +image: bootblock + $(CROSS_LD) -b0:0x0100 -b4:0xE800 -o fuzix.bin crt0.o devices.o main.o \ commonmem.o tricks.o v8080.o devtty.o \ ../start.o ../version.o ../lowlevel-8080.o \ ../bankfixed.o ../timer.o ../kdata.o \ @@ -41,4 +37,6 @@ image: ../syscall_proc.o ../syscall_other.o ../mm.o ../swap.o \ ../tty.o ../devsys.o ../usermem.o ../syscall_fs2.o \ ../syscall_fs3.o ../syscall_exec16.o \ - ../usermem_std-8080.o $(LIBC) end.o + ../usermem_std-8080.o devfd.o $(LIBC) end.o + anm fuzix.bin | ../tools/8080map > ../fuzix.map + ../tools/ack2kernel -v fuzix.bin ../fuzix.bin diff --git a/Kernel/platform-v8080/README b/Kernel/platform-v8080/README index 9450d49e..a7835c3e 100644 --- a/Kernel/platform-v8080/README +++ b/Kernel/platform-v8080/README @@ -1,8 +1,16 @@ Some initial development code for 8080 support This is not finished (the block copiers for forking, udata and usermem all -need writing). In addition +need writing). +Drivers +- No disk driver yet +- Minimal serial driver for 88-2 style serial (assumes firmware set the ports up) + and doesn't yet do interrupt + + + +Also to deal with - The C compiler bombs on the adventure game builds - The preprocessor can't handle netd or fforth - We need signal handler code and kernel IRQ code to save memory temporaries diff --git a/Kernel/platform-v8080/commonmem.s b/Kernel/platform-v8080/commonmem.s index 12fa6f00..30bec328 100644 --- a/Kernel/platform-v8080/commonmem.s +++ b/Kernel/platform-v8080/commonmem.s @@ -1,4 +1,5 @@ -# +#include "../kernel-8080.def" + ! ! Common on z80pack is at 0xF000 as defined by hardware. ! diff --git a/Kernel/platform-v8080/crt0.s b/Kernel/platform-v8080/crt0.s index f8fdfef3..39138596 100644 --- a/Kernel/platform-v8080/crt0.s +++ b/Kernel/platform-v8080/crt0.s @@ -1,4 +1,7 @@ +#include "../kernel-8080.def" + .sect .text +.sect .rom .sect .data datastart: .sect .bss diff --git a/Kernel/platform-v8080/devices.c b/Kernel/platform-v8080/devices.c index cd58a3aa..a332399a 100644 --- a/Kernel/platform-v8080/devices.c +++ b/Kernel/platform-v8080/devices.c @@ -4,15 +4,17 @@ #include #include #include +#include + struct devsw dev_tab[] = /* The device driver switch table */ { // minor open close read write ioctl // ----------------------------------------------------------------- - /* 0: /dev/fd Floppy disc block devices */ - { no_open, no_close, no_rdwr, no_rdwr, no_ioctl }, - /* 1: /dev/hd Hard disc block devices (absent) */ - { no_open, no_close, no_rdwr, no_rdwr, no_ioctl }, + /* 0: /dev/hd Hard disc block devices */ + { hd_open, no_close, hd_read, hd_write, no_ioctl }, + /* 1: /dev/fd Floppy disc block devices */ + { fd_open, no_close, fd_read, fd_write, no_ioctl }, /* 2: /dev/tty TTY devices */ { tty_open, tty_close, tty_read, tty_write, tty_ioctl }, /* 3: /dev/lpr Printer devices */ diff --git a/Kernel/platform-v8080/devtty.c b/Kernel/platform-v8080/devtty.c index 0a00c0a6..b448557a 100644 --- a/Kernel/platform-v8080/devtty.c +++ b/Kernel/platform-v8080/devtty.c @@ -40,22 +40,14 @@ int tty_carrier(uint8_t minor) return 1; } -void tty_pollirq(void) -{ -/* while(ASCI_STAT0 & 0x80) - tty_inproc(1, ASCI_RDR0); */ -} - void tty_putc(uint8_t minor, unsigned char c) { switch(minor){ case 1: -/* while(!(ASCI_STAT0 & 2)); - ASCI_TDR0 = c; */ + ttyout(c); break; case 2: -/* while(!(ASCI_STAT1 & 2)); - ASCI_TDR1 = c; */ + ttyout2(c); break; } } @@ -71,8 +63,14 @@ void tty_data_consumed(uint8_t minor) ttyready_t tty_writeready(uint8_t minor) { - minor; - return TTY_READY_NOW; + uint8_t r; + if (minor == 1) + r = ttyready(); + else + r = ttyready2(); + if (r) + return TTY_READY_NOW; + return TTY_READY_SOON; } /* kernel writes to system console -- never sleep! */ diff --git a/Kernel/platform-v8080/end.s b/Kernel/platform-v8080/end.s index a25f6c4c..8b1a2912 100644 --- a/Kernel/platform-v8080/end.s +++ b/Kernel/platform-v8080/end.s @@ -1,3 +1,5 @@ +#include "../kernel-8080.def" + .sect .common .define commonend diff --git a/Kernel/platform-v8080/kernel.def b/Kernel/platform-v8080/kernel.def index 59ab3678..4077bba4 100644 --- a/Kernel/platform-v8080/kernel.def +++ b/Kernel/platform-v8080/kernel.def @@ -1,9 +1,9 @@ ! UZI mnemonics for memory addresses etc -U_DATA = 0xF400 ! (this is struct u_data from kernel.h) +U_DATA = 0xE800 ! (this is struct u_data from kernel.h) U_DATA__TOTALSIZE = 0x200 ! 256+256 bytes. -U_DATA_STASH = 0xEE00 ! EE00-EFFF +U_DATA_STASH = 0xBE00 ! BE00-BFFF PROGBASE = 0x0000 PROGLOAD = 0x0100 diff --git a/Kernel/platform-v8080/tricks.s b/Kernel/platform-v8080/tricks.s index c05301bf..175e702a 100644 --- a/Kernel/platform-v8080/tricks.s +++ b/Kernel/platform-v8080/tricks.s @@ -2,3 +2,85 @@ #include "../kernel-8080.def" #include "../lib/8080fixedbank.s" + +.sect .common +! +! Copy all the user memory from bank a to bank c +! + +bankfork: + lxi d,0x18FE + lxi h,0 + mov b,a + ! We do D loops of E blocks. 8080 hasn't quite got enough + ! registers to do it in one go so we have to push/pop d thus + ! resetting E each cycle +outer: + push d +inner: + ! We do 8 bytes per loop and 254 loops per inner loop, so + ! 24 inner loops per run copies the needed space and a tiny shade + ! over + mov a,b + out 23 + mov d,m + mov a,c + out 23 + mov m,d + inx h + mov a,b + out 23 + mov d,m + mov a,c + out 23 + mov m,d + inx h + mov a,b + out 23 + mov d,m + mov a,c + out 23 + mov m,d + inx h + mov a,b + out 23 + mov d,m + mov a,c + out 23 + mov m,d + inx h + mov a,b + out 23 + mov d,m + mov a,c + out 23 + mov m,d + inx h + mov a,b + out 23 + mov d,m + mov a,c + out 23 + mov m,d + inx h + mov a,b + out 23 + mov d,m + mov a,c + out 23 + mov m,d + inx h + mov a,b + out 23 + mov d,m + mov a,c + out 23 + mov m,d + inx h + dcr e + jnz inner + pop d + dcr d + jnz outer + + ret diff --git a/Kernel/platform-v8080/v8080.s b/Kernel/platform-v8080/v8080.s index 1ca06d54..8b552373 100644 --- a/Kernel/platform-v8080/v8080.s +++ b/Kernel/platform-v8080/v8080.s @@ -12,15 +12,15 @@ _platform_monitor: _platform_reboot: - di - hlt + mvi a,1 + out 29 .define platform_interrupt_all platform_interrupt_all: ret -.sect .code +.sect .text .define init_early @@ -31,13 +31,13 @@ init_early: init_hardware: ! Hack for now - lxi h,256 + lxi h,400 ! 8 * 48K + 16K shld _ramsize - lxi h,192 + lxi h,336 shld _procmem mvi a,1 - out 8 ! Timer on + out 27 ! 100Hz timer on jmp _program_vectors_k @@ -84,7 +84,7 @@ map_kernel: map_kernel_di: push psw xra a - out 0x40 + out 21 pop psw ret @@ -99,7 +99,7 @@ map_process_di: jz map_kernel mov a,m map_process_a: - out 0x40 + out 21 ret .define map_process_always @@ -109,7 +109,7 @@ map_process_always: map_process_always_di: push psw lda U_DATA__U_PAGE - out 0x40 + out 21 pop psw ret @@ -117,10 +117,10 @@ map_process_always_di: map_save_kernel: push psw - in 0x40 + in 21 sta map_save xra a - out 0x40 + out 21 pop psw ret @@ -129,7 +129,7 @@ map_save_kernel: map_restore: push psw lda map_save - out 0x40 + out 21 pop psw ret @@ -137,14 +137,136 @@ map_save: .data1 0 .define outchar +.define _ttyout +! +! MITS 88-2SIO style serial ports at 0 and 40 +! +_ttyout: + pop h + pop d + push d + push h + mov a,e outchar: push psw outcharw: in 0 - rar - jnc outcharw + ani 2 + jz outcharw pop psw - out 0 + out 1 + ret + +.define _ttyout2 + +_ttyout2: + pop h + pop d + push d + push h +outw2: + in 2 + ani 2 + jz outw2 + mov a,e + out 3 + ret + +.define _ttyready +.define _ttyready2 + +_ttyready: + in 0 + ani 2 + mov e,a + ret +_ttyready2: + in 2 + ani 2 + mov e,a ret +.define _tty_pollirq + +_tty_pollirq: + in 0 + rar + jnc poll2 + in 1 + mov e,a + push d + mvi e,1 + push d + call _tty_inproc + pop d + pop d +poll2: + in 40 + rar + rnc + in 41 + mov e,a + push d + mvi e,2 + push d + call _tty_inproc + pop d + pop d + ret + + +.sect .common + +.define _fd_op + +_fd_op: + lxi h,_fd_drive + mov a,m + out 10 ! drive + inx h + mov a,m + out 11 ! track + inx h + mov a,m + out 12 ! sector l + inx h + mov a,m + out 17 ! sector h + inx h + mov a,m + out 15 ! dma l + inx h + mov a,m + out 16 ! dma h + inx h + mov a,m + out 21 ! mapping + inx h + mov a,m + out 13 ! issue + xra a + out 21 ! kernel mapping back + in 14 ! return status + mov e,a + ret + +.define _fd_drive +.define _fd_track +.define _fd_sector +.define _fd_dma +.define _fd_page +.define _fd_cmd + +_fd_drive: + .data1 0 +_fd_track: + .data1 0 +_fd_sector: + .data2 0 +_fd_dma: + .data2 0 +_fd_page: + .data1 0 +_fd_cmd: + .data1 0