source: rtems/c/src/libchip/ide/ide_controller.c @ 7357f566

4.104.115
Last change on this file since 7357f566 was 7357f566, checked in by Chris Johns <chrisj@…>, on 10/08/09 at 07:25:15

2009-10-08 Chris Johns <chrisj@…>

  • libchip/ide/ata.c, c/src/libchip/ide/ata_internal.h: Remove the multiblock support from the ATA driver. Multiblock at the disk level should not be a global policy as a disk may have more than one partition with different block sizes. An IDE driver could decide to use the feature with DMA but this a driver specific design choice. Fixed bugs relating to variable block sizes and large block transfer.
  • c/src/libchip/ide/ide_controller.c, c/src/libchip/ide/ide_ctrl_cfg.h, c/src/libchip/ide/ide_ctrl_io.h: Changed the block size to 32bits so blocks of 64K or bigger can be transfered in a single driver call.
  • Property mode set to 100644
File size: 5.9 KB
Line 
1/*
2 * ide_controller.c
3 *
4 * This is generic rtems driver for IDE controllers.
5 *
6 * Copyright (C) 2001 OKTET Ltd., St.-Petersburg, Russia
7 * Authors: Alexandra Kossovsky <sasha@oktet.ru>
8 *          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
12 *  http://www.rtems.com/license/LICENSE.
13 *
14 * $Id$
15 *
16 */
17
18#define IDE_CONTROLLER_TRACE 0
19
20#include <rtems/chain.h>
21#include <assert.h>
22#include <rtems/blkdev.h>
23
24#include <libchip/ide_ctrl_cfg.h>
25#include <libchip/ide_ctrl_io.h>
26
27#if IDE_CONTROLLER_TRACE
28int ide_controller_trace = 1;
29#endif
30
31/*
32 * ide_controller_initialize --
33 *     Initializes all configured IDE controllers. Controllers configuration
34 *     table is provided by BSP
35 *
36 * PARAMETERS:
37 *     major     - device major number
38 *     minor_arg - device minor number
39 *     args      - arguments
40 *
41 * RETURNS:
42 *     RTEMS_SUCCESSFUL on success, or error code if
43 *     error occured
44 */
45rtems_device_driver
46ide_controller_initialize(rtems_device_major_number  major,
47                          rtems_device_minor_number  minor_arg,
48                          void                      *args)
49{
50    unsigned long       minor;
51    rtems_status_code   status;
52
53    /* FIXME: may be it should be done on compilation phase */
54    if (IDE_Controller_Count > IDE_CTRL_MAX_MINOR_NUMBER)
55        rtems_fatal_error_occurred(RTEMS_TOO_MANY);
56
57    for (minor=0; minor < IDE_Controller_Count; minor++)
58    {
59        IDE_Controller_Table[minor].status = IDE_CTRL_NON_INITIALIZED;
60
61        if ((IDE_Controller_Table[minor].probe == NULL ||
62             IDE_Controller_Table[minor].probe(minor)) &&
63            (IDE_Controller_Table[minor].fns->ctrl_probe == NULL ||
64             IDE_Controller_Table[minor].fns->ctrl_probe(minor)))
65        {
66            status = rtems_io_register_name(IDE_Controller_Table[minor].name,
67                                            major, minor);
68            if (status != RTEMS_SUCCESSFUL)
69                rtems_fatal_error_occurred(status);
70
71            IDE_Controller_Table[minor].fns->ctrl_initialize(minor);
72
73            IDE_Controller_Table[minor].status = IDE_CTRL_INITIALIZED;
74        }
75    }
76    return RTEMS_SUCCESSFUL;
77}
78
79/*
80 * ide_controller_read_data_block --
81 *     Read data block via controller's data register
82 *
83 * PARAMETERS:
84 *     minor      - minor number of controller
85 *     block_size - number of bytes to read
86 *     bufs       - set of buffers to store data
87 *     cbuf       - number of current buffer from the set
88 *     pos        - position inside current buffer 'cbuf'
89 *
90 * RETURNS:
91 *     NONE
92 */
93void
94ide_controller_read_data_block(rtems_device_minor_number  minor,
95                               uint32_t                   block_size,
96                               rtems_blkdev_sg_buffer    *bufs,
97                               uint32_t                  *cbuf,
98                               uint32_t                  *pos)
99{
100#if IDE_CONTROLLER_TRACE
101    if (ide_controller_trace)
102        printk ("IDE data block read: %d:%d\n", *cbuf, bufs[*cbuf].block);
103#endif
104    IDE_Controller_Table[minor].fns->ctrl_read_block(minor, block_size, bufs,
105                                                     cbuf, pos);
106}
107
108/*
109 * ide_controller_write_data_block --
110 *     Write data block via controller's data register
111 *
112 * PARAMETERS:
113 *     minor      - minor number of controller
114 *     block_size - number of bytes to write
115 *     bufs       - set of buffers which store data
116 *     cbuf       - number of current buffer from the set
117 *     pos        - position inside current buffer 'cbuf'
118 *
119 * RETURNS:
120 *     NONE
121 */
122void
123ide_controller_write_data_block(rtems_device_minor_number  minor,
124                                uint32_t                   block_size,
125                                rtems_blkdev_sg_buffer    *bufs,
126                                uint32_t                  *cbuf,
127                                uint32_t                  *pos)
128
129{
130#if IDE_CONTROLLER_TRACE
131    if (ide_controller_trace)
132        printk ("IDE data block write: %d:%d\n", *cbuf, bufs[*cbuf].block);
133#endif
134    IDE_Controller_Table[minor].fns->ctrl_write_block(minor, block_size, bufs,
135                                                      cbuf, pos);
136}
137
138/*
139 * ide_controller_read_register --
140 *     Read controller's register
141 *
142 * PARAMETERS:
143 *     minor - minor number of controller
144 *     reg   - register to read
145 *     value - placeholder for result
146 *
147 * RETURNS
148 *     NONE
149 */
150void
151ide_controller_read_register(rtems_device_minor_number  minor,
152                             int                        reg,
153                             uint16_t                  *value)
154{
155    IDE_Controller_Table[minor].fns->ctrl_reg_read(minor, reg, value);
156#if IDE_CONTROLLER_TRACE
157    if (ide_controller_trace)
158        printk ("IDE read reg: %d => %04x\n", reg, *value);
159#endif
160}
161
162/*
163 * ide_controller_write_register --
164 *     Write controller's register
165 *
166 * PARAMETERS:
167 *     minor - minor number of controller
168 *     reg   - register to write
169 *     value - value to write
170 *
171 * RETURNS:
172 *     NONE
173 */
174void
175ide_controller_write_register(rtems_device_minor_number minor, int reg,
176                              uint16_t   value)
177{
178#if IDE_CONTROLLER_TRACE
179    if (ide_controller_trace)
180        printk ("IDE write reg: %d => %04x\n", reg, value);
181#endif
182    IDE_Controller_Table[minor].fns->ctrl_reg_write(minor, reg, value);
183}
184
185/*
186 * ide_controller_config_io_speed --
187 *     Set controller's speed of IO operations
188 *
189 * PARAMETERS:
190 *     minor           - minor number of controller
191 *     modes_available - speeds available
192 *
193 * RETURNS:
194 *     RTEMS_SUCCESSFUL on success, or error code if
195 *     error occured
196 */
197rtems_status_code
198ide_controller_config_io_speed(int minor, uint16_t modes_available)
199{
200    return IDE_Controller_Table[minor].fns->ctrl_config_io_speed(
201               minor,
202               modes_available);
203}
Note: See TracBrowser for help on using the repository browser.