2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_OSREFERENCE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the
10 * License may not be used to create, or enable the creation or
11 * redistribution of, unlawful or unlicensed copies of an Apple operating
12 * system, or to circumvent, violate, or enable the circumvention or
13 * violation of, any terms of an Apple operating system software license
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
20 * The Original Code and all software distributed under the License are
21 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
22 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
23 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
25 * Please see the License for the specific language governing rights and
26 * limitations under the License.
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
31 #ifndef _IOMULTIMEMORYDESCRIPTOR_H
32 #define _IOMULTIMEMORYDESCRIPTOR_H
34 #include <IOKit/IOMemoryDescriptor.h>
36 /*! @class IOMultiMemoryDescriptor : public IOMemoryDescriptor
37 @abstract The IOMultiMemoryDescriptor object describes a memory area made up of several other IOMemoryDescriptors.
38 @discussion The IOMultiMemoryDescriptor object represents multiple ranges of memory, specified as an ordered list of IOMemoryDescriptors. The descriptors are chained end-to-end to make up a single contiguous buffer. */
40 class IOMultiMemoryDescriptor
: public IOMemoryDescriptor
42 OSDeclareDefaultStructors(IOMultiMemoryDescriptor
);
46 IOMemoryDescriptor
** _descriptors
;
47 UInt32 _descriptorsCount
;
48 bool _descriptorsIsAllocated
;
53 * These methods are not supported under this subclass.
56 virtual bool initWithAddress( void * address
, /* not supported */
57 IOByteCount withLength
,
58 IODirection withDirection
);
60 virtual bool initWithAddress( vm_address_t address
, /* not supported */
61 IOByteCount withLength
,
62 IODirection withDirection
,
65 virtual bool initWithPhysicalAddress(
66 IOPhysicalAddress address
, /* not supported */
67 IOByteCount withLength
,
68 IODirection withDirection
);
70 virtual bool initWithPhysicalRanges(
71 IOPhysicalRange
* ranges
, /* not supported */
73 IODirection withDirection
,
74 bool asReference
= false );
76 virtual bool initWithRanges( IOVirtualRange
* ranges
, /* not supported */
78 IODirection withDirection
,
80 bool asReference
= false );
82 virtual void * getVirtualSegment( IOByteCount offset
, /* not supported */
83 IOByteCount
* length
);
85 IOMemoryDescriptor::withAddress
; /* not supported */
86 IOMemoryDescriptor::withPhysicalAddress
; /* not supported */
87 IOMemoryDescriptor::withPhysicalRanges
; /* not supported */
88 IOMemoryDescriptor::withRanges
; /* not supported */
89 IOMemoryDescriptor::withSubRange
; /* not supported */
93 /*! @function withDescriptors
94 @abstract Create an IOMultiMemoryDescriptor to describe a memory area made up of several other IOMemoryDescriptors.
95 @discussion This method creates and initializes an IOMultiMemoryDescriptor for memory consisting of a number of other IOMemoryDescriptors, chained end-to-end (in the order they appear in the array) to represent a single contiguous memory buffer. Passing the descriptor array as a reference will avoid an extra allocation.
96 @param descriptors An array of IOMemoryDescriptors which make up the memory to be described.
97 @param withCount The object count for the descriptors array.
98 @param withDirection An I/O direction to be associated with the descriptor, which may affect the operation of the prepare and complete methods on some architectures.
99 @param asReference If false, the IOMultiMemoryDescriptor object will make a copy of the descriptors array, otherwise, the array will be used in situ, avoiding an extra allocation.
100 @result The created IOMultiMemoryDescriptor on success, to be released by the caller, or zero on failure. */
102 static IOMultiMemoryDescriptor
* withDescriptors(
103 IOMemoryDescriptor
** descriptors
,
105 IODirection withDirection
,
106 bool asReference
= false );
108 /*! @function withDescriptors
109 @abstract Initialize an IOMultiMemoryDescriptor to describe a memory area made up of several other IOMemoryDescriptors.
110 @discussion This method initializes an IOMultiMemoryDescriptor for memory consisting of a number of other IOMemoryDescriptors, chained end-to-end (in the order they appear in the array) to represent a single contiguous memory buffer. Passing the descriptor array as a reference will avoid an extra allocation.
111 @param descriptors An array of IOMemoryDescriptors which make up the memory to be described.
112 @param withCount The object count for the descriptors array.
113 @param withDirection An I/O direction to be associated with the descriptor, which may affect the operation of the prepare and complete methods on some architectures.
114 @param asReference If false, the IOMultiMemoryDescriptor object will make a copy of the descriptors array, otherwise, the array will be used in situ, avoiding an extra allocation.
115 @result The created IOMultiMemoryDescriptor on success, to be released by the caller, or zero on failure. */
117 virtual bool initWithDescriptors(
118 IOMemoryDescriptor
** descriptors
,
120 IODirection withDirection
,
121 bool asReference
= false );
123 /*! @function getPhysicalAddress
124 @abstract Return the physical address of the first byte in the memory.
125 @discussion This method returns the physical address of the first byte in the memory. It is most useful on memory known to be physically contiguous.
126 @result A physical address. */
128 virtual IOPhysicalAddress
getPhysicalSegment( IOByteCount offset
,
129 IOByteCount
* length
);
131 #if !(defined(__ppc__) && defined(KPI_10_4_0_PPC_COMPAT))
132 virtual addr64_t
getPhysicalSegment64( IOByteCount offset
,
133 IOByteCount
* length
);
136 /*! @function prepare
137 @abstract Prepare the memory for an I/O transfer.
138 @discussion This involves paging in the memory, if necessary, and wiring it down for the duration of the transfer. The complete() method completes the processing of the memory after the I/O transfer finishes. This method needn't called for non-pageable memory.
139 @param forDirection The direction of the I/O just completed, or kIODirectionNone for the direction specified by the memory descriptor.
140 @result An IOReturn code. */
142 virtual IOReturn
prepare(IODirection forDirection
= kIODirectionNone
);
144 /*! @function complete
145 @abstract Complete processing of the memory after an I/O transfer finishes.
146 @discussion This method should not be called unless a prepare was previously issued; the prepare() and complete() must occur in pairs, before and after an I/O transfer involving pageable memory.
147 @param forDirection The direction of the I/O just completed, or kIODirectionNone for the direction specified by the memory descriptor.
148 @result An IOReturn code. */
150 virtual IOReturn
complete(IODirection forDirection
= kIODirectionNone
);
152 /*! @function readBytes
153 @abstract Copy data from the memory descriptor's buffer to the specified buffer.
154 @discussion This method copies data from the memory descriptor's memory at the given offset, to the caller's buffer.
155 @param offset A byte offset into the memory descriptor's memory.
156 @param bytes The caller supplied buffer to copy the data to.
157 @param withLength The length of the data to copy.
158 @result The number of bytes copied, zero will be returned if the specified offset is beyond the length of the descriptor. */
160 virtual IOByteCount
readBytes( IOByteCount offset
,
162 IOByteCount withLength
);
164 /*! @function writeBytes
165 @abstract Copy data to the memory descriptor's buffer from the specified buffer.
166 @discussion This method copies data to the memory descriptor's memory at the given offset, from the caller's buffer.
167 @param offset A byte offset into the memory descriptor's memory.
168 @param bytes The caller supplied buffer to copy the data from.
169 @param withLength The length of the data to copy.
170 @result The number of bytes copied, zero will be returned if the specified offset is beyond the length of the descriptor. */
172 virtual IOByteCount
writeBytes( IOByteCount offset
,
174 IOByteCount withLength
);
176 virtual IOPhysicalAddress
getSourceSegment(IOByteCount offset
,
177 IOByteCount
* length
);
180 #endif /* !_IOMULTIMEMORYDESCRIPTOR_H */