home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.ee.lbl.gov
/
2014.05.ftp.ee.lbl.gov.tar
/
ftp.ee.lbl.gov
/
bmd-1.0beta.tar.Z
/
bmd-1.0beta.tar
/
bmd-1.0beta
/
sundev
/
bmdvar.h
< prev
next >
Wrap
C/C++ Source or Header
|
1991-08-27
|
4KB
|
125 lines
/*
* Copyright (c) 1991 Regents of the University of California.
* All rights reserved.
*
* Redistribution and use in source and binary forms are permitted
* provided that the above copyright notice and this paragraph are
* duplicated in all such forms and that any documentation,
* advertising materials, and other materials related to such
* distribution and use acknowledge that the software was developed
* by the University of California, Lawrence Berkeley Laboratory,
* Berkeley, CA. The name of the University may not be used to
* endorse or promote products derived from this software without
* specific prior written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
/*
* A midi-data-queue (mdq) holds a single midi message which will be
* output atomically. On the write side, we link together messages
* with identical timestamps using the mq_tail field (this is so we
* can transfer potentially large chains of messages from the midi
* driver to the serial driver in a single operation, necessary to
* shorten this high ipl lock-out). The invariant for this field is
* that the head of a group points to the tail; all others are undefined.
* In essence, we have a queue of queues.
*/
struct mdq {
struct mdq *mq_next;
struct mdq *mq_tail;
short mq_qlen;
short mq_len;
u_char *mq_cp;
u_long mq_time;
u_char mq_data[BMD_MAXMSGLEN];
};
/*
* Below is the per interface structure. Sparcs have two usable serial
* ports (A and B), reflected in NPORTS.
*
* Since data to be output is timestamped, consecutive writes can cause
* interspersed midi messages and alter their meaning (i.e., midi streams
* have a running state). Outbound midi messages must be atomic. Hence,
* entire midi messages are stored in a single struct.
*
* There are three levels of interrupts. The midi clock comes in at level 14,
* which locks at just about everything (including hardclock). The zs chip
* interrupts at level 12, which is also very high (above hardclock).
* Software level 4 is used to synchronize wakeups with the process
* queues.
*
*/
struct midi_softc {
u_char sc_unit; /* port number (i.e., A or B) */
u_char sc_refcnt; /* number of opens on this device */
u_long sc_clkrate; /* microseconds per midi clock tick */
void * sc_msl;
struct midid *sc_readers; /* list of readers */
struct midid *sc_writers; /* list of writers */
struct mdq sc_sp; /* place to construct inbound message */
struct mdq sc_sf; /* place to construct inbound message */
struct mdq *sc_p;
struct mdq *sc_f;
int sc_stat;
};
struct sleepchan {
int want;
int have;
};
/*
* The midi file descriptor. Each open file has one of these. Note
* that there can be multiple files with the same interface opened.
* A descriptor is free if the points to itself (via md_nxtr).
*/
struct midid {
struct midid *md_nxtr; /* next reader */
struct midid *md_nxtw; /* next writer */
struct midid *md_nxti; /* next in interrupt list */
struct midi_softc *md_sc; /* midi port attached */
u_long md_tz; /* time zero */
int md_flag;
u_char md_pause;
u_char md_nbio;
u_char md_echo;
u_int md_echan;
u_long md_filter;
#define MS_IDLE ((u_int)-1)
#define MS_WAITING 0
#define MS_DATAREADY 1
#define MS_TIMEDOUT 2
#define MS_PAUSED 3
u_int md_nbuf; /* number of input messages to buffer */
u_int md_wlo; /* output low water mark */
int md_idrops; /* number of input messages dropped */
/*
* Input/output buffering.
*/
u_int md_rcnt; /* number of inbound messages queued */
struct mdq *md_rh; /* inbound message queue */
struct mdq *md_rt; /* inbound message queue */
u_int md_wcnt; /* number of outbound messages queued */
struct mdq *md_wh; /* outbound message queue */
struct mdq *md_wt; /* outbound message queue */
struct proc *md_sigioproc;
struct sleepchan md_rchan;
struct sleepchan md_wchan;
struct sleepchan md_rsel;
struct sleepchan md_wsel;
struct sleepchan md_sigio;
int md_rcol;
int md_wcol;
};
/*
* XXX There is no spl for the level 14 clock so we use spl8.
*/
#define splmidi spl8