]>
Commit | Line | Data |
---|---|---|
2d21ac55 A |
1 | /* |
2 | * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ | |
5 | * | |
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 License | |
10 | * may not be used to create, or enable the creation or redistribution of, | |
11 | * unlawful or unlicensed copies of an Apple operating system, or to | |
12 | * circumvent, violate, or enable the circumvention or violation of, any | |
13 | * terms of an Apple operating system software license agreement. | |
14 | * | |
15 | * Please obtain a copy of the License at | |
16 | * http://www.opensource.apple.com/apsl/ and read it before using this file. | |
17 | * | |
18 | * The Original Code and all software distributed under the License are | |
19 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, | |
21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. | |
23 | * Please see the License for the specific language governing rights and | |
24 | * limitations under the License. | |
25 | * | |
26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ | |
27 | */ | |
28 | ||
29 | #ifndef _IOINTERLEAVEDMEMORYDESCRIPTOR_H | |
30 | #define _IOINTERLEAVEDMEMORYDESCRIPTOR_H | |
31 | ||
32 | #include <IOKit/IOMemoryDescriptor.h> | |
33 | ||
34 | /*! @class IOInterleavedMemoryDescriptor : public IOMemoryDescriptor | |
35 | @abstract The IOInterleavedMemoryDescriptor object describes a memory area made up of portions of several other IOMemoryDescriptors. | |
36 | @discussion The IOInterleavedMemoryDescriptor object represents interleaved ranges of memory, specified as an ordered list of portions of individual IOMemoryDescriptors. The portions are chained end-to-end to make up a single contiguous buffer. */ | |
37 | ||
38 | class IOInterleavedMemoryDescriptor : public IOMemoryDescriptor | |
39 | { | |
40 | OSDeclareDefaultStructors(IOInterleavedMemoryDescriptor); | |
41 | ||
42 | protected: | |
43 | ||
b0d623f7 | 44 | IOByteCount _descriptorCapacity; |
2d21ac55 A |
45 | UInt32 _descriptorCount; |
46 | IOMemoryDescriptor ** _descriptors; | |
47 | IOByteCount * _descriptorOffsets; | |
48 | IOByteCount * _descriptorLengths; | |
49 | bool _descriptorPrepared; | |
50 | ||
3e170ce0 | 51 | virtual void free() APPLE_KEXT_OVERRIDE; |
2d21ac55 | 52 | |
2d21ac55 A |
53 | public: |
54 | ||
55 | /*! @function withCapacity | |
56 | @abstract Create an IOInterleavedMemoryDescriptor to describe a memory area made up of several other IOMemoryDescriptors. | |
57 | @discussion This method creates and initializes an IOInterleavedMemoryDescriptor for memory consisting of portions 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. | |
58 | @param capacity The maximum number of IOMemoryDescriptors that may be subsequently added to this IOInterleavedMemoryDescriptor. | |
59 | @param direction An I/O direction to be associated with the descriptor, which may affect the operation of the prepare and complete methods on some architectures. | |
60 | @result The created IOInterleavedMemoryDescriptor on success, to be released by the caller, or zero on failure. */ | |
61 | ||
b0d623f7 | 62 | static IOInterleavedMemoryDescriptor * withCapacity( IOByteCount capacity, |
2d21ac55 A |
63 | IODirection direction); |
64 | ||
65 | /*! @function initWithCapacity | |
66 | @abstract Initialize an IOInterleavedMemoryDescriptor to describe a memory area made up of several other IOMemoryDescriptors. | |
67 | @discussion This method initializes an IOInterleavedMemoryDescriptor for memory consisting of portions 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. | |
68 | @param capacity The maximum number of IOMemoryDescriptors that may be subsequently added to this IOInterleavedMemoryDescriptor. | |
69 | @param direction An I/O direction to be associated with the descriptor, which may affect the operation of the prepare and complete methods on some architectures. | |
70 | @result The created IOInterleavedMemoryDescriptor on success, to be released by the caller, or zero on failure. */ | |
71 | ||
b0d623f7 | 72 | virtual bool initWithCapacity( IOByteCount capacity, |
2d21ac55 A |
73 | IODirection direction ); |
74 | ||
75 | /*! @function clearMemoryDescriptors | |
76 | @abstract Clear all of the IOMemoryDescriptors currently contained in and reset the IOInterleavedMemoryDescriptor. | |
77 | @discussion Clears each IOMemoryDescriptor by completing (if needed) and releasing. The IOInterleavedMemoryDescriptor is then reset and may accept new descriptors up to the capacity specified when it was created. | |
78 | @param direction An I/O direction to be associated with the descriptor, which may affect the operation of the prepare and complete methods on some architectures. */ | |
79 | ||
80 | virtual void clearMemoryDescriptors( IODirection direction = kIODirectionNone ); | |
81 | ||
82 | /*! @function setMemoryDescriptor | |
83 | @abstract Add a portion of an IOMemoryDescriptor to the IOInterleavedMemoryDescriptor. | |
84 | @discussion This method adds the portion of an IOMemoryDescriptor described by the offset and length parameters to the end of the IOInterleavedMemoryDescriptor. A single IOMemoryDescriptor may be added as many times as there is room for it. The offset and length must describe a portion entirely within the IOMemoryDescriptor. | |
85 | @param descriptor An IOMemoryDescriptor to be added to the IOInterleavedMemoryDescriptor. Its direction must be compatible with that of the IOInterleavedMemoryDescriptor. | |
86 | @param offset The offset into the IOMemoryDescriptor of the portion that will be added to the virtualized buffer. | |
87 | @param length The length of the portion of the IOMemoryDescriptor to be added to the virtualized buffer. | |
88 | @result Returns true the portion was successfully added. */ | |
89 | ||
90 | virtual bool setMemoryDescriptor( IOMemoryDescriptor * descriptor, | |
91 | IOByteCount offset, | |
92 | IOByteCount length ); | |
93 | ||
94 | /*! @function getPhysicalSegment | |
95 | @abstract Break a memory descriptor into its physically contiguous segments. | |
96 | @discussion This method returns the physical address of the byte at the given offset into the memory, and optionally the length of the physically contiguous segment from that offset. | |
97 | @param offset A byte offset into the memory whose physical address to return. | |
98 | @param length If non-zero, getPhysicalSegment will store here the length of the physically contiguous segement at the given offset. | |
99 | @result A physical address, or zero if the offset is beyond the length of the memory. */ | |
100 | ||
b0d623f7 A |
101 | virtual addr64_t getPhysicalSegment( IOByteCount offset, |
102 | IOByteCount * length, | |
3e170ce0 | 103 | IOOptionBits options = 0 ) APPLE_KEXT_OVERRIDE; |
2d21ac55 A |
104 | |
105 | /*! @function prepare | |
106 | @abstract Prepare the memory for an I/O transfer. | |
107 | @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 need not called for non-pageable memory. | |
108 | @param forDirection The direction of the I/O to be performed, or kIODirectionNone for the direction specified by the memory descriptor. | |
109 | @result An IOReturn code. */ | |
110 | ||
3e170ce0 | 111 | virtual IOReturn prepare(IODirection forDirection = kIODirectionNone) APPLE_KEXT_OVERRIDE; |
2d21ac55 A |
112 | |
113 | /*! @function complete | |
114 | @abstract Complete processing of the memory after an I/O transfer finishes. | |
115 | @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. | |
116 | @param forDirection The direction of the I/O just completed, or kIODirectionNone for the direction specified by the memory descriptor. | |
117 | @result An IOReturn code. */ | |
118 | ||
3e170ce0 | 119 | virtual IOReturn complete(IODirection forDirection = kIODirectionNone) APPLE_KEXT_OVERRIDE; |
2d21ac55 A |
120 | }; |
121 | ||
122 | #endif /* !_IOINTERLEAVEDMEMORYDESCRIPTOR_H */ |