xref: /xnu-11417.121.6/osfmk/kern/exclaves_resource.h (revision a1e26a70f38d1d7daa7b49b258e2f8538ad81650)
1 /*
2  * Copyright (c) 2023 Apple 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 #if CONFIG_EXCLAVES
30 
31 #pragma once
32 
33 #include <kern/bits.h>
34 #include <kern/locks.h>
35 #include <kern/queue.h>
36 #include <mach/exclaves.h>
37 #include <mach/kern_return.h>
38 #include <sys/event.h>
39 
40 #include <stdint.h>
41 #include <os/base.h>
42 
43 #include "kern/exclaves.tightbeam.h"
44 
45 __BEGIN_DECLS
46 
47 
48 /* -------------------------------------------------------------------------- */
49 #pragma mark Exclaves Resources
50 
51 #define EXCLAVES_DOMAIN_KERNEL "com.apple.kernel"
52 #define EXCLAVES_DOMAIN_DARWIN "com.apple.darwin"
53 
54 /*
55  * Data associated with a conclave.
56  */
57 
58 /*
59  * Conclave State Machine:
60  *
61  *                 Launch Syscall
62  *       +---------+         +--------------+
63  *       |Attached | ------->|   Running    |
64  *       |         |         |              |
65  *       +---------+         +--------------+
66  *          ^ |                 |       ^
67  *    Spawn | |proc_exit        |       |
68  *          | |                 |       |
69  *          | v                 |       |
70  *      +---------+    Suspend  |       | Unsuspend
71  * *--> |  None   |     IPC to  |       |   IPC to
72  *      |         |    Conclave |       | Conclave
73  *      +---------+    Manager  |       | Manager
74  *           ^                  |       |
75  *  proc_exit|                  |       |
76  *           |                  |       |
77  *           |                  v       |
78  *         +---------+       +------------+
79  *         | Stopped |<------|  Suspended |
80  *         |         |       |            |
81  *         +---------+       +------------+
82  *                    Stop IPC
83  *                   to Conclave Manager
84  */
85 typedef enum {
86 	CONCLAVE_S_NONE = 0,
87 	CONCLAVE_S_ATTACHED = 0x1,
88 	CONCLAVE_S_RUNNING = 0x2,
89 	CONCLAVE_S_STOPPED = 0x3,
90 	CONCLAVE_S_SUSPENDED = 0x4,
91 } conclave_state_t;
92 
93 typedef enum __attribute__((flag_enum)) {
94 	CONCLAVE_R_NONE = 0,
95 	CONCLAVE_R_LAUNCH_REQUESTED = 0x1,
96 	CONCLAVE_R_SUSPEND_REQUESTED = 0x2,
97 	CONCLAVE_R_STOP_REQUESTED = 0x4,
98 } conclave_request_t;
99 
100 /* The maximum number of services available in any conclave. */
101 #define CONCLAVE_SERVICE_MAX 192
102 
103 typedef struct {
104 	conclave_state_t       c_state;
105 	conclave_request_t     c_request;
106 	bool                   c_active_downcall;
107 	bool                   c_active_stopcall;
108 	bool                   c_active_detach;
109 	tb_client_connection_t c_control;
110 	task_t XNU_PTRAUTH_SIGNED_PTR("conclave.task") c_task;
111 	thread_t XNU_PTRAUTH_SIGNED_PTR("conclave.thread") c_downcall_thread;
112 	bitmap_t               c_service_bitmap[BITMAP_LEN(CONCLAVE_SERVICE_MAX)];
113 } conclave_resource_t;
114 
115 typedef struct {
116 	size_t sm_size;
117 	exclaves_buffer_perm_t sm_perm;
118 	char *sm_addr;
119 	sharedmemorybase_mapping_s sm_mapping;
120 	sharedmemorybase_segxnuaccess_s sm_client;
121 } shared_memory_resource_t;
122 
123 typedef struct {
124 	/* how many times *this* sensor resource handle has been
125 	 * used to call sensor_start */
126 	uint64_t s_startcount;
127 } sensor_resource_t;
128 
129 typedef struct {
130 	struct klist notification_klist;
131 } exclaves_notification_t;
132 
133 /*
134  * Every resource has an associated name and some other common state.
135  * Additionally there may be type specific data associated with the resource.
136  */
137 #define EXCLAVES_RESOURCE_NAME_MAX 128
138 typedef struct exclaves_resource {
139 	char                r_name[EXCLAVES_RESOURCE_NAME_MAX];
140 	xnuproxy_resourcetype_s r_type;
141 	uint64_t            r_id;
142 	_Atomic uint32_t    r_usecnt;
143 	ipc_port_t          r_port;
144 	lck_mtx_t           r_mutex;
145 	bool                r_active;
146 	bool                r_connected;
147 
148 	union {
149 		conclave_resource_t     r_conclave;
150 		sensor_resource_t       r_sensor;
151 		exclaves_notification_t r_notification;
152 		shared_memory_resource_t r_shared_memory;
153 	};
154 } exclaves_resource_t;
155 
156 /*!
157  * @function exclaves_resource_init
158  *
159  * @abstract
160  * Called during exclaves_boot to dump the resource information from xnu proxy
161  * and build the xnu-side tables.
162  *
163  * @return
164  * KERN_SUCCESS on success otherwise an error code.
165  */
166 extern kern_return_t
167 exclaves_resource_init(void);
168 
169 /*!
170  * @function exclaves_resource_name
171  *
172  * @abstract
173  * Return the name associated with a resource.
174  *
175  * @param resource
176  * Conclave manager resource.
177  *
178  * @return
179  * The name of the resource or NULL.
180  */
181 extern const char *
182 exclaves_resource_name(const exclaves_resource_t *resource);
183 
184 /*!
185  * @function exclaves_resource_retain
186  *
187  * @abstract
188  * Grab a reference to the specified resource
189  *
190  * @param resource
191  * The resource to retain.
192  *
193  * @return
194  * The value of the use count before the retain
195  */
196 extern uint32_t
197 exclaves_resource_retain(exclaves_resource_t *resource);
198 
199 /*!
200  * @function exclaves_resource_release
201  *
202  * @abstract
203  * Drop a reference to the specified resource
204  *
205  * @param resource
206  * The resource to release.
207  *
208  * @discussion
209  * This may result in a resource type specific release function being called
210  * which can grab locks, free memory etc.
211  * After this function has been called, the resource should not be accessed as
212  * it may be in an uninitialized state.
213  */
214 extern void
215 exclaves_resource_release(exclaves_resource_t *resource);
216 
217 /*!
218  * @function exclaves_resource_from_port_name
219  *
220  * @abstract
221  * Find the resource associated with a port name in the specified space.
222  *
223  * @param space
224  * IPC space to search
225  *
226  * @param name
227  * Port name of the resource.
228  *
229  * @param resource
230  * Out parameter holding a pointer to the resource.
231  *
232  * @return
233  * KERN_SUCCESS or error code on failure.
234  *
235  * @discussion
236  * Returns with a +1 use-count on the resource which must be dropped with
237  * exclaves_resource_release().
238  */
239 extern kern_return_t
240 exclaves_resource_from_port_name(ipc_space_t space, mach_port_name_t name,
241     exclaves_resource_t **resource);
242 
243 
244 /*!
245  * @function exclaves_resource_create_port_name
246  *
247  * @abstract
248  * Create a port name for the given resource in the specified space.
249  *
250  * @param name
251  * Our parameter for holding a pointer to the port name.
252  *
253  * @param space
254  * IPC space in which to create the name
255  *
256  * @param resource
257  * Resource for which to create a port name for.
258  *
259  * @return
260  * KERN_SUCCESS or error code on failure.
261  *
262  * @discussion
263  * Returns with a +1 use-count on the resource which is associated with the life
264  * of the newly created send right.
265  */
266 extern kern_return_t
267 exclaves_resource_create_port_name(exclaves_resource_t *resource, ipc_space_t space,
268     mach_port_name_t *name);
269 
270 
271 /* -------------------------------------------------------------------------- */
272 #pragma mark Conclaves
273 
274 /*!
275  * @function exclaves_conclave_attach
276  *
277  * @abstract
278  * Attach a conclave to a task. The conclave must not already be attached to any
279  * task. Once attached, this conclave is exclusively associated with the task.
280  *
281  * @param name
282  * The name of conclave resource.
283  *
284  * @param task
285  * Task to attach the conclave to.
286  *
287  * @return
288  * KERN_SUCCESS on success, error code otherwise.
289  */
290 extern kern_return_t
291 exclaves_conclave_attach(const char *name, task_t task);
292 
293 /*!
294  * @function exclaves_conclave_detach
295  *
296  * @abstract
297  * Detach a conclave from a task. The conclave must already be attached to the
298  * task and stopped. Once detached, this conclave is available for other tasks.
299  *
300  * @param resource
301  * Conclave Manager resource.
302  *
303  * @param task
304  * Task to detach the conclave from.
305  *
306  * @return
307  * KERN_SUCCESS on success, error code otherwise.
308  */
309 extern kern_return_t
310 exclaves_conclave_detach(exclaves_resource_t *resource, task_t task);
311 
312 /*!
313  * @function exclaves_conclave_inherit
314  *
315  * @abstract
316  * Pass an attached conclave from one task to another.
317  *
318  * @param resource
319  * Conclave Manager resource.
320  *
321  * @param old_task
322  * Task with attached conclave.
323  *
324  * @param new_task
325  * Task which will inherit the conclave.
326  *
327  * @return
328  * KERN_SUCCESS on success, error code otherwise.
329  */
330 extern kern_return_t
331 exclaves_conclave_inherit(exclaves_resource_t *resource, task_t old_task,
332     task_t new_task);
333 
334 
335 /*!
336  * @function exclaves_conclave_is_attached
337  *
338  * @abstract
339  * Returns true if the conclave is in the ATTACHED state.
340  *
341  * @param resource
342  * Conclave Manager resource.
343  *
344  * @return
345  * True if conclave is attached, false otherwise
346  */
347 extern bool
348 exclaves_conclave_is_attached(const exclaves_resource_t *resource);
349 
350 /*!
351  * @function exclaves_conclave_launch
352  *
353  * @abstract
354  * Launch a conclave. The conclave must be attached to a task and not already
355  * launched.
356  *
357  * @param resource
358  * Conclave Manager resource.
359  *
360  * @return
361  * KERN_SUCCESS on success, error code otherwise.
362  */
363 extern kern_return_t
364 exclaves_conclave_launch(exclaves_resource_t *resource);
365 
366 /*!
367  * @function exclaves_conclave_lookup_resources
368  *
369  * @abstract
370  * Lookup conclave resource. The conclave must be attached to a task and
371  * launched.
372  *
373  * @param resource
374  * Conclave Manager resource.
375  *
376  * @param conclave_resource_user
377  * Array to fill user resources for Conclave
378  *
379  * @param resource_count
380  * Number of resources in array
381  *
382  * @return
383  * KERN_SUCCESS on success, error code otherwise.
384  */
385 extern kern_return_t
386 exclaves_conclave_lookup_resources(exclaves_resource_t *resource,
387     struct exclaves_resource_user *conclave_resource_user, int resource_count);
388 
389 /*!
390  * @function exclaves_conclave_stop
391  *
392  * @abstract
393  * Stop a conclave. The conclave must be launched and attached.
394  *
395  * @param resource
396  * Conclave Manager resource.
397  *
398  * @param gather_crash_bt
399  * Conclave Manager needs to gather backtraces
400  *
401  * @return
402  * KERN_SUCCESS on success, error code otherwise.
403  */
404 extern kern_return_t
405 exclaves_conclave_stop(exclaves_resource_t *resource, bool gather_crash_bt);
406 
407 /*!
408  * @function exclaves_conclave_suspend
409  *
410  * @abstract
411  * Suspend a conclave. The conclave must be attached.
412  *
413  * @param resource
414  * Conclave Manager resource.
415  *
416  * @return
417  * KERN_SUCCESS on success, error code otherwise.
418  */
419 extern kern_return_t
420 exclaves_conclave_suspend(exclaves_resource_t *resource);
421 
422 /*!
423  * @function exclaves_conclave_resume
424  *
425  * @abstract
426  * Resume a conclave. The conclave must be attached.
427  *
428  * @param resource
429  * Conclave Manager resource.
430  *
431  * @return
432  * KERN_SUCCESS on success, error code otherwise.
433  */
434 extern kern_return_t
435 exclaves_conclave_resume(exclaves_resource_t *resource);
436 
437 /*!
438  * @function exclaves_conclave_stop_upcall
439  *
440  * @abstract
441  * Stop a conclave. The conclave must be launched and attached.
442  *
443  * @param resource
444  * Conclave Manager resource.
445  *
446  * @return
447  * KERN_SUCCESS on success, error code otherwise.
448  */
449 extern kern_return_t
450 exclaves_conclave_stop_upcall(exclaves_resource_t *resource);
451 
452 /*!
453  * @function exclaves_conclave_stop_upcall_complete
454  *
455  * @abstract
456  * Complete the Conclave stop once back in regular context.
457  *
458  * @param resource
459  * Conclave Manager resource.
460  *
461  * @param task
462  * Conclave Host task
463  *
464  * @return
465  * KERN_SUCCESS on success, error code otherwise.
466  */
467 extern kern_return_t
468 exclaves_conclave_stop_upcall_complete(exclaves_resource_t *resource, task_t task);
469 
470 /*!
471  * @function exclaves_conclave_get_domain
472  *
473  * @abstract
474  * Return the domain associated with the specified conclave resource. Or the
475  * kernel domain if the conclave resource is NULL.
476  *
477  * @param resource
478  * Conclave Manager resource.
479  *
480  * @return
481  * The domain of the conclave or the kernel domain.
482  */
483 extern const char *
484 exclaves_conclave_get_domain(exclaves_resource_t *resource);
485 
486 
487 /*!
488  * @function exclaves_conclave_has_service
489  *
490  * @abstract
491  * Return true if the service ID is associated with the specified conclave
492  * resource.
493  *
494  * @param resource
495  * Conclave Manager resource.
496  *
497  * @params id
498  * ID of a SERVICE resource.
499  *
500  * @return
501  * true if the ID is available to conclave, false otherwise
502  */
503 extern bool
504 exclaves_conclave_has_service(exclaves_resource_t *resource, uint64_t id);
505 
506 /* -------------------------------------------------------------------------- */
507 #pragma mark Sensors
508 
509 /*!
510  * @function exclaves_resource_sensor_open
511  *
512  * @abstract
513  * Open a sensor resource.
514  *
515  * @param domain
516  * The domain to search.
517  *
518  * @param name
519  * The name of the sensor resource.
520  *
521  * @param resource
522  * Out parameter which holds the resource on success.
523  *
524  * @return
525  * KERN_SUCCESS on success, error code otherwise.
526  *
527  * @discussion
528  * Returns with a +1 use-count on the resource which must be dropped with
529  * exclaves_resource_release().
530  */
531 extern kern_return_t
532 exclaves_resource_sensor_open(const char *domain, const char *name,
533     exclaves_resource_t **resource);
534 
535 /*!
536  * @function exclaves_resource_sensor_start
537  *
538  * @abstract
539  * Start accessing a sensor.
540  *
541  * @param resource
542  * Sensor resource.
543  *
544  * @param flags
545  * Flags to pass to implementation.
546  *
547  * @param status
548  * output parameter for status of sensor after this operation.
549  *
550  * @return
551  * KERN_SUCCESS on success, error code otherwise.
552  */
553 kern_return_t
554 exclaves_resource_sensor_start(exclaves_resource_t *resource, uint64_t flags,
555     exclaves_sensor_status_t *status);
556 
557 /*!
558  * @function exclaves_resource_sensor_stop
559  *
560  * @abstract
561  * Stop accessing a sensor.
562  *
563  * @param resource
564  * Sensor resource.
565  *
566  * @param flags
567  * Flags to pass to implementation.
568  *
569  * @param status
570  * output parameter for status of sensor after this operation.
571  *
572  * @return
573  * KERN_SUCCESS on success, error code otherwise.
574  */
575 kern_return_t
576 exclaves_resource_sensor_stop(exclaves_resource_t *resource, uint64_t flags,
577     exclaves_sensor_status_t *status);
578 
579 /*!
580  * @function exclaves_resource_sensor_status
581  *
582  * @abstract
583  * Query the status of access to a sensor.
584  *
585  * @param resource
586  * Sensor resource.
587  *
588  * @param flags
589  * Flags to pass to implementation.
590  *
591  * @param status
592  * output parameter for status of sensor after this operation.
593  *
594  * @return
595  * KERN_SUCCESS on success, error code otherwise.
596  */
597 kern_return_t
598 exclaves_resource_sensor_status(exclaves_resource_t *resource, uint64_t flags,
599     exclaves_sensor_status_t *status);
600 
601 /* -------------------------------------------------------------------------- */
602 #pragma mark Notifications
603 
604 /*!
605  * @function exclaves_notification_create
606  *
607  * @abstract
608  * Set up an exclave notification from the specified resource.
609  *
610  * @param domain
611  * The domain to search.
612  *
613  * @param name
614  * The name of the notification resource.
615  *
616  * @return
617  * A notification resource or NULL.
618  *
619  * @discussion
620  * Returns with a +1 use-count on the resource which must be dropped with
621  * exclaves_resource_release().
622  */
623 extern kern_return_t
624 exclaves_notification_create(const char *domain, const char *name,
625     exclaves_resource_t **resource);
626 
627 /*!
628  * @function exclaves_notification_signal
629  *
630  * @abstract
631  * To be called from upcall context when the specified notification resource is signaled.
632  *
633  * @param resource
634  * Notification resource.
635  *
636  * @param event_mask
637  * Bit mask of events for the notification.
638  *
639  * @return
640  * KERN_SUCCESS on success, error code otherwise.
641  */
642 extern kern_return_t
643 exclaves_notification_signal(exclaves_resource_t *resource, long event_mask);
644 
645 
646 /*!
647  * @function exclaves_notificatione_lookup_by_id
648  *
649  * @abstract
650  * Find an exclave notification  by ID.
651  *
652  * @param id
653  * The resource ID.
654  *
655  * @param domain
656  * The domain to search.
657  *
658  * @return
659  * Pointer to the resource
660  */
661 exclaves_resource_t *
662 exclaves_notification_lookup_by_id(const char *domain, uint64_t id);
663 
664 
665 /* -------------------------------------------------------------------------- */
666 #pragma mark Services
667 
668 /*
669  * Indicates an invalid service. */
670 #define  EXCLAVES_INVALID_ID UINT64_C(~0)
671 
672 /*!
673  * @function exclaves_service_lookup
674  *
675  * @abstract
676  * Look up a service resource
677  *
678  * @param domain
679  * The domain to search.
680  *
681  * @param name
682  * The name of the service resource.
683  *
684  * @return
685  * ID of service or EXCLAVES_INVALID_ID if the service cannot be found.
686  */
687 extern uint64_t
688 exclaves_service_lookup(const char *domain, const char *name);
689 
690 
691 /* -------------------------------------------------------------------------- */
692 #pragma mark Shared Memory
693 
694 /*!
695  * @function exclaves_resource_shared_memory_map
696  *
697  * @abstract
698  * Map a shared memory resource.
699  *
700  * @param domain
701  * The domain to search.
702  *
703  * @param name
704  * The name of the shared memory resource.
705  *
706  * @param size
707  * Size of shared memory region to map.
708  *
709  * @param perm
710  * The permissions of the shared memory.
711  *
712  * @param resource
713  * Out parameter which holds the resource on success.
714  *
715  * @return
716  * KERN_SUCCESS or an error code.
717  *
718  * @discussion
719  * Returns with a +1 use-count on the resource which must be dropped with
720  * exclaves_resource_release().
721  */
722 extern kern_return_t
723 exclaves_resource_shared_memory_map(const char *domain, const char *name,
724     size_t size, exclaves_buffer_perm_t perm, exclaves_resource_t **resource);
725 
726 /*!
727  * @function exclaves_resource_shared_memory_copyin
728  *
729  * @abstract
730  * Copy user data into a shared memory.
731  *
732  * @param resource
733  * Shared memory resource.
734  *
735  * @param ubuffer
736  * Source of data to copy.
737  *
738  * @param usize1
739  * Size of data to copy.
740  *
741  * @param uoffset1
742  * Offset into the shared memory.
743  *
744  * @param usize2
745  * Size of 2nd range of data to copy (can be 0).
746  *
747  * @param uoffset2
748  * Offset of 2nd range into the shared memory.
749  *
750  * @return
751  * KERN_SUCCESS or error code on failure.
752  */
753 extern kern_return_t
754 exclaves_resource_shared_memory_copyin(exclaves_resource_t *resource,
755     user_addr_t ubuffer, mach_vm_size_t usize1, mach_vm_size_t uoffset1,
756     mach_vm_size_t usize2, mach_vm_size_t uoffset2);
757 
758 /*!
759  * @function exclaves_resource_shared_memory_copyout
760  *
761  * @abstract
762  * Copy user data into a shared memory.
763  *
764  * @param resource
765  * Shared memory resource.
766  *
767  * @param ubuffer
768  * Destination to copy data to.
769  *
770  * @param usize1
771  * Size of data to copy.
772  *
773  * @param uoffset1
774  * Offset into the shared memory.
775  *
776  * @param usize2
777  * Size of 2nd range of data to copy (can be 0).
778  *
779  * @param uoffset2
780  * Offset of 2nd range into the shared memory.
781  *
782  * @return
783  * KERN_SUCCESS or error code on failure.
784  */
785 extern kern_return_t
786 exclaves_resource_shared_memory_copyout(exclaves_resource_t *resource,
787     user_addr_t ubuffer, mach_vm_size_t usize1, mach_vm_size_t uoffset1,
788     mach_vm_size_t usize2, mach_vm_size_t uoffset2);
789 
790 /*!
791  * @function exclaves_resource_shared_memory_get_buffer
792  *
793  * @abstract
794  * Return a pointer to the shared memory buffer. Must already be mapped.
795  *
796  * @param resource
797  * Shared memory resource.
798  *
799  * @param buffer_len
800  * Returns the length of the returned buffer.
801  *
802  * @return
803  * Pointer to shared memory.
804  */
805 extern char *
806 exclaves_resource_shared_memory_get_buffer(exclaves_resource_t *resource,
807     size_t *buffer_len);
808 
809 /* -------------------------------------------------------------------------- */
810 #pragma mark Arbitrated Audio Memory
811 
812 /*!
813  * @function exclaves_resource_audio_memory_map
814  *
815  * @abstract
816  * Map an audio memory resource.
817  *
818  * @param domain
819  * The domain to search.
820  *
821  * @param name
822  * The name of audio memory resource.
823  *
824  * @param size
825  * Size of named buffer region to map.
826  *
827  * @param resource
828  * Out parameter which holds the resource on success.
829  *
830  * @return
831  * KERN_SUCCESS or error code on failure.
832  *
833  * @discussion
834  * Returns with a +1 use-count on the resource which must be dropped with
835  * exclaves_resource_release().
836  */
837 extern kern_return_t
838 exclaves_resource_audio_memory_map(const char *domain, const char *name, size_t size,
839     exclaves_resource_t **resource);
840 
841 /*!
842  * @function exclaves_resource_audio_memory_copyout
843  *
844  * @abstract
845  * Copy user data into a audio memory.
846  *
847  * @param resource
848  * audio memory resource.
849  *
850  * @param ubuffer
851  * Destination to copy data to.
852  *
853  * @param usize1
854  * Size of data to copy.
855  *
856  * @param uoffset1
857  * Offset into the audio memory.
858  *
859  * @param usize2
860  * Size of 2nd range of data to copy (can be 0).
861  *
862  * @param uoffset2
863  * Offset of 2nd range into the audio memory.
864  *
865  * @param ustatus
866  * Destination to copy status to.
867  *
868  * @return
869  * KERN_SUCCESS or error code on failure.
870  */
871 extern kern_return_t
872 exclaves_resource_audio_memory_copyout(exclaves_resource_t *resource,
873     user_addr_t ubuffer, mach_vm_size_t usize1, mach_vm_size_t uoffset1,
874     mach_vm_size_t usize2, mach_vm_size_t uoffset2, user_addr_t ustatus);
875 
876 extern exclaves_resource_t *
877 exclaves_resource_lookup_by_name(const char *domain_name, const char *name,
878     xnuproxy_resourcetype_s type);
879 
880 __END_DECLS
881 
882 #endif /* CONFIG_EXCLAVES */
883