- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

# /space/home/slher/rel/Beken/v6_4_5/macsw/modules/dbg/src/dbg_task.c

Go to the documentation of this file.

    00001
    00020 /*
    00021  * INCLUDE FILES
    00022  ****************************************************************************************
    00023  */
    00024 #include "co_endian.h"
    00025
    00026 #include "sta_mgmt.h"
    00027
    00028 #include "ke_timer.h"
    00029 #include "reg_mac_core.h"
    00030
    00031 #include "dbg.h"
    00032 #include "dbg_task.h"
    00033 #include "co_utils.h"
    00034
    00035 #include "reg_sysctrl.h"
    00036
    00037 /*
    00038  * MESSAGE HANDLERS
    00039  ****************************************************************************************
    00040  */
    00052 static int
    00053 dbg_mem_read_req_handler(ke_msg_id_t const msgid,
    00054                          struct dbg_mem_read_req const *param,
    00055                          ke_task_id_t const dest_id,
    00056                          ke_task_id_t const src_id)
    00057 {
    00058     // Allocate the message response structure
    00059     struct dbg_mem_read_cfm *mem_rd_cfm =
    00060         KE_MSG_ALLOC(DBG_MEM_READ_CFM, src_id, dest_id, dbg_mem_read_cfm);
    00061
    00063     mem_rd_cfm->memdata = *(volatile uint32_t *)param->memaddr;
    00064     mem_rd_cfm->memaddr = param->memaddr;
    00065
    00066     // Trace the action
    00067     dbg(D_INF D_DBG "DBG: Reading memory: [0x%08x] = 0x%08x / %d\n",
    00068         param->memaddr, mem_rd_cfm->memdata, mem_rd_cfm->memdata);
    00069
    00070     // Post the confirm message to the kernel
    00071     ke_msg_send(mem_rd_cfm);
    00072
    00073     return KE_MSG_CONSUMED;
    00074 }
    00075
    00087 static int
    00088 dbg_mem_write_req_handler(ke_msg_id_t const msgid,
    00089                           struct dbg_mem_write_req const *param,
    00090                           ke_task_id_t const dest_id,
    00091                           ke_task_id_t const src_id)
    00092 {
    00093     // Allocate the message response structure
    00094     struct dbg_mem_write_cfm *mem_wr_cfm =
    00095         KE_MSG_ALLOC(DBG_MEM_WRITE_CFM, src_id, dest_id, dbg_mem_write_cfm);
    00096
    00097     // Write to the corresponding memory location
    00098     *(volatile uint32_t *)param->memaddr = param->memdata;
    00099     mem_wr_cfm->memaddr = param->memaddr;
    00100     mem_wr_cfm->memdata = *(volatile uint32_t *)param->memaddr;
    00101
    00102     // Trace the action
    00103     dbg(D_INF D_DBG "DBG: Writing memory with 0x%08x / %d: [0x%08x] = 0x%08x / %d\n",
    00104         param->memdata, param->memdata, param->memaddr,
    00105         mem_wr_cfm->memdata, mem_wr_cfm->memdata);
    00106
    00107     // Post the confirm message to the kernel
    00108     ke_msg_send(mem_wr_cfm);
    00109
    00110     return KE_MSG_CONSUMED;
    00111 }
    00112
    00124 static int
    00125 dbg_set_mod_filter_req_handler(ke_msg_id_t const msgid,
    00126                                struct dbg_set_mod_filter_req const *param,
    00127                                ke_task_id_t const dest_id,
    00128                                ke_task_id_t const src_id)
    00129 {
    00130     // Trace the action
    00131     dbg(D_INF D_DBG "DBG: Setting module filter: 0x%08x\n", param->mod_filter);
    00132
    00134     dbg_env.filter_module = param->mod_filter;
    00135
    00136     // Post the confirm message to the kernel
    00137     ke_msg_send_basic(DBG_SET_MOD_FILTER_CFM, src_id, dest_id);
    00138
    00139     return KE_MSG_CONSUMED;
    00140 }
    00141
    00142
    00154 static int
    00155 dbg_set_sev_filter_req_handler(ke_msg_id_t const msgid,
    00156                                struct dbg_set_sev_filter_req const *param,
    00157                                ke_task_id_t const dest_id,
    00158                                ke_task_id_t const src_id)
    00159 {
    00160     // Trace the action
    00161     dbg(D_INF D_DBG "DBG: Setting severity filter: 0x%08x\n", param->sev_filter);
    00162
    00164     dbg_env.filter_severity = param->sev_filter;
    00165
    00166     // Post the confirm message to the kernel
    00167     ke_msg_send_basic(DBG_SET_SEV_FILTER_CFM, src_id, dest_id);
    00168
    00169     return KE_MSG_CONSUMED;
    00170 }
    00171
    00172
    00184 static int
    00185 dbg_get_sys_stat_req_handler(ke_msg_id_t const msgid,
    00186                              void const *param,
    00187                              ke_task_id_t const dest_id,
    00188                              ke_task_id_t const src_id)
    00189 {
    00190     struct dbg_get_sys_stat_cfm *cfm = KE_MSG_ALLOC(DBG_GET_SYS_STAT_CFM, src_id,
    00191                                                     dest_id, dbg_get_sys_stat_cfm);
    00192
    00193     // Fill in the message parameters
    00194     #if NX_SYS_STAT
    00195     cfm->cpu_sleep_time = dbg_env.sys_stats.cpu_sleep_time;
    00196     cfm->doze_time = dbg_env.sys_stats.doze_time;
    00197     cfm->stats_time = dbg_env.sys_stats.stats_time
    00198                    + ((dbg_sys_stats_time() - dbg_env.sys_stats.start_time) >> 10);
    00199
    00200     // Reset and restart the statistic measurements
    00201     dbg_sys_stat_reset();
    00202     #else
    00203     cfm->cpu_sleep_time = 0;
    00204     cfm->doze_time = 0;
    00205     cfm->stats_time = 0;
    00206     #endif
    00207
    00208     // Send the confirm message to the kernel
    00209     ke_msg_send(cfm);
    00210
    00211     return KE_MSG_CONSUMED;
    00212 }
    00213
    00214
    00215 #if NX_SYS_STAT
    00216
    00227 static int
    00228 dbg_sys_stat_timer_handler(ke_msg_id_t const msgid,
    00229                            void const *param,
    00230                            ke_task_id_t const dest_id,
    00231                            ke_task_id_t const src_id)
    00232 {
    00233     uint32_t time = dbg_sys_stats_time();
    00234
    00235     dbg_env.sys_stats.stats_time += (time - dbg_env.sys_stats.start_time) >> 10;
    00236     dbg_env.sys_stats.start_time = time;
    00237     // Restart the statistic measurement timer
    00238     ke_timer_set(DBG_SYS_STAT_TIMER, TASK_DBG, DBG_SYS_STAT_TIMEOUT);
    00239
    00240     return KE_MSG_CONSUMED;
    00241 }
    00242 #endif
    00243
    00244
    00245 /*
    00246  * TASK DESCRIPTOR DEFINITIONS
    00247  ****************************************************************************************
    00248  */
    00250 const struct ke_msg_handler dbg_default_state[] =
    00251 {
    00252     // Memory Read request
    00253     {DBG_MEM_READ_REQ, (ke_msg_func_t)dbg_mem_read_req_handler},
    00254     // Memory write request
    00255     {DBG_MEM_WRITE_REQ, (ke_msg_func_t)dbg_mem_write_req_handler},
    00256     // Module filter request
    00257     {DBG_SET_MOD_FILTER_REQ, (ke_msg_func_t)dbg_set_mod_filter_req_handler},
    00258     // Severity filter request
    00259     {DBG_SET_SEV_FILTER_REQ, (ke_msg_func_t)dbg_set_sev_filter_req_handler},
    00260     // Get system statistics request
    00261     {DBG_GET_SYS_STAT_REQ, (ke_msg_func_t)dbg_get_sys_stat_req_handler},
    00262     #if NX_SYS_STAT
    00263     // System statistics timer handler
    00264     {DBG_SYS_STAT_TIMER, (ke_msg_func_t)dbg_sys_stat_timer_handler},
    00265     #endif
    00266 };
    00267
    00269 const struct ke_state_handler dbg_default_handler =
    00270     KE_STATE_HANDLER(dbg_default_state);
    00271