Line 1... |
Line 1... |
/*
|
/*
|
/////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////
|
//// ////
|
//// ////
|
//// Include file for OpenCores ATA Controller (OCIDEC) ////
|
//// Include file for OpenCores ATA Controller (OCIDEC) ////
|
//// ////
|
//// ////
|
//// File : oc_ata.h ////
|
//// File : ata.h ////
|
//// Function: c-include file ////
|
//// Function: c-include file ////
|
//// ////
|
//// ////
|
//// Authors: Richard Herveille (rherveille@opencores) ////
|
//// Authors: Richard Herveille (rherveille@opencores) ////
|
//// www.opencores.org ////
|
//// www.opencores.org ////
|
//// ////
|
//// ////
|
Line 42... |
Line 42... |
|
|
#ifndef __OC_ATA_H
|
#ifndef __OC_ATA_H
|
#define __OC_ATA_H
|
#define __OC_ATA_H
|
|
|
|
|
#define ATA_DEBUG
|
|
|
|
|
|
#define MAX_ATA_COMMANDS 100
|
|
|
|
|
|
#ifndef REG32
|
#ifndef REG32
|
#define REG32(adr) *((volatile unsigned int *)(adr))
|
#define REG32(adr) *((volatile unsigned long *)(adr))
|
#endif
|
#endif
|
|
|
|
|
|
typedef unsigned long basetype;
|
|
|
/* --- Register definitions --- */
|
/* --- Register definitions --- */
|
|
|
/* ----- Core Registers */
|
/* ----- Core Registers */
|
#define ATA_CTRL 0x00 /* Control register */
|
#define ATA_CTRL 0x00 /* Control register */
|
#define ATA_STAT 0x04 /* Status register */
|
#define ATA_STAT 0x04 /* Status register */
|
Line 282... |
Line 279... |
|
|
#define ata_dev_busy(base) (ata_astatus(base) & ATA_SR_BSY)
|
#define ata_dev_busy(base) (ata_astatus(base) & ATA_SR_BSY)
|
#define ata_dev_cmdrdy(base) (ata_astatus(base) & (~ATA_SR_BSY & ATA_SR_DRDY))
|
#define ata_dev_cmdrdy(base) (ata_astatus(base) & (~ATA_SR_BSY & ATA_SR_DRDY))
|
#define ata_dev_datrdy(base) (ata_astatus(base) & ATA_SR_DRQ)
|
#define ata_dev_datrdy(base) (ata_astatus(base) & ATA_SR_DRQ)
|
|
|
|
|
|
|
|
/*
|
|
INTERNALS
|
|
*/
|
|
|
|
/* ------------------- */
|
|
/* ----- defines ----- */
|
|
/* ------------------- */
|
|
#define READ 0
|
|
#define WRITE 1
|
|
|
|
#define FMODE_READ 0
|
|
#define FMODE_WRITE 1
|
|
|
|
#define SET (1<<31)
|
|
#define CLR 0
|
|
|
|
|
|
#define PIO4 0x02
|
|
#define PIO3 0x01
|
|
|
|
/*define MAJOR, MINOR numbers */
|
|
#define MAJOR(dev) (dev >> 8)
|
|
#define MINOR(dev) (dev & 0xff)
|
|
|
|
#define MINOR_DEV0 0x00
|
|
#define MINOR_DEV1 0X80
|
|
|
|
|
|
#define ATA_IOCTL_IDENTIFY_DEVICE 0
|
|
#define ATA_IOCTL_IDENTIFY_HOST 1
|
|
#define ATA_IOCTL_SELECT_DEVICE 3
|
|
#define ATA_IOCTL_SET_RST 4
|
|
#define ATA_IOCTL_SET_PIO 5
|
|
#define ATA_IOCTL_SET_FEATURES 6
|
|
#define ATA_IOCTL_SET_FTE 7
|
|
|
|
#define ARG_HW_RST 0
|
|
#define ARG_SW_RST 1
|
|
#define ARG_DEV_RST 2
|
|
|
|
/* PIO numbers and PIO timing (in ns) */
|
|
#define ARG_PIO4 4
|
|
#define ARG_PIO3 3
|
|
#define ARG_PIO2 2
|
|
#define ARG_PIO1 1
|
|
#define ARG_PIO0 0
|
|
|
|
/* register transfer timings */
|
|
#define PIO0_RT0 600
|
|
#define PIO0_RT1 70
|
|
#define PIO0_RT2 290
|
|
#define PIO0_RT2I 0
|
|
#define PIO0_RT4 30
|
|
#define PIO0_RT9 20
|
|
|
|
#define PIO1_RT0 383
|
|
#define PIO1_RT1 50
|
|
#define PIO1_RT2 290
|
|
#define PIO1_RT2I 0
|
|
#define PIO1_RT4 20
|
|
#define PIO1_RT9 15
|
|
|
|
#define PIO2_RT0 330
|
|
#define PIO2_RT1 30
|
|
#define PIO2_RT2 290
|
|
#define PIO2_RT2I 0
|
|
#define PIO2_RT4 15
|
|
#define PIO2_RT9 10
|
|
|
|
#define PIO3_RT0 180
|
|
#define PIO3_RT1 30
|
|
#define PIO3_RT2 80
|
|
#define PIO3_RT2I 70
|
|
#define PIO3_RT4 10
|
|
#define PIO3_RT9 10
|
|
|
|
#define PIO4_RT0 120
|
|
#define PIO4_RT1 25
|
|
#define PIO4_RT2 70
|
|
#define PIO4_RT2I 25
|
|
#define PIO4_RT4 10
|
|
#define PIO4_RT9 10
|
|
|
|
/* data transfer timings */
|
|
#define PIO0_DT0 600
|
|
#define PIO0_DT1 70
|
|
#define PIO0_DT2 165
|
|
#define PIO0_DT2I 0
|
|
#define PIO0_DT4 30
|
|
#define PIO0_DT9 20
|
|
|
|
#define PIO1_DT0 383
|
|
#define PIO1_DT1 50
|
|
#define PIO1_DT2 125
|
|
#define PIO1_DT2I 0
|
|
#define PIO1_DT4 20
|
|
#define PIO1_DT9 15
|
|
|
|
#define PIO2_DT0 240
|
|
#define PIO2_DT1 30
|
|
#define PIO2_DT2 100
|
|
#define PIO2_DT2I 0
|
|
#define PIO2_DT4 15
|
|
#define PIO2_DT9 10
|
|
|
|
#define PIO3_DT0 180
|
|
#define PIO3_DT1 30
|
|
#define PIO3_DT2 80
|
|
#define PIO3_DT2I 70
|
|
#define PIO3_DT4 10
|
|
#define PIO3_DT9 10
|
|
|
|
#define PIO4_DT0 120
|
|
#define PIO4_DT1 25
|
|
#define PIO4_DT2 70
|
|
#define PIO4_DT2I 25
|
|
#define PIO4_DT4 10
|
|
#define PIO4_DT9 10
|
|
|
|
|
|
|
|
/* error numbers */
|
|
#define EINVAL -1
|
|
#define EIOCTLIARG -2
|
|
|
|
#define EOPENIDEV -3
|
|
#define EOPENIHOST -4
|
|
#define EOPENNODEV -5
|
|
|
|
|
|
|
|
|
|
/* ------------------------------ */
|
|
/* ----- structs & typedefs ----- */
|
|
/* ------------------------------ */
|
|
struct inode {
|
|
unsigned short i_rdev;
|
|
};
|
|
|
|
struct file {
|
|
unsigned long f_mode;
|
|
unsigned long f_flags;
|
|
};
|
|
|
|
typedef unsigned int dev_t;
|
|
|
|
struct request {
|
|
dev_t rq_dev;
|
|
int cmd;
|
|
unsigned long sector;
|
|
unsigned long nr_sectors;
|
|
unsigned char *buffer;
|
|
};
|
|
|
|
|
/* ---------------------------- */
|
/* ---------------------------- */
|
/* ----- Prototypes ----- */
|
/* ----- Prototypes ----- */
|
/* ---------------------------- */
|
/* ---------------------------- */
|
void module_ata_init (void);
|
int ata_open(struct inode *inode, struct file *filp);
|
int atabug(int argc, char **argv);
|
int ata_open_device_not_found(struct inode *inode);
|
int atabug_exit(int argc, char **argv);
|
|
int atabug_help(int argc, char **argv);
|
int ata_release(struct inode *inode, struct file *filp);
|
void register_ata_command (const char *name, const char *params, const char *help, int (*func)(int argc, char *argv[]));
|
|
int ata_mon_command(void);
|
int ata_ioctl(struct inode *inode, struct file *filp, unsigned command, unsigned long argument);
|
int execute_ata_command(char *pstr, int argc, char **argv);
|
unsigned long ata_calc_pio_timing(short t0, short t1, short t2, short t4, short t2i, short t9);
|
|
|
int ata_dump_device_regs_cmd(int argc, char **argv);
|
int ata_check_media_change(dev_t dev);
|
int ata_dump_host_regs_cmd(int argc, char **argv);
|
|
int ata_enable_cmd(int argc, char **argv);
|
int ata_revalidate(dev_t dev);
|
int ata_exec_cmd_cmd(int argc, char **argv);
|
|
int ata_identify_device_cmd(int argc, char **argv);
|
|
int ata_read_sector_cmd(int argc, char **argv);
|
|
int ata_reset_cmd(int argc, char **argv);
|
|
int ata_select_device_cmd(int argc, char **argv);
|
|
|
|
unsigned char atabug_dump_data(unsigned short *buffer, int cnt);
|
int ata_request(struct inode *inode, struct file *filp, struct request *request);
|
|
|
|
|
#endif
|
#endif
|
|
|
No newline at end of file
|
No newline at end of file
|