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