home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / os / linux / 23197 < prev    next >
Encoding:
Internet Message Format  |  1993-01-08  |  13.4 KB

  1. Path: sparky!uunet!mcsun!Germany.EU.net!urmel.informatik.rwth-aachen.de!kaa!heiko
  2. From: heiko@kaa.informatik.rwth-aachen.de (Heiko Schroeder)
  3. Newsgroups: comp.os.linux
  4. Subject: nonstandard floppy formats for linux
  5. Date: 8 Jan 93 10:02:48 GMT
  6. Organization: Rechnerbetrieb Informatik - RWTH Aachen
  7. Lines: 392
  8. Message-ID: <heiko.726487368@kaa>
  9. NNTP-Posting-Host: kaa.informatik.rwth-aachen.de
  10.  
  11. Hi,
  12.  
  13. for all of you who are not satisfied with 1.44MB on 3.5" floppy disk:
  14.  
  15. I patched the linux kernel so that I can use the formats known from the
  16. MS-DOS program fdformat. The formats are established with new device numbers,
  17. so that you can create dev-entries for them. Autodetection works, but there's
  18. one (minor) problem: some of the formats use more than 80 tracks, this is
  19. not detectable with reasonable effort (one would have to try to read the tracks
  20. 81,82,83 to find out if they exist, but I think, that's to much to slow).
  21. So I used a new variable in the main Makefile to decide which number of 
  22. tracks the autodetection routine should assume. You have to edit the Makefile
  23. to change this (I use FD_detect_83).
  24.  
  25. The new formats supported are:
  26. 3,5": 21 sectors, 80 tracks, 1.68MB, device 11
  27.       21 sectors, 82 tracks, 1.72MB, device 15
  28.       21 sectors, 83 tracks, 1.74MB, device 19
  29.       10 sectors, 80 tracks, 800k, device 9
  30.       10 sectors, 82 tracks, 820k, device 13
  31.       10 sectors, 83 tracks, 830k, device 17
  32. 5,25" HD:
  33.       18 sectors, 80 tracks, 1.44MB, device 10
  34.       18 sectors, 82 tracks, 1.48MB, device 14
  35.       18 sectors, 83 tracks, 1.59MB, device 18
  36.       10 sectors, 40 tracks, 400k, device 8
  37.       10 sectors, 41 tracks, 410k, device 12
  38.       10 sectors, 42 tracks, 420k, device 16
  39.  
  40. Minor device numbers are calculated as ususal:
  41.    device * 4 + drive number
  42. So a 1.74MB format for drive 0 would be set with
  43.   mknod /dev/fd0h1743 b 2 76
  44.  
  45. It works fine on my system and on a few other system, too, but I can't
  46. guarantee that it will work on other systems (but I think it should).
  47.  
  48. The files Makefile, boot/head.S and kernel/blk_drv/floppy.c are affected
  49. by the patch, so it should work with earlier versions of linux, but some
  50. editing may be needed.
  51. Here is the patch (for linux 0.99pl2):
  52. -------------------------------------------------------------------------
  53. *** Makefile.old    Fri Jan  1 21:45:57 1993
  54. --- Makefile    Thu Jan  7 18:00:38 1993
  55. ***************
  56. *** 71,80 ****
  57.   SOUND_SUPPORT = -DKERNEL_SOUNDCARD -DDSP_BUFFSIZE=16384 -DSBC_IRQ=7 -DPAS_IRQ=5
  58.   
  59.   #
  60.   # standard CFLAGS
  61.   #
  62.   
  63. ! CFLAGS = -Wall -O6 -fomit-frame-pointer
  64.   
  65.   ifdef CONFIG_M486
  66.   CFLAGS := $(CFLAGS) -m486
  67. --- 71,92 ----
  68.   SOUND_SUPPORT = -DKERNEL_SOUNDCARD -DDSP_BUFFSIZE=16384 -DSBC_IRQ=7 -DPAS_IRQ=5
  69.   
  70.   #
  71. + # As we can't detect the number of tracks on a floppy disk with in
  72. + # reasonable time, there is variable, which tells the autodetect routine
  73. + # how many tracks it should assume. This aplies only to the nonstandard
  74. + # formats!
  75. + #     FD_detect_82     assume 82 tracks
  76. + #     FD_detect_83     assume 83 tracks
  77. + #     (none)           assume 80 tracks, default
  78. + #
  79. + FD_DETECT=-DFD_detect_83
  80. + #
  81.   # standard CFLAGS
  82.   #
  83.   
  84. ! CFLAGS = -Wall -O6 -fomit-frame-pointer $(FD_DETECT) 
  85.   
  86.   ifdef CONFIG_M486
  87.   CFLAGS := $(CFLAGS) -m486
  88. *** boot/head.S.old    Fri Jan  1 21:45:58 1993
  89. --- boot/head.S    Thu Jan  7 14:37:31 1993
  90. ***************
  91. *** 215,224 ****
  92.    * floppy_track_buffer is used to buffer one track of floppy data: it
  93.    * has to be separate from the tmp_floppy area, as otherwise a single-
  94.    * sector read/write can mess it up. It can contain one full track of
  95. !  * data (18*2*512 bytes).
  96.    */
  97.   _floppy_track_buffer:
  98. !     .fill 512*2*18,1,0
  99.   
  100.   /* This is the default interrupt "handler" :-) */
  101.   int_msg:
  102. --- 215,224 ----
  103.    * floppy_track_buffer is used to buffer one track of floppy data: it
  104.    * has to be separate from the tmp_floppy area, as otherwise a single-
  105.    * sector read/write can mess it up. It can contain one full track of
  106. !  * data (21*2*512 bytes).
  107.    */
  108.   _floppy_track_buffer:
  109. !     .fill 512*2*21,1,0
  110.   
  111.   /* This is the default interrupt "handler" :-) */
  112.   int_msg:
  113. *** kernel/blk_drv/floppy.c.old    Fri Dec 11 11:15:23 1992
  114. --- kernel/blk_drv/floppy.c    Thu Jan  7 14:37:45 1993
  115. ***************
  116. *** 103,115 ****
  117.    * Maximum disk size (in kilobytes). This default is used whenever the
  118.    * current disk size is unknown.
  119.    */
  120. ! #define MAX_DISK_SIZE 1440
  121.   
  122.   /*
  123.    * Maximum number of sectors in a track buffer. Track buffering is disabled
  124.    * if tracks are bigger.
  125.    */
  126. ! #define MAX_BUFFER_SECTORS 18
  127.   
  128.   /*
  129.    * The DMA channel used by the floppy controller cannot access data at
  130. --- 103,115 ----
  131.    * Maximum disk size (in kilobytes). This default is used whenever the
  132.    * current disk size is unknown.
  133.    */
  134. ! #define MAX_DISK_SIZE 1743
  135.   
  136.   /*
  137.    * Maximum number of sectors in a track buffer. Track buffering is disabled
  138.    * if tracks are bigger.
  139.    */
  140. ! #define MAX_BUFFER_SECTORS 21
  141.   
  142.   /*
  143.    * The DMA channel used by the floppy controller cannot access data at
  144. ***************
  145. *** 135,171 ****
  146.    * be self-explanatory.
  147.    */
  148.   static struct floppy_struct floppy_type[] = {
  149. !     {    0, 0,0, 0,0,0x00,0x00,0x00,0x00,NULL },    /* no testing */
  150. !     {  720, 9,2,40,0,0x2A,0x02,0xDF,0x50,NULL },    /* 360kB PC diskettes */
  151. !     { 2400,15,2,80,0,0x1B,0x00,0xDF,0x54,NULL },    /* 1.2 MB AT-diskettes */
  152. !     {  720, 9,2,40,1,0x2A,0x02,0xDF,0x50,NULL },    /* 360kB in 720kB drive */
  153. !     { 1440, 9,2,80,0,0x2A,0x02,0xDF,0x50,NULL },    /* 3.5" 720kB diskette */
  154. !     {  720, 9,2,40,1,0x23,0x01,0xDF,0x50,NULL },    /* 360kB in 1.2MB drive */
  155. !     { 1440, 9,2,80,0,0x23,0x01,0xDF,0x50,NULL },    /* 720kB in 1.2MB drive */
  156. !     { 2880,18,2,80,0,0x1B,0x00,0xCF,0x6C,NULL },    /* 1.44MB diskette */
  157.   };
  158.   
  159.   /*
  160. !  * Auto-detection. Each drive type has a pair of formats which are
  161.    * used in succession to try to read the disk. If the FDC cannot lock onto
  162.    * the disk, the next format is tried. This uses the variable 'probing'.
  163.    */
  164. ! static struct floppy_struct floppy_types[] = {
  165. !     {  720, 9,2,40,0,0x2A,0x02,0xDF,0x50,"360k/PC" }, /* 360kB PC diskettes */
  166. !     {  720, 9,2,40,0,0x2A,0x02,0xDF,0x50,"360k/PC" }, /* 360kB PC diskettes */
  167. !     { 2400,15,2,80,0,0x1B,0x00,0xDF,0x54,"1.2M" },      /* 1.2 MB AT-diskettes */
  168. !     {  720, 9,2,40,1,0x23,0x01,0xDF,0x50,"360k/AT" }, /* 360kB in 1.2MB drive */
  169. !     { 1440, 9,2,80,0,0x2A,0x02,0xDF,0x50,"720k" },      /* 3.5" 720kB diskette */
  170. !     { 1440, 9,2,80,0,0x2A,0x02,0xDF,0x50,"720k" },      /* 3.5" 720kB diskette */
  171. !     { 2880,18,2,80,0,0x1B,0x00,0xCF,0x6C,"1.44M" },      /* 1.44MB diskette */
  172. !     { 1440, 9,2,80,0,0x2A,0x02,0xDF,0x50,"720k/AT" }, /* 3.5" 720kB diskette */
  173. ! };
  174.   
  175.   /* Auto-detection: Disk type used until the next media change occurs. */
  176.   struct floppy_struct *current_type[4] = { NULL, NULL, NULL, NULL };
  177.   
  178.   /* This type is tried first. */
  179. ! struct floppy_struct *base_type[4];
  180.   
  181.   /*
  182.    * User-provided type information. current_type points to
  183. --- 135,193 ----
  184.    * be self-explanatory.
  185.    */
  186.   static struct floppy_struct floppy_type[] = {
  187. !     {    0, 0,0, 0,0,0x00,0x00,0x00,0x00,NULL },    /*  0 no testing */
  188. !     {  720, 9,2,40,0,0x2A,0x02,0xDF,0x50,"360k PC" },    /*  1 360kB PC diskettes */
  189. !     { 2400,15,2,80,0,0x1B,0x00,0xDF,0x54,"1.2M" },    /*  2 1.2 MB AT-diskettes */
  190. !     {  720, 9,2,40,1,0x2A,0x02,0xDF,0x50,"D360" },    /*  3 360kB in 720kB drive */
  191. !     { 1440, 9,2,80,0,0x2A,0x02,0xDF,0x50,"720k"},    /*  4 3.5" 720kB diskette */
  192. !     {  720, 9,2,40,1,0x23,0x01,0xDF,0x50,"h360" },    /*  5 360kB in 1.2MB drive */
  193. !     { 1440, 9,2,80,0,0x23,0x01,0xDF,0x50,"h720" },    /*  6 720kB in 1.2MB drive */
  194. !     { 2880,18,2,80,0,0x1B,0x00,0xCF,0x6C,"1.44M" },    /*  7 1.44MB diskette */
  195. !     {  800,10,2,40,1,0x25,0x02,0xDF,0x2E,"h400" },    /*  8 400k 5.25" */
  196. !     { 1600,10,2,80,0,0x25,0x01,0xDF,0x2E,"H800" },    /*  9 800k 3.5" */
  197. !     { 2880,18,2,80,0,0x25,0x00,0xDF,0x02,"h1440" }, /* 10 1.44MB 5.25" */
  198. !     { 3360,21,2,80,0,0x25,0x00,0xDF,0x0C,"H1680" }, /* 11 1.68MB 3.5" */
  199. !     {  820,10,2,41,1,0x25,0x02,0xDF,0x2E,"h410" },    /* 12 410k 5.25" */
  200. !     { 1640,10,2,82,0,0x25,0x01,0xDF,0x2E,"H820" },    /* 13 820k 3.5" */
  201. !     { 2952,18,2,82,0,0x25,0x00,0xDF,0x02,"h1476" },    /* 14 1.48MB 5.25" */
  202. !     { 3444,21,2,82,0,0x25,0x00,0xDF,0x0C,"H1722" },    /* 15 1.72MB 3.5" */
  203. !     {  840,10,2,42,1,0x25,0x02,0xDF,0x2E,"h420" },    /* 16 420k 5.25" */
  204. !     { 1660,10,2,83,0,0x25,0x01,0xDF,0x2E,"H830" },    /* 17 830k 3.5" */
  205. !     { 2988,18,2,83,0,0x25,0x00,0xDF,0x02,"h1494" },    /* 18 1.49MB 5.25" */
  206. !     { 3486,21,2,83,0,0x25,0x00,0xDF,0x0C,"H1743" },    /* 19 1.74MB 3.5" */
  207.   };
  208.   
  209.   /*
  210. !  * Auto-detection. Each drive type has four formats which are
  211.    * used in succession to try to read the disk. If the FDC cannot lock onto
  212.    * the disk, the next format is tried. This uses the variable 'probing'.
  213.    */
  214. ! static int floppy_types[] = {
  215. ! #ifdef FD_detect_82
  216. !      1,  1,  1,  1,  /* 5.25" DD drive */
  217. !     14,  2, 12,  5,  /* 5.25" HD drive */
  218. !     13,  4, 13,  4,  /* 3.5" DD drive */
  219. !     15,  7, 13,  4   /* 3.5" HD drive */
  220. ! #else
  221. ! #ifdef FD_detect_83
  222. !      1,  1,  1,  1,
  223. !     18,  2, 16,  5,
  224. !     17,  4, 17,  4,
  225. !     19,  7, 17,  4
  226. ! #else   /* 80 tracks */
  227. !      1,  1,  1,  1,
  228. !     10,  2,  8,  5,
  229. !      9,  4,  9,  4,
  230. !     11,  7,  9,  4
  231. ! #endif
  232. ! #endif
  233. !     };
  234.   
  235.   /* Auto-detection: Disk type used until the next media change occurs. */
  236.   struct floppy_struct *current_type[4] = { NULL, NULL, NULL, NULL };
  237.   
  238.   /* This type is tried first. */
  239. ! int *base_type[4];
  240.   
  241.   /*
  242.    * User-provided type information. current_type points to
  243. ***************
  244. *** 181,187 ****
  245.        720, 720, 720, 720,
  246.        360, 360, 360, 360,
  247.        720, 720, 720, 720,
  248. !     1440,1440,1440,1440
  249.   };
  250.   
  251.   /*
  252. --- 203,221 ----
  253.        720, 720, 720, 720,
  254.        360, 360, 360, 360,
  255.        720, 720, 720, 720,
  256. !     1440,1440,1440,1440,
  257. !      400, 400, 400, 400,
  258. !      800, 800, 800, 800,
  259. !     1440,1440,1440,1440,
  260. !     1680,1680,1680,1680,
  261. !      410, 410, 410, 410,
  262. !      820, 820, 820, 820,
  263. !     1476,1476,1476,1476,
  264. !     1722,1722,1722,1722,
  265. !      420, 420, 420, 420,
  266. !      830, 830, 830, 830,
  267. !     1494,1494,1494,1494,
  268. !     1743,1743,1743,1743
  269.   };
  270.   
  271.   /*
  272. ***************
  273. *** 899,921 ****
  274.   
  275.   static void setup_format_params(void)
  276.   {
  277. !     unsigned char *here = (unsigned char *) tmp_floppy_area;
  278. !     int count,head_shift,track_shift,total_shift;
  279.   
  280.       /* allow for about 30ms for data transport per track */
  281.       head_shift  = floppy->sect / 6;
  282.       /* a ``cylinder'' is two tracks plus a little stepping time */
  283.       track_shift = 2 * head_shift + 1; 
  284. !     /* count backwards */
  285. !     total_shift = floppy->sect - 
  286. !     ((track_shift * track + head_shift * head) % floppy->sect);
  287. !     /* XXX: should do a check to see this fits in tmp_floppy_area!! */
  288. !     for (count = 0; count < floppy->sect; count++) {
  289. !     *here++ = track;
  290. !     *here++ = head;
  291. !     *here++ = 1 + (( count + total_shift ) % floppy->sect);
  292. !     *here++ = 2; /* 512 bytes */
  293.       }
  294.   }
  295.   
  296. --- 933,970 ----
  297.   
  298.   static void setup_format_params(void)
  299.   {
  300. !     struct fparm {
  301. !         unsigned char track,head,sect,size;
  302. !         } *here = (void *)tmp_floppy_area;
  303. !     int il,n,count,head_shift,track_shift;
  304.   
  305.       /* allow for about 30ms for data transport per track */
  306.       head_shift  = floppy->sect / 6;
  307.       /* a ``cylinder'' is two tracks plus a little stepping time */
  308.       track_shift = 2 * head_shift + 1; 
  309. !     /* position of logical sector 1 on this track */
  310. !     n = (track_shift * track + head_shift * head) % floppy->sect;
  311. !     /* determine interleave */
  312. !     il = (floppy->sect-
  313. !         floppy_type[base_type[format_req.device & 3][1]].sect)>2?2:1;
  314. !     /* initialize field */ 
  315. !     for (count = 0; count < floppy->sect; ++count) {
  316. !        here[count].track = track;
  317. !        here[count].head = head;
  318. !        here[count].sect = 0;
  319. !        here[count].size = 2;
  320. !        }
  321. !     /* place logical sectors */
  322. !     for (count = 1; count <= floppy->sect; ++count) {
  323. !         here[n].sect = count;
  324. !         n = (n+il) % floppy->sect;
  325. !         if (here[n].sect) { /* sector busy, find next free sector */
  326. !            ++n;
  327. !            if (n>=floppy->sect) {
  328. !              n-=floppy->sect;
  329. !              while (here[n].sect) ++n;
  330. !              }
  331. !         }
  332.       }
  333.   }
  334.   
  335. ***************
  336. *** 954,965 ****
  337.       else { /* Auto-detection */
  338.           if ((floppy = current_type[device & 3]) == NULL) {
  339.               probing = 1;
  340. !             if ((floppy = base_type[device & 3]) ==
  341. !                 NULL) {
  342.                   request_done(0);
  343.                   goto repeat;
  344.               }
  345. !             floppy += CURRENT_ERRORS & 1;
  346.           }
  347.       }
  348.       if (format_status != FORMAT_BUSY) {
  349. --- 1003,1014 ----
  350.       else { /* Auto-detection */
  351.           if ((floppy = current_type[device & 3]) == NULL) {
  352.               probing = 1;
  353. !             if (base_type[device & 3] == NULL) {
  354. !                 floppy = NULL;
  355.                   request_done(0);
  356.                   goto repeat;
  357.               }
  358. !             floppy = &floppy_type[base_type[device & 3][CURRENT_ERRORS & 3]];
  359.           }
  360.       }
  361.       if (format_status != FORMAT_BUSY) {
  362. ***************
  363. *** 1144,1156 ****
  364.   inb_p(0x71); \
  365.   })
  366.   
  367. ! static struct floppy_struct *find_base(int drive,int code)
  368.   {
  369. !     struct floppy_struct *base;
  370.   
  371.       if (code > 0 && code < 5) {
  372. !         base = &floppy_types[(code-1)*2];
  373. !         printk("fd%d is %s",drive,base->name);
  374.           return base;
  375.       }
  376.       printk("fd%d is unknown type %d",drive,code);
  377. --- 1193,1205 ----
  378.   inb_p(0x71); \
  379.   })
  380.   
  381. ! static int *find_base(int drive,int code)
  382.   {
  383. !     int *base;
  384.   
  385.       if (code > 0 && code < 5) {
  386. !         base = &floppy_types[(code-1)*4];
  387. !         printk("fd%d is %s",drive,floppy_type[base[1]].name);
  388.           return base;
  389.       }
  390.       printk("fd%d is unknown type %d",drive,code);
  391. ------------------------------------------------------------------------
  392. That`s ist. I hobe it is usefull for some of you.
  393.  
  394. CU
  395.    Heiko
  396. --
  397. PS: Please excuse my english as it is not my native language.
  398. (heiko@pool.informatik.rwth-aachen.de)
  399.  
  400.