Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:23:43

0001 /*
0002  * ide_ctrl_cfg.h
0003  *
0004  * LibChip library IDE controller header file - structures used for
0005  * configuration and plugin interface definition.
0006  *
0007  * Copyright (C) 2002 OKTET Ltd., St.-Petersburg, Russia
0008  * Author: Eugeny S. Mints <Eugeny.Mints@oktet.ru>
0009  *
0010  * The license and distribution terms for this file may be
0011  * found in the file LICENSE in this distribution or at
0012  * http://www.rtems.org/license/LICENSE.
0013  */
0014 #ifndef __IDE_CTRL_CFG_H__
0015 #define __IDE_CTRL_CFG_H__
0016 
0017 #include <rtems/blkdev.h>
0018 
0019 #ifdef __cplusplus
0020 extern "C" {
0021 #endif
0022 
0023 /*
0024  * Avaible drivers for IDE controllers
0025  */
0026 typedef enum {
0027     IDE_STD,
0028     IDE_CUSTOM                /* BSP specific driver */
0029 } ide_ctrl_devs_t;
0030 
0031 /* ATA modes: bit masks used in ctrl_config_io_speed call */
0032 #define ATA_MODES_PIO3    0x001
0033 #define ATA_MODES_PIO4    0x002
0034 
0035 #define ATA_MODES_PIO     0x003
0036 
0037 #define ATA_MODES_DMA0    0x004
0038 #define ATA_MODES_DMA1    0x008
0039 #define ATA_MODES_DMA2    0x010
0040 
0041 #define ATA_MODES_UDMA0   0x020
0042 #define ATA_MODES_UDMA1   0x040
0043 #define ATA_MODES_UDMA2   0x080
0044 #define ATA_MODES_UDMA3   0x100
0045 #define ATA_MODES_UDMA4   0x200
0046 #define ATA_MODES_UDMA5   0x400
0047 
0048 #define ATA_MODES_UDMA    0x7e0
0049 #define ATA_MODES_DMA     0x7fc
0050 
0051 
0052 /*
0053  * Each driver for a particular controller have to provide following
0054  * functions in such a structure. The only field which should not be NULL
0055  * is contInit.
0056  */
0057 typedef struct ide_ctrl_fns_s {
0058     bool              (*ctrl_probe)(int minor); /* probe routine */
0059     void              (*ctrl_initialize)(int minor);
0060     int               (*ctrl_control)(int minor, uint32_t   command,
0061                                       void *arg);
0062     /*
0063      * Functions which allow read/write registers of a particular controller.
0064      * (these functions may be used from ide_controller_read_register,
0065      * ide_controller_write_register)
0066      */
0067     void    (*ctrl_reg_read)(int minor, int regist, uint16_t   *value);
0068     void    (*ctrl_reg_write)(int minor, int regist, uint16_t   value);
0069 
0070     /*
0071      * The function allows to escape overhead for read/write register
0072      * functions calls
0073      */
0074     void  (*ctrl_read_block)(int minor, uint32_t   block_size,
0075                              rtems_blkdev_sg_buffer *bufs, uint32_t   *cbuf,
0076                              uint32_t   *pos);
0077     void  (*ctrl_write_block)(int minor, uint32_t   block_size,
0078                               rtems_blkdev_sg_buffer *bufs, uint32_t   *cbuf,
0079                               uint32_t   *pos);
0080 
0081     rtems_status_code (*ctrl_config_io_speed)(int minor,
0082                                               uint16_t modes_available);
0083 } ide_ctrl_fns_t;
0084 
0085 /*
0086  * IDE Controller configuration. Table of such configurations is provided
0087  * by BSP
0088  */
0089 typedef struct ide_controller_bsp_table_s {
0090     char                *name;  /* device name */
0091     ide_ctrl_devs_t      type;  /* chip type */
0092     ide_ctrl_fns_t      *fns;   /* pointer to the set of driver routines */
0093     bool                 (*probe)(int minor); /* general probe routine */
0094     uint8_t              status; /* initialized/non initialized. Should be set
0095                                   * to zero by static initialization
0096                                   */
0097     uint32_t             port1; /* port number for the port of the device */
0098     bool                 int_driven; /* interrupt/poll driven */
0099     rtems_vector_number  int_vec; /* the interrupt vector of the device */
0100     void                *params;  /* contains either device specific data or a
0101                                    * pointer to s device specific information
0102                                    * table
0103                                    */
0104 } ide_controller_bsp_table_t;
0105 
0106 /* IDE controllers Table */
0107 extern ide_controller_bsp_table_t    IDE_Controller_Table[];
0108 
0109 /* Number of rows in IDE_Controller_Table */
0110 extern unsigned long                 IDE_Controller_Count;
0111 
0112 
0113 #define IDE_CTRL_MAX_MINOR_NUMBER   4
0114 
0115 #define IDE_CTRL_NON_INITIALIZED    0
0116 #define IDE_CTRL_INITIALIZED        1
0117 
0118 #ifdef __cplusplus
0119 }
0120 #endif
0121 
0122 
0123 #endif /* __IDE_CTRL_CFG_H__ */