]> git.saurik.com Git - apple/xnu.git/blame - iokit/IOKit/IOMultiMemoryDescriptor.h
xnu-792.13.8.tar.gz
[apple/xnu.git] / iokit / IOKit / IOMultiMemoryDescriptor.h
CommitLineData
1c79356b
A
1/*
2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
3 *
8ad349bb 4 * @APPLE_LICENSE_OSREFERENCE_HEADER_START@
1c79356b 5 *
8ad349bb
A
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
14 * agreement.
15 *
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
18 * file.
19 *
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.
27 *
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
1c79356b
A
29 */
30
31#ifndef _IOMULTIMEMORYDESCRIPTOR_H
32#define _IOMULTIMEMORYDESCRIPTOR_H
33
34#include <IOKit/IOMemoryDescriptor.h>
35
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. */
39
40class IOMultiMemoryDescriptor : public IOMemoryDescriptor
41{
42 OSDeclareDefaultStructors(IOMultiMemoryDescriptor);
43
44protected:
45
46 IOMemoryDescriptor ** _descriptors;
47 UInt32 _descriptorsCount;
48 bool _descriptorsIsAllocated;
49
50 virtual void free();
51
52 /*
53 * These methods are not supported under this subclass.
54 */
55
56 virtual bool initWithAddress( void * address, /* not supported */
57 IOByteCount withLength,
58 IODirection withDirection );
59
60 virtual bool initWithAddress( vm_address_t address, /* not supported */
61 IOByteCount withLength,
62 IODirection withDirection,
63 task_t withTask );
64
65 virtual bool initWithPhysicalAddress(
66 IOPhysicalAddress address, /* not supported */
67 IOByteCount withLength,
68 IODirection withDirection );
69
70 virtual bool initWithPhysicalRanges(
71 IOPhysicalRange * ranges, /* not supported */
72 UInt32 withCount,
73 IODirection withDirection,
74 bool asReference = false );
75
76 virtual bool initWithRanges( IOVirtualRange * ranges, /* not supported */
77 UInt32 withCount,
78 IODirection withDirection,
79 task_t withTask,
80 bool asReference = false );
81
82 virtual void * getVirtualSegment( IOByteCount offset, /* not supported */
83 IOByteCount * length );
84
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 */
90
91public:
92
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. */
101
102 static IOMultiMemoryDescriptor * withDescriptors(
103 IOMemoryDescriptor ** descriptors,
104 UInt32 withCount,
105 IODirection withDirection,
106 bool asReference = false );
107
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. */
116
117 virtual bool initWithDescriptors(
118 IOMemoryDescriptor ** descriptors,
119 UInt32 withCount,
120 IODirection withDirection,
121 bool asReference = false );
122
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. */
127
128 virtual IOPhysicalAddress getPhysicalSegment( IOByteCount offset,
129 IOByteCount * length );
130
5d5c5d0d
A
131#if !(defined(__ppc__) && defined(KPI_10_4_0_PPC_COMPAT))
132 virtual addr64_t getPhysicalSegment64( IOByteCount offset,
133 IOByteCount * length );
134#endif
135
1c79356b
A
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. */
141
142 virtual IOReturn prepare(IODirection forDirection = kIODirectionNone);
143
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. */
149
150 virtual IOReturn complete(IODirection forDirection = kIODirectionNone);
151
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. */
159
160 virtual IOByteCount readBytes( IOByteCount offset,
161 void * bytes,
162 IOByteCount withLength );
163
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. */
171
172 virtual IOByteCount writeBytes( IOByteCount offset,
173 const void * bytes,
174 IOByteCount withLength );
0b4e3aa0
A
175
176 virtual IOPhysicalAddress getSourceSegment(IOByteCount offset,
177 IOByteCount * length);
1c79356b
A
178};
179
180#endif /* !_IOMULTIMEMORYDESCRIPTOR_H */