1995-04-21 06:47:35 +04:00
|
|
|
/* $NetBSD: adbsys.c,v 1.9 1995/04/21 02:47:42 briggs Exp $ */
|
1994-10-26 11:45:48 +03:00
|
|
|
|
1994-07-08 11:55:46 +04:00
|
|
|
/*-
|
1994-12-04 02:33:55 +03:00
|
|
|
* Copyright (C) 1994 Bradley A. Grantham
|
1994-07-08 11:55:46 +04:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
1994-12-04 02:33:55 +03:00
|
|
|
* This product includes software developed by Bradley A. Grantham.
|
|
|
|
* 4. The name of the author may not be used to endorse or promote products
|
|
|
|
* derived from this software without specific prior written permission.
|
1994-07-08 11:55:46 +04:00
|
|
|
*
|
1994-12-04 02:33:55 +03:00
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
1994-07-08 11:55:46 +04:00
|
|
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
1994-12-04 02:33:55 +03:00
|
|
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
1994-07-08 11:55:46 +04:00
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/param.h>
|
1994-07-30 08:21:42 +04:00
|
|
|
#include <machine/adbsys.h>
|
1995-04-21 06:47:35 +04:00
|
|
|
|
1994-12-04 02:33:55 +03:00
|
|
|
#include "adbvar.h"
|
1995-04-21 06:47:35 +04:00
|
|
|
#include "../mac68k/via.h"
|
1994-12-04 02:33:55 +03:00
|
|
|
#include "../mac68k/macrom.h"
|
1994-07-08 11:55:46 +04:00
|
|
|
|
1995-04-21 06:47:35 +04:00
|
|
|
/* from adb.c */
|
|
|
|
void adb_processevent(adb_event_t * event);
|
1994-07-08 11:55:46 +04:00
|
|
|
|
1994-12-04 02:33:55 +03:00
|
|
|
extern void adb_jadbproc(void);
|
1994-07-08 11:55:46 +04:00
|
|
|
|
1995-04-21 06:47:35 +04:00
|
|
|
void
|
|
|
|
adb_complete(buffer, data_area, adb_command)
|
|
|
|
caddr_t buffer;
|
|
|
|
caddr_t data_area;
|
|
|
|
int adb_command;
|
1994-07-08 11:55:46 +04:00
|
|
|
{
|
1995-04-21 06:47:35 +04:00
|
|
|
register int i;
|
|
|
|
register char *sbuf, *dbuf;
|
|
|
|
adb_event_t event;
|
|
|
|
ADBDataBlock adbdata;
|
|
|
|
int adbaddr;
|
|
|
|
int error;
|
1994-07-08 11:55:46 +04:00
|
|
|
|
1994-12-04 02:33:55 +03:00
|
|
|
#if defined(MRG_DEBUG)
|
|
|
|
printf("adb: transaction completion\n");
|
|
|
|
#endif
|
1994-07-08 11:55:46 +04:00
|
|
|
|
1995-04-21 06:47:35 +04:00
|
|
|
adbaddr = (adb_command & 0xf0) >> 4;
|
1994-12-04 02:33:55 +03:00
|
|
|
error = GetADBInfo(&adbdata, adbaddr);
|
|
|
|
#if defined(MRG_DEBUG)
|
|
|
|
printf("adb: GetADBInfo returned %d\n", error);
|
|
|
|
#endif
|
1994-07-08 11:55:46 +04:00
|
|
|
|
1994-12-04 02:33:55 +03:00
|
|
|
event.addr = adbaddr;
|
|
|
|
event.hand_id = adbdata.devType;
|
|
|
|
event.def_addr = adbdata.origADBAddr;
|
|
|
|
#if defined(MRG_DEBUG)
|
|
|
|
printf("adb: from %d at %d (org %d) %d:", event.addr,
|
|
|
|
event.hand_id, event.def_addr, buffer[0]);
|
1995-04-21 06:47:35 +04:00
|
|
|
for (i = 1; i <= buffer[0]; i++)
|
1994-12-04 02:33:55 +03:00
|
|
|
printf(" %x", buffer[i]);
|
|
|
|
printf("\n");
|
|
|
|
#endif
|
1994-07-08 11:55:46 +04:00
|
|
|
|
1994-12-04 02:33:55 +03:00
|
|
|
i = event.byte_count = buffer[0];
|
|
|
|
sbuf = &buffer[1];
|
|
|
|
dbuf = &event.bytes[0];
|
1995-04-21 06:47:35 +04:00
|
|
|
while (i--)
|
1994-12-04 02:33:55 +03:00
|
|
|
*dbuf++ = *sbuf++;
|
1994-07-08 11:55:46 +04:00
|
|
|
|
1994-12-04 02:33:55 +03:00
|
|
|
microtime(&event.timestamp);
|
1994-07-08 11:55:46 +04:00
|
|
|
|
1994-12-04 02:33:55 +03:00
|
|
|
adb_processevent(&event);
|
1994-07-08 11:55:46 +04:00
|
|
|
}
|
|
|
|
|
1995-04-21 06:47:35 +04:00
|
|
|
void
|
|
|
|
adb_init()
|
1994-07-08 11:55:46 +04:00
|
|
|
{
|
1994-12-04 02:33:55 +03:00
|
|
|
ADBDataBlock adbdata;
|
|
|
|
ADBSetInfoBlock adbinfo;
|
1995-04-21 06:47:35 +04:00
|
|
|
int i, s;
|
|
|
|
int totaladbs;
|
|
|
|
int adbindex, adbaddr;
|
1994-12-04 02:33:55 +03:00
|
|
|
int error;
|
1994-07-08 11:55:46 +04:00
|
|
|
|
1995-04-21 06:47:35 +04:00
|
|
|
if (!mrg_romready()) {
|
1994-12-04 02:33:55 +03:00
|
|
|
printf("adb: no ROM ADB driver in this kernel for this machine\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
printf("adb: bus subsystem\n");
|
|
|
|
#if defined(MRG_DEBUG)
|
|
|
|
printf("adb: call mrg_initadbintr\n");
|
|
|
|
#endif
|
1994-07-08 11:55:46 +04:00
|
|
|
|
1994-12-04 02:33:55 +03:00
|
|
|
mrg_initadbintr(); /* Mac ROM Glue okay to do ROM intr */
|
|
|
|
#if defined(MRG_DEBUG)
|
|
|
|
printf("adb: returned from mrg_initadbintr\n");
|
|
|
|
#endif
|
1994-07-08 11:55:46 +04:00
|
|
|
|
1995-04-21 06:47:35 +04:00
|
|
|
/* ADBReInit pre/post-processing */
|
1994-12-04 02:33:55 +03:00
|
|
|
JADBProc = adb_jadbproc;
|
1994-07-08 11:55:46 +04:00
|
|
|
|
1995-04-21 06:47:35 +04:00
|
|
|
/* Initialize ADB */
|
1994-12-04 02:33:55 +03:00
|
|
|
#if defined(MRG_DEBUG)
|
|
|
|
printf("adb: calling ADBReInit\n");
|
|
|
|
#endif
|
1994-07-08 11:55:46 +04:00
|
|
|
|
1994-12-04 02:33:55 +03:00
|
|
|
ADBReInit();
|
1994-07-08 11:55:46 +04:00
|
|
|
|
1994-12-04 02:33:55 +03:00
|
|
|
#if defined(MRG_DEBUG)
|
|
|
|
printf("adb: done with ADBReInit\n");
|
|
|
|
#endif
|
1994-07-08 11:55:46 +04:00
|
|
|
|
1994-12-04 02:33:55 +03:00
|
|
|
totaladbs = CountADBs();
|
1995-04-21 06:47:35 +04:00
|
|
|
|
|
|
|
/* for each ADB device */
|
|
|
|
for (adbindex = 1; adbindex <= totaladbs; adbindex++) {
|
|
|
|
/* Get the ADB information */
|
1994-12-04 02:33:55 +03:00
|
|
|
adbaddr = GetIndADB(&adbdata, adbindex);
|
1994-07-08 11:55:46 +04:00
|
|
|
|
1995-04-21 06:47:35 +04:00
|
|
|
/* Print out the glory */
|
1994-12-04 02:33:55 +03:00
|
|
|
printf("adb: ");
|
1995-04-21 06:47:35 +04:00
|
|
|
switch (adbdata.origADBAddr) {
|
|
|
|
case 2:
|
|
|
|
switch (adbdata.devType) {
|
|
|
|
case 1:
|
|
|
|
printf("keyboard");
|
|
|
|
break;
|
1994-12-04 02:33:55 +03:00
|
|
|
case 2:
|
1995-04-21 06:47:35 +04:00
|
|
|
printf("extended keyboard");
|
|
|
|
break;
|
|
|
|
case 12:
|
|
|
|
printf("PowerBook keyboard");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
printf("mapped device (%d)",
|
|
|
|
adbdata.devType);
|
1994-07-08 11:55:46 +04:00
|
|
|
break;
|
1995-04-21 06:47:35 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
switch (adbdata.devType) {
|
|
|
|
case 1:
|
|
|
|
printf("100 dpi mouse");
|
1994-12-04 02:33:55 +03:00
|
|
|
break;
|
1995-04-21 06:47:35 +04:00
|
|
|
case 2:
|
|
|
|
printf("200 dpi mouse");
|
1994-12-04 02:33:55 +03:00
|
|
|
break;
|
|
|
|
default:
|
1995-04-21 06:47:35 +04:00
|
|
|
printf("relative positioning device (mouse?) (%d)", adbdata.devType);
|
1994-12-04 02:33:55 +03:00
|
|
|
break;
|
1995-04-21 06:47:35 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
printf("absolute positioning device (tablet?) (%d)", adbdata.devType);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
printf("unknown type device, (def %d, handler %d)", adbdata.origADBAddr,
|
|
|
|
adbdata.devType);
|
|
|
|
break;
|
1994-07-08 11:55:46 +04:00
|
|
|
}
|
1994-12-04 02:33:55 +03:00
|
|
|
printf(" at %d\n", adbaddr);
|
|
|
|
|
1995-04-21 06:47:35 +04:00
|
|
|
/* Set completion routine to be MacBSD's */
|
1994-12-04 02:33:55 +03:00
|
|
|
adbinfo.siServiceRtPtr = adb_asmcomplete;
|
|
|
|
adbinfo.siDataAreaAddr = NULL;
|
|
|
|
error = SetADBInfo(&adbinfo, adbaddr);
|
|
|
|
#if defined(MRG_DEBUG)
|
|
|
|
printf("returned %d from SetADBInfo\n", error);
|
1994-07-08 11:55:46 +04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|