1/* iig(DriverKit-286) generated from IOExtensiblePaniclog.iig */
2
3/* IOExtensiblePaniclog.iig:1-53 */
4/*
5 * Copyright (c) 2022 Apple Computer, 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/IOExtensiblePaniclog.h>
35#endif
36#endif
37
38#ifndef _IOKIT_UIOEXTENSIBLEPANICLOG_H
39#define _IOKIT_UIOEXTENSIBLEPANICLOG_H
40
41#include <DriverKit/OSObject.h> /* .iig include */
42#include <DriverKit/IOBufferMemoryDescriptor.h> /* .iig include */
43
44/*!
45*/
46
47enum {
48 kIOExtensiblePaniclogOptionsNone = 0x0,
49 kIOExtensiblePaniclogOptionsWithBuffer = 0x1,
50};
51
52/* source class IOExtensiblePaniclog IOExtensiblePaniclog.iig:54-160 */
53
54#if __DOCUMENTATION__
55#define KERNEL IIG_KERNEL
56
57class KERNEL IOExtensiblePaniclog : public OSObject
58{
59public:
60 virtual bool
61 init() override;
62
63 virtual void
64 free() override;
65
66 /*!
67 * @brief This function is to be called to create IOExtensiblePaniclog object.
68 * @discussion First function to be called.
69 *
70 * @param uuid The UUID of the handle.
71 * @param data_id The string describing the handle. MAX length of 32.
72 * @param max_len The maximum length of the buffer.
73 * @param options Options to be passed while creating the handle
74 * @param out The pointer to the created IOExtensiblePaniclog object. NULL in case of an error.
75 * @return True in case of success. False in case of an error.
76 */
77 static kern_return_t
78 Create(OSData *uuid, OSString *data_id, uint32_t max_len, uint32_t options,
79 IOExtensiblePaniclog **out);
80
81 /*!
82 * @brief This function is called to set the IOExtensiblePaniclog object active.
83 * @discussion When it is set active, it is picked up and added to the extensible paniclog
84 * in case of a panic.
85 *
86 * @return 0 on success, negative value in case of failure.
87 */
88 virtual kern_return_t SetActive();
89
90 /*!
91 * @brief This function is called to set the IOExtensiblePaniclog object inactive.
92 * @discussion When it is set inactive, this buffer is not picked up in case of a panic
93 *
94 * @return True in case of success. False in case of an error.
95 */
96 virtual kern_return_t SetInactive();
97
98 /*!
99 * @brief This function is called to insert data into the buffer.
100 * @discussion This function overwrites the data in the buffer. The write starts from
101 * offset 0 and continues until 'len'
102 *
103 * @param data Data to be inserted
104 * @param len The length to be copied.
105 *
106 * @return 0 in case of success. Negative in case of an error.
107 */
108 virtual kern_return_t InsertData(OSData *data);
109
110 /*!
111 * @brief This function is called to insert data into the buffer.
112 * @discussion This function overwrites the data in the buffer. The write starts from
113 * last written byte and continues until 'len'
114 *
115 * @param data Data to be inserted
116 * @param len The length to be copied.
117 *
118 * @return 0 in case of success. Negative in case of an error.
119 */
120 virtual kern_return_t AppendData(OSData *data);
121
122 /*!
123 * @brief Function to get the Memory descriptor created in the Create function
124 *
125 * @param mem The pointer to the IOBufferMemoryDescriptor object
126 *
127 * @return 0 in case of success. Negative in case of an error.
128 */
129 virtual kern_return_t CopyMemoryDescriptor(IOBufferMemoryDescriptor **mem);
130
131 /*!
132 * @brief This function is called to get a pointer to the ext paniclog buffer
133 * @discussion After this function is called, the user is responsible for copying data into the buffer.
134 * The entire buffer is copied when a system panics.
135 * After claiming the buffer, YieldBuffer() has to be called to set the used_len of the buffer
136 * before calling InsertData() or AppendData()
137 *
138 * @param addr Address of the mapped buffer
139 * @param len The length of the mapped buffer. This is same value as the max_len in
140 * the Create() function
141 *
142 * @return 0 in case of success. Negative in case of an error.
143 */
144 virtual kern_return_t ClaimBuffer(uint64_t *addr, uint64_t *len) LOCALONLY;
145
146 /*!
147 * @brief This function is called to yield the buffer and set the used_len for the buffer
148 * @discussion After this function call, InsertData() and AppendData() can be called.
149 *
150 * @param used_len The length of the buffer used by the client.
151 *
152 * @return 0 in case of success. Negative in case of an error.
153 */
154 virtual kern_return_t YieldBuffer(uint32_t used_len) LOCALONLY;
155
156 /*!
157 * @brief This function is called to set the used len of the buffer
158 *
159 * @param used_len The length of the buffer used by the client.
160 *
161 * @return 0 in case of success. Negative in case of an error.
162 */
163 virtual kern_return_t SetUsedLen(uint32_t used_len);
164};
165
166#undef KERNEL
167#else /* __DOCUMENTATION__ */
168
169/* generated class IOExtensiblePaniclog IOExtensiblePaniclog.iig:54-160 */
170
171#define IOExtensiblePaniclog_Create_ID 0xa7f6249922e20bd7ULL
172#define IOExtensiblePaniclog_SetActive_ID 0xb058f6942cd75c58ULL
173#define IOExtensiblePaniclog_SetInactive_ID 0xf3f3d6994a227e5cULL
174#define IOExtensiblePaniclog_InsertData_ID 0xd1f144a17e423d38ULL
175#define IOExtensiblePaniclog_AppendData_ID 0xb4e7edba1a448dbfULL
176#define IOExtensiblePaniclog_CopyMemoryDescriptor_ID 0xe16647d53b415a3bULL
177#define IOExtensiblePaniclog_SetUsedLen_ID 0xfd7c6ccbbc4d6c5eULL
178
179#define IOExtensiblePaniclog_Create_Args \
180 OSData * uuid, \
181 OSString * data_id, \
182 uint32_t max_len, \
183 uint32_t options, \
184 IOExtensiblePaniclog ** out
185
186#define IOExtensiblePaniclog_SetActive_Args \
187
188
189#define IOExtensiblePaniclog_SetInactive_Args \
190
191
192#define IOExtensiblePaniclog_InsertData_Args \
193 OSData * data
194
195#define IOExtensiblePaniclog_AppendData_Args \
196 OSData * data
197
198#define IOExtensiblePaniclog_CopyMemoryDescriptor_Args \
199 IOBufferMemoryDescriptor ** mem
200
201#define IOExtensiblePaniclog_SetUsedLen_Args \
202 uint32_t used_len
203
204#define IOExtensiblePaniclog_Methods \
205\
206public:\
207\
208 virtual kern_return_t\
209 Dispatch(const IORPC rpc) APPLE_KEXT_OVERRIDE;\
210\
211 static kern_return_t\
212 _Dispatch(IOExtensiblePaniclog * self, const IORPC rpc);\
213\
214 static kern_return_t\
215 Create(\
216 OSData * uuid,\
217 OSString * data_id,\
218 uint32_t max_len,\
219 uint32_t options,\
220 IOExtensiblePaniclog ** out);\
221\
222 kern_return_t\
223 SetActive(\
224 OSDispatchMethod supermethod = NULL);\
225\
226 kern_return_t\
227 SetInactive(\
228 OSDispatchMethod supermethod = NULL);\
229\
230 kern_return_t\
231 InsertData(\
232 OSData * data,\
233 OSDispatchMethod supermethod = NULL);\
234\
235 kern_return_t\
236 AppendData(\
237 OSData * data,\
238 OSDispatchMethod supermethod = NULL);\
239\
240 kern_return_t\
241 CopyMemoryDescriptor(\
242 IOBufferMemoryDescriptor ** mem,\
243 OSDispatchMethod supermethod = NULL);\
244\
245 kern_return_t\
246 SetUsedLen(\
247 uint32_t used_len,\
248 OSDispatchMethod supermethod = NULL);\
249\
250\
251protected:\
252 /* _Impl methods */\
253\
254\
255public:\
256 /* _Invoke methods */\
257\
258 typedef kern_return_t (*Create_Handler)(IOExtensiblePaniclog_Create_Args);\
259 static kern_return_t\
260 Create_Invoke(const IORPC rpc,\
261 Create_Handler func);\
262\
263 typedef kern_return_t (*SetActive_Handler)(OSMetaClassBase * targetIOExtensiblePaniclog_SetActive_Args);\
264 static kern_return_t\
265 SetActive_Invoke(const IORPC rpc,\
266 OSMetaClassBase * target,\
267 SetActive_Handler func);\
268\
269 typedef kern_return_t (*SetInactive_Handler)(OSMetaClassBase * targetIOExtensiblePaniclog_SetInactive_Args);\
270 static kern_return_t\
271 SetInactive_Invoke(const IORPC rpc,\
272 OSMetaClassBase * target,\
273 SetInactive_Handler func);\
274\
275 typedef kern_return_t (*InsertData_Handler)(OSMetaClassBase * target, IOExtensiblePaniclog_InsertData_Args);\
276 static kern_return_t\
277 InsertData_Invoke(const IORPC rpc,\
278 OSMetaClassBase * target,\
279 InsertData_Handler func);\
280\
281 typedef kern_return_t (*AppendData_Handler)(OSMetaClassBase * target, IOExtensiblePaniclog_AppendData_Args);\
282 static kern_return_t\
283 AppendData_Invoke(const IORPC rpc,\
284 OSMetaClassBase * target,\
285 AppendData_Handler func);\
286\
287 typedef kern_return_t (*CopyMemoryDescriptor_Handler)(OSMetaClassBase * target, IOExtensiblePaniclog_CopyMemoryDescriptor_Args);\
288 static kern_return_t\
289 CopyMemoryDescriptor_Invoke(const IORPC rpc,\
290 OSMetaClassBase * target,\
291 CopyMemoryDescriptor_Handler func);\
292\
293 typedef kern_return_t (*SetUsedLen_Handler)(OSMetaClassBase * target, IOExtensiblePaniclog_SetUsedLen_Args);\
294 static kern_return_t\
295 SetUsedLen_Invoke(const IORPC rpc,\
296 OSMetaClassBase * target,\
297 SetUsedLen_Handler func);\
298\
299
300
301#define IOExtensiblePaniclog_KernelMethods \
302\
303protected:\
304 /* _Impl methods */\
305\
306 static kern_return_t\
307 Create_Impl(IOExtensiblePaniclog_Create_Args);\
308\
309 kern_return_t\
310 SetActive_Impl(IOExtensiblePaniclog_SetActive_Args);\
311\
312 kern_return_t\
313 SetInactive_Impl(IOExtensiblePaniclog_SetInactive_Args);\
314\
315 kern_return_t\
316 InsertData_Impl(IOExtensiblePaniclog_InsertData_Args);\
317\
318 kern_return_t\
319 AppendData_Impl(IOExtensiblePaniclog_AppendData_Args);\
320\
321 kern_return_t\
322 CopyMemoryDescriptor_Impl(IOExtensiblePaniclog_CopyMemoryDescriptor_Args);\
323\
324 kern_return_t\
325 SetUsedLen_Impl(IOExtensiblePaniclog_SetUsedLen_Args);\
326\
327
328
329#define IOExtensiblePaniclog_VirtualMethods \
330\
331public:\
332\
333 virtual bool\
334 init(\
335) APPLE_KEXT_OVERRIDE;\
336\
337 virtual void\
338 free(\
339) APPLE_KEXT_OVERRIDE;\
340\
341 virtual kern_return_t\
342 ClaimBuffer(\
343 uint64_t * addr,\
344 uint64_t * len) APPLE_KEXT_OVERRIDE;\
345\
346 virtual kern_return_t\
347 YieldBuffer(\
348 uint32_t used_len) APPLE_KEXT_OVERRIDE;\
349\
350
351
352#if !KERNEL
353
354extern OSMetaClass * gIOExtensiblePaniclogMetaClass;
355extern const OSClassLoadInformation IOExtensiblePaniclog_Class;
356
357class IOExtensiblePaniclogMetaClass : public OSMetaClass
358{
359public:
360 virtual kern_return_t
361 New(OSObject * instance) override;
362 virtual kern_return_t
363 Dispatch(const IORPC rpc) override;
364};
365
366#endif /* !KERNEL */
367
368#if !KERNEL
369
370class IOExtensiblePaniclogInterface : public OSInterface
371{
372public:
373 virtual kern_return_t
374 ClaimBuffer(uint64_t * addr,
375 uint64_t * len) = 0;
376
377 virtual kern_return_t
378 YieldBuffer(uint32_t used_len) = 0;
379
380 kern_return_t
381 ClaimBuffer_Call(uint64_t * addr,
382 uint64_t * len) { return ClaimBuffer(addr, len); };\
383
384 kern_return_t
385 YieldBuffer_Call(uint32_t used_len) { return YieldBuffer(used_len); };\
386
387};
388
389struct IOExtensiblePaniclog_IVars;
390struct IOExtensiblePaniclog_LocalIVars;
391
392class IOExtensiblePaniclog : public OSObject, public IOExtensiblePaniclogInterface
393{
394#if !KERNEL
395 friend class IOExtensiblePaniclogMetaClass;
396#endif /* !KERNEL */
397
398#if !KERNEL
399public:
400#ifdef IOExtensiblePaniclog_DECLARE_IVARS
401IOExtensiblePaniclog_DECLARE_IVARS
402#else /* IOExtensiblePaniclog_DECLARE_IVARS */
403 union
404 {
405 IOExtensiblePaniclog_IVars * ivars;
406 IOExtensiblePaniclog_LocalIVars * lvars;
407 };
408#endif /* IOExtensiblePaniclog_DECLARE_IVARS */
409#endif /* !KERNEL */
410
411#if !KERNEL
412 static OSMetaClass *
413 sGetMetaClass() { return gIOExtensiblePaniclogMetaClass; };
414#endif /* KERNEL */
415
416 using super = OSObject;
417
418#if !KERNEL
419 IOExtensiblePaniclog_Methods
420 IOExtensiblePaniclog_VirtualMethods
421#endif /* !KERNEL */
422
423};
424#endif /* !KERNEL */
425
426
427#endif /* !__DOCUMENTATION__ */
428
429/* IOExtensiblePaniclog.iig:162- */
430
431#endif /* _IOKIT_UIOEXTENSIBLEPANICLOG_H */
432