Annotation of driverkit/libDriver/pcmcia/IOPCMCIADeviceDescription.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: /*
                     25:  * Copyright (c) 1993 NeXT Computer, Inc.
                     26:  *
                     27:  * PCMCIA device description class.
                     28:  *
                     29:  * HISTORY
                     30:  *
                     31:  * 10 August 1994 Curtis Galloway at NeXT
                     32:  *     Created.
                     33:  */
                     34:  
                     35: #define KERNEL_PRIVATE 1
                     36: 
                     37: #import <driverkit/KernDeviceDescription.h>
                     38: #import <driverkit/i386/IOPCMCIADeviceDescription.h>
                     39: #import <driverkit/i386/IOPCMCIADeviceDescriptionPrivate.h>
                     40: #import <driverkit/IODeviceDescriptionPrivate.h>
                     41: #import <driverkit/i386/IOEISADeviceDescriptionPrivate.h>
                     42: #import <driverkit/i386/directDevice.h>
                     43: #import <driverkit/i386/IOPCMCIATuple.h>
                     44: #import <driverkit/i386/IOPCMCIATuplePrivate.h>
                     45: #import <driverkit/i386/PCMCIAKernBus.h>
                     46: 
                     47: struct _pcmcia_private {
                     48:     unsigned   tupleCount;
                     49:     id         *tupleList;
                     50: };
                     51: 
                     52: @implementation IOPCMCIADeviceDescription(Private)
                     53: 
                     54: - _initWithDelegate: delegate
                     55: {
                     56:     struct _pcmcia_private *private;
                     57: 
                     58:     [super _initWithDelegate:delegate];
                     59:     private = _pcmcia_private = 
                     60:        (struct _pcmcia_private *)IOMalloc(sizeof(struct _pcmcia_private));
                     61:     private->tupleCount = 0;
                     62:     private->tupleList = NULL;
                     63:     return self;       
                     64: }
                     65: 
                     66: @end
                     67: 
                     68: @implementation IOPCMCIADeviceDescription
                     69: 
                     70: - free
                     71: {
                     72:     struct _pcmcia_private *private =
                     73:        (struct _pcmcia_private *)_pcmcia_private;
                     74: 
                     75:     if         (private->tupleList) {
                     76:        int i;
                     77:        for (i=0; i < private->tupleCount; i++) {
                     78:            [private->tupleList[i] free];
                     79:        }
                     80:        IOFree(private->tupleList, private->tupleCount * sizeof(id));
                     81:     }
                     82:     IOFree(private, sizeof(struct _pcmcia_private));
                     83:     return [super free];
                     84: }
                     85: 
                     86: - (unsigned) numTuples
                     87: {
                     88:     struct _pcmcia_private *private =
                     89:        (struct _pcmcia_private *)_pcmcia_private;
                     90: 
                     91:     if (private->tupleCount == 0) {
                     92:        (void)[self tupleList];
                     93:     }
                     94:     return private->tupleCount;
                     95: }
                     96: 
                     97: - (id *) tupleList
                     98: {
                     99:     struct _pcmcia_private *private = 
                    100:        (struct _pcmcia_private *)_pcmcia_private;
                    101:     id         list;
                    102:     int i;
                    103: 
                    104:     if (private->tupleList == NULL) {
                    105:        list = [[self _delegate] resourcesForKey:PCMCIA_TUPLE_LIST];
                    106:        if (list) {
                    107:            private->tupleCount = [list count];
                    108:            private->tupleList = 
                    109:                (id *)IOMalloc(private->tupleCount * sizeof(id));
                    110:            for (i=0; i<private->tupleCount; i++) {
                    111:                id ioTuple, tuple;
                    112: 
                    113:                tuple = [list objectAt:i];
                    114:                ioTuple = [[IOPCMCIATuple alloc] initWithKernTuple:tuple];
                    115:                private->tupleList[i] = ioTuple;
                    116:            }
                    117:        }
                    118:     }
                    119:     return private->tupleList;
                    120: }
                    121: 
                    122: @end

unix.superglobalmegacorp.com

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