📄 ide.h
字号:
* * For each step, the core calls the subdriver start_power_step() first. * This can return: * - ide_stopped : In this case, the core calls us back again unless * step have been set to ide_power_state_completed. * - ide_started : In this case, the channel is left busy until an * async event (interrupt) occurs. * Typically, start_power_step() will issue a taskfile request with * do_rw_taskfile(). * * Upon reception of the interrupt, the core will call complete_power_step() * with the error code if any. This routine should update the step value * and return. It should not start a new request. The core will call * start_power_step for the new step value, unless step have been set to * ide_power_state_completed. * * Subdrivers are expected to define their own additional power * steps from 1..999 for suspend and from 1001..1999 for resume, * other values are reserved for future use. */enum { ide_pm_state_completed = -1, ide_pm_state_start_suspend = 0, ide_pm_state_start_resume = 1000,};/* * Subdrivers support. * * The gendriver.owner field should be set to the module owner of this driver. * The gendriver.name field should be set to the name of this driver */struct ide_driver_s { const char *version; u8 media; unsigned supports_dsc_overlap : 1; ide_startstop_t (*do_request)(ide_drive_t *, struct request *, sector_t); int (*end_request)(ide_drive_t *, int, int); ide_startstop_t (*error)(ide_drive_t *, struct request *rq, u8, u8); ide_startstop_t (*abort)(ide_drive_t *, struct request *rq); struct device_driver gen_driver; int (*probe)(ide_drive_t *); void (*remove)(ide_drive_t *); void (*resume)(ide_drive_t *); void (*shutdown)(ide_drive_t *);#ifdef CONFIG_IDE_PROC_FS ide_proc_entry_t *proc;#endif};#define to_ide_driver(drv) container_of(drv, ide_driver_t, gen_driver)int generic_ide_ioctl(ide_drive_t *, struct file *, struct block_device *, unsigned, unsigned long);/* * 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 */#endifextern int noautodma;extern int ide_end_request (ide_drive_t *drive, int uptodate, int nrsecs);int ide_end_dequeued_request(ide_drive_t *drive, struct request *rq, int uptodate, int nr_sectors);extern void ide_set_handler (ide_drive_t *drive, ide_handler_t *handler, unsigned int timeout, ide_expiry_t *expiry);extern void ide_execute_command(ide_drive_t *, task_ioreg_t cmd, ide_handler_t *, unsigned int, ide_expiry_t *);ide_startstop_t __ide_error(ide_drive_t *, struct request *, u8, u8);ide_startstop_t ide_error (ide_drive_t *drive, const char *msg, byte stat);ide_startstop_t __ide_abort(ide_drive_t *, struct request *);extern ide_startstop_t ide_abort(ide_drive_t *, const char *);extern void ide_fix_driveid(struct hd_driveid *);extern void ide_fixstring(u8 *, const int, const int);int ide_wait_stat(ide_startstop_t *, ide_drive_t *, u8, u8, unsigned long);extern ide_startstop_t ide_do_reset (ide_drive_t *);extern 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_preempt, /* insert rq in front of current request */ ide_head_wait, /* insert rq in front of current request and wait for it */ ide_end /* insert rq at end of list, but don't wait for it */} ide_action_t;extern int ide_do_drive_cmd(ide_drive_t *, struct request *, ide_action_t);extern void ide_end_drive_cmd(ide_drive_t *, u8, u8);/* * Issue ATA command and wait for completion. * Use for implementing commands in kernel * * (ide_drive_t *drive, u8 cmd, u8 nsect, u8 feature, u8 sectors, u8 *buf) */extern int ide_wait_cmd(ide_drive_t *, u8, u8, u8, u8, u8 *);typedef struct ide_task_s {/* * struct hd_drive_task_hdr tf; * task_struct_t tf; * struct hd_drive_hob_hdr hobf; * hob_struct_t hobf; */ task_ioreg_t tfRegister[8]; task_ioreg_t hobRegister[8]; ide_reg_valid_t tf_out_flags; ide_reg_valid_t tf_in_flags; int data_phase; int command_type; ide_pre_handler_t *prehandler; ide_handler_t *handler; struct request *rq; /* copy of request */ void *special; /* valid_t generally */} ide_task_t;extern u32 ide_read_24(ide_drive_t *);extern void SELECT_DRIVE(ide_drive_t *);extern void SELECT_INTERRUPT(ide_drive_t *);extern void SELECT_MASK(ide_drive_t *, int);extern void QUIRK_LIST(ide_drive_t *);extern int drive_is_ready(ide_drive_t *);/* * taskfile io for disks for now...and builds request from ide_ioctl */extern ide_startstop_t do_rw_taskfile(ide_drive_t *, ide_task_t *);/* * Special Flagged Register Validation Caller */extern ide_startstop_t flagged_taskfile(ide_drive_t *, ide_task_t *);extern ide_startstop_t set_multmode_intr(ide_drive_t *);extern ide_startstop_t set_geometry_intr(ide_drive_t *);extern ide_startstop_t recal_intr(ide_drive_t *);extern ide_startstop_t task_no_data_intr(ide_drive_t *);extern ide_startstop_t task_in_intr(ide_drive_t *);extern ide_startstop_t pre_task_out_intr(ide_drive_t *, struct request *);extern int ide_raw_taskfile(ide_drive_t *, ide_task_t *, u8 *);int ide_taskfile_ioctl(ide_drive_t *, unsigned int, unsigned long);int ide_cmd_ioctl(ide_drive_t *, unsigned int, unsigned long);int ide_task_ioctl(ide_drive_t *, unsigned int, unsigned long);extern int system_bus_clock(void);extern int ide_driveid_update(ide_drive_t *);extern int ide_ata66_check(ide_drive_t *, ide_task_t *);extern int ide_config_drive_speed(ide_drive_t *, u8);extern u8 eighty_ninty_three (ide_drive_t *);extern int set_transfer(ide_drive_t *, ide_task_t *);extern int taskfile_lib_get_identify(ide_drive_t *drive, u8 *);extern int ide_wait_not_busy(ide_hwif_t *hwif, unsigned long timeout);extern void ide_stall_queue(ide_drive_t *drive, unsigned long timeout);extern int ide_spin_wait_hwgroup(ide_drive_t *);extern void ide_timer_expiry(unsigned long);extern irqreturn_t ide_intr(int irq, void *dev_id);extern void do_ide_request(struct request_queue *);void ide_init_disk(struct gendisk *, ide_drive_t *);extern int ideprobe_init(void);#ifdef CONFIG_IDEPCI_PCIBUS_ORDERextern void ide_scan_pcibus(int scan_direction) __init;extern int __ide_pci_register_driver(struct pci_driver *driver, struct module *owner, const char *mod_name);#define ide_pci_register_driver(d) __ide_pci_register_driver(d, THIS_MODULE, KBUILD_MODNAME)#else#define ide_pci_register_driver(d) pci_register_driver(d)#endifvoid ide_pci_setup_ports(struct pci_dev *, const struct ide_port_info *, int, u8 *);void ide_setup_pci_noise(struct pci_dev *, const struct ide_port_info *);extern void default_hwif_iops(ide_hwif_t *);extern void default_hwif_mmiops(ide_hwif_t *);extern void default_hwif_transport(ide_hwif_t *);typedef struct ide_pci_enablebit_s { u8 reg; /* byte pci reg holding the enable-bit */ u8 mask; /* mask to isolate the enable-bit */ u8 val; /* value of masked reg when "enabled" */} ide_pci_enablebit_t;enum { /* Uses ISA control ports not PCI ones. */ IDE_HFLAG_ISA_PORTS = (1 << 0), /* single port device */ IDE_HFLAG_SINGLE = (1 << 1), /* don't use legacy PIO blacklist */ IDE_HFLAG_PIO_NO_BLACKLIST = (1 << 2), /* don't use conservative PIO "downgrade" */ IDE_HFLAG_PIO_NO_DOWNGRADE = (1 << 3), /* use PIO8/9 for prefetch off/on */ IDE_HFLAG_ABUSE_PREFETCH = (1 << 4), /* use PIO6/7 for fast-devsel off/on */ IDE_HFLAG_ABUSE_FAST_DEVSEL = (1 << 5), /* use 100-102 and 200-202 PIO values to set DMA modes */ IDE_HFLAG_ABUSE_DMA_MODES = (1 << 6), /* * keep DMA setting when programming PIO mode, may be used only * for hosts which have separate PIO and DMA timings (ie. PMAC) */ IDE_HFLAG_SET_PIO_MODE_KEEP_DMA = (1 << 7), /* program host for the transfer mode after programming device */ IDE_HFLAG_POST_SET_MODE = (1 << 8), /* don't program host/device for the transfer mode ("smart" hosts) */ IDE_HFLAG_NO_SET_MODE = (1 << 9), /* trust BIOS for programming chipset/device for DMA */ IDE_HFLAG_TRUST_BIOS_FOR_DMA = (1 << 10), /* host uses VDMA */ IDE_HFLAG_VDMA = (1 << 11), /* ATAPI DMA is unsupported */ IDE_HFLAG_NO_ATAPI_DMA = (1 << 12), /* set if host is a "bootable" controller */ IDE_HFLAG_BOOTABLE = (1 << 13), /* host doesn't support DMA */ IDE_HFLAG_NO_DMA = (1 << 14), /* check if host is PCI IDE device before allowing DMA */ IDE_HFLAG_NO_AUTODMA = (1 << 15), /* host is CS5510/CS5520 */ IDE_HFLAG_CS5520 = (1 << 16), /* no LBA48 */ IDE_HFLAG_NO_LBA48 = (1 << 17), /* no LBA48 DMA */ IDE_HFLAG_NO_LBA48_DMA = (1 << 18), /* data FIFO is cleared by an error */ IDE_HFLAG_ERROR_STOPS_FIFO = (1 << 19), /* serialize ports */ IDE_HFLAG_SERIALIZE = (1 << 20), /* use legacy IRQs */ IDE_HFLAG_LEGACY_IRQS = (1 << 21), /* force use of legacy IRQs */ IDE_HFLAG_FORCE_LEGACY_IRQS = (1 << 22), /* limit LBA48 requests to 256 sectors */ IDE_HFLAG_RQSIZE_256 = (1 << 23), /* use 32-bit I/O ops */ IDE_HFLAG_IO_32BIT = (1 << 24), /* unmask IRQs */ IDE_HFLAG_UNMASK_IRQS = (1 << 25),};#ifdef CONFIG_BLK_DEV_OFFBOARD# define IDE_HFLAG_OFF_BOARD IDE_HFLAG_BOOTABLE#else# define IDE_HFLAG_OFF_BOARD 0#endifstruct ide_port_info { char *name; unsigned int (*init_chipset)(struct pci_dev *, const char *); void (*init_iops)(ide_hwif_t *); void (*init_hwif)(ide_hwif_t *); void (*init_dma)(ide_hwif_t *, unsigned long); void (*fixup)(ide_hwif_t *); ide_pci_enablebit_t enablebits[2]; hwif_chipset_t chipset; unsigned int extra; u32 host_flags; u8 pio_mask; u8 swdma_mask; u8 mwdma_mask; u8 udma_mask;};int ide_setup_pci_device(struct pci_dev *, const struct ide_port_info *);int ide_setup_pci_devices(struct pci_dev *, struct pci_dev *, const struct ide_port_info *);void ide_map_sg(ide_drive_t *, struct request *);void ide_init_sg_cmd(ide_drive_t *, struct request *);#define BAD_DMA_DRIVE 0#define GOOD_DMA_DRIVE 1struct drive_list_entry { const char *id_model; const char *id_firmware;};int ide_in_drive_list(struct hd_driveid *, const struct drive_list_entry *);#ifdef CONFIG_BLK_DEV_IDEDMAint __ide_dma_bad_drive(ide_drive_t *);int ide_id_dma_bug(ide_drive_t *);u8 ide_find_dma_mode(ide_drive_t *, u8);static inline u8 ide_max_dma_mode(ide_drive_t *drive){ return ide_find_dma_mode(drive, XFER_UDMA_6);}void ide_dma_off(ide_drive_t *);int ide_set_dma(ide_drive_t *);ide_startstop_t ide_dma_intr(ide_drive_t *);#ifdef CONFIG_BLK_DEV_IDEDMA_PCIextern int ide_build_sglist(ide_drive_t *, struct request *);extern int ide_build_dmatable(ide_drive_t *, struct request *);extern void ide_destroy_dmatable(ide_drive_t *);extern int ide_release_dma(ide_hwif_t *);extern void ide_setup_dma(ide_hwif_t *, unsigned long, unsigned int);void ide_dma_host_off(ide_drive_t *);void ide_dma_off_quietly(ide_drive_t *);void ide_dma_host_on(ide_drive_t *);extern int __ide_dma_on(ide_drive_t *);extern int ide_dma_setup(ide_drive_t *);extern void ide_dma_start(ide_drive_t *);extern int __ide_dma_end(ide_drive_t *);extern void ide_dma_lost_irq(ide_drive_t *);extern void ide_dma_timeout(ide_drive_t *);#endif /* CONFIG_BLK_DEV_IDEDMA_PCI */#elsestatic inline int ide_id_dma_bug(ide_drive_t *drive) { return 0; }static inline u8 ide_find_dma_mode(ide_drive_t *drive, u8 speed) { return 0; }static inline u8 ide_max_dma_mode(ide_drive_t *drive) { return 0; }static inline void ide_dma_off(ide_drive_t *drive) { ; }static inline void ide_dma_verbose(ide_drive_t *drive) { ; }static inline int ide_set_dma(ide_drive_t *drive) { return 1; }#endif /* CONFIG_BLK_DEV_IDEDMA */#ifndef CONFIG_BLK_DEV_IDEDMA_PCIstatic inline void ide_release_dma(ide_hwif_t *drive) {;}#endif#ifdef CONFIG_BLK_DEV_IDEACPIextern int ide_acpi_exec_tfs(ide_drive_t *drive);extern void ide_acpi_get_timing(ide_hwif_t *hwif);extern void ide_acpi_push_timing(ide_hwif_t *hwif);extern void ide_acpi_init(ide_hwif_t *hwif);extern void ide_acpi_set_state(ide_hwif_t *hwif, int on);#elsestatic inline int ide_acpi_exec_tfs(ide_drive_t *drive) { return 0; }static inline void ide_acpi_get_timing(ide_hwif_t *hwif) { ; }static inline void ide_acpi_push_timing(ide_hwif_t *hwif) { ; }static inline void ide_acpi_init(ide_hwif_t *hwif) { ; }static inline void ide_acpi_set_state(ide_hwif_t *hwif, int on) {}#endifextern int ide_hwif_request_regions(ide_hwif_t *hwif);extern void ide_hwif_release_regions(ide_hwif_t* hwif);extern void ide_unregister (unsigned int index);void ide_register_region(struct gendisk *);void ide_unregister_region(struct gendisk *);void ide_undecoded_slave(ide_hwif_t *);int ide_device_add(u8 idx[4]);static inline void *ide_get_hwifdata (ide_hwif_t * hwif){ return hwif->hwif_data;}static inline void ide_set_hwifdata (ide_hwif_t * hwif, void *data){ hwif->hwif_data = data;}const char *ide_xfer_verbose(u8 mode);extern void ide_toggle_bounce(ide_drive_t *drive, int on);extern int ide_set_xfer_rate(ide_drive_t *drive, u8 rate);static inline int ide_dev_has_iordy(struct hd_driveid *id){ return ((id->field_valid & 2) && (id->capability & 8)) ? 1 : 0;}static inline int ide_dev_is_sata(struct hd_driveid *id){ /* * See if word 93 is 0 AND drive is at least ATA-5 compatible * verifying that word 80 by casting it to a signed type -- * this trick allows us to filter out the reserved values of * 0x0000 and 0xffff along with the earlier ATA revisions... */ if (id->hw_config == 0 && (short)id->major_rev_num >= 0x0020) return 1; return 0;}u8 ide_dump_status(ide_drive_t *, const char *, u8);typedef struct ide_pio_timings_s { int setup_time; /* Address setup (ns) minimum */ int active_time; /* Active pulse (ns) minimum */ int cycle_time; /* Cycle time (ns) minimum = */ /* active + recovery (+ setup for some chips) */} ide_pio_timings_t;unsigned int ide_pio_cycle_time(ide_drive_t *, u8);u8 ide_get_best_pio_mode(ide_drive_t *, u8, u8);extern const ide_pio_timings_t ide_pio_timings[6];int ide_set_pio_mode(ide_drive_t *, u8);int ide_set_dma_mode(ide_drive_t *, u8);void ide_set_pio(ide_drive_t *, u8);static inline void ide_set_max_pio(ide_drive_t *drive){ ide_set_pio(drive, 255);}extern spinlock_t ide_lock;extern struct mutex ide_cfg_mtx;/* * Structure locking: * * ide_cfg_mtx and ide_lock together protect changes to * ide_hwif_t->{next,hwgroup} * ide_drive_t->next * * ide_hwgroup_t->busy: ide_lock * ide_hwgroup_t->hwif: ide_lock * ide_hwif_t->mate: constant, no locking * ide_drive_t->hwif: constant, no locking */#define local_irq_set(flags) do { local_save_flags((flags)); local_irq_enable_in_hardirq(); } while (0)extern struct bus_type ide_bus_type;/* check if CACHE FLUSH (EXT) command is supported (bits defined in ATA-6) */#define ide_id_has_flush_cache(id) ((id)->cfs_enable_2 & 0x3000)/* some Maxtor disks have bit 13 defined incorrectly so check bit 10 too */#define ide_id_has_flush_cache_ext(id) \ (((id)->cfs_enable_2 & 0x2400) == 0x2400)static inline int hwif_to_node(ide_hwif_t *hwif){ struct pci_dev *dev = hwif->pci_dev; return dev ? pcibus_to_node(dev->bus) : -1;}static inline ide_drive_t *ide_get_paired_drive(ide_drive_t *drive){ ide_hwif_t *hwif = HWIF(drive); return &hwif->drives[(drive->dn ^ 1) & 1];}#endif /* _IDE_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -