home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / unix / bsd / 8455 < prev    next >
Encoding:
Text File  |  1992-11-04  |  8.5 KB  |  341 lines

  1. Newsgroups: comp.unix.bsd
  2. Path: sparky!uunet!spool.mu.edu!yale.edu!qt.cs.utexas.edu!cs.utexas.edu!sun-barr!sh.wide!wnoc-kyo!kuis!kudpc!nucc!nitgw!rokugogw!masuda
  3. From: masuda@rokugo.co.jp (Yoshihiro Masuda)
  4. Subject: [386bsd] physicaly formatter for floppy disk
  5. Message-ID: <1992Nov5.073156.29595@rokugo.co.jp>
  6. Reply-To: masuda@babel.ics.nitech.ac.jp
  7. Organization: ROKUGO SYSTEM ELC. Co.,LTD.
  8. Date: Thu, 5 Nov 1992 07:31:56 GMT
  9. Lines: 330
  10.  
  11. Hi!
  12.  
  13. I managed to make a program to physically format a floppy disk on 386bsd.
  14.  
  15. It is just a quick hack.  There is a possibility that use of this package 
  16. may cause trouble.
  17.  
  18. So...
  19.  
  20. USE THIS PACKAGE ON YOUR OWN RISK.
  21.  
  22. Enjoy!
  23.  
  24. --
  25. masuda@rokugo.co.jp
  26. $BA}ED2BBY(B@$BO;9g%7%9%F%`EE;R9)6H(B
  27. $B$^$9$@$h$7$R$m(B@$B$m$/$4$&$7$9$F$`$G$s$7$3$&$.$g$&(B
  28.  
  29. --8<-----------------------
  30. #! /bin/sh
  31. # This is a shell archive.  Save it in a file, remove anything before
  32. # this line, and then unpack it by entering "sh file".  Note, it may
  33. # create directories; files and directories will be owned by you and
  34. # have default permissions.
  35. #
  36. # This archive contains:
  37. #
  38. #    fdformat
  39. #    fdformat/FDFORMAT.change.file
  40. #    fdformat/README.eng
  41. #    fdformat/kernel
  42. #    fdformat/kernel/fdformat.diff
  43. #    fdformat/README.jis
  44. #    fdformat/Makefile
  45. #    fdformat/format.c
  46. #
  47. echo c - fdformat
  48. mkdir fdformat > /dev/null 2>&1
  49. echo x - fdformat/FDFORMAT.change.file
  50. sed 's/^X//' >fdformat/FDFORMAT.change.file << 'END-of-fdformat/FDFORMAT.change.file'
  51. X/sys/sys/ioctl.h
  52. X    FDIOCFORMAT
  53. X/sys/i386/i386/conf.c
  54. X    device entry
  55. X/sys/i386/isa/fd.c
  56. X    fdioctl
  57. X    fdintr
  58. END-of-fdformat/FDFORMAT.change.file
  59. echo x - fdformat/README.eng
  60. sed 's/^X//' >fdformat/README.eng << 'END-of-fdformat/README.eng'
  61. XFIRST OF ALL:
  62. X
  63. X  386BSD is an excellent OS.  Now we can throw away our good old MS-DOS
  64. X...almost.
  65. X
  66. X  It is very sad to find things which we cannot do with 386BSD but can 
  67. Xwith MS-DOS...for example, formatting floppy disks.  So first of all I 
  68. Xmade a formatter for formatting floppy disks.  
  69. X
  70. XCHANGES:
  71. X
  72. Xsys/i386/isa/fd.c:
  73. X    Adding fdioctl().
  74. X    Adding formatting process to fdintr().
  75. X
  76. Xsys/sys/ioctl.h
  77. X    Adding FDIOCFORMAT and FDIOCM.
  78. X
  79. XHOW TO INSTALL:
  80. X
  81. X1) Apply patch to kernel, as shown below.
  82. X
  83. X    # cd /sys
  84. X    # patch -p < fdformat.diff
  85. X
  86. X  This may be rejected because of the changes applied to i386/
  87. Xi386/conf.c.  In such a case, add fdioctl manually by checking 
  88. X.rej.
  89. X
  90. X  Make sure ioctl to /dev/rfd* calls fdioctl.
  91. X
  92. X2) Add 
  93. X
  94. X    options    FDFORMAT
  95. X
  96. Xto sys/i386/conf/MYCONFIG.  
  97. X
  98. X3) Re-configurate kernel as below.
  99. X
  100. X    # cd /sys/compile/MYCONFIG
  101. X    # make depend
  102. X    # make
  103. X
  104. X4) Copy the new kernel to /, as shown below.
  105. X
  106. X    # mv /386bsd /386bsd.old
  107. X    # cp 386bsd /386bsd
  108. X
  109. X5) Make and install fdformat, as shown below.
  110. X
  111. X    # make
  112. X    # make install
  113. X
  114. X6) Reboot.
  115. X
  116. X    # sync; sync; sync;
  117. X    # fastboot        <- or shutdown, halt, whatever you like.  
  118. X
  119. X  Now all the instllation is done.  
  120. X
  121. XHOW TO USE:
  122. X
  123. XUsage:    % fdformat [special device] 
  124. X
  125. X  If special device is not specified, you will be asked if you want to 
  126. Xformat /dev/rfd0a.  If you choose y, formatting will start.
  127. X
  128. X  Devices are
  129. X
  130. X    a:    1.4MB
  131. X    b:    1.2MB
  132. X    c/d:    360KB
  133. X
  134. X  For more information, see the array in the beginning of i386/isa/fd.c.  
  135. X
  136. XKNOWN BUGS:
  137. X
  138. X1) It is rather slow to read from and write to floppy disks formatted 
  139. Xwith this formatter.  Will someone please tell me the correct interlib 
  140. Xand length of GAP3?  
  141. X
  142. X2) Fdioctl only checks if the device is opened writable.  
  143. X
  144. X#This means anyone can execute format with ioctl(fd, FDIOCFORMAT, &track).
  145. X
  146. X  If you think this may cause trouble, try to do with changeing the 
  147. Xpermission for /dev/rfd??.  
  148. X
  149. X3) This program may format floppy disks when it shouldn't, which can 
  150. Xcause trouble.  
  151. X
  152. X4) This program can not work well on TOSHIBA J3100SLVW.
  153. X
  154. X  If you find any other problems, please let me know.  You can contact 
  155. Xme at:
  156. X
  157. Xmasuda@rokugo.co.jp (Please do not send mail from outside of Japan)
  158. XTAE00343( (NIFTY serve)
  159. Xpcs34996 (ascii net)
  160. X
  161. END-of-fdformat/README.eng
  162. echo c - fdformat/kernel
  163. mkdir fdformat/kernel > /dev/null 2>&1
  164. echo x - fdformat/kernel/fdformat.diff
  165. sed 's/^X//' >fdformat/kernel/fdformat.diff << 'END-of-fdformat/kernel/fdformat.diff'
  166. XOnly in /sys: ROADMAP
  167. XOnly in /sys: compile
  168. XOnly in /sys: conf
  169. XOnly in /sys: ddb
  170. XOnly in /sys/i386: Makefile
  171. XOnly in /sys/i386: boot
  172. XOnly in /sys/i386: conf
  173. XOnly in /sys/i386/i386: autoconf.c
  174. Xdiff -c -r ../orig/i386/i386/conf.c /sys/i386/i386/conf.c
  175. X*** ../orig/i386/i386/conf.c    Wed Sep 30 15:50:08 1992
  176. X--- /sys/i386/i386/conf.c    Sun Oct  4 23:50:57 1992
  177. X***************
  178. X*** 90,96 ****
  179. X  #include "fd.h"
  180. X  #if NFD > 0
  181. X  int    Fdopen(),fdclose(),fdstrategy();
  182. X! #define    fdioctl        enxio
  183. X  #define    fddump        enxio
  184. X  #define    fdsize        NULL
  185. X  #else
  186. X--- 90,100 ----
  187. X  #include "fd.h"
  188. X  #if NFD > 0
  189. X  int    Fdopen(),fdclose(),fdstrategy();
  190. X! #ifdef FDFORMAT
  191. X! int    fdioctl();
  192. X! #else
  193. X! # define    fdioctl        nullop
  194. X! #endif
  195. X  #define    fddump        enxio
  196. X  #define    fdsize        NULL
  197. X  #else
  198. XOnly in /sys/i386/i386: conf.c.orig
  199. XOnly in /sys/i386/i386: cons.c
  200. XOnly in /sys/i386/i386: cons.h
  201. XOnly in /sys/i386/i386: db_disasm.c
  202. XOnly in /sys/i386/i386: db_interface.c
  203. XOnly in /sys/i386/i386: db_trace.c
  204. XOnly in /sys/i386/i386: dkbad.c
  205. XOnly in /sys/i386/i386: genassym.c
  206. XOnly in /sys/i386/i386: in_cksum.c
  207. XOnly in /sys/i386/i386: locore.s
  208. XOnly in /sys/i386/i386: locore.s.orig
  209. XOnly in /sys/i386/i386: machdep.c
  210. XOnly in /sys/i386/i386: math_emu.h
  211. XOnly in /sys/i386/i386: math_emulate.c
  212. XOnly in /sys/i386/i386: mem.c
  213. XOnly in /sys/i386/i386: pmap.c
  214. XOnly in /sys/i386/i386: swapgeneric.c
  215. XOnly in /sys/i386/i386: symbols.raw
  216. XOnly in /sys/i386/i386: sys_machdep.c
  217. XOnly in /sys/i386/i386: trap.c
  218. XOnly in /sys/i386/i386: vm_machdep.c
  219. XOnly in /sys/i386: include
  220. XOnly in /sys/i386/isa: RCS
  221. XOnly in /sys/i386/isa: TODO
  222. XOnly in /sys/i386/isa: as.c
  223. XOnly in /sys/i386/isa: asreg.h
  224. XOnly in /sys/i386/isa: clock.c
  225. XOnly in /sys/i386/isa: com.c
  226. XOnly in /sys/i386/isa: com.c.rej
  227. XOnly in /sys/i386/isa: com.old
  228. XOnly in /sys/i386/isa: comreg.h
  229. Xdiff -c -r ../orig/i386/isa/fd.c /sys/i386/isa/fd.c
  230. X*** ../orig/i386/isa/fd.c    Fri Oct  2 15:50:26 1992
  231. X--- /sys/i386/isa/fd.c    Sun Oct  4 21:21:15 1992
  232. X***************
  233. X*** 53,58 ****
  234. X--- 53,60 ----
  235. X  #include "i386/isa/rtc.h"
  236. X  #undef NFD
  237. X  #define NFD 2
  238. X+ #define FDPRI    (PZERO+11)
  239. X+ #define FORMATDEBUG 0        /* turn on this for debub */
  240. X  
  241. X  #define    FDUNIT(s)    ((s>>3)&1)
  242. X  #define    FDTYPE(s)    ((s)&7)
  243. X***************
  244. X*** 95,100 ****
  245. X--- 97,122 ----
  246. X  
  247. X  /* state needed for current transfer */
  248. X  static fdc;    /* floppy disk controller io base register */
  249. X+ #ifdef    FDFORMAT
  250. X+ static int fd_unitno;
  251. X+ static int formatting;
  252. X+ #include "malloc.h"
  253. X+ #include "vm/vm.h"
  254. X+ #include "sys/proc.h"
  255. X+ struct id_t { char cylin; char head; char sec; char sectype;};
  256. X+ static struct id_t *id;
  257. X+ static struct id_t *tid;
  258. X+ static struct id_t idbuf[1024];
  259. X+     
  260. X+ static int format_type;
  261. X+ static int format_head;
  262. X+ static int format_cylin;
  263. X+ static char format_sectors[] = {
  264. X+     1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18
  265. X+ };    /* data base for interleave */
  266. X+ static int FormatError;
  267. X+ #endif
  268. X+ 
  269. X  int    fd_dmachan;
  270. X  static int fd_skip;
  271. X  static int fd_state;
  272. X***************
  273. X*** 318,323 ****
  274. X--- 340,358 ----
  275. X      return (0);
  276. X  }
  277. X  
  278. X+ int
  279. X+ in_fdcr()
  280. X+ {
  281. X+     return inb(fdc+fdsts);
  282. X+ }
  283. X+ 
  284. X+ out_fdcr(x)
  285. X+ int x;
  286. X+ {
  287. X+     outb(fdc+fdsts,x);
  288. X+     return (0);
  289. X+ }
  290. X+ 
  291. X  static fdopenf;
  292. X  /****************************************************************************/
  293. X  /*                           fdopen/fdclose                                 */
  294. X***************
  295. X*** 329,335 ****
  296. X       int unit = FDUNIT(minor(dev));
  297. X       /*int type = FDTYPE(minor(dev));*/
  298. X      int s;
  299. X! 
  300. X      fdopenf = 1;
  301. X      /* check bounds */
  302. X      if (unit >= NFD) return(ENXIO);
  303. X--- 364,372 ----
  304. X       int unit = FDUNIT(minor(dev));
  305. X       /*int type = FDTYPE(minor(dev));*/
  306. X      int s;
  307. X! #if 0
  308. X!     if (fdopenf == 1) return(EBUSY);
  309. X! #endif
  310. X      fdopenf = 1;
  311. X      /* check bounds */
  312. X      if (unit >= NFD) return(ENXIO);
  313. X***************
  314. X*** 342,347 ****
  315. X--- 379,385 ----
  316. X  fdclose(dev, flags)
  317. X      dev_t dev;
  318. X  {
  319. X+     fdopenf = 0;
  320. X      return(0);
  321. X  }
  322. X  
  323. X***************
  324. X*** 434,449 ****
  325. X      unsigned long blknum;
  326. X      struct fd_type *ft;
  327. X  
  328. X! #ifdef FDTEST
  329. X      printf("state %d, unit %d, dr %d|",fd_state,unit,fd_drive);
  330. X  #endif
  331. X- 
  332. X      if (!fdopenf) return;
  333. X!     dp = &fd_unit[fd_drive].head;
  334. X!     bp = dp->b_actf;
  335. X!     read = bp->b_flags & B_READ;
  336. X!      /*ft = &fd_types[FDTYPE(bp->b_dev)];*/
  337. -- 
  338. masuda@rokugo.co.jp
  339. $@A}ED2BBY(J@$@O;9g%7%9%F%`EE;R9)6H(J
  340. $@$^$9$@$h$7$R$m(J@$@$m$/$4$&$7$9$F$`$G$s$7$3$&$.$g$&(J
  341.