|
|
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: /* ! 26: * Copyright 1996 1995 by Open Software Foundation, Inc. 1997 1996 1995 1994 1993 1992 1991 ! 27: * All Rights Reserved ! 28: * ! 29: * Permission to use, copy, modify, and distribute this software and ! 30: * its documentation for any purpose and without fee is hereby granted, ! 31: * provided that the above copyright notice appears in all copies and ! 32: * that both the copyright notice and this permission notice appear in ! 33: * supporting documentation. ! 34: * ! 35: * OSF DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE ! 36: * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS ! 37: * FOR A PARTICULAR PURPOSE. ! 38: * ! 39: * IN NO EVENT SHALL OSF BE LIABLE FOR ANY SPECIAL, INDIRECT, OR ! 40: * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM ! 41: * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, ! 42: * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION ! 43: * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ! 44: * ! 45: */ ! 46: /* ! 47: * Copyright 1996 1995 by Apple Computer, Inc. 1997 1996 1995 1994 1993 1992 1991 ! 48: * All Rights Reserved ! 49: * ! 50: * Permission to use, copy, modify, and distribute this software and ! 51: * its documentation for any purpose and without fee is hereby granted, ! 52: * provided that the above copyright notice appears in all copies and ! 53: * that both the copyright notice and this permission notice appear in ! 54: * supporting documentation. ! 55: * ! 56: * APPLE COMPUTER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE ! 57: * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS ! 58: * FOR A PARTICULAR PURPOSE. ! 59: * ! 60: * IN NO EVENT SHALL APPLE COMPUTER BE LIABLE FOR ANY SPECIAL, INDIRECT, OR ! 61: * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM ! 62: * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, ! 63: * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION ! 64: * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ! 65: */ ! 66: /* ! 67: * MKLINUX-1.0DR2 ! 68: */ ! 69: ! 70: ! 71: //#include <device/device_types.h> ! 72: #include "adb_io.h" ! 73: ! 74: #define ADB_FLAGS_PRESENT 0x00000001 /* Device is present */ ! 75: #define ADB_FLAGS_REGISTERED 0x00000002 /* Device has a handler */ ! 76: #define ADB_FLAGS_UNRESOLVED 0x00000004 /* Device has not been fully probed */ ! 77: ! 78: struct adb_packet { ! 79: unsigned char a_header[8]; ! 80: int a_hcount; ! 81: unsigned char a_buffer[32]; ! 82: int a_bcount; ! 83: int a_bsize; ! 84: }; ! 85: ! 86: typedef struct adb_packet adb_packet_t; ! 87: ! 88: /* ! 89: * a_flags - used internal by ADB ! 90: */ ! 91: ! 92: #define ADB_IS_ASYNC 0x00001 ! 93: #define ADB_DONE 0x00002 ! 94: ! 95: struct adb_request { ! 96: simple_lock_data_t a_lock; ! 97: int a_result; /* Result of ADB command */ ! 98: int a_flags; /* used internally */ ! 99: adb_packet_t a_cmd; /* Command packet */ ! 100: adb_packet_t a_reply; /* Reply packet */ ! 101: void (*a_done)(struct adb_request *); ! 102: struct adb_request *a_next; ! 103: }; ! 104: ! 105: typedef struct adb_request adb_request_t; ! 106: ! 107: struct adb_ops { ! 108: void (*ao_send)(adb_request_t *); ! 109: void (*ao_poll)(void); ! 110: }; ! 111: ! 112: typedef struct adb_ops adb_ops_t; ! 113: ! 114: struct adb_device { ! 115: unsigned short a_dev_type; /* Device Type (default id) */ ! 116: unsigned short a_dev_handler; /* Device handler ID */ ! 117: unsigned short a_dev_orighandler;/* Original handler ID */ ! 118: unsigned short a_dev_addr; /* Device Reg 3 Address */ ! 119: int a_addr; /* Device Address */ ! 120: int a_flags; ! 121: int a_type; ! 122: void (*a_handler)(int number, unsigned char *buffer, int bytes, void * ssp); ! 123: }; ! 124: ! 125: typedef struct adb_device adb_device_t; ! 126: ! 127: extern struct adb_device adb_devices[ADB_DEVICE_COUNT]; ! 128: ! 129: /* ! 130: * ADB Commands ! 131: */ ! 132: ! 133: #define ADB_DEVCMD_SELF_TEST 0xff ! 134: #define ADB_DEVCMD_CHANGE_ID 0xfe ! 135: #define ADB_DEVCMD_CHANGE_ID_AND_ACT 0xfd ! 136: #define ADB_DEVCMD_CHANGE_ID_AND_ENABLE 0x00 ! 137: ! 138: /* ! 139: * Results for a_result ! 140: */ ! 141: ! 142: #define ADB_RET_OK 0 /* Successful */ ! 143: #define ADB_RET_INUSE 1 /* ADB Device in use */ ! 144: #define ADB_RET_NOTPRESENT 2 /* ADB Device not present */ ! 145: #define ADB_RET_TIMEOUT 3 /* ADB Timeout */ ! 146: #define ADB_RET_UNEXPECTED_RESULT 4 /* Unknown result */ ! 147: #define ADB_RET_REQUEST_ERROR 5 /* Packet Request Error */ ! 148: #define ADB_RET_BUS_ERROR 6 /* ADB Bus Error */ ! 149: ! 150: ! 151: /* ! 152: * ADB Packet Types ! 153: */ ! 154: ! 155: #define ADB_PACKET_ADB 0 ! 156: #define ADB_PACKET_PSEUDO 1 ! 157: #define ADB_PACKET_ERROR 2 ! 158: #define ADB_PACKET_TIMER 3 ! 159: #define ADB_PACKET_POWER 4 ! 160: #define ADB_PACKET_MACIIC 5 ! 161: ! 162: /* ! 163: * ADB Device Commands ! 164: */ ! 165: ! 166: #define ADB_ADBCMD_RESET_BUS 0x00 ! 167: #define ADB_ADBCMD_FLUSH_ADB 0x01 ! 168: #define ADB_ADBCMD_WRITE_ADB 0x08 ! 169: #define ADB_ADBCMD_READ_ADB 0x0c ! 170: ! 171: /* ! 172: * ADB Pseudo Commands ! 173: */ ! 174: ! 175: #define ADB_PSEUDOCMD_WARM_START 0x00 ! 176: #define ADB_PSEUDOCMD_START_STOP_AUTO_POLL 0x01 ! 177: #define ADB_PSEUDOCMD_GET_6805_ADDRESS 0x02 ! 178: #define ADB_PSEUDOCMD_GET_REAL_TIME 0x03 ! 179: #define ADB_PSEUDOCMD_GET_PRAM 0x07 ! 180: #define ADB_PSEUDOCMD_SET_6805_ADDRESS 0x08 ! 181: #define ADB_PSEUDOCMD_SET_REAL_TIME 0x09 ! 182: #define ADB_PSEUDOCMD_POWER_DOWN 0x0a ! 183: #define ADB_PSEUDOCMD_SET_POWER_UPTIME 0x0b ! 184: #define ADB_PSEUDOCMD_SET_PRAM 0x0c ! 185: #define ADB_PSEUDOCMD_MONO_STABLE_RESET 0x0d ! 186: #define ADB_PSEUDOCMD_SEND_DFAC 0x0e ! 187: #define ADB_PSEUDOCMD_BATTERY_SWAP_SENSE 0x10 ! 188: #define ADB_PSEUDOCMD_RESTART_SYSTEM 0x11 ! 189: #define ADB_PSEUDOCMD_SET_IPL_LEVEL 0x12 ! 190: #define ADB_PSEUDOCMD_FILE_SERVER_FLAG 0x13 ! 191: #define ADB_PSEUDOCMD_SET_AUTO_RATE 0x14 ! 192: #define ADB_PSEUDOCMD_GET_AUTO_RATE 0x16 ! 193: #define ADB_PSEUDOCMD_SET_DEVICE_LIST 0x19 ! 194: #define ADB_PSEUDOCMD_GET_DEVICE_LIST 0x1a ! 195: #define ADB_PSEUDOCMD_SET_ONE_SECOND_MODE 0x1b ! 196: #define ADB_PSEUDOCMD_SET_POWER_MESSAGES 0x21 ! 197: #define ADB_PSEUDOCMD_GET_SET_IIC 0x22 ! 198: #define ADB_PSEUDOCMD_ENABLE_DISABLE_WAKEUP 0x23 ! 199: #define ADB_PSEUDOCMD_TIMER_TICKLE 0x24 ! 200: #define ADB_PSEUDOCMD_COMBINED_FORMAT_IIC 0X25 ! 201: ! 202: /* ! 203: * Macros to help build commands up ! 204: */ ! 205: ! 206: #define ADB_BUILD_CMD1(c, p1) {(c)->a_cmd.a_header[0] = p1; (c)->a_cmd.a_hcount = 1; } ! 207: #define ADB_BUILD_CMD2(c, p1, p2) {(c)->a_cmd.a_header[0] = p1; (c)->a_cmd.a_header[1] = p2; (c)->a_cmd.a_hcount = 2; } ! 208: #define ADB_BUILD_CMD3(c, p1, p2, p3) {(c)->a_cmd.a_header[0] = p1; (c)->a_cmd.a_header[1] = p2; (c)->a_cmd.a_header[2] = p3; (c)->a_cmd.a_hcount = 3; } ! 209: #define ADB_BUILD_CMD4(c, p1, p2, p3, p4) {(c)->a_cmd.a_header[0] = p1; (c)->a_cmd.a_header[1] = p2; \ ! 210: (c)->a_cmd.a_header[2] = p3; (c)->a_cmd.a_header[3] = p4; (c)->a_cmd.a_hcount = 4; } ! 211: #define ADB_BUILD_CMD2_BUFFER(c, p1, p2, len, buf) {(c)->a_cmd.a_header[0] = p1; (c)->a_cmd.a_header[1] = p2; (c)->a_cmd.a_hcount = 2;\ ! 212: (c)->a_cmd.a_bcount = len;\ ! 213: memcpy(&(c)->a_cmd.a_buffer, buf, len); } ! 214: ! 215: /* ! 216: * Prototypes ! 217: */ ! 218: ! 219: void adb_register_handler(int id, ! 220: void (*handler)(int number, unsigned char *packet, int count, void * ssp)); ! 221: void adb_register_dev(int id, ! 222: void (*handler)(int number, unsigned char *packet, int count, void * ssp)); ! 223: int adb_readreg(int devnum, int regnum, unsigned short *value); ! 224: int adb_writereg(int devnum, int regnum, unsigned short value); ! 225: void adb_writereg_async(int devnum, int regnum, unsigned short value); ! 226: void adb_send(adb_request_t *req, boolean_t wait); ! 227: void adb_done(adb_request_t *req); ! 228: void adb_unsolicited_done(adb_packet_t *response, void * ssp); ! 229: adb_request_t *adb_next_request(void); ! 230: void adb_poll(void); ! 231: ! 232: int adb_set_handler(struct adb_device *devp, int handler); ! 233: ! 234: void borrow_adb( void (*handler)(int number, unsigned char *packet, int count,void * ssp)); ! 235: void return_adb( void ); ! 236: ! 237: /* ! 238: * For configuration ! 239: */ ! 240: ! 241: io_return_t adbopen(dev_t dev, dev_mode_t flag, io_req_t ior); ! 242: void adbclose(dev_t dev); ! 243: io_return_t adbread(dev_t dev, io_req_t ior); ! 244: io_return_t adbwrite(dev_t dev, io_req_t ior); ! 245: //boolean_t adbportdeath(dev_t dev, ipc_port_t port); ! 246: io_return_t adbgetstatus(dev_t dev, dev_flavor_t flavor, ! 247: dev_status_t data, mach_msg_type_number_t *status_count); ! 248: io_return_t adbsetstatus(dev_t dev, dev_flavor_t flavor, dev_status_t data, ! 249: mach_msg_type_number_t status_count); ! 250: ! 251:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.