Annotation of driverkit/libDriver/User/IODeviceMaster.m, revision 1.1

1.1     ! root        1: /*
        !             2:  * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
        !             3:  *
        !             4:  * @APPLE_LICENSE_HEADER_START@
        !             5:  * 
        !             6:  * Portions Copyright (c) 1999 Apple Computer, Inc.  All Rights
        !             7:  * Reserved.  This file contains Original Code and/or Modifications of
        !             8:  * Original Code as defined in and that are subject to the Apple Public
        !             9:  * Source License Version 1.1 (the "License").  You may not use this file
        !            10:  * except in compliance with the License.  Please obtain a copy of the
        !            11:  * License at http://www.apple.com/publicsource and read it before using
        !            12:  * this file.
        !            13:  * 
        !            14:  * The Original Code and all software distributed under the License are
        !            15:  * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
        !            16:  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
        !            17:  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
        !            18:  * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT.  Please see the
        !            19:  * License for the specific language governing rights and limitations
        !            20:  * under the License.
        !            21:  * 
        !            22:  * @APPLE_LICENSE_HEADER_END@
        !            23:  */
        !            24: /*     Copyright (c) 1993 NeXT Computer, Inc.  All rights reserved. 
        !            25:  *
        !            26:  * IODeviceMaster.m
        !            27:  *
        !            28:  * HISTORY
        !            29:  * 13-Jan-98   Martin Minow at Apple
        !            30:  *     Added createMachPort
        !            31:  * 08-Jan-93    Doug Mitchell at NeXT
        !            32:  *      Created. 
        !            33:  */
        !            34: 
        !            35: #import <driverkit/IODeviceMaster.h>
        !            36: #import <driverkit/driverServer.h>
        !            37: #import <mach/port.h>
        !            38: 
        !            39: /*
        !            40:  * IODeviceMaster class. Used in user space only, to do Get/Set parameter
        !            41:  * type operations. 
        !            42:  */
        !            43: 
        !            44: static IODeviceMaster *thisTasksId = nil;
        !            45: 
        !            46: @implementation IODeviceMaster
        !            47: 
        !            48: /*
        !            49:  * Alloc and init (if necessary) an instance of IODeviceMaster.
        !            50:  */
        !            51: + new
        !            52: {      
        !            53:        if(thisTasksId == nil) {
        !            54:                thisTasksId = [self alloc];
        !            55:                thisTasksId->_deviceMasterPort = device_master_self();
        !            56:        }
        !            57:        return thisTasksId;
        !            58: }
        !            59: 
        !            60: /*
        !            61:  * Free an instance of IODeviceMaster. Nop; we keep the instance around.
        !            62:  */
        !            63: - free
        !            64: {
        !            65:        return self;
        !            66: }
        !            67: 
        !            68: /*
        !            69:  * Get device type and device name for specified IOObjectNumber.
        !            70:  */
        !            71: - (IOReturn)lookUpByObjectNumber       : (IOObjectNumber)objectNumber
        !            72:                             deviceKind : (IOString *)deviceKind
        !            73:                             deviceName : (IOString *)deviceName
        !            74: {
        !            75:        return _IOLookupByObjectNumber(_deviceMasterPort, 
        !            76:                objectNumber,
        !            77:                deviceKind,
        !            78:                deviceName);
        !            79: }
        !            80:                                   
        !            81: 
        !            82: /*
        !            83:  * Get IOObjectNumber and device type for specified deviceName.
        !            84:  */
        !            85: - (IOReturn)lookUpByDeviceName         : (IOString)deviceName
        !            86:                           objectNumber : (IOObjectNumber *)objectNumber
        !            87:                             deviceKind : (IOString *)deviceKind
        !            88: {
        !            89:        return _IOLookupByDeviceName(_deviceMasterPort,
        !            90:                deviceName,
        !            91:                objectNumber,
        !            92:                deviceKind);
        !            93: }
        !            94:                             
        !            95: /*
        !            96:  * Get/set parameter methods used at user level to communicate with
        !            97:  * kernel-level drivers.
        !            98:  */
        !            99: - (IOReturn)getIntValues               : (unsigned *)parameterArray
        !           100:                           forParameter : (IOParameterName)parameterName
        !           101:                           objectNumber : (IOObjectNumber)objectNumber
        !           102:                                  count : (unsigned *)count     // in/out
        !           103: {
        !           104:        return _IOGetIntValues(_deviceMasterPort,
        !           105:                objectNumber,
        !           106:                parameterName,
        !           107:                *count,
        !           108:                parameterArray,
        !           109:                count);
        !           110: }
        !           111:        
        !           112: - (IOReturn)getCharValues              : (unsigned char *)parameterArray
        !           113:                           forParameter : (IOParameterName)parameterName
        !           114:                           objectNumber : (IOObjectNumber)objectNumber
        !           115:                                  count : (unsigned *)count     // in/out
        !           116: {
        !           117:        return _IOGetCharValues(_deviceMasterPort,
        !           118:                objectNumber,
        !           119:                parameterName,
        !           120:                *count,
        !           121:                parameterArray,
        !           122:                count);
        !           123: 
        !           124: }
        !           125:        
        !           126: - (IOReturn)setIntValues               : (unsigned *)parameterArray
        !           127:                           forParameter : (IOParameterName)parameterName
        !           128:                           objectNumber : (IOObjectNumber)objectNumber
        !           129:                                  count : (unsigned)count;
        !           130: {
        !           131:        return _IOSetIntValues(_deviceMasterPort,
        !           132:                objectNumber,
        !           133:                parameterName,
        !           134:                parameterArray,
        !           135:                count);
        !           136: }
        !           137: 
        !           138: - (IOReturn)setCharValues              : (unsigned char *)parameterArray
        !           139:                           forParameter : (IOParameterName)parameterName
        !           140:                           objectNumber : (IOObjectNumber)objectNumber
        !           141:                                  count : (unsigned)count;
        !           142: {
        !           143:        return _IOSetCharValues(_deviceMasterPort,
        !           144:                objectNumber,
        !           145:                parameterName,
        !           146:                parameterArray,
        !           147:                count);
        !           148: 
        !           149: }
        !           150: 
        !           151: /*
        !           152:  * - serverConnect:taskPort: notifies an object that is a sub class of
        !           153:  * IODevice that a client task is interested in communicating with it.
        !           154:  * The IODevice superclass implements this method returning IO_R_UNSUPPORTED.
        !           155:  * If a subclass, such as the IOSCSIController class, provices direct RPC
        !           156:  * service, it will override serverConnect:taskPort: and, when called, create a
        !           157:  * port, returning IO_R_SUCCESS to IODeviceMaster, which will return send right
        !           158:  * to the non-privileged client. The client and IODevice are subsequently
        !           159:  * responsible for all port management.
        !           160:  */
        !           161: - (IOReturn) serverConnect: (port_t *)       machPort
        !           162:              objectNumber: (IOObjectNumber) objectNumber
        !           163: {
        !           164:     return _IOServerConnect(_deviceMasterPort, objectNumber,
        !           165:                           task_self(), machPort);
        !           166: }
        !           167: 
        !           168: - (IOReturn) lookUpByStringPropertyList:(const char *)values
        !           169:             results:(char *)results
        !           170:             maxLength:(unsigned int)length
        !           171: {
        !           172:     int        unused = length;
        !           173: 
        !           174:     return( _IOLookUpByStringPropertyList( _deviceMasterPort,
        !           175:             (unsigned char *) values, strlen( values) + 1,
        !           176:            (unsigned char *) results, &unused,
        !           177:            length));
        !           178: }
        !           179: 
        !           180: - (IOReturn) getStringPropertyList:(IOObjectNumber) objectNumber
        !           181:             names:(const char *)names
        !           182:             results:(char *) results
        !           183:             maxLength:(unsigned int)length
        !           184: {
        !           185:     int        unused = length;
        !           186: 
        !           187:     return( _IOGetStringPropertyList( _deviceMasterPort, objectNumber,
        !           188:             (unsigned char *) names, strlen( names) + 1,
        !           189:            (unsigned char *) results, &unused,
        !           190:            length));
        !           191: }
        !           192: 
        !           193: - (IOReturn) getByteProperty:(IOObjectNumber) objectNumber
        !           194:             name:(const char *)name
        !           195:             results:(char *) results
        !           196:             maxLength:(unsigned int *)length
        !           197: {
        !           198: 
        !           199:     return( _IOGetByteProperty( _deviceMasterPort, objectNumber,
        !           200:             (unsigned char *) name, strlen( name) + 1,
        !           201:            (unsigned char *) results, length,
        !           202:            *length));
        !           203: }
        !           204: 
        !           205: 
        !           206: @end

unix.superglobalmegacorp.com

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