From c1a185be974b18fb029f96efe5e1ba350679f7ee Mon Sep 17 00:00:00 2001 From: scottr Date: Mon, 23 Feb 1998 03:11:26 +0000 Subject: [PATCH] Mostly KNF. There's still a bunch of ugly comments and some problems with long lines, but this is at least a big step in the right direction. --- sys/arch/mac68k/dev/adb.c | 70 ++--- sys/arch/mac68k/dev/adbsys.c | 181 +++++++------ sys/arch/mac68k/dev/adbvar.h | 12 +- sys/arch/mac68k/dev/pm_direct.c | 459 +++++++++++++++++--------------- 4 files changed, 377 insertions(+), 345 deletions(-) diff --git a/sys/arch/mac68k/dev/adb.c b/sys/arch/mac68k/dev/adb.c index 5a840cd0c0fd..8adb852a81ba 100644 --- a/sys/arch/mac68k/dev/adb.c +++ b/sys/arch/mac68k/dev/adb.c @@ -1,4 +1,4 @@ -/* $NetBSD: adb.c,v 1.20 1998/02/21 00:37:07 scottr Exp $ */ +/* $NetBSD: adb.c,v 1.21 1998/02/23 03:11:26 scottr Exp $ */ /*- * Copyright (C) 1994 Bradley A. Grantham @@ -114,7 +114,7 @@ adbmatch(parent, cf, aux) static void adbattach(parent, dev, aux) struct device *parent, *dev; - void *aux; + void *aux; { printf(" (ADB event device)\n"); adb_init(); @@ -122,9 +122,9 @@ adbattach(parent, dev, aux) void adb_enqevent(event) - adb_event_t *event; + adb_event_t *event; { - int s; + int s; s = spladb(); @@ -153,7 +153,7 @@ adb_enqevent(event) void adb_handoff(event) - adb_event_t *event; + adb_event_t *event; { if (adb_isopen && !adb_polling) { adb_enqevent(event); @@ -166,9 +166,9 @@ adb_handoff(event) void adb_autorepeat(keyp) - void *keyp; + void *keyp; { - int key = (int) keyp; + int key = (int)keyp; adb_rptevent.bytes[0] |= 0x80; microtime(&adb_rptevent.timestamp); @@ -186,9 +186,9 @@ adb_autorepeat(keyp) void adb_dokeyupdown(event) - adb_event_t *event; + adb_event_t *event; { - int adb_key; + int adb_key; if (event->def_addr == 2) { adb_key = event->u.k.key & 0x7f; @@ -197,17 +197,17 @@ adb_dokeyupdown(event) /* ignore shift & control */ if (adb_repeating != -1) { untimeout(adb_autorepeat, - (void *) adb_rptevent.u.k.key); + (void *)adb_rptevent.u.k.key); } adb_rptevent = *event; adb_repeating = adb_key; timeout(adb_autorepeat, - (void *) adb_key, adb_rptdelay); + (void *)adb_key, adb_rptdelay); } else { if (adb_repeating != -1) { adb_repeating = -1; untimeout(adb_autorepeat, - (void *) adb_rptevent.u.k.key); + (void *)adb_rptevent.u.k.key); } adb_rptevent = *event; } @@ -219,7 +219,7 @@ static adb_ms_buttons = 0; void adb_keymaybemouse(event) - adb_event_t *event; + adb_event_t *event; { static int optionkey_down = 0; adb_event_t new_event; @@ -326,7 +326,7 @@ adb_keymaybemouse(event) void adb_processevent(event) - adb_event_t *event; + adb_event_t *event; { adb_event_t new_event; int i, button_bit, max_byte, mask, buttons; @@ -404,9 +404,9 @@ adb_processevent(event) int adbopen(dev, flag, mode, p) - dev_t dev; - int flag, mode; - struct proc *p; + dev_t dev; + int flag, mode; + struct proc *p; { register int unit; int error = 0; @@ -433,9 +433,9 @@ adbopen(dev, flag, mode, p) int adbclose(dev, flag, mode, p) - dev_t dev; - int flag, mode; - struct proc *p; + dev_t dev; + int flag, mode; + struct proc *p; { int s = spladb(); @@ -449,9 +449,9 @@ adbclose(dev, flag, mode, p) int adbread(dev, uio, flag) - dev_t dev; - struct uio *uio; - int flag; + dev_t dev; + struct uio *uio; + int flag; { int s, error; int willfit; @@ -498,9 +498,9 @@ adbread(dev, uio, flag) int adbwrite(dev, uio, flag) - dev_t dev; - struct uio *uio; - int flag; + dev_t dev; + struct uio *uio; + int flag; { return 0; } @@ -508,11 +508,11 @@ adbwrite(dev, uio, flag) int adbioctl(dev, cmd, data, flag, p) - dev_t dev; - int cmd; - caddr_t data; - int flag; - struct proc *p; + dev_t dev; + int cmd; + caddr_t data; + int flag; + struct proc *p; { switch (cmd) { case ADBIOC_DEVSINFO: { @@ -522,7 +522,7 @@ adbioctl(dev, cmd, data, flag, p) int adbaddr; int i; - di = (void *) data; + di = (void *)data; /* Initialize to no devices */ for (i = 0; i < 16; i++) @@ -543,7 +543,7 @@ adbioctl(dev, cmd, data, flag, p) case ADBIOC_GETREPEAT:{ adb_rptinfo_t *ri; - ri = (void *) data; + ri = (void *)data; ri->delay_ticks = adb_rptdelay; ri->interval_ticks = adb_rptinterval; break; @@ -552,7 +552,7 @@ adbioctl(dev, cmd, data, flag, p) case ADBIOC_SETREPEAT:{ adb_rptinfo_t *ri; - ri = (void *) data; + ri = (void *)data; adb_rptdelay = ri->delay_ticks; adb_rptinterval = ri->interval_ticks; break; @@ -565,7 +565,7 @@ adbioctl(dev, cmd, data, flag, p) case ADBIOC_LISTENCMD:{ adb_listencmd_t *lc; - lc = (void *) data; + lc = (void *)data; } default: diff --git a/sys/arch/mac68k/dev/adbsys.c b/sys/arch/mac68k/dev/adbsys.c index 11556e4f004d..37c195e51929 100644 --- a/sys/arch/mac68k/dev/adbsys.c +++ b/sys/arch/mac68k/dev/adbsys.c @@ -1,4 +1,4 @@ -/* $NetBSD: adbsys.c,v 1.36 1998/02/21 00:37:07 scottr Exp $ */ +/* $NetBSD: adbsys.c,v 1.37 1998/02/23 03:11:26 scottr Exp $ */ /*- * Copyright (C) 1994 Bradley A. Grantham @@ -172,18 +172,19 @@ adb_mm_nonemp_complete(buffer, data_area, adb_command) #endif /* massage the data to look like EMP data */ - if ( (buffer[3] & 0x04) == 0x04 ) - buffer[1]&=0x7f; + if ((buffer[3] & 0x04) == 0x04) + buffer[1] &= 0x7f; else - buffer[1]|=0x80; - if ( (buffer[3] & 0x02) == 0x02 ) - buffer[2]&=0x7f; + buffer[1] |= 0x80; + if ((buffer[3] & 0x02) == 0x02) + buffer[2] &= 0x7f; else - buffer[2]|=0x80; - if ( (buffer[3] & 0x01) == 0x01 ) - buffer[3]=0x00; + buffer[2] |= 0x80; + if ((buffer[3] & 0x01) == 0x01) + buffer[3] = 0x00; else - buffer[3]=0x80; + buffer[3] = 0x80; + event.addr = adbaddr; event.hand_id = adbdata.devType; event.def_addr = adbdata.origADBAddr; @@ -259,8 +260,8 @@ extdms_init(totaladbs) /* busy wait until done */; } if (adbdata.origADBAddr == ADBADDR_MS && - ( adbdata.devType == ADBMS_100DPI - || adbdata.devType == ADBMS_200DPI)) { + (adbdata.devType == ADBMS_100DPI || + adbdata.devType == ADBMS_200DPI)) { /* found a mouse */ cmd = ((adbaddr << 4) & 0xf0) | 0x3; @@ -291,8 +292,10 @@ extdms_init(totaladbs) while (!extdms_done) /* busy wait until done */; - /* Check to see if successful, if not - * try to initialize it as other types */ + /* + * Check to see if successful, if not + * try to initialize it as other types + */ cmd = ((adbaddr << 4) & 0xf0) | 0x3; extdms_done = 0; cmd = (cmd & 0xf3) | 0x0c; /* talk command */ @@ -311,8 +314,10 @@ extdms_init(totaladbs) while (!extdms_done) /* busy wait until done */; - /* Check to see if successful, if not - * try to initialize it as other types */ + /* + * Check to see if successful, if not + * try to initialize it as other types + */ cmd = ((adbaddr << 4) & 0xf0) | 0x3; extdms_done = 0; cmd = (cmd & 0xf3) | 0x0c; /* talk command */ @@ -329,8 +334,10 @@ extdms_init(totaladbs) buffer[1] = 0x00; /* Irrelevant, buffer has 0x77 */ buffer[2] = 0x07; - /* enable 3 button mode = 0111b, - * speed = normal */ + /* + * enable 3 button mode = 0111b, + * speed = normal + */ extdms_done = 0; ADBOp((Ptr)buffer, (Ptr)extdms_complete, (Ptr)&extdms_done, cmd); @@ -356,8 +363,10 @@ adb_init() extern int adb_initted; #ifdef MRG_ADB - /* Even if serial console only, some models require the - * ADB in order to get the date/time and do soft power. */ + /* + * Even if serial console only, some models require the + * ADB in order to get the date/time and do soft power. + */ if ((mac68k_machine.serial_console & 0x03)) { printf("adb: using serial console\n"); return; @@ -421,11 +430,12 @@ adb_init() case ADB_ISOKBD: printf("standard keyboard (ISO layout)"); break; - case ADB_EXTKBD: + case ADB_EXTKBD: extdms_done = 0; - cmd = (((adbaddr << 4) & 0xf0) | 0x0d ); /* talk R1 */ + /* talk R1 */ + cmd = (((adbaddr << 4) & 0xf0) | 0x0d ); ADBOp((Ptr)buffer, (Ptr)extdms_complete, - (Ptr)&extdms_done, cmd); + (Ptr)&extdms_done, cmd); /* Wait until done, but no more than 2 secs */ count = 40000; @@ -437,7 +447,7 @@ adb_init() printf("Mouseman (non-EMP) pseudo keyboard"); else printf("extended keyboard"); - break; + break; case ADB_EXTISOKBD: printf("extended keyboard (ISO layout)"); break; @@ -478,8 +488,7 @@ adb_init() printf("extended keyboard"); break; default: - printf("mapped device (%d)", - adbdata.devType); + printf("mapped device (%d)", adbdata.devType); break; } break; @@ -487,7 +496,7 @@ adb_init() extdms_done = 0; /* talk register 3 */ ADBOp((Ptr)buffer, (Ptr)extdms_complete, - (Ptr)&extdms_done, (adbaddr << 4) | 0xf); + (Ptr)&extdms_done, (adbaddr << 4) | 0xf); /* Wait until done, but no more than 2 secs */ count = 40000; @@ -517,19 +526,18 @@ adb_init() extdms_done = 0; /* talk register 1 */ ADBOp((Ptr)buffer, (Ptr)extdms_complete, - (Ptr)&extdms_done, - (adbaddr << 4) | 0xd); + (Ptr)&extdms_done, (adbaddr << 4) | 0xd); while (!extdms_done) /* busy-wait until done */; if (buffer[1] == 0x9a && buffer[2] == 0x20) printf("Mouseman (non-EMP) mouse"); else { - printf("extended mouse " - "<%c%c%c%c> %d-button %d dpi ", - buffer[1], buffer[2], - buffer[3], buffer[4], - (int)buffer[8], - (int)*(short *)&buffer[5]); + printf("extended mouse <%c%c%c%c> " + "%d-button %d dpi ", + buffer[1], buffer[2], + buffer[3], buffer[4], + (int)buffer[8], + (int)*(short *)&buffer[5]); if (buffer[7] == 1) printf("mouse"); else if (buffer[7] == 2) @@ -539,7 +547,8 @@ adb_init() } break; default: - printf("relative positioning device (mouse?) (%d)", adbdata.devType); + printf("relative positioning device (mouse?) " + "(%d)", adbdata.devType); break; } break; @@ -581,55 +590,57 @@ adb_init() (buffer[0] > 0) && (buffer[2] == ADBMS_MSA3)) { /* Special device handler for the A3 mouse */ adbinfo.siServiceRtPtr = (Ptr)adb_msa3_asmcomplete; - } else if ( ( adbdata.origADBAddr == ADBADDR_MAP ) && - ( adbdata.devType == ADB_EXTKBD ) && - ( buffer[1] == 0x9a ) && ( buffer[2]==0x20 ) ) { - /* ignore non-EMP Mouseman pseudo keyboard */ - adbinfo.siServiceRtPtr = (Ptr)0; - } else if ( ( adbdata.origADBAddr == ADBADDR_REL ) && - ( devtype == ADBMS_EXTENDED ) && - ( buffer[1] == 0x9a ) && ( buffer[2]==0x20 ) ) { - /* Set up non-EMP Mouseman to put button - * bits in 3rd byte instead of sending via - * pseudo keyboard device. */ - extdms_done = 0; - /* listen register 1 */ - buffer[0] = 2; - buffer[1] = 0x00; - buffer[2] = 0x81; - ADBOp((Ptr)buffer, (Ptr)extdms_complete, - (Ptr)&extdms_done, (adbaddr << 4) | 0x9); - while (!extdms_done) - /* busy-wait until done */; - extdms_done = 0; - /* listen register 1 */ - buffer[0] = 2; - buffer[1] = 0x01; - buffer[2] = 0x81; - ADBOp((Ptr)buffer, (Ptr)extdms_complete, - (Ptr)&extdms_done, (adbaddr << 4) | 0x9); - while (!extdms_done) - /* busy-wait until done */; - extdms_done = 0; - /* listen register 1 */ - buffer[0] = 2; - buffer[1] = 0x02; - buffer[2] = 0x81; - ADBOp((Ptr)buffer, (Ptr)extdms_complete, - (Ptr)&extdms_done, (adbaddr << 4) | 0x9); - while (!extdms_done) - /* busy-wait until done */; - extdms_done = 0; - /* listen register 1 */ - buffer[0] = 2; - buffer[1] = 0x03; - buffer[2] = 0x38; - ADBOp((Ptr)buffer, (Ptr)extdms_complete, - (Ptr)&extdms_done, (adbaddr << 4) | 0x9); - while (!extdms_done) - /* busy-wait until done */; - /* non-EMP Mouseman has special handler */ - adbinfo.siServiceRtPtr = (Ptr)adb_mm_nonemp_asmcomplete; + } else if ((adbdata.origADBAddr == ADBADDR_MAP) && + (adbdata.devType == ADB_EXTKBD) && + (buffer[1] == 0x9a) && (buffer[2] == 0x20)) { + /* ignore non-EMP Mouseman pseudo keyboard */ + adbinfo.siServiceRtPtr = (Ptr)0; + } else if ((adbdata.origADBAddr == ADBADDR_REL) && + (devtype == ADBMS_EXTENDED) && + (buffer[1] == 0x9a) && (buffer[2] == 0x20)) { + /* + * Set up non-EMP Mouseman to put button + * bits in 3rd byte instead of sending via + * pseudo keyboard device. + */ + extdms_done = 0; + /* listen register 1 */ + buffer[0] = 2; + buffer[1] = 0x00; + buffer[2] = 0x81; + ADBOp((Ptr)buffer, (Ptr)extdms_complete, + (Ptr)&extdms_done, (adbaddr << 4) | 0x9); + while (!extdms_done) + /* busy-wait until done */; + extdms_done = 0; + /* listen register 1 */ + buffer[0] = 2; + buffer[1] = 0x01; + buffer[2] = 0x81; + ADBOp((Ptr)buffer, (Ptr)extdms_complete, + (Ptr)&extdms_done, (adbaddr << 4) | 0x9); + while (!extdms_done) + /* busy-wait until done */; + extdms_done = 0; + /* listen register 1 */ + buffer[0] = 2; + buffer[1] = 0x02; + buffer[2] = 0x81; + ADBOp((Ptr)buffer, (Ptr)extdms_complete, + (Ptr)&extdms_done, (adbaddr << 4) | 0x9); + while (!extdms_done) + /* busy-wait until done */; + extdms_done = 0; + /* listen register 1 */ + buffer[0] = 2; + buffer[1] = 0x03; + buffer[2] = 0x38; + ADBOp((Ptr)buffer, (Ptr)extdms_complete, + (Ptr)&extdms_done, (adbaddr << 4) | 0x9); + while (!extdms_done) + /* busy-wait until done */; + /* non-EMP Mouseman has special handler */ + adbinfo.siServiceRtPtr = (Ptr)adb_mm_nonemp_asmcomplete; } else { /* Default completion routine */ adbinfo.siServiceRtPtr = (Ptr)adb_asmcomplete; diff --git a/sys/arch/mac68k/dev/adbvar.h b/sys/arch/mac68k/dev/adbvar.h index 8484489b1a21..9da4fb3d8daa 100644 --- a/sys/arch/mac68k/dev/adbvar.h +++ b/sys/arch/mac68k/dev/adbvar.h @@ -1,4 +1,4 @@ -/* $NetBSD: adbvar.h,v 1.9 1998/02/21 00:37:07 scottr Exp $ */ +/* $NetBSD: adbvar.h,v 1.10 1998/02/23 03:11:26 scottr Exp $ */ /*- * Copyright (C) 1994 Bradley A. Grantham @@ -32,11 +32,6 @@ #include -#define ADB_MAXTRACE (NBPG / sizeof(int) - 1) -extern int adb_traceq[ADB_MAXTRACE]; -extern int adb_traceq_tail; -extern int adb_traceq_len; - typedef struct adb_trace_xlate_s { int params; char *string; @@ -44,6 +39,11 @@ typedef struct adb_trace_xlate_s { extern adb_trace_xlate_t adb_trace_xlations[]; +#define ADB_MAXTRACE (NBPG / sizeof(int) - 1) +extern int adb_traceq[ADB_MAXTRACE]; +extern int adb_traceq_tail; +extern int adb_traceq_len; +extern int adb_polling; #ifdef ADB_DEBUG extern int adb_debug; #endif diff --git a/sys/arch/mac68k/dev/pm_direct.c b/sys/arch/mac68k/dev/pm_direct.c index 5da152d33805..e0d2a8cc722d 100644 --- a/sys/arch/mac68k/dev/pm_direct.c +++ b/sys/arch/mac68k/dev/pm_direct.c @@ -1,4 +1,4 @@ -/* $NetBSD: pm_direct.c,v 1.3 1998/02/21 00:37:07 scottr Exp $ */ +/* $NetBSD: pm_direct.c,v 1.4 1998/02/23 03:11:26 scottr Exp $ */ /* * Copyright (C) 1997 Takashi Hamada @@ -72,11 +72,11 @@ extern struct mac68k_machine_S mac68k_machine; #define PM_VIA_CLR_INTR() via_reg(VIA1, vIFR) = 0x90 #define PM_SET_STATE_ACKON() via_reg(VIA2, vBufB) |= 0x04 #define PM_SET_STATE_ACKOFF() via_reg(VIA2, vBufB) &= ~0x04 -#define PM_IS_ON ( 0x02 == (via_reg(VIA2, vBufB) & 0x02) ) -#define PM_IS_OFF ( 0x00 == (via_reg(VIA2, vBufB) & 0x02) ) +#define PM_IS_ON (0x02 == (via_reg(VIA2, vBufB) & 0x02)) +#define PM_IS_OFF (0x00 == (via_reg(VIA2, vBufB) & 0x02)) -/* - * Valiables for internal use +/* + * Variables for internal use */ int pmHardware = PM_HW_UNKNOWN; u_short pm_existent_ADB_devices = 0x0; /* each bit expresses the existent ADB device */ @@ -86,42 +86,74 @@ u_int pm_counter = 0; /* clock count */ /* these values shows that number of data returned after 'send' cmd is sent */ char pm_send_cmd_type[] = { - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0x01,0x01,0xff,0xff,0xff,0xff,0xff,0xff, 0x00,0x00,0xff,0xff,0xff,0xff,0xff,0x00, - 0xff,0x00,0x02,0x01,0x01,0xff,0xff,0xff, 0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0x04,0x14,0xff,0xff,0xff,0xff,0xff,0xff, 0x00,0x00,0x02,0xff,0xff,0xff,0xff,0xff, - 0x01,0x01,0xff,0xff,0xff,0xff,0xff,0xff, 0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff, - 0x01,0x00,0x02,0x02,0xff,0x01,0x03,0x01, 0x00,0x01,0x00,0x00,0x00,0xff,0xff,0xff, - 0x02,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff, - 0x01,0x01,0x01,0xff,0xff,0xff,0xff,0xff, 0x00,0x00,0xff,0xff,0xff,0xff,0x04,0x04, - 0x04,0xff,0x00,0xff,0xff,0xff,0xff,0xff, 0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0x01,0x02,0xff,0xff,0xff,0xff,0xff,0xff, 0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff, - 0x02,0x02,0x02,0x04,0xff,0x00,0xff,0xff, 0x01,0x01,0x03,0x02,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0x01,0x01,0xff,0xff,0x00,0x00,0xff,0xff, - 0xff,0x04,0x00,0xff,0xff,0xff,0xff,0xff, 0x03,0xff,0x00,0xff,0x00,0xff,0xff,0x00, - 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0x01, 0x01, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, + 0xff, 0x00, 0x02, 0x01, 0x01, 0xff, 0xff, 0xff, + 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0x04, 0x14, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0x00, 0x00, 0x02, 0xff, 0xff, 0xff, 0xff, 0xff, + 0x01, 0x01, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0x01, 0x00, 0x02, 0x02, 0xff, 0x01, 0x03, 0x01, + 0x00, 0x01, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, + 0x02, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, + 0x01, 0x01, 0x01, 0xff, 0xff, 0xff, 0xff, 0xff, + 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x04, 0x04, + 0x04, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, + 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0x01, 0x02, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0x02, 0x02, 0x02, 0x04, 0xff, 0x00, 0xff, 0xff, + 0x01, 0x01, 0x03, 0x02, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0x01, 0x01, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, + 0xff, 0x04, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, + 0x03, 0xff, 0x00, 0xff, 0x00, 0xff, 0xff, 0x00, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; /* these values shows that number of data returned after 'receive' cmd is sent */ char pm_receive_cmd_type[] = { - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x02,0x02,0xff,0xff,0xff,0xff,0xff,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x05,0x15,0xff,0xff,0xff,0xff,0xff,0xff, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x02,0x02,0xff,0xff,0xff,0xff,0xff,0xff, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x02,0x00,0x03,0x03,0xff,0xff,0xff,0xff, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x04,0x04,0x03,0x09,0xff,0xff,0xff,0xff, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0xff,0xff,0xff,0xff,0xff,0xff,0x01,0x01, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x06,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x02,0x02,0xff,0xff,0xff,0xff,0xff,0xff, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x02,0x00,0x00,0x00,0xff,0xff,0xff,0xff, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x02,0x02,0xff,0xff,0x02,0xff,0xff,0xff, - 0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00, 0xff,0xff,0x02,0xff,0xff,0xff,0xff,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x02, 0x02, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x05, 0x15, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x02, 0x02, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x02, 0x00, 0x03, 0x03, 0xff, 0xff, 0xff, 0xff, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x04, 0x04, 0x03, 0x09, 0xff, 0xff, 0xff, 0xff, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x06, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x02, 0x02, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x02, 0x02, 0xff, 0xff, 0x02, 0xff, 0xff, 0xff, + 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xff, 0xff, 0x02, 0xff, 0xff, 0xff, 0xff, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, }; @@ -131,37 +163,37 @@ char pm_receive_cmd_type[] = { /* for debugging */ #ifdef ADB_DEBUG -void pm_printerr __P(( char *, int, int, char * )); +void pm_printerr __P((char *, int, int, char *)); #endif -int pm_wait_busy __P((int)); -int pm_wait_free __P((int)); +int pm_wait_busy __P((int)); +int pm_wait_free __P((int)); /* these functions are for the PB1XX series */ -int pm_receive_pm1 __P((u_char *)); -int pm_send_pm1 __P((u_char,int)); -int pm_pmgrop_pm1 __P((PMData *)); -void pm_intr_pm1 __P((void)); +int pm_receive_pm1 __P((u_char *)); +int pm_send_pm1 __P((u_char,int)); +int pm_pmgrop_pm1 __P((PMData *)); +void pm_intr_pm1 __P((void)); /* these functions are for the PB Duo series and the PB 5XX series */ -int pm_receive_pm2 __P((u_char *)); -int pm_send_pm2 __P((u_char)); -int pm_pmgrop_pm2 __P((PMData *)); -void pm_intr_pm2 __P((void)); +int pm_receive_pm2 __P((u_char *)); +int pm_send_pm2 __P((u_char)); +int pm_pmgrop_pm2 __P((PMData *)); +void pm_intr_pm2 __P((void)); /* this function is MRG-Based (for testing) */ -int pm_pmgrop_mrg __P((PMData *)); +int pm_pmgrop_mrg __P((PMData *)); /* these functions are called from adb_direct.c */ -void pm_setup_adb __P((void)); -void pm_check_adb_devices __P((int)); -void pm_intr __P((void)); -int pm_adb_op __P((u_char *, void *, void *, int)); +void pm_setup_adb __P((void)); +void pm_check_adb_devices __P((int)); +void pm_intr __P((void)); +int pm_adb_op __P((u_char *, void *, void *, int)); /* these functions also use the variables of adb_direct.c */ -void pm_adb_get_TALK_result __P((PMData *)); -void pm_adb_get_ADB_data __P((PMData *)); -void pm_adb_poll_next_device_pm1 __P((PMData *)); +void pm_adb_get_TALK_result __P((PMData *)); +void pm_adb_get_ADB_data __P((PMData *)); +void pm_adb_poll_next_device_pm1 __P((PMData *)); /* @@ -179,8 +211,8 @@ extern int adbStarting; /* doing ADB reinit, so do "polling" differently */ /* * Define the external functions */ -extern int zshard(int); /* from zs.c */ -extern void adb_comp_exec(void); /* from adb_direct.c */ +extern int zshard __P((int)); /* from zs.c */ +extern void adb_comp_exec __P((void)); /* from adb_direct.c */ #ifdef ADB_DEBUG @@ -189,17 +221,17 @@ extern void adb_comp_exec(void); /* from adb_direct.c */ */ void pm_printerr(ttl, rval, num, data) - char *ttl; - int rval; - int num; - char *data; + char *ttl; + int rval; + int num; + char *data; { int i; - printf( "pm: %s:%04x %02x ", ttl, rval, num ); - for( i=0; icommand ) { + switch (pmdata->command) { default: - for( i=0; i<7; i++ ) { + for (i = 0; i < 7; i++) { via_reg(VIA2, vDirA) = 0x00; /* wait until PM is free */ - if (pm_wait_free( ADBDelay ) == 0) { /* timeout */ + if (pm_wait_free(ADBDelay) == 0) { /* timeout */ via_reg(VIA2, vDirA) = 0x00; /* restore formar value */ via_reg(VIA1, vDirA) = via1_vDirA; via_reg(VIA1, vIER) = via1_vIER; - return( 0xffffcd38 ); + return (0xffffcd38); } - switch( mac68k_machine.machineid ) { + switch (mac68k_machine.machineid) { case MACH_MACPB160: case MACH_MACPB165: case MACH_MACPB165C: @@ -407,26 +439,26 @@ pm_pmgrop_pm1(pmdata) int delay = ADBDelay * 16; via_reg(VIA2, vDirA) = 0x00; - while((via_reg(VIA2, 0x200) == 0x7f) && (delay >= 0)) + while ((via_reg(VIA2, 0x200) == 0x7f) && (delay >= 0)) delay--; if (delay < 0) { /* timeout */ via_reg(VIA2, vDirA) = 0x00; /* restore formar value */ via_reg(VIA1, vIER) = via1_vIER; - return( 0xffffcd38 ); + return (0xffffcd38); } } } /* end switch */ - s=splhigh(); + s = splhigh(); via1_vDirA = via_reg(VIA1, vDirA); via_reg(VIA1, vDirA) &= 0x7f; pm_cmd = (u_char)(pmdata->command & 0xff); - if ((rval = pm_send_pm1( pm_cmd, ADBDelay*8 )) == 0) /* succeeded to send PM command */ - break; + if ((rval = pm_send_pm1(pm_cmd, ADBDelay * 8)) == 0) + break; /* send command succeeded */ via_reg(VIA1, vDirA) = via1_vDirA; splx(s); @@ -438,48 +470,48 @@ pm_pmgrop_pm1(pmdata) /* restore formar value */ via_reg(VIA1, vDirA) = via1_vDirA; via_reg(VIA1, vIER) = via1_vIER; - return( 0xffffcd38 ); + return (0xffffcd38); } /* send # of PM data */ num_pm_data = pmdata->num_data; - if ((rval = pm_send_pm1( (u_char)(num_pm_data & 0xff), ADBDelay*8 )) != 0) + if ((rval = pm_send_pm1((u_char)(num_pm_data & 0xff), ADBDelay * 8)) != 0) break; /* timeout */ /* send PM data */ pm_buf = (u_char *)pmdata->s_buf; - for( i=0; icommand = pm_data; /* receive number of PM data */ - if ((rval = pm_receive_pm1( &pm_data )) != 0) - break; /* timeout */ + if ((rval = pm_receive_pm1(&pm_data)) != 0) + break; /* timeout */ num_pm_data = pm_data; pmdata->num_data = num_pm_data; /* receive PM data */ pm_buf = (u_char *)pmdata->r_buf; - for( i=0; icommand ) { + switch (pmdata->command) { default: /* wait until PM is free */ pm_cmd = (u_char)(pmdata->command & 0xff); rval = 0xcd38; - if (pm_wait_free( ADBDelay * 4 ) == 0) + if (pm_wait_free(ADBDelay * 4) == 0) break; /* timeout */ - if (HwCfgFlags3 & 0x00200000) { /* PB 160, PB 165(c), PB 180(c) ? */ - int delay = ADBDelay * 16; + if (HwCfgFlags3 & 0x00200000) { + /* PB 160, PB 165(c), PB 180(c)? */ + int delay = ADBDelay * 16; via_reg(VIA2, vDirA) = 0x00; - while((via_reg(VIA2, 0x200) == 0x07) && (delay >= 0)) + while ((via_reg(VIA2, 0x200) == 0x07) && + (delay >= 0)) delay--; if (delay < 0) { @@ -678,25 +715,25 @@ pm_pmgrop_pm2(pmdata) } /* send PM command */ - if ((rval = pm_send_pm2( (u_char)(pm_cmd & 0xff) ))) + if ((rval = pm_send_pm2((u_char)(pm_cmd & 0xff)))) break; /* timeout */ /* send number of PM data */ num_pm_data = pmdata->num_data; if (HwCfgFlags3 & 0x00020000) { /* PB Duo, PB 5XX */ if (pm_send_cmd_type[pm_cmd] < 0) { - if ((rval = pm_send_pm2( (u_char)(num_pm_data & 0xff) )) != 0) + if ((rval = pm_send_pm2((u_char)(num_pm_data & 0xff))) != 0) break; /* timeout */ pmdata->command = 0; } } else { /* PB 1XX series ? */ - if ((rval = pm_send_pm2( (u_char)(num_pm_data & 0xff) )) != 0) + if ((rval = pm_send_pm2((u_char)(num_pm_data & 0xff))) != 0) break; /* timeout */ } /* send PM data */ pm_buf = (u_char *)pmdata->s_buf; - for( i=0; icommand = pm_data; } else { /* PB 1XX series ? */ - if ((rval = pm_receive_pm2( &pm_data )) != 0) { + if ((rval = pm_receive_pm2(&pm_data)) != 0) { rval = 0xffffcd37; break; } @@ -731,14 +768,14 @@ pm_pmgrop_pm2(pmdata) /* receive number of PM data */ if (HwCfgFlags3 & 0x00020000) { /* PB Duo, PB 5XX */ if (pm_num_rx_data < 0) { - if ((rval = pm_receive_pm2( &pm_data )) != 0) + if ((rval = pm_receive_pm2(&pm_data)) != 0) break; /* timeout */ num_pm_data = pm_data; } else num_pm_data = pm_num_rx_data; pmdata->num_data = num_pm_data; } else { /* PB 1XX serias ? */ - if ((rval = pm_receive_pm2( &pm_data )) != 0) + if ((rval = pm_receive_pm2(&pm_data)) != 0) break; /* timeout */ num_pm_data = pm_data; pmdata->num_data = num_pm_data; @@ -746,8 +783,8 @@ pm_pmgrop_pm2(pmdata) /* receive PM data */ pm_buf = (u_char *)pmdata->r_buf; - for( i=0; i 0x5a) pm_LCD_brightness = 0x7f; + if (pm_LCD_brightness < 0x25) + pm_LCD_brightness = 0x25; + if (pm_LCD_brightness > 0x5a) + pm_LCD_brightness = 0x7f; pmdata.data[0] = pm_LCD_brightness; - rval = pm_pmgrop_pm2( &pmdata ); + rval = pm_pmgrop_pm2(&pmdata); break; - } - /* ADB data that were requested by TALK command */ - case 0x10: + case 0x10: /* ADB data that were requested by TALK command */ case 0x14: pm_adb_get_TALK_result(&pmdata); break; - /* ADB device event */ - case 0x16: + case 0x16: /* ADB device event */ case 0x18: case 0x1e: pm_adb_get_ADB_data(&pmdata); break; default: - { #ifdef ADB_DEBUG if (adb_debug) pm_printerr("driver does not supported this event.", pmdata.data[2], pmdata.num_data, pmdata.data); #endif - } break; } @@ -882,20 +911,16 @@ int pmgrop(pmdata) PMData *pmdata; { - switch( pmHardware ) { + switch (pmHardware) { case PM_HW_PB1XX: - { - return( pm_pmgrop_pm1(pmdata) ); + return (pm_pmgrop_pm1(pmdata)); break; - } case PM_HW_PB5XX: - { - return( pm_pmgrop_pm2(pmdata) ); + return (pm_pmgrop_pm2(pmdata)); break; - } default: -/* return( pmgrop_mrg(pmdata) ); */ - return( -1 ); + /* return (pmgrop_mrg(pmdata)); */ + return (-1); } } @@ -904,19 +929,15 @@ pmgrop(pmdata) * My PM interrupt routine */ void -pm_intr(void) +pm_intr() { - switch( pmHardware ) { + switch (pmHardware) { case PM_HW_PB1XX: - { pm_intr_pm1(); break; - } case PM_HW_PB5XX: - { pm_intr_pm2(); break; - } default: break; } @@ -934,14 +955,14 @@ pm_adb_op(buffer, compRout, data, command) void *data; int command; { - int i,len; - int s; - int rval; - int delay; - PMData pmdata; + int i, len; + int s; + int rval; + int delay; + PMData pmdata; if (adbWaiting == 1) - return( -1 ); + return (-1); s = splhigh(); via_reg(VIA1, vIER) = 0x10; @@ -966,16 +987,16 @@ pm_adb_op(buffer, compRout, data, command) if ((command & 0xc) == 0x8) { /* if the command is LISTEN, copy ADB data to PM buffer */ if ((buffer != (u_char *)0) && (buffer[0] <= 24)) { pmdata.data[2] = buffer[0]; /* number of data */ - for( i=0; idata[3] = pmdata->num_data - 2; adbInputBuffer[0] = pmdata->num_data + 1; - for( i=1; inum_data+2; i++ ) + for (i = 1; i < pmdata->num_data + 2; i++) adbInputBuffer[i] = pmdata->data[i]; if ((adbWaiting == 1) && (rx_pm_adb_cmd == adbWaitingCmd)) { if (adbStarting == 0) - adb_complete( &pmdata->data[3] , (long)0, adbWaitingCmd ); + adb_complete(&pmdata->data[3], (long)0, adbWaitingCmd); adbWaitingCmd = 0x0; adbWaiting = 0; @@ -1074,7 +1095,7 @@ pm_adb_get_ADB_data(pmdata) adbInputBuffer[0] = pmdata->num_data + 1; if (adbStarting == 0) - adb_complete( &pmdata->data[3] , (long)0, i ); + adb_complete(&pmdata->data[3], (long)0, i); } @@ -1089,7 +1110,7 @@ pm_adb_poll_next_device_pm1(pmdata) PMData tmp_pmdata; /* find another existent ADB device to poll */ - for( i=1; i<16; i++ ) { + for (i = 1; i < 16; i++) { ndid = (((pmdata->data[3] & 0xf0) >> 4) + i) & 0xf; bendid <<= ndid; if ((pm_existent_ADB_devices & bendid) != 0) @@ -1104,7 +1125,7 @@ pm_adb_poll_next_device_pm1(pmdata) tmp_pmdata.data[0] = (u_char)(ndid << 4) | 0xc; tmp_pmdata.data[1] = 0x04; /* magic spell for awaking the PM */ tmp_pmdata.data[2] = 0x00; - rval = pmgrop( &tmp_pmdata ); + rval = pmgrop(&tmp_pmdata); }