switch(cmd) {
case SWAP_DRIVER_BUFFER_INITIALIZE:
{
+ print_debug("SWAP_DRIVER_BUFFER_INITIALIZE\n");
struct buffer_initialize initialize_struct;
result = copy_from_user(&initialize_struct, (void*)arg,
}
case SWAP_DRIVER_BUFFER_UNINITIALIZE:
{
+ print_debug("SWAP_DRIVER_BUFFER_UNINITIALIZE\n");
result = driver_to_buffer_uninitialize();
if (result < 0)
print_err("Buffer uninitialization failed %d\n"< result);
}
case SWAP_DRIVER_NEXT_BUFFER_TO_READ:
{
+ print_debug("SWAP_DRIVER_NEXT_BUFFER_TO_READ\n");
/* Use this carefully */
result = driver_to_buffer_next_buffer_to_read();
if (result == E_SD_NO_DATA_TO_READ) {
}
case SWAP_DRIVER_FLUSH_BUFFER:
{
+ print_debug("SWAP_DRIVER_FLUSH_BUFFER\n");
result = driver_to_buffer_flush();
break;
}
default:
{
+ print_debug("SWAP_DRIVER_BUFFER MESSAGE\n");
if (msg_handler) {
result = msg_handler((void __user *)arg);
} else {
#include <linux/slab.h>
#include <linux/vmalloc.h>
#include "msg_buf.h"
+#include "parser_defs.h"
int init_mb(struct msg_buf *mb, size_t size)
{
*val = *((u32 *)mb->ptr);
mb->ptr += sizeof(*val);
+ print_parse_debug("u32->%d;%08X\n", *val, *val);
+
return 0;
}
*val = *((u64 *)mb->ptr);
mb->ptr += sizeof(*val);
+ print_parse_debug("u64->%d; 0x%016lX\n", *val, *val);
return 0;
}
memcpy(*str, mb->ptr, len);
mb->ptr += len;
+ print_parse_debug("str->'%s'\n", *str);
return 0;
}
u32 app_type;
char *ta_id, *exec_path;
+ print_parse_debug("app_info:\n");
+
+ print_parse_debug("type:");
ret = get_u32(mb, &app_type);
if (ret) {
print_err("failed to read target application type\n");
return NULL;
}
+ print_parse_debug("id:");
ret = get_string(mb, &ta_id);
if (ret) {
print_err("failed to read target application ID\n");
return NULL;
}
+ print_parse_debug("exec path:");
ret = get_string(mb, &exec_path);
if (ret) {
print_err("failed to read executable path\n");
u64 uf;
u32 stp, dmp;
+ print_parse_debug("conf_data:\n");
+
+ print_parse_debug("features:");
if (get_u64(mb, &uf)) {
print_err("failed to read use_features\n");
return NULL;
}
+ print_parse_debug("sys trace period:");
if (get_u32(mb, &stp)) {
print_err("failed to read sys trace period\n");
return NULL;
}
+ print_parse_debug("data msg period:");
if (get_u32(mb, &dmp)) {
print_err("failed to read data message period\n");
return NULL;
u64 addr;
char *args;
+ print_parse_debug("func addr:");
if (get_u64(mb, &addr)) {
print_err("failed to read data function address\n");
return NULL;
}
+ print_parse_debug("funct args:");
if (get_string(mb, &args)) {
print_err("failed to read data function arguments\n");
return NULL;
char *path;
u32 cnt, j, i = 0;
+ print_parse_debug("bin path:");
if (get_string(mb, &path)) {
print_err("failed to read path of binary\n");
return NULL;
}
+ print_parse_debug("func count:");
if (get_u32(mb, &cnt)) {
print_err("failed to read count of functions\n");
return NULL;
}
for (i = 0; i < cnt; ++i) {
+ print_parse_debug("func #%d:\n", i + 1);
fi = create_func_inst_data(mb);
if (fi == NULL)
goto free_func;
if (app_info == NULL)
return NULL;
+ print_parse_debug("func count:");
if (get_u32(mb, &cnt_func)) {
print_err("failed to read count of functions\n");
goto free_app_info;
}
for (i_func = 0; i_func < cnt_func; ++i_func) {
+ print_parse_debug("func #%d:\n", i_func + 1);
func = create_func_inst_data(mb);
if (func == NULL)
goto free_func;
app_inst->func[i_func] = func;
}
+ print_parse_debug("lib count:");
if (get_u32(mb, &cnt_lib)) {
print_err("failed to read count of libraries\n");
goto free_func;
}
for (i_lib = 0; i_lib < cnt_lib; ++i_lib) {
+ print_parse_debug("lib #%d:\n", i_lib + 1);
lib = create_lib_inst_data(mb);
if (lib == NULL)
goto free_lib;
struct app_inst_data *ai;
u32 cnt, j, i = 0;
+ print_parse_debug("us_inst_data:\n");
+
+ print_parse_debug("app count:");
if (get_u32(mb, &cnt)) {
print_err("failed to read count of applications\n");
return NULL;
}
for (i = 0; i < cnt; ++i) {
+ print_parse_debug("app #%d:\n",i+1);
ai = create_app_inst_data(mb);
if (ai == NULL)
goto free_app_inst;
#include <linux/kernel.h>
+/* #define PARSE_DEBUG */
+
#define print_debug(msg, args...) \
printk(KERN_DEBUG "SWAP_PARSER DEBUG : " msg, ##args)
#define print_msg(msg, args...) \
#define print_crit(msg, args...) \
printk(KERN_CRIT "SWAP_PARSER CRITICAL : " msg, ##args)
+/* debug parse */
+#ifdef PARSE_DEBUG
+#define print_parse_debug(msg, args...) \
+ printk(KERN_DEBUG "SWAP_PARSER DEBUG : " msg, ##args)
+#else
+#define print_parse_debug(msg, args...) \
+ do {} while (0)
+#endif /* PARSE_DEBUG */
+
#endif /* __SWAP_DRIVER_DEVICE_DEFS_H__ */