FreeCalypso > hg > ffs-editor
comparison src/cs/riviera/rvf/rvf_trace_adapt.c @ 0:92470e5d0b9e
src: partial import from FC Selenite
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Fri, 15 May 2020 01:28:16 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:92470e5d0b9e |
---|---|
1 /****************************************************************************/ | |
2 /* */ | |
3 /* Name rvf_trace_adapt.c */ | |
4 /* */ | |
5 /* Function this file is used to trace messages if TRACE module is */ | |
6 /* activated or not */ | |
7 /* */ | |
8 /* Version 0.1 */ | |
9 /* */ | |
10 /* Date Modification */ | |
11 /* ------------------------------------ */ | |
12 /* 03/19/2001 Create */ | |
13 /* */ | |
14 /* Author Pascal Puel (p-puel@tif.ti.com) */ | |
15 /* */ | |
16 /* (C) Copyright 1999 by Texas Instruments Incorporated, All Rights Reserved*/ | |
17 /****************************************************************************/ | |
18 | |
19 | |
20 #ifndef _WINDOWS | |
21 #include "config/rv.cfg" | |
22 #include "config/trace.cfg" | |
23 #endif | |
24 | |
25 #include "rv/general.h" | |
26 #include "rv/rv.h" | |
27 #include "rv/rv_general.h" | |
28 #include "rvf/rvf_api.h" | |
29 | |
30 #include "rvt/rvt_gen.h" | |
31 | |
32 #include "rvm/rvm_use_id_list.h" | |
33 | |
34 #include <string.h> | |
35 | |
36 /* DAR files used to redirect trace to DAR entity */ | |
37 //#ifdef RVM_DAR_SWE | |
38 // #include "dar_api.h" | |
39 // #include "dar_gen.h" | |
40 // #include "dar_structs_i.h" | |
41 // #include "dar_diagnose_i.h" | |
42 | |
43 /* Define a pointer to the DAR Global Environment Control block */ | |
44 // extern T_DAR_ENV_CTRL_BLK *dar_gbl_var_p; | |
45 //#endif | |
46 | |
47 UINT8 rvf_trace_level = TRACE_LEVEL_FILTER; | |
48 UINT32 rvf_layer_mask = LAYER_DBG; | |
49 | |
50 /* Decimal to hexadecimal conversion table */ | |
51 static const char Num2Char[] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'}; | |
52 | |
53 extern T_RVT_USER_ID rv_trace_user_id; | |
54 | |
55 #ifndef FRAMING_PROTOCOL | |
56 void rvf_send_trace1 (char * msg, UINT8 msg_length, UINT32 val, UINT8 TRACE_LEVEL, UINT32 swe_use_id) | |
57 { | |
58 UINT32 trace_type = swe_use_id; | |
59 | |
60 /* Apply the appropriate compilation flags to filter trace messages based on | |
61 their type and level */ | |
62 if ((TRACE_LEVEL < RV_TRACE_LEVEL_WARNING) || | |
63 ((TRACE_LEVEL <= rvf_trace_level) && | |
64 (((trace_type & rvf_layer_mask & 0x0000FFFF) == (trace_type & 0x0000FFFF)) || | |
65 ((trace_type & rvf_layer_mask & 0xFFFF0000) != (trace_type & 0xFFFF0000))))) | |
66 { | |
67 char * buff; | |
68 | |
69 if (val == NULL_PARAM) | |
70 { | |
71 rvt_mem_alloc (rv_trace_user_id, msg_length, (T_RVT_BUFFER *)&buff); | |
72 if (buff != NULL) /* Check if there is enough memory for the buffer */ | |
73 { | |
74 /* Copy the body of the message */ | |
75 memcpy( buff, msg, msg_length); | |
76 rvt_send_trace_no_cpy( buff, rv_trace_user_id, msg_length, RVT_ASCII_FORMAT); | |
77 } | |
78 } | |
79 else | |
80 { | |
81 rvt_mem_alloc (rv_trace_user_id, msg_length +11, (T_RVT_BUFFER *)&buff); | |
82 if (buff != NULL) /* Check if there is enough memory for the buffer */ | |
83 { | |
84 UINT8 i; | |
85 | |
86 /* Copy the body of the message */ | |
87 memcpy( buff, msg, msg_length); | |
88 | |
89 ((char *)buff)[msg_length] = ' '; | |
90 ((char *)buff)[msg_length + 1] = '0'; | |
91 ((char *)buff)[msg_length + 2] = 'x'; | |
92 | |
93 for (i=0; i<8; i++) | |
94 { | |
95 ((char *)buff)[msg_length+3+i] = Num2Char[(UINT8)((val<<(i<<2))>>28)]; | |
96 } | |
97 rvt_send_trace_no_cpy(buff, rv_trace_user_id, msg_length + 11, RVT_BINARY_FORMAT); | |
98 } | |
99 } | |
100 } | |
101 } | |
102 #else | |
103 /********************************* VERSION WITH TRACE MUX **************************/ | |
104 | |
105 void rvf_send_trace1 (char * msg, UINT8 msg_length, UINT32 val, UINT8 TRACE_LEVEL, UINT32 swe_use_id) | |
106 { | |
107 UINT32 trace_type = swe_use_id; | |
108 | |
109 /* Apply the appropriate compilation flags to filter trace messages based | |
110 on their type and level */ | |
111 if ((TRACE_LEVEL < RV_TRACE_LEVEL_WARNING) || | |
112 ((TRACE_LEVEL <= rvf_trace_level) && | |
113 (((trace_type & rvf_layer_mask & 0x0000FFFF) == (trace_type & 0x0000FFFF)) || | |
114 ((trace_type & rvf_layer_mask & 0xFFFF0000) != (trace_type & 0xFFFF0000))))) | |
115 { | |
116 char * buff; | |
117 | |
118 if (val == NULL_PARAM) | |
119 { | |
120 rvt_mem_alloc (rv_trace_user_id, msg_length+5, (T_RVT_BUFFER *)&buff); | |
121 | |
122 if (buff != NULL) /* Check if there is enough memory for the buffer */ | |
123 { | |
124 /* Add the trace type (MSB and LSB) and Trace level */ | |
125 buff [0] = (char) (trace_type >> 24); | |
126 buff [1] = (char) (trace_type >> 16); | |
127 buff [2] = (char) (trace_type >> 8); | |
128 buff [3] = (char) (trace_type & 0xff); | |
129 buff [4] = (char) TRACE_LEVEL; | |
130 | |
131 /* Copy the message in the new buffer */ | |
132 memcpy(buff+5, msg, msg_length); | |
133 | |
134 /* Send the trace message */ | |
135 rvt_send_trace_no_cpy ((T_RVT_BUFFER) buff, rv_trace_user_id, msg_length+5, RVT_BINARY_FORMAT); | |
136 } | |
137 } | |
138 else | |
139 { | |
140 rvt_mem_alloc (rv_trace_user_id, msg_length+16, (T_RVT_BUFFER *)&buff); | |
141 | |
142 if (buff != NULL) /* Check if there is enough memory for the buffer */ | |
143 { | |
144 UINT8 i; | |
145 | |
146 /* Add the trace type (MSB and LSB) and Trace level */ | |
147 buff [0] = (char) (trace_type >> 24); | |
148 buff [1] = (char) (trace_type >> 16); | |
149 buff [2] = (char) (trace_type >> 8); | |
150 buff [3] = (char) (trace_type & 0xff); | |
151 buff [4] = (char) TRACE_LEVEL; | |
152 | |
153 /* Copy the message in the new buffer */ | |
154 memcpy( buff + 5, msg, msg_length); | |
155 | |
156 buff[5+msg_length] = ' '; | |
157 buff[5+msg_length + 1] = '0'; | |
158 buff[5+msg_length + 2] = 'x'; | |
159 | |
160 for (i=0; i<8; i++) | |
161 { | |
162 ((char *)buff)[8+msg_length+i] = Num2Char[(UINT8)((val<<(i<<2))>>28)]; | |
163 } | |
164 | |
165 /* Send the trace message */ | |
166 rvt_send_trace_no_cpy ((T_RVT_BUFFER) buff, rv_trace_user_id, msg_length+16, RVT_BINARY_FORMAT); | |
167 } | |
168 } | |
169 } | |
170 } | |
171 #endif |