00001 /* 00002 ** idesrv.h for in /root/research/lseosr2/include/lseos 00003 ** 00004 ** Copyright (c)2004 Julien Quintard 00005 ** Login <quinta_j@epita.fr> 00006 ** 00007 ** Started on Sat Feb 14 14:57:22 2004 Julien Quintard 00008 ** Last update Mon Dec 6 12:23:07 2004 Vianney Rancurel 00009 */ 00010 #ifndef __IDEVAR_H__ 00011 #define __IDEVAR_H__ 1 00012 #include <libc.h> 00013 00014 #undef DEBUG_IDE 00015 00016 /* 00017 * ide constants values 00018 */ 00019 00020 #define IDE_DEV1 0x1 00021 #define IDE_DEV2 0x2 00022 #define IDE_DEV3 0x3 00023 #define IDE_DEV4 0x4 00024 00025 #define ATA_TIMEOUT 32000 00026 00027 #define ATAPI_MAGIC_LSB 0x14 00028 #define ATAPI_MAGIC_MSB 0xeb 00029 00030 #define ATA_SECTOR_SIZE 0x200 00031 #define ATA_BLOCK_SIZE ATA_SECTOR_SIZE 00032 00033 /* 00034 * ide syscalls 00035 */ 00036 00037 #define SYSIDE_GETDRIVE 0x1 00038 #define SYSIDE_READ 0x2 00039 #define SYSIDE_WRITE 0x3 00040 00041 /* 00042 * command status codes 00043 */ 00044 00045 #define ATA_CMD_EBSY 0x1 /* busy bit set */ 00046 #define ATA_CMD_EERR 0x2 /* error bit set */ 00047 #define ATA_CMD_EDRQ 0x3 /* drq bit set */ 00048 #define ATA_CMD_ETMODE 0x4 /* unknown transfer mode */ 00049 #define ATA_CMD_EPMODE 0x5 /* unknown pio mode */ 00050 #define ATA_CMD_ENSL 0x6 /* no sector left */ 00051 #define ATA_CMD_EMSL 0x7 /* more sectors left */ 00052 #define ATA_CMD_EBADREQ 0x8 /* bad request */ 00053 00054 typedef struct s_device 00055 { 00056 u_int8_t d_unit; 00057 char d_id; 00058 u_int8_t d_type; 00059 u_int8_t d_removable; 00060 u_int8_t d_dma; 00061 char d_model[41]; 00062 u_int32_t d_sectors; 00063 u_int32_t d_dev; 00064 } t_device; 00065 00066 typedef struct s_ata_cmd 00067 { 00068 u_int32_t cmd_command; 00069 u_int32_t cmd_offset; 00070 u_int16_t cmd_count; 00071 u_int16_t cmd_cylinder; 00072 u_int16_t cmd_head; 00073 u_int16_t cmd_sector; 00074 u_int32_t cmd_lba; 00075 void *cmd_buffer; 00076 u_int16_t cmd_transfered; 00077 } t_ata_cmd; 00078 00079 typedef struct s_ata_chs 00080 { 00081 u_int16_t chs_heads; 00082 u_int16_t chs_cylinders; 00083 u_int16_t chs_spt; 00084 } t_ata_chs; 00085 00086 typedef struct s_ide_drv 00087 { 00088 00089 #define ATA_MASTER 0x00 00090 #define ATA_SLAVE 0x01 00091 00092 u_int8_t d_unit; 00093 00094 char d_id; 00095 00096 #define ATA_STATE_NP 0x00 00097 #define ATA_STATE_IDLE 0x01 00098 #define ATA_STATE_WORK 0x02 00099 00100 u_int8_t d_state; 00101 00102 #define ATA_TYPE_NONE 0x00 00103 #define ATA_TYPE_UNKNOWN 0x01 00104 #define ATA_TYPE_ATA 0x02 00105 #define ATA_TYPE_ATAPI 0x03 00106 00107 u_int8_t d_type; 00108 00109 u_int8_t d_removable; 00110 00111 #define ATA_MODE_NONE 0x00 00112 #define ATA_MODE_PIO16 0x01 00113 #define ATA_MODE_PIO32 0x02 00114 00115 u_int8_t d_mode; 00116 00117 #define ATA_DMA_DISABLE 0x0 00118 #define ATA_DMA_ENABLE 0x1 00119 00120 u_int8_t d_dma; 00121 00122 #define ATA_TRANS_NONE 0x00 00123 #define ATA_TRANS_LBA 0x01 00124 #define ATA_TRANS_RECHS 0x02 00125 #define ATA_TRANS_LARGE 0x03 00126 #define ATA_TRANS_UNKNOWN 0x04 00127 00128 u_int8_t d_trans; 00129 00130 u_int16_t d_blksize; 00131 00132 u_int8_t d_dma_queue; 00133 u_int16_t d_queue_depth; 00134 u_int16_t d_mw_dma_cycle_time; 00135 00136 int16_t d_ata_version; 00137 int16_t d_pio_mode; 00138 int16_t d_ultra_dma_mode; 00139 int16_t d_dma_mode; 00140 00141 t_ata_chs d_lchs; 00142 t_ata_chs d_pchs; 00143 00144 char d_model[41]; 00145 char d_serial[21]; 00146 char d_firmware[9]; 00147 00148 u_int32_t d_sectors; 00149 00150 u_int32_t d_dev; 00151 00152 /* 00153 * to set in each task, cause shared memory 00154 */ 00155 00156 void *d_parent_ctrl; 00157 } t_ide_drv; 00158 00159 typedef struct s_ide_ctrl 00160 { 00161 00162 #define ATA_PRIMARY 0x01 00163 #define ATA_SECONDARY 0x02 00164 00165 u_int8_t c_unit; 00166 00167 #define ATA_P_IOADDR1 0x1f0 00168 #define ATA_S_IOADDR1 0x170 00169 00170 u_int16_t c_ioaddr1; 00171 00172 #define ATA_P_IOADDR2 0x3f0 00173 #define ATA_S_IOADDR2 0x370 00174 00175 u_int16_t c_ioaddr2; 00176 00177 #define ATA_P_IRQ 0x0e 00178 #define ATA_S_IRQ 0x0f 00179 00180 u_int8_t c_irq; 00181 00182 t_ide_drv c_master; 00183 t_ide_drv c_slave; 00184 } t_ide_ctrl; 00185 00186 typedef struct s_ide_info 00187 { 00188 __cpu_simple_lock_t i_lock; 00189 pid_t i_sys_pid; 00190 pid_t i_pri_pid; 00191 pid_t i_sec_pid; 00192 00193 u_int8_t i_hd_cnt; 00194 u_int8_t i_cd_cnt; 00195 } t_ide_info; 00196 00197 typedef struct s_ide 00198 { 00199 t_ide_ctrl i_primary; 00200 t_ide_ctrl i_secondary; 00201 00202 t_ide_info i_info; 00203 00204 /* t_ide_queue i_queue; */ 00205 } t_ide; 00206 00207 /* 00208 * main.c 00209 */ 00210 00211 /* PROTO main.c */ 00212 #ifdef KERNEL 00213 /* main.c */ 00214 #endif /* KERNEL */ 00215 #endif