Skip to content

Commit

Permalink
fix build, fix syntax issues, fix sleep bug
Browse files Browse the repository at this point in the history
  • Loading branch information
RehabMan committed Oct 6, 2012
1 parent 6b947dc commit b33b10c
Show file tree
Hide file tree
Showing 28 changed files with 496 additions and 425 deletions.
4 changes: 4 additions & 0 deletions AppleACPIPS2Nub/AppleACPIPS2Nub-Prefix.pch
@@ -0,0 +1,4 @@
//
// Prefix header for all source files of the 'AppleACPIPS2Nub' target in the 'AppleACPIPS2Nub' project
//

2 changes: 1 addition & 1 deletion AppleACPIPS2Nub/AppleACPIPS2Nub.cpp
Expand Up @@ -114,7 +114,7 @@ IOService *AppleACPIPS2Nub::findMouseDevice()
IORegistryEntry *entry;
if(i != NULL)
{
while(entry = i->getNextObject())
while((entry = i->getNextObject()))
{
if(entry->compareNames(prop))
break;
Expand Down
15 changes: 15 additions & 0 deletions VoodooPS2Controller/ApplePS2Device.h
Expand Up @@ -317,4 +317,19 @@ enum {
kPS2C_EnableDevice
};

//TODO: rehabman maybe figure out how to use pio.h
//#warning FIXME: use inb and outb from the kernel framework (2688371)
typedef unsigned short i386_ioport_t;
inline unsigned char inb(i386_ioport_t port)
{
unsigned char datum;
asm volatile("inb %1, %0" : "=a" (datum) : "d" (port));
return(datum);
}

inline void outb(i386_ioport_t port, unsigned char datum)
{
asm volatile("outb %0, %1" : : "a" (datum), "d" (port));
}

#endif /* !_APPLEPS2DEVICE_H */
64 changes: 64 additions & 0 deletions VoodooPS2Controller/IOSyncer.h
@@ -0,0 +1,64 @@
/*
* Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* 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. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* 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, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef _IOSYNCER_H
#define _IOSYNCER_H

#include <libkern/c++/OSObject.h>
#include <IOKit/IOTypes.h>
#include <IOKit/IOLocks.h>

class IOSyncer : public OSObject
{
OSDeclareDefaultStructors(IOSyncer)

private:
// The spin lock that is used to guard the 'threadMustStop' variable.
IOSimpleLock *guardLock;
volatile bool threadMustStop;
IOReturn fResult;
virtual void free();
virtual void privateSignal();

public:

static IOSyncer * create(bool twoRetains = true)
APPLE_KEXT_DEPRECATED;

virtual bool init(bool twoRetains)
APPLE_KEXT_DEPRECATED;
virtual void reinit()
APPLE_KEXT_DEPRECATED;
virtual IOReturn wait(bool autoRelease = true)
APPLE_KEXT_DEPRECATED;
virtual void signal(IOReturn res = kIOReturnSuccess,
bool autoRelease = true)
APPLE_KEXT_DEPRECATED;
};

#endif /* !_IOSYNCER */

4 changes: 4 additions & 0 deletions VoodooPS2Controller/VoodooPS2Controller-Prefix.pch
@@ -0,0 +1,4 @@
//
// Prefix header for all source files of the 'VoodooPS2Controller' target in the 'VoodooPS2Controller' project
//

49 changes: 21 additions & 28 deletions VoodooPS2Controller/VoodooPS2Controller.cpp
Expand Up @@ -22,8 +22,10 @@

#include <IOKit/assert.h>
#include <IOKit/IOService.h>
#include <IOKit/IOSyncer.h>
#include <IOKit/IOWorkLoop.h>
//#include <IOKit/IOSyncer.h>
//TODO: IOSyncer is deprecated in 10.7 headers, gone from 10.8 headers
#include "IOsyncer.h"
#include "ApplePS2KeyboardDevice.h"
#include "ApplePS2MouseDevice.h"
#include "VoodooPS2Controller.h"
Expand All @@ -34,20 +36,6 @@ extern "C"
#include <machine/machine_routines.h>
}

#warning FIXME: use inb and outb from the kernel framework (2688371)
typedef unsigned short i386_ioport_t;
inline unsigned char inb(i386_ioport_t port)
{
unsigned char datum;
asm volatile("inb %1, %0" : "=a" (datum) : "d" (port));
return(datum);
}

inline void outb(i386_ioport_t port, unsigned char datum)
{
asm volatile("outb %0, %1" : : "a" (datum), "d" (port));
}

enum {
kPS2PowerStateSleep = 0,
kPS2PowerStateDoze = 1,
Expand Down Expand Up @@ -144,7 +132,7 @@ static void interruptHandlerKeyboard(OSObject *, void *, IOService *, int)

gApplePS2Controller->_interruptSourceKeyboard->interruptOccurred(0, 0, 0);

#endif DEBUGGER_SUPPORT
#endif //DEBUGGER_SUPPORT
}

// =============================================================================
Expand Down Expand Up @@ -198,7 +186,7 @@ bool ApplePS2Controller::init(OSDictionary * properties)

_controllerLock = IOSimpleLockAlloc();
if (!_controllerLock) return false;
#endif DEBUGGER_SUPPORT
#endif //DEBUGGER_SUPPORT

return true;
}
Expand Down Expand Up @@ -238,7 +226,7 @@ bool ApplePS2Controller::start(IOService * provider)
for (int index = 0; index < kKeyboardQueueSize; index++)
queue_enter(&_keyboardQueueUnused, &_keyboardQueueAlloc[index],
KeyboardQueueElement *, chain);
#endif DEBUGGER_SUPPORT
#endif //DEBUGGER_SUPPORT

