Some changes to make ADB work when compiled with -O2:

- extdms_done is modified by things outside of our direct control;
    it needs to be declared `volatile'
  - CountADBs() fails when we call it the second time.  We can work
    around this by telling extdms_init() how many ADB devices we have,
    only calling CountADBs() once.
This commit is contained in:
scottr 1997-01-13 07:01:23 +00:00
parent af1ee80179
commit e14ea342e3
2 changed files with 21 additions and 27 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: adbsys.c,v 1.23 1996/10/13 03:21:14 christos Exp $ */ /* $NetBSD: adbsys.c,v 1.24 1997/01/13 07:01:23 scottr Exp $ */
/*- /*-
* Copyright (C) 1994 Bradley A. Grantham * Copyright (C) 1994 Bradley A. Grantham
@ -43,9 +43,9 @@
extern struct mac68k_machine_S mac68k_machine; extern struct mac68k_machine_S mac68k_machine;
/* from adb.c */ /* from adb.c */
void adb_processevent(adb_event_t * event); void adb_processevent __P((adb_event_t * event));
extern void adb_jadbproc(void); extern void adb_jadbproc __P((void));
void void
adb_complete(buffer, data_area, adb_command) adb_complete(buffer, data_area, adb_command)
@ -53,27 +53,29 @@ adb_complete(buffer, data_area, adb_command)
caddr_t data_area; caddr_t data_area;
int adb_command; int adb_command;
{ {
register int i;
register char *sbuf, *dbuf;
adb_event_t event; adb_event_t event;
ADBDataBlock adbdata; ADBDataBlock adbdata;
int adbaddr; int adbaddr;
int error; int error;
#ifdef MRG_DEBUG
register int i;
#if defined(MRG_DEBUG)
printf("adb: transaction completion\n"); printf("adb: transaction completion\n");
#endif #endif
adbaddr = (adb_command & 0xf0) >> 4; adbaddr = (adb_command & 0xf0) >> 4;
error = GetADBInfo(&adbdata, adbaddr); error = GetADBInfo(&adbdata, adbaddr);
#if defined(MRG_DEBUG) #ifdef MRG_DEBUG
printf("adb: GetADBInfo returned %d\n", error); printf("adb: GetADBInfo returned %d\n", error);
#endif #endif
event.addr = adbaddr; event.addr = adbaddr;
event.hand_id = adbdata.devType; event.hand_id = adbdata.devType;
event.def_addr = adbdata.origADBAddr; event.def_addr = adbdata.origADBAddr;
#if defined(MRG_DEBUG) event.byte_count = buffer[0];
memcpy(event.bytes, buffer + 1, event.byte_count);
#ifdef MRG_DEBUG
printf("adb: from %d at %d (org %d) %d:", event.addr, printf("adb: from %d at %d (org %d) %d:", event.addr,
event.hand_id, event.def_addr, buffer[0]); event.hand_id, event.def_addr, buffer[0]);
for (i = 1; i <= buffer[0]; i++) for (i = 1; i <= buffer[0]; i++)
@ -81,33 +83,26 @@ adb_complete(buffer, data_area, adb_command)
printf("\n"); printf("\n");
#endif #endif
i = event.byte_count = buffer[0];
sbuf = &buffer[1];
dbuf = &event.bytes[0];
while (i--)
*dbuf++ = *sbuf++;
microtime(&event.timestamp); microtime(&event.timestamp);
adb_processevent(&event); adb_processevent(&event);
} }
static int extdms_done; static volatile int extdms_done;
/* /*
* initialize extended mouse - probes devices as * initialize extended mouse - probes devices as
* described in _Inside Macintosh, Devices_. * described in _Inside Macintosh, Devices_.
*/ */
void void
extdms_init() extdms_init(totaladbs)
int totaladbs;
{ {
ADBDataBlock adbdata; ADBDataBlock adbdata;
int totaladbs;
int adbindex, adbaddr; int adbindex, adbaddr;
short cmd; short cmd;
char buffer[9]; char buffer[9];
totaladbs = CountADBs();
for (adbindex = 1; adbindex <= totaladbs; adbindex++) { for (adbindex = 1; adbindex <= totaladbs; adbindex++) {
/* Get the ADB information */ /* Get the ADB information */
adbaddr = GetIndADB(&adbdata, adbindex); adbaddr = GetIndADB(&adbdata, adbindex);
@ -190,12 +185,12 @@ adb_init()
return; return;
} }
printf("adb: bus subsystem\n"); printf("adb: bus subsystem\n");
#if defined(MRG_DEBUG) #ifdef MRG_DEBUG
printf("adb: call mrg_initadbintr\n"); printf("adb: call mrg_initadbintr\n");
#endif #endif
mrg_initadbintr(); /* Mac ROM Glue okay to do ROM intr */ mrg_initadbintr(); /* Mac ROM Glue okay to do ROM intr */
#if defined(MRG_DEBUG) #ifdef MRG_DEBUG
printf("adb: returned from mrg_initadbintr\n"); printf("adb: returned from mrg_initadbintr\n");
#endif #endif
@ -203,19 +198,18 @@ adb_init()
JADBProc = adb_jadbproc; JADBProc = adb_jadbproc;
/* Initialize ADB */ /* Initialize ADB */
#if defined(MRG_DEBUG) #ifdef MRG_DEBUG
printf("adb: calling ADBAlternateInit.\n"); printf("adb: calling ADBAlternateInit.\n");
#endif #endif
ADBAlternateInit(); ADBAlternateInit();
#if defined(MRG_DEBUG) #ifdef MRG_DEBUG
printf("adb: done with ADBReInit\n"); printf("adb: done with ADBReInit\n");
#endif #endif
extdms_init();
totaladbs = CountADBs(); totaladbs = CountADBs();
extdms_init(totaladbs);
/* for each ADB device */ /* for each ADB device */
for (adbindex = 1; adbindex <= totaladbs; adbindex++) { for (adbindex = 1; adbindex <= totaladbs; adbindex++) {
@ -299,7 +293,7 @@ adb_init()
adbinfo.siServiceRtPtr = (Ptr) adb_asmcomplete; adbinfo.siServiceRtPtr = (Ptr) adb_asmcomplete;
adbinfo.siDataAreaAddr = NULL; adbinfo.siDataAreaAddr = NULL;
error = SetADBInfo(&adbinfo, adbaddr); error = SetADBInfo(&adbinfo, adbaddr);
#if defined(MRG_DEBUG) #ifdef MRG_DEBUG
printf("returned %d from SetADBInfo\n", error); printf("returned %d from SetADBInfo\n", error);
#endif #endif
} }

View File

@ -1,4 +1,4 @@
/* $NetBSD: adbvar.h,v 1.4 1996/09/14 06:08:01 scottr Exp $ */ /* $NetBSD: adbvar.h,v 1.5 1997/01/13 07:01:24 scottr Exp $ */
/*- /*-
* Copyright (C) 1994 Bradley A. Grantham * Copyright (C) 1994 Bradley A. Grantham
@ -62,4 +62,4 @@ void extdms_complete __P((void));
/* adbsys.c */ /* adbsys.c */
void adb_complete __P((caddr_t buffer, caddr_t data_area, int adb_command)); void adb_complete __P((caddr_t buffer, caddr_t data_area, int adb_command));
void extdms_init __P((void)); void extdms_init __P((int));