CSRCS = devlpr.c devtty.c devfd.c devsil.c
CSRCS += devices.c main.c
+DISCSRCS = discard.c
+
ASRCS = crt0.s mtx.s vdp.s floppy.s
ASRCS += tricks.s commonmem.s
+DISCARD_DSRCS = ../dev/devide_discard.c
+DSRCS = ../dev/blkdev.c ../dev/devide.c ../dev/mbr.c
+
AOBJS = $(ASRCS:.s=.rel)
COBJS = $(CSRCS:.c=.rel)
+DISCOBJS = $(DISCSRCS:.c=.rel)
DOBJS = $(patsubst ../dev/%.c,%.rel, $(DSRCS))
+DISCARD_DOBJS = $(patsubst ../dev/%.c,%.rel, $(DISCARD_DSRCS))
-OBJS = $(AOBJS) $(COBJS) $(DOBJS)
+OBJS = $(AOBJS) $(COBJS) $(DOBJS) $(DISCOBJS) $(DISCARD_DOBJS)
CROSS_CCOPTS += -I../dev/
$(DOBJS): %.rel: ../dev/%.c
$(CROSS_CC) $(CROSS_CCOPTS) -c $<
+$(DISCOBJS): %.rel: %.c
+ $(CROSS_CC) $(CROSS_CCOPTS) $(CROSS_CC_SEGDISC) -c $<
+
+$(DISCARD_DOBJS): %.rel: ../dev/%.c
+ $(CROSS_CC) $(CROSS_CCOPTS) $(CROSS_CC_SEGDISC) -c $<
clean:
rm -f $(OBJS) $(JUNK) core *~ fuzix.com
TODO
-- Probe what memory banks are present up to the full 640K that might be present
-- Support for the retro adapters (CF2+ etc)
+IP - Fix the configuration for maximum memory banks
+IP - Autodetect the propeller MTX 80 column card on 0x60/61
+IP - Driver for the propellor 80 column card
+IP - Probe what memory banks are present up to the full 640K that might be present
+IP - Support for the retro adapters (CF2+ etc)
- Autodetect silicon ramdisk
-- Figure out the DPB and how to get images onto the CF for ROM CP/M to run
+DONE - Figure out the DPB and how to get images onto the CF for ROM CP/M to run
- Floppy features support
+DONE - Get more stuff into discard
+DONE - Dynamic buffer assignment
+DONE - Support swap via CF adapter
+- Add hooks for uadmin to support swapon() so we can handle silicon disk nicely
+- Need some kind of hack to reconfigure the CF card as the CFII brokenly turns
+ off write caching and we want it back on.
+DONE - Report graphics capabilities according to card (inc octel modes on
+ 80 col)
+- UDG support on both VDP and Prop
+- Use prop as a slave to vt layer because of awkward prop ctrl codes
The following MTX512 features are supported
-- 6845 based colour text display attributes yet) as /dev/tty1
+- 6845 based colour text display (no attributes yet) as /dev/tty1
- VDP based graphics display (equivalent to MSX1 but on ports 1 and 2) with
interrupts fed into CTC#0 as /dev/tty2. TTY usage is supported.
- Keyboard including F1/F2 to switch tty
A 40 track image will need to be hand built with a few of the less useful
utilities removed.
+
+CFII boots CP/M from ROM it seems
+
+Claimed DPB
+
+.CPMdpb
+DW 26 ;Sectors/track
+DB 5 ;Block shift factor (block size = 4096)
+DB 31 ;Block mask (block size = 4096)
+DB 1 ;Extent mask
+DW 2045 ;Maximum block number - 1
+DW 511 ;Maximum directory entries - 1 (four blocks)
+DB &F0,&00 ;Allocation vectors
+DW 128 ;Check vector ((directory entries+3)/4)
+DW 2 ;Reserved tracks
#define CONFIG_FONT6X8
/* Fixed banking */
#define CONFIG_BANK_FIXED
-/* 10 48K banks, 1 is kernel */
-#define MAX_MAPS 10
+/* 16 48K banks, 1 is kernel */
+#define MAX_MAPS 16
#define MAP_SIZE 0xC000U
-#define CONFIG_LARGE_IO_DIRECT(x) 1
+#define CONFIG_LARGE_IO_DIRECT(x) ((x) != 1)
/* Banks as reported to user space */
#define CONFIG_BANKS 1
#define SWAPBASE 0x0000 /* We swap the lot in one, include the */
#define SWAPTOP 0xC000 /* vectors so its a round number of sectors */
#define MAX_SWAPS 64 /* How many swaps per disc */
-#define SWAPDEV ((8*256) + 0) /* Device for swapping. - first silicon disk */
+#define SWAPDEV (swap_dev) /* Device for swapping. */
+
+extern unsigned int swap_dev;
+
+#define CONFIG_DYNAMIC_SWAP /* Find swap partitions on disks */
#define BOOT_TTY (512 + 1)/* Set this to default device for stdio, stderr */
/* In this case, the default is the first TTY device */
#define TTYDEV BOOT_TTY /* Device used by kernel for messages, panics */
-#define NBUFS 16 /* Number of block buffers */
+/* We will size the buffer pool to fill the space */
+#define CONFIG_DYNAMIC_BUFPOOL
+#define NBUFS 5 /* Number of block buffers */
#define NMOUNTS 4 /* Number of mounts at a time */
/* Terminal definitions */
#define VT_RIGHT vt_tright[curtty]
#define VT_BOTTOM 23
+#define CONFIG_IDE
+#define MAX_BLKDEV 2
+
#define swap_map(x) ((uint8_t *)(x))
-#define platform_discard()
#define platform_copyright()
-#define BOOTDEVICENAMES ",fd#"
+#define BOOTDEVICENAMES "hd#,fd"
; when they are first seen.
.area _CODE
.area _CODE2
+ .area _HOME
.area _CONST
.area _VIDEO
.area _INITIALIZED
.area _BSEG
.area _BSS
.area _HEAP
- ; note that areas below here may be overwritten by the heap at runtime, so
- ; put initialisation stuff in here
+ .area _BUFFERS
+ ; Buffers will overwrite everything up to commonmem
.area _INITIALIZER
.area _GSINIT
.area _GSFINAL
.area _DISCARD
+ ; We load the font into the VDP then it's discardable
.area _FONT
+ ; and the common memory goes top
.area _COMMONMEM
; imported symbols
.globl l__DATA
.globl s__FONT
.globl l__FONT
+ .globl s__BUFFERS
+ .globl l__BUFFERS
.globl s__DISCARD
.globl l__DISCARD
.globl s__COMMONMEM
ld bc, #l__DATA - 1
ld (hl), #0
ldir
+ ; Zero buffers area
+ ld hl, #s__BUFFERS
+ ld de, #s__BUFFERS + 1
+ ld bc, #l__BUFFERS - 1
+ ld (hl), #0
+ ldir
; Hardware setup
call init_hardware
#include <devsys.h>
#include <devlpr.h>
#include <devtty.h>
+#include <blkdev.h>
+#include <devide.h>
struct devsw dev_tab[] = /* The device driver switch table */
{
// minor open close read write ioctl
// -----------------------------------------------------------------
- /* 0: /dev/fd Floppy disc block devices */
+ /* 0: /dev/hd Hard disc block devices (hdx - not supported yet) */
+ { blkdev_open, no_close, blkdev_read, blkdev_write, blkdev_ioctl },
+ /* 1: /dev/fd Floppy disc block devices */
{ fd_open, no_close, fd_read, fd_write, no_ioctl },
- /* 1: /dev/hd Hard disc block devices (hdx - not supported yet) */
- { no_open, no_close, no_rdwr, no_rdwr, no_ioctl },
/* 2: /dev/tty TTY devices */
- { tty_open, mtxtty_close,tty_read, tty_write, vt_ioctl },
+ { tty_open, mtxtty_close,tty_read, tty_write, mtx_vt_ioctl },
/* 3: /dev/lpr Printer devices */
{ lpr_open, lpr_close, no_rdwr, lpr_write, no_ioctl },
/* 4: /dev/mem etc System devices (one offs) */
void device_init(void)
{
-// int i;
-// for (i = 0; i < MAX_SWAPS; i++)
-// swapmap_init(i);
+ devide_init();
}
/*
* Memotech Silicon Disk Driver
*
- * FIXME: would be sensible to add swap support to this driver for boxes with
- * < 512K RAM.
- *
+ * FIXME: add swap support to this driver for boxes with < 512K RAM.
* FIXME: Check presence of device by probing ?
*/
flag;minor;
return sil_transfer(minor, false, rawflag);
}
-
#include <devtty.h>
#include <vt.h>
#include <tty.h>
+#include <graphics.h>
#undef DEBUG /* UNdefine to delete debug code sequences */
__sfr __at 0x09 ctc1;
__sfr __at 0x0A ctc2;
+__sfr __at 0x60 prop_io;
+__sfr __at 0x61 prop_rb;
+
signed char vt_twidth[2] = { 80, 40 };
signed char vt_tright[2] = { 79, 39 };
uint8_t curtty; /* output side */
uint8_t inputtty; /* input side */
static struct vt_switch ttysave[2];
+uint8_t prop80; /* Propeller not a 6845 based 80 column interface */
+
/* FIXME: this will eventually vary by tty so we'll need to either load
it then call the vt ioctl or just intercept the vt ioctl */
uint8_t vtattr_cap;
};
-/* tty1 is the screen tty2 is vdp screen */
+/* tty1 is the 80 column screen tty2 is vdp screen */
/* Output for the system console (kprintf etc) */
void kputchar(uint_fast8_t c)
ttyready_t tty_writeready(uint_fast8_t minor)
{
uint8_t reg = 0xFF;
+ if (minor == 1 && prop80)
+ return prop_io == 255 ? TTY_READY_SOON : TTY_READY_NOW;
if (minor == 3)
reg = serialAc;
if (minor == 4)
{
irqflags_t irq;
+ /* The first tty might be a real 6845 80 column card but it might be
+ a propellor based one which has its own brains and video control */
+ if (minor == 1 && prop80) {
+ prop_io = c;
+ return;
+ }
+
if (minor < 3) {
/* FIXME: this makes our vt handling messy as we have the
IRQ off for the character I/O */
void tty_data_consumed(uint_fast8_t minor)
{
+ used(minor);
/* FIXME:we can now implement flow control stuff */
}
uint16_t cf = t->termios.c_cflag;
uint8_t r;
+ used(flagbits);
+
/* Console */
- if (minor < 2)
+ if (minor <= 2)
return;
if ((cf & CBAUD) < B150) {
/* This is used by the vt asm code, but needs to live in the kernel */
uint16_t cursorpos;
-/* FIXME: need to wrap vt_ioctl so we switch to the right tty before asking
+/* Need to wrap vt_ioctl so we switch to the right tty before asking
the size! */
+
+static struct videomap vdpmap = {
+ 0,
+ 0x01, /* I/O ports at 1 and 2 */
+ 0, 0,
+ 0, 0,
+ 1,
+ MAP_PIO
+};
+
+static struct display mtxdisp[2] = {
+ {
+ 0,
+ 160, 96,
+ 80, 24,
+ 255, 255,
+ FMT_8PIXEL_MTX,
+ HW_UNACCEL,
+ GFX_TEXT,
+ 1,
+ 0
+ },
+ /* VDP: we need to think harder about how we deal with VDP mode
+ setting here and in MSX TODO */
+ {
+ 1,
+ 256, 192,
+ 256, 192,
+ 255, 255,
+ FMT_VDP,
+ HW_VDP_9918A,
+ GFX_MULTIMODE|GFX_MAPPABLE|GFX_TEXT,
+ 16,
+ 0
+ }
+};
+
+/*
+ * TODO: VDP font setting and UDG. Also the same is needed for the prop80
+ * with it's 20x8 programmable characters in weird format.
+ */
+int mtx_vt_ioctl(uint_fast8_t minor, uarg_t request, char *data)
+{
+ if (minor > 2)
+ return tty_ioctl(minor, request, data);
+
+ if (request == GFXIOC_GETINFO)
+ return uput(&mtxdisp[minor - 1], data, sizeof(struct display));
+ if (request == GFXIOC_MAP && minor == 2)
+ return uput(&vdpmap, data, sizeof(struct videomap));
+ if (request == GFXIOC_UNMAP)
+ return 0;
+ if (request == VTSIZE) {
+ if (minor == 1)
+ return (24 << 8) | 80;
+ if (minor == 2)
+ return (24 << 8) | 40;
+ }
+ return vt_ioctl(minor, request, data);
+}
+
+/*
+ * See if our 80 column card is a propellor board or a 6845 based board
+ *
+ * Must be called very early so we drive the right screen!
+ */
+static int prop_wait(void)
+{
+ uint16_t i;
+ for (i = 0; i < 8192; i++) {
+ if (prop_io == 0)
+ return 0;
+ }
+ return 1;
+}
+
+int probe_prop(void)
+{
+ if (prop_wait())
+ return 0;
+ prop_io = 0x1B;
+ prop_io = 0x9C;
+ prop_rb = 0xB4;
+ if (prop_wait() || prop_rb)
+ return 0;
+ prop_io = 0x1B;
+ prop_io = 0x9E;
+ prop_rb = 0xB4;
+ if (prop_wait() || prop_rb != 2)
+ return 0;
+ prop80 = 1;
+ return 1;
+}
extern void kbd_interrupt(void);
extern void tty_interrupt(void);
extern int mtxtty_close(uint_fast8_t);
+extern int mtx_vt_ioctl(uint_fast8_t minor, uarg_t request, char *data);
+
+extern int probe_prop(void);
extern signed char vt_twidth[2];
extern signed char vt_tright[2];
ld (motor_running), a
ret
- .area _COMMONDATA
curdrive:
.db 0xff
motor_running:
platform-mtx/commonmem.rel
platform-mtx/mtx.rel
platform-mtx/main.rel
+platform-mtx/discard.rel
start.rel
version.rel
lowlevel-z80.rel
devsys.rel
platform-mtx/devlpr.rel
platform-mtx/devtty.rel
+platform-mtx/blkdev.rel
+platform-mtx/devide.rel
+platform-mtx/devide_discard.rel
+platform-mtx/mbr.rel
-e
Z80_MMU_HOOKS .equ 0
CONFIG_SWAP .equ 1
+
+NBUFS .equ 5 ; must match config.h
uint16_t ramtop = PROGTOP;
uint16_t vdpport = 0x02 + 256 * 40; /* port and width */
uint8_t membanks;
-
-void pagemap_init(void)
-{
- int i;
- /* Up to ten banks */
- for (i = 0x81; i < 0x80 + membanks; i++)
- pagemap_add(i);
-}
+uint16_t swap_dev = 0xFFFF;
void platform_idle(void)
{
__endasm;
}
-uint8_t platform_param(char *p)
-{
- used(p);
- return 0;
-}
-
void platform_interrupt(void)
{
extern uint8_t irqvector;
timer_interrupt();
}
-/* Nothing to do for the map of init */
-void map_init(void)
+void do_beep(void)
{
}
-void do_beep(void)
+/* This points to the last buffer in the disk buffers. There must be at least
+ four buffers to avoid deadlocks. */
+struct blkbuf *bufpool_end = bufpool + NBUFS;
+
+/*
+ * Blow away the boot time discard area and the font we uploaded to the
+ * VDP.
+ */
+void platform_discard(void)
{
+ uint16_t discard_size = (uint16_t)udata - (uint16_t)bufpool_end;
+ bufptr bp = bufpool_end;
+
+ discard_size /= sizeof(struct blkbuf);
+
+ kprintf("%d buffers added\n", discard_size);
+
+ bufpool_end += discard_size;
+
+ memset( bp, 0, discard_size * sizeof(struct blkbuf) );
+
+ for( bp = bufpool + NBUFS; bp < bufpool_end; ++bp ){
+ bp->bf_dev = NO_DEVICE;
+ bp->bf_busy = BF_FREE;
+ }
}
.globl platform_interrupt_all
.globl map_kernel
+ .globl map_buffers
.globl map_kernel_di
.globl map_process
.globl map_process_di
.globl map_process_always_di
.globl map_save_kernel
.globl map_restore
+ .globl map_for_swap
.globl _int_disabled
.globl vdpinit
.globl vdpload
.globl _vtinit
+ .globl _probe_prop
.globl outcharhex
.globl outhl, outde, outbc
.include "kernel.def"
.include "../kernel-z80.def"
+;
+; Disk buffers
+;
+ .globl _bufpool
+ .area _BUFFERS
+
+_bufpool:
+ .ds BUFSIZE * NBUFS
+
+
; -----------------------------------------------------------------------------
; COMMON MEMORY BANK (0xC000 upwards)
; -----------------------------------------------------------------------------
cp (hl)
jr nz, size_nonram
inc b
- ld a, #0x8B
+ ld a, #0x90
cp b
jr nz, size_next ; All banks done
size_nonram:
init_early:
;
; Bring up the 80 column card early so it can be used for debug
+; Will effectively be a no-op if we then turn out to have a prop
+; based board
;
ld hl, #crtcmap
xor a
ld i, a
im 2 ; set CPU interrupt mode
+ call _probe_prop ; see what 80 colum card we have
call _vtinit ; init the console video
ret
; put the paging back as it was -- we're in kernel mode so this is predictable
map_kernel:
+map_buffers:
map_kernel_di:
push af
ld a, #0x80 ; ROM off bank 0
or l
jr z, map_kernel
ld a, (hl)
+map_for_swap:
map_process_a:
ld (map_copy), a
out (0), a