00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef __FLOPPY_H
00019 #define __FLOPPY_H
00020
00021 #include "core/kio.h"
00022 #include "core/kstdio.h"
00023 #include "common/kconst.h"
00024 #include "core/kasm.h"
00025
00026
00027 #define TIME_OUT 3
00028
00029 #define TRUE 1
00030 #define FALSE 0
00031 #define OK 0
00032
00033 #define MAX_FL_REQ 100
00034 #define MAX_RESULTS 16
00035 #define MAX_SECTOR 2880
00036
00037 #define DOR 0x3F2
00038 #define CTL_BUSY 0x10
00039 #define DIRECTION 0x40
00040 #define MASTER 0x80
00041
00042
00043 #define FDC_STATUS 0x3F4
00044 #define FDC_DATA 0x3F5
00045 #define FDC_RATE 0x3F7
00046
00047 #define DMA_ADDR 0x004
00048 #define DMA_TOP 0x081
00049 #define DMA_COUNT 0x005
00050 #define DMA_FLIPFLOP 0x00C
00051 #define DMA_MODE 0x00B
00052 #define DMA_INIT 0x00A
00053 #define DMA_RESET_VAL 0x06
00054
00055 #define ST0 0x00
00056 #define ST1 0x01
00057 #define ST2 0x02
00058 #define ST3 0x00
00059 #define ST_CYL 0x03
00060 #define ST_HEAD 0x04
00061 #define ST_SEC 0x05
00062 #define ST_PCN 0x01
00063
00064 #define NO_SECTOR 0
00065 #define NO_CYL (-1)
00066 #define NO_DENS 100
00067
00068
00069
00070
00071 #define ST0_BITS 0xF8
00072 #define TRANS_ST0 0x00
00073 #define SEEK_ST0 0x20
00074
00075
00076 #define BAD_SECTOR 0x05
00077 #define WRITE_PROTECT 0x02
00078
00079
00080 #define BAD_CYL 0x1F
00081
00082
00083 #define FDC_SEEK 0x0F
00084 #define FDC_READ 0xE6
00085 #define FDC_WRITE 0xC5
00086 #define FDC_SENSE 0x08
00087 #define FDC_RECALIBRATE 0x07
00088 #define FDC_SPECIFY 0x03
00089 #define FDC_READ_ID 0x4A
00090 #define FDC_FORMAT 0x4D
00091
00092 #define DMA_READ 0x46
00093 #define DMA_WRITE 0x4A
00094
00095
00096
00097
00098 #define SECTOR_SIZE 512
00099 #define SECTOR_SHIFT 9
00100
00101 #define ENABLE_DMA 0x0C
00102
00103 #define ERR_SEEK (-1)
00104 #define ERR_TRANSFER (-2)
00105 #define ERR_STATUS (-3)
00106 #define ERR_READ_ID (-4)
00107 #define ERR_RECALIBRATE (-5)
00108 #define ERR_DRIVE (-6)
00109 #define ERR_WR_PROTECT (-7)
00110 #define ERR_TIMEOUT (-8)
00111
00112 #define DTL 0xFF
00113 #define BASE_SECTOR 1
00114 #define SECTOR_SIZE_CODE 2
00115
00116
00117
00118 typedef struct
00119
00120 {
00121 unsigned r_count;
00122 long offset;
00123 long r_dma;
00124 int opcode;
00125 int pid;
00126 }request;
00127 extern request freqs[MAX_FL_REQ];
00128 extern volatile int no_req;
00129
00130 struct floppy {
00131 int fl_curcyl;
00132 int fl_hardcyl;
00133 int fl_cylinder;
00134 int fl_sector;
00135 int fl_head;
00136 char fl_calibration;
00137 };
00138
00139 void fdc_out(int val);
00140
00141 int startmotor();
00142
00143 void stopmotor();
00144 void dma_setup(request *req);
00145 int do_transfer(request *req);
00146 int perform_oper(request *req);
00147 int fdc_results();
00148 int recalibrate();
00149 int seek();
00150
00151 int reset();
00152 int transfer(request r);
00153 int wait_for_intr();
00154 void runFloppy();
00155 int addreq(request *r);
00156
00157 #endif