source: rtems/c/src/libchip/ide/ide_ctrl_io.h @ d0e2fa3

4.104.115
Last change on this file since d0e2fa3 was 3735f08, checked in by Chris Johns <chrisj@…>, on 07/29/08 at 02:23:48

2008-07-29 Chris Johns <chrisj@…>

  • libchip/i2c/spi-sd-card.c: Updated to the libblock changes.
  • libchip/ide/ata.c: Change to use a mutex rather than disable pre-emption. Updated to the libblock changes.
  • libchip/ide/ata_internal.h: Updated to the new chains API.
  • libchip/ide/ide_controller.c: Updated to the libblock changes. Added come debug tracing.
  • libchip/ide/ide_ctrl_cfg.h, libchip/ide/ide_ctrl_io.h: Updated to the libblock changes.
  • Property mode set to 100644
File size: 6.4 KB
Line 
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.com/license/LICENSE.
13 *
14 * $Id$
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          0x80  /* Interface CRC error on */
78                                               /* UDMA data transfer */
79#define IDE_REGISTER_ERROR_UNC           0x40  /* Uncorrectable data error */
80#define IDE_REGISTER_ERROR_WP            0x40  /* Write protect */
81#define IDE_REGISTER_ERROR_MC            0x20  /* Media changed */
82#define IDE_REGISTER_ERROR_IDNF          0x10  /* Sector ID not found */
83#define IDE_REGISTER_ERROR_MCR           0x08  /* Media change requested */
84#define IDE_REGISTER_ERROR_ABRT          0x04  /* Aborted command */
85#define IDE_REGISTER_ERROR_NM            0x02  /* No media */
86#define IDE_REGISTER_ERROR_AMNF          0x01  /* Address mark not found */
87                                               /* --obsolette in ATA-4 */
88#define IDE_REGISTER_ERROR_MED           0x01  /* Media error is detected */
89
90/*
91 * ide_controller_read_data_block --
92 *     Read data block via controller's data register
93 *
94 * PARAMETERS:
95 *     minor      - minor number of controller
96 *     block_size - number of bytes to read
97 *     bufs       - set of buffers to store data
98 *     cbuf       - number of current buffer from the set
99 *     pos        - position inside current buffer 'cbuf'
100 *
101 * RETURNS:
102 *     NONE
103 */
104void
105ide_controller_read_data_block(rtems_device_minor_number  minor,
106                               uint16_t                   block_size,
107                               rtems_blkdev_sg_buffer    *bufs,
108                               uint32_t                  *cbuf,
109                               uint32_t                  *pos);
110
111/*
112 * ide_controller_write_data_block --
113 *     Write data block via controller's data register
114 *
115 * PARAMETERS:
116 *     minor      - minor number of controller
117 *     block_size - number of bytes to write
118 *     bufs       - set of buffers which store data
119 *     cbuf       - number of current buffer from the set
120 *     pos        - position inside current buffer 'cbuf'
121 *
122 * RETURNS:
123 *     NONE
124 */
125void
126ide_controller_write_data_block(rtems_device_minor_number  minor,
127                                uint16_t                   block_size,
128                                rtems_blkdev_sg_buffer    *bufs,
129                                uint32_t                  *cbuf,
130                                uint32_t                  *pos);
131
132/*
133 * ide_controller_read_register --
134 *     Read controller's register
135 *
136 * PARAMETERS:
137 *     minor - minor number of controller
138 *     reg   - register to read
139 *     value - placeholder for result
140 *
141 * RETURNS
142 *     NONE
143 */
144void
145ide_controller_read_register(rtems_device_minor_number  minor,
146                             int                        reg,
147                             uint16_t                  *value);
148
149/*
150 * ide_controller_write_register --
151 *     Write controller's register
152 *
153 * PARAMETERS:
154 *     minor - minor number of controller
155 *     reg   - register to write
156 *     value - value to write
157 *
158 * RETURNS:
159 *     NONE
160 */
161void
162ide_controller_write_register(rtems_device_minor_number minor,
163                              int reg, uint16_t   value);
164
165/*
166 * ide_controller_config_io_speed --
167 *     Set controller's speed of IO operations
168 *
169 * PARAMETERS:
170 *     minor           - minor number of controller
171 *     modes_available - speeds available
172 *
173 * RETURNS:
174 *     RTEMS_SUCCESSFUL on success, or error code if
175 *     error occured
176 */
177rtems_status_code
178ide_controller_config_io_speed(int minor, uint16_t modes_available);
179
180#ifdef __cplusplus
181}
182#endif
183
184
185#endif /* __IDE_CTRL_IO_H__ */
Note: See TracBrowser for help on using the repository browser.