1 /* 2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved. 3 * 4 * @APPLE_LICENSE_HEADER_START@ 5 * 6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. 7 * 8 * This file contains Original Code and/or Modifications of Original Code 9 * as defined in and that are subject to the Apple Public Source License 10 * Version 2.0 (the 'License'). You may not use this file except in 11 * compliance with the License. Please obtain a copy of the License at 12 * http://www.opensource.apple.com/apsl/ and read it before using this 13 * file. 14 * 15 * The Original Code and all software distributed under the License are 16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 20 * Please see the License for the specific language governing rights and 21 * limitations under the License. 22 * 23 * @APPLE_LICENSE_HEADER_END@ 24 */ 25 /* 26 Copyright (c) 1998 Apple Computer, Inc. All rights reserved. 27 28 HISTORY 29 1998-7-13 Godfrey van der Linden(gvdl) 30 Created. 31 ]*/ 32 #include <IOKit/IOLib.h> 33 34 #include <IOKit/IOEventSource.h> 35 #include <IOKit/IOWorkLoop.h> 36 37 #define super OSObject 38 39 OSDefineMetaClassAndAbstractStructors(IOEventSource, OSObject) 40 OSMetaClassDefineReservedUnused(IOEventSource, 0); 41 OSMetaClassDefineReservedUnused(IOEventSource, 1); 42 OSMetaClassDefineReservedUnused(IOEventSource, 2); 43 OSMetaClassDefineReservedUnused(IOEventSource, 3); 44 OSMetaClassDefineReservedUnused(IOEventSource, 4); 45 OSMetaClassDefineReservedUnused(IOEventSource, 5); 46 OSMetaClassDefineReservedUnused(IOEventSource, 6); 47 OSMetaClassDefineReservedUnused(IOEventSource, 7); 48 49 /* inline function implementations */ 50 void IOEventSource::signalWorkAvailable() { workLoop->signalWorkAvailable(); } 51 void IOEventSource::openGate() { workLoop->openGate(); } 52 void IOEventSource::closeGate() { workLoop->closeGate(); } 53 bool IOEventSource::tryCloseGate() { return workLoop->tryCloseGate(); } 54 int IOEventSource::sleepGate(void *event, UInt32 type) 55 { return workLoop->sleepGate(event, type); } 56 void IOEventSource::wakeupGate(void *event, bool oneThread) 57 { workLoop->wakeupGate(event, oneThread); } 58 59 bool IOEventSource::init(OSObject *inOwner, 60 Action inAction) 61 { 62 if (!inOwner) 63 return false; 64 65 owner = inOwner; 66 67 if ( !super::init() ) 68 return false; 69 70 (void) setAction(inAction); 71 enabled = true; 72 73 return true; 74 } 75 76 IOEventSource::Action IOEventSource::getAction () const { return action; }; 77 78 void IOEventSource::setAction(Action inAction) 79 { 80 action = inAction; 81 } 82 83 IOEventSource *IOEventSource::getNext() const { return eventChainNext; }; 84 85 void IOEventSource::setNext(IOEventSource *inNext) 86 { 87 eventChainNext = inNext; 88 } 89 90 void IOEventSource::enable() 91 { 92 enabled = true; 93 if (workLoop) 94 return signalWorkAvailable(); 95 } 96 97 void IOEventSource::disable() 98 { 99 enabled = false; 100 } 101 102 bool IOEventSource::isEnabled() const 103 { 104 return enabled; 105 } 106 107 void IOEventSource::setWorkLoop(IOWorkLoop *inWorkLoop) 108 { 109 if ( !inWorkLoop ) 110 disable(); 111 workLoop = inWorkLoop; 112 } 113 114 IOWorkLoop *IOEventSource::getWorkLoop() const 115 { 116 return workLoop; 117 } 118 119 bool IOEventSource::onThread() const 120 { 121 return (workLoop != 0) && workLoop->onThread(); 122 } 123