Commit ad0f0da8 authored by Adam Wujek's avatar Adam Wujek

tools/wrpc-dump: make common a checking the type's size

Signed-off-by: 's avatarAdam Wujek <adam.wujek@creotech.pl>
parent e99b38ff
......@@ -288,7 +288,7 @@ struct dump_info dump_info[] = {
DUMP_FIELD(yes_no_Boolean, received_dresp_fup), /* Count the number of delay response follow up messages received for a given delay request */
DUMP_FIELD(yes_no_Boolean, ptp_support), /* True if allow pure PTP support */
DUMP_FIELD(yes_no_Boolean, bmca_execute), /* True: Ask fsm to run bmca state decision */
DUMP_FIELD(pdstate, pdstate), /* Protocol detection state */
DUMP_FIELD(pp_pdstate, pdstate), /* Protocol detection state */
DUMP_FIELD(int, /* FIXME:pp_exstate_t */ extState), /* Extension state */
......
......@@ -59,7 +59,7 @@ enum dump_type {
dump_type_wr_config_Enumeration8,
dump_type_wr_role,
dump_type_wr_role_Enumeration8,
dump_type_pdstate,
dump_type_pp_pdstate,
};
/* because of the sizeof later on, we need these typedefs */
......@@ -82,7 +82,7 @@ typedef int wr_config;
typedef Enumeration8 wr_config_Enumeration8;
typedef int wr_role;
typedef Enumeration8 wr_role_Enumeration8;
typedef pp_pdstate_t pdstate;
typedef pp_pdstate_t pp_pdstate;
/*
* This is generated with the target compiler, and then linked
......
......@@ -118,6 +118,27 @@ void dump_one_field(void *addr, struct dump_info *info, char *info_prefix)
type = wrpc_get_i32(&info->type);
size = wrpc_get_i32(&info->size);
// printf("%3d|%2d|", wrpc_get_i32(&info->offset), size);
/* For some (mostly enum like types) the size may vary. Check the size
* and assign a proper value to variable i */
switch(type) {
case dump_type_yes_no:
case dump_type_yes_no_Boolean:
case dump_type_ppi_state:
case dump_type_ppi_state_Enumeration8:
case dump_type_wr_config:
case dump_type_wr_config_Enumeration8:
case dump_type_wr_role:
case dump_type_wr_role_Enumeration8:
case dump_type_pp_pdstate:
if (size == 1)
i = *(uint8_t *)p;
else if (size == 2)
i = wrpc_get_16(p);
else
i = wrpc_get_l32(p);
}
/* check the size of Boolean, which is declared as Enum */
if (type == dump_type_Boolean) {
switch(size) {
......@@ -190,15 +211,6 @@ void dump_one_field(void *addr, struct dump_info *info, char *info_prefix)
break;
case dump_type_yes_no:
case dump_type_yes_no_Boolean:
/* check the size of type, e.g. Boolean is not 8 bits! */
if (size == 1)
i = *(uint8_t *)p;
else if (size == 2)
i = wrpc_get_16(p);
else
i = wrpc_get_l32(p);
printf("%d", i);
if (i == 0)
print_str("no");
......@@ -327,14 +339,6 @@ void dump_one_field(void *addr, struct dump_info *info, char *info_prefix)
case dump_type_ppi_state:
case dump_type_ppi_state_Enumeration8:
/* check the size of type, e.g. Boolean is not 8 bits! */
if (size == 1)
i = *(uint8_t *)p;
else if (size == 2)
i = wrpc_get_16(p);
else
i = wrpc_get_l32(p);
switch(i) {
ENUM_TO_P_IN_CASE(PPS_END_OF_TABLE, char_p);
ENUM_TO_P_IN_CASE(PPS_INITIALIZING, char_p);
......@@ -356,14 +360,6 @@ void dump_one_field(void *addr, struct dump_info *info, char *info_prefix)
case dump_type_wr_config:
case dump_type_wr_config_Enumeration8:
/* check the size of type, e.g. Boolean is not 8 bits! */
if (size == 1)
i = *(uint8_t *)p;
else if (size == 2)
i = wrpc_get_16(p);
else
i = wrpc_get_l32(p);
switch(i) {
ENUM_TO_P_IN_CASE(NON_WR, char_p);
ENUM_TO_P_IN_CASE(WR_M_ONLY, char_p);
......@@ -380,14 +376,6 @@ void dump_one_field(void *addr, struct dump_info *info, char *info_prefix)
case dump_type_wr_role:
case dump_type_wr_role_Enumeration8:
/* check the size of type, e.g. Boolean is not 8 bits! */
if (size == 1)
i = *(uint8_t *)p;
else if (size == 2)
i = wrpc_get_16(p);
else
i = wrpc_get_l32(p);
switch(i) {
ENUM_TO_P_IN_CASE(WR_ROLE_NONE, char_p);
ENUM_TO_P_IN_CASE(WR_MASTER, char_p);
......@@ -400,15 +388,7 @@ void dump_one_field(void *addr, struct dump_info *info, char *info_prefix)
printf("\n");
break;
case dump_type_pdstate:
/* check the size of type, e.g. Boolean is not 8 bits! */
if (size == 1)
i = *(uint8_t *)p;
else if (size == 2)
i = wrpc_get_16(p);
else
i = wrpc_get_l32(p);
case dump_type_pp_pdstate:
switch(i) {
ENUM_TO_P_IN_CASE(PP_PDSTATE_NONE, char_p);
ENUM_TO_P_IN_CASE(PP_PDSTATE_WAIT_MSG, char_p);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment