source: rtems/c/src/lib/libbsp/shared/ide_ctrl.c @ cf720006

4.104.114.84.95
Last change on this file since cf720006 was cf720006, checked in by Ralf Corsepius <ralf.corsepius@…>, on 04/01/04 at 10:11:53

2004-04-01 Ralf Corsepius <ralf_corsepius@…>

  • ide_ctrl.c: Include <rtems/chain.h> instead of <chain.h>.
  • Property mode set to 100644
File size: 5.2 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#include <rtems/chain.h>
18#include <assert.h>
19#include <rtems/blkdev.h>
20
21#include <libchip/ide_ctrl_cfg.h>
22#include <libchip/ide_ctrl_io.h>
23
24/*
25 * ide_controller_initialize --
26 *     Initializes all configured IDE controllers. Controllers configuration
27 *     table is provided by BSP
28 *
29 * PARAMETERS:
30 *     major     - device major number
31 *     minor_arg - device minor number
32 *     args      - arguments
33 *
34 * RETURNS:
35 *     RTEMS_SUCCESSFUL on success, or error code if
36 *     error occured
37 */
38rtems_device_driver
39ide_controller_initialize(rtems_device_major_number  major,
40                          rtems_device_minor_number  minor_arg,
41                          void                      *args)
42{
43    unsigned long       minor;
44    rtems_status_code   status;
45
46    /* FIXME: may be it should be done on compilation phase */
47    if (IDE_Controller_Count > IDE_CTRL_MAX_MINOR_NUMBER)
48        rtems_fatal_error_occurred(RTEMS_TOO_MANY);
49       
50    for (minor=0; minor < IDE_Controller_Count; minor++)
51    {
52        IDE_Controller_Table[minor].status = IDE_CTRL_NON_INITIALIZED;
53       
54        if ((IDE_Controller_Table[minor].probe != NULL &&
55             IDE_Controller_Table[minor].probe(minor)) ||
56            IDE_Controller_Table[minor].fns->ctrl_probe(minor))
57        {
58            status = rtems_io_register_name(IDE_Controller_Table[minor].name,
59                                            major, minor);
60            if (status != RTEMS_SUCCESSFUL)
61                rtems_fatal_error_occurred(status);
62
63            IDE_Controller_Table[minor].fns->ctrl_initialize(minor);
64           
65            IDE_Controller_Table[minor].status = IDE_CTRL_INITIALIZED;
66        }
67    }
68    return RTEMS_SUCCESSFUL;
69}
70
71/*
72 * ide_controller_read_data_block --
73 *     Read data block via controller's data register
74 *
75 * PARAMETERS:
76 *     minor      - minor number of controller
77 *     block_size - number of bytes to read
78 *     bufs       - set of buffers to store data
79 *     cbuf       - number of current buffer from the set
80 *     pos        - position inside current buffer 'cbuf'
81 *
82 * RETURNS:
83 *     NONE
84 */
85void
86ide_controller_read_data_block(rtems_device_minor_number  minor,
87                               uint16_t                   block_size,
88                               blkdev_sg_buffer          *bufs,
89                               uint32_t                  *cbuf,
90                               uint32_t                  *pos)
91{
92    IDE_Controller_Table[minor].fns->ctrl_read_block(minor, block_size, bufs,
93                                                     cbuf, pos);
94}
95
96/*
97 * ide_controller_write_data_block --
98 *     Write data block via controller's data register
99 *
100 * PARAMETERS:
101 *     minor      - minor number of controller
102 *     block_size - number of bytes to write
103 *     bufs       - set of buffers which store data
104 *     cbuf       - number of current buffer from the set
105 *     pos        - position inside current buffer 'cbuf'
106 *
107 * RETURNS:
108 *     NONE
109 */
110void
111ide_controller_write_data_block(rtems_device_minor_number  minor,
112                                uint16_t                   block_size,
113                                blkdev_sg_buffer          *bufs,
114                                uint32_t                  *cbuf,
115                                uint32_t                  *pos)
116
117{
118    IDE_Controller_Table[minor].fns->ctrl_write_block(minor, block_size, bufs,
119                                                      cbuf, pos);
120}
121
122/*
123 * ide_controller_read_register --
124 *     Read controller's register
125 *
126 * PARAMETERS:
127 *     minor - minor number of controller
128 *     reg   - register to read
129 *     value - placeholder for result
130 *
131 * RETURNS
132 *     NONE
133 */
134void
135ide_controller_read_register(rtems_device_minor_number  minor,
136                             int                        reg,
137                             uint16_t                  *value)
138{
139    IDE_Controller_Table[minor].fns->ctrl_reg_read(minor, reg, value);
140}
141
142/*
143 * ide_controller_write_register --
144 *     Write controller's register
145 *
146 * PARAMETERS:
147 *     minor - minor number of controller
148 *     reg   - register to write
149 *     value - value to write
150 *
151 * RETURNS:
152 *     NONE
153 */
154void
155ide_controller_write_register(rtems_device_minor_number minor, int reg,
156                              uint16_t   value)
157{
158    IDE_Controller_Table[minor].fns->ctrl_reg_write(minor, reg, value);
159}
160
161/*
162 * ide_controller_config_io_speed --
163 *     Set controller's speed of IO operations
164 *
165 * PARAMETERS:
166 *     minor         - minor number of controller
167 *     modes_avaible - speeds available
168 *
169 * RETURNS:
170 *     RTEMS_SUCCESSFUL on success, or error code if
171 *     error occured
172 */
173rtems_status_code
174ide_controller_config_io_speed(int minor, uint8_t   modes_avaible)
175{
176    return IDE_Controller_Table[minor].fns->ctrl_config_io_speed(
177               minor,
178               modes_avaible);
179}
Note: See TracBrowser for help on using the repository browser.