FreeCalypso > hg > freecalypso-sw
comparison gsm-fw/services/etm/etm_api.c @ 165:9dbf3248a197
starting to compile ETM
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Tue, 19 Nov 2013 04:23:29 +0000 |
parents | d78219c43fbf |
children | f9ac53d8e999 |
comparison
equal
deleted
inserted
replaced
164:d78219c43fbf | 165:9dbf3248a197 |
---|---|
17 * | 17 * |
18 * (C) Copyright 2003 by Texas Instruments Incorporated, All Rights Reserved | 18 * (C) Copyright 2003 by Texas Instruments Incorporated, All Rights Reserved |
19 *********************************************************************************/ | 19 *********************************************************************************/ |
20 | 20 |
21 | 21 |
22 #include "etm/etm.h" | 22 #include "etm.h" |
23 #include "etm/etm_env.h" | 23 #include "etm_env.h" |
24 #include "etm/etm_messages_i.h" | 24 #include "etm_messages_i.h" |
25 #include "etm/etm_trace.h" | 25 #include "etm_trace.h" |
26 | 26 |
27 #include "etm/etm_misc.h" | 27 #include "etm_misc.h" |
28 | 28 |
29 #include "rvf/rvf_api.h" | 29 #include "../../riviera/rvf/rvf_api.h" |
30 | 30 |
31 #include <string.h> | 31 #include <string.h> |
32 | 32 |
33 extern T_ETM_ENV_CTRL_BLK *etm_env_ctrl_blk; | 33 extern T_ETM_ENV_CTRL_BLK *etm_env_ctrl_blk; |
34 | 34 |
42 * | 42 * |
43 * @return ETM_NOMEM in case of a memory error, | 43 * @return ETM_NOMEM in case of a memory error, |
44 * the return value of rvf_send_msg otherwise. | 44 * the return value of rvf_send_msg otherwise. |
45 *********************************************************************************/ | 45 *********************************************************************************/ |
46 | 46 |
47 int etm_register(char name[], int mid, int task_id, T_RVF_ADDR_ID addr_id, ETM_CALLBACK_FUNC callback) | 47 int etm_register(char name[], int mid, int task_id, T_RVF_ADDR_ID addr_id, |
48 { | 48 ETM_CALLBACK_FUNC callback) |
49 /* Type for a registration event. */ | 49 { |
50 T_ETM_REGISTER_REQ *etm_registration_p; | 50 /* Type for a registration event. */ |
51 | 51 T_ETM_REGISTER_REQ *etm_registration_p; |
52 tr_etm(TgTrEtmLow, "ETM API: _register bridge function(%s)", name); | 52 |
53 tr_etm(TgTrEtmLow, "ETM API: _register bridge function(%s)", name); | |
53 | 54 |
54 /* Allocate the memory for the message to send */ | 55 /* Allocate the memory for the message to send */ |
55 if ((etm_registration_p = (T_ETM_REGISTER_REQ*) etm_malloc(sizeof(T_ETM_REGISTER_REQ))) == NULL) | 56 if ((etm_registration_p = (T_ETM_REGISTER_REQ*) |
57 etm_malloc(sizeof(T_ETM_REGISTER_REQ))) == NULL) | |
56 return ETM_NOMEM; | 58 return ETM_NOMEM; |
57 | 59 |
58 /* Fill the message id */ | 60 /* Fill the message id */ |
59 etm_registration_p->header.msg_id = ETM_REGISTER_REQ; | 61 etm_registration_p->header.msg_id = ETM_REGISTER_REQ; |
60 | 62 |
63 etm_registration_p->header.dest_addr_id = etm_env_ctrl_blk->addr_id; | 65 etm_registration_p->header.dest_addr_id = etm_env_ctrl_blk->addr_id; |
64 etm_registration_p->header.callback_func = NULL; | 66 etm_registration_p->header.callback_func = NULL; |
65 | 67 |
66 /* Fill the message parameters */ | 68 /* Fill the message parameters */ |
67 memcpy(etm_registration_p->name, name, strlen(name)); | 69 memcpy(etm_registration_p->name, name, strlen(name)); |
68 etm_registration_p->mid = mid; | 70 etm_registration_p->mid = mid; |
69 etm_registration_p->task_id = task_id; | 71 etm_registration_p->task_id = task_id; |
70 etm_registration_p->addr_id = addr_id; | 72 etm_registration_p->addr_id = addr_id; |
71 etm_registration_p->rx_callback_func = callback; | 73 etm_registration_p->rx_callback_func = callback; |
72 | 74 |
73 /* Send the message using mailbox. */ | 75 /* Send the message using mailbox. */ |
74 return rvf_send_msg(etm_env_ctrl_blk->addr_id, | 76 return rvf_send_msg(etm_env_ctrl_blk->addr_id, (void*) etm_registration_p); |
75 (void*) etm_registration_p); | 77 } |
76 } | 78 |
77 | 79 |
78 | 80 /******************************************************************************** |
79 /******************************************************************************** | 81 * Cleans ETM register tables, i.e. set/clean the variable at their |
80 * Cleans ETM register tables, i.e. set/clean the variable at their initialization | 82 * initialization state for a specific entity. |
81 * state for a specific entity. | 83 * This function can be used to reinitialize ETM register database without |
82 * This function can be used to reinitialize ETM register database without having to | 84 * having to start/stop it. |
83 * start/stop it. | |
84 * | 85 * |
85 * This is a bridge function. It sends ETM_UNREGISTER message to ETM. | 86 * This is a bridge function. It sends ETM_UNREGISTER message to ETM. |
86 * | 87 * |
87 * @return ETM_NOMEM in case of a memory error, | 88 * @return ETM_NOMEM in case of a memory error, |
88 * the return value of rvf_send_msg otherwise. | 89 * the return value of rvf_send_msg otherwise. |
89 *********************************************************************************/ | 90 *********************************************************************************/ |
90 | 91 |
91 int etm_unregister(char name[], int mid, int task_id, T_RVF_ADDR_ID addr_id, ETM_CALLBACK_FUNC callback) | 92 int etm_unregister(char name[], int mid, int task_id, T_RVF_ADDR_ID addr_id, ETM_CALLBACK_FUNC callback) |
92 { | 93 { |
93 /* Type for a start input event. */ | 94 /* Type for a start input event. */ |
94 T_ETM_UNREGISTER *etm_unregister_p; | 95 T_ETM_UNREGISTER *etm_unregister_p; |
95 | 96 |
96 tr_etm(TgTrEtmLow, "ETM API: _unregister bridge function"); | 97 tr_etm(TgTrEtmLow, "ETM API: _unregister bridge function"); |
97 | 98 |
98 /* Allocate the memory for the message to send */ | 99 /* Allocate the memory for the message to send */ |
99 if ((etm_unregister_p = (T_ETM_UNREGISTER*) etm_malloc(sizeof(T_ETM_UNREGISTER))) == NULL) | 100 if ((etm_unregister_p = (T_ETM_UNREGISTER*) |
101 etm_malloc(sizeof(T_ETM_UNREGISTER))) == NULL) | |
100 return ETM_NOMEM; | 102 return ETM_NOMEM; |
101 | 103 |
102 /* Fill the message id */ | 104 /* Fill the message id */ |
103 etm_unregister_p->header.msg_id = ETM_UNREGISTER; | 105 etm_unregister_p->header.msg_id = ETM_UNREGISTER; |
104 | 106 |
107 etm_unregister_p->header.dest_addr_id = etm_env_ctrl_blk->addr_id; | 109 etm_unregister_p->header.dest_addr_id = etm_env_ctrl_blk->addr_id; |
108 etm_unregister_p->header.callback_func = NULL; | 110 etm_unregister_p->header.callback_func = NULL; |
109 | 111 |
110 /* Fill the message parameters */ | 112 /* Fill the message parameters */ |
111 memcpy(etm_unregister_p->name, name, strlen(name)); | 113 memcpy(etm_unregister_p->name, name, strlen(name)); |
112 etm_unregister_p->mid = mid; | 114 etm_unregister_p->mid = mid; |
113 etm_unregister_p->task_id = task_id; | 115 etm_unregister_p->task_id = task_id; |
114 etm_unregister_p->addr_id = addr_id; | 116 etm_unregister_p->addr_id = addr_id; |
115 etm_unregister_p->rx_callback_func = callback; | 117 etm_unregister_p->rx_callback_func = callback; |
116 | 118 |
117 /* Send the message using mailbox. */ | 119 /* Send the message using mailbox. */ |
118 return rvf_send_msg(etm_env_ctrl_blk->addr_id, | 120 return rvf_send_msg(etm_env_ctrl_blk->addr_id, (void*) etm_unregister_p); |
119 (void*) etm_unregister_p); | |
120 } | 121 } |
121 | 122 |
122 | 123 |
123 /******************************************************************************** | 124 /******************************************************************************** |
124 * Get data from a ETM packet structur. Get either 8, 16 or 32 value | 125 * Get data from a ETM packet structur. Get either 8, 16 or 32 value |
140 return value; | 141 return value; |
141 } | 142 } |
142 | 143 |
143 int etm_get16(void *buf) | 144 int etm_get16(void *buf) |
144 { | 145 { |
145 unsigned char *p = buf; | 146 unsigned char *p = buf; |
146 | 147 |
147 int value = | 148 int value = |
148 (*p++ | (*p << 8)); | 149 (*p++ | (*p << 8)); |
149 | 150 |
150 tr_etm(TgTrEtmLow, "ETM API: _get16(%d)", value); | 151 tr_etm(TgTrEtmLow, "ETM API: _get16(%d)", value); |
275 if(error < 0) | 276 if(error < 0) |
276 tr_etm(TgTrFatal, "ETM API: _pkt_send: ERROR(%d)", error); | 277 tr_etm(TgTrFatal, "ETM API: _pkt_send: ERROR(%d)", error); |
277 | 278 |
278 return error; | 279 return error; |
279 } | 280 } |
280 |