home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.next.programmer
- Path: sparky!uunet!nwnexus!sounds!brianw
- From: BrianW@SoundS.WA.com (Brian Willoughby)
- Subject: Re: _IO, _IOR, _IOW and _IOWR functions
- Message-ID: <Bt9sG7.96E@sounds.wa.com>
- Sender: brianw@sounds.wa.com (Brian Willoughby)
- Reply-To: BrianW@SoundS.WA.com
- Organization: SoundSoftware, Bellevue, WA, USA
- References: <1992Aug19.220946.13633@unmvax.cs.unm.edu>
- Date: Thu, 20 Aug 1992 06:52:55 GMT
- Lines: 71
-
-
- Now that the curious seem to have turned the discussion to ioctl() calls, I
- would like to take the opportunity to re-post a question of mine about directly
- accessing the Intel 82077 Floppy Disk Controller chip.
-
- For compatibility with a 10-sector per track 3.5" floppy format, I need to send
- a READ command directly to the controller chip with DMA enabled in order to
- read a sector written with an address tag of sector 0. Reading multiple
- sectors with one call would be nice as well.
-
- I have learned a great deal from the /NextDeveloper/Examples/Floppy code and
- have successfully been able to read sectors 1 through 9 with a higher level
- function {namely ioctl(fd, FDIOCRRW, &rawio)}, but apparently I cannot read
- sector 0 without going to the lowest level because FDIOCRRW is block based and
- assumes that each track starts with sector 1 when it determines the cylinder.
-
- Here is what I have coded so far. do_ioc() is taken from fdform.c with
- improved error reporting. I tried sectors 0 and 1, combined with tracks 0 and
- 1, for transfers of 1, 9 and 10 sectors without any luck.
-
- | #include <sys/file.h>
- | #include <sys/ioctl.h>
- | #include <nextdev/fd_extern.h>
- | #include <nextdev/disk.h>
- | #include <nextdev/dma.h>
- |
- | bzero(&ioreq, sizeof(struct fd_ioreq));
- | ioreq.density = FD_DENS_1;
- | ioreq.timeout = 5000;
- | ioreq.command = FDCMD_CMD_XFR;
- | pcmd->mfm = 1;
- | pcmd->opcode = (read_flag ? FCCMD_READ : FCCMD_WRITE);
- | pcmd->hds = head;
- | pcmd->drive_sel = 0;
- | pcmd->cylinder = cylinder;
- | pcmd->head = head;
- | pcmd->sector = sector;
- | pcmd->sector_size = pfi->sectsize_info.n;
- | pcmd->eot = EOT;
- | pcmd->gap_length= pfi->sectsize_info.rw_gap_length;
- | pcmd->dtl = 0xff;
- | ioreq.num_cmd_bytes = SIZEOF_RW_CMD;
- | ioreq.addrs = (caddr_t)addrs;
- | ioreq.byte_count = DMA_ENDALIGN(int, sector_count * SECT_SIZE);
- | ioreq.num_stat_bytes = SIZEOF_RW_STAT;
- | ioreq.flags = (read_flag ? FD_IOF_DMA_RD : FD_IOF_DMA_WR);
- | rtn = do_ioc(fd, &ioreq);
-
- And here are the results interpreted by my error printing routines (if you can
- answer my question, you might be able to understand these based upon knowledge
- of the Intel controller):
-
- | Accessing floppy disk volume 0
- | ...Expected stat byte count = 0x7
- | received stat byte count = 0x0
- | ...Unexpected status: a
- | FDR_BADPHASE: controller changed phase unexpectedly
- | ...Read/Write Failed
- | Status Register 0:
- | Head Address 0
- | Drive Select 0
-
- Has anyone successully used the ioctl(fd, FDIOCREQ, fdiop) call to read and
- write a floppy? Even code which uses FDIOCREQ to access a standard 9-sector
- disk would be useful.
-
- Is NeXT listening? You may be the only resource that can solve this...
- --
- Brian Willoughby Software Design Engineer, BSEE
- BrianW@SoundS.WA.com SoundSoftware
- NeXTmail welcome
-