Annotation of XNU/iokit/IOKit/firewire/IOFWAddressSpace.h, revision 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:  *
        !            24:  *     IOFWAddressSpace.h
        !            25:  *
        !            26:  * Classes which describe addresses in the local node which are accessable to other nodes
        !            27:  * via firewire asynchronous read/write/lock requests.
        !            28:  */
        !            29: #ifndef _IOKIT_IOFWADDRESSSPACE_H
        !            30: #define _IOKIT_IOFWADDRESSSPACE_H
        !            31: 
        !            32: #include <IOKit/IOMemoryDescriptor.h>
        !            33: #include <IOKit/firewire/IOFWRegs.h>
        !            34: 
        !            35: class IOFireWireDevice;
        !            36: 
        !            37: /*
        !            38:  * Callback called when a write request packet is received for
        !            39:  * a 'virtual' firewire address.
        !            40:  * device is the node originating the request
        !            41:  * addr is the address the device is requesting to write to
        !            42:  * len is the number of bytes to write
        !            43:  * buf contains the packet data
        !            44:  * lockWrite is true if the write is the write part of a lock request.
        !            45:  * return:
        !            46:        kFWResponseComplete             = 0,    // OK!
        !            47:        kFWResponseConflictError        = 4,    // Resource conflict, may retry
        !            48:        kFWResponseDataError            = 5,    // Data not available
        !            49:        kFWResponseTypeError            = 6,    // Operation not supported
        !            50:        kFWResponseAddressError         = 7     // Address not valid in target device
        !            51:  */
        !            52: typedef UInt32 (*FWWriteCallback)(void *refcon, UInt16 nodeID,
        !            53:                                FWAddress addr, UInt32 len, const void *buf, bool lockWrite);
        !            54: 
        !            55: /*
        !            56:  * Callback called when a read request packet is received for
        !            57:  * a 'virtual' firewire address.
        !            58:  * nodeID is the node originating the request
        !            59:  * addr is the address the device is requesting to write to
        !            60:  * len is the number of bytes to write
        !            61:  * buf contains the packet data
        !            62:  * lockRead is true if the read is the read part of a lock request.
        !            63:  * return:
        !            64:        kFWResponseComplete             = 0,    // OK!
        !            65:        kFWResponseConflictError        = 4,    // Resource conflict, may retry
        !            66:        kFWResponseDataError            = 5,    // Data not available
        !            67:        kFWResponseTypeError            = 6,    // Operation not supported
        !            68:        kFWResponseAddressError         = 7     // Address not valid in target device
        !            69:  *
        !            70:  */
        !            71: typedef UInt32 (*FWReadCallback)(void *refcon, UInt16 nodeID,
        !            72:                                FWAddress addr, UInt32 len, IOMemoryDescriptor **buf,
        !            73:                                IOByteCount * offset, bool lockRead);
        !            74: /*
        !            75:  * Base class for FireWire address space objects
        !            76:  */
        !            77: class IOFWAddressSpace : public OSObject
        !            78: {
        !            79:     OSDeclareAbstractStructors(IOFWAddressSpace)
        !            80: 
        !            81: public:
        !            82:     virtual UInt32 doRead(UInt16 nodeID, FWAddress addr, UInt32 len, 
        !            83:                                        IOMemoryDescriptor **buf, IOByteCount * offset,
        !            84:                                        bool lockRead) = 0;
        !            85:     virtual UInt32 doWrite(UInt16 nodeID, FWAddress addr, UInt32 len, 
        !            86:                                        const void *buf, bool lockWrite) = 0;
        !            87: };
        !            88: 
        !            89: /*
        !            90:  * Direct physical memory <-> FireWire address.
        !            91:  * Accesses to these addresses will be handled automatically by the
        !            92:  * hardware without notification.
        !            93:  *
        !            94:  * The 64 bit FireWire address of (32 bit) physical addr xxxx:xxxx is hostNode:0000:xxxx:xxxx
        !            95:  */
        !            96: class IOFWPhysicalAddressSpace : public IOFWAddressSpace
        !            97: {
        !            98:     OSDeclareDefaultStructors(IOFWPhysicalAddressSpace)
        !            99: 
        !           100: protected:
        !           101:     IOMemoryDescriptor *fMem;
        !           102:     vm_size_t          fLen;
        !           103: 
        !           104: public:
        !           105:     virtual bool initWithDesc(IOMemoryDescriptor *mem);
        !           106: 
        !           107:     virtual UInt32 doRead(UInt16 nodeID, FWAddress addr, UInt32 len, 
        !           108:                                        IOMemoryDescriptor **buf, IOByteCount * offset,
        !           109:                                        bool lockRead);
        !           110:     virtual UInt32 doWrite(UInt16 nodeID, FWAddress addr, UInt32 len, 
        !           111:                                        const void *buf, bool lockWrite);
        !           112: };
        !           113: 
        !           114: /*
        !           115:  * Pseudo firewire addresses usually represent emulated registers of some kind.
        !           116:  * Accesses to these addresses will result in the owner being notified.
        !           117:  * 
        !           118:  * Virtual addresses should not have zero as the top 16 bits of the 48 bit local address,
        !           119:  * since that may look like a physical address to hardware (eg. OHCI).
        !           120:  * if reader is NULL then reads will not be allowed.
        !           121:  * if writer is NULL then writes will not be allowed.
        !           122:  * if either is NULL then lock requests will not be allowed.
        !           123:  * refcon is passed back as the first argument of read and write callbacks.
        !           124:  */
        !           125: class IOFWPseudoAddressSpace : public IOFWAddressSpace
        !           126: {
        !           127:     OSDeclareDefaultStructors(IOFWPseudoAddressSpace)
        !           128: 
        !           129: protected:
        !           130:     IOMemoryDescriptor*        fDesc;
        !           131:     void *             fRefCon;
        !           132:     FWReadCallback     fReader;
        !           133:     FWWriteCallback    fWriter;
        !           134:     FWAddress          fBase;
        !           135:     UInt32             fLen;
        !           136: 
        !           137:     virtual void free();
        !           138:     static UInt32 simpleReader(void *refcon, UInt16 nodeID,
        !           139:                FWAddress addr, UInt32 len, IOMemoryDescriptor **buf, IOByteCount * offset,
        !           140:                bool lockRead);
        !           141:     static UInt32 simpleWriter(void *refcon, UInt16 nodeID,
        !           142:                FWAddress addr, UInt32 len, const void *buf, bool lockRead);
        !           143: 
        !           144: public:
        !           145:     static IOFWPseudoAddressSpace * readWrite(FWAddress addr, UInt32 len, 
        !           146:                FWReadCallback reader, FWWriteCallback writer, void *refcon);
        !           147: 
        !           148:     // make an address space object to handle read-only memory (eg. the local ROM)
        !           149:     // Handles everything itself
        !           150:     static IOFWPseudoAddressSpace * simpleRead(FWAddress addr, UInt32 len, const void *data);
        !           151: 
        !           152:     // make an address space object to handle r/w memory
        !           153:     // Handles everything itself
        !           154:     static IOFWPseudoAddressSpace * simpleRW(FWAddress addr, UInt32 len, void *data);
        !           155: 
        !           156:     virtual bool initAll(FWAddress addr, UInt32 len, 
        !           157:                FWReadCallback reader, FWWriteCallback writer, void *refcon);
        !           158: 
        !           159:     virtual UInt32 doRead(UInt16 nodeID, FWAddress addr, UInt32 len, 
        !           160:                                        IOMemoryDescriptor **buf, IOByteCount * offset,
        !           161:                                        bool lockRead);
        !           162:     virtual UInt32 doWrite(UInt16 nodeID, FWAddress addr, UInt32 len, 
        !           163:                                        const void *buf, bool lockWrite);
        !           164: };
        !           165: 
        !           166: #endif /* _IOKIT_IOFWADDRESSSPACE */

unix.superglobalmegacorp.com

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