home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / sys / next / programm / 5715 < prev    next >
Encoding:
Text File  |  1992-08-20  |  3.2 KB  |  84 lines

  1. Newsgroups: comp.sys.next.programmer
  2. Path: sparky!uunet!nwnexus!sounds!brianw
  3. From: BrianW@SoundS.WA.com (Brian Willoughby)
  4. Subject: Re: _IO, _IOR, _IOW and _IOWR functions
  5. Message-ID: <Bt9sG7.96E@sounds.wa.com>
  6. Sender: brianw@sounds.wa.com (Brian Willoughby)
  7. Reply-To: BrianW@SoundS.WA.com
  8. Organization: SoundSoftware, Bellevue, WA, USA
  9. References: <1992Aug19.220946.13633@unmvax.cs.unm.edu>
  10. Date: Thu, 20 Aug 1992 06:52:55 GMT
  11. Lines: 71
  12.  
  13.  
  14. Now that the curious seem to have turned the discussion to ioctl() calls, I  
  15. would like to take the opportunity to re-post a question of mine about directly  
  16. accessing the Intel 82077 Floppy Disk Controller chip.
  17.  
  18. For compatibility with a 10-sector per track 3.5" floppy format, I need to send  
  19. a READ command directly to the controller chip with DMA enabled in order to  
  20. read a sector written with an address tag of sector 0.  Reading multiple  
  21. sectors with one call would be nice as well.
  22.  
  23. I have learned a great deal from the /NextDeveloper/Examples/Floppy code and  
  24. have successfully been able to read sectors 1 through 9 with a higher level  
  25. function {namely ioctl(fd, FDIOCRRW, &rawio)}, but apparently I cannot read  
  26. sector 0 without going to the lowest level because FDIOCRRW is block based and  
  27. assumes that each track starts with sector 1 when it determines the cylinder.
  28.  
  29. Here is what I have coded so far.  do_ioc() is taken from fdform.c with  
  30. improved error reporting.  I tried sectors 0 and 1, combined with tracks 0 and  
  31. 1, for transfers of 1, 9 and 10 sectors without any luck.
  32.  
  33. | #include <sys/file.h>
  34. | #include <sys/ioctl.h>
  35. | #include <nextdev/fd_extern.h>
  36. | #include <nextdev/disk.h>
  37. | #include <nextdev/dma.h>
  38. |     bzero(&ioreq, sizeof(struct fd_ioreq));
  39. |     ioreq.density = FD_DENS_1;
  40. |     ioreq.timeout = 5000;
  41. |     ioreq.command = FDCMD_CMD_XFR;
  42. |     pcmd->mfm = 1;
  43. |     pcmd->opcode = (read_flag ? FCCMD_READ : FCCMD_WRITE);
  44. |     pcmd->hds = head;
  45. |     pcmd->drive_sel = 0;
  46. |     pcmd->cylinder = cylinder;
  47. |     pcmd->head = head;
  48. |     pcmd->sector = sector;
  49. |     pcmd->sector_size = pfi->sectsize_info.n;
  50. |     pcmd->eot = EOT;
  51. |     pcmd->gap_length= pfi->sectsize_info.rw_gap_length;
  52. |     pcmd->dtl = 0xff;
  53. |     ioreq.num_cmd_bytes = SIZEOF_RW_CMD;
  54. |     ioreq.addrs = (caddr_t)addrs;
  55. |     ioreq.byte_count = DMA_ENDALIGN(int, sector_count * SECT_SIZE);
  56. |     ioreq.num_stat_bytes = SIZEOF_RW_STAT;
  57. |     ioreq.flags = (read_flag ? FD_IOF_DMA_RD : FD_IOF_DMA_WR);
  58. |     rtn = do_ioc(fd, &ioreq);
  59.  
  60. And here are the results interpreted by my error printing routines (if you can  
  61. answer my question, you might be able to understand these based upon knowledge  
  62. of the Intel controller):
  63.  
  64. | Accessing floppy disk volume 0
  65. | ...Expected stat byte count = 0x7
  66. |    received stat byte count = 0x0
  67. | ...Unexpected status: a
  68. | FDR_BADPHASE:   controller changed phase unexpectedly
  69. | ...Read/Write Failed
  70. | Status Register 0:
  71. | Head Address 0
  72. | Drive Select 0
  73.  
  74. Has anyone successully used the ioctl(fd, FDIOCREQ, fdiop) call to read and  
  75. write a floppy?  Even code which uses FDIOCREQ to access a standard 9-sector  
  76. disk would be useful.
  77.  
  78. Is NeXT listening?  You may be the only resource that can solve this...
  79. -- 
  80. Brian Willoughby    Software Design Engineer, BSEE
  81. BrianW@SoundS.WA.com    SoundSoftware
  82. NeXTmail welcome
  83.