|
|
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: #import <mach/std_types.h> ! 26: #import <kernserv/ns_timer.h> ! 27: #import <driverkit/IODirectDevice.h> ! 28: ! 29: ! 30: #ifndef __APPLE_TYPES_DEFINED__ ! 31: #define __APPLE_TYPES_DEFINED__ 1 ! 32: ! 33: typedef unsigned int UInt32; // A 32-bit unsigned integer ! 34: typedef unsigned char UInt8; // A "byte-sized" integer ! 35: typedef signed char SInt8; ! 36: typedef signed int SInt32; // A 32-bit signed integer ! 37: typedef boolean_t Boolean; // TRUE/FALSE value (YES/NO in NeXT) ! 38: typedef signed int OSErr; ! 39: typedef signed int OSStatus; ! 40: ! 41: #endif /* __APPLE_TYPES_DEFINED__ */ ! 42: ! 43: ! 44: ! 45: struct adb_packet { ! 46: unsigned char a_header[8]; ! 47: int a_hcount; ! 48: unsigned char a_buffer[32]; ! 49: int a_bcount; ! 50: int a_bsize; ! 51: }; ! 52: ! 53: typedef struct adb_packet adb_packet_t; ! 54: ! 55: ! 56: struct adb_request { ! 57: simple_lock_data_t a_lock; ! 58: int a_result; /* Result of ADB command */ ! 59: int a_flags; /* used internally */ ! 60: adb_packet_t a_cmd; /* Command packet */ ! 61: adb_packet_t a_reply; /* Reply packet */ ! 62: void (*a_done)(struct adb_request *); ! 63: struct adb_request *a_next; ! 64: }; ! 65: ! 66: typedef struct adb_request adb_request_t; ! 67: ! 68: /* ! 69: * ADB Packet Types ! 70: */ ! 71: ! 72: #define ADB_PACKET_ADB 0 ! 73: #define ADB_PACKET_PSEUDO 1 ! 74: #define ADB_PACKET_ERROR 2 ! 75: #define ADB_PACKET_TIMER 3 ! 76: #define ADB_PACKET_POWER 4 ! 77: #define ADB_PACKET_MACIIC 5 ! 78: ! 79: /* ! 80: * ADB Device Commands ! 81: */ ! 82: ! 83: #define ADB_ADBCMD_RESET_BUS 0x00 ! 84: #define ADB_ADBCMD_FLUSH_ADB 0x01 ! 85: #define ADB_ADBCMD_WRITE_ADB 0x08 ! 86: #define ADB_ADBCMD_READ_ADB 0x0c ! 87: ! 88: /* ! 89: * ADB Pseudo Commands ! 90: */ ! 91: ! 92: #define ADB_PSEUDOCMD_WARM_START 0x00 ! 93: #define ADB_PSEUDOCMD_START_STOP_AUTO_POLL 0x01 ! 94: #define ADB_PSEUDOCMD_GET_6805_ADDRESS 0x02 ! 95: #define ADB_PSEUDOCMD_GET_REAL_TIME 0x03 ! 96: #define ADB_PSEUDOCMD_GET_PRAM 0x07 ! 97: #define ADB_PSEUDOCMD_SET_6805_ADDRESS 0x08 ! 98: #define ADB_PSEUDOCMD_SET_REAL_TIME 0x09 ! 99: #define ADB_PSEUDOCMD_POWER_DOWN 0x0a ! 100: #define ADB_PSEUDOCMD_SET_POWER_UPTIME 0x0b ! 101: #define ADB_PSEUDOCMD_SET_PRAM 0x0c ! 102: #define ADB_PSEUDOCMD_MONO_STABLE_RESET 0x0d ! 103: #define ADB_PSEUDOCMD_SEND_DFAC 0x0e ! 104: #define ADB_PSEUDOCMD_BATTERY_SWAP_SENSE 0x10 ! 105: #define ADB_PSEUDOCMD_RESTART_SYSTEM 0x11 ! 106: #define ADB_PSEUDOCMD_SET_IPL_LEVEL 0x12 ! 107: #define ADB_PSEUDOCMD_FILE_SERVER_FLAG 0x13 ! 108: #define ADB_PSEUDOCMD_SET_AUTO_RATE 0x14 ! 109: #define ADB_PSEUDOCMD_GET_AUTO_RATE 0x16 ! 110: #define ADB_PSEUDOCMD_SET_DEVICE_LIST 0x19 ! 111: #define ADB_PSEUDOCMD_GET_DEVICE_LIST 0x1a ! 112: #define ADB_PSEUDOCMD_SET_ONE_SECOND_MODE 0x1b ! 113: #define ADB_PSEUDOCMD_SET_POWER_MESSAGES 0x21 ! 114: #define ADB_PSEUDOCMD_GET_SET_IIC 0x22 ! 115: #define ADB_PSEUDOCMD_ENABLE_DISABLE_WAKEUP 0x23 ! 116: #define ADB_PSEUDOCMD_TIMER_TICKLE 0x24 ! 117: #define ADB_PSEUDOCMD_COMBINED_FORMAT_IIC 0X25 ! 118: ! 119: ! 120: struct CudaRequest { ! 121: struct CudaMachMessage * next; ! 122: struct CudaMachMessage * prev; ! 123: adb_packet_t a_cmd; /* Command packet */ ! 124: adb_packet_t a_reply; /* Reply packet */ ! 125: pmCallback_func pmCallback; ! 126: id pmId; ! 127: UInt32 pmRefNum; ! 128: }; ! 129: ! 130: typedef struct CudaRequest CudaRequest; ! 131: ! 132: struct CudaMachMessage { ! 133: msg_header_t msgHeader; ! 134: msg_type_t msgType; ! 135: CudaRequest msgBody; ! 136: }; ! 137: ! 138: typedef struct CudaMachMessage CudaMachMessage; ! 139: ! 140: ! 141: @interface AppleCuda : IODirectDevice <ADBservice, RTCservice> ! 142: { ! 143: ! 144: VIAAddress VIA1_shift; // pointers to VIA registers ! 145: VIAAddress VIA1_auxillaryControl; ! 146: VIAAddress VIA1_interruptFlag; ! 147: VIAAddress VIA1_interruptEnable; ! 148: VIAAddress VIA2_dataB; ! 149: UInt8 PMack; // ack bit ! 150: ! 151: pmADBinput_func ADBclient; // Input handler in ADB client ! 152: id ADBid; // id of ADB client ! 153: pmCallback_func RTCclient; // Tick handler in RTC client ! 154: id RTCid; // id of RTC client ! 155: pmCallback_func PWRclient; // Button handler in Power Management client ! 156: id PWRid; // id of Power Management client ! 157: ! 158: CudaRequest * clientRequest; ! 159: CudaMachMessage localMachMessage; ! 160: UInt8 firstChar; ! 161: UInt32 charCountS1; ! 162: UInt8 * dataPointer1; ! 163: ! 164: CudaMachMessage * queueHead; // our command queue ! 165: CudaMachMessage * queueTail; ! 166: port_t port; // our interrupt port ! 167: pmCallback_func who_to_call; // ADB client's callback for solicited input ! 168: id theirId; // ADB client's id for input callback ! 169: UInt32 theirRefNum; // ADB client's refnum for input callback ! 170: ns_time_t adb_read_timeout; // timeout on read to absent adb device ! 171: UInt8 auto_power_on; ! 172: ! 173: } ! 174: ! 175: ! 176: + (Boolean)probe : (IODeviceDescription *)deviceDescription; // initialize the driver ! 177: ! 178: - initFromDeviceDescription : (IODeviceDescription *)deviceDescription; ! 179: ! 180: - free; // shut the driver down ! 181: ! 182: - (void)interruptOccurred; ! 183: ! 184: - (void)timeoutOccurred; ! 185: ! 186: - (void)receiveMsg; ! 187: ! 188: ! 189: ! 190: // ADB protocol ! 191: - (void)registerForADBAutopoll :(pmCallback_func)inputHandler ! 192: :(id)caller; ! 193: ! 194: - (PMUStatus)ADBWrite :(UInt32)DevAddr ! 195: :(UInt32)DevReg ! 196: :(UInt32)ByteCount ! 197: :(UInt8*)Buffer ! 198: :(UInt32)RefNum ! 199: :(id)Id ! 200: :(pmCallback_func)Callback; ! 201: ! 202: - (PMUStatus)ADBRead :(UInt32)DevAddr ! 203: :(UInt32)DevReg ! 204: :(UInt32)RefNum ! 205: :(id)Id ! 206: :(pmCallback_func)Callback; ! 207: ! 208: - (PMUStatus)ADBReset :(UInt32)Refnum ! 209: :(id)Id ! 210: :(pmCallback_func)Callback; ! 211: ! 212: - (PMUStatus)ADBFlush :(UInt32)DevAddr ! 213: :(UInt32)RefNum ! 214: :(id)Id ! 215: :(pmCallback_func)Callback; ! 216: ! 217: - (PMUStatus)ADBSetPollList :(UInt32)PollBitField ! 218: :(UInt32)RefNum ! 219: :(id)Id ! 220: :(pmCallback_func)Callback; ! 221: ! 222: - (PMUStatus)ADBPollDisable :(UInt32)RefNum ! 223: :(id)Id ! 224: :(pmCallback_func)Callback; ! 225: ! 226: ! 227: - (PMUStatus)ADBSetFileServerMode:(UInt32)RefNum ! 228: :(id)Id ! 229: :(pmCallback_func)Callback; ! 230: ! 231: ! 232: - (PMUStatus)ADBPollEnable :(UInt32)RefNum ! 233: :(id)Id ! 234: :(pmCallback_func)Callback; ! 235: ! 236: - (PMUStatus)ADBSetPollRate :(UInt32)newRate ! 237: :(UInt32)RefNum ! 238: :(id)Id ! 239: :(pmCallback_func)Callback; ! 240: ! 241: - (PMUStatus)ADBGetPollRate :(UInt32 *)currentRate ! 242: :(UInt32)RefNum ! 243: :(id)Id ! 244: :(pmCallback_func)Callback; ! 245: ! 246: - (PMUStatus)ADBSetAlternateKeyboard :(UInt32)DevAddr ! 247: :(UInt32)RefNum ! 248: :(id)Id ! 249: :(pmCallback_func)Callback; ! 250: ! 251: ! 252: // RTC protocol ! 253: - (void)registerForClockTicks :(pmCallback_func)tickHandler ! 254: :(id)caller; ! 255: ! 256: - (PMUStatus)setRealTimeClock :(UInt8 *)newTime ! 257: :(UInt32)RefNum ! 258: :(id)Id ! 259: :(pmCallback_func)Callback; ! 260: ! 261: - (PMUStatus)getRealTimeClock :(UInt8 *)currentTime ! 262: :(UInt32)RefNum ! 263: :(id)Id ! 264: :(pmCallback_func)Callback; ! 265: ! 266: - (PMUStatus)setPowerupTime :(UInt8 *)newTime ! 267: :(UInt32)RefNum ! 268: :(id)Id ! 269: :(pmCallback_func)Callback; ! 270: ! 271: ! 272: - (PMUStatus)CudaMisc :(UInt8 *)output ! 273: :(UInt32)length ! 274: :(UInt32)RefNum ! 275: :(id)Id ! 276: :(pmCallback_func)Callback; ! 277: ! 278: // private methods ! 279: ! 280: // - (void)ADBinput:(UInt32)theLength:(UInt8 *)theInput; ! 281: ! 282: - (void)StartCudaTransmission:(CudaRequest *)plugInMessage; ! 283: ! 284: - (void)EnableCudaInterrupt; ! 285: ! 286: - (void)CheckRequestQueue; ! 287: ! 288: -(void) cuda_error; ! 289: -(void) cuda_idle; ! 290: -(void) cuda_collision; ! 291: -(void) cuda_receive_last_byte; ! 292: -(void) cuda_receive_data; ! 293: -(void) cuda_unexpected_attention; ! 294: -(void) cuda_expected_attention; ! 295: -(void) cuda_transmit_data; ! 296: -(void) cuda_process_response; ! 297: -(void) poll_device; ! 298: ! 299: ! 300: @end ! 301: ! 302: ! 303: ! 304: ! 305: ! 306: ! 307: ! 308: ! 309: ! 310:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.