]> git.saurik.com Git - apple/xnu.git/blame_incremental - iokit/IOKit/IOMultiMemoryDescriptor.h
xnu-344.21.73.tar.gz
[apple/xnu.git] / iokit / IOKit / IOMultiMemoryDescriptor.h
... / ...
CommitLineData
1/*
2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
7 *
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * file.
14 *
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
22 *
23 * @APPLE_LICENSE_HEADER_END@
24 */
25
26#ifndef _IOMULTIMEMORYDESCRIPTOR_H
27#define _IOMULTIMEMORYDESCRIPTOR_H
28
29#include <IOKit/IOMemoryDescriptor.h>
30
31/*! @class IOMultiMemoryDescriptor : public IOMemoryDescriptor
32 @abstract The IOMultiMemoryDescriptor object describes a memory area made up of several other IOMemoryDescriptors.
33 @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. */
34
35class IOMultiMemoryDescriptor : public IOMemoryDescriptor
36{
37 OSDeclareDefaultStructors(IOMultiMemoryDescriptor);
38
39protected:
40
41 IOMemoryDescriptor ** _descriptors;
42 UInt32 _descriptorsCount;
43 bool _descriptorsIsAllocated;
44
45 virtual void free();
46
47 /*
48 * These methods are not supported under this subclass.
49 */
50
51 virtual bool initWithAddress( void * address, /* not supported */
52 IOByteCount withLength,
53 IODirection withDirection );
54
55 virtual bool initWithAddress( vm_address_t address, /* not supported */
56 IOByteCount withLength,
57 IODirection withDirection,
58 task_t withTask );
59
60 virtual bool initWithPhysicalAddress(
61 IOPhysicalAddress address, /* not supported */
62 IOByteCount withLength,
63 IODirection withDirection );
64
65 virtual bool initWithPhysicalRanges(
66 IOPhysicalRange * ranges, /* not supported */
67 UInt32 withCount,
68 IODirection withDirection,
69 bool asReference = false );
70
71 virtual bool initWithRanges( IOVirtualRange * ranges, /* not supported */
72 UInt32 withCount,
73 IODirection withDirection,
74 task_t withTask,
75 bool asReference = false );
76
77 virtual void * getVirtualSegment( IOByteCount offset, /* not supported */
78 IOByteCount * length );
79
80 IOMemoryDescriptor::withAddress; /* not supported */
81 IOMemoryDescriptor::withPhysicalAddress; /* not supported */
82 IOMemoryDescriptor::withPhysicalRanges; /* not supported */
83 IOMemoryDescriptor::withRanges; /* not supported */
84 IOMemoryDescriptor::withSubRange; /* not supported */
85
86public:
87
88/*! @function withDescriptors
89 @abstract Create an IOMultiMemoryDescriptor to describe a memory area made up of several other IOMemoryDescriptors.
90 @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.
91 @param descriptors An array of IOMemoryDescriptors which make up the memory to be described.
92 @param withCount The object count for the descriptors array.
93 @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.
94 @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.
95 @result The created IOMultiMemoryDescriptor on success, to be released by the caller, or zero on failure. */
96
97 static IOMultiMemoryDescriptor * withDescriptors(
98 IOMemoryDescriptor ** descriptors,
99 UInt32 withCount,
100 IODirection withDirection,
101 bool asReference = false );
102
103/*! @function withDescriptors
104 @abstract Initialize an IOMultiMemoryDescriptor to describe a memory area made up of several other IOMemoryDescriptors.
105 @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.
106 @param descriptors An array of IOMemoryDescriptors which make up the memory to be described.
107 @param withCount The object count for the descriptors array.
108 @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.
109 @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.
110 @result The created IOMultiMemoryDescriptor on success, to be released by the caller, or zero on failure. */
111
112 virtual bool initWithDescriptors(
113 IOMemoryDescriptor ** descriptors,
114 UInt32 withCount,
115 IODirection withDirection,
116 bool asReference = false );
117
118/*! @function getPhysicalAddress
119 @abstract Return the physical address of the first byte in the memory.
120 @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.
121 @result A physical address. */
122
123 virtual IOPhysicalAddress getPhysicalSegment( IOByteCount offset,
124 IOByteCount * length );
125
126/*! @function prepare
127 @abstract Prepare the memory for an I/O transfer.
128 @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.
129 @param forDirection The direction of the I/O just completed, or kIODirectionNone for the direction specified by the memory descriptor.
130 @result An IOReturn code. */
131
132 virtual IOReturn prepare(IODirection forDirection = kIODirectionNone);
133
134/*! @function complete
135 @abstract Complete processing of the memory after an I/O transfer finishes.
136 @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.
137 @param forDirection The direction of the I/O just completed, or kIODirectionNone for the direction specified by the memory descriptor.
138 @result An IOReturn code. */
139
140 virtual IOReturn complete(IODirection forDirection = kIODirectionNone);
141
142/*! @function readBytes
143 @abstract Copy data from the memory descriptor's buffer to the specified buffer.
144 @discussion This method copies data from the memory descriptor's memory at the given offset, to the caller's buffer.
145 @param offset A byte offset into the memory descriptor's memory.
146 @param bytes The caller supplied buffer to copy the data to.
147 @param withLength The length of the data to copy.
148 @result The number of bytes copied, zero will be returned if the specified offset is beyond the length of the descriptor. */
149
150 virtual IOByteCount readBytes( IOByteCount offset,
151 void * bytes,
152 IOByteCount withLength );
153
154/*! @function writeBytes
155 @abstract Copy data to the memory descriptor's buffer from the specified buffer.
156 @discussion This method copies data to the memory descriptor's memory at the given offset, from the caller's buffer.
157 @param offset A byte offset into the memory descriptor's memory.
158 @param bytes The caller supplied buffer to copy the data from.
159 @param withLength The length of the data to copy.
160 @result The number of bytes copied, zero will be returned if the specified offset is beyond the length of the descriptor. */
161
162 virtual IOByteCount writeBytes( IOByteCount offset,
163 const void * bytes,
164 IOByteCount withLength );
165
166 virtual IOPhysicalAddress getSourceSegment(IOByteCount offset,
167 IOByteCount * length);
168};
169
170#endif /* !_IOMULTIMEMORYDESCRIPTOR_H */