source: rtems/doc/bsp_howto/ata.t @ 7a845e2f

4.104.114.84.95
Last change on this file since 7a845e2f was 51eacee9, checked in by Joel Sherrill <joel.sherrill@…>, on 10/28/02 at 13:44:39

2002-10-24 Eugeny S. Mints <Eugeny.Mints@…>

  • ata.t, ide-ctrl.t: New file.
  • .cvsignore: Added new .texi files.
  • Makefile.am:: Added new files to generate.
  • bsp_howto.texi: Added new chapters.
  • stamp-vti, version.texi: Regenerated.
  • Property mode set to 100644
File size: 7.0 KB
Line 
1@c
2@c  COPYRIGHT (c) 1988-2002.
3@c  On-Line Applications Research Corporation (OAR).
4@c  All rights reserved.
5@c
6@c  $Id$
7@c
8
9@chapter ATA Driver
10
11@section Terms
12
13ATA device - physical device attached to an IDE controller
14
15@section Introduction
16
17ATA driver provides generic interface to an ATA device. ATA driver is
18hardware independant implementation of ATA standart defined in working draft
19"AT Attachment Interface with Extentions (ATA-2)" X3T10/0948D revision 4c,
20March 18, 1996. ATA Driver based on IDE Controller Driver and may be used for
21computer systems with single IDE controller and with multiple as well. Although
22current implementation has several restrictions detailed below ATA driver
23architecture allows easily extend the driver. Current restrictions are:
24
25@itemize @bullet
26@item Only mandatory (see draft p.29) and two optional (READ/WRITE MULTIPLE)
27commands are implemented
28@item Only PIO mode is supported but both poll and interrupt driven
29@end itemize
30
31The reference implementation for ATA driver can be found in
32@code{c/src/exec/libblock/src/ata.c}. 
33
34@section Initialization
35
36The @code{ata_initialize} routine is responsible for ATA driver
37initialization. The main goal of the initialization is to detect and
38register in the system all ATA devices attached to IDE controllers
39successfully initialized by the IDE Controller driver.
40
41In the implementation of the driver, the following actions are performed:
42
43@example
44@group
45rtems_device_driver ata_initialize(
46  rtems_device_major_number  major,
47  rtems_device_minor_number  minor,
48  void                      *arg
49)
50@{
51   initialize internal ATA driver data structure
52
53   for each IDE controller successfully initialized by the IDE Controller
54       driver
55     if the controller is interuupt driven
56       set up interrupt handler
57
58     obtain information about ATA devices attached to the controller
59     with help of EXECUTE DEVICE DIAGNOSTIC command
60
61     for each ATA device detected on the controller
62       obtain device parameters with help of DEVICE IDENTIFY command
63
64       register new ATA device as new block device in the system
65@}
66@end group
67@end example
68
69Special processing of ATA commands is required because of absence of
70multitasking enviroment during the driver initialization.
71
72Detected ATA devices are registered in the system as physical block devices
73(see libblock library description). Device names are formed based on IDE
74controller minor number device is attached to and device number on the
75controller (0 - Master, 1 - Slave). In current implementation 64 minor
76numbers are reserved for each ATA device which allows to support up to 63
77logical partitions per device.
78
79@example
80@group
81controller minor    device number    device name    ata device minor
82      0                  0             hda                0
83      0                  1             hdb               64
84      1                  0             hdc              128
85      1                  1             hdd              172
86     ...                ...            ...
87@end group
88@end example
89
90@section ATA Driver Architecture
91
92@subsection ATA Driver Main Internal Data Structures
93
94ATA driver works with ATA requests. ATA request is described by the
95following structure:
96
97@example
98@group
99/* ATA request */
100typedef struct ata_req_s @{
101    Chain_Node        link;   /* link in requests chain */
102    char              type;   /* request type */
103    ata_registers_t   regs;   /* ATA command */
104    rtems_unsigned32  cnt;    /* Number of sectors to be exchanged */
105    rtems_unsigned32  cbuf;   /* number of current buffer from breq in use */
106    rtems_unsigned32  pos;    /* current position in 'cbuf' */
107    blkdev_request   *breq;   /* blkdev_request which corresponds to the
108                               * ata request
109                               */
110    rtems_id          sema;   /* semaphore which is used if synchronous
111                               * processing of the ata request is required
112                               */
113    rtems_status_code status; /* status of ata request processing */
114    int               error;  /* error code */
115@} ata_req_t;
116@end group
117@end example
118
119ATA driver supports separate ATA requests queues for each IDE
120controller (one queue per controller). The following structure contains
121inforamtion about controller's queue and devices attached to the controller:
122
123@example
124@group
125/*
126 * This structure describes controller state, devices configuration on the
127 * controller and chain of ATA requests to the controller.
128 */
129typedef struct ata_ide_ctrl_s @{
130    rtems_boolean present;   /* controller state */
131    ata_dev_t     device[2]; /* ata diveces description */
132    Chain_Control reqs;      /* requests chain */
133@} ata_ide_ctrl_t;
134@end group
135@end example
136
137Driver uses array of the structures indexed by the controllers minor
138number.
139
140The following struture allows to map an ATA device to the pair (IDE
141controller minor number device is attached to, device number
142on the controller):
143
144@example
145@group
146/*
147 * Mapping of rtems ATA devices to the following pairs:
148 * (IDE controller number served the device, device number on the controller)
149 */
150typedef struct ata_ide_dev_s @{
151    int ctrl_minor;/* minor number of IDE controller serves rtems ATA device */
152    int device;    /* device number on IDE controller (0 or 1) */
153@} ata_ide_dev_t;
154@end group
155@end example
156
157Driver uses array of the structures indexed by the ATA devices minor
158number.
159
160ATA driver defines the following internal events:
161
162@example
163@group
164/* ATA driver events */
165typedef enum ata_msg_type_s @{
166    ATA_MSG_GEN_EVT = 1,     /* general event */
167    ATA_MSG_SUCCESS_EVT,     /* success event */
168    ATA_MSG_ERROR_EVT,       /* error event */
169    ATA_MSG_PROCESS_NEXT_EVT /* process next ata request event */
170@} ata_msg_type_t;
171@end group
172@end example
173
174@subsection Brief ATA Driver Core Overview
175
176All ATA driver functionality is available via ATA driver ioctl. Current
177implementation supports only two ioctls: BLKIO_REQUEST and
178ATAIO_SET_MULTIPLE_MODE. Each ATA driver ioctl() call generates an
179ATA request which is appended to the apropriate controller queue depending
180on ATA device the request belongs to. If appended request is single request in
181the controller's queue then ATA driver event is generated.
182
183ATA driver task which manages queue of ATA driver events is core of ATA
184driver. In current driver version queue of ATA driver events implemented
185as RTEMS message queue. Each message contains event type, IDE controller
186minor number on which event happaned and error if an error occured. Events
187may be generated either by ATA driver ioctl call or by ATA driver task itself.
188Each time ATA driver task receives an event it gets controller minor number
189from event, takes first ATA request from controller queue and processes it
190depending on request and event types. An ATA request processing may also
191includes sending of several events. If ATA request processing is finished
192the ATA request is removed from the controller queue. Note, that in current
193implementation maximum one event per controller may be queued at any moment
194of the time.
195
196(This part seems not very clear, hope I rewrite it soon)
197
198
199
Note: See TracBrowser for help on using the repository browser.