2 * Copyright (c) 2019 Apple Computer, Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
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.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
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.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
30 #include <mach/task.h>
31 #include <machine/machine_routines.h>
32 #include <pexpert/pexpert.h>
35 #include <IOKit/IOPlatformExpert.h>
36 #include <IOKit/IOService.h>
37 #include <IOKit/PassthruInterruptController.h>
39 #define super IOInterruptController
40 OSDefineMetaClassAndStructors(PassthruInterruptController
, IOInterruptController
);
43 PassthruInterruptController::init(void)
46 !this->setProperty(gPlatformInterruptControllerName
, kOSBooleanTrue
) ||
47 !this->attach(getPlatform())) {
51 if (getPlatform()->registerInterruptController(gPlatformInterruptControllerName
, this) != kIOReturnSuccess
) {
54 if (semaphore_create(kernel_task
, &child_sentinel
, SYNC_POLICY_FIFO
, 0) != KERN_SUCCESS
) {
61 PassthruInterruptController::setCPUInterruptProperties(IOService
*service
)
63 if ((service
->getProperty(gIOInterruptControllersKey
) != NULL
) &&
64 (service
->getProperty(gIOInterruptSpecifiersKey
) != NULL
)) {
69 OSArray
*specifier
= OSArray::withCapacity(1);
70 OSData
*tmpData
= OSData::withBytes(&zero
, sizeof(zero
));
71 specifier
->setObject(tmpData
);
73 service
->setProperty(gIOInterruptSpecifiersKey
, specifier
);
76 OSArray
*controller
= OSArray::withCapacity(1);
77 controller
->setObject(gPlatformInterruptControllerName
);
78 service
->setProperty(gIOInterruptControllersKey
, controller
);
79 controller
->release();
83 PassthruInterruptController::registerInterrupt(IOService
*nub
,
86 IOInterruptHandler handler
,
89 child_handler
= handler
;
91 child_target
= target
;
92 child_refCon
= refCon
;
94 // Wake up waitForChildController() to tell it that AIC is registered
95 semaphore_signal(child_sentinel
);
96 return kIOReturnSuccess
;
100 PassthruInterruptController::waitForChildController(void)
102 // Block if child controller isn't registered yet. Assumes that this
103 // is only called from one place.
104 semaphore_wait(child_sentinel
);
106 // NOTE: Assumes that AppleInterruptController passes |this| as the target argument.
111 PassthruInterruptController::getInterruptType(IOService */
*nub*/
,
115 if (interruptType
== NULL
) {
116 return kIOReturnBadArgument
;
119 *interruptType
= kIOInterruptTypeLevel
;
121 return kIOReturnSuccess
;
125 PassthruInterruptController::enableInterrupt(IOService */
*nub*/
,
128 return kIOReturnSuccess
;
132 PassthruInterruptController::disableInterrupt(IOService */
*nub*/
,
135 return kIOReturnSuccess
;
139 PassthruInterruptController::causeInterrupt(IOService */
*nub*/
,
142 ml_cause_interrupt();
143 return kIOReturnSuccess
;
147 PassthruInterruptController::handleInterrupt(void */
*refCon*/
,
151 panic("handleInterrupt shouldn't be invoked directly");
155 PassthruInterruptController::externalInterrupt(void)
157 child_handler(child_target
, child_refCon
, child_nub
, 0);