if (provider->getProperty("newIRQLayout")) { // turbo
IOLog("Using new IRQ layout 0,1\n");
Expand Down Expand Up @@ -455,7 +443,7 @@ void ApplePS2Controller::stop(IOService * provider)
// Free the keyboard queue allocation space (after disabling interrupt).
if (_keyboardQueueAlloc)
IOFree(_keyboardQueueAlloc,kKeyboardQueueSize*sizeof(KeyboardQueueElement));
#endif DEBUGGER_SUPPORT
#endif //DEBUGGER_SUPPORT

gApplePS2Controller = 0;

Expand Down Expand Up @@ -602,6 +590,9 @@ bool ApplePS2Controller::submitRequest(PS2Request * request)

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

//TODO: rehabman. IOSyncer is deprecated.
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"

void ApplePS2Controller::submitRequestAndBlock(PS2Request * request)
{
//
Expand Down Expand Up @@ -638,6 +629,8 @@ void ApplePS2Controller::submitRequestAndBlock(PS2Request * request)
}
}

#pragma GCC diagnostic warning "-Wdeprecated-declarations"

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

void ApplePS2Controller::submitRequestAndBlockCompletion(void *, void * param)
Expand Down Expand Up @@ -708,7 +701,7 @@ void ApplePS2Controller::interruptOccurred(IOInterruptEventSource *, int)
dispatchDriverInterrupt((status&kMouseData)?kDT_Mouse:kDT_Keyboard,
inb(kDataPort));
}
#endif DEBUGGER_SUPPORT
#endif //DEBUGGER_SUPPORT
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Expand Down Expand Up @@ -905,7 +898,7 @@ UInt8 ApplePS2Controller::readDataPort(PS2DeviceType deviceType)
unlockController(state);
return readByte;
}
#endif DEBUGGER_SUPPORT
#endif //DEBUGGER_SUPPORT

