FreeCalypso > hg > freecalypso-sw
comparison gsm-fw/riviera/rvf/rvf_trace_adapt.c @ 143:afceeeb2cba1
Our nuc-fw is destined to become gsm-fw, so I went ahead and did the big hg mv
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Tue, 12 Nov 2013 05:35:48 +0000 |
parents | nuc-fw/riviera/rvf/rvf_trace_adapt.c@e7d4ec9c4c32 |
children |
comparison
equal
deleted
inserted
replaced
142:15d5977390c2 | 143:afceeeb2cba1 |
---|---|
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 #include "../../include/config.h" | |
20 | |
21 #include "../rv/general.h" | |
22 #include "../rv/rv.h" | |
23 #include "../rv/rv_general.h" | |
24 #include "rvf_api.h" | |
25 | |
26 #include "../rvt/rvt_gen.h" | |
27 | |
28 #include "../rvm/rvm_use_id_list.h" | |
29 | |
30 #include <string.h> | |
31 | |
32 /* DAR files used to redirect trace to DAR entity */ | |
33 //#ifdef RVM_DAR_SWE | |
34 // #include "dar_api.h" | |
35 // #include "dar_gen.h" | |
36 // #include "dar_structs_i.h" | |
37 // #include "dar_diagnose_i.h" | |
38 | |
39 /* Define a pointer to the DAR Global Environment Control block */ | |
40 // extern T_DAR_ENV_CTRL_BLK *dar_gbl_var_p; | |
41 //#endif | |
42 | |
43 /* | |
44 * FreeCalypso: the configuration we've got with the Sotomodem semi-src | |
45 * has this in g23m/__out__/gsm_<blah>/config/trace.cfg: | |
46 */ | |
47 | |
48 #define LAYER_DBG 0xFFFFFFFF | |
49 #define TRACE_LEVEL_FILTER 5 | |
50 | |
51 /* | |
52 * The above configuration corresponds to all trace output | |
53 * being enabled by default. | |
54 */ | |
55 | |
56 UINT8 rvf_trace_level = TRACE_LEVEL_FILTER; | |
57 UINT32 rvf_layer_mask = LAYER_DBG; | |
58 | |
59 /* Decimal to hexadecimal conversion table */ | |
60 static const char Num2Char[] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'}; | |
61 | |
62 extern T_RVT_USER_ID rv_trace_user_id; | |
63 | |
64 #ifndef FRAMING_PROTOCOL | |
65 void rvf_send_trace1 (char * msg, UINT8 msg_length, UINT32 val, UINT8 TRACE_LEVEL, UINT32 swe_use_id) | |
66 { | |
67 UINT32 trace_type = swe_use_id; | |
68 | |
69 /* Apply the appropriate compilation flags to filter trace messages based on | |
70 their type and level */ | |
71 if ((TRACE_LEVEL < RV_TRACE_LEVEL_WARNING) || | |
72 ((TRACE_LEVEL <= rvf_trace_level) && | |
73 (((trace_type & rvf_layer_mask & 0x0000FFFF) == (trace_type & 0x0000FFFF)) || | |
74 ((trace_type & rvf_layer_mask & 0xFFFF0000) != (trace_type & 0xFFFF0000))))) | |
75 { | |
76 char * buff; | |
77 | |
78 if (val == NULL_PARAM) | |
79 { | |
80 rvt_mem_alloc (rv_trace_user_id, msg_length, (T_RVT_BUFFER *)&buff); | |
81 if (buff != NULL) /* Check if there is enough memory for the buffer */ | |
82 { | |
83 /* Copy the body of the message */ | |
84 memcpy( buff, msg, msg_length); | |
85 rvt_send_trace_no_cpy( buff, rv_trace_user_id, msg_length, RVT_ASCII_FORMAT); | |
86 } | |
87 } | |
88 else | |
89 { | |
90 rvt_mem_alloc (rv_trace_user_id, msg_length +11, (T_RVT_BUFFER *)&buff); | |
91 if (buff != NULL) /* Check if there is enough memory for the buffer */ | |
92 { | |
93 UINT8 i; | |
94 | |
95 /* Copy the body of the message */ | |
96 memcpy( buff, msg, msg_length); | |
97 | |
98 ((char *)buff)[msg_length] = ' '; | |
99 ((char *)buff)[msg_length + 1] = '0'; | |
100 ((char *)buff)[msg_length + 2] = 'x'; | |
101 | |
102 for (i=0; i<8; i++) | |
103 { | |
104 ((char *)buff)[msg_length+3+i] = Num2Char[(UINT8)((val<<(i<<2))>>28)]; | |
105 } | |
106 rvt_send_trace_no_cpy(buff, rv_trace_user_id, msg_length + 11, RVT_BINARY_FORMAT); | |
107 } | |
108 } | |
109 } | |
110 } | |
111 #else | |
112 /********************************* VERSION WITH TRACE MUX **************************/ | |
113 | |
114 void rvf_send_trace1 (char * msg, UINT8 msg_length, UINT32 val, UINT8 TRACE_LEVEL, UINT32 swe_use_id) | |
115 { | |
116 UINT32 trace_type = swe_use_id; | |
117 | |
118 /* Apply the appropriate compilation flags to filter trace messages based | |
119 on their type and level */ | |
120 if ((TRACE_LEVEL < RV_TRACE_LEVEL_WARNING) || | |
121 ((TRACE_LEVEL <= rvf_trace_level) && | |
122 (((trace_type & rvf_layer_mask & 0x0000FFFF) == (trace_type & 0x0000FFFF)) || | |
123 ((trace_type & rvf_layer_mask & 0xFFFF0000) != (trace_type & 0xFFFF0000))))) | |
124 { | |
125 char * buff; | |
126 | |
127 if (val == NULL_PARAM) | |
128 { | |
129 rvt_mem_alloc (rv_trace_user_id, msg_length+5, (T_RVT_BUFFER *)&buff); | |
130 | |
131 if (buff != NULL) /* Check if there is enough memory for the buffer */ | |
132 { | |
133 /* Add the trace type (MSB and LSB) and Trace level */ | |
134 buff [0] = (char) (trace_type >> 24); | |
135 buff [1] = (char) (trace_type >> 16); | |
136 buff [2] = (char) (trace_type >> 8); | |
137 buff [3] = (char) (trace_type & 0xff); | |
138 buff [4] = (char) TRACE_LEVEL; | |
139 | |
140 /* Copy the message in the new buffer */ | |
141 memcpy(buff+5, msg, msg_length); | |
142 | |
143 /* Send the trace message */ | |
144 rvt_send_trace_no_cpy ((T_RVT_BUFFER) buff, rv_trace_user_id, msg_length+5, RVT_BINARY_FORMAT); | |
145 } | |
146 } | |
147 else | |
148 { | |
149 rvt_mem_alloc (rv_trace_user_id, msg_length+16, (T_RVT_BUFFER *)&buff); | |
150 | |
151 if (buff != NULL) /* Check if there is enough memory for the buffer */ | |
152 { | |
153 UINT8 i; | |
154 | |
155 /* Add the trace type (MSB and LSB) and Trace level */ | |
156 buff [0] = (char) (trace_type >> 24); | |
157 buff [1] = (char) (trace_type >> 16); | |
158 buff [2] = (char) (trace_type >> 8); | |
159 buff [3] = (char) (trace_type & 0xff); | |
160 buff [4] = (char) TRACE_LEVEL; | |
161 | |
162 /* Copy the message in the new buffer */ | |
163 memcpy( buff + 5, msg, msg_length); | |
164 | |
165 buff[5+msg_length] = ' '; | |
166 buff[5+msg_length + 1] = '0'; | |
167 buff[5+msg_length + 2] = 'x'; | |
168 | |
169 for (i=0; i<8; i++) | |
170 { | |
171 ((char *)buff)[8+msg_length+i] = Num2Char[(UINT8)((val<<(i<<2))>>28)]; | |
172 } | |
173 | |
174 /* Send the trace message */ | |
175 rvt_send_trace_no_cpy ((T_RVT_BUFFER) buff, rv_trace_user_id, msg_length+16, RVT_BINARY_FORMAT); | |
176 } | |
177 } | |
178 } | |
179 } | |
180 #endif |