RTEMS: bsps/include/libchip/ide_ctrl_io.h Source File

| RTEMS 5.4-rc2

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