1 /*
2 * Copyright (c) 1998-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 #include <IOKit/IOService.h>
30 #include <IOKit/IOInterruptEventSource.h>
31 #include <IOKit/IOTimerEventSource.h>
32 #include <IOKit/IOMapper.h>
33 #include "../Kernel/IOServicePrivate.h"
34
35 #include <Exclaves/Exclaves.h>
36
37
38 struct IOService::IOExclaveProxyState {
39 IOService *service;
40 uint64_t mach_endpoint;
41 };
42
43
44 bool
exclaveStart(IOService * provider,IOExclaveProxyState ** pRef)45 IOService::exclaveStart(IOService * provider, IOExclaveProxyState ** pRef)
46 {
47 IOExclaveProxyState * ref;
48
49 ref = NULL;
50
51 if (!ref) {
52 return false;
53 }
54
55 *pRef = ref;
56 return true;
57 }
58
59 uint64_t
exclaveEndpoint(IOExclaveProxyState * pRef)60 IOService::exclaveEndpoint(IOExclaveProxyState * pRef)
61 {
62 return pRef->mach_endpoint;
63 }
64
65 bool
start(IOService * provider)66 IOExclaveProxy::start(IOService * provider)
67 {
68 bool ok;
69
70 ok = exclaveStart(provider, &exclaveState);
71
72 return ok;
73 }
74
75 /* Exclave upcall handlers */
76
77
78 bool
exclaveRegisterInterrupt(IOExclaveProxyState * pRef,int index,bool noProvider=false)79 IOService::exclaveRegisterInterrupt(IOExclaveProxyState * pRef, int index, bool noProvider = false)
80 {
81 return false;
82 }
83
84 bool
exclaveRemoveInterrupt(IOExclaveProxyState * pRef,int index)85 IOService::exclaveRemoveInterrupt(IOExclaveProxyState * pRef, int index)
86 {
87 return false;
88 }
89
90 bool
exclaveEnableInterrupt(IOExclaveProxyState * pRef,int index,bool enable)91 IOService::exclaveEnableInterrupt(IOExclaveProxyState * pRef, int index, bool enable)
92 {
93 return false;
94 }
95
96
97 void
exclaveInterruptOccurred(IOInterruptEventSource * eventSource,int count)98 IOService::exclaveInterruptOccurred(IOInterruptEventSource *eventSource, int count)
99 {
100 }
101
102
103 bool
exclaveRegisterTimer(IOExclaveProxyState * pRef,uint32_t * timer_id)104 IOService::exclaveRegisterTimer(IOExclaveProxyState * pRef, uint32_t *timer_id)
105 {
106 return false;
107 }
108
109 bool
exclaveRemoveTimer(IOExclaveProxyState * pRef,uint32_t timer_id)110 IOService::exclaveRemoveTimer(IOExclaveProxyState * pRef, uint32_t timer_id)
111 {
112 return false;
113 }
114
115 bool
exclaveEnableTimer(IOExclaveProxyState * pRef,uint32_t timer_id,bool enable)116 IOService::exclaveEnableTimer(IOExclaveProxyState * pRef, uint32_t timer_id, bool enable)
117 {
118 return false;
119 }
120
121 bool
exclaveTimerSetTimeout(IOExclaveProxyState * pRef,uint32_t timer_id,uint32_t options,AbsoluteTime interval,AbsoluteTime leeway,kern_return_t * kr)122 IOService::exclaveTimerSetTimeout(IOExclaveProxyState * pRef, uint32_t timer_id, uint32_t options, AbsoluteTime interval, AbsoluteTime leeway, kern_return_t *kr)
123 {
124 return false;
125 }
126
127 bool
exclaveTimerCancelTimeout(IOExclaveProxyState * pRef,uint32_t timer_id)128 IOService::exclaveTimerCancelTimeout(IOExclaveProxyState * pRef, uint32_t timer_id)
129 {
130 return false;
131 }
132
133 void
exclaveTimerFired(IOTimerEventSource * eventSource)134 IOService::exclaveTimerFired(IOTimerEventSource *eventSource)
135 {
136 }
137
138
139 kern_return_t
exclaveAsyncNotificationRegister(IOExclaveProxyState * pRef,IOInterruptEventSource * notification,uint32_t * notificationID)140 IOService::exclaveAsyncNotificationRegister(IOExclaveProxyState * pRef, IOInterruptEventSource *notification, uint32_t *notificationID)
141 {
142 #pragma unused(pRef, notification, notificationID)
143 return kIOReturnUnsupported;
144 }
145
146 kern_return_t
exclaveAsyncNotificationSignal(IOExclaveProxyState * pRef,uint32_t notificationID)147 IOService::exclaveAsyncNotificationSignal(IOExclaveProxyState * pRef, uint32_t notificationID)
148 {
149 #pragma unused(pRef, notificationID)
150 return kIOReturnUnsupported;
151 }
152