z80pack-lite: clean up config, use common devfd
authorAlan Cox <alan@etchedpixels.co.uk>
Sun, 23 Nov 2014 00:39:23 +0000 (00:39 +0000)
committerAlan Cox <alan@etchedpixels.co.uk>
Sun, 23 Nov 2014 00:39:23 +0000 (00:39 +0000)
Kernel/platform-z80pack-lite/Makefile
Kernel/platform-z80pack-lite/config.h
Kernel/platform-z80pack-lite/devfd.c [deleted file]
Kernel/platform-z80pack-lite/devfd.h [deleted file]

index 2ce7afd..659ab73 100644 (file)
@@ -1,5 +1,5 @@
 
-CSRCS = devlpr.c devtty.c devfd.c
+CSRCS = devlpr.c devtty.c ../dev/z80pack/devfd.c
 CSRCS += devices.c main.c
 
 ASRCS = crt0.s z80pack.s
@@ -9,6 +9,8 @@ COBJS = $(CSRCS:.c=.rel)
 AOBJS = $(ASRCS:.s=.rel)
 OBJS  = $(COBJS) $(AOBJS)
 
+CROSS_CCOPTS += -I../dev/z80pack/
+
 JUNK = $(CSRCS:.c=.lst) $(CSRCS:.c=.asm) $(CSRCS:.c=.sym) $(ASRCS:.s=.lst) $(ASRCS:.s=.sym) $(CSRCS:.c=.rst) $(ASRCS:.s=.rst)
 
 all:   $(OBJS)
@@ -17,7 +19,7 @@ $(COBJS): %.rel: %.c
        $(CROSS_CC) $(CROSS_CCOPTS) -c $<
 
 $(AOBJS): %.rel: %.s
-       $(SDAS) $(SDASOPTS) $<
+       $(CROSS_AS) $(ASOPTS) $<
 
 clean:
        rm -f $(OBJS) $(JUNK)  core *~ 
index c90b364..0652456 100644 (file)
 /* CP/M emulation */
 #undef CONFIG_CPM_EMU
 
+#define CONFIG_BANKS 1
+
 #define TICKSPERSEC 100   /* Ticks per second */
-#define PROGBASE    ((char *)(0x0000))
-#define PROGLOAD    ((char *)(0x0100))  /* also data base */
-#define PROGTOP     ((char *)(0xF000))  /* Top of program, base of U_DATA copy */
+#define PROGBASE    0x0000
+#define PROGLOAD    0x0100  /* also data base */
+#define PROGTOP     0xF000  /* Top of program, base of U_DATA copy */
 
 #define BOOT_TTY 513      /* Set this to default device for stdio, stderr */
                           /* In this case, the default is the first TTY device */
