00001 /************************************************************************************ 00002 * txtBuffer.h 00003 * 00004 * This header file defines three character buffers used for error reporting, 00005 * informational messages and diagnostic messages. The buffers may 00006 * individually be set to be either linear or circular depending on the value 00007 * of the "mode" data element. They also can either overwrite if the message 00008 * is longer than the buffer, or truncate the message, depending on 00009 * the value of the "overwrite" data element. 00010 * 00011 * The buffers are contiguous in memory, with the start of the buffer block 00012 * defined in a loader command file. 00013 * 00014 * Users add messages via the routines txtNewBufferEntry (for a new entry) and 00015 * txtAddBufferEntry to append information to an existing entry. The 00016 * arguments to both calls are the same: 00017 * void *buffer: a pointer to the start of the buffer structure to hold 00018 * the entry [INPUT and OUTPUT] 00019 * char *file: an ASCII string containing the name of the source file 00020 * of the routine making the call (use __FILE__ as 00021 * defoned in the ANSI C standard). [INPUT] 00022 * INT32 line: An integer giving the line number within the above file 00023 * that the buffer routine was called from (use the C 00024 * macro __LINE__) [INPUT] 00025 * char *txtMessage: A character string containing arbitrary ASCII data. 00026 * Usually this will be created by a sprintf call. It may 00027 * contain text messages, error codes, and printouts 00028 * of variable values. [INPUT] 00029 * 00030 * After the buffer has been read, the user calls txtMarkBufferRead to set the 00031 * pointers appropriately. 00032 * 00033 * Revision history: 00034 * 18-Apr-2000: Changed names from dspXxxx to txtXxxxx. 00035 * 09-May-2000: First CVS release (1.0) 00036 * 15-Oct-2002: Added Buffer ID so that txtNewBufferEntry can set the appropriate 00037 * status register flag, which serves as a signal for the main loop 00038 * to call sendTxtBuffs. dpsf. 00039 * 31-03-2004: Added new text buffer structure jsv. 00040 * 00041 * Written by: Tom Meyer, Iowa State University, meyer@iastate.edu 00042 ************************************************************************************/ 00043 #ifndef TXTBUF /* To avoid including it twice */ 00044 #define TXTBUF 00045 00046 #include "processor.h" 00047 00048 /* number of text buffers and text buffer indicies */ 00049 #define ERR_BUFF 0 00050 #define INFO_BUFF 1 00051 #define DIAG_BUFF 2 00052 #define XFER_BUFF 3 00053 00054 #if (defined(I_AM_MASTER_DSP)||defined(I_AM_HOST)) 00055 #define N_TXT_BUFFS 4 00056 #define N_MDSP_TXT_BUFFS 4 00057 #define N_SDSP_TXT_BUFFS 4 00058 #elif (defined(I_AM_SLAVE_DSP)) 00059 #define N_TXT_BUFFS 4 00060 #define N_SDSP_TXT_BUFFS (N_TXT_BUFFS) 00061 #endif 00062 00063 #define RINGBUFF 0 00064 #define LINBUFF 1 00065 #define NOOVERWRITE 0 00066 #define OVERWRITE 1 00067 #define NOWRAPAROUND 0 /* Wrap-around means the data continues from */ 00068 #define WRAPAROUND 1 /* the end of the buffer back to the start */ 00069 #define TXT_BFR_NOOVERFLOW 0 /* Overflow means more data was written to the */ 00070 #define TXT_BFR_OVERFLOW 1 /* buffer than it can hold. This is independen */ 00071 /* from the wrap-around condition. */ 00072 #define BUFFER_EMPTY 0 00073 #define BUFFER_OCCUPIED 1 00074 00075 /* 00076 Some ASCII characters. Should these be defined elsewhere? 00077 Are they used anywhere else? 00078 */ 00079 #define STX '\002' 00080 #define SPC '\040' 00081 00082 /* This is defined in the DAQ c++ software as RodTxtBuff.h; contains a 00083 text buffer class. Any changes made here must be consistent there. */ 00084 struct TXTBUFFER{ 00085 UINT32 dataEnd; /* Last data byte */ 00086 UINT32 readIndx; /* Next location to read from */ 00087 UINT32 writeIndx; /* Next location to write to */ 00088 INT32 mode; /* LINEAR or RING */ 00089 INT32 overwrite; 00090 INT32 overflow; /* Did buffer overflow? */ 00091 INT32 wrap; /* Did buffer wrap around? */ 00092 INT32 state; /* Is there unread data? */ 00093 UINT32 id; /* Buffer ID */ 00094 char* data; /* Pointer to data array */ 00095 }; 00096 00097 typedef struct { 00098 UINT32 tail, head, base, length; 00099 } TxtBuffer; 00100 00101 #endif /* Multiple inclusion protection */