]> git.saurik.com Git - apple/xnu.git/blame - iokit/IOKit/ata/IOATADevice_Reference.h
xnu-201.42.3.tar.gz
[apple/xnu.git] / iokit / IOKit / ata / IOATADevice_Reference.h
CommitLineData
1c79356b
A
1/*
2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
11 *
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
18 * under the License.
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22
23/*!
24@header IOATADevice_Reference.h
25
26This header defines the IOATADevice class.
27
28The ATA/ATAPI framework creates instances of this class to
29represent each valid ATA/ATAPI device detected during
30ATA bus scanning. When an instance of this class is registered with
31IOKit, the instance will be presented to clients which
32'match' the IOATADevice class.
33*/
34
35/*!
36@enum ATADeviceType
37Defines ATA/ATAPI Device types.
38@constant kATADeviceNone
39Indicates no device installed.
40@constant kATADeviceATA
41Indicates ATA type device, i.e. packet protocols not supported.
42@constant kATADeviceATAPI
43Indicates ATAPI type device, i.e. packet protocols supported.
44*/
45enum ATADeviceType {
46
47 kATADeviceNone,
48 kATADeviceATA,
49 kATADeviceATAPI,
50
51};
52
53/*!
54@enum ATATimingProtocol
55Defines supported transport timing. See getTimingsSupported(), selectTiming().
56@constant kATATimingPIO
57Indicates transport timing is for Programmed I/O.
58@constant kATATimingDMA
59Indicates transport timing is for DMA.
60@constant kATATimingDMA33
61Indicates transport timing is for Ultra DMA/33.
62@constant kATATimingDMA66
63Indicates transport timing is for Ultra DMA/66.
64@constant kATAMaxTimings
65Indicates number of timing protocols defined.
66*/
67enum ATATimingProtocol
68{
69 kATATimingPIO = (1 << 0),
70 kATATimingDMA = (1 << 1),
71 kATATimingUltraDMA33 = (1 << 2),
72 kATATimingUltraDMA66 = (1 << 3),
73 kATAMaxTimings = 4,
74
75};
76
77/*!
78@enum ATAProtocol
79Defines supported transport protocols. See getProtocolsSupported().
80@constant kATAProtocolNone
81Indicates no transport protocol defined.
82@constant kATAProtocolSetRegs
83Indicates the transport driver should do a Set ATA Registers operation. For this
84protocol, the transport driver sets the requested taskfile registers as indicated
85in the ATATaskfile structure and then reads back the taskfile registers requested.
86The transport presumes the device will not generate an interrupt as a result
87of this operation.
88@constant kATAProtocolPIO
89Indicates the transport driver should do a Programmed I/O operation. For this
90protocol, the transport driver sets the requested taskfile registers, and transfers
91data to/from the IOATADevice via Programmed I/O operations. The IOATADevice client
92can control the direction/amount data transferred by using setPointers() function.
93The client can indicate a zero data transfer length to implement non-data transfer
94commands such as power-management and set features.
95@constant kATAProtocolDMA
96Indicates the transport driver should do a DMA I/O operation to the device. For this
97protocol, the transport driver sets the requested taskfile registers, and transfers
98data to/from the IOATADevice via DMA operations.
99@constant kATAProtocolDMAQueued
100Indicates the transport driver should do DMA Queued I/O operations. In this case,
101the driver will queue multiple I/O operations at the IOATADevice. Both the device
102and the transport driver must support this protocol.
103@constant kATAProtocolDMAQueueRelease
104Indicates the transport driver should do DMA Queued I/O operations with bus release.
105In this case, the driver will queue multiple I/O operations at the IOATADevice. In
106addition this protocol allows Overlap between both devices on the ATA Bus.
107@constant kATAProtocolATAPIPIO
108Indicates the transport driver should send an use ATAPI packet protocol and transfer
109data to/from the device via PIO cycles.
110@constant kATAProtocolATAPIDMA
111Indicates the transport driver should send an use ATAPI packet protocol and transfer
112data to/from the device via DMA cycles.
113*/
114enum ATAProtocol {
115
116 kATAProtocolNone = 0,
117 kATAProtocolSetRegs = (1 << 0),
118 kATAProtocolPIO = (1 << 1),
119 kATAProtocolDMA = (1 << 2),
120 kATAProtocolDMAQueued = (1 << 3),
121 kATAProtocolDMAQueuedRelease = (1 << 4),
122
123 kATAProtocolATAPIPIO = (1 << 16),
124 kATAProtocolATAPIDMA = (1 << 17),
125
126};
127
128/*!
129@typedef ATATiming
130@abstract
131Provides the low-level cycle times for the transport timing indicated.
132@discussion
133See enum ATATimingProtocols for a list of transport timing protocols.
134@field timingProtocol
135Indicates transport timing the structure refers to. See enum ATATimingProtocol
136for a list of transport timings.
137@field mode
138Indicates the ATA DMA/PIO mode supported. The mode is a number indicating preset
139timings for a particular set of timings as defined by the ATA specification.
140@field minDataAccess
141The minimum time (in nS) that IOW-/IOR- indicates that the data is valid for 16-bit
142data transfers. This field does not apply for Ultra/33 and Ultra/66 timings.
143@field minDataCycle
144The minimum time (in nS) that a full 16-bit data transfer will take, i.e. the time
145between consecutive assertions of IOW-/IOR-. For Ultra/33 and Ultra/66 timings
146this field indicates the average single cycle time.
147@field minCmdAccess
148The minimum time (in nS) that IOW-/IOR- indicates that the data is valid for 8-bit
149pio command transfers.
150@field minCmdCycle
151The minimum time (in nS) that a full 8-bit pio data transfer will take, i.e. the time
152between consecutive assertions of IOW-/IOR-.
153*/
154typedef struct ATATiming {
155
156 ATATimingProtocol timingProtocol;
157
158 UInt32 featureSetting;
159
160 UInt32 mode;
161 UInt32 minDataAccess;
162 UInt32 minDataCycle;
163 UInt32 minCmdAccess;
164 UInt32 minCmdCycle;
165 UInt32 reserved_3[9];
166
167} ATATiming;
168
169class IOATAStandardDevice : public IOATADevice
170{
171public:
172
173/*!
174@function allocCommand
175@abstract
176Allocates an IOATACommand object for this device.
177@discussion
178The client uses the allocCommand() member function to allocate IOATACommand(s)
179for an IOATADevice. The client then uses the member functions of
180the IOATACommand to initialize it and send it to the device. A completed IOATACommand
181may be reused for subsequent I/O requests or returned to the ATA/ATAPI Family.
182@param deviceType
183Always specify kIOATADevice.
184@param clientDataSize
185The client may indicate the size of a per-command data area for its own
186use.
187*/
188 IOATACommand *allocCommand( IOATADevice *deviceType, UInt32 clientDataSize = 0 );
189
190/*!
191@function getUnit
192@abstract
193Returns the ATA unit number corresponding to this device.
194*/
195 ATAUnit getUnit();
196
197/*!
198@function getDeviceType
199@abstract
200Returns the type of the corresponding ATA/ATAPI device.
201@discussion
202See enum ATADeviceType for return values for this function.
203*/
204 ATADeviceType getDeviceType();
205
206/*!
207@function getIdentifyData
208@abstract
209Returns the ATA/ATAPI Identify data for the IOATADevice
210@discussion
211Identify data is from the results of the last ATA bus probe.
212@param identifyBuffer
213Pointer to a 512-byte data buffer to receive the ATA/ATAPI Identify data.
214*/
215 bool getIdentifyData( ATAIdentify *identifyBuffer );
216
217/*!
218@function getInquiryData
219@abstract
220Returns ATAPI Inquiry data for the IOATADevice.
221@discussion
222Inquiry data returned is from the results of the last ATA bus probe.
223@param inquiryBufSize
224Size of the buffer supplied.
225@param inquiryBuffer
226Pointer to a buffer to receive the Inquiry data.
227*/
228 bool getInquiryData( UInt32 inquiryBufSize, ATAPIInquiry *inquiryBuffer );
229
230/*!
231@function getDeviceCapacity
232@abstract
233Returns the block count and block size of the ATA/ATAPI device.
234@discussion
235This function returns the capacity as returned by the ATA Identify command for ATA devices,
236and the Read Device Capacity for ATAPI devices. The client should use caution in interpreting
237the results of this function since the results are based on the last ATA bus scan.
238@param blockMax
239Pointer to a (UInt32) to receive the maximum addressable block on the device. Note: The device
240block count is one greater than the maximum addressable block number.
241@param blockSize
242Pointer to a (UInt32) to receive the block size of the device in bytes.
243*/
244 bool getDeviceCapacity( UInt32 *blockMax, UInt32 *blockSize );
245
246
247/*!
248@function getProtocolSupported
249@abstract
250Returns a bit mask of transport protocols this IOATADevice supports.
251@discussion
252There is no guarantee that a particular device/driver combination will support
253all transport protocols defined. The IOATADevice client must use this function
254to determine which ATAProtocol values are valid for this device.
255@param protocolsSupported
256Pointer to a (UInt32) to receive a bit mask of transport protocols supported. See enum
257ATAProtocol of a list of transport protocols.
258*/
259 bool getProtocolsSupported( ATAProtocol *protocolsSupported );
260
261/*!
262@function getTimingsSupported
263@abstract
264Returns a bit mask of transport timings this IOATADevice supports
265@discussion
266There is no guarantee that a particular device/driver combination will support
267all transport timings defined. The IOATADevice client must use this function
268to determine which ATATimingProtocol values are valid for this device.
269@param protocolsSupported
270Pointer to a (UInt32) to receive a bit mask of transport timings supported. See enum
271ATATimingProtocol of a list of transport timings.
272*/
273 bool getTimingsSupported( ATATimingProtocol *timingsSupported );
274
275/*!
276@function getTimingSelected
277@abstract
278Returns the last transport timing selected for the device
279@param timingProtocol
280Pointer to a (UInt32) to receive the current timing protocol selected. See enum ATATimingProtocol
281for a list of transport timing protocols.
282*/
283 bool getTimingSelected( ATATimingProtocol *timingProtocol );
284
285/*!
286@function getTiming
287@abstract
288Returns the parameters for the transport timing indicated.
289@discussion
290If the transport/device combination does not support the transport timing
291indicated, then this function will return false. See getTimingsSupported()
292to obtain a bit mask of supported timings.
293@param timingProtocol
294Pointer to a (UInt32) which the client has set to the timing protocol whose parameters are
295to be obtained.
296@param timing
297Pointer to a (struct ATATiming) to receive the parameters (cycle timings) for the requested
298timing.
299*/
300 bool getTiming( ATATimingProtocol *timingProtocol, ATATiming *timing );
301
302/*!
303@function getATAPIPktInt
304@abstract
305Returns whether the an ATAPI device will generate an Interrupt prior to signal it is ready
306to request a command packet.
307@discussion
308A return value of (true) will indicates the device will generate a packet transfer interrupt.
309This function would not normally need to be used by the IOATADevice client. It is for use
310by the transport driver.
311*/
312 bool getATAPIPktInt();
313
314/*!
315@function selectTiming
316@abstract
317Selects the transport timing to be used for this IOATADevice.
318@discussion
319The IOATADevice client must issue the selectTiming() function when initializing an IOATADevice and
320after an ATA Bus Reset event.
321@param timingProtocol
322The transport timing to be selected for the device. See getTimingsSupported() for transport timings
323supported by the transport/device combination.
324@param fNotifyMsg
325If fNotifyMsg is set to false, selectTiming() operates a synchronous call, i.e. it blocks the
326client until it completes. If the client needs to call this function during an event such as
327an ATA Bus Reset, it must use the asynchronous version of this function by setting fNotifyMsg
328to true. In this case the client will be notified via a message when this function has
329completed.
330*/
331 bool selectTiming( ATATimingProtocol timingProtocol, bool fNotifyMsg = false );
332
333/*!
334@function holdQueue
335@abstract
336Suspends sending additional IOATACommand to this device.
337@discussion
338holdQueue() may only be called from the IOATADevice workloop. The client
339is guaranteed to be running in this context during a message() notification.
340
341holdQueue() has no effect on commands already passed to the host adapter. One
342or more commands may complete after the queue is held. See notifyIdle()
343@param queueType
344Perform action on the indicated queue. See enum ATAQueueType in IOATACommand.
345*/
346 void holdQueue( UInt32 queueType );
347
348/*!
349@function releaseQueue
350@abstract
351Resumes sending IOATACommands to the IOATADevice.
352@discussion
353If the device queue was not held, releaseQueue() has no effect.
354
355releaseQueue() may only be called from the IOATADevice workloop. This is guaranteed
356to be the case after a IOATACommand completion of after a message() notification.
357@param queueType
358Perform action on the indicated queue. See enum ATAQueueType in IOATACommand.
359*/
360 void releaseQueue( UInt32 queueType );
361
362/*!
363@function flushQueue
364@abstract
365Returns any commands on the IOATADevice's pending work queue.
366@discussion
367flushQueue() may only be called from the IOATADevice workloop. This is
368guaranteed to be the case after a IOATACommand completion of after a
369message() notification.
370
371All pending command are completed prior to flushQueue() returning to the caller.
372
373flushQueue() has no effect on commands already passed to the host adapter. One
374or more commands may complete after the queue is flushed. See notifyIdle().
375@param queueType
376Perform action on the indicated queue. See enum ATAQueueType in IOATACommand.
377@param rc
378The return code of any flushed commands is set to (rc).
379*/
380 void flushQueue( UInt32 queueType, IOReturn rc );
381
382/*!
383@function notifyIdle
384@abstract
385Notifies the client when all active commands on an ATA device have completed.
386@discussion
387notifyIdle() may only be called from the IOATADevice workloop. This is guaranteed
388to be the case after a IOATACommand completion of after a message() notification.
389
390Only one notifyIdle() call may be active. Any outstanding notifyIdle() calls may
391be cancelled by calling notifyIdle() with no parameters.
392@param target
393Object to receive the notification. Normally the client's (this) pointer.
394@param callback
395Pointer to a callback routine of type CallbackFn.
396@param refcon
397Pointer to client's private data.
398*/
399 void notifyIdle( void *target = 0, CallbackFn callback = 0, void *refcon = 0 );
400
401/*!
402@function getWorkLoop
403@abstract
404Returns the IOWorkLoop object that services this IOATADevice.
405*/
406IOWorkloop *getWorkLoop();
407
408};