Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

floppy.h

Go to the documentation of this file.
00001 // See the end of this file for license information.
00002 
00003 #ifndef TORSION_FLOPPY_H
00004 #define TORSION_FLOPPY_H
00005 
00006 #include "dma.h"
00007 #include "irq.h"
00008 #include "blockdev.h"
00009 #include "semaphore.h"
00010 #include "timer.h"
00011 #include "sched.h"
00012 
00013 class Floppy;
00014 extern Floppy* floppy;
00015 
00018 
00019 class Floppy : public Block_device {
00020 protected:
00021   static const Size BLOCK_SIZE = 512;
00022   DMA_buffer buffer;      
00023   bool disk_change;
00024   unsigned char status[7];
00025   unsigned char status_size;
00026   unsigned char sr0;
00027   unsigned char current_track;    
00028   Int_handler handler;      
00029 
00030 public:
00031   Semaphore operation_lock;   
00032   Timer_callback motor_kill_callback; 
00033   bool motor_on;      
00034 
00036   virtual void
00037   init();
00038   
00040   virtual void
00041   deinit();
00042 
00044   void
00045   reset();
00046 
00048   void
00049   send_byte(unsigned short int byte);
00050 
00052   short int
00053   get_byte();
00054 
00057   bool
00058   wait_for_op(bool sense_interrupt_status);
00059 
00061   bool
00062   seek(unsigned char track);
00063 
00065   void
00066   recalibrate();
00067 
00069   void
00070   turn_motor_on();
00071 
00073   void
00074   turn_motor_off();
00075 
00077   virtual bool
00078   read_block(unsigned block, void* data);
00079   
00081   virtual bool
00082   write_block(unsigned block, void* data);
00083 
00086   bool
00087   read_write(unsigned block, void* data, bool read);
00088 
00090   void
00091   print();
00092 };
00093 
00094 bool
00095 really_turn_motor_off(void* floppy_void_ptr);
00096 
00098 inline bool
00099 floppy_interrupt_handler();
00100 
00102 const unsigned DG144_HEADS = 2;   
00103 const unsigned DG144_TRACKS = 80; 
00104 const unsigned DG144_SPT = 18;    
00105 const unsigned DG144_GAP3FMT = 0x54;  
00106 const unsigned DG144_GAP3RW = 0x1b; 
00107 
00108 const unsigned DG168_HEADS = 2;   
00109 const unsigned DG168_TRACKS = 80; 
00110 const unsigned DG168_SPT = 21;    
00111 const unsigned DG168_GAP3FMT = 0x0c;  
00112 const unsigned DG168_GAP3RW = 0x1c; 
00113 
00115 const unsigned FDC_DOR = 0x3f2;   
00116 const unsigned FDC_MSR = 0x3f4;   
00117 const unsigned FDC_DRS = 0x3f4;   
00118 const unsigned FDC_DATA = 0x3f5;  
00119 const unsigned FDC_DIR = 0x3f7;   
00120 const unsigned FDC_CCR = 0x3f7;   
00121 
00123 const unsigned CMD_SPECIFY = 0x03;  
00124 const unsigned CMD_WRITE = 0xc5;  
00125 const unsigned CMD_READ = 0xe6;   
00126 const unsigned CMD_RECAL = 0x07;  
00127 const unsigned CMD_SENSEI = 0x08; 
00128 const unsigned CMD_FORMAT = 0x4d; 
00129 const unsigned CMD_SEEK = 0x0f;   
00130 const unsigned CMD_VERSION = 0x10;  
00131 
00132 #endif
00133 
00134 /* Torsion Operating System, Copyright (C) 2000-2004 Dan Helfman
00135  *
00136  * This program is free software; you can redistribute it and/or modify it
00137  * under the terms of the GNU General Public License as published by the
00138  * Free Software Foundation; either version 2 of the License, or (at your
00139  * option) any later version.
00140  * 
00141  * This program is distributed in the hope that it will be useful, but
00142  * WITHOUT ANY WARRANTY; without even the implied warranty of
00143  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00144  * General Public License for more details (in the COPYING file).
00145  * 
00146  * You should have received a copy of the GNU General Public License along
00147  * with this program; if not, write to the Free Software Foundation, Inc.,
00148  * 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00149  */

Torsion Operating System, Copyright (C) 2000-2004 Dan Helfman