FreeCalypso > hg > leo2moko-debug
comparison gpf/MISC/trace.c @ 0:509db1a7b7b8
initial import: leo2moko-r1
author | Space Falcon <falcon@ivan.Harhan.ORG> |
---|---|
date | Mon, 01 Jun 2015 03:24:05 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:509db1a7b7b8 |
---|---|
1 /* | |
2 +------------------------------------------------------------------------------ | |
3 | File: trace.c | |
4 +------------------------------------------------------------------------------ | |
5 | Copyright 2002 Texas Instruments Berlin, AG | |
6 | All rights reserved. | |
7 | | |
8 | This file is confidential and a trade secret of Texas | |
9 | Instruments Berlin, AG | |
10 | The receipt of or possession of this file does not convey | |
11 | any rights to reproduce or disclose its contents or to | |
12 | manufacture, use, or sell anything it may describe, in | |
13 | whole, or in part, without the specific written consent of | |
14 | Texas Instruments Berlin, AG. | |
15 +----------------------------------------------------------------------------- | |
16 | Purpose : This Modul provides data and functions for fast in memory tracing | |
17 +----------------------------------------------------------------------------- | |
18 */ | |
19 | |
20 #ifndef TRACE_C | |
21 #define TRACE_C | |
22 #endif | |
23 #define FAST_TRACE | |
24 | |
25 /*==== INCLUDES ===================================================*/ | |
26 | |
27 #include <string.h> | |
28 #include "typedefs.h" | |
29 #include "header.h" | |
30 #include "custom.h" | |
31 #include "vsi.h" | |
32 #include "gsm.h" | |
33 #include "prim.h" | |
34 #include "pei.h" | |
35 #include "tok.h" | |
36 | |
37 #include "trace.h" | |
38 | |
39 #include <string.h> | |
40 #include <stdio.h> | |
41 #include "message.h" | |
42 | |
43 /*==== CONST ======================================================*/ | |
44 | |
45 #define TRC_ENTITY 0x60 | |
46 #define TRC_FILE 1 | |
47 | |
48 | |
49 #ifdef OPTION_MULTITHREAD | |
50 #define VSI_CALLER "ACI", | |
51 #define VSI_CALLER_SINGLE "ACI" | |
52 #else | |
53 #define VSI_CALLER | |
54 #define VSI_CALLER_SINGLE | |
55 #endif | |
56 | |
57 | |
58 /*==== TYPES ======================================================*/ | |
59 | |
60 /*==== VARIABLES ==================================================*/ | |
61 | |
62 | |
63 /*==== FUNCTIONS ==================================================*/ | |
64 /* | |
65 +--------------------------------------------------------------------+ | |
66 | PROJECT : GSM-F&D (8411) MODULE : TRACE | | |
67 | STATE : code ROUTINE : trc_init | | |
68 +--------------------------------------------------------------------+ | |
69 | |
70 PURPOSE : This function is called to initialize the trace function | |
71 | |
72 */ | |
73 | |
74 GLOBAL void trc_init | |
75 ( | |
76 void | |
77 ) | |
78 { | |
79 trc_p_buffer = trc_buffer; | |
80 trc_p_buffer_end = &trc_buffer[TRC_BUF_LEN-1]; | |
81 trc_wrap_around = FALSE; | |
82 trc_wrap_around_enable = TRUE; | |
83 trc_enabled = TRUE; | |
84 /*semTRC = vsi_s_open (VSI_CALLER "TRC"); */ | |
85 } | |
86 | |
87 | |
88 /* | |
89 +--------------------------------------------------------------------+ | |
90 | PROJECT : GSM-F&D (8411) MODULE : TRACE | | |
91 | STATE : code ROUTINE : trc_enable_wrap_around | | |
92 +--------------------------------------------------------------------+ | |
93 | |
94 PURPOSE : This function is called to enable wrap around | |
95 | |
96 */ | |
97 | |
98 GLOBAL void trc_enable_wrap_around | |
99 ( | |
100 void | |
101 ) | |
102 { | |
103 trc_wrap_around_enable = TRUE; | |
104 } | |
105 | |
106 | |
107 /* | |
108 +--------------------------------------------------------------------+ | |
109 | PROJECT : GSM-F&D (8411) MODULE : TRACE | | |
110 | STATE : code ROUTINE : trc_disable_wrap_around | | |
111 +--------------------------------------------------------------------+ | |
112 | |
113 PURPOSE : This function is called to disable wrap around | |
114 | |
115 */ | |
116 | |
117 GLOBAL void trc_disable_wrap_around | |
118 ( | |
119 void | |
120 ) | |
121 { | |
122 trc_wrap_around_enable = FALSE; | |
123 } | |
124 | |
125 | |
126 /* | |
127 +--------------------------------------------------------------------+ | |
128 | PROJECT : GSM-F&D (8411) MODULE : TRACE | | |
129 | STATE : code ROUTINE : trc_enable | | |
130 +--------------------------------------------------------------------+ | |
131 | |
132 PURPOSE : This function is called to enable fast trace | |
133 | |
134 */ | |
135 | |
136 GLOBAL void trc_enable | |
137 ( | |
138 void | |
139 ) | |
140 { | |
141 trc_enabled = TRUE; | |
142 } | |
143 | |
144 | |
145 /* | |
146 +--------------------------------------------------------------------+ | |
147 | PROJECT : GSM-F&D (8411) MODULE : TRACE | | |
148 | STATE : code ROUTINE : trc_disable | | |
149 +--------------------------------------------------------------------+ | |
150 | |
151 PURPOSE : This function is called to disable fast trace | |
152 | |
153 */ | |
154 | |
155 GLOBAL void trc_disable | |
156 ( | |
157 void | |
158 ) | |
159 { | |
160 trc_enabled = FALSE; | |
161 } | |
162 | |
163 | |
164 /* | |
165 +--------------------------------------------------------------------+ | |
166 | PROJECT : GSM-F&D (8411) MODULE : RA_SHM | | |
167 | STATE : code ROUTINE : trc_dump | | |
168 +--------------------------------------------------------------------+ | |
169 | |
170 PURPOSE : the content of the stored dump is dumped | |
171 into the system trace window. | |
172 | |
173 */ | |
174 | |
175 GLOBAL void trc_dump (void) | |
176 { | |
177 T_TRC_BUF_ENTRY *p_readOut; | |
178 ULONG *p; | |
179 ULONG i; | |
180 char buf [40]; | |
181 char buf1 [40]; | |
182 | |
183 #ifndef NEW_FRAME | |
184 vsi_o_trace ("", 0xff, "---FASTTRACEBUFFER---"); | |
185 #else | |
186 vsi_o_ttrace (0, 0xff, "---FASTTRACEBUFFER---"); | |
187 #endif | |
188 if (trc_wrap_around) | |
189 { | |
190 for (p_readOut= trc_p_buffer; | |
191 p_readOut < trc_p_buffer_end; | |
192 p_readOut++) | |
193 { | |
194 p = (ULONG*)p_readOut; | |
195 | |
196 buf1[0]='\0'; | |
197 | |
198 for (i = sizeof(T_TRC_BUF_ENTRY); i>=0; i-=sizeof(ULONG)) | |
199 { | |
200 sprintf(buf1, "0x%x ", *p++); | |
201 strcat (buf, buf1); | |
202 } | |
203 #ifndef NEW_FRAME | |
204 vsi_o_trace ("", 0xff, buf); | |
205 vsi_t_sleep("", 1); | |
206 #else | |
207 vsi_o_ttrace (0, 0xff, buf); | |
208 vsi_t_sleep(0, 1); | |
209 #endif | |
210 } | |
211 } | |
212 for (p_readOut= trc_buffer; | |
213 p_readOut < trc_p_buffer; | |
214 p_readOut++) | |
215 { | |
216 p = (ULONG*)p_readOut; | |
217 | |
218 buf1[0]='\0'; | |
219 | |
220 for (i = sizeof(T_TRC_BUF_ENTRY); i>=0; i-=sizeof(ULONG)) | |
221 { | |
222 sprintf(buf1, "0x%x ", *p++); | |
223 strcat (buf, buf1); | |
224 } | |
225 #ifndef NEW_FRAME | |
226 vsi_o_trace ("", 0xff, buf); | |
227 vsi_t_sleep("", 1); | |
228 #else | |
229 vsi_o_ttrace (0, 0xff, buf); | |
230 vsi_t_sleep(0, 1); | |
231 #endif | |
232 } | |
233 | |
234 #ifndef NEW_FRAME | |
235 vsi_o_trace ("", 0xff, "---END---"); | |
236 #else | |
237 vsi_o_ttrace (0, 0xff, "---END---"); | |
238 #endif | |
239 } |