source: rtems/c/src/libchip/ide/ide_controller.c @ 39b8611

4.104.115
Last change on this file since 39b8611 was 39b8611, checked in by Joel Sherrill <joel.sherrill@…>, on 03/11/10 at 19:17:39

2010-03-11 Joel Sherrill <joel.sherrill@…>

  • libchip/ide/ide_controller.c: Fix warnings for uninitialized variable.
  • Property mode set to 100644
File size: 5.8 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 <errno.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
52    /* FIXME: may be it should be done on compilation phase */
53    if (IDE_Controller_Count > IDE_CTRL_MAX_MINOR_NUMBER)
54        rtems_fatal_error_occurred(RTEMS_TOO_MANY);
55
56    for (minor=0; minor < IDE_Controller_Count; minor++)
57    {
58        IDE_Controller_Table[minor].status = IDE_CTRL_NON_INITIALIZED;
59
60        if ((IDE_Controller_Table[minor].probe == NULL ||
61             IDE_Controller_Table[minor].probe(minor)) &&
62            (IDE_Controller_Table[minor].fns->ctrl_probe == NULL ||
63             IDE_Controller_Table[minor].fns->ctrl_probe(minor)))
64        {
65            dev_t  dev;
66            dev = rtems_filesystem_make_dev_t( major, minor );
67            if (mknod(IDE_Controller_Table[minor].name,
68                      0777 | S_IFBLK, dev ) < 0)
69                rtems_fatal_error_occurred(errno);
70            IDE_Controller_Table[minor].fns->ctrl_initialize(minor);
71            IDE_Controller_Table[minor].status = IDE_CTRL_INITIALIZED;
72        }
73    }
74    return RTEMS_SUCCESSFUL;
75}
76
77/*
78 * ide_controller_read_data_block --
79 *     Read data block via controller's data register
80 *
81 * PARAMETERS:
82 *     minor      - minor number of controller
83 *     block_size - number of bytes to read
84 *     bufs       - set of buffers to store data
85 *     cbuf       - number of current buffer from the set
86 *     pos        - position inside current buffer 'cbuf'
87 *
88 * RETURNS:
89 *     NONE
90 */
91void
92ide_controller_read_data_block(rtems_device_minor_number  minor,
93                               uint32_t                   block_size,
94                               rtems_blkdev_sg_buffer    *bufs,
95                               uint32_t                  *cbuf,
96                               uint32_t                  *pos)
97{
98#if IDE_CONTROLLER_TRACE
99    if (ide_controller_trace)
100        printk ("IDE data block read: %d:%d\n", *cbuf, bufs[*cbuf].block);
101#endif
102    IDE_Controller_Table[minor].fns->ctrl_read_block(minor, block_size, bufs,
103                                                     cbuf, pos);
104}
105
106/*
107 * ide_controller_write_data_block --
108 *     Write data block via controller's data register
109 *
110 * PARAMETERS:
111 *     minor      - minor number of controller
112 *     block_size - number of bytes to write
113 *     bufs       - set of buffers which store data
114 *     cbuf       - number of current buffer from the set
115 *     pos        - position inside current buffer 'cbuf'
116 *
117 * RETURNS:
118 *     NONE
119 */
120void
121ide_controller_write_data_block(rtems_device_minor_number  minor,
122                                uint32_t                   block_size,
123                                rtems_blkdev_sg_buffer    *bufs,
124                                uint32_t                  *cbuf,
125                                uint32_t                  *pos)
126
127{
128#if IDE_CONTROLLER_TRACE
129    if (ide_controller_trace)
130        printk ("IDE data block write: %d:%d\n", *cbuf, bufs[*cbuf].block);
131#endif
132    IDE_Controller_Table[minor].fns->ctrl_write_block(minor, block_size, bufs,
133                                                      cbuf, pos);
134}
135
136/*
137 * ide_controller_read_register --
138 *     Read controller's register
139 *
140 * PARAMETERS:
141 *     minor - minor number of controller
142 *     reg   - register to read
143 *     value - placeholder for result
144 *
145 * RETURNS
146 *     NONE
147 */
148void
149ide_controller_read_register(rtems_device_minor_number  minor,
150                             int                        reg,
151                             uint16_t                  *value)
152{
153    IDE_Controller_Table[minor].fns->ctrl_reg_read(minor, reg, value);
154#if IDE_CONTROLLER_TRACE
155    if (ide_controller_trace)
156        printk ("IDE read reg: %d => %04x\n", reg, *value);
157#endif
158}
159
160/*
161 * ide_controller_write_register --
162 *     Write controller's register
163 *
164 * PARAMETERS:
165 *     minor - minor number of controller
166 *     reg   - register to write
167 *     value - value to write
168 *
169 * RETURNS:
170 *     NONE
171 */
172void
173ide_controller_write_register(rtems_device_minor_number minor, int reg,
174                              uint16_t   value)
175{
176#if IDE_CONTROLLER_TRACE
177    if (ide_controller_trace)
178        printk ("IDE write reg: %d => %04x\n", reg, value);
179#endif
180    IDE_Controller_Table[minor].fns->ctrl_reg_write(minor, reg, value);
181}
182
183/*
184 * ide_controller_config_io_speed --
185 *     Set controller's speed of IO operations
186 *
187 * PARAMETERS:
188 *     minor           - minor number of controller
189 *     modes_available - speeds available
190 *
191 * RETURNS:
192 *     RTEMS_SUCCESSFUL on success, or error code if
193 *     error occured
194 */
195rtems_status_code
196ide_controller_config_io_speed(int minor, uint16_t modes_available)
197{
198    return IDE_Controller_Table[minor].fns->ctrl_config_io_speed(
199               minor,
200               modes_available);
201}
Note: See TracBrowser for help on using the repository browser.