1/* 2 * Copyright (c) 1998-2000 Apple Computer, 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/* 29Copyright (c) 1998 Apple Computer, Inc. All rights reserved. 30 31HISTORY 32 1998-7-13 Godfrey van der Linden(gvdl) 33 Created. 34]*/ 35#include <IOKit/IOLib.h> 36 37#include <IOKit/IOEventSource.h> 38#include <IOKit/IOWorkLoop.h> 39 40#define super OSObject 41 42OSDefineMetaClassAndAbstractStructors(IOEventSource, OSObject) 43OSMetaClassDefineReservedUnused(IOEventSource, 0); 44OSMetaClassDefineReservedUnused(IOEventSource, 1); 45OSMetaClassDefineReservedUnused(IOEventSource, 2); 46OSMetaClassDefineReservedUnused(IOEventSource, 3); 47OSMetaClassDefineReservedUnused(IOEventSource, 4); 48OSMetaClassDefineReservedUnused(IOEventSource, 5); 49OSMetaClassDefineReservedUnused(IOEventSource, 6); 50OSMetaClassDefineReservedUnused(IOEventSource, 7); 51 52/* inline function implementations */ 53void IOEventSource::signalWorkAvailable() { workLoop->signalWorkAvailable(); } 54void IOEventSource::openGate() { workLoop->openGate(); } 55void IOEventSource::closeGate() { workLoop->closeGate(); } 56bool IOEventSource::tryCloseGate() { return workLoop->tryCloseGate(); } 57int IOEventSource::sleepGate(void *event, UInt32 type) 58 { return workLoop->sleepGate(event, type); } 59void IOEventSource::wakeupGate(void *event, bool oneThread) 60 { workLoop->wakeupGate(event, oneThread); } 61 62bool IOEventSource::init(OSObject *inOwner, 63 Action inAction) 64{ 65 if (!inOwner) 66 return false; 67 68 owner = inOwner; 69 70 if ( !super::init() ) 71 return false; 72 73 (void) setAction(inAction); 74 enabled = true; 75 76 return true; 77} 78 79IOEventSource::Action IOEventSource::getAction () const { return action; }; 80 81void IOEventSource::setAction(Action inAction) 82{ 83 action = inAction; 84} 85 86IOEventSource *IOEventSource::getNext() const { return eventChainNext; }; 87 88void IOEventSource::setNext(IOEventSource *inNext) 89{ 90 eventChainNext = inNext; 91} 92 93void IOEventSource::enable() 94{ 95 enabled = true; 96 if (workLoop) 97 return signalWorkAvailable(); 98} 99 100void IOEventSource::disable() 101{ 102 enabled = false; 103} 104 105bool IOEventSource::isEnabled() const 106{ 107 return enabled; 108} 109 110void IOEventSource::setWorkLoop(IOWorkLoop *inWorkLoop) 111{ 112 if ( !inWorkLoop ) 113 disable(); 114 workLoop = inWorkLoop; 115} 116 117IOWorkLoop *IOEventSource::getWorkLoop() const 118{ 119 return workLoop; 120} 121 122bool IOEventSource::onThread() const 123{ 124 return (workLoop != 0) && workLoop->onThread(); 125} 126