]> git.saurik.com Git - apple/xnu.git/blame - iokit/IOKit/IOInterleavedMemoryDescriptor.h
xnu-6153.101.6.tar.gz
[apple/xnu.git] / iokit / IOKit / IOInterleavedMemoryDescriptor.h
CommitLineData
2d21ac55
A
1/*
2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
0a7de745 5 *
2d21ac55
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 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.
0a7de745 14 *
2d21ac55
A
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
0a7de745 17 *
2d21ac55
A
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.
0a7de745 25 *
2d21ac55
A
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
0a7de745
A
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. */
2d21ac55
A
37
38class IOInterleavedMemoryDescriptor : public IOMemoryDescriptor
39{
0a7de745 40 OSDeclareDefaultStructors(IOInterleavedMemoryDescriptor);
2d21ac55
A
41
42protected:
43
0a7de745
A
44 IOByteCount _descriptorCapacity;
45 UInt32 _descriptorCount;
46 IOMemoryDescriptor ** _descriptors;
47 IOByteCount * _descriptorOffsets;
48 IOByteCount * _descriptorLengths;
49 bool _descriptorPrepared;
2d21ac55 50
0a7de745 51 virtual void free() APPLE_KEXT_OVERRIDE;
2d21ac55 52
2d21ac55
A
53public:
54
55/*! @function withCapacity
0a7de745
A
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. */
2d21ac55 61
0a7de745
A
62 static IOInterleavedMemoryDescriptor * withCapacity( IOByteCount capacity,
63 IODirection direction);
2d21ac55
A
64
65/*! @function initWithCapacity
0a7de745
A
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. */
2d21ac55 71
0a7de745
A
72 virtual bool initWithCapacity( IOByteCount capacity,
73 IODirection direction );
2d21ac55
A
74
75/*! @function clearMemoryDescriptors
0a7de745
A
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. */
2d21ac55 79
0a7de745 80 virtual void clearMemoryDescriptors( IODirection direction = kIODirectionNone );
2d21ac55
A
81
82/*! @function setMemoryDescriptor
0a7de745
A
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. */
2d21ac55 89
0a7de745
A
90 virtual bool setMemoryDescriptor( IOMemoryDescriptor * descriptor,
91 IOByteCount offset,
92 IOByteCount length );
2d21ac55
A
93
94/*! @function getPhysicalSegment
0a7de745
A
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. */
2d21ac55 100
0a7de745
A
101 virtual addr64_t getPhysicalSegment( IOByteCount offset,
102 IOByteCount * length,
103 IOOptionBits options = 0 ) APPLE_KEXT_OVERRIDE;
2d21ac55
A
104
105/*! @function prepare
0a7de745
A
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. */
2d21ac55 110
0a7de745 111 virtual IOReturn prepare(IODirection forDirection = kIODirectionNone) APPLE_KEXT_OVERRIDE;
2d21ac55
A
112
113/*! @function complete
0a7de745
A
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. */
2d21ac55 118
0a7de745 119 virtual IOReturn complete(IODirection forDirection = kIODirectionNone) APPLE_KEXT_OVERRIDE;
2d21ac55
A
120};
121
122#endif /* !_IOINTERLEAVEDMEMORYDESCRIPTOR_H */