1 /* 2 * Copyright (c) 2024 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 <sys/cdefs.h> 34 35 #include <mach/kern_return.h> 36 37 #include "kern/exclaves.tightbeam.h" 38 39 __BEGIN_DECLS 40 41 /*! 42 * @function exclaves_aoe_setup 43 * 44 * @abstract 45 * Called from a thread in an Always-On conclave. Returns the number of message 46 * and worker threads required. 47 * 48 * @param num_message 49 * Returns the number of message threads that should be spawned. 50 * 51 * @param num_worker 52 * Returns the number of worker threads that should be spawned. 53 * 54 * @return 55 * KERN_SUCCESS or error code on failure. 56 */ 57 extern kern_return_t 58 exclaves_aoe_setup(uint8_t *num_message, uint8_t *num_worker); 59 60 /*! 61 * @function exclaves_aoe_teardown 62 * 63 * @abstract 64 * Cleans up state (if any) initialised by exclaves_aoe_setup(). 65 */ 66 extern void 67 exclaves_aoe_teardown(void); 68 69 /*! 70 * @function exclaves_aoe_message_loop 71 * 72 * @abstract 73 * Called from an AOE message thread. Can return with an error if AOE is not 74 * supported or uninitialised. Once successfully setup will only ever return if 75 * the thread was aborted. 76 * Used to handle message delivery. 77 */ 78 extern kern_return_t 79 exclaves_aoe_message_loop(void); 80 81 /*! 82 * @function exclaves_aoe_work_loop 83 * 84 * @abstract 85 * Called from an AOE worker thread. Can return with an error if AOE is not 86 * supported or uninitialised. Once successfully setup will only ever return if 87 * the thread was aborted. 88 * Worker threads for message processing. 89 */ 90 extern kern_return_t 91 exclaves_aoe_work_loop(void); 92 93 /*! 94 * @function exclaves_aoe_upcall_work_available 95 * 96 * @abstract 97 * Upcall invoked when AOE proxy has recieved new work that needs to be processed. 98 * 99 * @param work_info 100 * Information on the type of work available. 101 * 102 * @param completion 103 * Tightbeam completion callback. 104 * 105 * @return 106 * TB_ERROR_SUCCESS or error code on failure. 107 */ 108 extern tb_error_t 109 exclaves_aoe_upcall_work_available(const xnuupcallsv2_aoeworkinfo_s * work_info, 110 tb_error_t (^completion)(void)); 111 112 __END_DECLS 113 114 #endif /* CONFIG_EXCLAVES */ 115