1/* iig(DriverKit-286) generated from IOBufferMemoryDescriptor.iig */
2
3/* IOBufferMemoryDescriptor.iig:1-40 */
4/*
5 * Copyright (c) 2019-2019 Apple Inc. All rights reserved.
6 *
7 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
8 *
9 * This file contains Original Code and/or Modifications of Original Code
10 * as defined in and that are subject to the Apple Public Source License
11 * Version 2.0 (the 'License'). You may not use this file except in
12 * compliance with the License. The rights granted to you under the License
13 * may not be used to create, or enable the creation or redistribution of,
14 * unlawful or unlicensed copies of an Apple operating system, or to
15 * circumvent, violate, or enable the circumvention or violation of, any
16 * terms of an Apple operating system software license agreement.
17 *
18 * Please obtain a copy of the License at
19 * http://www.opensource.apple.com/apsl/ and read it before using this file.
20 *
21 * The Original Code and all software distributed under the License are
22 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
23 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
24 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
25 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
26 * Please see the License for the specific language governing rights and
27 * limitations under the License.
28 *
29 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
30 */
31
32#if !__IIG
33#if KERNEL
34#include <IOKit/IOBufferMemoryDescriptor.h>
35#endif
36#endif
37
38
39#ifndef _IOKIT_UIOBUFFERMEMORYDESCRIPTOR_H
40#define _IOKIT_UIOBUFFERMEMORYDESCRIPTOR_H
41
42#include <DriverKit/IOMemoryDescriptor.h> /* .iig include */
43
44/* source class IOBufferMemoryDescriptor IOBufferMemoryDescriptor.iig:41-96 */
45
46#if __DOCUMENTATION__
47#define KERNEL IIG_KERNEL
48
49/*!
50 * @class IOBufferMemoryDescriptor
51 *
52 * @abstract
53 * IOBufferMemoryDescriptor describes a memory buffer allocated in the callers address space.
54 *
55 * @discussion
56 * To allocate memory for I/O or sharing, use IOBufferMemoryDescriptor::Create().
57 * IOBufferMemoryDescriptor can be handed to any API that expects an IOMemoryDescriptor.
58 */
59
60class KERNEL IOBufferMemoryDescriptor : public IOMemoryDescriptor
61{
62public:
63
64 /*!
65 * @brief Create an IOBufferMemoryDescriptor.
66 * @param options Pass the flags kIOMemoryDirectionIn, kIOMemoryDirectionOut or kIOMemoryDirectionOutIn
67 * to set the direction of the i/o
68 * @param capacity Maximum length of the memory buffer. The descriptor has no valid data
69 * and zero length until set with SetLength().
70 * @param memory Created descriptor with +1 retain count to be released by the caller.
71 * @param alignment For small less-than-page-size buffers, control the alignment of the memory buffer.
72 * Pass zero for no guaranteed alignment.
73 * @return kIOReturnSuccess on success. See IOReturn.h for error codes.
74 */
75 static kern_return_t
76 Create(
77 uint64_t options,
78 uint64_t capacity,
79 uint64_t alignment,
80 IOBufferMemoryDescriptor ** memory);
81
82 virtual bool
83 init() override;
84
85 virtual void
86 free() override;
87
88 /*!
89 * @brief Obtain the address and length of the memory buffer.
90 * @param range An IOAddressSegment structure filled out with the address and length of the memory buffer.
91 * @return kIOReturnSuccess on success. See IOReturn.h for error codes.
92 */
93 kern_return_t
94 GetAddressRange(IOAddressSegment * range) LOCALONLY;
95
96 /*!
97 * @brief Set the valid length of the memory buffer.
98 * @discussion IOBufferMemoryDescriptor have capacity allocated at Create() but no valid data until set
99 * with this method.
100 * @param length New valid length of the memory described.
101 * @return kIOReturnSuccess on success. See IOReturn.h for error codes.
102 */
103 virtual kern_return_t
104 SetLength(uint64_t length);
105};
106
107#undef KERNEL
108#else /* __DOCUMENTATION__ */
109
110/* generated class IOBufferMemoryDescriptor IOBufferMemoryDescriptor.iig:41-96 */
111
112#define IOBufferMemoryDescriptor_Create_ID 0xb78de684e17d5a4bULL
113#define IOBufferMemoryDescriptor_SetLength_ID 0xc115230c191a6a9aULL
114
115#define IOBufferMemoryDescriptor_Create_Args \
116 uint64_t options, \
117 uint64_t capacity, \
118 uint64_t alignment, \
119 IOBufferMemoryDescriptor ** memory
120
121#define IOBufferMemoryDescriptor_SetLength_Args \
122 uint64_t length
123
124#define IOBufferMemoryDescriptor_Methods \
125\
126public:\
127\
128 virtual kern_return_t\
129 Dispatch(const IORPC rpc) APPLE_KEXT_OVERRIDE;\
130\
131 static kern_return_t\
132 _Dispatch(IOBufferMemoryDescriptor * self, const IORPC rpc);\
133\
134 static kern_return_t\
135 Create(\
136 uint64_t options,\
137 uint64_t capacity,\
138 uint64_t alignment,\
139 IOBufferMemoryDescriptor ** memory);\
140\
141 kern_return_t\
142 GetAddressRange(\
143 IOAddressSegment * range);\
144\
145 kern_return_t\
146 SetLength(\
147 uint64_t length,\
148 OSDispatchMethod supermethod = NULL);\
149\
150\
151protected:\
152 /* _Impl methods */\
153\
154\
155public:\
156 /* _Invoke methods */\
157\
158 typedef kern_return_t (*Create_Handler)(IOBufferMemoryDescriptor_Create_Args);\
159 static kern_return_t\
160 Create_Invoke(const IORPC rpc,\
161 Create_Handler func);\
162\
163 typedef kern_return_t (*SetLength_Handler)(OSMetaClassBase * target, IOBufferMemoryDescriptor_SetLength_Args);\
164 static kern_return_t\
165 SetLength_Invoke(const IORPC rpc,\
166 OSMetaClassBase * target,\
167 SetLength_Handler func);\
168\
169
170
171#define IOBufferMemoryDescriptor_KernelMethods \
172\
173protected:\
174 /* _Impl methods */\
175\
176 static kern_return_t\
177 Create_Impl(IOBufferMemoryDescriptor_Create_Args);\
178\
179 kern_return_t\
180 SetLength_Impl(IOBufferMemoryDescriptor_SetLength_Args);\
181\
182
183
184#define IOBufferMemoryDescriptor_VirtualMethods \
185\
186public:\
187\
188 virtual bool\
189 init(\
190) APPLE_KEXT_OVERRIDE;\
191\
192 virtual void\
193 free(\
194) APPLE_KEXT_OVERRIDE;\
195\
196
197
198#if !KERNEL
199
200extern OSMetaClass * gIOBufferMemoryDescriptorMetaClass;
201extern const OSClassLoadInformation IOBufferMemoryDescriptor_Class;
202
203class IOBufferMemoryDescriptorMetaClass : public OSMetaClass
204{
205public:
206 virtual kern_return_t
207 New(OSObject * instance) override;
208 virtual kern_return_t
209 Dispatch(const IORPC rpc) override;
210};
211
212#endif /* !KERNEL */
213
214#if !KERNEL
215
216class IOBufferMemoryDescriptorInterface : public OSInterface
217{
218public:
219};
220
221struct IOBufferMemoryDescriptor_IVars;
222struct IOBufferMemoryDescriptor_LocalIVars;
223
224class IOBufferMemoryDescriptor : public IOMemoryDescriptor, public IOBufferMemoryDescriptorInterface
225{
226#if !KERNEL
227 friend class IOBufferMemoryDescriptorMetaClass;
228#endif /* !KERNEL */
229
230#if !KERNEL
231public:
232#ifdef IOBufferMemoryDescriptor_DECLARE_IVARS
233IOBufferMemoryDescriptor_DECLARE_IVARS
234#else /* IOBufferMemoryDescriptor_DECLARE_IVARS */
235 union
236 {
237 IOBufferMemoryDescriptor_IVars * ivars;
238 IOBufferMemoryDescriptor_LocalIVars * lvars;
239 };
240#endif /* IOBufferMemoryDescriptor_DECLARE_IVARS */
241#endif /* !KERNEL */
242
243#if !KERNEL
244 static OSMetaClass *
245 sGetMetaClass() { return gIOBufferMemoryDescriptorMetaClass; };
246#endif /* KERNEL */
247
248 using super = IOMemoryDescriptor;
249
250#if !KERNEL
251 IOBufferMemoryDescriptor_Methods
252 IOBufferMemoryDescriptor_VirtualMethods
253#endif /* !KERNEL */
254
255};
256#endif /* !KERNEL */
257
258
259#endif /* !__DOCUMENTATION__ */
260
261/* IOBufferMemoryDescriptor.iig:98- */
262
263#endif /* ! _IOKIT_UIOBUFFERMEMORYDESCRIPTOR_H */
264