First pass of KNFication. Needs more.

This commit is contained in:
briggs 1995-04-21 02:47:35 +00:00
parent 6a233c363c
commit 13efb6c197
23 changed files with 4647 additions and 4826 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
/* $NetBSD: adb.c,v 1.1 1994/12/03 23:34:12 briggs Exp $ */
/* $NetBSD: adb.c,v 1.2 1995/04/21 02:47:41 briggs Exp $ */
/*-
* Copyright (C) 1994 Bradley A. Grantham
@ -10,7 +10,7 @@
* 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
e* 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:
@ -30,126 +30,118 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/types.h>
#include <sys/param.h>
#include <machine/param.h>
#include <sys/device.h>
#include <sys/fcntl.h>
#include <sys/select.h>
#include <sys/proc.h>
#include <sys/systm.h>
#include <machine/adbsys.h>
#include "adbvar.h"
#include <machine/keyboard.h>
#include "adbvar.h"
#include "../mac68k/macrom.h"
/*
* External keyboard translation matrix
* Function declarations.
*/
static void adbattach __P((struct device *parent, struct device *dev, void *aux));
/*
* Global variables.
*/
int adb_polling = 0; /* Are we polling? (Debugger mode) */
/*
* Local variables.
*/
/* External keyboard translation matrix */
extern unsigned char keyboard[128][3];
/*
* Event queue definitions
*/
/* Event queue definitions */
#if !defined(ADB_MAX_EVENTS)
#define ADB_MAX_EVENTS 200 /* Maximum events to be kept in queue */
#endif /* !defined(ADB_MAX_EVENTS) */
/* maybe should be higher for slower macs? */
/* maybe should be higher for slower macs? */
#endif /* !defined(ADB_MAX_EVENTS) */
static adb_event_t adb_evq[ADB_MAX_EVENTS]; /* ADB event queue */
static int adb_evq_tail = 0; /* event queue tail */
static int adb_evq_len = 0; /* event queue length */
static int adb_evq_tail = 0; /* event queue tail */
static int adb_evq_len = 0; /* event queue length */
/*
* ADB device state information
*/
/* ADB device state information */
static int adb_isopen = 0; /* Are we queuing events for adb_read? */
int adb_polling = 0; /* Are we polling? (Debugger mode) */
static struct selinfo adb_selinfo; /* select() info */
static struct proc *adb_ioproc = NULL; /* process to wakeup */
/* Key repeat parameters */
static int adb_rptdelay = 20; /* ticks before auto-repeat */
static int adb_rptinterval = 6; /* ticks between auto-repeat */
static int adb_repeating = -1; /* key that is auto-repeating */
static adb_event_t adb_rptevent;/* event to auto-repeat */
/*
* Key repeat parameters
*/
static int adb_rptdelay = 20; /* ticks before auto-repeat */
static int adb_rptinterval = 6; /* ticks between auto-repeat */
static int adb_repeating = -1; /* key that is auto-repeating */
static adb_event_t adb_rptevent; /* event to auto-repeat */
extern int matchbyname();
/* Driver definition. */
struct cfdriver adbcd = {
NULL, "adb", matchbyname, adbattach, DV_DULL, sizeof(struct device),
};
static void
adbattach(parent, dev, aux)
struct device *parent, *dev;
void *aux;
struct device *parent, *dev;
void *aux;
{
printf(" (ADB event device)\n");
}
/*
* Auto-configure parameters
*/
extern int matchbyname();
struct cfdriver adbcd =
{ NULL,
"adb",
matchbyname,
adbattach,
DV_DULL,
sizeof(struct device),
NULL,
0 };
void adb_enqevent(
adb_event_t *event)
void
adb_enqevent(event)
adb_event_t *event;
{
int s;
int s;
if(adb_evq_tail < 0 || adb_evq_tail >= ADB_MAX_EVENTS)
if (adb_evq_tail < 0 || adb_evq_tail >= ADB_MAX_EVENTS)
panic("adb: event queue tail is out of bounds");
if(adb_evq_len < 0 || adb_evq_len > ADB_MAX_EVENTS)
if (adb_evq_len < 0 || adb_evq_len > ADB_MAX_EVENTS)
panic("adb: event queue len is out of bounds");
s = splhigh();
if(adb_evq_len == ADB_MAX_EVENTS){
if (adb_evq_len == ADB_MAX_EVENTS) {
splx(s);
return; /* Oh, well... */
return; /* Oh, well... */
}
adb_evq[(adb_evq_len + adb_evq_tail) % ADB_MAX_EVENTS] =
*event;
*event;
adb_evq_len++;
selwakeup(&adb_selinfo);
if(adb_ioproc)
if (adb_ioproc)
psignal(adb_ioproc, SIGIO);
splx(s);
}
void adb_handoff(
adb_event_t *event)
void
adb_handoff(event)
adb_event_t *event;
{
if(adb_isopen && !adb_polling){
if (adb_isopen && !adb_polling) {
adb_enqevent(event);
}else{
if(event->def_addr == 2)
} else {
if (event->def_addr == 2)
ite_intr(event);
}
}
void adb_autorepeat(
void *keyp)
void
adb_autorepeat(keyp)
void *keyp;
{
int key = (int)keyp;
int key = (int) keyp;
adb_rptevent.bytes[0] |= 0x80;
microtime(&adb_rptevent.timestamp);
@ -158,37 +150,37 @@ void adb_autorepeat(
adb_rptevent.bytes[0] &= 0x7f;
microtime(&adb_rptevent.timestamp);
adb_handoff(&adb_rptevent); /* do key down */
if(adb_repeating == key){
if (adb_repeating == key) {
timeout(adb_autorepeat, keyp, adb_rptinterval);
}
}
void adb_dokeyupdown(
adb_event_t *event)
void
adb_dokeyupdown(event)
adb_event_t *event;
{
int adb_key;
int adb_key;
if(event->def_addr == 2){
if (event->def_addr == 2) {
adb_key = event->u.k.key & 0x7f;
if(!(event->u.k.key & 0x80) &&
keyboard[event->u.k.key & 0x7f][0] != 0)
{
if (!(event->u.k.key & 0x80) &&
keyboard[event->u.k.key & 0x7f][0] != 0) {
/* ignore shift & control */
if(adb_repeating != -1){
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);
}else{
if(adb_repeating != -1){
(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;
}
@ -196,19 +188,21 @@ void adb_dokeyupdown(
adb_handoff(event);
}
static adb_ms_buttons = 0;
static adb_ms_buttons = 0;
void adb_keymaybemouse(
adb_event_t *event)
void
adb_keymaybemouse(event)
adb_event_t *event;
{
static int optionkey_down = 0;
adb_event_t new_event;
static optionkey_down = 0;
if(event->u.k.key == ADBK_KEYDOWN(ADBK_OPTION)){
if (event->u.k.key == ADBK_KEYDOWN(ADBK_OPTION)) {
optionkey_down = 1;
}else if(event->u.k.key == ADBK_KEYUP(ADBK_OPTION)){ /* keyup */
} else if (event->u.k.key == ADBK_KEYUP(ADBK_OPTION)) {
/* key up */
optionkey_down = 0;
if(adb_ms_buttons & 0xfe){
if (adb_ms_buttons & 0xfe) {
adb_ms_buttons &= 1;
new_event.def_addr = ADBADDR_MS;
new_event.u.m.buttons = adb_ms_buttons;
@ -216,130 +210,130 @@ void adb_keymaybemouse(
microtime(&new_event.timestamp);
adb_dokeyupdown(&new_event);
}
}else if(optionkey_down){
if(event->u.k.key == ADBK_KEYDOWN(ADBK_LEFT)){
} else if (optionkey_down) {
if (event->u.k.key == ADBK_KEYDOWN(ADBK_LEFT)) {
adb_ms_buttons |= 2; /* middle down */
new_event.def_addr = ADBADDR_MS;
new_event.u.m.buttons = adb_ms_buttons;
new_event.u.m.dx = new_event.u.m.dy = 0;
microtime(&new_event.timestamp);
adb_dokeyupdown(&new_event);
}else if(event->u.k.key == ADBK_KEYUP(ADBK_LEFT)){
} else if (event->u.k.key == ADBK_KEYUP(ADBK_LEFT)) {
adb_ms_buttons &= ~2; /* middle up */
new_event.def_addr = ADBADDR_MS;
new_event.u.m.buttons = adb_ms_buttons;
new_event.u.m.dx = new_event.u.m.dy = 0;
microtime(&new_event.timestamp);
adb_dokeyupdown(&new_event);
}else if(event->u.k.key == ADBK_KEYDOWN(ADBK_RIGHT)){
} else if (event->u.k.key == ADBK_KEYDOWN(ADBK_RIGHT)) {
adb_ms_buttons |= 4; /* right down */
new_event.def_addr = ADBADDR_MS;
new_event.u.m.buttons = adb_ms_buttons;
new_event.u.m.dx = new_event.u.m.dy = 0;
microtime(&new_event.timestamp);
adb_dokeyupdown(&new_event);
}else if(event->u.k.key == ADBK_KEYUP(ADBK_RIGHT)){
} else if (event->u.k.key == ADBK_KEYUP(ADBK_RIGHT)) {
adb_ms_buttons &= ~4; /* right up */
new_event.def_addr = ADBADDR_MS;
new_event.u.m.buttons = adb_ms_buttons;
new_event.u.m.dx = new_event.u.m.dy = 0;
microtime(&new_event.timestamp);
adb_dokeyupdown(&new_event);
}else if(ADBK_MODIFIER(event->u.k.key)){ /* ctrl, shift, cmd */
} else if (ADBK_MODIFIER(event->u.k.key)) {
/* ctrl, shift, cmd */
adb_dokeyupdown(event);
}else if(event->u.k.key & 0x80){ /* key down */
} else if (event->u.k.key & 0x80) {
/* key down */
new_event = *event;
new_event.u.k.key = ADBK_KEYDOWN(ADBK_OPTION); /* send option-down */
/* send option-down */
new_event.u.k.key = ADBK_KEYDOWN(ADBK_OPTION);
new_event.bytes[0] = new_event.u.k.key;
microtime(&new_event.timestamp);
adb_dokeyupdown(&new_event);
new_event.u.k.key = event->bytes[0]; /* send key-down */
/* send key-down */
new_event.u.k.key = event->bytes[0];
new_event.bytes[0] = new_event.u.k.key;
microtime(&new_event.timestamp);
adb_dokeyupdown(&new_event);
new_event.u.k.key = ADBK_KEYVAL(event->bytes[0]); /* send key-up */
/* send key-up */
new_event.u.k.key = ADBK_KEYVAL(event->bytes[0]);
adb_dokeyupdown(&new_event);
microtime(&new_event.timestamp);
new_event.bytes[0] = new_event.u.k.key;
new_event.u.k.key = ADBK_OPTION; /* send option-up */
/* send option-up */
new_event.u.k.key = ADBK_OPTION;
new_event.bytes[0] = new_event.u.k.key;
microtime(&new_event.timestamp);
adb_dokeyupdown(&new_event);
}else{
/* option-keyup -- do nothing */
} else {
/* option-keyup -- do nothing. */
}
}else{
} else {
adb_dokeyupdown(event);
}
}
void adb_processevent(
adb_event_t *event)
void
adb_processevent(event)
adb_event_t *event;
{
adb_event_t new_event;
new_event = *event;
switch(event->def_addr){
case ADBADDR_KBD:
new_event.u.k.key = event->bytes[0];
switch (event->def_addr) {
case ADBADDR_KBD:
new_event.u.k.key = event->bytes[0];
new_event.bytes[1] = 0xff;
adb_keymaybemouse(&new_event);
if (event->bytes[1] != 0xff) {
new_event.u.k.key = event->bytes[1];
new_event.bytes[0] = event->bytes[1];
new_event.bytes[1] = 0xff;
adb_keymaybemouse(&new_event);
if(event->bytes[1] != 0xff){
new_event.u.k.key = event->bytes[1];
new_event.bytes[0] = event->bytes[1];
new_event.bytes[1] = 0xff;
adb_keymaybemouse(&new_event);
}
break;
case ADBADDR_MS:
if(! (event->bytes[0] & 0x80)) /* 0 is button down */
adb_ms_buttons |= 1;
else
adb_ms_buttons &= 0xfe;
new_event.u.m.buttons = adb_ms_buttons;
new_event.u.m.dx = ((signed int)(event->bytes[1] &
0x3f)) - ((event->bytes[1] &
0x40) ? 64 : 0);
new_event.u.m.dy = ((signed int)(event->bytes[0] &
0x3f)) - ((event->bytes[0] &
0x40) ? 64 : 0);
adb_dokeyupdown(&new_event);
break;
default: /* God only knows. */
adb_dokeyupdown(event);
}
break;
case ADBADDR_MS:
if (!(event->bytes[0] & 0x80)) /* 0 is button down */
adb_ms_buttons |= 1;
else
adb_ms_buttons &= 0xfe;
new_event.u.m.buttons = adb_ms_buttons;
new_event.u.m.dx = ((signed int) (event->bytes[1] & 0x3f)) -
((event->bytes[1] & 0x40) ? 64 : 0);
new_event.u.m.dy = ((signed int) (event->bytes[0] & 0x3f)) -
((event->bytes[0] & 0x40) ? 64 : 0);
adb_dokeyupdown(&new_event);
break;
default: /* God only knows. */
adb_dokeyupdown(event);
}
}
int adbopen(
dev_t dev,
int flag,
int mode,
struct proc *p)
int
adbopen(dev, flag, mode, p)
dev_t dev;
int flag, mode;
struct proc *p;
{
register int unit;
int error = 0;
int s;
unit = minor(dev);
if(unit != 0)
return(ENXIO);
if (unit != 0)
return (ENXIO);
s = splhigh();
if (adb_isopen)
{
if (adb_isopen) {
splx(s);
return(EBUSY);
return (EBUSY);
}
splx(s);
adb_evq_tail = 0;
@ -351,11 +345,11 @@ int adbopen(
}
int adbclose(
dev_t dev,
int flag,
int mode,
struct proc *p)
int
adbclose(dev, flag, mode, p)
dev_t dev;
int flag, mode;
struct proc *p;
{
adb_isopen = 0;
adb_ioproc = NULL;
@ -363,10 +357,11 @@ int adbclose(
}
int adbread(
dev_t dev,
struct uio *uio,
int flag)
int
adbread(dev, uio, flag)
dev_t dev;
struct uio *uio;
int flag;
{
int s, error;
int willfit;
@ -378,130 +373,135 @@ int adbread(
return (EMSGSIZE); /* close enough. */
s = splhigh();
if(adb_evq_len == 0){
splx(s);
return(0);
if (adb_evq_len == 0) {
splx(s);
return (0);
}
willfit = howmany(uio->uio_resid, sizeof(adb_event_t));
total = (adb_evq_len < willfit) ? adb_evq_len : willfit;
firstmove = (adb_evq_tail + total > ADB_MAX_EVENTS)
? (ADB_MAX_EVENTS - adb_evq_tail) : total;
error = uiomove((caddr_t)&adb_evq[adb_evq_tail],
firstmove * sizeof(adb_event_t), uio);
if(error) {
? (ADB_MAX_EVENTS - adb_evq_tail) : total;
error = uiomove((caddr_t) & adb_evq[adb_evq_tail],
firstmove * sizeof(adb_event_t), uio);
if (error) {
splx(s);
return(error);
return (error);
}
moremove = total - firstmove;
if (moremove > 0){
error = uiomove((caddr_t)&adb_evq[0],
moremove * sizeof(adb_event_t), uio);
if(error) {
if (moremove > 0) {
error = uiomove((caddr_t) & adb_evq[0],
moremove * sizeof(adb_event_t), uio);
if (error) {
splx(s);
return(error);
return (error);
}
}
adb_evq_tail = (adb_evq_tail + total) % ADB_MAX_EVENTS;
adb_evq_len -= total;
splx(s);
return (0);
}
int adbwrite(
dev_t dev,
struct uio *uio,
int flag)
int
adbwrite(dev, uio, flag)
dev_t dev;
struct uio *uio;
int flag;
{
return 0;
}
int adbioctl(
dev_t dev,
int cmd,
caddr_t data,
int flag,
struct proc *p)
int
adbioctl(dev, cmd, data, flag, p)
dev_t dev;
int cmd;
caddr_t data;
int flag;
struct proc *p;
{
switch(cmd){
case ADBIOC_DEVSINFO: {
adb_devinfo_t *di = (void *)data;
int totaldevs;
ADBDataBlock adbdata;
int adbaddr;
int i;
switch (cmd) {
case ADBIOC_DEVSINFO: {
adb_devinfo_t *di;
ADBDataBlock adbdata;
int totaldevs;
int adbaddr;
int i;
/* Initialize to no devices */
for(i = 0; i < 16; i++)
di->dev[i].addr = -1;
di = (void *) data;
totaldevs = CountADBs();
for(i = 1; i <= totaldevs; i++){
adbaddr = GetIndADB(&adbdata, i);
di->dev[adbaddr].addr = adbaddr;
di->dev[adbaddr].default_addr =
adbdata.origADBAddr;
di->dev[adbaddr].handler_id =
adbdata.devType;
/* Initialize to no devices */
for (i = 0; i < 16; i++)
di->dev[i].addr = -1;
totaldevs = CountADBs();
for (i = 1; i <= totaldevs; i++) {
adbaddr = GetIndADB(&adbdata, i);
di->dev[adbaddr].addr = adbaddr;
di->dev[adbaddr].default_addr = adbdata.origADBAddr;
di->dev[adbaddr].handler_id = adbdata.devType;
}
/* Must call ADB Manager to get devices now */
break;
}
case ADBIOC_GETREPEAT:{
adb_rptinfo_t *ri = (void *)data;
ri->delay_ticks = adb_rptdelay;
ri->interval_ticks = adb_rptinterval;
break;
}
case ADBIOC_SETREPEAT:{
adb_rptinfo_t *ri = (void *)data;
adb_rptdelay = ri->delay_ticks;
adb_rptinterval = ri->interval_ticks;
break;
}
case ADBIOC_RESET:
adb_init();
break;
case ADBIOC_LISTENCMD:{
adb_listencmd_t *lc = (void *)data;
}
default:
return(EINVAL);
/* Must call ADB Manager to get devices now */
break;
}
return(0);
case ADBIOC_GETREPEAT:{
adb_rptinfo_t *ri;
ri = (void *) data;
ri->delay_ticks = adb_rptdelay;
ri->interval_ticks = adb_rptinterval;
break;
}
case ADBIOC_SETREPEAT:{
adb_rptinfo_t *ri;
ri = (void *) data;
adb_rptdelay = ri->delay_ticks;
adb_rptinterval = ri->interval_ticks;
break;
}
case ADBIOC_RESET:
adb_init();
break;
case ADBIOC_LISTENCMD:{
adb_listencmd_t *lc;
lc = (void *) data;
}
default:
return (EINVAL);
}
return (0);
}
int adbselect(
dev_t dev,
int rw,
struct proc *p)
int
adbselect(dev, rw, p)
dev_t dev;
int rw;
struct proc *p;
{
switch (rw) {
case FREAD:
/* succeed if there is something to read */
if (adb_evq_len > 0)
return (1);
selrecord(p, &adb_selinfo);
break;
case FREAD:
/* succeed if there is something to read */
if (adb_evq_len > 0)
return (1);
selrecord(p, &adb_selinfo);
break;
case FWRITE:
return (1); /* always fails => never blocks */
break;
case FWRITE:
return (1); /* always fails => never blocks */
break;
}
return (0);

View File

@ -1,4 +1,4 @@
/* $NetBSD: adbsys.c,v 1.8 1994/12/03 23:34:13 briggs Exp $ */
/* $NetBSD: adbsys.c,v 1.9 1995/04/21 02:47:42 briggs Exp $ */
/*-
* Copyright (C) 1994 Bradley A. Grantham
@ -30,41 +30,36 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/types.h>
#include <sys/param.h>
#include <machine/param.h>
#include "../mac68k/via.h"
#include <machine/adbsys.h>
#include "adbvar.h"
#include "../mac68k/via.h"
#include "../mac68k/macrom.h"
/* from adb.c */
void adb_processevent(adb_event_t *event);
/* from adb.c */
void adb_processevent(adb_event_t * event);
extern void adb_jadbproc(void);
void adb_complete(
caddr_t buffer,
caddr_t data_area, /* ignore */
int adb_command)
void
adb_complete(buffer, data_area, adb_command)
caddr_t buffer;
caddr_t data_area;
int adb_command;
{
int adbaddr;
adb_event_t event;
ADBDataBlock adbdata;
int error;
register int i;
register char *sbuf, *dbuf;
register int i;
register char *sbuf, *dbuf;
adb_event_t event;
ADBDataBlock adbdata;
int adbaddr;
int error;
#if defined(MRG_DEBUG)
printf("adb: transaction completion\n");
#endif
adbaddr = (adb_command & 0xf0)>> 4;
adbaddr = (adb_command & 0xf0) >> 4;
error = GetADBInfo(&adbdata, adbaddr);
#if defined(MRG_DEBUG)
printf("adb: GetADBInfo returned %d\n", error);
@ -76,7 +71,7 @@ void adb_complete(
#if defined(MRG_DEBUG)
printf("adb: from %d at %d (org %d) %d:", event.addr,
event.hand_id, event.def_addr, buffer[0]);
for(i = 1; i <= buffer[0]; i++)
for (i = 1; i <= buffer[0]; i++)
printf(" %x", buffer[i]);
printf("\n");
#endif
@ -84,7 +79,7 @@ void adb_complete(
i = event.byte_count = buffer[0];
sbuf = &buffer[1];
dbuf = &event.bytes[0];
while(i--)
while (i--)
*dbuf++ = *sbuf++;
microtime(&event.timestamp);
@ -92,38 +87,34 @@ void adb_complete(
adb_processevent(&event);
}
void adb_init()
void
adb_init()
{
int i;
int totaladbs;
int adbindex;
int adbaddr;
ADBDataBlock adbdata;
ADBSetInfoBlock adbinfo;
int s;
int i, s;
int totaladbs;
int adbindex, adbaddr;
int error;
if(!mrg_romready()){
if (!mrg_romready()) {
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
/* s = splhigh(); */
mrg_initadbintr(); /* Mac ROM Glue okay to do ROM intr */
#if defined(MRG_DEBUG)
printf("adb: returned from mrg_initadbintr\n");
#endif
/* ADBReInit pre/post-processing */
/* ADBReInit pre/post-processing */
JADBProc = adb_jadbproc;
/* Initialize ADB */
/* Initialize ADB */
#if defined(MRG_DEBUG)
printf("adb: calling ADBReInit\n");
#endif
@ -134,57 +125,57 @@ void adb_init()
printf("adb: done with ADBReInit\n");
#endif
totaladbs = CountADBs();
/* for each ADB device */
for(adbindex = 1; adbindex <= totaladbs ; adbindex++){
/* Get the ADB information */
/* for each ADB device */
for (adbindex = 1; adbindex <= totaladbs; adbindex++) {
/* Get the ADB information */
adbaddr = GetIndADB(&adbdata, adbindex);
/* Print out the glory */
/* Print out the glory */
printf("adb: ");
switch(adbdata.origADBAddr){
switch (adbdata.origADBAddr) {
case 2:
switch (adbdata.devType) {
case 1:
printf("keyboard");
break;
case 2:
switch(adbdata.devType){
case 1:
printf("keyboard");
break;
case 2:
printf("extended keyboard");
break;
case 12:
printf("PowerBook keyboard");
break;
default:
printf("mapped device (%d)",
adbdata.devType);
break;
}
printf("extended keyboard");
break;
case 3:
switch(adbdata.devType){
case 1:
printf("100 dpi mouse");
break;
case 2:
printf("200 dpi mouse");
break;
default:
printf("relative positioning device (mouse?) (%d)", adbdata.devType);
break;
}
break;
case 4:
printf("absolute positioning device (tablet?) (%d)", adbdata.devType);
case 12:
printf("PowerBook keyboard");
break;
default:
printf("unknown type device, (def %d, handler %d)", adbdata.origADBAddr,
adbdata.devType);
printf("mapped device (%d)",
adbdata.devType);
break;
}
break;
case 3:
switch (adbdata.devType) {
case 1:
printf("100 dpi mouse");
break;
case 2:
printf("200 dpi mouse");
break;
default:
printf("relative positioning device (mouse?) (%d)", adbdata.devType);
break;
}
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;
}
printf(" at %d\n", adbaddr);
/* Set completion routine to be MacBSD's */
/* Set completion routine to be MacBSD's */
adbinfo.siServiceRtPtr = adb_asmcomplete;
adbinfo.siDataAreaAddr = NULL;
error = SetADBInfo(&adbinfo, adbaddr);
@ -192,6 +183,4 @@ printf("unknown type device, (def %d, handler %d)", adbdata.origADBAddr,
printf("returned %d from SetADBInfo\n", error);
#endif
}
/* splx(s); /* allow interrupts to go on */
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: adbvar.h,v 1.1 1994/12/03 23:34:15 briggs Exp $ */
/* $NetBSD: adbvar.h,v 1.2 1995/04/21 02:47:44 briggs Exp $ */
/*-
* Copyright (C) 1994 Bradley A. Grantham
@ -35,12 +35,10 @@ 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;
} adb_trace_xlate_t;
typedef struct adb_trace_xlate_s {
int params;
char *string;
} adb_trace_xlate_t;
extern adb_trace_xlate_t adb_trace_xlations[];
void adb_asmcomplete();
void adb_asmcomplete();

View File

@ -1,4 +1,4 @@
/* $NetBSD: asc.c,v 1.6 1994/10/26 08:46:02 cgd Exp $ */
/* $NetBSD: asc.c,v 1.7 1995/04/21 02:47:45 briggs Exp $ */
/*-
* Copyright (C) 1993 Allen K. Briggs, Chris P. Caputo,
@ -47,7 +47,7 @@
/* Global ASC location */
volatile unsigned char *ASCBase = (unsigned char *)0x14000;
volatile unsigned char *ASCBase = (unsigned char *) 0x14000;
/* bell support data */
@ -56,19 +56,19 @@ static int bell_length = 10;
static int bell_volume = 100;
static int bell_ringing = 0;
static int ascprobe(struct device *, struct cfdata *, void *);
static void ascattach(struct device *, struct device *, void *);
extern int matchbyname(struct device *, struct cfdata *, void *);
static int ascprobe(struct device *, struct cfdata *, void *);
static void ascattach(struct device *, struct device *, void *);
extern int matchbyname(struct device *, struct cfdata *, void *);
struct cfdriver asccd =
{ NULL, "asc", matchbyname, ascattach,
DV_DULL, sizeof(struct device), NULL, 0 };
{NULL, "asc", matchbyname, ascattach,
DV_DULL, sizeof(struct device), NULL, 0};
static int
ascprobe(parent, cf, aux)
struct device *parent;
struct cfdata *cf;
void *aux;
struct device *parent;
struct cfdata *cf;
void *aux;
{
if (strcmp(*((char **) aux), asccd.cd_name))
return 0;
@ -79,106 +79,110 @@ ascprobe(parent, cf, aux)
static void
ascattach(parent, dev, aux)
struct device *parent, *dev;
void *aux;
struct device *parent, *dev;
void *aux;
{
printf(" Apple sound chip.\n");
ASCBase = IOBase + ASCBase;
}
int asc_setbellparams(
int freq,
int length,
int volume)
int
asc_setbellparams(
int freq,
int length,
int volume)
{
/* I only perform these checks for sanity. */
/* I suppose someone might want a bell that rings */
/* all day, but then the can make kernel mods themselves. */
if(freq < 10 || freq > 40000)
return(EINVAL);
if(length < 0 || length > 3600)
return(EINVAL);
if(volume < 0 || volume > 100)
return(EINVAL);
if (freq < 10 || freq > 40000)
return (EINVAL);
if (length < 0 || length > 3600)
return (EINVAL);
if (volume < 0 || volume > 100)
return (EINVAL);
bell_freq = freq;
bell_length = length;
bell_volume = volume;
return(0);
return (0);
}
int asc_getbellparams(
int *freq,
int *length,
int *volume)
int
asc_getbellparams(
int *freq,
int *length,
int *volume)
{
*freq = bell_freq;
*length = bell_length;
*volume = bell_volume;
return(0);
return (0);
}
void asc_bellstop(
int param)
void
asc_bellstop(
int param)
{
if(bell_ringing > 1000 || bell_ringing < 0)
if (bell_ringing > 1000 || bell_ringing < 0)
panic("bell got out of synch?????");
if(--bell_ringing == 0){
if (--bell_ringing == 0) {
ASCBase[0x801] = 0;
}
/* disable ASC */
}
int asc_ringbell()
int
asc_ringbell()
{
int i;
int i;
unsigned long freq;
if(bell_ringing == 0){
for(i = 0; i < 0x800; i++)
if (bell_ringing == 0) {
for (i = 0; i < 0x800; i++)
ASCBase[i] = 0;
for(i = 0; i < 256;i++){
for (i = 0; i < 256; i++) {
ASCBase[i] = i / 4;
ASCBase[i + 512] = i / 4;
ASCBase[i + 1024] = i / 4;
ASCBase[i + 1536] = i / 4;
}/* up part of wave, four voices ? */
for(i = 0; i < 256;i++){
} /* up part of wave, four voices ? */
for (i = 0; i < 256; i++) {
ASCBase[i + 256] = 0x3f - (i / 4);
ASCBase[i + 768] = 0x3f - (i / 4);
ASCBase[i + 1280] = 0x3f - (i / 4);
ASCBase[i + 1792] = 0x3f - (i / 4);
}/* down part of wave, four voices ? */
} /* down part of wave, four voices ? */
/* Fix this. Need to find exact ASC sampling freq */
/* Fix this. Need to find exact ASC sampling freq */
freq = 65536 * bell_freq / 466;
/* printf("beep: from %d, %02x %02x %02x %02x\n", cur_beep.freq,
(freq >> 24) & 0xff, (freq >> 16) & 0xff,
(freq >> 8) & 0xff, (freq) & 0xff);*/
for(i = 0; i < 8; i++){
/* printf("beep: from %d, %02x %02x %02x %02x\n",
* cur_beep.freq, (freq >> 24) & 0xff, (freq >> 16) & 0xff,
* (freq >> 8) & 0xff, (freq) & 0xff); */
for (i = 0; i < 8; i++) {
ASCBase[0x814 + 8 * i] = (freq >> 24) & 0xff;
ASCBase[0x815 + 8 * i] = (freq >> 16) & 0xff;
ASCBase[0x816 + 8 * i] = (freq >> 8) & 0xff;
ASCBase[0x817 + 8 * i] = (freq) & 0xff;
}/* frequency; should put cur_beep.freq in here somewhere. */
ASCBase[0x807] = 3; /* 44 ? */
ASCBase[0x806] = 255 * bell_volume / 100;
ASCBase[0x805] = 0;
ASCBase[0x80f] = 0;
ASCBase[0x802] = 2; /* sampled */
ASCBase[0x801] = 2; /* enable sampled */
}
} /* frequency; should put cur_beep.freq in here
* somewhere. */
ASCBase[0x807] = 3; /* 44 ? */
ASCBase[0x806] = 255 * bell_volume / 100;
ASCBase[0x805] = 0;
ASCBase[0x80f] = 0;
ASCBase[0x802] = 2; /* sampled */
ASCBase[0x801] = 2; /* enable sampled */
}
bell_ringing++;
timeout((void *) asc_bellstop, 0, bell_length);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: asc.h,v 1.2 1994/10/26 08:46:03 cgd Exp $ */
/* $NetBSD: asc.h,v 1.3 1995/04/21 02:47:46 briggs Exp $ */
/*-
* Copyright (C) 1993 Allen K. Briggs, Chris P. Caputo,
@ -39,12 +39,6 @@
int asc_ringbell();
int asc_getbellparams(
int *freq,
int *length,
int *volume);
int asc_getbellparams __P((int *freq, int *length, int *volume));
int asc_setbellparams(
int freq,
int length,
int volume);
int asc_setbellparams __P((int freq, int length, int volume));

View File

@ -1,36 +1,34 @@
/* $NetBSD: bounds.h,v 1.2 1994/10/26 08:46:04 cgd Exp $ */
/* $NetBSD: bounds.h,v 1.3 1995/04/21 02:47:47 briggs Exp $ */
#if defined(CHECKBOUNDS)
#undef CHECKBOUNDS
#define CHECKBOUNDS(a, i) \
{\
if((((a) + (i)) < (a)) || \
(((a) + (i)) >= ((a) + (sizeof(a) / sizeof(*(a)))))) \
{ \
printf("index " #i " (%d) exceeded bounds of " #a ", '%s' line %d.\n", \
(i), __FILE__, __LINE__); \
printf("halting...\n"); \
/*asm(" stop #0x2700");*/ \
} \
}
/* This requires ANSI C stringification. */
#define CHECKBOUNDS(a, i) { \
if ( (((a) + (i)) < (a)) || \
(((a) + (i)) >= ((a) + (sizeof(a) / sizeof(*(a))))) ) { \
printf("index " #i " (%d) exceeded bounds of " #a \
", '%s' line %d.\n", (i), __FILE__, __LINE__); \
printf("halting...\n"); \
/*asm(" stop #0x2700");*/ \
} \
}
#define CHECKPOINTER(a, p) \
{\
if(((p) < (a)) || \
((p) >= ((a) + (sizeof(a) / sizeof(*(a)))))) \
{ \
printf("pointer " #p " (0x%X) exceeded bounds of " #a " (0x%X), '%s' line %d.\n", \
, (p), (a), (i), __FILE__, __LINE__); \
printf("halting...\n"); \
/*asm(" stop #0x2700");*/ \
} \
}
#define CHECKPOINTER(a, p) { \
if ( ((p) < (a)) || \
((p) >= ((a) + (sizeof(a) / sizeof(*(a))))) ) { \
printf("pointer " #p " (0x%X) exceeded bounds of " #a \
" (0x%X), '%s' line %d.\n", \
(p), (a), __FILE__, __LINE__); \
printf("halting...\n"); \
/*asm(" stop #0x2700");*/ \
} \
}
#else /* !defined(CHECKBOUNDS) */
#else /* !defined(CHECKBOUNDS) */
#define CHECKBOUNDS(a, i)
#define CHECKPOINTER(a, p)
#endif /* defined(CHECKBOUNDS) */
#endif /* defined(CHECKBOUNDS) */

View File

@ -1,4 +1,4 @@
/* $NetBSD: grf.c,v 1.18 1995/04/13 04:04:58 briggs Exp $ */
/* $NetBSD: grf.c,v 1.19 1995/04/21 02:47:49 briggs Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -48,159 +48,122 @@
* Hardware access is through the grfdev routines below.
*/
#include "grf.h"
#if NGRF > 0
#include <sys/types.h>
#include "param.h"
#include "proc.h"
#include "ioctl.h"
#include "file.h"
#include "malloc.h"
#include <sys/param.h>
#include <sys/device.h>
#include "nubus.h"
#include <machine/grfioctl.h>
#include "grfvar.h"
#include <sys/ioctl.h>
#include <sys/file.h>
#include <sys/malloc.h>
#include <sys/mman.h>
#include <sys/proc.h>
#include <sys/vnode.h>
#include <machine/grfioctl.h>
#include <machine/cpu.h>
#include <miscfs/specfs/specdev.h>
#include <vm/vm.h>
#include <vm/vm_kern.h>
#include <vm/vm_page.h>
#include <vm/vm_pager.h>
#include <vnode.h>
#include <miscfs/specfs/specdev.h>
#include <mman.h>
#include "nubus.h"
#include "grfvar.h"
#include "grf.h"
#include "ite.h"
#if NITE == 0
#define iteon(u,f)
#define iteoff(u,f)
#endif
int grfprobe();
int macvideo_init(), macvideo_mode();
static int matchvideocard __P((/*struct device *parent, struct device *dev,
void *aux*/));
static void grf_attach __P((struct device *parent, struct device *dev,
void *aux));
static void fake_internal __P((void));
static int grfprobe __P((struct nubus_hw *nu, int unit));
static int macvideo_init __P((struct grf_softc *gp, struct nubus_hw *nu));
static int macvideo_mode __P((struct grf_softc *gp, int cmd, void *arg));
struct cfdriver grfcd = {
NULL, "grf", matchvideocard, grf_attach, DV_DULL,
sizeof(struct device)
};
struct grfdev grfdev[] = {
GID_MAC, GRFMAC, macvideo_init, macvideo_mode, "MacVideo",
GID_MAC, GRFMAC, macvideo_init, macvideo_mode, "MacVideo",
};
int ngrfdev = sizeof(grfdev) / sizeof(grfdev[0]);
/* struct driver grfdriver = { grfprobe, "grf" }; */
struct grf_softc grf_softc[NGRF];
int gNumGrfDev=0;
static int ngrfdev=(sizeof(grfdev) / sizeof(grfdev[0]));
static struct grf_softc grf_softc[NGRF];
static int gNumGrfDev=0;
#ifdef DEBUG
int grfdebug = 0xff;
static int grfdebug = 0xff;
#define GDB_DEVNO 0x01
#define GDB_MMAP 0x02
#define GDB_IOMAP 0x04
#define GDB_LOCK 0x08
#endif
/*
* XXX: called from ite console init routine.
* Does just what configure will do later but without printing anything.
*/
grfconfig()
{
#if 0
register caddr_t addr;
register struct nubus_hw *hw;
register struct mac_device *hd, *nhd;
int i;
for (i=0,hw = nubus_table;i<NUBUS_MAXSLOTS; hw++,i++) {
if (hw->Slot.type!=NUBUS_VIDEO)
continue;
/*
* Found one, now match up with a logical unit number
*/
nhd = NULL;
addr = hw->addr;
for (hd = mac_dinit; hd->mac_driver; hd++) {
if ((hd->mac_driver != &grfdriver) || hd->mac_alive)
continue;
nhd = hd;
nhd->mac_addr = addr;
nhd->mac_unit = gNumGrfDev++;
break;
/*
* Not wildcarded.
* If exact match done searching, else keep looking.
*/
/* if (sctova(hd->mac_addr) == addr) { */
/* nhd = hd; */
/* break; */
/* } */
}
/*
* Found a match, initialize
*/
if (nhd && grfprobe(nhd))
{
nhd->mac_alive=1;
hw->claimed = 1;
}
}
#endif
}
/*
* Normal init routine called by configure() code
*/
grfprobe(nu, unit)
struct nubus_hw *nu;
int unit;
int unit;
{
struct grf_softc *gp = &grf_softc[unit];
if ((gp->g_flags & GF_ALIVE) == 0 &&
!grfinit(nu, unit)) {
if ((gp->g_flags & GF_ALIVE) == 0 && !grfinit(nu, unit)) {
printf("\n");
return(0);
return (0);
}
printf(": %d x %d ",
gp->g_display.gd_dwidth, gp->g_display.gd_dheight);
gp->g_display.gd_dwidth, gp->g_display.gd_dheight);
if (gp->g_display.gd_colors == 2)
printf("monochrome");
else
printf("%d color", gp->g_display.gd_colors);
printf(" %s (%s) display\n", grfdev[gp->g_type].gd_desc, nu->Slot.name);
gp->g_data = (void *)&nu->Slot;
return(1);
printf(" %s (%s) display\n",
grfdev[gp->g_type].gd_desc, nu->slot.name);
gp->g_data = (void *) &nu->slot;
return (1);
}
static int
matchvideocard(parent, cf, aux)
struct device *parent;
struct cfdata *cf;
void *aux;
struct device *parent;
struct device *cf;
void *aux;
{
struct nubus_hw *nu = (struct nubus_hw *) aux;
struct nubus_hw *nu = (struct nubus_hw *) aux;
return (nu->Slot.type == NUBUS_VIDEO);
return (nu->slot.type == NUBUS_VIDEO);
}
static void
grf_attach(parent, dev, aux)
struct device *parent, *dev;
void *aux;
struct device *parent, *dev;
void *aux;
{
struct nubus_hw *nu = (struct nubus_hw *) aux;
struct nubus_hw *nu = (struct nubus_hw *) aux;
grfprobe(nu, dev->dv_unit);
}
struct cfdriver grfcd =
{ NULL, "grf", matchvideocard, grf_attach,
DV_DULL, sizeof(struct device), NULL, 0 };
int
grfinit(nu, unit)
struct nubus_hw *nu;
int unit;
{
struct grf_softc *gp = &grf_softc[unit];
struct grfreg *gr;
@ -208,29 +171,29 @@ grfinit(nu, unit)
for (gd = grfdev; gd < &grfdev[ngrfdev]; gd++)
/* if (gd->gd_hardid == gr->gr_id2) */
break;
if (gd < &grfdev[ngrfdev] && (*gd->gd_init)(gp, nu)) {
break;
if (gd < &grfdev[ngrfdev] && (*gd->gd_init) (gp, nu)) {
gp->g_display.gd_id = gd->gd_softid;
gp->g_type = gd - grfdev;
gp->g_flags = GF_ALIVE;
return(1);
return (1);
}
return(0);
return (0);
}
void fake_internal (void)
static void
fake_internal()
{
int i, j;
struct grf_softc *gp;
struct grfinfo *gi;
struct grfterm *gt;
struct grfmouse *gm;
extern unsigned long int_video_start;
extern unsigned long int_video_start;
struct grf_softc *gp;
struct grfinfo *gi;
struct grfterm *gt;
struct grfmouse *gm;
int i, j;
if (int_video_start == 0) {
return;
}
for (i = 0; i < NGRF; i++) {
gp = &grf_softc[i];
if ((gp->g_flags & GF_ALIVE) == 0) {
@ -239,10 +202,9 @@ void fake_internal (void)
}
if (i == NGRF) {
printf ("grf: not enough grf's to map internal video.\n");
printf("grf: not enough grf's to map internal video.\n");
return;
}
gp->g_type = 0;
gp->g_flags = GF_ALIVE;
@ -251,32 +213,40 @@ void fake_internal (void)
gi->gd_regsize = 0;
gi->gd_colors = 1;
gi->gd_planes = 1;
gi->gd_dwidth = gi->gd_fbwidth = 640; /* XXX */
gi->gd_dheight = gi->gd_fbheight = 480; /* XXX */
gi->gd_dwidth = gi->gd_fbwidth = 640; /* XXX */
gi->gd_dheight = gi->gd_fbheight = 480; /* XXX */
gi->gd_fbsize = gi->gd_dwidth * gi->gd_dheight;
gi->gd_fbrowbytes = 80; /* XXX Hack */
gi->gd_fbaddr = (caddr_t)0;
gi->gd_fbrowbytes = 80; /* XXX Hack */
gi->gd_fbaddr = (caddr_t) 0;
gp->g_fbkva = gi->gd_fbaddr;
}
/*ARGSUSED*/
grfopen(dev, flags)
int
grfopen(dev, flag, mode, p)
dev_t dev;
int flag;
int mode;
struct proc *p;
{
int unit = GRFUNIT(dev);
register struct grf_softc *gp = &grf_softc[unit];
int error = 0;
static int faked; /* Whether we've faked internal video yet */
static int faked; /* Whether we've faked internal video yet */
register struct grf_softc *gp;
int unit;
int error;
unit = GRFUNIT(dev);
gp = &grf_softc[unit];
if (!faked) {
fake_internal ();
fake_internal();
faked = 1;
}
if (unit >= NGRF || (gp->g_flags & GF_ALIVE) == 0)
return(ENXIO);
if ((gp->g_flags & (GF_OPEN|GF_EXCLUDE)) == (GF_OPEN|GF_EXCLUDE))
return(EBUSY);
return (ENXIO);
if ((gp->g_flags & (GF_OPEN | GF_EXCLUDE)) == (GF_OPEN | GF_EXCLUDE))
return (EBUSY);
/*
* First open.
* XXX: always put in graphics mode.
@ -286,138 +256,145 @@ grfopen(dev, flags)
gp->g_flags |= GF_OPEN;
error = grfon(dev);
}
return(error);
return (error);
}
/*ARGSUSED*/
grfclose(dev, flags)
grfclose(dev, flag, mode, p)
dev_t dev;
int flag;
int mode;
struct proc *p;
{
register struct grf_softc *gp = &grf_softc[GRFUNIT(dev)];
register struct grf_softc *gp;
gp = &grf_softc[GRFUNIT(dev)];
(void) grfoff(dev);
(void) grfunlock(gp);
gp->g_flags &= GF_ALIVE;
return(0);
return (0);
}
/*ARGSUSED*/
grfioctl(dev, cmd, data, flag, p)
dev_t dev;
int cmd;
caddr_t data;
int flag;
struct proc *p;
{
register struct grf_softc *gp = &grf_softc[GRFUNIT(dev)];
int error;
register struct grf_softc *gp;
int error;
gp = &grf_softc[GRFUNIT(dev)];
error = 0;
switch (cmd) {
/* XXX: compatibility hack */
case OGRFIOCGINFO:
bcopy((caddr_t)&gp->g_display, data, sizeof(struct ogrfinfo));
bcopy((caddr_t) & gp->g_display, data, sizeof(struct ogrfinfo));
break;
case GRFIOCGINFO:
bcopy((caddr_t)&gp->g_display, data, sizeof(struct grfinfo));
bcopy((caddr_t) & gp->g_display, data, sizeof(struct grfinfo));
break;
case GRFIOCON:
error = grfon(dev);
break;
case GRFIOCOFF:
error = grfoff(dev);
break;
case GRFIOCMAP:
error = grfmap(dev, (caddr_t *)data, p);
error = grfmap(dev, (caddr_t *) data, p);
break;
case GRFIOCUNMAP:
error = grfunmap(dev, *(caddr_t *)data, p);
error = grfunmap(dev, *(caddr_t *) data, p);
break;
default:
error = EINVAL;
break;
}
return(error);
return (error);
}
/*ARGSUSED*/
grfselect(dev, rw)
grfselect(dev, rw, p)
dev_t dev;
int rw;
struct proc *p;
{
if (rw == FREAD)
return(0);
return(1);
return (0);
return (1);
}
int
grflock(gp, block)
register struct grf_softc *gp;
int block;
{
struct proc *p = curproc; /* XXX */
int error;
extern char devioc[];
struct proc *p = curproc; /* XXX */
int error;
#ifdef DEBUG
if (grfdebug & GDB_LOCK)
printf("grflock(%d): dev %x flags %x lockpid %x\n",
p->p_pid, gp-grf_softc, gp->g_flags,
gp->g_lockp ? gp->g_lockp->p_pid : -1);
p->p_pid, gp - grf_softc, gp->g_flags,
gp->g_lockp ? gp->g_lockp->p_pid : -1);
#endif
if (gp->g_lockp) {
if (gp->g_lockp == p)
return(EBUSY);
return (EBUSY);
if (!block)
return(EAGAIN);
return (EAGAIN);
do {
gp->g_flags |= GF_WANTED;
if (error = tsleep((caddr_t)&gp->g_flags,
(PZERO+1) | PCATCH, devioc, 0))
if (error = tsleep((caddr_t) & gp->g_flags,
(PZERO + 1) | PCATCH, devioc, 0))
return (error);
} while (gp->g_lockp);
}
gp->g_lockp = p;
return(0);
return (0);
}
int
grfunlock(gp)
register struct grf_softc *gp;
{
#ifdef DEBUG
if (grfdebug & GDB_LOCK)
printf("grfunlock(%d): dev %x flags %x lockpid %d\n",
curproc->p_pid, gp-grf_softc, gp->g_flags,
gp->g_lockp ? gp->g_lockp->p_pid : -1);
curproc->p_pid, gp - grf_softc, gp->g_flags,
gp->g_lockp ? gp->g_lockp->p_pid : -1);
#endif
if (gp->g_lockp != curproc)
return(EBUSY);
return (EBUSY);
if (gp->g_flags & GF_WANTED) {
wakeup((caddr_t)&gp->g_flags);
wakeup((caddr_t) & gp->g_flags);
gp->g_flags &= ~GF_WANTED;
}
gp->g_lockp = NULL;
return(0);
return (0);
}
/*ARGSUSED*/
grfmmap(dev, off, prot)
dev_t dev;
int off;
int prot;
{
return(grfaddr(&grf_softc[GRFUNIT(dev)], off));
return (grfaddr(&grf_softc[GRFUNIT(dev)], off));
}
int
grfon(dev)
dev_t dev;
dev_t dev;
{
int unit = GRFUNIT(dev);
int unit = GRFUNIT(dev);
struct grf_softc *gp = &grf_softc[unit];
/*
@ -426,25 +403,27 @@ grfon(dev)
* of the dev arg.
*/
iteoff(unit, 3);
return((*grfdev[gp->g_type].gd_mode)
(gp, (dev&GRFOVDEV) ? GM_GRFOVON : GM_GRFON));
return ((*grfdev[gp->g_type].gd_mode)
(gp, (dev & GRFOVDEV) ? GM_GRFOVON : GM_GRFON));
}
int
grfoff(dev)
dev_t dev;
dev_t dev;
{
int unit = GRFUNIT(dev);
int unit = GRFUNIT(dev);
struct grf_softc *gp = &grf_softc[unit];
int error;
int error;
(void) grfunmap(dev, (caddr_t)0, curproc);
(void) grfunmap(dev, (caddr_t) 0, curproc);
error = (*grfdev[gp->g_type].gd_mode)
(gp, (dev&GRFOVDEV) ? GM_GRFOVOFF : GM_GRFOFF);
(gp, (dev & GRFOVDEV) ? GM_GRFOVOFF : GM_GRFOFF);
/* XXX: see comment for iteoff above */
iteon(unit, 2);
return(error);
return (error);
}
int
grfaddr(gp, off)
struct grf_softc *gp;
register int off;
@ -453,27 +432,28 @@ grfaddr(gp, off)
/* control registers */
if (off >= 0 && off < gi->gd_regsize)
return(((u_int)gi->gd_regaddr + off) >> PGSHIFT);
return (((u_int) gi->gd_regaddr + off) >> PGSHIFT);
/* frame buffer */
if (off >= gi->gd_regsize && off < gi->gd_regsize+gi->gd_fbsize) {
if (off >= gi->gd_regsize && off < gi->gd_regsize + gi->gd_fbsize) {
off -= gi->gd_regsize;
return(((u_int)gi->gd_fbaddr + off) >> PGSHIFT);
return (((u_int) gi->gd_fbaddr + off) >> PGSHIFT);
}
/* bogus */
return(-1);
return (-1);
}
int
grfmap(dev, addrp, p)
dev_t dev;
caddr_t *addrp;
struct proc *p;
{
struct grf_softc *gp = &grf_softc[GRFUNIT(dev)];
int len, error;
int len, error;
struct vnode vn;
struct specinfo si;
int flags;
int flags;
#ifdef DEBUG
if (grfdebug & GDB_MMAP)
@ -483,92 +463,95 @@ grfmap(dev, addrp, p)
flags = MAP_SHARED;
if (*addrp)
flags |= MAP_FIXED;
else
{
else {
return 12;
*addrp = (caddr_t)0x1000000; /* XXX */
*addrp = (caddr_t) 0x1000000; /* XXX */
}
vn.v_type = VCHR; /* XXX */
vn.v_specinfo = &si; /* XXX */
vn.v_rdev = dev; /* XXX */
vn.v_type = VCHR; /* XXX */
vn.v_specinfo = &si; /* XXX */
vn.v_rdev = dev; /* XXX */
error = vm_mmap(&p->p_vmspace->vm_map, (vm_offset_t *)addrp,
(vm_size_t)len, VM_PROT_ALL, VM_PROT_ALL, flags, (caddr_t)&vn,
0);
error = vm_mmap(&p->p_vmspace->vm_map, (vm_offset_t *) addrp,
(vm_size_t) len, VM_PROT_ALL, VM_PROT_ALL, flags, (caddr_t) & vn,
0);
/* Offset into page: */
*addrp += (unsigned long)gp->g_display.gd_fbaddr & 0xfff;
*addrp += (unsigned long) gp->g_display.gd_fbaddr & 0xfff;
return(error);
return (error);
}
int
grfunmap(dev, addr, p)
dev_t dev;
dev_t dev;
caddr_t addr;
struct proc *p;
{
struct grf_softc *gp = &grf_softc[GRFUNIT(dev)];
vm_size_t size;
int rv;
int rv;
#ifdef DEBUG
if (grfdebug & GDB_MMAP)
printf("grfunmap(%d): dev %x addr %x\n", p->p_pid, dev, addr);
#endif
if (addr == 0)
return(EINVAL); /* XXX: how do we deal with this? */
return (EINVAL);/* XXX: how do we deal with this? */
size = round_page(gp->g_display.gd_regsize + gp->g_display.gd_fbsize);
rv = vm_deallocate(&p->p_vmspace->vm_map, (vm_offset_t)addr, size);
return(rv == KERN_SUCCESS ? 0 : EINVAL);
rv = vm_deallocate(&p->p_vmspace->vm_map, (vm_offset_t) addr, size);
return (rv == KERN_SUCCESS ? 0 : EINVAL);
}
#endif /* NGRF > 0 */
static char zero = 0;
static void
macvideo_intr(int unit, int slot)
macvideo_intr(unit, slot)
int unit, slot;
{
struct grf_softc *gp = &grf_softc[unit];
struct grf_softc *gp;
((char *)(0xf0000000 | ((long)slot << 24)))[0xa0000] = zero;
return 1;
((char *) (0xf0000000 | ((long) slot << 24)))[0xa0000] = zero;
}
int
macvideo_init(struct grf_softc *gp,struct nubus_hw *nu)
static int
macvideo_init(gp, nu)
struct grf_softc *gp;
struct nubus_hw *nu;
{
int i=0;
struct grfinfo *gi;
struct imagedata *image;
struct imagedata imageSpace;
int i = 0;
/*
* find out which nubus slot this guy is in, then get the video params
*/
image=(struct imagedata *)NUBUS_GetImageData(&(nu->Slot),&imageSpace );
/*
* find out which nubus slot this guy is in, then get the video params
*/
image = (struct imagedata *) NUBUS_GetImageData(&(nu->slot), &imageSpace);
gi = &(gp->g_display);
gi->gd_regsize=0;
gi->gd_colors=1;
gi->gd_planes=1;
gi->gd_dwidth=gi->gd_fbwidth=image->right;
gi->gd_dheight=gi->gd_fbheight=image->bottom;
gi->gd_fbsize=image->rowbytes*image->bottom;
gi->gd_fbrowbytes=image->rowbytes;
gi->gd_fbaddr=(caddr_t) ((u_long)image->offset+(u_long)nu->addr);
gp->g_fbkva=gi->gd_fbaddr;
gi->gd_regsize = 0;
gi->gd_colors = 1;
gi->gd_planes = 1;
gi->gd_dwidth = gi->gd_fbwidth = image->right;
gi->gd_dheight = gi->gd_fbheight = image->bottom;
gi->gd_fbsize = image->rowbytes * image->bottom;
gi->gd_fbrowbytes = image->rowbytes;
gi->gd_fbaddr = (caddr_t) ((u_long) image->offset + (u_long) nu->addr);
gp->g_fbkva = gi->gd_fbaddr;
add_nubus_intr((unsigned int)nu->addr & 0xFF000000, macvideo_intr,
(gp - grf_softc));
add_nubus_intr((unsigned int) nu->addr & 0xFF000000, macvideo_intr,
(gp - grf_softc));
gNumGrfDev++;
return 1;
}
int
macvideo_mode(struct grf_softc *gp,int cmd, void *arg)
static int
macvideo_mode(gp, cmd, arg)
struct grf_softc *gp;
int cmd;
void *arg;
{
return 0;
}

View File

@ -1,166 +0,0 @@
/* $NetBSD: grf_gb.c,v 1.6 1994/10/26 08:46:08 cgd Exp $ */
/*
* Copyright (c) 1988 University of Utah.
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* the Systems Programming Group of the University of Utah Computer
* Science Department.
*
* 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:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, 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.
*
* from: Utah $Hdr: grf_gb.c 1.16 91/04/02$
*
* @(#)grf_gb.c 7.4 (Berkeley) 5/7/91
*/
#include "grf.h"
#if NGRF > 0
/*
* Graphics routines for the Gatorbox.
*
* Note: In the context of this system, "gator" and "gatorbox" both refer to
* HP 987x0 graphics systems. "Gator" is not used for high res mono.
* (as in 9837 Gator systems)
*/
#include <sys/param.h>
#include <sys/errno.h>
#include <machine/grfioctl.h>
#include "grfvar.h"
#include "grf_gbreg.h"
#include <machine/cpu.h>
#define CRTC_DATA_LENGTH 0x0e
u_char crtc_init_data[CRTC_DATA_LENGTH] = {
0x29, 0x20, 0x23, 0x04, 0x30, 0x0b, 0x30,
0x30, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00
};
/*
* Initialize hardware.
* Must point g_display at a grfinfo structure describing the hardware.
* Returns 0 if hardware not present, non-zero ow.
*/
gb_init(gp, addr)
struct grf_softc *gp;
caddr_t addr;
{
register struct gboxfb *gbp;
struct grfinfo *gi = &gp->g_display;
u_char *fbp, save;
int fboff;
extern caddr_t sctopa(), iomap();
gbp = (struct gboxfb *) addr;
#ifdef FOO
if (ISIIOVA(addr))
gi->gd_regaddr = (caddr_t) IIOP(addr);
else
gi->gd_regaddr = sctopa(vatosc(addr));
#endif
gi->gd_regsize = 0x10000;
gi->gd_fbwidth = 1024; /* XXX */
gi->gd_fbheight = 1024; /* XXX */
gi->gd_fbsize = gi->gd_fbwidth * gi->gd_fbheight;
fboff = (gbp->fbomsb << 8) | gbp->fbolsb;
gi->gd_fbaddr = (caddr_t) (*((u_char *)addr + fboff) << 16);
gp->g_regkva = addr;
gp->g_fbkva = iomap(gi->gd_fbaddr, gi->gd_fbsize);
gi->gd_dwidth = 1024; /* XXX */
gi->gd_dheight = 768; /* XXX */
gi->gd_planes = 0; /* how do we do this? */
/*
* The minimal register info here is from the Gatorbox X driver.
*/
fbp = (u_char *) gp->g_fbkva;
gbp->write_protect = 0;
gbp->interrupt = 4; /** fb_enable ? **/
gbp->rep_rule = 3; /* GXcopy */
gbp->blink1 = 0xff;
gbp->blink2 = 0xff;
gb_microcode(gbp);
/*
* Find out how many colors are available by determining
* which planes are installed. That is, write all ones to
* a frame buffer location, see how many ones are read back.
*/
save = *fbp;
*fbp = 0xFF;
gi->gd_colors = *fbp + 1;
*fbp = save;
return(1);
}
/*
* Program the 6845.
*/
gb_microcode(gbp)
register struct gboxfb *gbp;
{
register int i;
for (i = 0; i < CRTC_DATA_LENGTH; i++) {
gbp->crtc_address = i;
gbp->crtc_data = crtc_init_data[i];
}
}
/*
* Change the mode of the display.
* Right now all we can do is grfon/grfoff.
* Return a UNIX error number or 0 for success.
*/
gb_mode(gp, cmd)
register struct grf_softc *gp;
{
struct gboxfb *gbp;
int error = 0;
gbp = (struct gboxfb *) gp->g_regkva;
switch (cmd) {
case GM_GRFON:
gbp->sec_interrupt = 1;
break;
case GM_GRFOFF:
break;
default:
error = EINVAL;
break;
}
return(error);
}
#endif

View File

@ -1,126 +0,0 @@
/* $NetBSD: grf_gbreg.h,v 1.3 1994/10/26 08:46:08 cgd Exp $ */
/*
* Copyright (c) 1988 University of Utah.
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* the Systems Programming Group of the University of Utah Computer
* Science Department.
*
* 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:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, 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.
*
* from: Utah $Hdr: grf_gbreg.h 1.1 90/07/09$
*
* @(#)grf_gbreg.h 7.2 (Berkeley) 11/4/90
*/
/*
* Gatorbox driver regs
*/
#define TILER_ENABLE 0x80
#define LINE_MOVER_ENABLE 0x80
#define UP_LEFT 0x00
#define DOWN_RIGHT 0x40
#define MOVE_UP_LEFT TILER_ENABLE|UP_LEFT
#define MOVE_DOWN_RIGHT TILER_ENABLE|DOWN_RIGHT
#define tile_mover_waitbusy(regaddr) \
while (((struct gboxfb *)(regaddr))->sec_interrupt & 0x10)
#define line_mover_waitbusy(regaddr) \
while ((((struct gboxfb *)(regaddr))->status & 0x80) == 0)
#define gbcm_waitbusy(regaddr) \
while (((struct gboxfb *)(regaddr))->cmap_busy != 0xff)
#define vu_char volatile u_char
struct gboxfb {
u_char :8;
vu_char reset; /* reset register 0x01 */
vu_char sec_interrupt; /* Secondary interrupt register 0x03 */
vu_char interrupt; /* interrupt register 0x03 */
u_char :8;
vu_char fbwmsb; /* frame buffer width MSB 0x05 */
u_char :8;
vu_char fbwlsb; /* frame buffer width MSB 0x07 */
u_char :8;
vu_char fbhmsb; /* frame buffer height MSB 0x09 */
u_char :8;
vu_char fbhlsb; /* frame buffer height MSB 0x0b */
u_char :8;
vu_char dwmsb; /* display width MSB 0x0d */
u_char :8;
vu_char dwlsb; /* display width MSB 0x0f */
u_char :8;
vu_char dhmsb; /* display height MSB 0x11 */
u_char :8;
vu_char dhlsb; /* display height MSB 0x13 */
u_char :8;
vu_char fbid; /* Scondary frame buffer id 0x15 */
u_char f1[0x5d-0x15-1];
vu_char fbomsb; /* frame buffer offset MSB 0x5d */
u_char :8;
vu_char fbolsb; /* frame buffer offset LSB 0x5f */
u_char f2[0x4000-0x5f-1];
vu_char crtc_address; /* CTR controller address reg 0x4000 */
vu_char status; /* Status register 0x4001 */
vu_char crtc_data; /* CTR controller data reg 0x4002 */
u_char f3[6];
vu_char line_mover_rep_rule; /* Line move rep rule */
u_char :8, :8;
vu_char line_mover_width; /* Line move width */
u_char f4[0xff3];
vu_char width; /* width in tiles 0x5001 */
u_char :8;
vu_char height; /* height in tiles 0x5003 */
u_char f5[3];
vu_char rep_rule; /* replacement rule 0x5007 */
u_char f6[0x6001-0x5007-1];
vu_char blink1; /* blink 1 0x6001 */
u_char f7[3];
vu_char blink2; /* blink 2 0x6005 */
u_char f8[3];
vu_char write_protect; /* write protect 0x6009 */
u_char f9[0x6803-0x6009-1];
vu_char cmap_busy; /* color map busy 0x6803 */
u_char f10[0x68b9-0x6803-1];
vu_char creg_select; /* color map register select 0x68b8 */
u_char f11[0x68f1-0x68b9-1];
vu_char cmap_write; /* color map write trigger 0x68f1 */
u_char f12[0x69b3-0x68f1-1];
vu_char cmap_red; /* red value register 0x69b3 */
u_char :8;
vu_char cmap_grn; /* green value register 0x69b5 */
u_char :8;
vu_char cmap_blu; /* blue value register 0x69b6 */
};

View File

@ -1,4 +1,4 @@
/* $NetBSD: grfvar.h,v 1.4 1995/03/23 20:19:16 briggs Exp $ */
/* $NetBSD: grfvar.h,v 1.5 1995/04/21 02:47:52 briggs Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -44,23 +44,23 @@
/* internal structure of lock page */
#define GRFMAXLCK 256
struct grf_lockpage {
u_char gl_locks[GRFMAXLCK];
struct grf_lockpage {
u_char gl_locks[GRFMAXLCK];
};
#define gl_lockslot gl_locks[0]
/* per display info */
struct grf_softc {
int g_flags; /* software flags */
int g_type; /* type of display */
caddr_t g_regkva; /* KVA of registers */
caddr_t g_fbkva; /* KVA of framebuffer */
struct grf_softc {
int g_flags; /* software flags */
int g_type; /* type of display */
caddr_t g_regkva; /* KVA of registers */
caddr_t g_fbkva; /* KVA of framebuffer */
struct grfinfo g_display; /* hardware description (for ioctl) */
struct grf_lockpage *g_lock; /* lock page associated with device */
struct proc *g_lockp; /* process holding lock */
short *g_pid; /* array of pids with device open */
int g_lockpslot; /* g_pid entry of g_lockp */
caddr_t g_data; /* device dependent data */
struct proc *g_lockp; /* process holding lock */
short *g_pid; /* array of pids with device open */
int g_lockpslot; /* g_pid entry of g_lockp */
caddr_t g_data; /* device dependent data */
};
/* flags */
@ -74,14 +74,13 @@ struct grf_softc {
/* display types - indices into grfdev */
#define GT_MAC 0
struct grfdev {
struct grfdev {
int gd_hardid; /* secondary id returned by hardware */
int gd_softid; /* id returned by HP-UX */
int (*gd_init)(); /* boot time initialization */
int (*gd_mode)(); /* misc functions */
int (*gd_init) (); /* boot time initialization */
int (*gd_mode) (); /* misc functions */
char *gd_desc; /* text description */
};
/* hardware ids */
#define GID_MAC 1
@ -93,15 +92,15 @@ struct grfdev {
#define GM_GRFOVON 3
#define GM_GRFOVOFF 4
struct grfreg {
char gr_pad0;
u_char gr_id; /* +0x01 */
char gr_pad1[0x13];
u_char gr_id2; /* +0x15 */
char gr_pad2[0x47];
u_char gr_fbomsb; /* +0x5d */
char gr_pad3;
u_char gr_fbolsb; /* +0x5f */
struct grfreg {
char gr_pad0;
u_char gr_id; /* +0x01 */
char gr_pad1[0x13];
u_char gr_id2; /* +0x15 */
char gr_pad2[0x47];
u_char gr_fbomsb; /* +0x5d */
char gr_pad3;
u_char gr_fbolsb; /* +0x5f */
};
/* bitmapped display hardware id */
#define GRFHWID 0x39
@ -115,5 +114,5 @@ struct grfreg {
#define GRFUNIT(d) ((d) & 0x7)
#ifdef _KERNEL
extern struct grf_softc grf_softc[];
#endif /* _KERNEL */
extern struct grf_softc grf_softc[];
#endif /* _KERNEL */

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_ae.c,v 1.24 1995/04/19 04:43:36 briggs Exp $ */
/* $NetBSD: if_ae.c,v 1.25 1995/04/21 02:47:53 briggs Exp $ */
/*
* Device driver for National Semiconductor DS8390/WD83C690 based ethernet
@ -64,44 +64,44 @@
/*
* ae_softc: per line info and status
*/
struct ae_softc {
struct device sc_dev;
struct ae_softc {
struct device sc_dev;
/* struct nubusdev sc_nu;
struct intrhand sc_ih; */
struct arpcom sc_arpcom; /* ethernet common */
struct arpcom sc_arpcom;/* ethernet common */
char *type_str; /* pointer to type string */
u_char vendor; /* interface vendor */
u_char type; /* interface type code */
u_char regs_rev; /* registers are reversed */
char *type_str; /* pointer to type string */
u_char vendor; /* interface vendor */
u_char type; /* interface type code */
u_char regs_rev; /* registers are reversed */
#define REG_MAP(sc, reg) ((sc)->regs_rev ? (0x0f-(reg))<<2 : (reg)<<2)
#define NIC_GET(sc, reg) ((sc)->nic_addr[REG_MAP(sc, reg)])
#define NIC_PUT(sc, reg, val) ((sc)->nic_addr[REG_MAP(sc, reg)] = (val))
volatile caddr_t nic_addr; /* NIC (DS8390) I/O bus address */
caddr_t rom_addr; /* on board prom address */
volatile caddr_t nic_addr; /* NIC (DS8390) I/O bus address */
caddr_t rom_addr; /* on board prom address */
u_char cr_proto; /* values always set in CR */
u_char cr_proto; /* values always set in CR */
caddr_t mem_start; /* shared memory start address */
caddr_t mem_end; /* shared memory end address */
u_long mem_size; /* total shared memory size */
caddr_t mem_ring; /* start of RX ring-buffer (in smem) */
caddr_t mem_start; /* shared memory start address */
caddr_t mem_end; /* shared memory end address */
u_long mem_size; /* total shared memory size */
caddr_t mem_ring; /* start of RX ring-buffer (in smem) */
u_char mem_wr_short; /* card memory requires int16 writes */
u_char mem_wr_short; /* card memory requires int16 writes */
u_char xmit_busy; /* transmitter is busy */
u_char txb_cnt; /* Number of transmit buffers */
u_char txb_inuse; /* number of TX buffers currently in-use*/
u_char xmit_busy; /* transmitter is busy */
u_char txb_cnt; /* Number of transmit buffers */
u_char txb_inuse; /* number of TX buffers currently in-use */
u_char txb_new; /* pointer to where new buffer will be added */
u_char txb_next_tx; /* pointer to next buffer ready to xmit */
u_short txb_len[8]; /* buffered xmit buffer lengths */
u_char tx_page_start; /* first page of TX buffer area */
u_char rec_page_start; /* first page of RX ring-buffer */
u_char rec_page_stop; /* last page of RX ring-buffer */
u_char next_packet; /* pointer to next unread RX packet */
u_char txb_new; /* pointer to where new buffer will be added */
u_char txb_next_tx; /* pointer to next buffer ready to xmit */
u_short txb_len[8]; /* buffered xmit buffer lengths */
u_char tx_page_start; /* first page of TX buffer area */
u_char rec_page_start; /* first page of RX ring-buffer */
u_char rec_page_stop; /* last page of RX ring-buffer */
u_char next_packet; /* pointer to next unread RX packet */
};
int aeprobe __P((struct device *, void *, void *));
@ -109,46 +109,57 @@ void aeattach __P((struct device *, struct device *, void *));
void aeintr __P((struct ae_softc *));
int ae_ioctl __P((struct ifnet *, u_long, caddr_t));
void ae_start __P((struct ifnet *));
void ae_watchdog __P((/* short */));
void ae_watchdog __P(( /* short */ ));
void ae_reset __P((struct ae_softc *));
void ae_init __P((struct ae_softc *));
void ae_stop __P((struct ae_softc *));
void ae_getmcaf __P((struct arpcom *, u_long *));
u_short ae_put __P((struct ae_softc *, struct mbuf *, caddr_t));
#define inline /* XXX for debugging porpoises */
#define inline /* XXX for debugging porpoises */
void ae_get_packet __P((/* struct ae_softc *, caddr_t, u_short */));
void ae_get_packet __P(( /* struct ae_softc *, caddr_t, u_short */ ));
static inline void ae_rint __P((struct ae_softc *));
static inline void ae_xmit __P((struct ae_softc *));
static inline caddr_t ae_ring_copy __P((/* struct ae_softc *, caddr_t, caddr_t,
u_short */));
struct cfdriver aecd = {
NULL, "ae", aeprobe, aeattach, DV_IFNET, sizeof(struct ae_softc)
};
static inline caddr_t ae_ring_copy
__P(( /* struct ae_softc *, caddr_t, caddr_t,
u_short */ ));
struct cfdriver aecd = {
NULL, "ae", aeprobe, aeattach, DV_IFNET, sizeof(struct ae_softc)
};
#define ETHER_MIN_LEN 64
#define ETHER_MAX_LEN 1518
#define ETHER_ADDR_LEN 6
char ae_name[] = "8390 Nubus Ethernet card";
static char zero = 0;
static u_char ones = 0xff;
char ae_name[] = "8390 Nubus Ethernet card";
static char zero = 0;
static u_char ones = 0xff;
struct vendor_S {
char *manu;
int len;
int vendor;
} vend[] = {
{ "Apple", 5, AE_VENDOR_APPLE },
{ "3Com", 4, AE_VENDOR_APPLE },
{ "Dayna", 5, AE_VENDOR_DAYNA },
{ "Inter", 5, AE_VENDOR_INTERLAN },
{ "Asant", 5, AE_VENDOR_ASANTE },
struct vendor_S {
char *manu;
int len;
int vendor;
} vend[] =
{
{
"Apple", 5, AE_VENDOR_APPLE
},
{
"3Com", 4, AE_VENDOR_APPLE
},
{
"Dayna", 5, AE_VENDOR_DAYNA
},
{
"Inter", 5, AE_VENDOR_INTERLAN
},
{
"Asant", 5, AE_VENDOR_ASANTE
},
};
static int numvend = sizeof(vend)/sizeof(vend[0]);
static int numvend = sizeof(vend) / sizeof(vend[0]);
/*
* XXX These two should be moved to locore, and maybe changed to use shorts
@ -157,36 +168,33 @@ static int numvend = sizeof(vend)/sizeof(vend[0]);
*/
void
bszero(u_short *addr, int len)
bszero(u_short * addr, int len)
{
while (len--)
*addr++ = 0;
}
/*
* Memory copy, copies word at time.
*/
static inline void
word_copy(a, b, len)
caddr_t a, b;
int len;
int len;
{
u_short *x = (u_short *)a,
*y = (u_short *)b;
u_short *x = (u_short *) a, *y = (u_short *) b;
len >>= 1;
while (len--)
*y++ = *x++;
}
/*
* Memory copy, copies bytes at time.
*/
static inline void
byte_copy(a, b, len)
caddr_t a, b;
int len;
int len;
{
while (len--)
*b++ = *a++;
@ -194,44 +202,44 @@ byte_copy(a, b, len)
void
ae_id_card(nu, sc)
struct nubus_hw *nu;
struct ae_softc *sc;
struct nubus_hw *nu;
struct ae_softc *sc;
{
int i;
int i;
/*
* Try to determine what type of card this is...
*/
sc->vendor = AE_VENDOR_UNKNOWN;
for (i = 0; i < numvend; i++) {
if (!strncmp(nu->Slot.manufacturer, vend[i].manu, vend[i].len)) {
if (!strncmp(nu->slot.manufacturer, vend[i].manu, vend[i].len)) {
sc->vendor = vend[i].vendor;
break;
}
}
sc->type_str = (char *)(nu->Slot.manufacturer);
sc->type_str = (char *) (nu->slot.manufacturer);
}
int
ae_size_card_memory(sc)
struct ae_softc *sc;
struct ae_softc *sc;
{
u_short *p;
u_short i1, i2, i3, i4;
int size;
int size;
p = (u_short *)sc->mem_start;
p = (u_short *) sc->mem_start;
/*
* very simple size memory, assuming it's installed in 8k
* banks; also assume it will generally mirror in upper banks
* if not installed.
*/
i1 = (8192*0)/2;
i2 = (8192*1)/2;
i3 = (8192*2)/2;
i4 = (8192*3)/2;
i1 = (8192 * 0) / 2;
i2 = (8192 * 1) / 2;
i3 = (8192 * 2) / 2;
i4 = (8192 * 3) / 2;
p[i1] = 0x1111;
p[i2] = 0x2222;
@ -240,11 +248,11 @@ ae_size_card_memory(sc)
if (p[i1] == 0x1111 && p[i2] == 0x2222 &&
p[i3] == 0x3333 && p[i4] == 0x4444)
return 8192*4;
return 8192 * 4;
if ((p[i1] == 0x1111 && p[i2] == 0x2222) ||
(p[i1] == 0x3333 && p[i2] == 0x4444))
return 8192*2;
return 8192 * 2;
if (p[i1] == 0x1111 || p[i1] == 0x4444)
return 8192;
@ -255,14 +263,14 @@ ae_size_card_memory(sc)
int
aeprobe(parent, match, aux)
struct device *parent;
void *match, *aux;
void *match, *aux;
{
struct ae_softc *sc = match;
register struct nubus_hw *nu = aux;
int i, memsize;
int flags = 0;
int i, memsize;
int flags = 0;
if (nu->Slot.type != NUBUS_NETWORK)
if (nu->slot.type != NUBUS_NETWORK)
return 0;
ae_id_card(nu, sc);
@ -271,7 +279,7 @@ aeprobe(parent, match, aux)
sc->mem_wr_short = 0;
switch (sc->vendor) {
case AE_VENDOR_INTERLAN:
case AE_VENDOR_INTERLAN:
sc->nic_addr = nu->addr + GC_NIC_OFFSET;
sc->rom_addr = nu->addr + GC_ROM_OFFSET;
sc->mem_start = nu->addr + GC_DATA_OFFSET;
@ -279,19 +287,19 @@ aeprobe(parent, match, aux)
return 0;
/* reset the NIC chip */
*((caddr_t)nu->addr + GC_RESET_OFFSET) = (char)zero;
*((caddr_t) nu->addr + GC_RESET_OFFSET) = (char) zero;
/* Get station address from on-board ROM */
for (i = 0; i < ETHER_ADDR_LEN; ++i)
sc->sc_arpcom.ac_enaddr[i] = *(sc->rom_addr + i*4);
sc->sc_arpcom.ac_enaddr[i] = *(sc->rom_addr + i * 4);
break;
case AE_VENDOR_ASANTE:
case AE_VENDOR_ASANTE:
/* memory writes require *(u_short *) */
sc->mem_wr_short = 1;
/* otherwise, pretend to be an apple card (fall through) */
case AE_VENDOR_APPLE:
case AE_VENDOR_APPLE:
sc->regs_rev = 1;
sc->nic_addr = nu->addr + AE_NIC_OFFSET;
sc->rom_addr = nu->addr + AE_ROM_OFFSET;
@ -301,10 +309,10 @@ aeprobe(parent, match, aux)
/* Get station address from on-board ROM */
for (i = 0; i < ETHER_ADDR_LEN; ++i)
sc->sc_arpcom.ac_enaddr[i] = *(sc->rom_addr + i*2);
sc->sc_arpcom.ac_enaddr[i] = *(sc->rom_addr + i * 2);
break;
case AE_VENDOR_DAYNA:
case AE_VENDOR_DAYNA:
printf("We think we are a Dayna card, but ");
sc->nic_addr = nu->addr + DP_NIC_OFFSET;
sc->rom_addr = nu->addr + DP_ROM_OFFSET;
@ -313,12 +321,12 @@ aeprobe(parent, match, aux)
/* Get station address from on-board ROM */
for (i = 0; i < ETHER_ADDR_LEN; ++i)
sc->sc_arpcom.ac_enaddr[i] = *(sc->rom_addr + i*2);
sc->sc_arpcom.ac_enaddr[i] = *(sc->rom_addr + i * 2);
printf("it is dangerous to continue.\n");
return (0); /* Since we don't work yet... */
return (0); /* Since we don't work yet... */
break;
default:
default:
return (0);
break;
}
@ -339,29 +347,27 @@ aeprobe(parent, match, aux)
sc->mem_end = sc->mem_start + memsize;
/* Now zero memory and verify that it is clear. */
bszero((u_short *)sc->mem_start, memsize / 2);
bszero((u_short *) sc->mem_start, memsize / 2);
for (i = 0; i < memsize; ++i)
if (sc->mem_start[i]) {
printf("%s: failed to clear shared memory at %x - check configuration\n",
printf("%s: failed to clear shared memory at %x - check configuration\n",
sc->sc_dev.dv_xname,
sc->mem_start + i);
return (0);
}
return (1);
}
/*
* Install interface into kernel networking data structures
*/
void
aeattach(parent, self, aux)
struct device *parent, *self;
void *aux;
void *aux;
{
struct ae_softc *sc = (void *)self;
struct nubus_hw *nu = aux;
struct ae_softc *sc = (void *) self;
struct nubus_hw *nu = aux;
struct cfdata *cf = sc->sc_dev.dv_cfdata;
struct ifnet *ifp = &sc->sc_arpcom.ac_if;
@ -396,9 +402,8 @@ aeattach(parent, self, aux)
#endif
/* make sure interrupts are vectored to us */
add_nubus_intr( (int) sc->rom_addr & 0xFF000000, aeintr, sc);
add_nubus_intr((int) sc->rom_addr & 0xFF000000, aeintr, sc);
}
/*
* Reset interface.
*/
@ -406,14 +411,13 @@ void
ae_reset(sc)
struct ae_softc *sc;
{
int s;
int s;
s = splimp();
ae_stop(sc);
ae_init(sc);
splx(s);
}
/*
* Take interface offline.
*/
@ -421,7 +425,7 @@ void
ae_stop(sc)
struct ae_softc *sc;
{
int n = 5000;
int n = 5000;
/* Stop everything on the interface, and select page 0 registers. */
NIC_PUT(sc, ED_P0_CR, sc->cr_proto | ED_CR_PAGE_0 | ED_CR_STP);
@ -433,15 +437,14 @@ ae_stop(sc)
*/
while (((NIC_GET(sc, ED_P0_ISR) & ED_ISR_RST) == 0) && --n);
}
/*
* Device timeout/watchdog routine. Entered if the device neglects to generate
* an interrupt after a transmit has been started on it.
*/
static int aeintr_ctr = 0;
static int aeintr_ctr = 0;
void
ae_watchdog(unit)
int unit;
int unit;
{
struct ae_softc *sc = aecd.cd_devs[unit];
@ -451,11 +454,11 @@ ae_watchdog(unit)
* sometimes. This kludges around that by calling the handler
* by hand if the watchdog is activated. -- XXX (akb)
*/
int i;
int i;
i = aeintr_ctr;
(*via2itab[1])(1);
(*via2itab[1]) (1);
if (i != aeintr_ctr) {
log(LOG_ERR, "ae%d: device timeout, recovered\n", unit);
@ -468,7 +471,6 @@ ae_watchdog(unit)
ae_reset(sc);
}
/*
* Initialize device.
*/
@ -477,9 +479,9 @@ ae_init(sc)
struct ae_softc *sc;
{
struct ifnet *ifp = &sc->sc_arpcom.ac_if;
int i, s;
u_char command;
u_long mcaf[2];
int i, s;
u_char command;
u_long mcaf[2];
/* Address not known. */
if (ifp->if_addrlist == 0)
@ -552,7 +554,7 @@ ae_init(sc)
/* Set multicast filter on chip. */
ae_getmcaf(&sc->sc_arpcom, mcaf);
for (i = 0; i < 8; i++)
NIC_PUT(sc, ED_P1_MAR0 + i, ((u_char *)mcaf)[i]);
NIC_PUT(sc, ED_P1_MAR0 + i, ((u_char *) mcaf)[i]);
/*
* Set current page pointer to one page after the boundary pointer, as
@ -589,7 +591,6 @@ ae_init(sc)
splx(s);
}
/*
* This routine actually starts the transmission on the interface.
*/
@ -625,7 +626,6 @@ ae_xmit(sc)
/* Set a timer just in case we never hear from the board again. */
ifp->if_timer = 2;
}
/*
* Start output on interface.
* We make two assumptions here:
@ -642,7 +642,7 @@ ae_start(ifp)
struct ae_softc *sc = aecd.cd_devs[ifp->if_unit];
struct mbuf *m0, *m;
caddr_t buffer;
int len;
int len;
outloop:
/*
@ -654,14 +654,12 @@ outloop:
sc->sc_dev.dv_xname);
ae_xmit(sc);
}
/* See if there is room to put another packet in the buffer. */
if (sc->txb_inuse == sc->txb_cnt) {
/* No room. Indicate this to the outside world and exit. */
ifp->if_flags |= IFF_OACTIVE;
return;
}
IF_DEQUEUE(&sc->sc_arpcom.ac_if.if_snd, m);
if (m == 0) {
/*
@ -674,7 +672,6 @@ outloop:
ifp->if_flags &= ~IFF_OACTIVE;
return;
}
/* Copy the mbuf chain into the transmit buffer. */
m0 = m;
@ -704,7 +701,6 @@ outloop:
/* Loop back to the top to possibly buffer more packets. */
goto outloop;
}
/*
* Ethernet interface receiver interrupt.
*/
@ -712,9 +708,9 @@ static inline void
ae_rint(sc)
struct ae_softc *sc;
{
u_char boundary, current;
u_char boundary, current;
u_short len;
u_char nlen;
u_char nlen;
struct ae_ring packet_hdr;
caddr_t packet_ptr;
@ -746,7 +742,7 @@ loop:
* The byte count includes a 4 byte header that was added by
* the NIC.
*/
packet_hdr = *(struct ae_ring *)packet_ptr;
packet_hdr = *(struct ae_ring *) packet_ptr;
packet_hdr.count =
((packet_hdr.count >> 8) & 0xff) |
((packet_hdr.count & 0xff) << 8);
@ -764,7 +760,7 @@ loop:
nlen = (packet_hdr.next_packet - sc->next_packet);
else
nlen = ((packet_hdr.next_packet - sc->rec_page_start) +
(sc->rec_page_stop - sc->next_packet));
(sc->rec_page_stop - sc->next_packet));
--nlen;
if ((len & ED_PAGE_MASK) + sizeof(packet_hdr) > ED_PAGE_SIZE)
--nlen;
@ -820,13 +816,12 @@ loop:
goto loop;
}
/* Ethernet interface interrupt processor. */
void
aeintr(sc)
struct ae_softc *sc;
{
u_char isr;
u_char isr;
aeintr_ctr++;
@ -851,7 +846,7 @@ aeintr(sc)
* the receiver will reset the board under some conditions.
*/
if (isr & (ED_ISR_PTX | ED_ISR_TXE)) {
u_char collisions = NIC_GET(sc, ED_P0_NCR) & 0x0f;
u_char collisions = NIC_GET(sc, ED_P0_NCR) & 0x0f;
/*
* Check for transmit error. If a TX completed with an
@ -876,7 +871,6 @@ aeintr(sc)
*/
collisions = 16;
}
/* Update output errors counter. */
++sc->sc_arpcom.ac_if.if_oerrors;
} else {
@ -910,7 +904,6 @@ aeintr(sc)
if (sc->txb_inuse && --sc->txb_inuse)
ae_xmit(sc);
}
/* Handle receiver interrupts. */
if (isr & (ED_ISR_PRX | ED_ISR_RXE | ED_ISR_OVW)) {
/*
@ -945,7 +938,6 @@ aeintr(sc)
NIC_GET(sc, ED_P0_RSR));
#endif
}
/*
* Go get the packet(s)
* XXX - Doing this on an error is dubious
@ -956,7 +948,6 @@ aeintr(sc)
ae_rint(sc);
}
}
/*
* If it looks like the transmitter can take more data, attempt
* to start output on the interface. This is done after
@ -983,26 +974,24 @@ aeintr(sc)
(void) NIC_GET(sc, ED_P0_CNTR1);
(void) NIC_GET(sc, ED_P0_CNTR2);
}
isr = NIC_GET(sc, ED_P0_ISR);
if (!isr)
return;
}
}
/*
* Process an ioctl request. This code needs some work - it looks pretty ugly.
*/
int
ae_ioctl(ifp, command, data)
register struct ifnet *ifp;
u_long command;
u_long command;
caddr_t data;
{
struct ae_softc *sc = aecd.cd_devs[ifp->if_unit];
register struct ifaddr *ifa = (struct ifaddr *)data;
struct ifreq *ifr = (struct ifreq *)data;
int s, error = 0;
register struct ifaddr *ifa = (struct ifaddr *) data;
struct ifreq *ifr = (struct ifreq *) data;
int s, error = 0;
s = splimp();
@ -1019,22 +1008,22 @@ ae_ioctl(ifp, command, data)
break;
#endif
#ifdef NS
/* XXX - This code is probably wrong. */
/* XXX - This code is probably wrong. */
case AF_NS:
{
register struct ns_addr *ina = &IA_SNS(ifa)->sns_addr;
{
register struct ns_addr *ina = &IA_SNS(ifa)->sns_addr;
if (ns_nullhost(*ina))
ina->x_host =
*(union ns_host *)(sc->sc_arpcom.ac_enaddr);
else
bcopy(ina->x_host.c_host,
sc->sc_arpcom.ac_enaddr,
sizeof(sc->sc_arpcom.ac_enaddr));
/* Set new address. */
ae_init(sc);
break;
}
if (ns_nullhost(*ina))
ina->x_host =
*(union ns_host *) (sc->sc_arpcom.ac_enaddr);
else
bcopy(ina->x_host.c_host,
sc->sc_arpcom.ac_enaddr,
sizeof(sc->sc_arpcom.ac_enaddr));
/* Set new address. */
ae_init(sc);
break;
}
#endif
default:
ae_init(sc);
@ -1051,21 +1040,22 @@ ae_ioctl(ifp, command, data)
*/
ae_stop(sc);
ifp->if_flags &= ~IFF_RUNNING;
} else if ((ifp->if_flags & IFF_UP) != 0 &&
(ifp->if_flags & IFF_RUNNING) == 0) {
/*
* If interface is marked up and it is stopped, then
* start it.
*/
ae_init(sc);
} else {
/*
* Reset the interface to pick up changes in any other
* flags that affect hardware registers.
*/
ae_stop(sc);
ae_init(sc);
}
} else
if ((ifp->if_flags & IFF_UP) != 0 &&
(ifp->if_flags & IFF_RUNNING) == 0) {
/*
* If interface is marked up and it is stopped, then
* start it.
*/
ae_init(sc);
} else {
/*
* Reset the interface to pick up changes in any other
* flags that affect hardware registers.
*/
ae_stop(sc);
ae_init(sc);
}
break;
case SIOCADDMULTI:
@ -1080,7 +1070,7 @@ ae_ioctl(ifp, command, data)
* Multicast list has changed; set the hardware filter
* accordingly.
*/
ae_stop(sc); /* XXX for ds_setmcaf? */
ae_stop(sc); /* XXX for ds_setmcaf? */
ae_init(sc);
error = 0;
}
@ -1093,7 +1083,6 @@ ae_ioctl(ifp, command, data)
splx(s);
return (error);
}
/*
* Retreive packet from shared memory and send to the next level up via
* ether_input(). If there is a BPF listener, give a copy to BPF, too.
@ -1105,7 +1094,7 @@ ae_get_packet(sc, buf, len)
u_short len;
{
struct ether_header *eh;
struct mbuf *m, *ae_ring_to_mbuf();
struct mbuf *m, *ae_ring_to_mbuf();
/* Allocate a header mbuf. */
MGETHDR(m, M_DONTWAIT, MT_DATA);
@ -1136,7 +1125,6 @@ ae_get_packet(sc, buf, len)
m_freem(m);
return;
}
#if NBPFILTER > 0
/*
* Check if there's a BPF listener on this interface. If so, hand off
@ -1151,9 +1139,9 @@ ae_get_packet(sc, buf, len)
* mode, we have to check if this packet is really ours.
*/
if ((sc->sc_arpcom.ac_if.if_flags & IFF_PROMISC) &&
(eh->ether_dhost[0] & 1) == 0 && /* !mcast and !bcast */
(eh->ether_dhost[0] & 1) == 0 && /* !mcast and !bcast */
bcmp(eh->ether_dhost, sc->sc_arpcom.ac_enaddr,
sizeof(eh->ether_dhost)) != 0) {
sizeof(eh->ether_dhost)) != 0) {
m_freem(m);
return;
}
@ -1164,7 +1152,6 @@ ae_get_packet(sc, buf, len)
m_adj(m, sizeof(struct ether_header));
ether_input(&sc->sc_arpcom.ac_if, eh, m);
}
/*
* Supporting routines.
*/
@ -1177,9 +1164,9 @@ static inline caddr_t
ae_ring_copy(sc, src, dst, amount)
struct ae_softc *sc;
caddr_t src, dst;
u_short amount;
u_short amount;
{
u_short tmp_amount;
u_short tmp_amount;
/* Does copy wrap to lower addr in ring buffer? */
if (src + amount > sc->mem_end) {
@ -1192,12 +1179,10 @@ ae_ring_copy(sc, src, dst, amount)
src = sc->mem_ring;
dst += tmp_amount;
}
byte_copy(src, dst, amount);
return (src + amount);
}
/*
* Copy data from receive buffer to end of mbuf chain allocate additional mbufs
* as needed. Return pointer to last mbuf in chain.
@ -1244,7 +1229,6 @@ ae_ring_to_mbuf(sc, src, dst, total_len)
dst->m_next = m;
amount = min(total_len, M_TRAILINGSPACE(m));
}
src = ae_ring_copy(sc, src, mtod(m, caddr_t) + m->m_len,
amount);
@ -1253,7 +1237,6 @@ ae_ring_to_mbuf(sc, src, dst, total_len)
}
return (m);
}
/*
* Compute the multicast address filter from the list of multicast addresses we
* need to listen to.
@ -1283,12 +1266,11 @@ ae_getmcaf(ac, af)
af[0] = af[1] = 0xffffffff;
return;
}
af[0] = af[1] = 0;
ETHER_FIRST_MULTI(step, ac, enm);
while (enm != NULL) {
if (bcmp(enm->enm_addrlo, enm->enm_addrhi,
sizeof(enm->enm_addrlo)) != 0) {
sizeof(enm->enm_addrlo)) != 0) {
/*
* We must listen to a range of multicast addresses.
* For now, just accept all multicasts, rather than
@ -1301,7 +1283,6 @@ ae_getmcaf(ac, af)
af[0] = af[1] = 0xffffffff;
return;
}
cp = enm->enm_addrlo;
crc = 0xffffffff;
for (len = sizeof(enm->enm_addrlo); --len >= 0;) {
@ -1325,7 +1306,6 @@ ae_getmcaf(ac, af)
}
ifp->if_flags &= ~IFF_ALLMULTI;
}
/*
* Copy packet from mbuf to the board memory
*
@ -1340,8 +1320,8 @@ ae_put(sc, m, buf)
caddr_t buf;
{
u_char *data, savebyte[2];
int len, wantbyte;
u_short totlen=0;
int len, wantbyte;
u_short totlen = 0;
wantbyte = 0;
@ -1378,6 +1358,5 @@ ae_put(sc, m, buf)
savebyte[1] = 0;
word_copy(savebyte, buf, 2);
}
return (totlen);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_aereg.h,v 1.8 1995/04/19 04:46:06 briggs Exp $ */
/* $NetBSD: if_aereg.h,v 1.9 1995/04/21 02:47:55 briggs Exp $ */
/*
* National Semiconductor DS8390 NIC register definitions.
@ -17,12 +17,11 @@
* have the card in m68k mode, we're hosed for the moment.
* Fix this. -- XXX
*/
struct ae_ring {
u_char rsr; /* receiver status */
u_char next_packet; /* pointer to next packet */
u_short count; /* bytes in packet (length + 4) */
struct ae_ring {
u_char rsr; /* receiver status */
u_char next_packet; /* pointer to next packet */
u_short count; /* bytes in packet (length + 4) */
};
/*
* Vendor types
*/
@ -46,15 +45,15 @@ struct ae_ring {
#define AE_FLAGS_NO_DOUBLE_BUFFERING 0x0008
/* */
#define GC_RESET_OFFSET 0x000c0000 /* writes here reset NIC */
#define GC_ROM_OFFSET 0x000c0000 /* address prom */
#define GC_DATA_OFFSET 0x000d0000 /* Offset to NIC memory */
#define GC_NIC_OFFSET 0x000e0000 /* Offset to NIC registers */
#define GC_RESET_OFFSET 0x000c0000 /* writes here reset NIC */
#define GC_ROM_OFFSET 0x000c0000 /* address prom */
#define GC_DATA_OFFSET 0x000d0000 /* Offset to NIC memory */
#define GC_NIC_OFFSET 0x000e0000 /* Offset to NIC registers */
#define DP_ROM_OFFSET 0x000f0000
#define DP_DATA_OFFSET 0x000d0000 /* Offset to SONIC memory */
#define DP_NIC_OFFSET 0x000e0000 /* Offset to SONIC registers */
#define DP_DATA_OFFSET 0x000d0000 /* Offset to SONIC memory */
#define DP_NIC_OFFSET 0x000e0000 /* Offset to SONIC registers */
#define AE_ROM_OFFSET 0x000f0000
#define AE_DATA_OFFSET 0x000d0000 /* Offset to NIC memory */
#define AE_NIC_OFFSET 0x000e0000 /* Offset to NIC registers */
#define AE_DATA_OFFSET 0x000d0000 /* Offset to NIC memory */
#define AE_NIC_OFFSET 0x000e0000 /* Offset to NIC registers */

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
/* $NetBSD: nubus.h,v 1.3 1994/10/26 08:46:15 cgd Exp $ */
/* $NetBSD: nubus.h,v 1.4 1995/04/21 02:48:01 briggs Exp $ */
/*-
* Copyright (C) 1993 Allen K. Briggs, Chris P. Caputo,
@ -38,36 +38,34 @@
#define NUBUS_MOTHERBOARD 0x0a
#define NUBUS_MAXSLOTS 16
struct imagedata{
long whatTheHellIsThis;
long offset;
short rowbytes;
short top;
short left;
short right;
short bottom;
short version;
short packType;
short packSize;
long hRes;
long vRes;
short pixelType;
short pixelSize;
struct imagedata {
long whatTheHellIsThis;
long offset;
short rowbytes;
short top;
short left;
short right;
short bottom;
short version;
short packType;
short packSize;
long hRes;
long vRes;
short pixelType;
short pixelSize;
};
/* this is the main data structure that points to good stuff */
struct header {
long offset;
long length;
long crc;
char romrev;
char format;
long tst;
char reserved;
char bytelane;
} ;
long offset;
long length;
long crc;
char romrev;
char format;
long tst;
char reserved;
char bytelane;
};
/* this is what the directory entries contain */
struct dir {
@ -78,20 +76,20 @@ struct dir {
/* describe a single slot */
struct slot {
int size;
int size;
struct header head;
struct dir mainDir[15];
long type;
char name[40];
char manufacturer[40];
long type;
char name[40];
char manufacturer[40];
};
struct nubus_hw{
int found; /* If there is a card there */
caddr_t addr; /* Phys addr of start of card */
caddr_t rom; /* Phys addr of start of ROM */
int claimed; /* TRUE if a driver claims this */
struct slot Slot; /* MF NUBUS STUFF */
/* any other Nubus stuff we can think of when we get */
/* the NuBus documentation */
struct nubus_hw {
int found; /* If there is a card there */
caddr_t addr; /* Phys addr of start of card */
caddr_t rom; /* Phys addr of start of ROM */
int claimed; /* TRUE if a driver claims this */
struct slot slot; /* MF NUBUS STUFF */
/* any other Nubus stuff we can think of when we get */
/* the NuBus documentation */
};

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
/* $NetBSD: scsi96.c,v 1.8 1995/01/15 06:27:56 briggs Exp $ */
/* $NetBSD: scsi96.c,v 1.9 1995/04/21 02:48:04 briggs Exp $ */
/*
* Copyright (C) 1994 Allen K. Briggs
@ -52,24 +52,23 @@
/* Support for the NCR 53C96 SCSI processor--primarily for '040 Macs. */
#ifdef DDB
int Debugger();
int Debugger();
#else
#define Debugger() panic("Should call Debugger here (mac/dev/scsi96.c).")
#endif
#define NNCR53C96 1
static volatile unsigned char *ncr53c96base =
(volatile unsigned char *) 0xF000; /* Offset from IOBase */
static volatile unsigned char *ncr53c96base =
(volatile unsigned char *) 0xF000; /* Offset from IOBase */
struct ncr53c96_data {
struct device sc_dev;
void *reg_base;
int adapter_target;
struct scsi_link sc_link;
} *ncr53c96data[NNCR53C96];
struct device sc_dev;
void *reg_base;
int adapter_target;
struct scsi_link sc_link;
} *ncr53c96data[NNCR53C96];
#define WAIT_FOR(reg, val) { \
int timeo=100000; \
while (!(reg & val)) { \
@ -80,69 +79,65 @@ struct ncr53c96_data {
} \
}
static unsigned int ncr53c96_adapter_info(struct ncr53c96_data *ncr53c96);
static void ncr53c96_minphys(struct buf *bp);
static int ncr53c96_scsi_cmd(struct scsi_xfer *xs);
static unsigned int ncr53c96_adapter_info(struct ncr53c96_data * ncr53c96);
static void ncr53c96_minphys(struct buf * bp);
static int ncr53c96_scsi_cmd(struct scsi_xfer * xs);
static int ncr53c96_show_scsi_cmd(struct scsi_xfer *xs);
static int ncr53c96_reset_target(int adapter, int target);
static int ncr53c96_poll(int adapter, int timeout);
static int ncr53c96_send_cmd(struct scsi_xfer *xs);
static int ncr53c96_show_scsi_cmd(struct scsi_xfer * xs);
static int ncr53c96_reset_target(int adapter, int target);
static int ncr53c96_poll(int adapter, int timeout);
static int ncr53c96_send_cmd(struct scsi_xfer * xs);
struct scsi_adapter ncr53c96_switch = {
ncr53c96_scsi_cmd, /* scsi_cmd() */
ncr53c96_minphys, /* scsi_minphys() */
0, /* open_target_lu() */
0, /* close_target_lu() */
struct scsi_adapter ncr53c96_switch = {
ncr53c96_scsi_cmd, /* scsi_cmd() */
ncr53c96_minphys, /* scsi_minphys() */
0, /* open_target_lu() */
0, /* close_target_lu() */
};
/* This is copied from julian's bt driver */
/* "so we have a default dev struct for our link struct." */
struct scsi_device ncr53c96_dev = {
NULL, /* Use default error handler. */
NULL, /* have a queue, served by this (?) */
NULL, /* have no async handler. */
NULL, /* Use default "done" routine. */
NULL, /* Use default error handler. */
NULL, /* have a queue, served by this (?) */
NULL, /* have no async handler. */
NULL, /* Use default "done" routine. */
};
extern int matchbyname();
static int ncr96probe();
static void ncr96attach();
extern int matchbyname();
static int ncr96probe();
static void ncr96attach();
struct cfdriver ncr96scsicd =
{ NULL, "ncr96scsi", ncr96probe, ncr96attach,
DV_DULL, sizeof(struct ncr53c96_data), NULL, 0 };
{NULL, "ncr96scsi", ncr96probe, ncr96attach,
DV_DULL, sizeof(struct ncr53c96_data), NULL, 0};
static int
ncr96_print(aux, name)
void *aux;
char *name;
void *aux;
char *name;
{
/* printf("%s: (sc_link = 0x%x)", name, (int) aux);
return UNCONF;*/
/* printf("%s: (sc_link = 0x%x)", name, (int) aux); return UNCONF; */
}
static int
ncr96probe(parent, cf, aux)
struct device *parent;
struct cfdata *cf;
void *aux;
struct device *parent;
struct cfdata *cf;
void *aux;
{
static int probed = 0;
int unit = cf->cf_unit;
struct ncr53c96_data *ncr53c96;
static int probed = 0;
int unit = cf->cf_unit;
struct ncr53c96_data *ncr53c96;
if (!mac68k_machine.scsi96) {
return 0;
}
if (strcmp(*((char **) aux), ncr96scsicd.cd_name)) {
return 0;
}
if (unit >= NNCR53C96) {
if (unit >= NNCR53C96) {
printf("ncr53c96attach: unit %d more than %d configured.\n",
unit+1, NNCR53C96);
unit + 1, NNCR53C96);
return 0;
}
ncr53c96 = malloc(sizeof(struct ncr53c96_data), M_TEMP, M_NOWAIT);
@ -150,32 +145,30 @@ static int probed = 0;
printf("ncr53c96attach: Can't malloc.\n");
return 0;
}
bzero(ncr53c96, sizeof(*ncr53c96));
ncr53c96data[unit] = ncr53c96;
if (!probed) {
int i;
int i;
probed = 1;
ncr53c96base += IOBase;
}
return 1;
}
static void
ncr96attach(parent, dev, aux)
struct device *parent, *dev;
void *aux;
struct device *parent, *dev;
void *aux;
{
int unit = dev->dv_unit;
struct ncr53c96_data *ncr53c96 = ncr53c96data[unit];
int r;
int unit = dev->dv_unit;
struct ncr53c96_data *ncr53c96 = ncr53c96data[unit];
int r;
bcopy((char *) ncr53c96 + sizeof(struct device),
(char *) dev + sizeof(struct device),
sizeof(struct ncr53c96_data) - sizeof(struct device));
(char *) dev + sizeof(struct device),
sizeof(struct ncr53c96_data) - sizeof(struct device));
free(ncr53c96, M_TEMP);
ncr53c96data[unit] = ncr53c96 = (struct ncr53c96_data *) dev;
@ -196,50 +189,49 @@ ncr96attach(parent, dev, aux)
}
static unsigned int
ncr53c96_adapter_info(struct ncr53c96_data *ncr53c96)
ncr53c96_adapter_info(struct ncr53c96_data * ncr53c96)
{
return 1;
}
#define MIN_PHYS 65536 /*BARF!!!!*/
#define MIN_PHYS 65536 /* BARF!!!! */
static void
ncr53c96_minphys(struct buf *bp)
ncr53c96_minphys(struct buf * bp)
{
if (bp->b_bcount > MIN_PHYS) {
printf("Uh-oh... ncr53c96_minphys setting bp->b_bcount "
"= %x.\n", MIN_PHYS);
"= %x.\n", MIN_PHYS);
bp->b_bcount = MIN_PHYS;
}
}
#undef MIN_PHYS
static int
ncr53c96_scsi_cmd(struct scsi_xfer *xs)
ncr53c96_scsi_cmd(struct scsi_xfer * xs)
{
int flags, s, r;
int flags, s, r;
flags = xs->flags;
if (xs->bp) flags |= (SCSI_NOSLEEP);
if ( flags & ITSDONE ) {
if (xs->bp)
flags |= (SCSI_NOSLEEP);
if (flags & ITSDONE) {
printf("Already done?");
xs->flags &= ~ITSDONE;
}
if ( ! ( flags & INUSE ) ) {
if (!(flags & INUSE)) {
printf("Not in use?");
xs->flags |= INUSE;
}
if ( flags & SCSI_RESET ) {
if (flags & SCSI_RESET) {
printf("flags & SCSIRESET.\n");
if ( ! ( flags & SCSI_NOSLEEP ) ) {
if (!(flags & SCSI_NOSLEEP)) {
s = splbio();
ncr53c96_reset_target(xs->sc_link->scsibus,
xs->sc_link->target);
xs->sc_link->target);
splx(s);
return(SUCCESSFULLY_QUEUED);
return (SUCCESSFULLY_QUEUED);
} else {
ncr53c96_reset_target(xs->sc_link->scsibus,
xs->sc_link->target);
xs->sc_link->target);
if (ncr53c96_poll(xs->sc_link->scsibus, xs->timeout)) {
return (COMPLETE);
}
@ -262,14 +254,15 @@ ncr53c96_scsi_cmd(struct scsi_xfer *xs)
r = ncr53c96_send_cmd(xs);
xs->flags |= ITSDONE;
scsi_done(xs);
switch(r) {
case COMPLETE: case SUCCESSFULLY_QUEUED:
r = SUCCESSFULLY_QUEUED;
if (xs->flags&SCSI_POLL)
r = COMPLETE;
break;
default:
break;
switch (r) {
case COMPLETE:
case SUCCESSFULLY_QUEUED:
r = SUCCESSFULLY_QUEUED;
if (xs->flags & SCSI_POLL)
r = COMPLETE;
break;
default:
break;
}
return r;
/*
@ -286,27 +279,27 @@ ncr53c96_scsi_cmd(struct scsi_xfer *xs)
}
static int
ncr53c96_show_scsi_cmd(struct scsi_xfer *xs)
ncr53c96_show_scsi_cmd(struct scsi_xfer * xs)
{
u_char *b = (u_char *) xs->cmd;
int i = 0;
u_char *b = (u_char *) xs->cmd;
int i = 0;
if ( ! ( xs->flags & SCSI_RESET ) ) {
if (!(xs->flags & SCSI_RESET)) {
printf("ncr53c96(%d:%d:%d)-",
xs->sc_link->scsibus, xs->sc_link->target,
xs->sc_link->lun);
xs->sc_link->scsibus, xs->sc_link->target,
xs->sc_link->lun);
while (i < xs->cmdlen) {
if (i) printf(",");
printf("%x",b[i++]);
if (i)
printf(",");
printf("%x", b[i++]);
}
printf("-\n");
} else {
printf("ncr53c96(%d:%d:%d)-RESET-\n",
xs->sc_link->scsibus, xs->sc_link->target,
xs->sc_link->lun);
xs->sc_link->scsibus, xs->sc_link->target,
xs->sc_link->lun);
}
}
/*
* Actual chip control.
*/
@ -341,23 +334,23 @@ ncr53c96_poll(int adapter, int timeout)
}
static int
do_send_cmd(struct scsi_xfer *xs)
do_send_cmd(struct scsi_xfer * xs)
{
struct ncr53c96regs *ncr = (struct ncr53c96regs *) ncr53c96base;
u_char *cmd;
int i, stat, is, intr;
int status, msg, phase;
struct ncr53c96regs *ncr = (struct ncr53c96regs *) ncr53c96base;
u_char *cmd;
int i, stat, is, intr;
int status, msg, phase;
xs->resid=0;
i = (int) ncr->statreg; /* clear interrupts */
xs->resid = 0;
i = (int) ncr->statreg; /* clear interrupts */
ncr->cmdreg = NCR96_CMD_CLRFIFO; /* and fifo */
cmd = (u_char *) xs->cmd;
for (i = 0 ; i < xs->cmdlen ; i++)
for (i = 0; i < xs->cmdlen; i++)
ncr->fifo = *cmd++;
ncr->tcreg_lsb = xs->cmdlen;
ncr->tcreg_msb = 0;
ncr->stimreg = 122; /* XXX */
ncr->stimreg = 122; /* XXX */
ncr->sdidreg = xs->sc_link->target;
/* ncr->ctrlreg1 = 0x47; from the mac -- inherited*/
ncr->cmdreg = NCR96_CMD_SEL;
@ -367,50 +360,50 @@ do_send_cmd(struct scsi_xfer *xs)
stat = ncr->statreg;
is = ncr->isreg;
intr = ncr->instreg;
if ((is&0x07) != 0x4 || intr != 0x18) {
if ((is&0x7) != 0x0 || intr != 0x20) {
if ((is & 0x07) != 0x4 || intr != 0x18) {
if ((is & 0x7) != 0x0 || intr != 0x20) {
printf("scsi96: stat = 0x%x, is = 0x%x, intr = 0x%x\n",
stat, is, intr);
stat, is, intr);
}
goto have_error;
}
printf("scsi96: before loop: stat = 0x%x, is = 0x%x, intr = 0x%x, "
"datalen = %d\n", stat, is, intr, xs->datalen);
"datalen = %d\n", stat, is, intr, xs->datalen);
phase = ncr->statreg & NCR96_STAT_PHASE;
if (((phase == 0x01) || (phase == 0x00)) && xs->datalen) {
printf("data = 0x%x, datalen = 0x%x.\n", xs->data, xs->datalen);
stat = ncr->statreg;
is = ncr->isreg;
intr = ncr->instreg;
printf("entering info xfer...stat = 0x%x, is = 0x%x, intr = 0x%x\n",
stat, is, intr);
ncr->tcreg_lsb = (xs->datalen & 0xff);
ncr->tcreg_msb = (xs->datalen >> 8) & 0xff;
ncr->cmdreg = 0x80 | NCR96_CMD_INFOXFER;
printf("rem... %d.\n", ncr->tcreg_lsb | (ncr->tcreg_msb << 8));
i=0;
while (i < xs->datalen) {
int d, stat;
WAIT_FOR(ncr->statreg, NCR96_STAT_INT);
printf("data = 0x%x, datalen = 0x%x.\n", xs->data, xs->datalen);
stat = ncr->statreg;
for (d=1000000 ; d && !(via_reg(VIA2, vIFR) & 0x01);d--);
if (d<=0) printf("read timeout.\n");
d = ncr->fifostatereg & NCR96_CF_MASK;
while (d--) {
xs->data[i++] = ncr->fifo;
printf("0x%x,",xs->data[i-1]);
}
is = ncr->isreg;
intr = ncr->instreg;
printf("\nin loop. stat = 0x%x, intr = 0x%x, cnt = %d. ",
stat, intr, cnt);
printf("entering info xfer...stat = 0x%x, is = 0x%x, intr = 0x%x\n",
stat, is, intr);
ncr->tcreg_lsb = (xs->datalen & 0xff);
ncr->tcreg_msb = (xs->datalen >> 8) & 0xff;
ncr->cmdreg = 0x80 | NCR96_CMD_INFOXFER;
printf("rem... %d.\n", ncr->tcreg_lsb | (ncr->tcreg_msb << 8));
}
i = 0;
while (i < xs->datalen) {
int d, stat;
WAIT_FOR(ncr->statreg, NCR96_STAT_INT);
stat = ncr->statreg;
for (d = 1000000; d && !(via_reg(VIA2, vIFR) & 0x01); d--);
if (d <= 0)
printf("read timeout.\n");
d = ncr->fifostatereg & NCR96_CF_MASK;
while (d--) {
xs->data[i++] = ncr->fifo;
printf("0x%x,", xs->data[i - 1]);
}
intr = ncr->instreg;
printf("\nin loop. stat = 0x%x, intr = 0x%x, cnt = %d. ",
stat, intr, cnt);
printf("rem... %d.\n", ncr->tcreg_lsb | (ncr->tcreg_msb << 8));
}
/* } else {
WAIT_FOR(ncr->statreg, NCR96_STAT_INT); */
}
@ -418,7 +411,7 @@ if (d<=0) printf("read timeout.\n");
is = ncr->isreg;
intr = ncr->instreg;
printf("past loop...stat = 0x%x, is = 0x%x, intr = 0x%x\n",
stat, is, intr);
stat, is, intr);
ncr->cmdreg = NCR96_CMD_ICCS;
@ -447,18 +440,19 @@ have_error:
}
static int
ncr53c96_send_cmd(struct scsi_xfer *xs)
ncr53c96_send_cmd(struct scsi_xfer * xs)
{
int r=COMPLETE;
int r = COMPLETE;
if (xs->sc_link->target >= 5) ncr53c96_show_scsi_cmd(xs);
if (xs->sc_link->target >= 5)
ncr53c96_show_scsi_cmd(xs);
switch (xs->cmd->opcode) {
case 0: /* TUN */
case 0x12:/* INQUIRY */
r = do_send_cmd(xs);
default:
xs->error = XS_DRIVER_STUFFUP;
r = COMPLETE;
case 0: /* TUN */
case 0x12: /* INQUIRY */
r = do_send_cmd(xs);
default:
xs->error = XS_DRIVER_STUFFUP;
r = COMPLETE;
}
return r;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: ser.c,v 1.21 1995/04/20 15:27:12 briggs Exp $ */
/* $NetBSD: ser.c,v 1.22 1995/04/21 02:48:06 briggs Exp $ */
/*
* Copyright (c) 1982, 1986, 1990 The Regents of the University of California.
@ -103,36 +103,35 @@
#undef DEBUG
struct ser_status {
unsigned char ddcd, dcts; /* delta (change) flags */
unsigned char dcd, cts; /* last state of signal */
unsigned char dtr, rts; /* current state of signal */
int oflo; /* s/w fifo over flow */
int over; /* h/w fifo over flow */
int flags;
unsigned char ddcd, dcts; /* delta (change) flags */
unsigned char dcd, cts; /* last state of signal */
unsigned char dtr, rts; /* current state of signal */
int oflo; /* s/w fifo over flow */
int over; /* h/w fifo over flow */
int flags;
#define SER_BUSY 0x01
};
#define INBUFLEN 128
#define OUTBUFLEN 512
struct ser_softc {
struct device sc_dev;
struct tty *sc_tty;
struct ser_status status;
struct device sc_dev;
struct tty *sc_tty;
struct ser_status status;
/* private buffers used by driver at splscc() */
u_char inbuf[INBUFLEN];
volatile u_char inlen;
u_char intail;
u_char inbuf[INBUFLEN];
volatile u_char inlen;
u_char intail;
u_char outbuf[OUTBUFLEN];
volatile u_int outlen;
volatile u_int outtail;
u_char outbuf[OUTBUFLEN];
volatile u_int outlen;
volatile u_int outtail;
};
extern int matchbyname();
static void serattach(struct device *par, struct device *dev, void *aux);
static void serinit(int);
extern int matchbyname();
static void serattach(struct device * par, struct device * dev, void *aux);
static void serinit(int);
struct cfdriver sercd = {
NULL, "ser", matchbyname, serattach, DV_TTY, sizeof(struct ser_softc)
@ -140,16 +139,16 @@ struct cfdriver sercd = {
volatile unsigned char *sccA = (unsigned char *) 0x4000;
static void serstart __P((register struct tty *));
static int serparam __P((register struct tty *, register struct termios *));
static int serctl __P((dev_t dev, int bits, int how));
extern int ser_intr __P((void));
static void serstart __P((register struct tty *));
static int serparam __P((register struct tty *, register struct termios *));
static int serctl __P((dev_t dev, int bits, int how));
extern int ser_intr __P((void));
static int ser_active = 0;
static int nser = NSER;
static int serdefaultrate = TTYDEF_SPEED;
static int ser_active = 0;
static int nser = NSER;
static int serdefaultrate = TTYDEF_SPEED;
extern struct tty *constty;
extern struct tty *constty;
#define UNIT(x) minor(x)
#define SER_TTY(unit) \
@ -160,39 +159,39 @@ extern struct tty *constty;
/* SCC initialization string from Steve Allen (wormey@eskimo.com) */
static unsigned char ser_init_bytes[]={
4, 0x44, /* Transmit/Receive control. Select Async or Sync
mode and clock multiplier. */
3, 0xc0, /* select receiver control. Bit d0 (rx enable)
must be set to 0 at this time. */
5, 0xe2, /* select transmit control. Bit d3 (tx enable)
must be set to 0 at this time. */
9, 0x06, /* select interrupt control. Bit d3 (mie)
must be set to 0 at this time. */
10, 0x00, /* miscellaneous control. */
11, 0x50, /* clock control. */
12, 0x04, /* time constant LB. */
13, 0x00, /* time constant HB. */
14, 0x00, /* miscellaneous control. Bit d0 (BR gen enable)
must be set to 0 at this time. */
3, 0xc1, /* set d0 (rx enable). */
5, 0xea, /* set d3 (tx enable). */
0, 0x80, /* reset txCRC. */
14, 0x01, /* BR gen enable. Enable DPLL. */
1, 0x00, /* make sure DMA not set. */
15, 0x00, /* disable external interrupts. */
0, 0x10, /* reset ext/status twice. */
0, 0x10,
1, 0x0a, /* enable rcv and xmit interrupts. */
9, 0x0e, /* enable master interrupt bit d3. */
static unsigned char ser_init_bytes[] = {
4, 0x44, /* Transmit/Receive control. Select Async or
* Sync mode and clock multiplier. */
3, 0xc0, /* select receiver control. Bit d0 (rx
* enable) must be set to 0 at this time. */
5, 0xe2, /* select transmit control. Bit d3 (tx
* enable) must be set to 0 at this time. */
9, 0x06, /* select interrupt control. Bit d3 (mie)
* must be set to 0 at this time. */
10, 0x00, /* miscellaneous control. */
11, 0x50, /* clock control. */
12, 0x04, /* time constant LB. */
13, 0x00, /* time constant HB. */
14, 0x00, /* miscellaneous control. Bit d0 (BR gen
* enable) must be set to 0 at this time. */
3, 0xc1, /* set d0 (rx enable). */
5, 0xea, /* set d3 (tx enable). */
0, 0x80, /* reset txCRC. */
14, 0x01, /* BR gen enable. Enable DPLL. */
1, 0x00, /* make sure DMA not set. */
15, 0x00, /* disable external interrupts. */
0, 0x10, /* reset ext/status twice. */
0, 0x10,
1, 0x0a, /* enable rcv and xmit interrupts. */
9, 0x0e, /* enable master interrupt bit d3. */
};
static void
serinit(int running_interrupts)
{
static int initted=0;
int bcount;
int i, s, spd;
static int initted = 0;
int bcount;
int i, s, spd;
/*
* Will be called twice if we're running a serial console.
@ -212,14 +211,14 @@ static int initted=0;
* initialize ports, substituting proper speed.
*/
bcount = sizeof(ser_init_bytes);
for(i = 0; i < bcount; i += 2){
for (i = 0; i < bcount; i += 2) {
if (ser_init_bytes[i] == 12) /* baud rate low byte */
ser_init_bytes[i+1] = (spd & 0xff);
ser_init_bytes[i + 1] = (spd & 0xff);
if (ser_init_bytes[i] == 13) /* baud rate high byte */
ser_init_bytes[i+1] = ((spd>>8) & 0xff);
ser_init_bytes[i + 1] = ((spd >> 8) & 0xff);
if (!running_interrupts) {
if ( ser_init_bytes[i] == 0x01
&& ser_init_bytes[i+1] == 0x0a)
if (ser_init_bytes[i] == 0x01
&& ser_init_bytes[i + 1] == 0x0a)
break;
}
SER_DOCNTL(0, ser_init_bytes[i], ser_init_bytes[i + 1]);
@ -231,8 +230,8 @@ static int initted=0;
static void
serattach(parent, dev, aux)
struct device *parent, *dev;
void *aux;
struct device *parent, *dev;
void *aux;
{
if (mac68k_machine.serial_boot_echo) {
printf(" (serial boot echo is on)\n");
@ -241,16 +240,15 @@ serattach(parent, dev, aux)
serinit(1);
}
/* ARGSUSED */
extern int
seropen(dev_t dev, int flag, int mode, struct proc *p)
seropen(dev_t dev, int flag, int mode, struct proc * p)
{
struct ser_softc *sc;
register struct tty *tp;
register int unit = UNIT(dev);
int error = 0;
int error = 0;
#if defined(DEBUG)
printf("ser: entered seropen(%d, %d, %d, xx)\n", dev, flag, mode);
#endif
@ -281,19 +279,19 @@ seropen(dev_t dev, int flag, int mode, struct proc *p)
}
serparam(tp, &tp->t_termios);
ttsetwater(tp);
} else if (tp->t_state&TS_XCLUDE && p->p_ucred->cr_uid != 0){
printf("ser%d: device is busy.\n", unit);
return EBUSY;
}
} else
if (tp->t_state & TS_XCLUDE && p->p_ucred->cr_uid != 0) {
printf("ser%d: device is busy.\n", unit);
return EBUSY;
}
/* serial device open code */
bzero((char *)&sc->status, sizeof(struct ser_status));
bzero((char *) &sc->status, sizeof(struct ser_status));
/* turn on RTS & DTR */
serctl(unit, ZSWR5_RTS | ZSWR5_DTR, DMSET);
if(serctl(unit, 0, DMGET) & ZSRR0_DCD)
if (serctl(unit, 0, DMGET) & ZSRR0_DCD)
tp->t_state |= TS_CARR_ON;
/* enable interrupts */
@ -302,16 +300,16 @@ seropen(dev_t dev, int flag, int mode, struct proc *p)
/* end serial device open code */
(void) spltty();
while ((flag&O_NONBLOCK) == 0 && (tp->t_cflag&CLOCAL) == 0 &&
(tp->t_state & TS_CARR_ON) == 0) {
while ((flag & O_NONBLOCK) == 0 && (tp->t_cflag & CLOCAL) == 0 &&
(tp->t_state & TS_CARR_ON) == 0) {
tp->t_state |= TS_WOPEN;
if (error = ttysleep(tp, (caddr_t)&tp->t_rawq, TTIPRI | PCATCH,
ttopen, 0))
if (error = ttysleep(tp, (caddr_t) & tp->t_rawq, TTIPRI | PCATCH,
ttopen, 0))
break;
}
(void) spl0();
if (error == 0)
error = (*linesw[tp->t_line].l_open)(dev, tp);
error = (*linesw[tp->t_line].l_open) (dev, tp);
#if defined(DEBUG)
printf("ser: exiting seropen()\n");
@ -319,27 +317,26 @@ seropen(dev_t dev, int flag, int mode, struct proc *p)
return (error);
}
/*ARGSUSED*/
extern int
serclose(dev_t dev, int flag, int mode, struct proc *p)
serclose(dev_t dev, int flag, int mode, struct proc * p)
{
register int unit = UNIT(dev);
register struct tty *tp = SER_TTY(unit);
int s;
int s;
#if defined(DEBUG)
printf("ser: entered serclose()\n");
#endif
(*linesw[tp->t_line].l_close)(tp, flag);
(*linesw[tp->t_line].l_close) (tp, flag);
/* serial device close code */
/* disable interrupts */
serctl(unit, 0, SCC_INT);
if (tp->t_cflag&HUPCL || tp->t_state&TS_WOPEN ||
(tp->t_state&TS_ISOPEN) == 0)
if (tp->t_cflag & HUPCL || tp->t_state & TS_WOPEN ||
(tp->t_state & TS_ISOPEN) == 0)
serctl(unit, 0, DMSET); /* turn RTS and DTR off */
ser_active &= ~(1 << unit);
@ -355,37 +352,36 @@ serclose(dev_t dev, int flag, int mode, struct proc *p)
#endif
return (0);
}
extern int
serread(dev, uio, flag)
dev_t dev;
dev_t dev;
struct uio *uio;
int flag;
int flag;
{
register struct tty *tp = SER_TTY(UNIT(dev));
#if defined(DEBUG)
printf("ser: called serread()\n");
#endif
return ((*linesw[tp->t_line].l_read)(tp, uio, flag));
return ((*linesw[tp->t_line].l_read) (tp, uio, flag));
}
extern int
serwrite(dev, uio, flag)
dev_t dev;
dev_t dev;
struct uio *uio;
int flag;
int flag;
{
register struct tty *tp = SER_TTY(UNIT(dev));
#if defined(DEBUG)
printf("ser: called serwrite()\n");
#endif
return ((*linesw[tp->t_line].l_write)(tp, uio, flag));
return ((*linesw[tp->t_line].l_write) (tp, uio, flag));
}
/*
* NOTE: This function is called by locore.s on a level 4 interrupt.
* NOTE: This function is called by locore.s on a level 4 interrupt.
* since "splscc()" is level 4, and this is currently higher than
* anything except splhigh(), you can't call anything from this
* routine or you'll break the syncronization. basically we just
@ -397,93 +393,92 @@ serwrite(dev, uio, flag)
extern int
ser_intr(void)
{
register struct ser_softc *sc;
unsigned char reg0, reg1, ch, ch1, c, bits;
int s;
register int unit;
register struct ser_softc *sc;
unsigned char reg0, reg1, ch, ch1, c, bits;
int s;
register int unit;
/* read status to reset SCC state machine */
reg0 = SCCCNTL(0);
/* read status to reset SCC state machine */
reg0 = SCCCNTL(0);
/* reset port B vector to see who interrupted us */
bits = SER_STATUS(1, 2) & 0x0e;
if (bits < 8)
unit = 1;
else
unit = 0;
sc = sercd.cd_devs[unit];
reg0 = SER_STATUS(unit, 0);
switch ((bits & 7) >> 1) {
case 0: /* tranmitter buffer empty */
if (sc->outlen > 0)
{
c = sc->outbuf[sc->outtail];
sc->outtail = (sc->outtail + 1) % OUTBUFLEN;
SCCRDWR(unit) = c;
sc->outlen--;
} else {
SER_DOCNTL(unit, 0, ZSWR0_RESET_TXINT);
sc->status.flags &= ~SER_BUSY;
setsoftserial();
}
SER_DOCNTL(unit, 0, ZSWR0_CLR_INTR);
break;
case 1: /* ext/status change */
if ((reg0 & ZSRR0_DCD) && sc->status.dcd == 0)
sc->status.ddcd = 1;
/* reset port B vector to see who interrupted us */
bits = SER_STATUS(1, 2) & 0x0e;
if (bits < 8)
unit = 1;
else
if (!(reg0 & ZSRR0_DCD) && sc->status.dcd != 0)
unit = 0;
sc = sercd.cd_devs[unit];
reg0 = SER_STATUS(unit, 0);
switch ((bits & 7) >> 1) {
case 0: /* tranmitter buffer empty */
if (sc->outlen > 0) {
c = sc->outbuf[sc->outtail];
sc->outtail = (sc->outtail + 1) % OUTBUFLEN;
SCCRDWR(unit) = c;
sc->outlen--;
} else {
SER_DOCNTL(unit, 0, ZSWR0_RESET_TXINT);
sc->status.flags &= ~SER_BUSY;
setsoftserial();
}
SER_DOCNTL(unit, 0, ZSWR0_CLR_INTR);
break;
case 1: /* ext/status change */
if ((reg0 & ZSRR0_DCD) && sc->status.dcd == 0)
sc->status.ddcd = 1;
sc->status.dcd = reg0 & ZSRR0_DCD;
else
if (!(reg0 & ZSRR0_DCD) && sc->status.dcd != 0)
sc->status.ddcd = 1;
sc->status.dcd = reg0 & ZSRR0_DCD;
if ((reg0 & ZSRR0_CTS) && sc->status.cts == 0)
sc->status.dcts = 1;
else
if (!(reg0 & ZSRR0_CTS) && sc->status.cts != 0)
if ((reg0 & ZSRR0_CTS) && sc->status.cts == 0)
sc->status.dcts = 1;
sc->status.cts = reg0 & ZSRR0_CTS;
else
if (!(reg0 & ZSRR0_CTS) && sc->status.cts != 0)
sc->status.dcts = 1;
sc->status.cts = reg0 & ZSRR0_CTS;
if (reg0 & ZSRR0_TXUNDER)
SER_DOCNTL(unit, 0, ZSWR0_RESET_EOM);
if (reg0 & ZSRR0_TXUNDER)
SER_DOCNTL(unit, 0, ZSWR0_RESET_EOM);
SER_DOCNTL(unit, 0, ZSWR0_RESET_STATUS);
SER_DOCNTL(unit, 0, ZSWR0_CLR_INTR);
break;
case 2: /* recv char available */
ch = SCCRDWR(unit);
c = 1;
if (SER_STATUS(unit, 0) & ZSRR0_RX_READY) {
ch1 = SCCRDWR(unit);
c = 2;
SER_DOCNTL(unit, 0, ZSWR0_RESET_STATUS);
SER_DOCNTL(unit, 0, ZSWR0_CLR_INTR);
break;
case 2: /* recv char available */
ch = SCCRDWR(unit);
c = 1;
if (SER_STATUS(unit, 0) & ZSRR0_RX_READY) {
ch1 = SCCRDWR(unit);
c = 2;
}
if (sc->inlen < INBUFLEN)
sc->inbuf[(sc->intail + (sc->inlen++)) % INBUFLEN] = ch;
else
sc->status.oflo++;
if (c > 1) {
if (sc->inlen < INBUFLEN)
sc->inbuf[(sc->intail + (sc->inlen++)) % INBUFLEN] = ch1;
else
sc->status.oflo++;
}
setsoftserial();
SER_DOCNTL(unit, 0, ZSWR0_CLR_INTR);
break;
case 3: /* spec recv condition */
reg1 = SER_STATUS(unit, 1);
SCCRDWR(unit); /* flush fifo */
if (reg1 & ZSRR1_DO)
sc->status.over++;
SER_DOCNTL(unit, 0, ZSWR0_RESET_ERRORS);
SER_DOCNTL(unit, 0, ZSWR0_CLR_INTR);
break;
}
if (sc->inlen < INBUFLEN)
sc->inbuf[(sc->intail + (sc->inlen++)) % INBUFLEN] = ch;
else sc->status.oflo++;
if (c > 1) {
if (sc->inlen < INBUFLEN)
sc->inbuf[(sc->intail+(sc->inlen++)) % INBUFLEN] = ch1;
else sc->status.oflo++;
}
setsoftserial();
SER_DOCNTL(unit, 0, ZSWR0_CLR_INTR);
break;
case 3: /* spec recv condition */
reg1 = SER_STATUS(unit, 1);
SCCRDWR(unit); /* flush fifo */
if (reg1 & ZSRR1_DO)
sc->status.over++;
SER_DOCNTL(unit, 0, ZSWR0_RESET_ERRORS);
SER_DOCNTL(unit, 0, ZSWR0_CLR_INTR);
break;
}
return(1);
/* end of serial interrupt code */
return (1);
/* end of serial interrupt code */
}
/* serial software interrupt. do all the things we could
not do at splscc();
*/
@ -493,7 +488,7 @@ sersir(void)
{
register struct ser_softc *sc;
register struct tty *tp;
int unit, s, c;
int unit, s, c;
for (unit = 0; unit < 2; unit++) {
sc = sercd.cd_devs[unit];
@ -507,7 +502,7 @@ sersir(void)
sc->status.over = 0;
splx(s);
if (tp->t_state & TS_ISOPEN)
(*linesw[tp->t_line].l_rint)('#', tp);
(*linesw[tp->t_line].l_rint) ('#', tp);
}
/* check for change in DCD */
if (sc->status.ddcd) {
@ -520,8 +515,8 @@ sersir(void)
else
tp->t_state &= ~TS_CARR_ON;
(*linesw[tp->t_line].l_modem)(tp,
sc->status.dcd ? 1 : 0);
(*linesw[tp->t_line].l_modem) (tp,
sc->status.dcd ? 1 : 0);
}
}
/* check for change in CTS */
@ -548,28 +543,28 @@ sersir(void)
sc->inlen--;
splx(s);
if (tp->t_state & TS_ISOPEN)
(*linesw[tp->t_line].l_rint)(c, tp);
(*linesw[tp->t_line].l_rint) (c, tp);
}
/* fill output fifo */
if (sc->outlen == 0) {
if (tp->t_line)
(*linesw[tp->t_line].l_start)(tp);
(*linesw[tp->t_line].l_start) (tp);
else
serstart(tp);
serstart(tp);
}
}
}
extern int
serioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p)
serioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc * p)
{
register struct tty *tp = SER_TTY(UNIT(dev));
register int error;
#if defined(DEBUG)
printf("ser: entering ioctl()\n");
#endif
error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag, p);
error = (*linesw[tp->t_line].l_ioctl) (tp, cmd, data, flag, p);
if (error >= 0)
return (error);
error = ttioctl(tp, cmd, data, flag, p);
@ -578,54 +573,54 @@ serioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p)
switch (cmd) {
#if 0
case TIOCSBRK: /* turn break on */
case TIOCSBRK: /* turn break on */
dca->dca_cfcr |= CFCR_SBREAK;
break;
case TIOCCBRK: /* turn break off */
case TIOCCBRK: /* turn break off */
dca->dca_cfcr &= ~CFCR_SBREAK;
break;
#endif
case TIOCSDTR: /* set DTR */
case TIOCSDTR: /* set DTR */
(void) serctl(dev, ZSWR5_DTR | ZSWR5_RTS, DMBIS);
break;
case TIOCCDTR: /* clear DTR */
case TIOCCDTR: /* clear DTR */
(void) serctl(dev, ZSWR5_DTR | ZSWR5_RTS, DMBIC);
break;
case TIOCMSET: /* set modem control bits */
(void) serctl(dev, *(int *)data, DMSET);
case TIOCMSET: /* set modem control bits */
(void) serctl(dev, *(int *) data, DMSET);
break;
case TIOCMBIS: /* OR bits on */
(void) serctl(dev, *(int *)data, DMBIS);
case TIOCMBIS: /* OR bits on */
(void) serctl(dev, *(int *) data, DMBIS);
break;
case TIOCMBIC: /* AND bits off */
(void) serctl(dev, *(int *)data, DMBIC);
case TIOCMBIC: /* AND bits off */
(void) serctl(dev, *(int *) data, DMBIC);
break;
case TIOCMGET: /* get modem bits */
*(int *)data = serctl(dev, 0, DMGET);
case TIOCMGET: /* get modem bits */
*(int *) data = serctl(dev, 0, DMGET);
break;
case TIOCGFLAGS:
{
int bits = 0;
int bits = 0;
*(int *)data = bits;
*(int *) data = bits;
break;
}
case TIOCSFLAGS:
{
int userbits, driverbits = 0;
int userbits, driverbits = 0;
error = suser(p->p_ucred, &p->p_acflag);
if (error != 0)
return (EPERM);
userbits = *(int *)data;
userbits = *(int *) data;
break;
}
@ -643,7 +638,7 @@ serioctl(dev_t dev, int cmd, caddr_t data, int flag, struct proc *p)
static int
ser_calc_regs(int unit, int cflag, unsigned char *preg3, unsigned char *preg4,
unsigned char *preg5)
unsigned char *preg5)
{
unsigned char r3, r4, r5;
struct ser_softc *sc = sercd.cd_devs[unit];
@ -654,20 +649,20 @@ ser_calc_regs(int unit, int cflag, unsigned char *preg3, unsigned char *preg4,
r5 |= ZSWR5_DTR;
if (sc->status.rts)
r5 |= ZSWR5_RTS;
switch (cflag&CSIZE) {
case CS5:
switch (cflag & CSIZE) {
case CS5:
r3 |= ZSWR3_RX_5;
r5 |= ZSWR5_TX_5;
break;
case CS6:
case CS6:
r3 |= ZSWR3_RX_6;
r5 |= ZSWR5_TX_6;
break;
case CS7:
case CS7:
r3 |= ZSWR3_RX_7;
r5 |= ZSWR5_TX_7;
break;
case CS8:
case CS8:
r3 |= ZSWR3_RX_8;
r5 |= ZSWR5_TX_8;
break;
@ -681,41 +676,40 @@ ser_calc_regs(int unit, int cflag, unsigned char *preg3, unsigned char *preg4,
r4 |= ZSWR4_TWOSB;
else
r4 |= ZSWR4_ONESB;
*preg3 = r3;
*preg4 = r4;
*preg5 = r5;
}
static int
serparam(register struct tty *tp, register struct termios *t)
serparam(register struct tty * tp, register struct termios * t)
{
register int cflag = t->c_cflag;
unsigned char reg3, reg4, reg5;
int unit = UNIT(tp->t_dev);
int ospeed = t->c_ospeed;
int s;
int unit = UNIT(tp->t_dev);
int ospeed = t->c_ospeed;
int s;
#if defined(DEBUG)
printf("ser: entering serparam()\n");
#endif
/* check requested parameters */
if (ospeed < 0 || (t->c_ispeed && t->c_ispeed != t->c_ospeed)){
if (ospeed < 0 || (t->c_ispeed && t->c_ispeed != t->c_ospeed)) {
printf("ser: serparam() returning EINVAL\n");
return (EINVAL);
return (EINVAL);
}
/* and copy to tty */
tp->t_ispeed = t->c_ispeed;
tp->t_ospeed = t->c_ospeed;
tp->t_cflag = cflag;
/* and copy to tty */
tp->t_ispeed = t->c_ispeed;
tp->t_ospeed = t->c_ospeed;
tp->t_cflag = cflag;
/* Start of serial specific param code */
if(ospeed == 0) {
if (ospeed == 0) {
serctl(unit, 0, DMSET); /* hang up line */
return(0);
return (0);
}
serctl(unit, ospeed, SCC_SPEED);
/*
ser_calc_regs(unit, cflag, &reg3, &reg4, &reg5);
@ -738,23 +732,23 @@ serparam(register struct tty *tp, register struct termios *t)
}
extern void
serstart(register struct tty *tp)
serstart(register struct tty * tp)
{
int s, s1;
int i, space, unit, c, need_start, first_char;
int s, s1;
int i, space, unit, c, need_start, first_char;
struct ser_softc *sc;
unit = UNIT(tp->t_dev);
sc = sercd.cd_devs[unit];
s = spltty();
if (tp->t_state & (TS_TIMEOUT|TS_TTSTOP)) {
if (tp->t_state & (TS_TIMEOUT | TS_TTSTOP)) {
goto out;
}
if (tp->t_outq.c_cc <= tp->t_lowat) {
if (tp->t_state&TS_ASLEEP) {
if (tp->t_state & TS_ASLEEP) {
tp->t_state &= ~TS_ASLEEP;
wakeup((caddr_t)&tp->t_outq);
wakeup((caddr_t) & tp->t_outq);
}
selwakeup(&(tp->t_wsel));
}
@ -763,8 +757,8 @@ serstart(register struct tty *tp)
goto out;
tp->t_state |= TS_BUSY;
if(sc->outlen == 0){
first_char = (char)getc(&tp->t_outq);
if (sc->outlen == 0) {
first_char = (char) getc(&tp->t_outq);
need_start = 1;
} else
need_start = 0;
@ -777,13 +771,13 @@ serstart(register struct tty *tp)
space = OUTBUFLEN - sc->outlen;
splx(s1);
while(tp->t_outq.c_cc && space > 0) {
while (tp->t_outq.c_cc && space > 0) {
/* note that getc goes spltty() */
c = getc(&tp->t_outq);
/* protect s/w fifo at splhigh() */
s1 = splhigh();
sc->outbuf[(sc->outtail + (sc->outlen++))
% OUTBUFLEN] = (char)c;
% OUTBUFLEN] = (char) c;
splx(s1);
space--;
}
@ -795,17 +789,15 @@ serstart(register struct tty *tp)
SCCRDWR(unit) = first_char; /* to start chain */
splx(s1);
}
out:
splx(s);
}
/*
* Stop output on a line.
*/
/*ARGSUSED*/
extern int
serstop(register struct tty *tp, int flag)
serstop(register struct tty * tp, int flag)
{
register int s;
@ -814,7 +806,7 @@ serstop(register struct tty *tp, int flag)
#endif
s = spltty();
if (tp->t_state & TS_BUSY) {
if ((tp->t_state&TS_TTSTOP)==0)
if ((tp->t_state & TS_TTSTOP) == 0)
tp->t_state |= TS_FLUSH;
}
#if defined(DEBUG)
@ -825,7 +817,7 @@ serstop(register struct tty *tp, int flag)
struct tty *
sertty(dev)
dev_t dev;
dev_t dev;
{
return (SER_TTY(UNIT(dev)));
}
@ -834,7 +826,7 @@ static int
serctl(dev_t dev, int bits, int how)
{
struct ser_softc *sc;
int unit, s;
int unit, s;
unit = UNIT(dev);
sc = sercd.cd_devs[unit];
@ -858,7 +850,7 @@ serctl(dev_t dev, int bits, int how)
bits = SER_STATUS(unit, 0);
break;
/* */
/* */
case SCC_INT:
if (bits) {
SER_DOCNTL(unit, 0, ZSWR0_RESET_ERRORS);
@ -874,72 +866,67 @@ serctl(dev_t dev, int bits, int how)
}
(void) splx(s);
return(bits);
return (bits);
}
/*
* Console functions.
*/
dev_t mac68k_serdev;
dev_t mac68k_serdev;
sercnprobe(struct consdev *cp)
sercnprobe(struct consdev * cp)
{
int maj, unit;
int maj, unit;
for (maj = 0 ; maj < nchrdev ; maj++) {
if (cdevsw[maj].d_open == seropen) {
break;
}
}
if (maj == nchrdev)
goto nosercon;
for (maj = 0; maj < nchrdev; maj++) {
if (cdevsw[maj].d_open == seropen) {
break;
}
}
if (maj == nchrdev)
goto nosercon;
cp->cn_pri = CN_NORMAL; /* Lower than CN_INTERNAL */
if (mac68k_machine.serial_console & 0x01)
cp->cn_pri = CN_REMOTE; /* Higher than CN_INTERNAL */
cp->cn_pri = CN_NORMAL; /* Lower than CN_INTERNAL */
if (mac68k_machine.serial_console & 0x01)
cp->cn_pri = CN_REMOTE; /* Higher than CN_INTERNAL */
unit = (mac68k_machine.serial_console & 0x02) ? 1 : 0;
unit = (mac68k_machine.serial_console & 0x02) ? 1 : 0;
cp->cn_dev = makedev(maj, unit);
cp->cn_dev = makedev(maj, unit);
mac68k_machine.serial_boot_echo = 0;
return 0;
mac68k_machine.serial_boot_echo = 0;
return 0;
nosercon:
if (mac68k_machine.serial_boot_echo) {
/* major number doesn't really matter. */
mac68k_serdev = makedev(maj, 0);
serinit(1);
}
return 0;
if (mac68k_machine.serial_boot_echo) {
/* major number doesn't really matter. */
mac68k_serdev = makedev(maj, 0);
serinit(1);
}
return 0;
}
sercninit(struct consdev *cp)
sercninit(struct consdev * cp)
{
serinit(1);
serinit(1);
}
sercngetc(dev_t dev)
{
int unit, c;
int unit, c;
unit = UNIT(dev);
unit = UNIT(dev);
while (!(SER_STATUS(unit, 0) & ZSRR0_RX_READY));
c = SCCRDWR(unit);
SER_STATUS(unit, 0) = ZSWR0_RESET_STATUS;
while (!(SER_STATUS(unit, 0) & ZSRR0_RX_READY));
c = SCCRDWR(unit);
SER_STATUS(unit, 0) = ZSWR0_RESET_STATUS;
return c;
return c;
}
sercnputc(dev_t dev, int c)
{
int unit;
int unit;
unit = UNIT(dev);
unit = UNIT(dev);
while (!(SER_STATUS(unit, 0) & ZSRR0_TX_READY));
SCCRDWR(unit) = c;
while (!(SER_STATUS(unit, 0) & ZSRR0_TX_READY));
SCCRDWR(unit) = c;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: serreg.h,v 1.8 1995/04/11 03:00:58 mycroft Exp $ */
/* $NetBSD: serreg.h,v 1.9 1995/04/21 02:48:09 briggs Exp $ */
/*
* Copyright (C) 1993 Allen K. Briggs, Chris P. Caputo,
@ -40,7 +40,7 @@
*/
/* Gleaned from MacOS */
extern volatile unsigned char *sccA;
extern volatile unsigned char *sccA;
#define SERBRD(x) (mac68k_machine.sccClkConst / (x) - 2)
#define SCCCNTL(unit) (sccA[2 - ((unit) << 1)])

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
/* $NetBSD: nubus.h,v 1.3 1994/10/26 08:46:15 cgd Exp $ */
/* $NetBSD: nubus.h,v 1.4 1995/04/21 02:48:01 briggs Exp $ */
/*-
* Copyright (C) 1993 Allen K. Briggs, Chris P. Caputo,
@ -38,36 +38,34 @@
#define NUBUS_MOTHERBOARD 0x0a
#define NUBUS_MAXSLOTS 16
struct imagedata{
long whatTheHellIsThis;
long offset;
short rowbytes;
short top;
short left;
short right;
short bottom;
short version;
short packType;
short packSize;
long hRes;
long vRes;
short pixelType;
short pixelSize;
struct imagedata {
long whatTheHellIsThis;
long offset;
short rowbytes;
short top;
short left;
short right;
short bottom;
short version;
short packType;
short packSize;
long hRes;
long vRes;
short pixelType;
short pixelSize;
};
/* this is the main data structure that points to good stuff */
struct header {
long offset;
long length;
long crc;
char romrev;
char format;
long tst;
char reserved;
char bytelane;
} ;
long offset;
long length;
long crc;
char romrev;
char format;
long tst;
char reserved;
char bytelane;
};
/* this is what the directory entries contain */
struct dir {
@ -78,20 +76,20 @@ struct dir {
/* describe a single slot */
struct slot {
int size;
int size;
struct header head;
struct dir mainDir[15];
long type;
char name[40];
char manufacturer[40];
long type;
char name[40];
char manufacturer[40];
};
struct nubus_hw{
int found; /* If there is a card there */
caddr_t addr; /* Phys addr of start of card */
caddr_t rom; /* Phys addr of start of ROM */
int claimed; /* TRUE if a driver claims this */
struct slot Slot; /* MF NUBUS STUFF */
/* any other Nubus stuff we can think of when we get */
/* the NuBus documentation */
struct nubus_hw {
int found; /* If there is a card there */
caddr_t addr; /* Phys addr of start of card */
caddr_t rom; /* Phys addr of start of ROM */
int claimed; /* TRUE if a driver claims this */
struct slot slot; /* MF NUBUS STUFF */
/* any other Nubus stuff we can think of when we get */
/* the NuBus documentation */
};

View File

@ -1,4 +1,4 @@
/* $NetBSD: asc.c,v 1.6 1994/10/26 08:46:02 cgd Exp $ */
/* $NetBSD: asc.c,v 1.7 1995/04/21 02:47:45 briggs Exp $ */
/*-
* Copyright (C) 1993 Allen K. Briggs, Chris P. Caputo,
@ -47,7 +47,7 @@
/* Global ASC location */
volatile unsigned char *ASCBase = (unsigned char *)0x14000;
volatile unsigned char *ASCBase = (unsigned char *) 0x14000;
/* bell support data */
@ -56,19 +56,19 @@ static int bell_length = 10;
static int bell_volume = 100;
static int bell_ringing = 0;
static int ascprobe(struct device *, struct cfdata *, void *);
static void ascattach(struct device *, struct device *, void *);
extern int matchbyname(struct device *, struct cfdata *, void *);
static int ascprobe(struct device *, struct cfdata *, void *);
static void ascattach(struct device *, struct device *, void *);
extern int matchbyname(struct device *, struct cfdata *, void *);
struct cfdriver asccd =
{ NULL, "asc", matchbyname, ascattach,
DV_DULL, sizeof(struct device), NULL, 0 };
{NULL, "asc", matchbyname, ascattach,
DV_DULL, sizeof(struct device), NULL, 0};
static int
ascprobe(parent, cf, aux)
struct device *parent;
struct cfdata *cf;
void *aux;
struct device *parent;
struct cfdata *cf;
void *aux;
{
if (strcmp(*((char **) aux), asccd.cd_name))
return 0;
@ -79,106 +79,110 @@ ascprobe(parent, cf, aux)
static void
ascattach(parent, dev, aux)
struct device *parent, *dev;
void *aux;
struct device *parent, *dev;
void *aux;
{
printf(" Apple sound chip.\n");
ASCBase = IOBase + ASCBase;
}
int asc_setbellparams(
int freq,
int length,
int volume)
int
asc_setbellparams(
int freq,
int length,
int volume)
{
/* I only perform these checks for sanity. */
/* I suppose someone might want a bell that rings */
/* all day, but then the can make kernel mods themselves. */
if(freq < 10 || freq > 40000)
return(EINVAL);
if(length < 0 || length > 3600)
return(EINVAL);
if(volume < 0 || volume > 100)
return(EINVAL);
if (freq < 10 || freq > 40000)
return (EINVAL);
if (length < 0 || length > 3600)
return (EINVAL);
if (volume < 0 || volume > 100)
return (EINVAL);
bell_freq = freq;
bell_length = length;
bell_volume = volume;
return(0);
return (0);
}
int asc_getbellparams(
int *freq,
int *length,
int *volume)
int
asc_getbellparams(
int *freq,
int *length,
int *volume)
{
*freq = bell_freq;
*length = bell_length;
*volume = bell_volume;
return(0);
return (0);
}
void asc_bellstop(
int param)
void
asc_bellstop(
int param)
{
if(bell_ringing > 1000 || bell_ringing < 0)
if (bell_ringing > 1000 || bell_ringing < 0)
panic("bell got out of synch?????");
if(--bell_ringing == 0){
if (--bell_ringing == 0) {
ASCBase[0x801] = 0;
}
/* disable ASC */
}
int asc_ringbell()
int
asc_ringbell()
{
int i;
int i;
unsigned long freq;
if(bell_ringing == 0){
for(i = 0; i < 0x800; i++)
if (bell_ringing == 0) {
for (i = 0; i < 0x800; i++)
ASCBase[i] = 0;
for(i = 0; i < 256;i++){
for (i = 0; i < 256; i++) {
ASCBase[i] = i / 4;
ASCBase[i + 512] = i / 4;
ASCBase[i + 1024] = i / 4;
ASCBase[i + 1536] = i / 4;
}/* up part of wave, four voices ? */
for(i = 0; i < 256;i++){
} /* up part of wave, four voices ? */
for (i = 0; i < 256; i++) {
ASCBase[i + 256] = 0x3f - (i / 4);
ASCBase[i + 768] = 0x3f - (i / 4);
ASCBase[i + 1280] = 0x3f - (i / 4);
ASCBase[i + 1792] = 0x3f - (i / 4);
}/* down part of wave, four voices ? */
} /* down part of wave, four voices ? */
/* Fix this. Need to find exact ASC sampling freq */
/* Fix this. Need to find exact ASC sampling freq */
freq = 65536 * bell_freq / 466;
/* printf("beep: from %d, %02x %02x %02x %02x\n", cur_beep.freq,
(freq >> 24) & 0xff, (freq >> 16) & 0xff,
(freq >> 8) & 0xff, (freq) & 0xff);*/
for(i = 0; i < 8; i++){
/* printf("beep: from %d, %02x %02x %02x %02x\n",
* cur_beep.freq, (freq >> 24) & 0xff, (freq >> 16) & 0xff,
* (freq >> 8) & 0xff, (freq) & 0xff); */
for (i = 0; i < 8; i++) {
ASCBase[0x814 + 8 * i] = (freq >> 24) & 0xff;
ASCBase[0x815 + 8 * i] = (freq >> 16) & 0xff;
ASCBase[0x816 + 8 * i] = (freq >> 8) & 0xff;
ASCBase[0x817 + 8 * i] = (freq) & 0xff;
}/* frequency; should put cur_beep.freq in here somewhere. */
ASCBase[0x807] = 3; /* 44 ? */
ASCBase[0x806] = 255 * bell_volume / 100;
ASCBase[0x805] = 0;
ASCBase[0x80f] = 0;
ASCBase[0x802] = 2; /* sampled */
ASCBase[0x801] = 2; /* enable sampled */
}
} /* frequency; should put cur_beep.freq in here
* somewhere. */
ASCBase[0x807] = 3; /* 44 ? */
ASCBase[0x806] = 255 * bell_volume / 100;
ASCBase[0x805] = 0;
ASCBase[0x80f] = 0;
ASCBase[0x802] = 2; /* sampled */
ASCBase[0x801] = 2; /* enable sampled */
}
bell_ringing++;
timeout((void *) asc_bellstop, 0, bell_length);
}