X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/0b4e3aa066abc0728aacb4bbeb86f53f9737156e..43866e378188c25dd1e2208016ab3cbeb086ae6c:/iokit/Drivers/platform/drvApplePMU/IOPMUADBController.cpp diff --git a/iokit/Drivers/platform/drvApplePMU/IOPMUADBController.cpp b/iokit/Drivers/platform/drvApplePMU/IOPMUADBController.cpp index 8220e8511..f71f313da 100644 --- a/iokit/Drivers/platform/drvApplePMU/IOPMUADBController.cpp +++ b/iokit/Drivers/platform/drvApplePMU/IOPMUADBController.cpp @@ -3,19 +3,22 @@ * * @APPLE_LICENSE_HEADER_START@ * - * The contents of this file constitute Original Code as defined in and - * are subject to the Apple Public Source License Version 1.1 (the - * "License"). You may not use this file except in compliance with the - * License. Please obtain a copy of the License at - * http://www.apple.com/publicsource and read it before using this file. + * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. * - * This Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * * @APPLE_LICENSE_HEADER_END@ */ @@ -23,6 +26,7 @@ * 12 Nov 1998 suurballe Created. */ +#include #include #include "IOPMUADBController.h" @@ -69,7 +73,7 @@ bool IOPMUADBController::start ( IOService * nub ) waitingForData = NULL; // Registers for the two interrupts that needs to handle: - if (PMUdriver->callPlatformFunction("registerForPMUInterrupts", true, (void*)kPMUADBint, (void*)handleADBInterrupt, (void*)this, NULL) != kIOReturnSuccess) { + if (PMUdriver->callPlatformFunction("registerForPMUInterrupts", true, (void*) (kPMUADBint | kPMUenvironmentInt), (void*)handleADBInterrupt, (void*)this, NULL) != kIOReturnSuccess) { #ifdef VERBOSE_LOGS_ON IOLog("IOPMUADBController::start registerForPMUInterrupts kPMUADBint fails\n"); #endif // VERBOSE_LOGS_ON @@ -83,6 +87,8 @@ bool IOPMUADBController::start ( IOService * nub ) if (!requestMutexLock) return false; + clamshellOpen = true; + // This happens last (while the most common place is the begin) because // trhe superclass may need the services of the functions above. if( !super::start(nub)) @@ -105,7 +111,7 @@ void IOPMUADBController::free ( ) // And removes the interrupt handler: if (PMUdriver != NULL) - PMUdriver->callPlatformFunction("deRegisterClient", true, (void*)this, (void*)kPMUADBint, NULL, NULL); + PMUdriver->callPlatformFunction("deRegisterClient", true, (void*)this, (void*)(kPMUADBint | kPMUenvironmentInt), NULL, NULL); } // ********************************************************************************** @@ -144,7 +150,9 @@ IOReturn IOPMUADBController::localSendMiscCommand(int command, IOByteCount sLeng // ********************************************************************************** // this is the interrupt handler for all ADB interrupts: -// +// A.W. Added code to check for clamshell status, and block all ADB traffic except +// for POWER key scan code from default ADB keyboard or devices that connect +// to that keyboard power button. // ********************************************************************************** /* static */ void @@ -156,8 +164,36 @@ IOPMUADBController::handleADBInterrupt(IOService *client, UInt8 interruptMask, U if (myThis == NULL) return; + if (interruptMask & kPMUenvironmentInt) + { + if (buffer) + { + if (*buffer & kClamshellClosedEventMask) + myThis->clamshellOpen = false; + else + myThis->clamshellOpen = true; + } + if ( !(interruptMask & kPMUautopoll)) + { + return; //Nothing left to do + } + } if ((interruptMask & kPMUautopoll) && (myThis->autopollOn)) - autopollHandler(client, buffer[0], length - 1, buffer + 1); // yes, call adb input handler + { + if (myThis->clamshellOpen) + { + autopollHandler(client, buffer[0], length - 1, buffer + 1); // yes, call adb input handler + } + else if ( (buffer[0] == 0x2c) && (buffer[1] == 0x7f) && (buffer[2] == 0x7f)) + { + autopollHandler(client, buffer[0], length - 1, buffer + 1); // POWER down + } + else if ( (buffer[0] == 0x2c) && (buffer[1] == 0xff) && (buffer[2] == 0xff)) + { + autopollHandler(client, buffer[0], length - 1, buffer + 1); // POWER up + } + + } else { if (myThis->waitingForData != NULL) { // Complets the adb transaction