1/********************************************************************** 2** System: ALOG 3** File: usc.h 4** Author: Arun Nanda 5** : Kees Schuerman 6** SccsId: "@(#)alog.h 1.1 11/4/94" 7** Description: ALOG Interface 8***********************************************************************/ 9 10#ifndef _ALOG_H_ 11#define _ALOG_H_ 12 13#include <stdio.h> 14#include "usc.h" 15 16 17/* 18** Constants 19*/ 20 21#define MAX_DIRNAME_LEN 100 22#define MAX_LOG_STRING_LEN 12 23#define MAX_BUF_SIZE 100 24#define ALOG_LOGFILE "alogfile.p" 25 26#define ALOG_TRUNCATE 0 27#define ALOG_WRAP 1 28 29#define ALOG_OFF 0 30#define ALOG_ON 1 31 32#define ALOG_EVENT_SYNC -101 33#define ALOG_EVENT_PAIR_A1 -102 34#define ALOG_EVENT_PAIR_A2 -103 35#define ALOG_EVENT_PAIR_B1 -104 36 37 38/* 39** Structure Definitions 40*/ 41 42struct head_trace_buf { 43 int next_entry; 44 int max_size; 45 unsigned long prev_time; 46 unsigned long ind_time; 47 int trace_flag; 48 struct trace_buf *xx_list; 49 struct trace_buf *cbuf; 50 FILE *file_t; 51}; 52 53struct trace_buf { 54 struct trace_buf *next_buf; 55 struct trace_table { 56 int id; 57 int task_id; 58 int event; 59 int data_int; 60 char data_string[MAX_LOG_STRING_LEN+1]; 61 unsigned long tind; 62 unsigned long tstamp; 63 } ALOG_table[MAX_BUF_SIZE]; 64}; 65 66 67/* 68** Variables 69*/ 70 71extern int xx_alog_status; 72extern int xx_alog_setup_called; 73extern int xx_alog_output_called; 74extern char xx_alog_outdir[]; 75extern struct head_trace_buf *xx_buf_head; 76 77 78/* 79** Functions 80*/ 81 82#if defined(__STDC__) 83void xx_write(struct head_trace_buf * head, 84 int pid, int event, int data1, char * data2); 85void xx_dump(struct head_trace_buf * head); 86void xx_dump_aux(struct trace_buf * buf, 87 FILE * fp, int xx_j, int xx_k); 88void xx_user(struct head_trace_buf * head, int id); 89void xx_user1(struct head_trace_buf * head, int id); 90void xx_alog_setup(int pid, int flag); 91int xx_getbuf(struct head_trace_buf * head); 92#else /* __STDC__ */ 93void xx_write(); 94void xx_dump(); 95void xx_dump_aux(); 96void xx_user(); 97void xx_user1(); 98void xx_alog_setup(); 99int xx_getbuf(); 100#endif /* __STDC__ */ 101 102 103/* 104** Macro's 105*/ 106 107#ifdef ALOG_TRACE 108 109#define ALOG_DEC 110 111#define ALOG_STATUS(status) \ 112 if ((status) == ALOG_ON) \ 113 xx_alog_status |= 0x1; \ 114 else \ 115 xx_alog_status &= ~0x1 116 117#define ALOG_ENABLE ALOG_STATUS(ALOG_ON) 118 119#define ALOG_DISABLE ALOG_STATUS(ALOG_OFF) 120 121#define ALOG_SETDIR(dir) \ 122 {\ 123 strncpy(xx_alog_outdir,(dir),MAX_DIRNAME_LEN); \ 124 xx_alog_outdir[MAX_DIRNAME_LEN] = '\0'; \ 125 } 126 127 128#define ALOG_SETUP(pid,flag) \ 129 {\ 130 if (xx_alog_status & 0x1 && !xx_alog_setup_called) \ 131 {\ 132 xx_alog_setup_called = 1;\ 133 xx_alog_setup((pid),(flag));\ 134 }\ 135 } 136 137#define ALOG_MASTER(pid,flag) \ 138 {\ 139 if (xx_alog_status & 0x1) \ 140 {\ 141 xx_alog_setup((pid),(flag)); \ 142 xx_user1(xx_buf_head,(pid)); \ 143 }\ 144 } 145 146#define ALOG_DEFINE(event,edef,strdef) \ 147 {\ 148 if (xx_alog_status & 0x1) \ 149 {\ 150 xx_write(xx_buf_head,0,(-9),(event),(edef)); \ 151 xx_write(xx_buf_head,0,(-10),(event),(strdef)); \ 152 }\ 153 } 154 155#define ALOG_LOG(pid,type,data1,data2) \ 156 {\ 157 if (xx_alog_status & 0x1) \ 158 xx_write(xx_buf_head,(pid),(type),(data1),(data2)); \ 159 } 160 161#define ALOG_OUTPUT \ 162 {\ 163 if (xx_alog_status & 0x1 && !xx_alog_output_called) \ 164 {\ 165 xx_alog_output_called = 1;\ 166 xx_dump(xx_buf_head);\ 167 }\ 168 } 169 170#else /* ALOG_TRACE */ 171 172#define ALOG_DEC 173#define ALOG_STATUS(a) 174#define ALOG_ENABLE 175#define ALOG_DISABLE 176#define ALOG_SETDIR(a) 177#define ALOG_SETUP(a,b) 178#define ALOG_MASTER(a,b) 179#define ALOG_DEFINE(a,b,c) 180#define ALOG_LOG(a,b,c,d) 181#define ALOG_OUTPUT 182 183#endif /* ALOG_TRACE */ 184 185 186#endif /* _ALOG_H_ */ 187