ui_defi.h (7878B)
1 /* 2 * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file. 3 * 4 * Copyright 2007-2020 Broadcom Inc. All rights reserved. 5 */ 6 #ifndef UI_DEFI_INCLUDED 7 /* { */ 8 #define UI_DEFI_INCLUDED 9 /* 10 * General include file for reference design. 11 */ 12 #include <appl/diag/dpp/ref_sys.h> 13 #include <soc/dpp/SAND/Utils/sand_framework.h> 14 15 16 /* 17 * General include file for user interface. 18 */ 19 #include <appl/dpp/UserInterface/ui_pure_defi.h> 20 /* 21 * Rom variables. 22 * { 23 */ 24 #ifdef EXTERN 25 #undef EXTERN 26 #endif 27 #define EXTERN extern 28 #ifdef INIT 29 #undef INIT 30 #endif 31 #ifdef CONST 32 #undef CONST 33 #endif 34 #define CONST const 35 #include <appl/dpp/UserInterface/ui_rom_defi.h> 36 /* 37 * } 38 */ 39 #ifdef EXTERN 40 #undef EXTERN 41 #endif 42 #define EXTERN extern 43 /* 44 * Ram variables. 45 * { 46 */ 47 #include <appl/dpp/UserInterface/ui_ram_defi.h> 48 /* 49 * } 50 */ 51 52 #if DUNE_BCM 53 #define _SPRINTF sal_sprintf 54 #else 55 #define _SPRINTF sprintf 56 #endif 57 58 /* 59 * Assuming existence of 'ui_ret' and 'err_msg'. 60 */ 61 #define UI_MACROS_INIT_FUNCTION(FUNCTION_NAME) \ 62 int \ 63 ui_ret = FALSE; \ 64 PARAM_VAL \ 65 *param_val=NULL; \ 66 unsigned long \ 67 error_id = 0; \ 68 char \ 69 err_msg[80*8]; \ 70 const char \ 71 *soc_sand_proc_name = "Need to init 'soc_sand_proc_name' variable", \ 72 *proc_name = FUNCTION_NAME; \ 73 unsigned int \ 74 match_index = 0, \ 75 unit = 0; \ 76 \ 77 if(1) \ 78 { \ 79 _SPRINTF(err_msg, \ 80 "\r\n" \ 81 "*** \'%s\' error \r\n" \ 82 "*** or \'unknown parameter \'.\r\n" \ 83 " Probably SW error\r\n", \ 84 FUNCTION_NAME \ 85 ); /* Removing the unused variable warnings */ \ 86 SOC_SAND_IGNORE_UNUSED_VAR(error_id); \ 87 SOC_SAND_IGNORE_UNUSED_VAR(match_index); \ 88 SOC_SAND_IGNORE_UNUSED_VAR(param_val); \ 89 SOC_SAND_IGNORE_UNUSED_VAR(unit); \ 90 SOC_SAND_IGNORE_UNUSED_VAR(proc_name[0]); \ 91 SOC_SAND_IGNORE_UNUSED_VAR(soc_sand_proc_name[0]); \ 92 SOC_SAND_IGNORE_UNUSED_VAR(err_msg[0]); \ 93 } 94 95 96 97 98 #define UI_MACROS_CHECK_GET_VAL_OF_ERROR \ 99 if (ui_ret) \ 100 { \ 101 soc_sand_os_printf("\n %s.\n SW get error\n",soc_sand_proc_name) ; \ 102 goto exit ; \ 103 } 104 105 106 107 #define UI_MACROS_ERR_UNRECOGNIZED_PARAM(_ui_current_param) \ 108 soc_sand_os_printf( \ 109 "\r\n\n" \ 110 "*** Parameter following \'%s\' is unrecognizable\r\n",#_ui_current_param) ; \ 111 send_string_to_screen(err_msg,TRUE) ; \ 112 ui_ret = TRUE ; \ 113 goto exit ; 114 /* 115 * Assuming one appearance of value. 116 * Assuming existence of 'ui_ret' and 'param_val'. 117 */ 118 #define UI_MACROS_GET_NUMMERIC_VAL(val_id) \ 119 ui_ret = \ 120 get_val_of( \ 121 current_line,(int *)&match_index, \ 122 val_id,1, \ 123 ¶m_val,VAL_NUMERIC,err_msg \ 124 ); 125 126 #define UI_MACROS_GET_NUMMERIC_VAL_WITH_INDEX(val_id, ndx) \ 127 ui_ret = \ 128 get_val_of( \ 129 current_line,(int *)&match_index, \ 130 val_id,ndx, \ 131 ¶m_val,VAL_NUMERIC,err_msg \ 132 ); 133 134 /* 135 * Assuming one appearance of value. 136 * Assuming existence of 'ui_ret' and 'param_val'. 137 */ 138 #define UI_MACROS_GET_SYMBOL_VAL(val_id) \ 139 ui_ret = \ 140 get_val_of( \ 141 current_line,(int *)&match_index, \ 142 val_id,1, \ 143 ¶m_val,VAL_SYMBOL,err_msg \ 144 ); 145 146 147 148 /* 149 * Assuming one appearance of value. 150 * Assuming existence of 'ui_ret' and 'param_val'. 151 */ 152 #define UI_MACROS_GET_NUM_SYM_VAL(val_id) \ 153 ui_ret = \ 154 get_val_of( \ 155 current_line,(int *)&match_index, \ 156 val_id,1, \ 157 ¶m_val,VAL_NUMERIC|VAL_SYMBOL,err_msg \ 158 ); 159 160 #define UI_MACROS_GET_NUM_SYM_VAL_WITH_INDEX(val_id, ndx) \ 161 ui_ret = \ 162 get_val_of( \ 163 current_line,(int *)&match_index, \ 164 val_id, ndx, \ 165 ¶m_val,VAL_NUMERIC|VAL_SYMBOL,err_msg \ 166 ); 167 168 /* 169 * Assuming one appearance of value. 170 * Assuming existence of 'ui_ret' and 'param_val'. 171 */ 172 #define UI_MACROS_GET_TEXT_VAL(val_id) \ 173 ui_ret = \ 174 get_val_of( \ 175 current_line,(int *)&match_index, \ 176 val_id,1, \ 177 ¶m_val,VAL_TEXT,err_msg \ 178 ); 179 180 /* 181 * Assuming one appearance of value. 182 * Assuming existence of 'param_val'. 183 * Handles VAL_NUMERIC/VAL_SYMBOL/VAL_IP 184 */ 185 #define UI_MACROS_LOAD_TEXT_VAL(val)\ 186 if(param_val->val_type == VAL_TEXT)\ 187 {\ 188 val = param_val->value.val_text ;\ 189 } 190 191 /* 192 * Assuming one appearance of value. 193 * Assuming existence of 'param_val'. 194 * Handles VAL_NUMERIC/VAL_SYMBOL/VAL_IP 195 */ 196 #define UI_MACROS_LOAD_LONG_VAL(val)\ 197 if(param_val->val_type == VAL_NUMERIC)\ 198 {\ 199 val = param_val->value.ulong_value ;\ 200 }\ 201 else if(param_val->val_type == VAL_SYMBOL)\ 202 {\ 203 val = param_val->numeric_equivalent ;\ 204 }\ 205 else\ 206 {\ 207 val = param_val->value.ip_value;\ 208 } 209 210 /* 211 * Assuming existence of current_line, match_index 212 */ 213 #define UI_MACROS_MATCH_ID(_ui_val_id) \ 214 !search_param_val_pairs(current_line,&match_index,_ui_val_id,1) 215 216 #define UI_COMP(var_ptr1, var_ptr2, type, count, is_equal_res) \ 217 { \ 218 is_equal_res = SOC_SAND_NUM2BOOL_INVERSE(soc_sand_os_memcmp( \ 219 var_ptr1, \ 220 var_ptr2, \ 221 (count) * sizeof(type) \ 222 )); \ 223 } 224 225 /* } */ 226 #endif