1 | .. comment SPDX-License-Identifier: CC-BY-SA-4.0 |
---|
2 | |
---|
3 | .. COMMENT: COPYRIGHT (c) 1988-2002. |
---|
4 | .. COMMENT: On-Line Applications Research Corporation (OAR). |
---|
5 | .. COMMENT: All rights reserved. |
---|
6 | |
---|
7 | IDE Controller Driver |
---|
8 | ********************* |
---|
9 | |
---|
10 | .. warning:: |
---|
11 | |
---|
12 | The ATA/IDE Drivers are out of date and should not be used for new BSPs. |
---|
13 | The preferred alternative is to port the ATA/SATA/SCSI/NVMe support from |
---|
14 | FreeBSD to RTEMS using the `libbsd <https://git.rtems.org/rtems-libbsd>`_. |
---|
15 | Ask on the mailing list if you plan to write a driver for an ATA/IDE device. |
---|
16 | |
---|
17 | Introduction |
---|
18 | ============ |
---|
19 | |
---|
20 | The IDE Controller driver is responsible for providing an interface to an IDE |
---|
21 | Controller. The capabilities provided by this driver are: |
---|
22 | |
---|
23 | - Read IDE Controller register |
---|
24 | |
---|
25 | - Write IDE Controller register |
---|
26 | |
---|
27 | - Read data block through IDE Controller Data Register |
---|
28 | |
---|
29 | - Write data block through IDE Controller Data Register |
---|
30 | |
---|
31 | The reference implementation for an IDE Controller driver can be found in |
---|
32 | ``bsps/shared/dev/ide``. This driver is based on the libchip |
---|
33 | concept and allows to work with any of the IDE Controller chips simply by |
---|
34 | appropriate configuration of BSP. Drivers for a particular IDE Controller chips |
---|
35 | locate in the following directories: drivers for well-known IDE Controller |
---|
36 | chips locate into ``bsps/shared/dev/ide`` |
---|
37 | and drivers for custom IDE |
---|
38 | Controller chips (for example, implemented on FPGA) locate into |
---|
39 | ``bsps/${RTEMS_CPU}/${RTEMS_BSP/ata``. There is a README file in these |
---|
40 | directories for each supported IDE Controller chip. Each of these README |
---|
41 | explains how to configure a BSP for that particular IDE Controller chip. |
---|
42 | |
---|
43 | Initialization |
---|
44 | ============== |
---|
45 | |
---|
46 | IDE Controller chips used by a BSP are statically configured into |
---|
47 | ``IDE_Controller_Table``. The ``ide_controller_initialize`` routine is |
---|
48 | responsible for initialization of all configured IDE controller chips. |
---|
49 | Initialization order of the chips based on the order the chips are defined in |
---|
50 | the ``IDE_Controller_Table``. |
---|
51 | |
---|
52 | The following actions are performed by the IDE Controller driver initialization |
---|
53 | routine: |
---|
54 | |
---|
55 | .. code-block:: c |
---|
56 | |
---|
57 | rtems_device_driver ide_controller_initialize( |
---|
58 | rtems_device_major_number major, |
---|
59 | rtems_device_minor_number minor_arg, |
---|
60 | void *arg |
---|
61 | ) |
---|
62 | { |
---|
63 | for each IDE Controller chip configured in IDE_Controller_Table |
---|
64 | if (BSP dependent probe(if exists) AND device probe for this IDE chip |
---|
65 | indicates it is present) |
---|
66 | perform initialization of the particular chip |
---|
67 | register device with configured name for this chip |
---|
68 | } |
---|
69 | |
---|
70 | Read IDE Controller Register |
---|
71 | ============================ |
---|
72 | |
---|
73 | The ``ide_controller_read_register`` routine reads the content of the IDE |
---|
74 | Controller chip register. IDE Controller chip is selected via the minor |
---|
75 | number. This routine is not allowed to be called from an application. |
---|
76 | |
---|
77 | .. code-block:: c |
---|
78 | |
---|
79 | void ide_controller_read_register( |
---|
80 | rtems_device_minor_number minor, |
---|
81 | unsigned32 reg, |
---|
82 | unsigned32 *value |
---|
83 | ) |
---|
84 | { |
---|
85 | get IDE Controller chip configuration information from |
---|
86 | IDE_Controller_Table by minor number |
---|
87 | |
---|
88 | invoke read register routine for the chip |
---|
89 | } |
---|
90 | |
---|
91 | Write IDE Controller Register |
---|
92 | ============================= |
---|
93 | |
---|
94 | The ``ide_controller_write_register`` routine writes IDE Controller chip |
---|
95 | register with specified value. IDE Controller chip is selected via the minor |
---|
96 | number. This routine is not allowed to be called from an application. |
---|
97 | |
---|
98 | .. code-block:: c |
---|
99 | |
---|
100 | void ide_controller_write_register( |
---|
101 | rtems_device_minor_number minor, |
---|
102 | unsigned32 reg, |
---|
103 | unsigned32 value |
---|
104 | ) |
---|
105 | { |
---|
106 | get IDE Controller chip configuration information from |
---|
107 | IDE_Controller_Table by minor number |
---|
108 | |
---|
109 | invoke write register routine for the chip |
---|
110 | } |
---|
111 | |
---|
112 | Read Data Block Through IDE Controller Data Register |
---|
113 | ==================================================== |
---|
114 | |
---|
115 | The ``ide_controller_read_data_block`` provides multiple consequent read of the |
---|
116 | IDE Controller Data Register. IDE Controller chip is selected via the minor |
---|
117 | number. The same functionality may be achieved via separate multiple calls of |
---|
118 | ``ide_controller_read_register`` routine but ``ide_controller_read_data_block`` |
---|
119 | allows to escape functions call overhead. This routine is not allowed to be |
---|
120 | called from an application. |
---|
121 | |
---|
122 | .. code-block:: c |
---|
123 | |
---|
124 | void ide_controller_read_data_block( |
---|
125 | rtems_device_minor_number minor, |
---|
126 | unsigned16 block_size, |
---|
127 | blkdev_sg_buffer *bufs, |
---|
128 | uint32_t *cbuf, |
---|
129 | uint32_t *pos |
---|
130 | ) |
---|
131 | { |
---|
132 | get IDE Controller chip configuration information from |
---|
133 | IDE_Controller_Table by minor number |
---|
134 | |
---|
135 | invoke read data block routine for the chip |
---|
136 | } |
---|
137 | |
---|
138 | Write Data Block Through IDE Controller Data Register |
---|
139 | ===================================================== |
---|
140 | |
---|
141 | The ``ide_controller_write_data_block`` provides multiple consequent write into |
---|
142 | the IDE Controller Data Register. IDE Controller chip is selected via the minor |
---|
143 | number. The same functionality may be achieved via separate multiple calls of |
---|
144 | ``ide_controller_write_register`` routine but |
---|
145 | ``ide_controller_write_data_block`` allows to escape functions call |
---|
146 | overhead. This routine is not allowed to be called from an application. |
---|
147 | |
---|
148 | .. code-block:: c |
---|
149 | |
---|
150 | void ide_controller_write_data_block( |
---|
151 | rtems_device_minor_number minor, |
---|
152 | unsigned16 block_size, |
---|
153 | blkdev_sg_buffer *bufs, |
---|
154 | uint32_t *cbuf, |
---|
155 | uint32_t *pos |
---|
156 | ) |
---|
157 | { |
---|
158 | get IDE Controller chip configuration information from |
---|
159 | IDE_Controller_Table by minor number |
---|
160 | |
---|
161 | invoke write data block routine for the chip |
---|
162 | } |
---|