Fork me on GitHub

root/include/fiwix/floppy.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


   1 /*
   2  * fiwix/include/fiwix/floppy.h
   3  *
   4  * Copyright 2018, Jordi Sanfeliu. All rights reserved.
   5  * Distributed under the terms of the Fiwix License.
   6  */
   7 
   8 #ifndef _FIWIX_FLOPPY_H
   9 #define _FIWIX_FLOPPY_H
  10 
  11 #include <fiwix/fs.h>
  12 #include <fiwix/sigcontext.h>
  13 
  14 #define FLOPPY_IRQ      6
  15 #define FLOPPY_DMA      2       /* DMA channel */
  16 
  17 #define FDC_MAJOR       2       /* fdd major number */
  18 
  19 #define FDC_SECTSIZE    512     /* sector size (in bytes) */
  20 #define FDC_TR_DEFAULT  0       /* timer reason is IRQ */
  21 #define FDC_TR_MOTOR    1       /* timer reason is motor on */
  22 
  23 #define FDC_SRA         0x3F0   /* Status Register A */
  24 #define FDC_SRB         0x3F1   /* Status Register B */
  25 #define FDC_DOR         0x3F2   /* Digital Output Register */
  26 #define FDC_MSR         0x3F4   /* Main Status Register */
  27 #define FDC_DATA        0x3F5   /* command/data register */
  28 #define FDC_DIR         0x3F7   /* Digital Input Register */
  29 #define FDC_CCR         0x3F7   /* Configuration Control Register */
  30 
  31 #define FDC_ENABLE      0x04    /* bit #2 FDC enabled (normal op) */
  32 #define FDC_DMA_ENABLE  0x08    /* bit #3 DMA enabled */
  33 #define FDC_DRIVE0      0x10    /* motor on for the first drive, the rest will
  34                                  * be calculated by left-shifting this value
  35                                  * with 'current_fdd'.
  36                                  */
  37 
  38 #define FDC_DIO         0x40    /* bit #6 DIO I/O direction */
  39 #define FDC_RQM         0x80    /* bit #7 RQM is ready for I/O */
  40 
  41 #define MAX_FDC_RESULTS 7
  42 #define MAX_FDC_ERR     5
  43 
  44 #define FDC_RESET       0xFF    /* reset indicador */
  45 #define FDC_READ        0xE6
  46 #define FDC_WRITE       0xC5
  47 #define FDC_VERSION     0x10
  48 #define FDC_FORMAT_TRK  0x4D
  49 #define FDC_RECALIBRATE 0x07
  50 #define FDC_SENSEI      0x08
  51 #define FDC_SPECIFY     0x03
  52 #define FDC_SEEK        0x0F
  53 #define FDC_LOCK        0x14
  54 #define FDC_PARTID      0x18
  55 
  56 #define ST0             0x00    /* Status Register 0 */
  57 #define ST1             0x01    /* Status Register 1 */
  58 #define ST2             0x02    /* Status Register 2 */
  59 
  60 #define ST0_IC          0xC0    /* bits #7 and #6 interrupt code */
  61 #define ST0_SE          0x20    /* bit #5 successful implied seek */
  62 #define ST0_RECALIBRATE ST0_SE  /* bit #5 successful FDC_RECALIBRATE */
  63 #define ST0_SEEK        ST0_SE  /* bit #5 successful FDC_SEEK */
  64 #define ST0_UC          0x10    /* bit #4 unit needs check (fault) */
  65 #define ST0_NR          0x8     /* bit #3 drive not ready */
  66 
  67 #define ST1_NW          0x02    /* bit #1 not writable */
  68 
  69 #define ST_PCN          0x01    /* present cylinder */
  70 #define ST_CYL          0x03    /* cylinder returned */
  71 #define ST_HEAD         0x04    /* head returned */
  72 #define ST_SECTOR       0x05    /* sector returned */
  73 
  74 /* floppy disk drive type */
  75 struct fddt {
  76         short int size;         /* number of sectors */
  77         short int sizekb;       /* size in KB */
  78         char tracks;            /* number of tracks */
  79         char spt;               /* number of sectors per track */
  80         char heads;             /* number of heads */
  81         char gpl1;              /* GAP in READ/WRITE operations */
  82         char gpl2;              /* GAP in FORMAT TRACK operations */
  83         char rate;              /* data rate value */
  84         char spec;              /* SRT+HUT (StepRate + HeadUnload) Time */
  85         char hlt;               /* HLT (Head Load Time) */
  86         char *name;             /* unit name */
  87 };
  88 
  89 void irq_floppy(int, struct sigcontext *);
  90 void fdc_timer(unsigned int);
  91 
  92 int fdc_open(struct inode *, struct fd *);
  93 int fdc_close(struct inode *, struct fd *);
  94 int fdc_read(__dev_t, __blk_t, char *, int);
  95 int fdc_write(__dev_t, __blk_t, char *, int);
  96 int fdc_ioctl(struct inode *, int, unsigned long int);
  97 int fdc_lseek(struct inode *, __off_t);
  98 
  99 void floppy_init(void);
 100 
 101 #endif /* _FIWIX_FLOPPY_H */

/* [previous][next][first][last][top][bottom][index][help] */