📄 ide.h
字号:
typedef struct ide_settings_s { char *name; int rw; int read_ioctl; int write_ioctl; int data_type; int min; int max; int mul_factor; int div_factor; void *data; ide_procset_t *set; int auto_remove; struct ide_settings_s *next;} ide_settings_t;void ide_add_setting(ide_drive_t *drive, const char *name, int rw, int read_ioctl, int write_ioctl, int data_type, int min, int max, int mul_factor, int div_factor, void *data, ide_procset_t *set);void ide_remove_setting(ide_drive_t *drive, char *name);ide_settings_t *ide_find_setting_by_name(ide_drive_t *drive, char *name);int ide_read_setting(ide_drive_t *t, ide_settings_t *setting);int ide_write_setting(ide_drive_t *drive, ide_settings_t *setting, int val);void ide_add_generic_settings(ide_drive_t *drive);/* * /proc/ide interface */typedef struct { const char *name; mode_t mode; read_proc_t *read_proc; write_proc_t *write_proc;} ide_proc_entry_t;#ifdef CONFIG_PROC_FSvoid proc_ide_create(void);void proc_ide_destroy(void);void ide_add_proc_entries(struct proc_dir_entry *dir, ide_proc_entry_t *p, void *data);void ide_remove_proc_entries(struct proc_dir_entry *dir, ide_proc_entry_t *p);read_proc_t proc_ide_read_capacity;read_proc_t proc_ide_read_geometry;/* * Standard exit stuff: */#define PROC_IDE_READ_RETURN(page,start,off,count,eof,len) \{ \ len -= off; \ if (len < count) { \ *eof = 1; \ if (len <= 0) \ return 0; \ } else \ len = count; \ *start = page + off; \ return len; \}#else#define PROC_IDE_READ_RETURN(page,start,off,count,eof,len) return 0;#endif/* * Subdrivers support. */#define IDE_SUBDRIVER_VERSION 1typedef int (ide_cleanup_proc)(ide_drive_t *);typedef void (ide_do_request_proc)(ide_drive_t *, struct request *, unsigned long);typedef void (ide_end_request_proc)(byte, ide_hwgroup_t *);typedef int (ide_ioctl_proc)(ide_drive_t *, struct inode *, struct file *, unsigned int, unsigned long);typedef int (ide_open_proc)(struct inode *, struct file *, ide_drive_t *);typedef void (ide_release_proc)(struct inode *, struct file *, ide_drive_t *);typedef int (ide_check_media_change_proc)(ide_drive_t *);typedef void (ide_pre_reset_proc)(ide_drive_t *);typedef unsigned long (ide_capacity_proc)(ide_drive_t *);typedef void (ide_special_proc)(ide_drive_t *);typedef void (ide_setting_proc)(ide_drive_t *);typedef struct ide_driver_s { const char *name; const char *version; byte media; unsigned busy : 1; unsigned supports_dma : 1; unsigned supports_dsc_overlap : 1; ide_cleanup_proc *cleanup; ide_do_request_proc *do_request; ide_end_request_proc *end_request; ide_ioctl_proc *ioctl; ide_open_proc *open; ide_release_proc *release; ide_check_media_change_proc *media_change; ide_pre_reset_proc *pre_reset; ide_capacity_proc *capacity; ide_special_proc *special; ide_proc_entry_t *proc; } ide_driver_t;#define DRIVER(drive) ((ide_driver_t *)((drive)->driver))/* * IDE modules. */#define IDE_CHIPSET_MODULE 0 /* not supported yet */#define IDE_PROBE_MODULE 1#define IDE_DRIVER_MODULE 2typedef int (ide_module_init_proc)(void);typedef struct ide_module_s { int type; ide_module_init_proc *init; void *info; struct ide_module_s *next;} ide_module_t;/* * ide_hwifs[] is the master data structure used to keep track * of just about everything in ide.c. Whenever possible, routines * should be using pointers to a drive (ide_drive_t *) or * pointers to a hwif (ide_hwif_t *), rather than indexing this * structure directly (the allocation/layout may change!). * */#ifndef _IDE_Cextern ide_hwif_t ide_hwifs[]; /* master data repository */extern ide_module_t *ide_modules;#endif/* * We need blk.h, but we replace its end_request by our own version. */#define IDE_DRIVER /* Toggle some magic bits in blk.h */#define LOCAL_END_REQUEST /* Don't generate end_request in blk.h */#include <linux/blk.h>void ide_end_request(byte uptodate, ide_hwgroup_t *hwgroup);/* * This is used for (nearly) all data transfers from/to the IDE interface */void ide_input_data (ide_drive_t *drive, void *buffer, unsigned int wcount);void ide_output_data (ide_drive_t *drive, void *buffer, unsigned int wcount);/* * This is used for (nearly) all ATAPI data transfers from/to the IDE interface */void atapi_input_bytes (ide_drive_t *drive, void *buffer, unsigned int bytecount);void atapi_output_bytes (ide_drive_t *drive, void *buffer, unsigned int bytecount);/* * This is used on exit from the driver, to designate the next irq handler * and also to start the safety timer. */void ide_set_handler (ide_drive_t *drive, ide_handler_t *handler, unsigned int timeout);/* * Error reporting, in human readable form (luxurious, but a memory hog). */byte ide_dump_status (ide_drive_t *drive, const char *msg, byte stat);/* * ide_error() takes action based on the error returned by the controller. * The calling function must return afterwards, to restart the request. */void ide_error (ide_drive_t *drive, const char *msg, byte stat);/* * Issue a simple drive command * The drive must be selected beforehand. */void ide_cmd(ide_drive_t *drive, byte cmd, byte nsect, ide_handler_t *handler);/* * ide_fixstring() cleans up and (optionally) byte-swaps a text string, * removing leading/trailing blanks and compressing internal blanks. * It is primarily used to tidy up the model name/number fields as * returned by the WIN_[P]IDENTIFY commands. */void ide_fixstring (byte *s, const int bytecount, const int byteswap);/* * This routine busy-waits for the drive status to be not "busy". * It then checks the status for all of the "good" bits and none * of the "bad" bits, and if all is okay it returns 0. All other * cases return 1 after invoking ide_error() -- caller should return. * */int ide_wait_stat (ide_drive_t *drive, byte good, byte bad, unsigned long timeout);/* * This routine is called from the partition-table code in genhd.c * to "convert" a drive to a logical geometry with fewer than 1024 cyls. * * The second parameter, "xparm", determines exactly how the translation * will be handled: * 0 = convert to CHS with fewer than 1024 cyls * using the same method as Ontrack DiskManager. * 1 = same as "0", plus offset everything by 63 sectors. * -1 = similar to "0", plus redirect sector 0 to sector 1. * >1 = convert to a CHS geometry with "xparm" heads. * * Returns 0 if the translation was not possible, if the device was not * an IDE disk drive, or if a geometry was "forced" on the commandline. * Returns 1 if the geometry translation was successful. */int ide_xlate_1024 (kdev_t, int, const char *);/* * Start a reset operation for an IDE interface. * The caller should return immediately after invoking this. */void ide_do_reset (ide_drive_t *);/* * This function is intended to be used prior to invoking ide_do_drive_cmd(). */void ide_init_drive_cmd (struct request *rq);/* * "action" parameter type for ide_do_drive_cmd() below. */typedef enum {ide_wait, /* insert rq at end of list, and wait for it */ ide_next, /* insert rq immediately after current request */ ide_preempt, /* insert rq in front of current request */ ide_end} /* insert rq at end of list, but don't wait for it */ ide_action_t;/* * This function issues a special IDE device request * onto the request queue. * * If action is ide_wait, then the rq is queued at the end of the * request queue, and the function sleeps until it has been processed. * This is for use when invoked from an ioctl handler. * * If action is ide_preempt, then the rq is queued at the head of * the request queue, displacing the currently-being-processed * request and this function returns immediately without waiting * for the new rq to be completed. This is VERY DANGEROUS, and is * intended for careful use by the ATAPI tape/cdrom driver code. * * If action is ide_next, then the rq is queued immediately after * the currently-being-processed-request (if any), and the function * returns without waiting for the new rq to be completed. As above, * This is VERY DANGEROUS, and is intended for careful use by the * ATAPI tape/cdrom driver code. * * If action is ide_end, then the rq is queued at the end of the * request queue, and the function returns immediately without waiting * for the new rq to be completed. This is again intended for careful * use by the ATAPI tape/cdrom driver code. */int ide_do_drive_cmd (ide_drive_t *drive, struct request *rq, ide_action_t action);/* * Clean up after success/failure of an explicit drive cmd. * stat/err are used only when (HWGROUP(drive)->rq->cmd == IDE_DRIVE_CMD). */void ide_end_drive_cmd (ide_drive_t *drive, byte stat, byte err);/* * Issue ATA command and wait for completion. */int ide_wait_cmd (ide_drive_t *drive, int cmd, int nsect, int feature, int sectors, byte *buf);/* * ide_system_bus_speed() returns what we think is the system VESA/PCI * bus speed (in MHz). This is used for calculating interface PIO timings. * The default is 40 for known PCI systems, 50 otherwise. * The "idebus=xx" parameter can be used to override this value. */int ide_system_bus_speed (void);/* * ide_multwrite() transfers a block of up to mcount sectors of data * to a drive as part of a disk multwrite operation. */void ide_multwrite (ide_drive_t *drive, unsigned int mcount);/* * ide_stall_queue() can be used by a drive to give excess bandwidth back * to the hwgroup by sleeping for timeout jiffies. */void ide_stall_queue (ide_drive_t *drive, unsigned long timeout);/* * ide_get_queue() returns the queue which corresponds to a given device. */struct request **ide_get_queue (kdev_t dev);/* * CompactFlash cards and their brethern pretend to be removable hard disks, * but they never have a slave unit, and they don't have doorlock mechanisms. * This test catches them, and is invoked elsewhere when setting appropriate config bits. */int drive_is_flashcard (ide_drive_t *drive);int ide_spin_wait_hwgroup(ide_drive_t *drive, unsigned long *flags);void ide_timer_expiry (unsigned long data);void ide_intr (int irq, void *dev_id, struct pt_regs *regs);void ide_geninit (struct gendisk *gd);void do_ide0_request (void);#if MAX_HWIFS > 1void do_ide1_request (void);#endif#if MAX_HWIFS > 2void do_ide2_request (void);#endif#if MAX_HWIFS > 3void do_ide3_request (void);#endif#if MAX_HWIFS > 4void do_ide4_request (void);#endif#if MAX_HWIFS > 5void do_ide5_request (void);#endifvoid ide_init_subdrivers (void);#ifndef _IDE_Cextern struct file_operations ide_fops[];#endif#ifdef _IDE_C#ifdef CONFIG_BLK_DEV_IDEint ideprobe_init (void);#endif /* CONFIG_BLK_DEV_IDE */#ifdef CONFIG_BLK_DEV_IDEDISKint idedisk_init (void);#endif /* CONFIG_BLK_DEV_IDEDISK */#ifdef CONFIG_BLK_DEV_IDECDint ide_cdrom_init (void);#endif /* CONFIG_BLK_DEV_IDECD */#ifdef CONFIG_BLK_DEV_IDETAPEint idetape_init (void);#endif /* CONFIG_BLK_DEV_IDETAPE */#ifdef CONFIG_BLK_DEV_IDEFLOPPYint idefloppy_init (void);#endif /* CONFIG_BLK_DEV_IDEFLOPPY */#ifdef CONFIG_BLK_DEV_IDESCSIint idescsi_init (void);#endif /* CONFIG_BLK_DEV_IDESCSI */#endif /* _IDE_C */int ide_register_module (ide_module_t *module);void ide_unregister_module (ide_module_t *module);ide_drive_t *ide_scan_devices (byte media, const char *name, ide_driver_t *driver, int n);int ide_register_subdriver (ide_drive_t *drive, ide_driver_t *driver, int version);int ide_unregister_subdriver (ide_drive_t *drive);int ide_replace_subdriver(ide_drive_t *drive, const char *driver);#ifdef CONFIG_BLK_DEV_IDEPCI#define ON_BOARD 1#define NEVER_BOARD 0#ifdef CONFIG_BLK_DEV_OFFBOARD# define OFF_BOARD ON_BOARD#else /* CONFIG_BLK_DEV_OFFBOARD */# define OFF_BOARD NEVER_BOARD#endif /* CONFIG_BLK_DEV_OFFBOARD */unsigned long ide_find_free_region (unsigned short size) __init;void ide_scan_pcibus (void) __init;#endif#ifdef CONFIG_BLK_DEV_IDEDMA#define BAD_DMA_DRIVE 0#define GOOD_DMA_DRIVE 1int ide_build_dmatable (ide_drive_t *drive);void ide_dma_intr (ide_drive_t *drive);int check_drive_lists (ide_drive_t *drive, int good_bad);int ide_dmaproc (ide_dma_action_t func, ide_drive_t *drive);int ide_release_dma (ide_hwif_t *hwif);void ide_setup_dma (ide_hwif_t *hwif, unsigned long dmabase, unsigned int num_ports) __init;unsigned long ide_get_or_set_dma_base (ide_hwif_t *hwif, int extra, const char *name) __init;#endif#ifdef CONFIG_BLK_DEV_PDC4030#include "pdc4030.h"#define IS_PDC4030_DRIVE (HWIF(drive)->chipset == ide_pdc4030)#else#define IS_PDC4030_DRIVE (0) /* auto-NULLs out pdc4030 code */#endif /* CONFIG_BLK_DEV_PDC4030 */#endif /* _IDE_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -