1/* $NetBSD: adbvar.h,v 1.14 2009/11/01 01:51:35 snj Exp $ */ 2 3/*- 4 * Copyright (C) 1994 Bradley A. Grantham 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 */ 27 28#include <machine/adbsys.h> 29 30/* 31 * Arguments used to attach a device to the Apple Desktop Bus 32 */ 33struct adb_attach_args { 34 int origaddr; 35 int adbaddr; 36 int handler_id; 37}; 38 39typedef struct adb_trace_xlate_s { 40 int params; 41 char *string; 42} adb_trace_xlate_t; 43 44extern adb_trace_xlate_t adb_trace_xlations[]; 45 46#ifdef DEBUG 47#ifndef ADB_DEBUG 48#define ADB_DEBUG 49#endif 50#endif 51 52#ifdef ADB_DEBUG 53extern int adb_debug; 54#endif 55 56typedef void *Ptr; 57typedef void **Handle; 58 59/* ADB Manager */ 60typedef struct { 61 Ptr siServiceRtPtr; 62 Ptr siDataAreaAddr; 63} ADBSetInfoBlock; 64typedef struct { 65 unsigned char devType; 66 unsigned char origADBAddr; 67 Ptr dbServiceRtPtr; 68 Ptr dbDataAreaAddr; 69} ADBDataBlock; 70 71struct adb_softc { 72 char *sc_regbase; 73}; 74 75typedef void (adbComp)(void *, volatile int *, int); 76 77/* adb_direct.c */ 78extern int adbHardware; 79 80/* types of adb hardware that we (will eventually) support */ 81#define ADB_HW_UNKNOWN 0x01 /* don't know */ 82#define ADB_HW_II 0x02 /* Mac II series */ 83#define ADB_HW_IISI 0x03 /* Mac IIsi series */ 84#define ADB_HW_PMU 0x04 /* PowerBook series */ 85#define ADB_HW_CUDA 0x05 /* Machines with a Cuda chip */ 86 87#define ADB_CMDADDR(cmd) ((u_int8_t)((cmd) & 0xf0) >> 4) 88#define ADBFLUSH(dev) ((((u_int8_t)(dev) & 0x0f) << 4) | 0x01) 89#define ADBLISTEN(dev, reg) ((((u_int8_t)(dev) & 0x0f) << 4) | 0x08 | (reg)) 90#define ADBTALK(dev, reg) ((((u_int8_t)(dev) & 0x0f) << 4) | 0x0c | (reg)) 91 92int adb_intr(void *); 93int adb_poweroff(void); 94void adb_restart(void); 95void adb_cuda_autopoll(void); 96int adb_intr_cuda(void *); 97int CountADBs(void); 98void ADBReInit(void); 99int GetIndADB(ADBDataBlock * info, int index); 100int GetADBInfo(ADBDataBlock * info, int adbAddr); 101int SetADBInfo(ADBSetInfoBlock * info, int adbAddr); 102int ADBOp(Ptr buffer, adbComp *compRout, Ptr data, short commandNum); 103int adb_read_date_time(unsigned long *t); 104int adb_set_date_time(unsigned long t); 105 106int adb_op_sync(Ptr, adbComp *, Ptr, short); 107void adb_op_comprout(void *, volatile int *, int); 108