//
// Wait for the controller's output buffer to become ready.
Expand All @@ -925,7 +918,7 @@ UInt8 ApplePS2Controller::readDataPort(PS2DeviceType deviceType)
{
#if DEBUGGER_SUPPORT
unlockController(state); // (release interrupt lockout + access to queue)
#endif DEBUGGER_SUPPORT
#endif //DEBUGGER_SUPPORT

if (!_suppressTimeout)
IOLog("%s: Timed out on %s input stream.\n", getName(),
Expand All @@ -950,7 +943,7 @@ UInt8 ApplePS2Controller::readDataPort(PS2DeviceType deviceType)

#if DEBUGGER_SUPPORT
unlockController(state); // (release interrupt lockout + access to queue)
#endif DEBUGGER_SUPPORT
#endif //DEBUGGER_SUPPORT

if (_suppressTimeout) // startup mode w/o interrupts
return readByte;
Expand Down Expand Up @@ -1027,7 +1020,7 @@ UInt8 ApplePS2Controller::readDataPort(PS2DeviceType deviceType,
requestedStream = true;
goto skipForwardToY;
}
#endif DEBUGGER_SUPPORT
#endif //DEBUGGER_SUPPORT

//
// Wait for the controller's output buffer to become ready.
Expand All @@ -1049,7 +1042,7 @@ UInt8 ApplePS2Controller::readDataPort(PS2DeviceType deviceType,
{
#if DEBUGGER_SUPPORT
unlockController(state); // (release interrupt lockout + access to queue)
#endif DEBUGGER_SUPPORT
#endif //DEBUGGER_SUPPORT

if (firstByteHeld) return firstByte;

Expand Down Expand Up @@ -1086,7 +1079,7 @@ UInt8 ApplePS2Controller::readDataPort(PS2DeviceType deviceType,
#if DEBUGGER_SUPPORT
skipForwardToY:
unlockController(state); // (release interrupt lockout + access to queue)
#endif DEBUGGER_SUPPORT
#endif //DEBUGGER_SUPPORT

if (requestedStream)
{
Expand Down Expand Up @@ -1358,7 +1351,7 @@ void ApplePS2Controller::lockController(int * state)
*state = IOSimpleLockLockDisableInterrupt(_controllerLock);
}

#endif DEBUGGER_SUPPORT
#endif //DEBUGGER_SUPPORT

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
//
Expand Down Expand Up @@ -1505,7 +1498,7 @@ void ApplePS2Controller::setPowerStateGated( UInt32 powerState )
break;

default:
IOLog("%s: bad power state %ld\n", getName(), powerState);
IOLog("%s: bad power state %ld\n", getName(), (long)powerState);
break;
}

Expand Down
6 changes: 3 additions & 3 deletions VoodooPS2Controller/VoodooPS2Controller.h
Expand Up @@ -149,7 +149,7 @@ struct KeyboardQueueElement
queue_chain_t chain;
UInt8 data;
};
#endif DEBUGGER_SUPPORT
#endif //DEBUGGER_SUPPORT

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// ApplePS2Controller Class Declaration
Expand All @@ -173,7 +173,7 @@ class ApplePS2Controller : public IOService
bool doEscape(UInt8 key);
bool dequeueKeyboardData(UInt8 * key);
void enqueueKeyboardData(UInt8 key);
#endif DEBUGGER_SUPPORT
#endif //DEBUGGER_SUPPORT

private:
IOWorkLoop * _workLoop;
Expand Down Expand Up @@ -206,7 +206,7 @@ class ApplePS2Controller : public IOService

bool _extendedState;
UInt16 _modifierState;
#endif DEBUGGER_SUPPORT
#endif //DEBUGGER_SUPPORT

thread_call_t _powerChangeThreadCall;
UInt32 _currentPowerState;
Expand Down
Binary file modified VoodooPS2Controller/en.lproj/InfoPlist.strings
Binary file not shown.
Binary file removed VoodooPS2Keyboard/.VoodooPS2Keyboard.cpp.swp
Binary file not shown.
4 changes: 4 additions & 0 deletions VoodooPS2Keyboard/VoodooPS2Keyboard-Prefix.pch
@@ -0,0 +1,4 @@
//
// Prefix header for all source files of the 'VoodooPS2Keyboard' target in the 'VoodooPS2Keyboard' project
//

24 changes: 20 additions & 4 deletions VoodooPS2Keyboard/VoodooPS2Keyboard.cpp
Expand Up @@ -46,7 +46,7 @@ UInt32 ApplePS2Keyboard::deviceType() {
OSNumber *xml_handlerID;
UInt32 ret_id;

if ( xml_handlerID = OSDynamicCast( OSNumber, getProperty("alt_handler_id")) )
if ( (xml_handlerID = OSDynamicCast( OSNumber, getProperty("alt_handler_id"))) )
ret_id = xml_handlerID->unsigned32BitValue();
else
ret_id = APPLEPS2KEYBOARD_DEVICE_TYPE;
Expand Down Expand Up @@ -922,19 +922,33 @@ void ApplePS2Keyboard::setDevicePowerState( UInt32 whatToDo )
//
// Disable keyboard.
//

setKeyboardEnable( false );

//rehabman: Work around for auto repeat keyboard sometimes after
// wakeup from sleep
// see: http://www.mydellmini.com/forum/general-mac-os-x-discussion/3553-fixed-zero-key-stack-after-wake-up.html
// remove interrupt handler
setCommandByte(kCB_DisableKeyboardClock, kCB_EnableKeyboardIRQ);
if (_interruptHandlerInstalled)
{
_device->uninstallInterruptAction();
_interruptHandlerInstalled = false;
}
break;

case kPS2C_EnableDevice:
//rehabman: Work around for auto repeat of keyboard sometimes after
// wakeup from sleep
// re-install interrupt handler
_device->installInterruptAction(this,
/*(PS2InterruptAction)&ApplePS2Keyboard::interruptOccurred*/
OSMemberFunctionCast(PS2InterruptAction, this, &ApplePS2Keyboard::interruptOccurred));
_interruptHandlerInstalled = true;

//
// Enable keyboard and restore state.
//

initKeyboard();

break;
}
}
Expand Down Expand Up @@ -980,3 +994,5 @@ void ApplePS2Keyboard::initKeyboard()

setKeyboardEnable(true);
}


Binary file modified VoodooPS2Keyboard/en.lproj/InfoPlist.strings
Binary file not shown.
4 changes: 4 additions & 0 deletions VoodooPS2Mouse/VoodooPS2Mouse-Prefix.pch
@@ -0,0 +1,4 @@
//
// Prefix header for all source files of the 'VoodooPS2Mouse' target in the 'VoodooPS2Mouse' project
//

6 changes: 3 additions & 3 deletions VoodooPS2Mouse/VoodooPS2Mouse.cpp
Expand Up @@ -62,11 +62,11 @@ bool ApplePS2Mouse::init(OSDictionary * properties)
_buttonCount = 3;
_mouseInfoBytes = (UInt32)-1;

if (num=OSDynamicCast (OSNumber, properties->getObject ("DefaultResolution")))
if ((num=OSDynamicCast (OSNumber, properties->getObject ("DefaultResolution"))))
defres = num->unsigned32BitValue();
if (bl=OSDynamicCast (OSBoolean, properties->getObject ("ForceDefaultResolution")))
if ((bl=OSDynamicCast (OSBoolean, properties->getObject ("ForceDefaultResolution"))))
forceres=bl->isTrue();
if (bl=OSDynamicCast (OSBoolean, properties->getObject ("InvertY")))
if ((bl=OSDynamicCast (OSBoolean, properties->getObject ("InvertY"))))
inverty=bl->isTrue();

_resolution = defres;
Expand Down
Binary file modified VoodooPS2Mouse/en.lproj/InfoPlist.strings
Binary file not shown.

0 comments on commit b33b10c

Please sign in to comment.