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.
This commit is contained in:
scottr 1998-02-23 03:11:26 +00:00
parent e50238f77a
commit c1a185be97
4 changed files with 377 additions and 345 deletions

View File

@ -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:

View File

@ -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;

View File

@ -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 <machine/adbsys.h>
#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

View File

@ -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; i<num; i++ )
printf( "%02x ", data[i] );
printf( "\n" );
printf("pm: %s:%04x %02x ", ttl, rval, num);
for (i = 0; i < num; i++)
printf("%02x ", data[i]);
printf("\n");
}
#endif
@ -209,7 +241,7 @@ pm_printerr(ttl, rval, num, data)
* Check the hardware type of the Power Manager
*/
void
pm_setup_adb(void)
pm_setup_adb()
{
switch (mac68k_machine.machineid) {
case MACH_MACPB140:
@ -259,14 +291,14 @@ int
pm_wait_busy(delay)
int delay;
{
while(PM_IS_ON) {
while (PM_IS_ON) {
#ifdef PM_GRAB_SI
zshard(0); /* grab any serial interrupts */
#endif
if ((--delay) < 0)
return( 1 ); /* timeout */
return (1); /* timeout */
}
return( 0 );
return (0);
}
@ -277,14 +309,14 @@ int
pm_wait_free(delay)
int delay;
{
while(PM_IS_OFF) {
while (PM_IS_OFF) {
#ifdef PM_GRAB_SI
zshard(0); /* grab any serial interrupts */
#endif
if ((--delay) < 0)
return( 0 ); /* timeout */
return (0); /* timeout */
}
return( 1 );
return (1);
}
@ -304,16 +336,16 @@ pm_receive_pm1(data)
via_reg(VIA2, vDirA) = 0x00;
switch( 1 ) {
switch (1) {
default:
if (pm_wait_busy( 0x40 ) != 0)
if (pm_wait_busy(0x40) != 0)
break; /* timeout */
PM_SET_STATE_ACKOFF();
*data = via_reg(VIA2, 0x200);
rval = 0xffffcd33;
if (pm_wait_free( 0x40 ) == 0)
if (pm_wait_free(0x40) == 0)
break; /* timeout */
rval = 0x00;
@ -323,7 +355,7 @@ pm_receive_pm1(data)
PM_SET_STATE_ACKON();
via_reg(VIA2, vDirA) = 0x00;
return( rval );
return (rval);
}
@ -336,28 +368,28 @@ pm_send_pm1(data, delay)
u_char data;
int delay;
{
int rval;
int rval;
via_reg(VIA2, vDirA) = 0xff;
via_reg(VIA2, 0x200) = data;
PM_SET_STATE_ACKOFF();
if (pm_wait_busy( 0x400 ) != 0) {
if (pm_wait_busy(0x400) != 0) {
PM_SET_STATE_ACKON();
via_reg(VIA2, vDirA) = 0x00;
return( 0xffffcd36 );
return (0xffffcd36);
}
rval = 0x0;
PM_SET_STATE_ACKON();
if (pm_wait_free( 0x40 ) == 0)
if (pm_wait_free(0x40) == 0)
rval = 0xffffcd35;
PM_SET_STATE_ACKON();
via_reg(VIA2, vDirA) = 0x00;
return( rval );
return (rval);
}
@ -368,14 +400,14 @@ int
pm_pmgrop_pm1(pmdata)
PMData *pmdata;
{
int i;
int s = 0x81815963;
u_char via1_vIER, via1_vDirA;
int rval = 0;
int num_pm_data = 0;
u_char pm_cmd;
u_char pm_data;
u_char *pm_buf;
int i;
int s = 0x81815963;
u_char via1_vIER, via1_vDirA;
int rval = 0;
int num_pm_data = 0;
u_char pm_cmd;
u_char pm_data;
u_char *pm_buf;
/* disable all inetrrupts but PM */
via1_vIER = via_reg(VIA1, vIER);
@ -383,21 +415,21 @@ pm_pmgrop_pm1(pmdata)
via1_vDirA = via_reg(VIA1, vDirA);
switch( pmdata->command ) {
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; i<num_pm_data; i++ )
if((rval = pm_send_pm1( pm_buf[i], ADBDelay*8 )) != 0)
break; /* timeout */
for (i = 0; i < num_pm_data; i++)
if ((rval = pm_send_pm1(pm_buf[i], ADBDelay * 8)) != 0)
break; /* timeout */
if ((i != num_pm_data) && (num_pm_data != 0))
break; /* timeout */
break; /* timeout */
/* Will PM IC return data? */
if ((pm_cmd & 0x08) == 0) {
rval = 0;
break; /* no returned data */
break; /* no returned data */
}
rval = 0xffffcd37;
if (pm_wait_busy( ADBDelay ) != 0)
if (pm_wait_busy(ADBDelay) != 0)
break; /* timeout */
/* receive PM command */
if ((rval = pm_receive_pm1( &pm_data )) != 0)
if ((rval = pm_receive_pm1(&pm_data)) != 0)
break;
pmdata->command = 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; i<num_pm_data; i++ ) {
if ((rval = pm_receive_pm1( &pm_data )) != 0)
for (i = 0; i < num_pm_data; i++) {
if ((rval = pm_receive_pm1(&pm_data)) != 0)
break; /* timeout */
pm_buf[i] = pm_data;
}
@ -495,7 +527,7 @@ pm_pmgrop_pm1(pmdata)
if (s != 0x81815963)
splx(s);
return( rval );
return (rval);
}
@ -503,11 +535,11 @@ pm_pmgrop_pm1(pmdata)
* My PM interrupt routine for PB100-series
*/
void
pm_intr_pm1(void)
pm_intr_pm1()
{
int s;
int rval;
PMData pmdata;
int s;
int rval;
PMData pmdata;
s = splhigh();
@ -519,7 +551,7 @@ pm_intr_pm1(void)
pmdata.data[0] = pmdata.data[1] = 0;
pmdata.s_buf = &pmdata.data[2];
pmdata.r_buf = &pmdata.data[2];
rval = pm_pmgrop_pm1( &pmdata );
rval = pm_pmgrop_pm1(&pmdata);
if (rval != 0) {
#ifdef ADB_DEBUG
if (adb_debug)
@ -529,11 +561,14 @@ pm_intr_pm1(void)
}
if ((pmdata.data[2] & 0x10) == 0x10) {
if ((pmdata.data[2] & 0x0f) == 0) { /* ADB data that were requested by TALK command */
if ((pmdata.data[2] & 0x0f) == 0) {
/* ADB data that were requested by TALK command */
pm_adb_get_TALK_result(&pmdata);
} else if ((pmdata.data[2] & 0x08) == 0x8) { /* PM is requesting to poll */
} else if ((pmdata.data[2] & 0x08) == 0x8) {
/* PM is requesting to poll */
pm_adb_poll_next_device_pm1(&pmdata);
} else if ((pmdata.data[2] & 0x04) == 0x4) { /* ADB device event */
} else if ((pmdata.data[2] & 0x04) == 0x4) {
/* ADB device event */
pm_adb_get_ADB_data(&pmdata);
}
} else {
@ -560,12 +595,12 @@ int
pm_receive_pm2(data)
u_char *data;
{
int i;
int rval;
int i;
int rval;
rval = 0xffffcd34;
switch( 1 ) {
switch (1) {
default:
/* set VIA SR to input mode */
via_reg(VIA1, vACR) |= 0x0c;
@ -590,7 +625,7 @@ pm_receive_pm2(data)
PM_SET_STATE_ACKON();
via_reg(VIA1, vACR) |= 0x1c;
return( rval );
return (rval);
}
@ -602,7 +637,7 @@ int
pm_send_pm2(data)
u_char data;
{
int rval;
int rval;
via_reg(VIA1, vACR) |= 0x1c;
PM_SR() = data;
@ -614,7 +649,7 @@ pm_send_pm2(data)
via_reg(VIA1, vACR) |= 0x1c;
return( rval );
return (rval);
}
PM_SET_STATE_ACKON();
@ -625,7 +660,7 @@ pm_send_pm2(data)
PM_SET_STATE_ACKON();
via_reg(VIA1, vACR) |= 0x1c;
return( rval );
return (rval);
}
@ -637,17 +672,17 @@ int
pm_pmgrop_pm2(pmdata)
PMData *pmdata;
{
int i;
int s;
u_char via1_vIER;
int rval = 0;
int num_pm_data = 0;
u_char pm_cmd;
short pm_num_rx_data;
u_char pm_data;
u_char *pm_buf;
int i;
int s;
u_char via1_vIER;
int rval = 0;
int num_pm_data = 0;
u_char pm_cmd;
short pm_num_rx_data;
u_char pm_data;
u_char *pm_buf;
s=splhigh();
s = splhigh();
/* disable all inetrrupts but PM */
via1_vIER = 0x10;
@ -656,19 +691,21 @@ pm_pmgrop_pm2(pmdata)
if (via1_vIER != 0x0)
via1_vIER |= 0x80;
switch( pmdata->command ) {
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; i<num_pm_data; i++ )
if((rval = pm_send_pm2( pm_buf[i] )) != 0)
for (i = 0 ; i < num_pm_data; i++)
if ((rval = pm_send_pm2(pm_buf[i])) != 0)
break; /* timeout */
if (i != num_pm_data)
break; /* timeout */
@ -715,13 +752,13 @@ pm_pmgrop_pm2(pmdata)
if (HwCfgFlags3 & 0x00020000) { /* PB Duo, PB 5XX */
pm_num_rx_data--;
if (pm_num_rx_data == 0)
if ((rval = pm_receive_pm2( &pm_data )) != 0) {
if ((rval = pm_receive_pm2(&pm_data)) != 0) {
rval = 0xffffcd37;
break;
}
pmdata->command = 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<num_pm_data; i++ ) {
if ((rval = pm_receive_pm2( &pm_data )) != 0)
for (i = 0; i < num_pm_data; i++) {
if ((rval = pm_receive_pm2(&pm_data)) != 0)
break; /* timeout */
pm_buf[i] = pm_data;
}
@ -759,7 +796,7 @@ pm_pmgrop_pm2(pmdata)
via_reg(VIA1, vIER) = via1_vIER;
splx(s);
return( rval );
return (rval);
}
@ -767,21 +804,21 @@ pm_pmgrop_pm2(pmdata)
* My PM interrupt routine for the PB Duo series and the PB 5XX series
*/
void
pm_intr_pm2(void)
pm_intr_pm2()
{
int s;
int rval;
PMData pmdata;
int s;
int rval;
PMData pmdata;
s = splhigh();
PM_VIA_CLR_INTR(); /* clear VIA1 interrupt */
/* ask PM what happend */
PM_VIA_CLR_INTR(); /* clear VIA1 interrupt */
/* ask PM what happend */
pmdata.command = 0x78;
pmdata.num_data = 0;
pmdata.s_buf = &pmdata.data[2];
pmdata.r_buf = &pmdata.data[2];
rval = pm_pmgrop_pm2( &pmdata );
rval = pm_pmgrop_pm2(&pmdata);
if (rval != 0) {
#ifdef ADB_DEBUG
if (adb_debug)
@ -790,30 +827,25 @@ pm_intr_pm2(void)
splx(s);
}
switch( (u_int)(pmdata.data[2] & 0xff) ) {
case 0x00: /* 1 sec interrupt? */
{
switch ((u_int)(pmdata.data[2] & 0xff)) {
case 0x00: /* 1 sec interrupt? */
break;
}
case 0x80: /* 1 sec interrupt? */
{
case 0x80: /* 1 sec interrupt? */
pm_counter++;
break;
}
case 0x08: /* Brightness/Contrast button on LCD panel */
{
case 0x08: /* Brightness/Contrast button on LCD panel */
/* get brightness and contrast of the LCD */
pm_LCD_brightness = (u_int)pmdata.data[3] & 0xff;
pm_LCD_contrast = (u_int)pmdata.data[4] & 0xff;
/*
pm_printerr( "#08", rval, pmdata.num_data, pmdata.data );
pm_printerr("#08", rval, pmdata.num_data, pmdata.data);
pmdata.command = 0x33;
pmdata.num_data = 1;
pmdata.s_buf = pmdata.data;
pmdata.r_buf = pmdata.data;
pmdata.data[0] = pm_LCD_contrast;
rval = pm_pmgrop_pm2( &pmdata );
pm_printerr( "#33", rval, pmdata.num_data, pmdata.data );
rval = pm_pmgrop_pm2(&pmdata);
pm_printerr("#33", rval, pmdata.num_data, pmdata.data);
*/
/* this is an experimental code */
pmdata.command = 0x41;
@ -821,32 +853,29 @@ pm_intr_pm2(void)
pmdata.s_buf = pmdata.data;
pmdata.r_buf = pmdata.data;
pm_LCD_brightness = 0x7f - pm_LCD_brightness / 2;
if (pm_LCD_brightness < 0x25) pm_LCD_brightness = 0x25;
if (pm_LCD_brightness > 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; i<buffer[0]; i++ )
for (i = 0; i < buffer[0]; i++)
pmdata.data[3 + i] = buffer[1 + i];
} else
pmdata.data[2] = 0;
} else
pmdata.data[2] = 0;
rval = pmgrop( &pmdata );
rval = pmgrop(&pmdata);
if (rval != 0)
return( -1 );
return (-1);
if (adbWaiting == 0) {
adbWaiting = 1;
@ -986,14 +1007,14 @@ pm_adb_op(buffer, compRout, data, command)
/* wait until the PM interrupt is occured */
delay = 0x80000;
while(adbWaiting == 1) {
while (adbWaiting == 1) {
if ((via_reg(VIA1, vIFR) & 0x10) == 0x10)
pm_intr();
#ifdef PM_GRAB_SI
zshard(0); /* grab any serial interrupts */
#endif
if ((--delay) < 0)
return( -1 );
return (-1);
}
if (buffer != (u_char *)0) {
@ -1004,7 +1025,7 @@ pm_adb_op(buffer, compRout, data, command)
buffer[0] = 0;
}
/* this command enables the interrupt by operating ADB devices */
/* this command enables the interrupt by operating ADB devices */
if (HwCfgFlags3 & 0x00020000) { /* PB Duo series, PB 500 series */
pmdata.command = 0x20;
pmdata.num_data = 4;
@ -1023,10 +1044,10 @@ pm_adb_op(buffer, compRout, data, command)
pmdata.data[1] = 0x04;
pmdata.data[2] = 0x00;
}
rval = pmgrop( &pmdata );
rval = pmgrop(&pmdata);
splx(s);
return( rval );
return (rval);
}
@ -1044,12 +1065,12 @@ pm_adb_get_TALK_result(pmdata)
pmdata->data[3] = pmdata->num_data - 2;
adbInputBuffer[0] = pmdata->num_data + 1;
for( i=1; i<pmdata->num_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);
}