|
|
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) 1992 NeXT Computer, Inc. All rights reserved. ! 25: * ! 26: * main.m - top-level module for IOStub example, Distributed Objects ! 27: * version. ! 28: * ! 29: * HISTORY ! 30: * 09-Jun-92 Doug Mitchell at NeXT ! 31: * Created. ! 32: */ ! 33: ! 34: #import "FloppyDisk.h" ! 35: #import "SCSIDisk.h" ! 36: #import "unixDiskUxpr.h" ! 37: #import <driverkit/generalFuncs.h> ! 38: #import <objc/error.h> ! 39: #import <mach/cthreads.h> ! 40: #import <mach/mach.h> ! 41: #import <driverkit/IODiskPartition.h> ! 42: ! 43: #define SCSI_UNIT_MIN 0 ! 44: #define SCSI_UNIT_MAX 1 ! 45: #define FLOPPY_UNIT_MIN 0 ! 46: #define FLOPPY_UNIT_MAX 0 ! 47: ! 48: int main(int arcg, char **argv) ! 49: { ! 50: id diskId = nil; ! 51: int unit; ! 52: ! 53: IOInitDDM(200, "udXpr"); ! 54: IOSetDDMMask(XPR_IODEVICE_INDEX, ! 55: XPR_UNIXDISK | XPR_UDTHREAD | XPR_VC); ! 56: volCheckInit(); ! 57: IOInitGeneralFuncs(); ! 58: ! 59: /* ! 60: * Make sure IODiskPartition is ready for indirect device ! 61: * attachment. ! 62: */ ! 63: [IODiskPartition name]; ! 64: ! 65: for(unit=0; unit<=SCSI_UNIT_MIN; unit++) { ! 66: if(diskId == nil) { ! 67: diskId = [SCSIDisk alloc]; ! 68: } ! 69: ! 70: /* ! 71: * Avoid free/alloc if this init fails. ! 72: */ ! 73: if([diskId SCSIInit:unit] == nil) { ! 74: continue; ! 75: } ! 76: else { ! 77: /* ! 78: * Success. Have DiskObject superclass take care of ! 79: * the rest. ! 80: */ ! 81: if([diskId registerDevice] == nil) { ! 82: exit(1); ! 83: } ! 84: [diskId registerPartition:diskId]; ! 85: diskId = nil; ! 86: } ! 87: ! 88: } ! 89: if(diskId) { ! 90: [diskId free]; ! 91: diskId = nil; ! 92: } ! 93: ! 94: for(unit=0; unit<=FLOPPY_UNIT_MIN; unit++) { ! 95: if(diskId == nil) { ! 96: diskId = [FloppyDisk alloc]; ! 97: } ! 98: ! 99: /* ! 100: * Avoid free/alloc if this init fails. ! 101: */ ! 102: if([diskId floppyInit:unit] == nil) { ! 103: continue; ! 104: } ! 105: else { ! 106: /* ! 107: * Success. Have DiskObject superclass take care of ! 108: * the rest. ! 109: */ ! 110: if([diskId registerDevice] == nil) { ! 111: exit(1); ! 112: } ! 113: [diskId registerPartition:diskId]; ! 114: diskId = nil; ! 115: } ! 116: ! 117: } ! 118: if(diskId) { ! 119: [diskId free]; ! 120: } ! 121: ! 122: /* ! 123: * Success. This thread is done; all subsequent work is done by ! 124: * the IOStub objects' I/O threads (started in initStub:) and ! 125: * by the NXProxy threads. ! 126: */ ! 127: cthread_exit(0); ! 128: return 0; ! 129: } ! 130:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.