Annotation of driverkit/libDriver/Kernel/kernelDiskMethods.m, revision 1.1.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) 1991 NeXT Computer, Inc.  All rights reserved. 
                     25:  *
                     26:  * kernelDiskMethods.m - Kernel devsw glue for DiskObject class.
                     27:  *
                     28:  * HISTORY
                     29:  * 02-May-91    Doug Mitchell at NeXT
                     30:  *      Created. 
                     31:  */
                     32: 
                     33: /*
                     34:  * HACK ALERT
                     35:  * avoid including the code in signal.h to avoid the multiple definition of
                     36:  * __quad_word.
                     37:  */
                     38: #define _MACHINE_SIGNAL_ 1
                     39: 
                     40: #import <driverkit/return.h>
                     41: #import <driverkit/IODisk.h>
                     42: #import <driverkit/kernelDiskMethods.h>
                     43: #import <bsd/sys/buf.h>
                     44: #import <bsd/sys/errno.h>
                     45: #import <kern/assert.h>
                     46: #import <kernserv/prototypes.h>
                     47: #import <driverkit/generalFuncs.h>
                     48: 
                     49: 
                     50: #ifdef ppc //bknight - 12/3/97 - Radar #2004660
                     51: #define GROK_APPLE 1
                     52: #endif //bknight - 12/3/97 - Radar #2004660
                     53: 
                     54: 
                     55: @implementation IODisk(kernelDiskMethods)
                     56: 
                     57: /*
                     58:  * Async I/O complete function. Supercedes ioComplete method in 
                     59:  * libDriver/User/IODeviceDispatch.m. The void * argument is actually 
                     60:  * a struct buf *, but the rest of the code in DiskObject doesn't 
                     61:  * need to know that.
                     62:  */
                     63: - (void)completeTransfer               : (void *)iobuf 
                     64:                             withStatus : (IOReturn)status
                     65:                           actualLength : (unsigned)actualLength
                     66: {
                     67:        struct buf *bp = iobuf;
                     68:        
                     69:        if(status != IO_R_SUCCESS) {
                     70:                bp->b_flags |= B_ERROR;
                     71:        }
                     72:        bp->b_error = [self errnoFromReturn:status];
                     73:        bp->b_resid = bp->b_bcount - actualLength;
                     74:        biodone(bp);
                     75: }
                     76: 
                     77: 
                     78: /*
                     79:  * Get/set idMap pointer.
                     80:  */
                     81: - (IODevAndIdInfo *)devAndIdInfo
                     82: {
                     83:        return(_devAndIdInfo);
                     84: }
                     85: 
                     86: - (void)setDevAndIdInfo : (IODevAndIdInfo *)devAndIdInfo
                     87: {
                     88:        _devAndIdInfo = devAndIdInfo;
                     89: }
                     90: 
                     91: /*
                     92:  * Obtain dev_t associated with this instance. This does not take into 
                     93:  * account partitions, since they are a IODiskPartition construct.
                     94:  */
                     95: - (dev_t)blockDev
                     96: {
                     97:        return _devAndIdInfo->blockDev;
                     98: }
                     99: 
                    100: - (dev_t)rawDev
                    101: {
                    102:        return _devAndIdInfo->rawDev;
                    103: }
                    104: 
                    105: @end
                    106: 
                    107: @implementation IODisk(kernelDiskMethodsPrivate)
                    108: 
                    109: /*
                    110:  * Register either a LogicalDisk or a DiskObject subclass with the owner's
                    111:  * IODevAndIdInfo array.
                    112:  */
                    113: - (void)registerUnixDisk       : (int) partition       
                    114: {
                    115: #ifdef GROK_APPLE //bknight - 12/3/97 - Radar #2004660
                    116:        if( ! ( partition < ( 2 * NPART ) ) ) {
                    117: #else GROK_APPLE //bknight - 12/3/97 - Radar #2004660
                    118:        if(partition > (NPART-2)) {
                    119: #endif GROK_APPLE //bknight - 12/3/97 - Radar #2004660
                    120:                IOLog("%s registerUnixDisk: Bogus partition (%d)\n",
                    121:                        [self name], partition);
                    122:                return;
                    123:        }
                    124:        if(_isPhysical) {
                    125:                _devAndIdInfo->liveId = self;
                    126:        }
                    127:        else {
                    128:                _devAndIdInfo->partitionId[partition] = self;
                    129:        }
                    130: }
                    131: 
                    132: /*
                    133:  * FIXME:
                    134:  * This needs some locking to prevent IO requests to nil IDs!
                    135:  */
                    136: - (void)unregisterUnixDisk     :(int) partition        
                    137: {
                    138: #ifdef GROK_APPLE //bknight - 12/3/97 - Radar #2004660
                    139:        if( ! ( partition < ( 2 * NPART ) ) ) {
                    140: #else GROK_APPLE //bknight - 12/3/97 - Radar #2004660
                    141:        if(partition > (NPART-2)) {
                    142: #endif GROK_APPLE //bknight - 12/3/97 - Radar #2004660
                    143:                IOLog("%s unregisterUnixDisk: Bogus partition (%d)\n",
                    144:                        [self name], partition);
                    145:                return;
                    146:        }
                    147:        if(_isPhysical) {
                    148:                _devAndIdInfo->liveId = nil;
                    149:        }
                    150:        else {
                    151:                _devAndIdInfo->partitionId[partition] = nil;
                    152:        }
                    153: }
                    154: 
                    155: @end
                    156: 

unix.superglobalmegacorp.com

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