1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
|
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 1997 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _ATA_FSM_H
#define _ATA_FSM_H
#pragma ident "%Z%%M% %I% %E% SMI"
#ifdef __cplusplus
extern "C" {
#endif
/*
*
* The interrupt reason can be interpreted from other bits as follows:
*
* IO CoD DRQ
* -- --- ---
* 0 0 1 == 1 Data to device
* 0 1 0 == 2 Idle
* 0 1 1 == 3 Send ATAPI CDB to device
* 1 0 1 == 5 Data from device
* 1 1 0 == 6 Status ready
* 1 1 1 == 7 Future use
*
*/
/*
* This macro encodes the interrupt reason into a one byte
* event code which is used to index the FSM tables
*/
#define ATAPI_EVENT(drq, intr) \
(((unsigned char)((drq) & ATS_DRQ) >> 3) \
| (((intr) & (ATI_IO | ATI_COD)) << 1))
/*
* These are the names for the encoded ATAPI events
*/
#define ATAPI_EVENT_0 0
#define ATAPI_EVENT_IDLE ATAPI_EVENT(0, ATI_COD)
#define ATAPI_EVENT_2 2
#define ATAPI_EVENT_STATUS ATAPI_EVENT(0, ATI_IO | ATI_COD)
#define ATAPI_EVENT_PIO_OUT ATAPI_EVENT(ATS_DRQ, 0)
#define ATAPI_EVENT_CDB ATAPI_EVENT(ATS_DRQ, ATI_COD)
#define ATAPI_EVENT_PIO_IN ATAPI_EVENT(ATS_DRQ, ATI_IO)
#define ATAPI_EVENT_UNKNOWN ATAPI_EVENT(ATS_DRQ, (ATI_IO | ATI_COD))
#define ATAPI_NEVENTS 8
/*
* Actions for the ATAPI PIO FSM
*
*/
enum {
A_UNK, /* invalid event detected */
A_NADA, /* do nothing */
A_CDB, /* send the CDB */
A_IN, /* transfer data out to the device */
A_OUT, /* transfer data in from the device */
A_IDLE, /* unexpected idle phase */
A_RE, /* read the error code register */
A_REX /* alternate read the error code register */
};
/*
* States for the ATAPI PIO FSM
*/
enum {
S_IDLE, /* idle or fatal error state */
S_CMD, /* command byte sent */
S_CDB, /* CDB sent */
S_IN, /* transferring data in from device */
S_OUT, /* transferring data out to device */
S_DMA, /* dma transfer active */
ATAPI_NSTATES
};
#define S_X S_IDLE /* alias for idle */
/*
* controller and device functions
*/
enum {
ATA_FSM_START0,
ATA_FSM_START1,
ATA_FSM_INTR,
ATA_FSM_FINI,
ATA_FSM_RESET,
ATA_CTLR_NFUNCS
};
/*
* FSM return codes
*/
enum {
ATA_FSM_RC_OKAY,
ATA_FSM_RC_BUSY,
ATA_FSM_RC_INTR,
ATA_FSM_RC_FINI
};
/*
* states for the controller FSM
*/
enum {
AS_IDLE,
AS_ACTIVE0,
AS_ACTIVE1,
ATA_CTLR_NSTATES
};
/*
* actions for the controller FSM
*/
enum {
AC_NADA,
AC_START,
AC_INTR,
AC_FINI,
AC_BUSY,
AC_RESET_I,
AC_RESET_A
};
#ifdef __cplusplus
}
#endif
#endif /* _ATA_FSM_H */
|