diff --git a/Kernel/platform-z80pack-lite/devfd.c b/Kernel/platform-z80pack-lite/devfd.c
deleted file mode 100644 (file)
index 03b3fd6..0000000
+++ /dev/null
@@ -1,125 +0,0 @@
-/* 
- * z80pack fd driver
- *
- */
-
-#include <kernel.h>
-#include <kdata.h>
-#include <printf.h>
-#include <devfd.h>
-
-__sfr __at 10 fd_drive;
-__sfr __at 11 fd_track;
-__sfr __at 12 fd_sectorl;
-__sfr __at 13 fd_cmd;
-__sfr __at 14 fd_status;
-__sfr __at 15 fd_dmal;
-__sfr __at 16 fd_dmah;
-__sfr __at 17 fd_sectorh;
-
-/* floppies. 26 128 byte sectors, not a nice way to use all of them in 512's */
-static int sectrack[16] = {
-    26, 26, 26, 26,
-    0, 0, 0, 0,
-    128, 128, 0, 0,
-    0, 0, 0, 0
-};
-
-static int fd_transfer(bool is_read, uint8_t minor, uint8_t rawflag);
-
-int fd_read(uint8_t minor, uint8_t rawflag, uint8_t flag)
-{
-    flag;
-    return fd_transfer(true, minor, rawflag);
-}
-
-int fd_write(uint8_t minor, uint8_t rawflag, uint8_t flag)
-{
-    flag;
-    return fd_transfer(false, minor, rawflag);
-}
-
-/* We will wrap on big disks if we ever try and support the Z80Pack P:
-   that wants different logic */
-static void fd_geom(int minor, blkno_t block)
-{
-    /* Turn block int track/sector 
-       and write to the controller.
-       Forced to do real / and % */
-    int track = block / sectrack[minor];
-    int sector = block % sectrack[minor] + 1;
-    fd_sectorl = sector & 0xFF;
-    fd_sectorh = sector >> 8;
-    fd_track = track;
-}
-
-static int fd_transfer(bool is_read, uint8_t minor, uint8_t rawflag)
-{
-    blkno_t block;
-    uint16_t block_xfer;     /* blocks to transfer */
-    uint16_t dptr;
-    uint16_t dlen;
-    uint16_t ct = 0;
-    uint8_t st;
-    int map = 0;
-    uint16_t *page = &udata.u_page;
-
-    if(rawflag == 1) {
-        dlen = udata.u_count;
-        dptr = (uint16_t)udata.u_base;
-        block = udata.u_offset.o_blkno;
-        block_xfer = dlen >> 7;                /* We want this in 128 byte sectors */
-        map = 1;
-#ifdef SWAPDEV
-    } else if (rawflag == 2) {         /* Swap device special */
-        dlen = swapcnt;
-        dptr = (uint16_t)swapbase;
-        page = &swapproc->p_page;      /* Acting on this task */
-        block = swapblk;
-        block_xfer = dlen >> 7;                /* We want this in 128 byte sectors */
-        map = 1;
-#endif        
-    } else { /* rawflag == 0 */
-        dptr = (uint16_t)udata.u_buf->bf_data;
-        block = udata.u_buf->bf_blk;
-        block_xfer = 4;
-    }
-    block <<= 2;
-    /* Read the disk in four sector chunks. FIXME We ought to cache the geometry
-       and just bump sector checking for a wrap. */
-    while (ct < block_xfer) {
-        fd_drive = minor;
-        fd_geom(minor, block);
-        /* The Z80pack DMA uses the current MMU mappings... beware that
-         * is odd - but most hardware would be PIO (inir/otir etc) anyway */
-        fd_dmal = dptr & 0xFF;
-        fd_dmah = dptr >> 8;
-
-        if (map == 0)
-            fd_cmd = 1 - is_read;
-        else   /* RAW I/O - switch to user bank and issue command via
-                   a helper in common */
-            fd_bankcmd(1 - is_read, page);
-
-        st = fd_status;
-        /* Real disks would need retries */
-        if (st) {
-            kprintf("fd%d: block %d, error %d\n", minor, st, block);
-            break;
-        }
-        block++;
-        ct++;
-        dptr += 128;
-    }
-    return ct >> 2;
-}
-
-int fd_open(uint8_t minor, uint16_t flag)
-{
-    flag;
-    if(minor >= 16 || !sectrack[minor]) {
-        udata.u_error = ENODEV;
-        return -1;
-    }
-    return 0;
-}
diff --git a/Kernel/platform-z80pack-lite/devfd.h b/Kernel/platform-z80pack-lite/devfd.h
deleted file mode 100644 (file)
index f29b00a..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-#ifndef __DEVFD_DOT_H__
-#define __DEVFD_DOT_H__
-
-/* public interface */
-int fd_read(uint8_t minor, uint8_t rawflag, uint8_t flag);
-int fd_write(uint8_t minor, uint8_t rawflag, uint8_t flag);
-int fd_open(uint8_t minor, uint16_t flag);
-
-void fd_bankcmd(uint16_t cmd, uint16_t *bank);
-
-#endif /* __DEVRD_DOT_H__ */