From: Alan Cox Date: Sun, 6 May 2018 16:21:58 +0000 (+0100) Subject: ubee: commit all the pending stuff X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=3dfcca0828c563150392c77afce73199ffb7aff0;p=FUZIX.git ubee: commit all the pending stuff This should now build out of git and boot --- diff --git a/Kernel/platform-ubee/Makefile b/Kernel/platform-ubee/Makefile index 8dda780a..8939db53 100644 --- a/Kernel/platform-ubee/Makefile +++ b/Kernel/platform-ubee/Makefile @@ -1,20 +1,27 @@ +CROSS_CCOPTS += -I../dev/ + CSRCS = devlpr.c devtty.c devfd.c devhd.c -CSRCS += devices.c main.c vt.c +CSRCS += devices.c main.c vt.c ide.c DISCSRCS = discard.c ASRCS = ubee.s crt0.s ASRCS += tricks.s commonmem.s floppy.s +DISCARD_DSRCS = ../dev/devide_discard.c +DSRCS = ../dev/blkdev.c ../dev/devide.c ../dev/mbr.c + NSRCS = ../dev/net/net_native.c COBJS = $(CSRCS:.c=.rel) AOBJS = $(ASRCS:.s=.rel) NOBJS = $(patsubst ../dev/net/%.c,%.rel, $(NSRCS)) DISCOBJS = $(DISCSRCS:.c=.rel) +DISCARD_DOBJS = $(patsubst ../dev/%.c,%.rel, $(DISCARD_DSRCS)) +DOBJS = $(patsubst ../dev/%.c,%.rel, $(DSRCS)) -OBJS = $(COBJS) $(AOBJS) $(NOBJS) $(DISCOBJS) +OBJS = $(COBJS) $(AOBJS) $(NOBJS) $(DISCOBJS) $(DOBJS) $(DISCARD_DOBJS) JUNK = $(CSRCS:.c=.lst) $(CSRCS:.c=.asm) $(CSRCS:.c=.sym) $(ASRCS:.s=.lst) $(ASRCS:.s=.sym) $(CSRCS:.c=.rst) $(ASRCS:.s=.rst) @@ -26,6 +33,12 @@ $(COBJS): %.rel: %.c $(DISCOBJS): %.rel: %.c $(CROSS_CC) $(CROSS_CCOPTS) $(CROSS_CC_SEGDISC) -c $< +$(DOBJS): %.rel: ../dev/%.c + $(CROSS_CC) $(CROSS_CCOPTS) -c $< + +$(DISCARD_DOBJS): %.rel: ../dev/%.c + $(CROSS_CC) $(CROSS_CCOPTS) $(CROSS_CC_SEGDISC) -c $< + $(NOBJS): %.rel: ../dev/net/%.c $(CROSS_CC) $(CROSS_CCOPTS) -c $< diff --git a/Kernel/platform-ubee/commonmem.s b/Kernel/platform-ubee/commonmem.s new file mode 100644 index 00000000..bafd590b --- /dev/null +++ b/Kernel/platform-ubee/commonmem.s @@ -0,0 +1,10 @@ +; +; We have no real common on the TRS80so just tuck it up at the top of +; memory leaving room for the keyboard and video (3K) +; + .module commonmem + + .area _COMMONMEM + + .include "../cpu-z80/std-commonmem.s" + diff --git a/Kernel/platform-ubee/config.h b/Kernel/platform-ubee/config.h index 773050b9..f87eeaad 100644 --- a/Kernel/platform-ubee/config.h +++ b/Kernel/platform-ubee/config.h @@ -21,6 +21,10 @@ #define CONFIG_NET_NATIVE #define CONFIG_DYNAMIC_BUFPOOL +#define CONFIG_LARGE_IO_DIRECT + +#define MAX_BLKDEV 4 +#define CONFIG_IDE #define CONFIG_BANKS 2 /* 2 x 32K */ diff --git a/Kernel/platform-ubee/devices.c b/Kernel/platform-ubee/devices.c index fdc5e7fd..8f992a6b 100644 --- a/Kernel/platform-ubee/devices.c +++ b/Kernel/platform-ubee/devices.c @@ -41,6 +41,8 @@ void device_init(void) inittod(); /* Figure out what disks we have */ diskprobe(); + /* IDE */ + devide_init(); /* Add 64 swaps (2MB) */ for (i = MAX_SWAPS - 1 ; i >= 0; i--) swapmap_init(i); diff --git a/Kernel/platform-ubee/fuzix.lnk b/Kernel/platform-ubee/fuzix.lnk index b5082680..8a582935 100644 --- a/Kernel/platform-ubee/fuzix.lnk +++ b/Kernel/platform-ubee/fuzix.lnk @@ -42,4 +42,9 @@ devsys.rel platform-ubee/devlpr.rel platform-ubee/devtty.rel platform-ubee/vt.rel +platform-ubee/blkdev.rel +platform-ubee/mbr.rel +platform-ubee/devide.rel +platform-ubee/devide_discard.rel +platform-ubee/ide.rel -e diff --git a/Kernel/platform-ubee/ide.c b/Kernel/platform-ubee/ide.c new file mode 100644 index 00000000..ec2ae871 --- /dev/null +++ b/Kernel/platform-ubee/ide.c @@ -0,0 +1,98 @@ +#include +#include +#include +#include +#include +#include +#include + +__sfr __at 0x70 ide_dsr; + +static uint8_t old_dsr; + +void ide_select(uint8_t drive) +{ + if (drive > 1) + ide_dsr = 0x81; /* Powered on, second interface */ + else + ide_dsr = 0x80; /* Powered on, first interface */ + old_dsr = ide_dsr; +} + +static void devide_delay(void) +{ + timer_t timeout; + + timeout = set_timer_ms(25); + + while(!timer_expired(timeout)) + platform_idle(); +} + +void devide_reset(void) +{ + ide_dsr = 0xC0; /* Reset */ + devide_delay(); + ide_dsr = old_dsr; +} + +void devide_read_data(void) __naked +{ + __asm + ld a, (_blk_op+BLKPARAM_IS_USER_OFFSET) ; blkparam.is_user + ld hl, (_blk_op+BLKPARAM_ADDR_OFFSET) ; blkparam.addr + ld b, #0 ; setup count + ld c, #IDE_REG_DATA ; setup port number +#ifdef SWAPDEV + cp #2 + jr nz, not_swapin + ld a, (_blk_op+BLKPARAM_SWAP_PAGE) ; blkparam.swap_page + call map_for_swap + jr swapin +not_swapin: +#endif + or a ; test is_user + call nz, map_process_always ; map user memory first if required +swapin: + inir ; transfer first 256 bytes + inir ; transfer second 256 bytes + or a ; test is_user + ret z ; done if kernel memory transfer + jp map_kernel ; else map kernel then return + __endasm; +} + +void devide_write_data(void) __naked +{ + __asm + ld a, (_blk_op+BLKPARAM_IS_USER_OFFSET) ; blkparam.is_user + ld hl, (_blk_op+BLKPARAM_ADDR_OFFSET) ; blkparam.addr + ld b, #0 ; setup count + ld c, #IDE_REG_DATA ; setup port number +#ifdef SWAPDEV + cp #2 + jr nz, not_swapout + ld a, (_blk_op+BLKPARAM_SWAP_PAGE) ; blkparam.swap_page + call map_for_swap + jr swapout +not_swapout: +#endif + or a ; test is_user + call nz, map_process_always ; else map user memory first if required +swapout: +outloop: + ; + ; Invert the order for the latches + ; + ld a,(hl) + inc hl + ld e,(hl) + out (c),e + inc hl + out (c),a + djnz outloop + or a ; test is_user + ret z ; done if kernel memory transfer + jp map_kernel ; else map kernel then return + __endasm; +} diff --git a/Kernel/platform-ubee/platform_ide.h b/Kernel/platform-ubee/platform_ide.h new file mode 100644 index 00000000..4dc7ace2 --- /dev/null +++ b/Kernel/platform-ubee/platform_ide.h @@ -0,0 +1,7 @@ +#define IDE_DRIVE_COUNT 4 +#define IDE_REG_CS1_BASE 0x60 +#define IDE_HAS_RESET +#define IDE_NONSTANDARD_XFER + +extern void ide_select(uint8_t drive); +#define ide_deselect() diff --git a/Kernel/platform-ubee/tricks.s b/Kernel/platform-ubee/tricks.s new file mode 100644 index 00000000..ee50c077 --- /dev/null +++ b/Kernel/platform-ubee/tricks.s @@ -0,0 +1,5 @@ + + .include "../kernel.def" + .include "kernel.def" + + .include "../lib/z80fixedbank.s" diff --git a/Kernel/platform-ubee/ubeboot.s b/Kernel/platform-ubee/ubeboot.s new file mode 100644 index 00000000..2f54e249 --- /dev/null +++ b/Kernel/platform-ubee/ubeboot.s @@ -0,0 +1,69 @@ +; +; First go at a Microbee 128 boot sector +; +; The 'bee actually has a rather civilised boot environment with +; several boot ROM helpers available +; + +MONITOR .equ 0xE003 ; jump into monitor +CONOUT .equ 0xE00C ; print character in A +VDUSETUP .equ 0xE01E ; set 64x16 mode +SELDISK .equ 0xE021 ; select disk in drive A +XMXFER .equ 0xE02D ; bank to bank block move + ; HL bytes from D,IX to E,IY +FLASH .equ 0xE033 ; Print string in HL ending 0x80 + ; wait for return +OFFLOAD .equ 0xE039 ; Start at track D sector E + ; load BC bytes into HL + ; Z = OK + +; +; We get loaded at 0x0080 +; +; We are bank 0, block 0, ROM is high. Annoyingly when we turn the +; ROM off bank 0, block 0 ends up the common higher block +; + + .org 0x6F00 +start: ld hl, 0x0080 ; put ourselves somewhere safe + ld de, 0x6F00 ; 6F allows for video when we mirror + ld bc, 128 ; high + ldir + jp sysboot +sysboot: ld sp, sysboot + ld de, 0x0101 ; start at track 1 for data for now + ld iy, 0x0000 ; final destination bank 0,1, 0x0000 + call offload16 ; copy + ld de, 0x020D ; track 2 sector 13 (1 track, 12 + ; sectors for 16K) + ld iy, 0x4000 + call offload16 ; load next 16K, bank 0,1, 0x4000 + ; 32K now loaded, low image done + ld hl, 0x0000 + ld bc, 0x5000 ; load another 20K + ld de, 0x0305 ; track 3 sector 5 (32K in from start) + call OFFLOAD + jr nz, badload + ld a, 4 ; bank 0 both, ROMs off + di ; paranoia + out (0x50), a ; bank 0 is now low and high + jp strap+0x8000 ; jump to our high copy + +offload16: ld hl, 0x4000 + ld bc, 0x4000 + push iy + call OFFLOAD + jr nz, badload + pop iy +xm16: ld hl, 0x4000 + ld ix, 0x4000 + ld de, 0x0001 + jp XMXFER + +strap: inc a + out (0x50), a ; bank 1 now low + jp 0x100 ; enter OS image in bank 0 + +badload: ld hl, fail + call FLASH + jp MONITOR \ No newline at end of file diff --git a/Kernel/platform-ubee/ubee.h b/Kernel/platform-ubee/ubee.h new file mode 100644 index 00000000..a6323685 --- /dev/null +++ b/Kernel/platform-ubee/ubee.h @@ -0,0 +1,15 @@ +#ifndef _UBEE_H +#define _UBEE_H + +extern uint8_t ubee_model; +#define UBEE_BASIC 0 +#define UBEE_PREMIUM 1 +#define UBEE_256TC 2 + +extern void diskprobe(void); +extern uint8_t disk_type[2]; +#define DISK_TYPE_FDC 1 /* Standard FDC */ +#define DISK_TYPE_FDC_D 2 /* Dreamdisc */ +#define DISK_TYPE_HDC 3 /* WD fd/hd controller */ + +#endif diff --git a/Kernel/platform-ubee/ubee.s b/Kernel/platform-ubee/ubee.s index e9892d75..6486b909 100644 --- a/Kernel/platform-ubee/ubee.s +++ b/Kernel/platform-ubee/ubee.s @@ -15,6 +15,7 @@ .globl map_process_always .globl map_save .globl map_restore + .globl map_for_swap .globl platform_interrupt_all .globl _kernel_flag @@ -389,6 +390,7 @@ map_process: jr z, map_kernel map_process_hl: ld a, (hl) +map_for_swap: map_process_a: ; used by bankfork ld (mapreg), a out (0x50), a