Annotation of drvEIDE/EIDE.drvproj/EIDEInspector.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.0 (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 1997-1998 by Apple Computer, Inc., All rights reserved.
        !            26:  * Copyright 1994-1997 NeXT Software, Inc., All rights reserved.
        !            27:  *
        !            28:  * EIDEInspector.m
        !            29:  *
        !            30:  * Driver inspector.
        !            31:  */
        !            32: 
        !            33: #import "EIDEInspector.h"
        !            34: #import "localization.h"
        !            35: #import "IdeShared.h"
        !            36: 
        !            37: #define MYNAME         "EIDEInspector"
        !            38: #define NIB_TYPE       "nib"
        !            39: 
        !            40: #define SET_LOCAL_TITLES       1
        !            41: 
        !            42: @implementation EIDEInspector
        !            43: 
        !            44: /*
        !            45:  * Find and load our nib, put a localized title atop the connector
        !            46:  * box, and init buttons.
        !            47:  */
        !            48: - init
        !            49: {
        !            50:        char    buffer[MAXPATHLEN];
        !            51: 
        !            52:        myBundle = [NXBundle bundleForClass:[self class]];
        !            53: 
        !            54:        [super init];
        !            55: 
        !            56:        if (![myBundle getPath:buffer forResource:MYNAME ofType:NIB_TYPE]) {
        !            57:                [self free];
        !            58:                return nil;
        !            59:        }
        !            60:        if (![NXApp loadNibFile:buffer owner:self withNames:NO]) {
        !            61:                [self free];
        !            62:                return nil;
        !            63:        }
        !            64: 
        !            65:        /*
        !            66:         * Connect the target/action of the override PopUps to methods
        !            67:         * defined in this class.
        !            68:         */
        !            69:        [[popUpMasterDual target] setTarget:(id)self];
        !            70:        [[popUpSlaveDual target] setTarget:(id)self];
        !            71:        [[popUpMasterSingle target] setTarget:(id)self];
        !            72:        [[popUpSlaveSingle target] setTarget:(id)self];
        !            73:        [[popUpMasterSec target] setTarget:(id)self];
        !            74:        [[popUpSlaveSec target] setTarget:(id)self];    
        !            75: 
        !            76:        [[popUpMasterDual target] setAction:@selector(selectMasterOverride:)];
        !            77:        [[popUpSlaveDual target] setAction:@selector(selectSlaveOverride:)];
        !            78:        [[popUpMasterSingle target] setAction:@selector(selectMasterOverride:)];
        !            79:        [[popUpSlaveSingle target] setAction:@selector(selectSlaveOverride:)];  
        !            80:        [[popUpMasterSec target] setAction:@selector(selectMasterOverrideSec:)];
        !            81:        [[popUpSlaveSec target] setAction:@selector(selectSlaveOverrideSec:)];
        !            82:        
        !            83:        return self;
        !            84: }
        !            85: 
        !            86: /*
        !            87:  * Get current values of the buttons from the existing
        !            88:  * config table. If the current table has no entry for specified
        !            89:  * key, the associated button will be disabled.
        !            90:  */
        !            91: - (void)_initButton : button   key : (const char *)key
        !            92: {
        !            93:        const char *value;
        !            94:        int ival;
        !            95: 
        !            96:        value = [table valueForStringKey:key];
        !            97:        if (value == NULL) {
        !            98:                        [button setState:0];
        !            99:                        [button setEnabled:0];
        !           100:                        return;
        !           101:        }
        !           102:        else if (strcmp(value, "Yes") == 0) {
        !           103:                        ival = 1;
        !           104:        }
        !           105:        else {
        !           106:                        ival = 0;
        !           107:        }
        !           108:        [button setState:ival];
        !           109: }
        !           110: 
        !           111: /*
        !           112:  * Set the state of the DMA enable buttons from the mask value in the
        !           113:  * config table. If the key is NULL, then the button shall be disabled.
        !           114:  */
        !           115: #define DMA_FIELDS_MASK                0xffffff00
        !           116: 
        !           117: - (void)_initDMAButton:button key:(const char *)key
        !           118: {
        !           119:        const char *value;
        !           120:        unsigned int mask;
        !           121: 
        !           122:        if ((key == NULL) || ((value = [table valueForStringKey:key]) == NULL)) {
        !           123:                [button setState:0];
        !           124:                [button setEnabled:NO];
        !           125:                return;
        !           126:        }
        !           127:        
        !           128:        [button setEnabled:YES];
        !           129:        mask = strtoul(value, NULL, 16);
        !           130:        if ((mask & DMA_FIELDS_MASK) == 0)
        !           131:                [button setState:NO];
        !           132:        else
        !           133:                [button setState:YES];
        !           134: }
        !           135: 
        !           136: - (const char *)_getKeyForDMAButton:button
        !           137: {
        !           138:        char *key;
        !           139: 
        !           140:        if (button == enableDMAMaster)
        !           141:                key = MODES_MASK_MASTER;
        !           142:        else if (button == enableDMASlave)
        !           143:                key = MODES_MASK_SLAVE;
        !           144:        else if (button == enableDMAMasterPrimary)
        !           145:                key = MODES_MASK_MASTER;
        !           146:        else if (button == enableDMASlavePrimary)
        !           147:                key = MODES_MASK_SLAVE;
        !           148:        else if (button == enableDMAMasterSecondary)
        !           149:                key = MODES_MASK_MASTER_SEC;
        !           150:        else if (button == enableDMASlaveSecondary)
        !           151:                key = MODES_MASK_SLAVE_SEC;
        !           152:        else
        !           153:                key = NULL;
        !           154: 
        !           155:        return (key);
        !           156: }
        !           157: 
        !           158: - _initPopUp:popUp key:(const char *)key choices:(unsigned int)choices
        !           159: {
        !           160:        int i;
        !           161:        int overrideIndex;
        !           162:        const char *overrideString = [table valueForStringKey:key];
        !           163:        id      popUpList = [popUp target];
        !           164: 
        !           165:        // Remove all cells before populating the PopUpList
        !           166:        for (i = [popUpList count] - 1; i >= 0; i--) {
        !           167:                [popUpList removeItemAt:i];
        !           168:        }
        !           169: 
        !           170:        // Populate the PopUp
        !           171:        for (i = 0; i < choices; i++) { 
        !           172:                [popUpList addItem:OVERRIDE_STRING(overrideTable[i], myBundle)];
        !           173:                [[[popUpList itemList] cellAt:i :0] setTag:i];
        !           174:        }
        !           175: 
        !           176:        // Read the current configuration from the table
        !           177:        overrideIndex = OVERRIDE_AUTO;
        !           178:        if (overrideString) {
        !           179:                for (i = 0; i < choices; i++) {
        !           180:                        if (strcmp(overrideTable[i], overrideString) == 0) {
        !           181:                                overrideIndex = i;
        !           182:                                break;
        !           183:                        }
        !           184:                }
        !           185:                if (overrideIndex == OVERRIDE_TABLE_SIZE)
        !           186:                        overrideIndex = OVERRIDE_AUTO;
        !           187:        }
        !           188:        
        !           189:        // Make a selection
        !           190:        [[popUpList itemList] selectCellWithTag:overrideIndex];
        !           191:        [popUp setTitle:[popUpList selectedItem]];
        !           192: 
        !           193:        return self;
        !           194: }
        !           195: 
        !           196: - setTable:(NXStringTable *)instance
        !           197: {
        !           198:        char *str;
        !           199: 
        !           200:        [super setTable:instance];
        !           201:        [self setAccessoryView:boundingBox];
        !           202:        
        !           203:        /*
        !           204:         * Initialize the isBusMaster and isDualChannel variables.
        !           205:         */
        !           206:        isDMACapable = NO;
        !           207:        isDualChannel = NO;
        !           208:        
        !           209:        // Cheesy, but assume the driver supports DMA modes if the
        !           210:        // controller is PCI based.
        !           211:        str = (char *)[table valueForStringKey:BUS_TYPE];
        !           212:        if ((str != NULL) && (strcmp(str, "PCI") == 0)) {
        !           213:                isDMACapable = YES;
        !           214:        }
        !           215: 
        !           216:        // Hack to detect Dual EIDE case.
        !           217:        str = (char *)[table valueForStringKey:"Class Names"];
        !           218:        if ((str != NULL) && (strstr(str, "Dual")))
        !           219:                isDualChannel = YES;
        !           220: 
        !           221:        if (!isDMACapable) {
        !           222:                [self _initDMAButton:enableDMAMaster key:NULL];
        !           223:                [self _initDMAButton:enableDMASlave key:NULL];
        !           224:                [self _initDMAButton:enableDMAMasterPrimary key:NULL];
        !           225:                [self _initDMAButton:enableDMASlavePrimary key:NULL];
        !           226:                [self _initDMAButton:enableDMAMasterSecondary key:NULL];
        !           227:                [self _initDMAButton:enableDMASlaveSecondary key:NULL];
        !           228:        }
        !           229:        else {
        !           230:                [self _initDMAButton:enableDMAMaster
        !           231:                        key:[self _getKeyForDMAButton:enableDMAMaster]];
        !           232:                [self _initDMAButton:enableDMASlave
        !           233:                        key:[self _getKeyForDMAButton:enableDMASlave]];
        !           234:                [self _initDMAButton:enableDMAMasterPrimary
        !           235:                        key:[self _getKeyForDMAButton:enableDMAMasterPrimary]];
        !           236:                [self _initDMAButton:enableDMASlavePrimary
        !           237:                        key:[self _getKeyForDMAButton:enableDMASlavePrimary]];
        !           238:                [self _initDMAButton:enableDMAMasterSecondary 
        !           239:                        key:[self _getKeyForDMAButton:enableDMAMasterSecondary]];
        !           240:                [self _initDMAButton:enableDMASlaveSecondary 
        !           241:                        key:[self _getKeyForDMAButton:enableDMASlaveSecondary]];        
        !           242:        }
        !           243: 
        !           244:        [self _initButton:multipleSectors key:MULTIPLE_SECTORS_ENABLE];
        !           245:        [self _initPopUp:popUpMasterDual key:IDE_MASTER_KEY
        !           246:                choices:(OVERRIDE_TABLE_SIZE - 1)];
        !           247:        [self _initPopUp:popUpSlaveDual key:IDE_SLAVE_KEY
        !           248:                choices:OVERRIDE_TABLE_SIZE];
        !           249:        [self _initPopUp:popUpMasterSingle key:IDE_MASTER_KEY
        !           250:                choices:(OVERRIDE_TABLE_SIZE - 1)];
        !           251:        [self _initPopUp:popUpSlaveSingle key:IDE_SLAVE_KEY
        !           252:                choices:OVERRIDE_TABLE_SIZE];
        !           253:        [self _initPopUp:popUpMasterSec key:IDE_MASTER_KEY_SEC
        !           254:                choices:(OVERRIDE_TABLE_SIZE - 1)];
        !           255:        [self _initPopUp:popUpSlaveSec key:IDE_SLAVE_KEY_SEC
        !           256:                choices:OVERRIDE_TABLE_SIZE];
        !           257:                
        !           258: #if    SET_LOCAL_TITLES
        !           259:        [optionsBox setTitle:OPTION_BOX_STRING(myBundle)];
        !           260:        [multipleSectors setTitle:MULTIPLE_SECTORS_STRING(myBundle)];
        !           261:        [overrideButton setTitle:OPTIONS_BUTTON_STRING(myBundle)];
        !           262: 
        !           263:        [titleMasterDual setStringValue:MASTER_STRING(myBundle)];
        !           264:        [titleSlaveDual setStringValue:SLAVE_STRING(myBundle)];
        !           265:        [titleMasterSingle setStringValue:MASTER_STRING(myBundle)];
        !           266:        [titleSlaveSingle setStringValue:SLAVE_STRING(myBundle)];
        !           267:        [titleMasterSec setStringValue:MASTER_STRING(myBundle)];
        !           268:        [titleSlaveSec setStringValue:SLAVE_STRING(myBundle)];
        !           269:        
        !           270:        [boxPriDual setTitle:PRI_CHANNEL_STRING(myBundle)];
        !           271:        [boxSecDual setTitle:SEC_CHANNEL_STRING(myBundle)];
        !           272:        [boxSingle setTitle:SINGLE_CHANNEL_STRING(myBundle)];
        !           273:        [panelDualChannel setTitle:OPTIONS_BUTTON_STRING(myBundle)];
        !           274:        [panelSingleChannel setTitle:OPTIONS_BUTTON_STRING(myBundle)];
        !           275: #endif SET_LOCAL_TITLES
        !           276:        
        !           277:        return self;
        !           278: }
        !           279: 
        !           280: - selectOverrides:sender
        !           281: {
        !           282:        id panel;
        !           283:        
        !           284:        if (isDualChannel)
        !           285:                panel = panelDualChannel;
        !           286:        else
        !           287:                panel = panelSingleChannel;
        !           288: 
        !           289:     [panel center];
        !           290:     [panel makeKeyAndOrderFront:self];
        !           291:        [NXApp runModalFor:panel];
        !           292:        [panel orderOut:self];
        !           293: 
        !           294:     return self;
        !           295: }
        !           296: 
        !           297: - ok:sender
        !           298: {
        !           299:     [NXApp stopModal:1];
        !           300:     return self;
        !           301: }
        !           302: 
        !           303: - setDMAMode:sender
        !           304: {
        !           305:        const char *key = [self _getKeyForDMAButton:sender];
        !           306:        
        !           307:        if (key) {
        !           308:                char *value;
        !           309:                if ([sender state] == NO)
        !           310:                        value = "0x000000ff";
        !           311:                else
        !           312:                        value = "0xffffffff";
        !           313:                [table insertKey:key value:value];
        !           314:        }
        !           315:        return self;
        !           316: }
        !           317: 
        !           318: - multipleSectors:sender
        !           319: {
        !           320:        char *str;
        !           321: 
        !           322:        if ([sender state])
        !           323:                str = "Yes";
        !           324:        else
        !           325:                str = "No";
        !           326: 
        !           327:        [table insertKey:MULTIPLE_SECTORS_ENABLE value:str];
        !           328:        return self;
        !           329: }
        !           330: 
        !           331: - selectMasterOverride:sender
        !           332: {
        !           333:     int i = [[sender selectedCell] tag];
        !           334:     [table insertKey:IDE_MASTER_KEY value:(char *)overrideTable[i]];
        !           335:     return self;
        !           336: }
        !           337: 
        !           338: - selectSlaveOverride:sender
        !           339: {
        !           340:     int i = [[sender selectedCell] tag];
        !           341:     [table insertKey:IDE_SLAVE_KEY value:(char *)overrideTable[i]];
        !           342:     return self;
        !           343: }
        !           344: 
        !           345: - selectMasterOverrideSec:sender
        !           346: {
        !           347:     int i = [[sender selectedCell] tag];
        !           348:     [table insertKey:IDE_MASTER_KEY_SEC value:(char *)overrideTable[i]];
        !           349:     return self;
        !           350: }
        !           351: 
        !           352: - selectSlaveOverrideSec:sender
        !           353: {      
        !           354:     int i = [[sender selectedCell] tag];
        !           355:     [table insertKey:IDE_SLAVE_KEY_SEC value:(char *)overrideTable[i]];
        !           356:     return self;
        !           357: }
        !           358: 
        !           359: @end

unix.superglobalmegacorp.com

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