Main Page   Modules   Alphabetical List   Data Structures   File List   Data Fields   Globals   Related Pages  

floppy.h

Go to the documentation of this file.
00001 /*!     \file include/kernel/floppy.h
00002  *      \brief Floppy disk driver header.
00003  *      \author Andrea Righi <drizzt@inwind.it>
00004  *      \date Last update: 2003-11-08
00005  *      \note Copyright (&copy;) 2003 Andrea Righi
00006  */
00007 
00008 #ifndef FLOPPY_H
00009 #define FLOPPY_H
00010 
00011 // --- Drive geometry for 1.44MB floppies ----------------------------- //
00012 
00013 #define FDC_SECTORS     18      //!< Sectors per track.
00014 #define FDC_HEADS       2       //!< Heads per track.
00015 #define FDC_TRACKS      80      //!< Tracks per disk.
00016 #define FDC_SECTOR_SIZE 512     //!< Bytes per sector.
00017 
00018 //! FDC motor spin-up time (msec).
00019 #define FDC_TIME_MOTOR_SPINUP   500
00020 
00021 //! FDC timeout to turn the motor off (msec).
00022 #define FDC_TIME_MOTOR_OFF      3000
00023 
00024 // --- Floppy I/O ports ----------------------------------------------- //
00025 
00026 #define FDC_DOR         0x3F2 //!< Digital Output Register.
00027 #define FDC_MSR         0x3F4 //!< Main Status Register (read).
00028 #define FDC_DSR         0x3F4 //!< Data Rate Select Register (write).
00029 #define FDC_DATA        0x3F5 //!< Data Register.
00030 #define FDC_DIR         0x3F7 //!< Digital Input Register.
00031 #define FDC_CCR         0x3F7 //!< Configuration Control Register.
00032 
00033 // --- Floppy Commands ------------------------------------------------ //
00034 
00035 #define CMD_SPECIFY     0x03    //!< Specify.
00036 #define CMD_WRITE       0xC5    //!< Write.
00037 #define CMD_READ        0xE6    //!< Read.
00038 #define CMD_RECAL       0x07    //!< Recalibrate.
00039 #define CMD_SENSEI      0x08    //!< Send a "sense interrupt status".
00040 #define CMD_FORMAT      0x4D    //!< Format a track.
00041 #define CMD_SEEK        0x0F    //!< Seek a track.
00042 #define CMD_VERSION     0x10    //!< Get the controller version.
00043 
00044 // --- Register values ------------------------------------------------ //
00045 
00046 //! The controller is busy.
00047 #define MSR_BUSY        0x10
00048 
00049 //! Floppy geometry structures.
00050 typedef struct floppy_struct
00051 {
00052         dword   size,   //!< # of sectors total.
00053                 spt,    //!< sectors per track.
00054                 heads,  //!< # of heads.
00055                 tracks; //!< # of tracks.
00056         byte    fmtgap, //!< gap3 while formatting.
00057                 rwgap,  //!< gap3 while reading/writing.
00058                 rate;   //!< data rate.
00059         char    *name;  //!< format name.
00060 } floppy_struct;
00061 
00062 // --- Prototypes ----------------------------------------------------- //
00063 
00064 void floppy_handler();
00065 void floppy_thread();
00066 bool init_floppy();
00067 void fdc_motor_on();
00068 void fdc_motor_off();
00069 void fdc_recalibrate();
00070 bool fdc_seek(int track);
00071 bool fdc_read(int block, byte *buffer, uint32_t count);
00072 bool fdc_write(int block, byte *buffer, uint32_t count);
00073 bool fdc_is_changed();
00074 
00075 #endif

Generated on Fri Feb 20 15:32:15 2004 for Minirighi by doxygen1.2.18