MusicKit  0.0.0
_DSPObject.h
00001 #ifndef __MK__DSPObject_H___
00002 #define __MK__DSPObject_H___
00003 /* $Id$
00004  * Private functions in DSPObject.c
00005  * Copyright 1988-1992, NeXT Inc.  All rights reserved. 
00006  */
00007 
00008 
00009 extern int _DSPSetNumber(int i);
00010 /* 
00011  * Set assigned DSP number for this instance.  Called by the new method.
00012  */
00013 
00014 
00015 extern int _DSPAwaitMsgSendAck(msg_header_t *msg);
00016 /*
00017  * Read ack message sent to msg->local_port by Mach kernel in response to a 
00018  * msg_snd. Returns 0 if all is well.
00019  */
00020 
00021 
00022 extern int _DSPAwaitRegs(
00023     int mask,           /* mask to block on as bits in (ICR,CVR,ISR,IVR) */
00024     int value,          /* 1 or 0 as desired for each 1 mask bit */
00025     int msTimeLimit);   /* time limit in milliseconds */
00026 /*
00027  * Block until the specified mask is true in the DSP host interface.
00028  * Example conditions are (cf. <nextdev/snd_dspreg.h>):
00029  *  mask=DSP_CVR_REGS_MASK, value=0
00030  *      Wait for HC bit of DSP host interface to clear
00031  *  mask=value=DSP_ISR_HF2_REGS_MASK,
00032  *      Wait for HF2 bit of DSP host interface to set
00033  */
00034 
00035 
00036 extern int _DSPAwaitBit(
00037     int bit,            /* bit to block on as bit in (ICR,CVR,ISR,IVR) */
00038     int value,          /* 1 or 0 */
00039     int msTimeLimit);   /* time limit in milliseconds */
00040 /*
00041  * Block until the specified bit is true in the DSP host interface.
00042  * Example conditions are (cf. <nextdev/snd_dspreg.h>):
00043  *
00044  *      bit             value
00045  *      ---             -----
00046  * DSP_CVR_REGS_MASK      0     Wait for HC bit of DSP host interface to clear
00047  * DSP_ISR_HF2_REGS_MASK  1     Wait for HF2 bit of DSP host interface to set
00048  *
00049  */
00050 extern int _DSPAwaitMsgSendAck(
00051     msg_header_t *msg);
00052 /*
00053  * Read ack message sent to msg->local_port by Mach kernel in response to a 
00054  * msg_snd. Returns 0 if all is well.
00055  */
00056 
00057 
00058 extern int _DSPAwaitRegs(
00059     int mask,           /* mask to block on as bits in (ICR,CVR,ISR,IVR) */
00060     int value,          /* 1 or 0 as desired for each 1 mask bit */
00061     int msTimeLimit);   /* time limit in milliseconds */
00062 /*
00063  * Block until the specified mask is true in the DSP host interface.
00064  * Example conditions are (cf. <nextdev/snd_dspreg.h>):
00065  *  mask=DSP_CVR_REGS_MASK, value=0
00066  *      Wait for HC bit of DSP host interface to clear
00067  *  mask=value=DSP_ISR_HF2_REGS_MASK,
00068  *      Wait for HF2 bit of DSP host interface to set
00069  */
00070 
00071 
00072 extern int _DSPAwaitBit(
00073     int bit,            /* bit to block on as bit in (ICR,CVR,ISR,IVR) */
00074     int value,          /* 1 or 0 */
00075     int msTimeLimit);   /* time limit in milliseconds */
00076 /*
00077  * Block until the specified bit is true in the DSP host interface.
00078  * Example conditions are (cf. <nextdev/snd_dspreg.h>):
00079  *
00080  *      bit             value
00081  *      ---             -----
00082  * DSP_CVR_REGS_MASK      0     Wait for HC bit of DSP host interface to clear
00083  * DSP_ISR_HF2_REGS_MASK  1     Wait for HF2 bit of DSP host interface to set
00084  *
00085  */
00086 
00087 
00088 extern int _DSPReadDatumMode(DSPDatum *datumP, int mode);
00089 
00090 extern int _DSPReadDatum(DSPDatum *datumP);
00091 /*
00092  * Read a single DSP message.
00093  * Returns nonzero if there is no more data.
00094  * *** NOTE *** This routine is private because it does not support
00095  * mapped mode.  A routine DSPReadDatum() routine can be made which 
00096  * simply calls DSPReadRX().
00097  */
00098 
00099 
00100 extern int _DSPReadData(DSPDatum *dataP, int *nP);
00101 /*
00102  * Read back up to *nP DSP messages into array dataP.
00103  * On input,nP is the maximum number of DSP data words to be read.
00104  * On output,nP contains the number of DSP data words actually read.
00105  * Returns nonzero if *nP changes.
00106  * *** NOTE *** This routine is private because it does not support
00107  * mapped mode.  A routine DSPReadData() routine can be made which 
00108  * simply calls DSPReadRXArray().
00109  */
00110 
00111 
00112 extern int _DSPReadRegs(void);
00113 /* 
00114  * Return first four DSP host interface register bytes (ICR,CVR,ISR,IVR)
00115  * in *regsP.  Returns 0 on success.  Calls to this routine do not affect
00116  * the simulator output file because they do not affect the state of the DSP.
00117  */
00118 
00119 
00120 extern int _DSPPrintRegs(void);
00121 /* 
00122  * Print first four DSP host interface register bytes (ICR,CVR,ISR,IVR).
00123  */
00124 
00125 
00126 extern int _DSPPutBit(
00127     int bit,                    /* bit mask in (ICR,CVR,ISR,IVR) longword */
00128     int value);                 /* 1 or 0 */
00129 /*
00130  * Set DSP host-interface bit to given value.
00131  * Returns 0 for success, nonzero on error.
00132  * Example:
00133  *      _DSPPutBit(DSP_ICR_HF0_REGS_MASK,1),
00134  * sets host flag 0 to 1 and 
00135  *      _DSPPutBit(DSP_ICR_HF0_REGS_MASK,0));
00136  * clears it.
00137  *
00138  * *** NOTE: This routine is private because it does not support mapped mode.
00139  */
00140 
00141 
00142 extern int _DSPSetBit(int bit); /* bit mask in (ICR,CVR,ISR,IVR) longword */
00143 /*
00144  * Set DSP host-interface bit.
00145  * Returns 0 for success, nonzero on error.
00146  * Example: "_DSPSetBit(DSP_ICR_HF0_REGS_MASK)" sets host flag 0.
00147  * *** NOTE: This routine is private because it does not support mapped mode.
00148  */
00149 
00150 
00151 extern int _DSPClearBit(int bit);       /* bit mask in (ICR,CVR,ISR,IVR) longword */
00152 /*
00153  * Clear DSP host-interface bit.
00154  * Returns 0 for success, nonzero on error.
00155  * Example: "_DSPSetBit(DSP_ICR_HF0_REGS_MASK)" sets host flag 0.
00156  * *** NOTE: This routine is private because it does not support mapped mode.
00157  */
00158 
00159 
00160 extern int _DSPStartHmArray(void);
00161 /*
00162  * Start host message by zeroing the host message buffer pointer hm_ptr.
00163  */
00164 
00165 
00166 extern int _DSPExtendHmArray(DSPDatum *argArray, int nArgs);
00167 /*
00168  * Add arguments to a host message (for the DSP).
00169  * Add nArgs elements from argArray to hm_array.
00170  */
00171 
00172 
00173 extern int _DSPExtendHmArrayMode(void *argArray, int nArgs, int mode);
00174 /*
00175  * Add arguments to a host message (for the DSP).
00176  * Add nArgs elements from argArray to hm_array according to mode.
00177  * Mode codes are in <nextdev/dspvar.h> and discussed in 
00178  * DSPObject.h(DSPWriteArraySkipMode).
00179  */
00180 
00181 
00182 extern int _DSPExtendHmArrayB(DSPDatum *argArray, int nArgs);
00183 /*
00184  * Add nArgs elements from argArray to hm_array in reverse order.
00185  */
00186 
00187 
00188 extern int _DSPFinishHmArray(DSPFix48 *aTimeStampP, DSPAddress opcode);
00189 /*
00190  * Finish off host message by installing time stamp (if timed) and opcode.
00191  * Assumes host-message arguments have already been installed in hm_array via 
00192  * _DSPExtendHmArray().
00193  */
00194 
00195 
00196 extern int _DSPWriteHm(void);
00197 /*
00198  * Send host message struct to the DSP.
00199  */
00200 
00201 
00202 extern int _DSPWriteHostMessage(int *hm_array, int nwords);
00203 /*
00204  * Write host message array.
00205  * See DSPMessage.c for how this array is set up. (Called by _DSPWriteHm().)
00206  */
00207 
00208 
00209 extern int _DSPResetTMQ(void);
00210 /*
00211  * Reset TMQ buffers to empty state and reset "current time" to 0.
00212  * Any waiting timed messages in the buffer are lost.
00213  */
00214 
00215 
00216 extern int _DSPFlushTMQ(void) ;
00217 /*
00218  * Flush current buffer of accumulated timed host messages (all for the
00219  * same time).
00220  */
00221 
00222 
00223 extern int _DSPOpenMapped(void);
00224 /*
00225  * Open DSP in memory-mapped mode. 
00226  * No reset or boot is done.
00227  * DSPGetRegs() can be used to obtain a pointer to the DSP host interface.
00228  */
00229 
00230 
00231 extern int _DSPEnableMappedOnly(void);
00232 extern int _DSPDisableMappedOnly(void);
00233 extern int _DSPMappedOnlyIsEnabled(void);
00234 
00235 
00236 extern int _DSPCheckMappedMode(void) ;
00237 /*
00238  * See if mapped mode would be a safe thing to do.
00239  */
00240 
00241 
00242 extern int _DSPEnterMappedModeNoCheck(void) /* Don't call this directly! */;
00243 
00244 
00245 extern int _DSPEnterMappedModeNoPing(void) ;
00246 /*
00247  * Turn off DSP interrupts.
00248  */
00249 
00250 
00251 extern int _DSPEnterMappedMode(void);
00252 /*
00253  * Flush driver's DSP command queue and turn off DSP interrupts.
00254  */
00255 
00256 
00257 extern int _DSPExitMappedMode(void);
00258 /*
00259  * Flush driver's DSP command queue and turn off DSP interrupts.
00260  */
00261 
00262 
00263 DSPRegs *_DSPGetRegs(void);
00264 
00265 extern int _DSPMappedOnlyIsEnabled(void);
00266 extern int _DSPEnableMappedArrayReads(void);
00267 extern int _DSPDisableMappedArrayReads(void);
00268 extern int _DSPEnableMappedArrayWrites(void);
00269 extern int _DSPDisableMappedArrayWrites(void);
00270 extern int _DSPEnableMappedArrayTransfers(void);
00271 extern int _DSPDisableMappedArrayTransfers(void);
00272 
00273 extern int _DSPEnableUncheckedMappedArrayTransfers(void);
00274 
00275 extern int _DSPDisableUncheckedMappedArrayTransfers(void);
00276 
00277 extern int _DSPMKStartWriteDataNoThread(void);
00278 /*
00279  * Same as DSPMKStartWriteData() but using an untimed host message
00280  * to the DSP.
00281  */
00282 
00283 extern int _DSPMKStartWriteDataNoThread(void);
00284 
00285 extern int _DSPForceIdle(void);
00286 
00287 extern int _DSPOwnershipIsJoint();
00288 /*
00289  * Returns TRUE if DSP owner port is held by more than one task.
00290  */
00291 
00292 /* Added 3/30/90/jos from DSPObject.h */
00293 
00294 FILE *DSPMKGetWriteDataFP(void);
00295 /* 
00296  * Get the file-pointer being used for DSP write-data.
00297  */
00298 
00299 int DSPMKSetWriteDataFP(FILE *fp);
00300 /* 
00301  * Set the file-pointer for DSP write-data to fp.
00302  * The file-pointer will clear and override any prior specification
00303  * of write-data filename using DSPMKSetWriteDataFile().
00304  */
00305 
00306 #if !m68k && (defined(NeXT) || (defined(__APPLE__) && defined(__MACH__)))
00307 extern int _DSPAddIntelBasedDSP(char *driverName,int driverUnit,int subUnit, 
00308                                 float version);
00309 /*
00310  * Add Intel card-based DSP56001 with specified driver name and unit.
00311  * On Intel machines, you must call this before any other libdsp functions.
00312  * Note that DSPAddIntelBasedDSPs() is defined in terms of this function.
00313  */
00314 
00315 extern void _DSPAddIntelBasedDSPs(void);
00316 /* Invokes DSPAddIntelBasedDSP() for each "in use" DSP (see below).  
00317  * This function must be called before any other libdsp functions.  
00318  * The Music Kit invokes DSPAddIntelBasedDSPs automatically.
00319  */
00320 
00321 #endif
00322 
00323 extern void _DSPInitDefaults(void);
00324 /* Init defaults data base values */
00325 
00326 extern int _DSPResetSystem(DSPLoadSpec *system);
00327 /* Like DSPSetSystem() but assumes system is the same as the last one used
00328  * for this DSP (an optimization).
00329  */
00330 
00331 #endif