{
/* 0: /dev/fd Floppy disc block devices (NC200 only) */
#if defined CONFIG_NC200
- { blkdev_open, no_close, blkdev_read, blkdev_write, blkdev_ioctl },
+ { devfd_open, no_close, devfd_read, devfd_write, no_ioctl },
#else
{ nxio_open, no_close, no_rdwr, no_rdwr, no_ioctl },
#endif
{
inittod();
nc100_tty_init();
- devfd_init();
}
__sfr __at 0x30 control;
CSRCS = \
+ devfd.c \
../platform-nc100/devlpr.c \
../platform-nc100/devtty.c \
../platform-nc100/devrd.c \
../platform-nc100/main.c \
ASRCS = \
+ crt0.s \
+ fdc765.s \
../platform-nc100/nc100.s \
- ../platform-nc100/crt0.s \
../platform-nc100/tricks.s \
../platform-nc100/commonmem.s \
COBJS = $(CSRCS:.c=.rel)
AOBJS = $(ASRCS:.s=.rel)
-OBJS = $(COBJS) $(AOBJS)
+DOBJS = $(DSRCS:.c=.rel)
+OBJS = $(COBJS) $(AOBJS) $(DOBJS)
+
+CROSS_CCOPTS += -I../dev/
JUNK = \
$(CSRCS:.c=.lst) \
rm -f $(OBJS) $(JUNK) core *~
rm -f floppyskeleton.img autoprg.bin bootfloppy.img
-bootblock.img: ../platform-nc100/bootblock.s
- sdasz80 -fflopzws bootblock.rel ../platform-nc100/bootblock.s
- sdldz80 -nwmx -b BOOTBLOCK=0 -i bootblock.ihx bootblock.rel
- srec_cat -disable-sequence-warning \
- bootblock.ihx -intel \
- -output bootblock.img -binary
-
-image: floppyskeleton.img autoprg.bin bootblock.img ../fuzix.bin
- dd if=bootblock.img of=../fuzix.bin bs=1 conv=notrunc
+image: floppyskeleton.img autoprg.bin ../fuzix.bin
cp floppyskeleton.img ../fuzixfloppy.img
truncate ../fuzixfloppy.img --size 7680
mcopy -i ../fuzixfloppy.img autoprg.bin ::auto.prg
- dd if=../fuzix.bin bs=16k skip=0 count=1 | mcopy -i ../fuzixfloppy.img - ::load4000.80
- dd if=../fuzix.bin bs=16k skip=1 count=1 | mcopy -i ../fuzixfloppy.img - ::load4000.81
- dd if=../fuzix.bin bs=16k skip=2 count=1 | mcopy -i ../fuzixfloppy.img - ::load4000.82
- echo -n | mcopy -i ../fuzixfloppy.img - ::call4000.80
+ dd if=../fuzix.bin bs=16k skip=0 count=1 | mcopy -i ../fuzixfloppy.img - ::load4000.83
+ dd if=../fuzix.bin bs=16k skip=1 count=1 | mcopy -i ../fuzixfloppy.img - ::load4000.84
+ dd if=../fuzix.bin bs=16k skip=2 count=1 | mcopy -i ../fuzixfloppy.img - ::load4000.85
+ echo -n | mcopy -i ../fuzixfloppy.img - ::call4080.83
floppyskeleton.img: floppyskeleton.s
sdasz80 -fflopzws floppyskeleton.rel floppyskeleton.s
static timer_t spindown_timer = 0;
-void devfd_init(void)
+int devfd_open(uint8_t minor, uint16_t flag)
{
- blkdev_t* blk = blkdev_alloc();
- if (!blk)
- return;
-
+ flag;
+ if(minor != 0) {
+ udata.u_error = ENODEV;
+ return -1;
+ }
fd765_do_nudge_tc();
fd765_track = 0xff; /* not on a known track */
- blk->transfer = devfd_transfer;
- blk->drive_lba_count = 1440; /* 512-byte sectors */
- blkdev_scan(blk, 0);
+ return 0;
}
static void nudge_timer(void)
nudge_timer();
}
-uint8_t devfd_transfer(void)
+static int devfd_transfer(bool is_read, uint8_t is_raw)
{
int ct = 0;
int tries;
- int blocks = blk_op.nblock;
- uint16_t lba = blk_op.lba;
+ int blocks = udata.u_nblock;
+ uint16_t lba = udata.u_block;
+
+ // kprintf("[%s %d @ %x : %d:%x]\n", is_read ? "read" : "write",
+ // blocks, lba, is_raw, udata.u_dptr);
+ // if (!is_read)
+ // return blocks << BLKSHIFT;
+
+ if (is_raw && d_blkoff(BLKSHIFT))
+ return -1;
fd_select(0);
- fd765_is_user = blk_op.is_user;
- fd765_buffer = blk_op.addr;
+ fd765_is_user = is_raw;
+ fd765_buffer = udata.u_dptr;
while (blocks != 0)
{
if (fd765_sectors > blocks)
fd765_sectors = blocks;
- if (blk_op.is_read)
+ if (is_read)
fd765_do_read();
else
fd765_do_write();
}
if (tries == 3)
{
- kprintf("fd%d: I/O error %d:%d\n", blk_op.is_read, lba);
+ kprintf("fd%d: I/O error %d:%d\n", is_read, lba);
udata.u_error = EIO;
break;
}
ct += fd765_sectors;
}
- return ct;
-}
\ No newline at end of file
+ return ct << BLKSHIFT;
+}
+
+int devfd_read(uint8_t minor, uint8_t is_raw, uint8_t flag)
+{
+ flag;minor;
+ return devfd_transfer(true, is_raw);
+}
+
+int devfd_write(uint8_t minor, uint8_t is_raw, uint8_t flag)
+{
+ flag;minor;
+ return devfd_transfer(false, is_raw);
+}
+
#define __DEVFD_DOT_H__
/* public interface */
-extern void devfd_init(void);
+int devfd_open(uint8_t minor, uint16_t flag);
+int devfd_read(uint8_t minor, uint8_t rawflag, uint8_t flag);
+int devfd_write(uint8_t minor, uint8_t rawflag, uint8_t flag);
+
extern void devfd_spindown(void);
-extern uint8_t devfd_transfer(void);
extern void fd765_do_nudge_tc(void);
extern void fd765_do_recalibrate(void);