]> git.saurik.com Git - apple/xnu.git/blame - iokit/Kernel/IOEventSource.cpp
xnu-517.tar.gz
[apple/xnu.git] / iokit / Kernel / IOEventSource.cpp
CommitLineData
1c79356b
A
1/*
2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
43866e37 6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
1c79356b 7 *
43866e37
A
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
1c79356b
A
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
43866e37
A
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.
1c79356b
A
22 *
23 * @APPLE_LICENSE_HEADER_END@
24 */
25/*
26Copyright (c) 1998 Apple Computer, Inc. All rights reserved.
27
28HISTORY
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
39OSDefineMetaClassAndAbstractStructors(IOEventSource, OSObject)
40OSMetaClassDefineReservedUnused(IOEventSource, 0);
41OSMetaClassDefineReservedUnused(IOEventSource, 1);
42OSMetaClassDefineReservedUnused(IOEventSource, 2);
43OSMetaClassDefineReservedUnused(IOEventSource, 3);
44OSMetaClassDefineReservedUnused(IOEventSource, 4);
45OSMetaClassDefineReservedUnused(IOEventSource, 5);
46OSMetaClassDefineReservedUnused(IOEventSource, 6);
47OSMetaClassDefineReservedUnused(IOEventSource, 7);
48
9bccf70c
A
49/* inline function implementations */
50void IOEventSource::signalWorkAvailable() { workLoop->signalWorkAvailable(); }
51void IOEventSource::openGate() { workLoop->openGate(); }
52void IOEventSource::closeGate() { workLoop->closeGate(); }
53bool IOEventSource::tryCloseGate() { return workLoop->tryCloseGate(); }
54int IOEventSource::sleepGate(void *event, UInt32 type)
55 { return workLoop->sleepGate(event, type); }
56void IOEventSource::wakeupGate(void *event, bool oneThread)
57 { workLoop->wakeupGate(event, oneThread); }
58
1c79356b 59bool IOEventSource::init(OSObject *inOwner,
55e303ae 60 Action inAction)
1c79356b
A
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
76IOEventSource::Action IOEventSource::getAction () const { return action; };
77
78void IOEventSource::setAction(Action inAction)
79{
80 action = inAction;
81}
82
83IOEventSource *IOEventSource::getNext() const { return eventChainNext; };
84
85void IOEventSource::setNext(IOEventSource *inNext)
86{
87 eventChainNext = inNext;
88}
89
90void IOEventSource::enable()
91{
92 enabled = true;
93 if (workLoop)
94 return signalWorkAvailable();
95}
96
97void IOEventSource::disable()
98{
99 enabled = false;
100}
101
102bool IOEventSource::isEnabled() const
103{
104 return enabled;
105}
106
107void IOEventSource::setWorkLoop(IOWorkLoop *inWorkLoop)
108{
109 if ( !inWorkLoop )
110 disable();
111 workLoop = inWorkLoop;
112}
113
114IOWorkLoop *IOEventSource::getWorkLoop() const
115{
116 return workLoop;
117}
118
119bool IOEventSource::onThread() const
120{
121 return (workLoop != 0) && workLoop->onThread();
122}