Annotation of XNU/iokit/Families/IOFireWire/IOFWIsochPort.cpp, revision 1.1.1.1

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: /*
                     23:  * Copyright (c) 1999 Apple Computer, Inc.  All rights reserved.
                     24:  *
                     25:  * IOFWIsochPort is an abstract object that represents hardware on the bus
                     26:  * (locally or remotely) that sends or receives isochronous packets.
                     27:  * Local ports are implemented by the local device driver,
                     28:  * Remote ports are implemented by the driver for the remote device.
                     29:  *
                     30:  * HISTORY
                     31:  *
                     32:  */
                     33: #include <IOKit/firewire/IOFWIsochPort.h>
                     34: #include <IOKit/firewire/IOFWLocalIsochPort.h>
                     35: #include <IOKit/firewire/IOFWDCLProgram.h>
                     36: #include <IOKit/firewire/IOFWCommand.h>
                     37: 
                     38: /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
                     39: // Commands to control isoch bus hardware
                     40: 
                     41: class IOFWAllocIsoHWCommand : public IOFWBusCommand
                     42: {
                     43:     OSDeclareDefaultStructors(IOFWAllocIsoHWCommand)
                     44: 
                     45: protected:
                     46:     IODCLProgram *     fProgram;
                     47:     IOFWSpeed          fSpeed;
                     48:     UInt32             fChan;
                     49: 
                     50: public:
                     51:     virtual IOReturn   execute();
                     52:     virtual bool       init(IODCLProgram *program, IOFireWireController *control,
                     53:                                IOFWSpeed speed, UInt32 chan,
                     54:                                FWBusCallback completion=NULL, void *refcon=NULL);
                     55: };
                     56: 
                     57: OSDefineMetaClassAndStructors(IOFWAllocIsoHWCommand, IOFWBusCommand)
                     58: 
                     59: bool IOFWAllocIsoHWCommand::init(IODCLProgram *program,
                     60:                                IOFireWireController *control,
                     61:                                IOFWSpeed speed, UInt32 chan,
                     62:                                FWBusCallback completion, void *refcon)
                     63: {
                     64:     if(!IOFWBusCommand::initWithController(control, completion, refcon))
                     65:        return false;
                     66:     fProgram = program;
                     67:     fSpeed = speed;
                     68:     fChan = chan;
                     69:     return true;
                     70: }
                     71: 
                     72: IOReturn IOFWAllocIsoHWCommand::execute()
                     73: {
                     74:     return complete(fProgram->allocateHW(fSpeed, fChan));
                     75: }
                     76: 
                     77: /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
                     78: 
                     79: class IOFWReleaseIsoHWCommand : public IOFWBusCommand
                     80: {
                     81:     OSDeclareDefaultStructors(IOFWReleaseIsoHWCommand)
                     82: 
                     83: protected:
                     84:     IODCLProgram *     fProgram;
                     85: 
                     86: public:
                     87:     virtual IOReturn   execute();
                     88:     virtual bool       init(IODCLProgram *program, IOFireWireController *control,
                     89:                                FWBusCallback completion=NULL, void *refcon=NULL);
                     90: };
                     91: 
                     92: OSDefineMetaClassAndStructors(IOFWReleaseIsoHWCommand, IOFWBusCommand)
                     93: 
                     94: bool IOFWReleaseIsoHWCommand::init(IODCLProgram *program,
                     95:                                IOFireWireController *control,
                     96:                                FWBusCallback completion, void *refcon)
                     97: {
                     98:     if(!IOFWBusCommand::initWithController(control, completion, refcon))
                     99:        return false;
                    100:     fProgram = program;
                    101:     return true;
                    102: }
                    103: 
                    104: IOReturn IOFWReleaseIsoHWCommand::execute()
                    105: {
                    106:     return complete(fProgram->releaseHW());
                    107: }
                    108: 
                    109: 
                    110: /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
                    111: 
                    112: class IOFWStartIsoHWCommand : public IOFWBusCommand
                    113: {
                    114:     OSDeclareDefaultStructors(IOFWStartIsoHWCommand)
                    115: 
                    116: protected:
                    117:     IODCLProgram *     fProgram;
                    118: 
                    119: public:
                    120:     virtual IOReturn   execute();
                    121:     virtual bool       init(IODCLProgram *program, IOFireWireController *control,
                    122:                                FWBusCallback completion=NULL, void *refcon=NULL);
                    123: };
                    124: 
                    125: OSDefineMetaClassAndStructors(IOFWStartIsoHWCommand, IOFWBusCommand)
                    126: 
                    127: bool IOFWStartIsoHWCommand::init(IODCLProgram *program,
                    128:                                IOFireWireController *control,
                    129:                                FWBusCallback completion, void *refcon)
                    130: {
                    131:     if(!IOFWBusCommand::initWithController(control, completion, refcon))
                    132:        return false;
                    133:     fProgram = program;
                    134:     return true;
                    135: }
                    136: 
                    137: IOReturn IOFWStartIsoHWCommand::execute()
                    138: {
                    139:     return complete(fProgram->start());
                    140: }
                    141: 
                    142: 
                    143: /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
                    144: class IOFWStopIsoHWCommand : public IOFWBusCommand
                    145: {
                    146:     OSDeclareDefaultStructors(IOFWStopIsoHWCommand)
                    147: 
                    148: protected:
                    149:     IODCLProgram *     fProgram;
                    150: 
                    151: public:
                    152:     virtual IOReturn   execute();
                    153:     virtual bool       init(IODCLProgram *program, IOFireWireController *control,
                    154:                                FWBusCallback completion=NULL, void *refcon=NULL);
                    155: };
                    156: 
                    157: OSDefineMetaClassAndStructors(IOFWStopIsoHWCommand, IOFWBusCommand)
                    158: 
                    159: bool IOFWStopIsoHWCommand::init(IODCLProgram *program,
                    160:                                IOFireWireController *control,
                    161:                                FWBusCallback completion, void *refcon)
                    162: {
                    163:     if(!IOFWBusCommand::initWithController(control, completion, refcon))
                    164:        return false;
                    165:     fProgram = program;
                    166:     return true;
                    167: }
                    168: 
                    169: IOReturn IOFWStopIsoHWCommand::execute()
                    170: {
                    171:     fProgram->stop();
                    172:     return complete(kIOReturnSuccess);
                    173: }
                    174: 
                    175: 
                    176: /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
                    177: /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
                    178: OSDefineMetaClass( IOFWIsochPort, OSObject )
                    179: OSDefineAbstractStructors(IOFWIsochPort, OSObject)
                    180: 
                    181: /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
                    182: OSDefineMetaClassAndStructors(IOFWLocalIsochPort, IOFWIsochPort)
                    183: 
                    184: bool IOFWLocalIsochPort::init(IODCLProgram *program, IOFireWireController *control)
                    185: {
                    186:     if(!IOFWIsochPort::init())
                    187:        return false;
                    188:     fProgram = program; // belongs to us.
                    189:     fControl = control;
                    190:     return true;
                    191: }
                    192: 
                    193: void IOFWLocalIsochPort::free()
                    194: {
                    195:     if(fProgram)
                    196:        fProgram->release();
                    197:     IOFWIsochPort::free();
                    198: }
                    199: 
                    200: // Return maximum speed and channels supported
                    201: // (bit n set = chan n supported)
                    202: IOReturn IOFWLocalIsochPort::getSupported(IOFWSpeed &maxSpeed, UInt64 &chanSupported)
                    203: {
                    204:     maxSpeed = kFWSpeedMaximum;
                    205:     chanSupported = ~(UInt64)0;
                    206:     return kIOReturnSuccess;
                    207: }
                    208: 
                    209: /*
                    210:  * Allocate hardware resources for port, via workloop
                    211:  * Then compile program, not on workloop.
                    212:  */
                    213: IOReturn IOFWLocalIsochPort::allocatePort(IOFWSpeed speed, UInt32 chan)
                    214: {
                    215:     IOReturn res;
                    216:     IOFWAllocIsoHWCommand *allocHW;
                    217: 
                    218:     allocHW = new IOFWAllocIsoHWCommand();
                    219:     if(NULL == allocHW)
                    220:        return kIOReturnNoMemory;
                    221:     if(!allocHW->init(fProgram, fControl, speed, chan)) {
                    222:        allocHW->release();
                    223:        return kIOReturnNoMemory;
                    224:     }
                    225:     allocHW->submit();
                    226: 
                    227:     res = allocHW->fStatus;
                    228:     allocHW->release();
                    229: 
                    230:     if(kIOReturnSuccess != res)
                    231:        return res; 
                    232:     return fProgram->compile(speed, chan);     // Not on workloop
                    233: }
                    234: 
                    235: IOReturn IOFWLocalIsochPort::releasePort()
                    236: {
                    237:     IOFWReleaseIsoHWCommand *releaseHW;
                    238:     IOReturn res;
                    239: 
                    240:     releaseHW = new IOFWReleaseIsoHWCommand();
                    241:     if(NULL == releaseHW)
                    242:        return kIOReturnNoMemory;
                    243:     if(!releaseHW->init(fProgram, fControl)) {
                    244:         releaseHW->release();
                    245:        return kIOReturnNoMemory;
                    246:     }
                    247:     releaseHW->submit();
                    248: 
                    249:     res = releaseHW->fStatus;
                    250:     releaseHW->release();
                    251:     return res;
                    252: }
                    253: 
                    254: IOReturn IOFWLocalIsochPort::start()
                    255: {
                    256:     IOFWStartIsoHWCommand *startHW;
                    257:     IOReturn res;
                    258: 
                    259:     startHW = new IOFWStartIsoHWCommand();
                    260:     if(NULL == startHW)
                    261:        return kIOReturnNoMemory;
                    262:     if(!startHW->init(fProgram, fControl)) {
                    263:         startHW->release();
                    264:        return kIOReturnNoMemory;
                    265:     }
                    266:     startHW->submit();
                    267: 
                    268:     res = startHW->fStatus;
                    269:     startHW->release();
                    270:     return res;
                    271: }
                    272: 
                    273: IOReturn IOFWLocalIsochPort::stop()
                    274: {
                    275:     IOFWStopIsoHWCommand *stopHW;
                    276:     IOReturn res;
                    277: 
                    278:     stopHW = new IOFWStopIsoHWCommand();
                    279:     if(NULL == stopHW)
                    280:        return kIOReturnNoMemory;
                    281:     if(!stopHW->init(fProgram, fControl)) {
                    282:         stopHW->release();
                    283:        return kIOReturnNoMemory;
                    284:     }
                    285:     stopHW->submit();
                    286: 
                    287:     res = stopHW->fStatus;
                    288:     stopHW->release();
                    289:     return res;
                    290: }
                    291: 
                    292: 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.