source: rtems-docs/bsp_howto/ata.rst @ 9aafb39

4.115
Last change on this file since 9aafb39 was a1c7180, checked in by Joel Sherrill <joel@…>, on 10/28/16 at 00:19:00

Misc: Capitalize RTEMS.

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