source: rtems-docs/bsp_howto/ata.rst @ 548f844

4.115
Last change on this file since 548f844 was b350509, checked in by Amar Takhar <amar@…>, on 01/17/16 at 05:47:50

Split document into seperate files by section.

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