2 * Copyright (c) 2019-2019 Apple Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_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 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.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
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.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
31 #include <IOKit/IOMemoryDescriptor.h>
35 #ifndef _IOKIT_UIOMEMORYDESCRIPTOR_H
36 #define _IOKIT_UIOMEMORYDESCRIPTOR_H
38 #include <DriverKit/OSObject.iig>
44 // IOMemoryDescriptor Create options
46 kIOMemoryDirectionIn = 0x00000001,
47 kIOMemoryDirectionOut = 0x00000002,
48 kIOMemoryDirectionOutIn = kIOMemoryDirectionIn | kIOMemoryDirectionOut,
49 kIOMemoryDirectionInOut = kIOMemoryDirectionOutIn,
52 // IOMemoryDescriptor CreateMapping options
54 kIOMemoryMapFixedAddress = 0x00000001,
55 kIOMemoryMapReadOnly = 0x00000002,
56 kIOMemoryMapCacheModeDefault = 0x00000000,
57 kIOMemoryMapCacheModeInhibit = 0x00000100,
58 kIOMemoryMapCacheModeCopyback = 0x00000200,
59 kIOMemoryMapCacheModeWriteThrough = 0x00000400,
62 struct IOAddressSegment {
67 struct IOMDPrivateState {
73 * @class IOMemoryDescriptor
76 * IOMemoryDescriptor describes a memory buffer.
79 * To allocate memory for I/O or sharing, use IOBufferMemoryDescriptor::Create()
80 * Methods in this class are used for memory that was supplied as a parameter.
84 #include <DriverKit/IOService.h>
88 class KERNEL IOMemoryDescriptor : public OSObject
100 * @brief Obtain the length of the memory described.
101 * @param returnLength Returned length.
102 * @return kIOReturnSuccess on success. See IOReturn.h for error codes.
106 uint64_t * returnLength) LOCALONLY;
109 * @brief Create a mapping of the memory in the callers address space.
111 * kIOMemoryMapFixedAddress map at the address requested
112 * kIOMemoryMapReadOnly create a read only mapping
113 * kIOMemoryMapCacheModeDefault default cache mode
114 * kIOMemoryMapCacheModeInhibit inhibited cache mode
115 * kIOMemoryMapCacheModeCopyback copyback cache mode
116 * kIOMemoryMapCacheModeWriteThrough write through cache mode
117 * @param address Requested address if kIOMemoryMapFixedAddress was passed
118 * @param offset Start offset of the mapping in the descriptor.
119 * @param length Pass zero to map the entire memory, or a value <= the length of the descriptor.
120 * @param alignment of the memory virtual mapping. Only zero for no alignment is supported.
121 * @param map Returned IOMemoryMap object with +1 retain count.
122 * It should be retained until the map is no longer required.
123 * @return kIOReturnSuccess on success. See IOReturn.h for error codes.
125 virtual kern_return_t
135 virtual kern_return_t
143 uint64_t * returnLength,
144 uint32_t * segmentsCount,
145 IOAddressSegment segments[32]);
154 uint64_t * returnAddress,
155 uint64_t * returnLength) LOCALONLY;
158 class EXTENDS (IOMemoryDescriptor) IOMemoryDescriptorPrivate
160 virtual kern_return_t
162 IOMDPrivateState * state);
167 #endif /* ! _IOKIT_UIOMEMORYDESCRIPTOR_H */