|
|
1.1 ! root 1: /* ! 2: * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved. ! 3: * ! 4: * @APPLE_LICENSE_HEADER_START@ ! 5: * ! 6: * The contents of this file constitute Original Code as defined in and ! 7: * are subject to the Apple Public Source License Version 1.1 (the ! 8: * "License"). You may not use this file except in compliance with the ! 9: * License. Please obtain a copy of the License at ! 10: * http://www.apple.com/publicsource and read it before using this file. ! 11: * ! 12: * This Original Code and all software distributed under the License are ! 13: * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER ! 14: * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, ! 15: * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, ! 16: * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the ! 17: * License for the specific language governing rights and limitations ! 18: * under the License. ! 19: * ! 20: * @APPLE_LICENSE_HEADER_END@ ! 21: */ ! 22: #include <IOKit/IOCommandGate.h> ! 23: #include <IOKit/IOWorkLoop.h> ! 24: #include <IOKit/IOReturn.h> ! 25: #include <IOKit/IOTimeStamp.h> ! 26: ! 27: #define super IOEventSource ! 28: ! 29: OSDefineMetaClassAndStructors(IOCommandGate, IOEventSource) ! 30: ! 31: bool IOCommandGate::checkForWork() { return false; } ! 32: ! 33: bool IOCommandGate::init(OSObject *inOwner, Action inAction = 0) ! 34: { ! 35: return super::init(inOwner, (IOEventSource::Action) inAction); ! 36: } ! 37: ! 38: IOCommandGate * ! 39: IOCommandGate::commandGate(OSObject *inOwner, Action inAction = 0) ! 40: { ! 41: IOCommandGate *me = new IOCommandGate; ! 42: ! 43: if (me && !me->init(inOwner, inAction)) { ! 44: me->free(); ! 45: return 0; ! 46: } ! 47: ! 48: return me; ! 49: } ! 50: ! 51: IOReturn IOCommandGate::runCommand(void *arg0 = 0, void *arg1 = 0, ! 52: void *arg2 = 0, void *arg3 = 0) ! 53: { ! 54: IOReturn res; ! 55: ! 56: if (!enabled) ! 57: return kIOReturnNotPermitted; ! 58: ! 59: if (!action) ! 60: return kIOReturnNoResources; ! 61: ! 62: // closeGate is recursive so don't worry if we already hold the lock. ! 63: IOTimeStampConstant(IODBG_CMDQ(IOCMDQ_ACTION), ! 64: (unsigned int) action, (unsigned int) owner); ! 65: ! 66: workLoop->closeGate(); ! 67: res = (*(Action) action)(owner, arg0, arg1, arg2, arg3); ! 68: workLoop->openGate(); ! 69: ! 70: return res; ! 71: } ! 72: ! 73: IOReturn IOCommandGate::runAction(Action inAction, ! 74: void *arg0 = 0, void *arg1 = 0, ! 75: void *arg2 = 0, void *arg3 = 0) ! 76: { ! 77: IOReturn res; ! 78: ! 79: if (!enabled) ! 80: return kIOReturnNotPermitted; ! 81: ! 82: if (!inAction) ! 83: return kIOReturnBadArgument; ! 84: ! 85: IOTimeStampConstant(IODBG_CMDQ(IOCMDQ_ACTION), ! 86: (unsigned int) inAction, (unsigned int) owner); ! 87: ! 88: // closeGate is recursive so don't worry if we already hold the lock. ! 89: workLoop->closeGate(); ! 90: res = (*inAction)(owner, arg0, arg1, arg2, arg3); ! 91: workLoop->openGate(); ! 92: ! 93: return res; ! 94: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.