[11bbeb9] | 1 | /* |
---|
| 2 | * ide_ctrl_cfg.h |
---|
| 3 | * |
---|
[3495c57] | 4 | * LibChip library IDE controller header file - structures used for |
---|
[11bbeb9] | 5 | * configuration and plugin interface definition. |
---|
| 6 | * |
---|
| 7 | * Copyright (C) 2002 OKTET Ltd., St.-Petersburg, Russia |
---|
| 8 | * Author: Eugeny S. Mints <Eugeny.Mints@oktet.ru> |
---|
| 9 | * |
---|
| 10 | * The license and distribution terms for this file may be |
---|
| 11 | * found in the file LICENSE in this distribution or at |
---|
[c499856] | 12 | * http://www.rtems.org/license/LICENSE. |
---|
[11bbeb9] | 13 | */ |
---|
| 14 | #ifndef __IDE_CTRL_CFG_H__ |
---|
| 15 | #define __IDE_CTRL_CFG_H__ |
---|
| 16 | |
---|
[6640459d] | 17 | #include <rtems/blkdev.h> |
---|
| 18 | |
---|
[11bbeb9] | 19 | #ifdef __cplusplus |
---|
| 20 | extern "C" { |
---|
| 21 | #endif |
---|
| 22 | |
---|
| 23 | /* |
---|
| 24 | * Avaible drivers for IDE controllers |
---|
| 25 | */ |
---|
| 26 | typedef enum { |
---|
[3446afa] | 27 | IDE_STD, |
---|
[11bbeb9] | 28 | IDE_CUSTOM /* BSP specific driver */ |
---|
| 29 | } ide_ctrl_devs_t; |
---|
| 30 | |
---|
[bf474880] | 31 | /* ATA modes: bit masks used in ctrl_config_io_speed call */ |
---|
| 32 | #define ATA_MODES_PIO3 0x001 |
---|
| 33 | #define ATA_MODES_PIO4 0x002 |
---|
| 34 | |
---|
| 35 | #define ATA_MODES_PIO 0x003 |
---|
| 36 | |
---|
| 37 | #define ATA_MODES_DMA0 0x004 |
---|
| 38 | #define ATA_MODES_DMA1 0x008 |
---|
| 39 | #define ATA_MODES_DMA2 0x010 |
---|
| 40 | |
---|
| 41 | #define ATA_MODES_UDMA0 0x020 |
---|
| 42 | #define ATA_MODES_UDMA1 0x040 |
---|
| 43 | #define ATA_MODES_UDMA2 0x080 |
---|
| 44 | #define ATA_MODES_UDMA3 0x100 |
---|
| 45 | #define ATA_MODES_UDMA4 0x200 |
---|
| 46 | #define ATA_MODES_UDMA5 0x400 |
---|
| 47 | |
---|
| 48 | #define ATA_MODES_UDMA 0x7e0 |
---|
| 49 | #define ATA_MODES_DMA 0x7fc |
---|
| 50 | |
---|
| 51 | |
---|
[11bbeb9] | 52 | /* |
---|
| 53 | * Each driver for a particular controller have to provide following |
---|
| 54 | * functions in such a structure. The only field which should not be NULL |
---|
[a3d3d9a] | 55 | * is contInit. |
---|
[11bbeb9] | 56 | */ |
---|
| 57 | typedef struct ide_ctrl_fns_s { |
---|
[6640459d] | 58 | bool (*ctrl_probe)(int minor); /* probe routine */ |
---|
[11bbeb9] | 59 | void (*ctrl_initialize)(int minor); |
---|
[a3d3d9a] | 60 | int (*ctrl_control)(int minor, uint32_t command, |
---|
[11bbeb9] | 61 | void *arg); |
---|
| 62 | /* |
---|
| 63 | * Functions which allow read/write registers of a particular controller. |
---|
[a3d3d9a] | 64 | * (these functions may be used from ide_controller_read_register, |
---|
[11bbeb9] | 65 | * ide_controller_write_register) |
---|
| 66 | */ |
---|
[ee4f57d] | 67 | void (*ctrl_reg_read)(int minor, int regist, uint16_t *value); |
---|
| 68 | void (*ctrl_reg_write)(int minor, int regist, uint16_t value); |
---|
[a3d3d9a] | 69 | |
---|
| 70 | /* |
---|
| 71 | * The function allows to escape overhead for read/write register |
---|
[11bbeb9] | 72 | * functions calls |
---|
| 73 | */ |
---|
[7357f566] | 74 | void (*ctrl_read_block)(int minor, uint32_t block_size, |
---|
[3735f08] | 75 | rtems_blkdev_sg_buffer *bufs, uint32_t *cbuf, |
---|
[ee4f57d] | 76 | uint32_t *pos); |
---|
[7357f566] | 77 | void (*ctrl_write_block)(int minor, uint32_t block_size, |
---|
[3735f08] | 78 | rtems_blkdev_sg_buffer *bufs, uint32_t *cbuf, |
---|
[ee4f57d] | 79 | uint32_t *pos); |
---|
[a3d3d9a] | 80 | |
---|
| 81 | rtems_status_code (*ctrl_config_io_speed)(int minor, |
---|
[bf474880] | 82 | uint16_t modes_available); |
---|
[11bbeb9] | 83 | } ide_ctrl_fns_t; |
---|
| 84 | |
---|
[a3d3d9a] | 85 | /* |
---|
| 86 | * IDE Controller configuration. Table of such configurations is provided |
---|
[11bbeb9] | 87 | * by BSP |
---|
| 88 | */ |
---|
| 89 | typedef struct ide_controller_bsp_table_s { |
---|
| 90 | char *name; /* device name */ |
---|
| 91 | ide_ctrl_devs_t type; /* chip type */ |
---|
| 92 | ide_ctrl_fns_t *fns; /* pointer to the set of driver routines */ |
---|
[6640459d] | 93 | bool (*probe)(int minor); /* general probe routine */ |
---|
[a3d3d9a] | 94 | uint8_t status; /* initialized/non initialized. Should be set |
---|
| 95 | * to zero by static initialization |
---|
[11bbeb9] | 96 | */ |
---|
[ee4f57d] | 97 | uint32_t port1; /* port number for the port of the device */ |
---|
[6640459d] | 98 | bool int_driven; /* interrupt/poll driven */ |
---|
[11bbeb9] | 99 | rtems_vector_number int_vec; /* the interrupt vector of the device */ |
---|
[a3d3d9a] | 100 | void *params; /* contains either device specific data or a |
---|
| 101 | * pointer to s device specific information |
---|
[11bbeb9] | 102 | * table |
---|
| 103 | */ |
---|
| 104 | } ide_controller_bsp_table_t; |
---|
| 105 | |
---|
| 106 | /* IDE controllers Table */ |
---|
| 107 | extern ide_controller_bsp_table_t IDE_Controller_Table[]; |
---|
| 108 | |
---|
| 109 | /* Number of rows in IDE_Controller_Table */ |
---|
| 110 | extern unsigned long IDE_Controller_Count; |
---|
| 111 | |
---|
| 112 | |
---|
| 113 | #define IDE_CTRL_MAX_MINOR_NUMBER 4 |
---|
| 114 | |
---|
| 115 | #define IDE_CTRL_NON_INITIALIZED 0 |
---|
| 116 | #define IDE_CTRL_INITIALIZED 1 |
---|
| 117 | |
---|
| 118 | #ifdef __cplusplus |
---|
| 119 | } |
---|
| 120 | #endif |
---|
| 121 | |
---|
| 122 | |
---|
| 123 | #endif /* __IDE_CTRL_CFG_H__ */ |
---|