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