RTEMS 7.0-rc1
Loading...
Searching...
No Matches
ide_ctrl_io.h
1/* SPDX-License-Identifier: GPL-2.0+-with-RTEMS-exception */
2
3/*
4 * ide_ctrl_io.h
5 *
6 * LibChip library IDE controller header file - IO operations defined for
7 * IDE controllers.
8 *
9 * Copyright (C) 2002 OKTET Ltd., St.-Petersburg, Russia
10 * Author: Eugeny S. Mints <Eugeny.Mints@oktet.ru>
11 *
12 * The license and distribution terms for this file may be
13 * found in the file LICENSE in this distribution or at
14 * http://www.rtems.org/license/LICENSE.
15 */
16#ifndef __IDE_CTRL_IO_H__
17#define __IDE_CTRL_IO_H__
18
19#ifdef __cplusplus
20extern "C" {
21#endif
22
23#include <rtems/blkdev.h>
24
25/* Command Block Registers */
26#define IDE_REGISTER_DATA 0
27#define IDE_REGISTER_ERROR 1
28#define IDE_REGISTER_FEATURES IDE_REGISTER_ERROR
29#define IDE_REGISTER_SECTOR_COUNT 2
30#define IDE_REGISTER_SECTOR_NUMBER 3
31#define IDE_REGISTER_LBA0 IDE_REGISTER_SECTOR_NUMBER
32#define IDE_REGISTER_CYLINDER_LOW 4
33#define IDE_REGISTER_LBA1 IDE_REGISTER_CYLINDER_LOW
34#define IDE_REGISTER_CYLINDER_HIGH 5
35#define IDE_REGISTER_LBA2 IDE_REGISTER_CYLINDER_HIGH
36#define IDE_REGISTER_DEVICE_HEAD 6
37#define IDE_REGISTER_LBA3 IDE_REGISTER_DEVICE_HEAD
38#define IDE_REGISTER_STATUS 7
39#define IDE_REGISTER_COMMAND IDE_REGISTER_STATUS
40
41/* Control Block Registers */
42#define IDE_REGISTER_ALTERNATE_STATUS 6
43#define IDE_REGISTER_DEVICE_CONTROL IDE_REGISTER_ALTERNATE_STATUS
44
45/* offsets used to access registers */
46#define IDE_REGISTER_DEVICE_CONTROL_OFFSET 8
47#define IDE_REGISTER_ALTERNATE_STATUS_OFFSET IDE_REGISTER_DEVICE_CONTROL_OFFSET
48#define IDE_REGISTER_DATA_BYTE 9
49#define IDE_REGISTER_DATA_WORD 10
50
51/*
52 * Registers bits
53 */
54#define IDE_REGISTER_STATUS_BSY 0x80 /* Busy bit */
55#define IDE_REGISTER_STATUS_DRDY 0x40 /* Device ready */
56#define IDE_REGISTER_STATUS_DF 0x20 /* Device fault */
57#define IDE_REGISTER_STATUS_DSC 0x10 /* Device seek complete-- */
58 /* obsolete */
59#define IDE_REGISTER_STATUS_DRQ 0x08 /* Data request */
60#define IDE_REGISTER_STATUS_CORR 0x04 /* Corrected data-- */
61 /* vendor specific--obsolete */
62#define IDE_REGISTER_STATUS_IDX 0x02 /* Index-- */
63 /* vendor specific--obsolete */
64#define IDE_REGISTER_STATUS_ERR 0x01 /* Error */
65
66#define IDE_REGISTER_DEVICE_CONTROL_SRST 0x04 /* Host software reset bit */
67#define IDE_REGISTER_DEVICE_CONTROL_nIEN 0x02 /* Negated interrupt enable */
68
69#define IDE_REGISTER_DEVICE_HEAD_L 0x40 /* LBA mode bit */
70#define IDE_REGISTER_DEVICE_HEAD_DEV 0x10 /* Device0/Device1 bit */
71#define IDE_REGISTER_DEVICE_HEAD_DEV_POS 4 /* Dev0/Dev1 bit position */
72#define IDE_REGISTER_DEVICE_HEAD_HS 0x0f /* Head/LBA24_27 bits */
73#define IDE_REGISTER_LBA3_L 0x40
74#define IDE_REGISTER_LBA3_DEV 0x10
75#define IDE_REGISTER_LBA3_LBA 0x0f
76
77#define IDE_REGISTER_ERROR_ICRC (1 << 7) /* Interface CRC error on */
78 /* UDMA data transfer */
79#define IDE_REGISTER_ERROR_UNC (1 << 6) /* Uncorrectable data error */
80#if CCJ_COULD_NOT_FIND_THIS_ERROR
81#define IDE_REGISTER_ERROR_WP (1 << 6) /* Write protect */
82#endif
83#define IDE_REGISTER_ERROR_MC (1 << 5) /* Media changed */
84#define IDE_REGISTER_ERROR_IDNF (1 << 4) /* Sector ID not found */
85#define IDE_REGISTER_ERROR_MCR (1 << 3) /* Media change requested */
86 /* obsolette */
87#define IDE_REGISTER_ERROR_ABRT (1 << 2) /* Aborted command */
88#define IDE_REGISTER_ERROR_NM (1 << 1) /* No media, End of Media. */
89#define IDE_REGISTER_ERROR_AMNF (1 << 0) /* Address mark not found */
90 /* --obsolette in ATA-4 */
91#define IDE_REGISTER_ERROR_MED (1 << 0) /* Media error is detected */
92
93/*
94 * ide_controller_read_data_block --
95 * Read data block via controller's data register
96 *
97 * PARAMETERS:
98 * minor - minor number of controller
99 * block_size - number of bytes to read
100 * bufs - set of buffers to store data
101 * cbuf - number of current buffer from the set
102 * pos - position inside current buffer 'cbuf'
103 *
104 * RETURNS:
105 * NONE
106 */
107void
108ide_controller_read_data_block(rtems_device_minor_number minor,
109 uint32_t block_size,
111 uint32_t *cbuf,
112 uint32_t *pos);
113
114/*
115 * ide_controller_write_data_block --
116 * Write data block via controller's data register
117 *
118 * PARAMETERS:
119 * minor - minor number of controller
120 * block_size - number of bytes to write
121 * bufs - set of buffers which store data
122 * cbuf - number of current buffer from the set
123 * pos - position inside current buffer 'cbuf'
124 *
125 * RETURNS:
126 * NONE
127 */
128void
129ide_controller_write_data_block(rtems_device_minor_number minor,
130 uint32_t block_size,
132 uint32_t *cbuf,
133 uint32_t *pos);
134
135/*
136 * ide_controller_read_register --
137 * Read controller's register
138 *
139 * PARAMETERS:
140 * minor - minor number of controller
141 * reg - register to read
142 * value - placeholder for result
143 *
144 * RETURNS
145 * NONE
146 */
147void
148ide_controller_read_register(rtems_device_minor_number minor,
149 int reg,
150 uint16_t *value);
151
152/*
153 * ide_controller_write_register --
154 * Write controller's register
155 *
156 * PARAMETERS:
157 * minor - minor number of controller
158 * reg - register to write
159 * value - value to write
160 *
161 * RETURNS:
162 * NONE
163 */
164void
165ide_controller_write_register(rtems_device_minor_number minor,
166 int reg, uint16_t value);
167
168/*
169 * ide_controller_config_io_speed --
170 * Set controller's speed of IO operations
171 *
172 * PARAMETERS:
173 * minor - minor number of controller
174 * modes_available - speeds available
175 *
176 * RETURNS:
177 * RTEMS_SUCCESSFUL on success, or error code if
178 * error occured
179 */
181ide_controller_config_io_speed(int minor, uint16_t modes_available);
182
183#ifdef __cplusplus
184}
185#endif
186
187
188#endif /* __IDE_CTRL_IO_H__ */
Block Device Management.
uint32_t rtems_device_minor_number
This integer type represents the minor number of devices.
Definition: io.h:115
rtems_status_code
This enumeration provides status codes for directives of the Classic API.
Definition: status.h:85
Block device scatter or gather buffer structure.
Definition: blkdev.h:68