Return to BSD News archive
Newsgroups: comp.unix.bsd Path: sserve!manuel.anu.edu.au!munnari.oz.au!sgiblab!spool.mu.edu!yale.edu!qt.cs.utexas.edu!cs.utexas.edu!sun-barr!sh.wide!wnoc-kyo!kuis!kudpc!nucc!nitgw!rokugogw!masuda From: masuda@rokugo.co.jp (Yoshihiro Masuda) Subject: [386bsd] physicaly formatter for floppy disk Message-ID: <1992Nov5.073156.29595@rokugo.co.jp> Reply-To: masuda@babel.ics.nitech.ac.jp Organization: ROKUGO SYSTEM ELC. Co.,LTD. Date: Thu, 5 Nov 1992 07:31:56 GMT Lines: 330 Hi! I managed to make a program to physically format a floppy disk on 386bsd. It is just a quick hack. There is a possibility that use of this package may cause trouble. So... USE THIS PACKAGE ON YOUR OWN RISK. Enjoy! -- masuda@rokugo.co.jp 増田佳泰@六合システム電子工業 ますだよしひろ@ろくごう瘢雹しすてむでんしこう瘢雹ぎょう瘢雹 --8<----------------------- #! /bin/sh # This is a shell archive. Save it in a file, remove anything before # this line, and then unpack it by entering "sh file". Note, it may # create directories; files and directories will be owned by you and # have default permissions. # # This archive contains: # # fdformat # fdformat/FDFORMAT.change.file # fdformat/README.eng # fdformat/kernel # fdformat/kernel/fdformat.diff # fdformat/README.jis # fdformat/Makefile # fdformat/format.c # echo c - fdformat mkdir fdformat > /dev/null 2>&1 echo x - fdformat/FDFORMAT.change.file sed 's/^X//' >fdformat/FDFORMAT.change.file << 'END-of-fdformat/FDFORMAT.change.file' X/sys/sys/ioctl.h X FDIOCFORMAT X/sys/i386/i386/conf.c X device entry X/sys/i386/isa/fd.c X fdioctl X fdintr END-of-fdformat/FDFORMAT.change.file echo x - fdformat/README.eng sed 's/^X//' >fdformat/README.eng << 'END-of-fdformat/README.eng' XFIRST OF ALL: X X 386BSD is an excellent OS. Now we can throw away our good old MS-DOS X...almost. X X It is very sad to find things which we cannot do with 386BSD but can Xwith MS-DOS...for example, formatting floppy disks. So first of all I Xmade a formatter for formatting floppy disks. X XCHANGES: X Xsys/i386/isa/fd.c: X Adding fdioctl(). X Adding formatting process to fdintr(). X Xsys/sys/ioctl.h X Adding FDIOCFORMAT and FDIOCM. X XHOW TO INSTALL: X X1) Apply patch to kernel, as shown below. X X # cd /sys X # patch -p < fdformat.diff X X This may be rejected because of the changes applied to i386/ Xi386/conf.c. In such a case, add fdioctl manually by checking X.rej. X X Make sure ioctl to /dev/rfd* calls fdioctl. X X2) Add X X options FDFORMAT X Xto sys/i386/conf/MYCONFIG. X X3) Re-configurate kernel as below. X X # cd /sys/compile/MYCONFIG X # make depend X # make X X4) Copy the new kernel to /, as shown below. X X # mv /386bsd /386bsd.old X # cp 386bsd /386bsd X X5) Make and install fdformat, as shown below. X X # make X # make install X X6) Reboot. X X # sync; sync; sync; X # fastboot <- or shutdown, halt, whatever you like. X X Now all the instllation is done. X XHOW TO USE: X XUsage: % fdformat [special device] X X If special device is not specified, you will be asked if you want to Xformat /dev/rfd0a. If you choose y, formatting will start. X X Devices are X X a: 1.4MB X b: 1.2MB X c/d: 360KB X X For more information, see the array in the beginning of i386/isa/fd.c. X XKNOWN BUGS: X X1) It is rather slow to read from and write to floppy disks formatted Xwith this formatter. Will someone please tell me the correct interlib Xand length of GAP3? X X2) Fdioctl only checks if the device is opened writable. X X#This means anyone can execute format with ioctl(fd, FDIOCFORMAT, &track). X X If you think this may cause trouble, try to do with changeing the Xpermission for /dev/rfd??. X X3) This program may format floppy disks when it shouldn't, which can Xcause trouble. X X4) This program can not work well on TOSHIBA J3100SLVW. X X If you find any other problems, please let me know. You can contact Xme at: X Xmasuda@rokugo.co.jp (Please do not send mail from outside of Japan) XTAE00343( (NIFTY serve) Xpcs34996 (ascii net) X END-of-fdformat/README.eng echo c - fdformat/kernel mkdir fdformat/kernel > /dev/null 2>&1 echo x - fdformat/kernel/fdformat.diff sed 's/^X//' >fdformat/kernel/fdformat.diff << 'END-of-fdformat/kernel/fdformat.diff' XOnly in /sys: ROADMAP XOnly in /sys: compile XOnly in /sys: conf XOnly in /sys: ddb XOnly in /sys/i386: Makefile XOnly in /sys/i386: boot XOnly in /sys/i386: conf XOnly in /sys/i386/i386: autoconf.c Xdiff -c -r ../orig/i386/i386/conf.c /sys/i386/i386/conf.c X*** ../orig/i386/i386/conf.c Wed Sep 30 15:50:08 1992 X--- /sys/i386/i386/conf.c Sun Oct 4 23:50:57 1992 X*************** X*** 90,96 **** X #include "fd.h" X #if NFD > 0 X int Fdopen(),fdclose(),fdstrategy(); X! #define fdioctl enxio X #define fddump enxio X #define fdsize NULL X #else X--- 90,100 ---- X #include "fd.h" X #if NFD > 0 X int Fdopen(),fdclose(),fdstrategy(); X! #ifdef FDFORMAT X! int fdioctl(); X! #else X! # define fdioctl nullop X! #endif X #define fddump enxio X #define fdsize NULL X #else XOnly in /sys/i386/i386: conf.c.orig XOnly in /sys/i386/i386: cons.c XOnly in /sys/i386/i386: cons.h XOnly in /sys/i386/i386: db_disasm.c XOnly in /sys/i386/i386: db_interface.c XOnly in /sys/i386/i386: db_trace.c XOnly in /sys/i386/i386: dkbad.c XOnly in /sys/i386/i386: genassym.c XOnly in /sys/i386/i386: in_cksum.c XOnly in /sys/i386/i386: locore.s XOnly in /sys/i386/i386: locore.s.orig XOnly in /sys/i386/i386: machdep.c XOnly in /sys/i386/i386: math_emu.h XOnly in /sys/i386/i386: math_emulate.c XOnly in /sys/i386/i386: mem.c XOnly in /sys/i386/i386: pmap.c XOnly in /sys/i386/i386: swapgeneric.c XOnly in /sys/i386/i386: symbols.raw XOnly in /sys/i386/i386: sys_machdep.c XOnly in /sys/i386/i386: trap.c XOnly in /sys/i386/i386: vm_machdep.c XOnly in /sys/i386: include XOnly in /sys/i386/isa: RCS XOnly in /sys/i386/isa: TODO XOnly in /sys/i386/isa: as.c XOnly in /sys/i386/isa: asreg.h XOnly in /sys/i386/isa: clock.c XOnly in /sys/i386/isa: com.c XOnly in /sys/i386/isa: com.c.rej XOnly in /sys/i386/isa: com.old XOnly in /sys/i386/isa: comreg.h Xdiff -c -r ../orig/i386/isa/fd.c /sys/i386/isa/fd.c X*** ../orig/i386/isa/fd.c Fri Oct 2 15:50:26 1992 X--- /sys/i386/isa/fd.c Sun Oct 4 21:21:15 1992 X*************** X*** 53,58 **** X--- 53,60 ---- X #include "i386/isa/rtc.h" X #undef NFD X #define NFD 2 X+ #define FDPRI (PZERO+11) X+ #define FORMATDEBUG 0 /* turn on this for debub */ X X #define FDUNIT(s) ((s>>3)&1) X #define FDTYPE(s) ((s)&7) X*************** X*** 95,100 **** X--- 97,122 ---- X X /* state needed for current transfer */ X static fdc; /* floppy disk controller io base register */ X+ #ifdef FDFORMAT X+ static int fd_unitno; X+ static int formatting; X+ #include "malloc.h" X+ #include "vm/vm.h" X+ #include "sys/proc.h" X+ struct id_t { char cylin; char head; char sec; char sectype;}; X+ static struct id_t *id; X+ static struct id_t *tid; X+ static struct id_t idbuf[1024]; X+ X+ static int format_type; X+ static int format_head; X+ static int format_cylin; X+ static char format_sectors[] = { X+ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18 X+ }; /* data base for interleave */ X+ static int FormatError; X+ #endif X+ X int fd_dmachan; X static int fd_skip; X static int fd_state; X*************** X*** 318,323 **** X--- 340,358 ---- X return (0); X } X X+ int X+ in_fdcr() X+ { X+ return inb(fdc+fdsts); X+ } X+ X+ out_fdcr(x) X+ int x; X+ { X+ outb(fdc+fdsts,x); X+ return (0); X+ } X+ X static fdopenf; X /****************************************************************************/ X /* fdopen/fdclose */ X*************** X*** 329,335 **** X int unit = FDUNIT(minor(dev)); X /*int type = FDTYPE(minor(dev));*/ X int s; X! X fdopenf = 1; X /* check bounds */ X if (unit >= NFD) return(ENXIO); X--- 364,372 ---- X int unit = FDUNIT(minor(dev)); X /*int type = FDTYPE(minor(dev));*/ X int s; X! #if 0 X! if (fdopenf == 1) return(EBUSY); X! #endif X fdopenf = 1; X /* check bounds */ X if (unit >= NFD) return(ENXIO); X*************** X*** 342,347 **** X--- 379,385 ---- X fdclose(dev, flags) X dev_t dev; X { X+ fdopenf = 0; X return(0); X } X X*************** X*** 434,449 **** X unsigned long blknum; X struct fd_type *ft; X X! #ifdef FDTEST X printf("state %d, unit %d, dr %d|",fd_state,unit,fd_drive); X #endif X- X if (!fdopenf) return; X! dp = &fd_unit[fd_drive].head; X! bp = dp->b_actf; X! read = bp->b_flags & B_READ; X! /*ft = &fd_types[FDTYPE(bp->b_dev)];*/ -- masuda@rokugo.co.jp 増田佳泰@六合システム電子工業 ますだよしひろ@ろくごう瘢雹しすてむでんしこう瘢雹ぎょう瘢雹