CSRCS = devlpr.c devtty.c devfd.c devhd.c
CSRCS += devices.c main.c
+DISCARD_CSRCS = discard.c devhd_discard.c
ASRCS = trs80.s crt0.s
ASRCS += tricks.s commonmem.s floppy.s
COBJS = $(CSRCS:.c=.rel)
AOBJS = $(ASRCS:.s=.rel)
-OBJS = $(COBJS) $(AOBJS)
+DISCARD_COBJS = $(DISCARD_CSRCS:.c=.rel)
+OBJS = $(COBJS) $(AOBJS) $(DISCARD_COBJS)
JUNK = $(CSRCS:.c=.lst) $(CSRCS:.c=.asm) $(CSRCS:.c=.sym) $(ASRCS:.s=.lst) $(ASRCS:.s=.sym) $(CSRCS:.c=.rst) $(ASRCS:.s=.rst)
$(AOBJS): %.rel: %.s
$(CROSS_AS) $(ASOPTS) $<
+$(DISCARD_COBJS): %.rel: %.c
+ $(CROSS_CC) $(CROSS_CCOPTS) $(CROSS_CC_SEGDISC) -c $<
+
clean:
rm -f $(OBJS) $(JUNK) core *~
* WD1010 hard disk driver
*/
+#define _HD_PRIVATE
#include <kernel.h>
#include <kdata.h>
#include <printf.h>
#include <devhd.h>
#include <diskgeom.h>
-__sfr __at 0xC0 hd_wpbits; /* Write protect and IRQ (not used) */
-__sfr __at 0xC1 hd_ctrl; /* Reset and enable bits */
-__sfr __at 0xC8 hd_data;
-__sfr __at 0xC9 hd_precomp; /* W/O */
-__sfr __at 0xC9 hd_err; /* R/O */
-__sfr __at 0xCA hd_seccnt;
-__sfr __at 0xCB hd_secnum;
-__sfr __at 0xCC hd_cyllo;
-__sfr __at 0xCD hd_cylhi;
-__sfr __at 0xCE hd_sdh;
-__sfr __at 0xCF hd_status; /* R/O */
-__sfr __at 0xCF hd_cmd;
-
-#define HDCMD_RESTORE 0x10
-#define HDCMD_READ 0x20
-#define HDCMD_WRITE 0x30
-#define HDCMD_VERIFY 0x40 /* Not on the 1010 later only */
-#define HDCMD_FORMAT 0x50
-#define HDCMD_INIT 0x60 /* Ditto */
-#define HDCMD_SEEK 0x70
-
-#define RATE_4MS 0x08 /* 4ms step rate for hd (conservative) */
-
-#define HDCTRL_SOFTRESET 0x10
-#define HDCTRL_ENABLE 0x08
-#define HDCTRL_WAITENABLE 0x04
-
-#define HDSDH_ECC256 0x80
-
/* Used by the asm helpers */
uint8_t hd_page;
/* Seek and restore low 4 bits are the step rate, read/write support
multi-sector mode but not all emulators do .. */
-#define MAX_HD 4
-
struct minipart parts[MAX_HD];
/* Wait for the drive to show ready */
-static uint8_t hd_waitready(void)
+uint8_t hd_waitready(void)
{
uint8_t st;
do {
}
/* Wait for DRQ or an error */
-static uint8_t hd_waitdrq(void)
+uint8_t hd_waitdrq(void)
{
uint8_t st;
do {
return st;
}
-static uint8_t hd_xfer(bool is_read, uint16_t addr)
+uint8_t hd_xfer(bool is_read, uint16_t addr)
{
/* Error ? */
if (hd_status & 0x01)
return hd_transfer(minor, false, rawflag);
}
-/*------------------- below this is thrown after boot ---------------- */
-DISCARDABLE
-
-/*
- * Mini part processing. This and mbr and other things all one day
- * need to become a bit more unified.
- */
-static void hd_swapon(struct minipart *p, unsigned int d, unsigned int i)
-{
- uint16_t cyls;
- if (i == 14 || p->cyl[i+1] == 0xFFFF)
- cyls = p->g.cyl;
- else
- cyls = p->cyl[i+1];
- cyls -= p->cyl[i];
- cyls *= p->g.head;
- /* This is now the number of sets of 32 sectors (16K) in swap.
- We need 32K per process: hardwire it here - FIX if you change
- the mapping model */
-
- swap_dev = (d << 4) + i + 1 + 0x100;
-
- if (cyls >= MAX_SWAPS)
- cyls = MAX_SWAPS - 1;
- for (i = 0; i < cyls; i++) {
- swapmap_add(i);
- }
- kputs("swap-");
-}
-
-void hd_probe(void)
-{
- unsigned int dev = 0;
- unsigned int i;
- uint8_t *d = tmpbuf();
- /* Second half of second block */
- struct minipart *p = (struct minipart *)(d + 128);
- for (dev = 0; dev < 4; dev++) {
- hd_sdh = 0x80 | (dev << 3);
- hd_cmd = HDCMD_RESTORE | RATE_4MS;
- if (hd_waitready() & 1) {
- if ((hd_err & 0x12) == 0x12)
- continue;
- }
- hd_seccnt = 1;
- hd_sdh = 0x80 | (dev << 3);
- hd_secnum = 2;
- hd_cyllo = 0;
- hd_cylhi = 0;
- hd_cmd = HDCMD_READ;
- if (hd_waitdrq() & 1)
- continue;
- if((hd_xfer(1, (uint16_t)d) & 0x41) != 0x40)
- continue;
- kprintf("hd%c: ", dev + 'a');
- if (p->g.magic != MP_SIG_0) {
- p->g.cyl = 1;
- p->g.head = 1;
- p->g.sec = 32;
- p->g.precomp = 0;
- p->g.seek = 10;
- p->g.secsize = 8;
- for (i = 0; i < 15; i++)
- p->cyl[i] = 0xFFFFU;
- kputs("(unlabelled)\n");
- } else {
- for (i = 0; i < 15; i++) {
- if (p->cyl[i] != 0xFFFFU) {
- if (p->type[i] == 0x56) {
- /* Configure swap */
- hd_swapon(p, dev, i);
- }
- kprintf("hd%c%d ", dev + 'a', i + 1);
- }
- }
- kputs("\n");
- }
- if (p->g.seek) {
- p->g.seek /= 2;
- if (p->g.seek == 0)
- p->g.seek = 1;
- }
- /* Set the step rate */
- hd_cmd = HDCMD_SEEK | p->g.seek;
- hd_waitready();
- memcpy(&parts[dev], p, sizeof(parts[dev]));
- }
- brelse((bufptr)d);
-}
#define __DEVHD_DOT_H__
/* public interface */
-int hd_read(uint8_t minor, uint8_t rawflag, uint8_t flag);
-int hd_write(uint8_t minor, uint8_t rawflag, uint8_t flag);
-int hd_open(uint8_t minor, uint16_t flag);
+extern int hd_read(uint8_t minor, uint8_t rawflag, uint8_t flag);
+extern int hd_write(uint8_t minor, uint8_t rawflag, uint8_t flag);
+extern int hd_open(uint8_t minor, uint16_t flag);
-/* helpers in common memory for the block transfers */
-int hd_xfer_in(uint16_t addr);
-int hd_xfer_out(uint16_t addr);
+extern void hd_probe(void);
+
+#ifdef _HD_PRIVATE
+
+__sfr __at 0xC0 hd_wpbits; /* Write protect and IRQ (not used) */
+__sfr __at 0xC1 hd_ctrl; /* Reset and enable bits */
+__sfr __at 0xC8 hd_data;
+__sfr __at 0xC9 hd_precomp; /* W/O */
+__sfr __at 0xC9 hd_err; /* R/O */
+__sfr __at 0xCA hd_seccnt;
+__sfr __at 0xCB hd_secnum;
+__sfr __at 0xCC hd_cyllo;
+__sfr __at 0xCD hd_cylhi;
+__sfr __at 0xCE hd_sdh;
+__sfr __at 0xCF hd_status; /* R/O */
+__sfr __at 0xCF hd_cmd;
+
+#define HDCMD_RESTORE 0x10
+#define HDCMD_READ 0x20
+#define HDCMD_WRITE 0x30
+#define HDCMD_VERIFY 0x40 /* Not on the 1010 later only */
+#define HDCMD_FORMAT 0x50
+#define HDCMD_INIT 0x60 /* Ditto */
+#define HDCMD_SEEK 0x70
+
+#define RATE_4MS 0x08 /* 4ms step rate for hd (conservative) */
+
+#define HDCTRL_SOFTRESET 0x10
+#define HDCTRL_ENABLE 0x08
+#define HDCTRL_WAITENABLE 0x04
-void hd_probe(void);
+#define HDSDH_ECC256 0x80
+
+/* Seek and restore low 4 bits are the step rate, read/write support
+ multi-sector mode but not all emulators do .. */
+
+#define MAX_HD 4
+
+extern struct minipart parts[MAX_HD];
+
+extern uint8_t hd_waitready(void);
+extern uint8_t hd_waitdrq(void);
+extern uint8_t hd_xfer(bool is_read, uint16_t addr);
+
+/* helpers in common memory for the block transfers */
+extern int hd_xfer_in(uint16_t addr);
+extern int hd_xfer_out(uint16_t addr);
+#endif
#endif /* __DEVHD_DOT_H__ */
--- /dev/null
+#define _HD_PRIVATE
+#include <kernel.h>
+#include <kdata.h>
+#include <printf.h>
+#include <devhd.h>
+#include <diskgeom.h>
+
+/*
+ * Mini part processing. This and mbr and other things all one day
+ * need to become a bit more unified.
+ */
+static void hd_swapon(struct minipart *p, unsigned int d, unsigned int i)
+{
+ uint16_t cyls;
+ if (i == 14 || p->cyl[i+1] == 0xFFFF)
+ cyls = p->g.cyl;
+ else
+ cyls = p->cyl[i+1];
+ cyls -= p->cyl[i];
+ cyls *= p->g.head;
+ /* This is now the number of sets of 32 sectors (16K) in swap.
+ We need 32K per process: hardwire it here - FIX if you change
+ the mapping model */
+
+ swap_dev = (d << 4) + i + 1 + 0x100;
+
+ if (cyls >= MAX_SWAPS)
+ cyls = MAX_SWAPS - 1;
+ for (i = 0; i < cyls; i++) {
+ swapmap_add(i);
+ }
+ kputs("swap-");
+}
+
+void hd_probe(void)
+{
+ unsigned int dev = 0;
+ unsigned int i;
+ uint8_t *d = tmpbuf();
+ /* Second half of second block */
+ struct minipart *p = (struct minipart *)(d + 128);
+ for (dev = 0; dev < 4; dev++) {
+ hd_sdh = 0x80 | (dev << 3);
+ hd_cmd = HDCMD_RESTORE | RATE_4MS;
+ if (hd_waitready() & 1) {
+ if ((hd_err & 0x12) == 0x12)
+ continue;
+ }
+ hd_seccnt = 1;
+ hd_sdh = 0x80 | (dev << 3);
+ hd_secnum = 2;
+ hd_cyllo = 0;
+ hd_cylhi = 0;
+ hd_cmd = HDCMD_READ;
+ if (hd_waitdrq() & 1)
+ continue;
+ if((hd_xfer(1, (uint16_t)d) & 0x41) != 0x40)
+ continue;
+ kprintf("hd%c: ", dev + 'a');
+ if (p->g.magic != MP_SIG_0) {
+ p->g.cyl = 1;
+ p->g.head = 1;
+ p->g.sec = 32;
+ p->g.precomp = 0;
+ p->g.seek = 10;
+ p->g.secsize = 8;
+ for (i = 0; i < 15; i++)
+ p->cyl[i] = 0xFFFFU;
+ kputs("(unlabelled)\n");
+ } else {
+ for (i = 0; i < 15; i++) {
+ if (p->cyl[i] != 0xFFFFU) {
+ if (p->type[i] == 0x56) {
+ /* Configure swap */
+ hd_swapon(p, dev, i);
+ }
+ kprintf("hd%c%d ", dev + 'a', i + 1);
+ }
+ }
+ kputs("\n");
+ }
+ if (p->g.seek) {
+ p->g.seek /= 2;
+ if (p->g.seek == 0)
+ p->g.seek = 1;
+ }
+ /* Set the step rate */
+ hd_cmd = HDCMD_SEEK | p->g.seek;
+ hd_waitready();
+ memcpy(&parts[dev], p, sizeof(parts[dev]));
+ }
+ brelse((bufptr)d);
+}
return true;
}
-DISCARDABLE
-
-void device_init(void)
-{
-#ifdef CONFIG_RTC
- /* Time of day clock */
- inittod();
-#endif
- hd_probe();
-}
platform-trs80/devfd.rel
platform-trs80/floppy.rel
platform-trs80/devhd.rel
+platform-trs80/devhd_discard.rel
platform-trs80/devices.rel
devio.rel
filesys.rel
devsys.rel
platform-trs80/devlpr.rel
platform-trs80/devtty.rel
+platform-trs80/discard.rel
-e
#endif
-DISCARDABLE
-
-void map_init(void)
-{
-}
-
-void pagemap_init(void)
-{
- pagemap_add(0x63); /* Mode 3, U64K low 32K mapped as low 32K */
- pagemap_add(0x73); /* Mode 3, U64K high 32K mapped as low 32K */
-}