+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)
$(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 $<
--- /dev/null
+;
+; 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"
+
#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 */
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);
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
--- /dev/null
+#include <kernel.h>
+#include <kdata.h>
+#include <printf.h>
+#include <stdbool.h>
+#include <timer.h>
+#include <devide.h>
+#include <blkdev.h>
+
+__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;
+}
--- /dev/null
+#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()
--- /dev/null
+
+ .include "../kernel.def"
+ .include "kernel.def"
+
+ .include "../lib/z80fixedbank.s"
--- /dev/null
+;
+; 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
--- /dev/null
+#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
.globl map_process_always
.globl map_save
.globl map_restore
+ .globl map_for_swap
.globl platform_interrupt_all
.globl _kernel_flag
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