utils_defx.h (42019B)
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 UTILS_DEFX_INCLUDED 7 /* { */ 8 #define UTILS_DEFX_INCLUDED 9 10 #ifdef __cplusplus 11 extern "C" { 12 #endif 13 14 #include <soc/drv.h> 15 #include "ref_sys.h" 16 #include "bits_bytes_macros.h" 17 #include "dune_chips.h" 18 19 #if !DUNE_BCM 20 /* 21 * Dune chips include file. 22 */ 23 24 #include "Pub/include/ref_sys.h" 25 #include "Pub/include/bits_bytes_macros.h" 26 27 #if (defined(LINUX) || defined(UNIX)) 28 /* { */ 29 #include <sys/time.h> 30 #include <sys/socket.h> 31 #include <sys/types.h> 32 #include <sys/signal.h> 33 #include <signal.h> 34 #include <unistd.h> 35 #elif !defined(WIN32) 36 /* { */ 37 #include <sys/time.h> 38 #include <sys/socket.h> 39 #include <sys/types.h> 40 #include <sys/signal.h> 41 #include <signal.h> 42 /* } */ 43 #endif 44 45 #include <time.h> 46 47 #include "stdio.h" 48 #include "string.h" 49 50 #if !(defined(LINUX) || defined(UNIX)) 51 /* { */ 52 #include "DuneDriver/SOC_SAND_FAP10M/include/fap10m_chip_defines.h" 53 #include "../../../../H/drv/mem/eeprom.h" 54 #include "../../../../H/DuneTypeDef.h" 55 /*} LINUX */ 56 #endif 57 58 #include "Pub/include/dune_chips.h" 59 60 typedef void* ESFPPC; 61 typedef char * caddr_t; 62 63 #ifdef WIN32 64 /* { */ 65 typedef void* WIND_TCB; 66 typedef int (*FUNCPTR) (); 67 typedef void* SEM_ID; 68 typedef int timer_t; 69 /*}*/ 70 #elif defined (__DUNE_HRP__) 71 /* { */ 72 #include "DHRP/include/dhrp_defs.h" 73 /* } */ 74 #elif (defined(LINUX) || defined(UNIX)) 75 typedef int (*FUNCPTR) (); 76 typedef void* SEM_ID; 77 /* !DUNE_BCM changed all BOOL to uint8 typedef int BOOL; */ 78 #endif 79 80 #if !(defined(LINUX) || defined(UNIX)) 81 #define D_TICKS_PER_SEC sysClkRateGet() 82 #else 83 #define D_TICKS_PER_SEC sysconf(_SC_CLK_TCK) 84 #endif 85 86 87 #else /* !DUNE_BCM */ 88 89 #define B_BIT(x) (1<<(x)) 90 #define MAC_ADRS_LEN 6 91 #define __ATTRIBUTE_PACKED__ __attribute__ ((packed)) 92 93 #define FLASH_WIDTH 2 94 95 #define IMPORT 96 #define ERROR TRUE 97 #define WAIT_FOREVER -1 98 typedef void* SEM_ID; 99 100 #if (defined(LINUX) || defined(UNIX)) || defined(__DUNE_GTO_BCM_CPU__) 101 #define OK 0 102 #define bcopyBytes sal_memcpy 103 typedef unsigned char UINT8; 104 typedef int STATUS; 105 typedef void (*FUNCPTR_BCM) (void*); 106 typedef int (*FUNCPTR) (void); 107 #define FLASH_WIDTH 2 108 #define FLASH_DEF unsigned short 109 #define FLASH_CAST (unsigned short *) 110 /* from eeprom.h */ 111 #define NV_RAM_SIZE (16 * 1024) 112 #include "utils_eeprom.h" 113 #include "time.h" 114 115 int 116 host_board_cat_number_from_nv( 117 char *board_serial_num_ptr 118 ) ; 119 int 120 host_board_description_from_nv( 121 char *board_description_ptr 122 ) ; 123 int 124 host_board_version_from_nv( 125 char *board_version_ptr 126 ) ; 127 int 128 host_board_sn_from_nv( 129 unsigned short *board_sn_ptr 130 ) ; 131 int 132 front_does_card_exist( 133 void 134 ) ; 135 int 136 front_board_sn_from_nv( 137 unsigned short *board_sn_ptr 138 ) ; 139 unsigned short 140 crc16_with_ini( 141 void *buff, 142 unsigned long size, 143 unsigned short init_crc 144 ); 145 146 #if !defined (SAND_LOW_LEVEL_SIMULATION) 147 #define FLASH_DEF_INF_V1 1 148 #endif 149 150 typedef struct 151 { 152 153 unsigned char struct_version; 154 unsigned long f_adrs; /*Base address of FLASH*/ 155 unsigned char f_adrs_jump; /*E.g. FLASH is 16 bits.*/ 156 unsigned char f_type; /*FLASH type. Supported: FLASH_28F640, FLASH_28F320*/ 157 unsigned long f_sector_size; /*Sector Byte size*/ 158 } FLASH_DEF_INF; 159 160 /* from usrApp.h */ 161 #define BT_FS_VERSION_0 0 162 #define BT_FS_VERSION_1 1 163 #define FRONT_PANEL_YELLOW_LED (1) 164 165 unsigned 166 char 167 get_slot_id( 168 void 169 ) ; 170 unsigned 171 char 172 read_epld_reg( 173 unsigned int offset 174 ) ; 175 void 176 write_epld_reg( 177 unsigned char byte_value, 178 unsigned int offset 179 ); 180 unsigned 181 char 182 get_epld_board_id( 183 void 184 ) ; 185 unsigned 186 char 187 get_crate_id( 188 void 189 ) ; 190 unsigned 191 char 192 get_crate_type( 193 void 194 ) ; 195 char 196 *get_crate_type_text( 197 unsigned int crate_type 198 ) ; 199 void 200 lock_flash( 201 void 202 ); 203 void 204 unlock_flash( 205 void 206 ); 207 unsigned 208 int 209 get_flash_device_code( 210 void 211 ) ; 212 unsigned 213 long 214 get_flash_sector_size( 215 void 216 ); 217 unsigned int 218 boot_get_fs_version(void); 219 void 220 private_delay( 221 unsigned long delay_count 222 ); 223 int 224 load_indication_run_silent( 225 unsigned long current_work_load 226 ); 227 228 STATUS 229 sysFlashGet_protected_info( 230 const FLASH_DEF_INF *flash_info, /*Flash information*/ 231 char *string, /* where to copy flash memory */ 232 int strLen, /* maximum number of bytes to copy */ 233 int offset /* byte offset into flash memory */ 234 ); 235 STATUS 236 sysFlashErase_protected_info( 237 const FLASH_DEF_INF *flash_info, /*Flash information*/ 238 int do_poll_indication, /* Flag. Non-Zero print progress indication*/ 239 /* in percentage. */ 240 int sector /* Number of sector to erase (starting from*/ 241 /* zero. If negative then erase the whole */ 242 /* memory space. If number of sector is */ 243 /* larger than the maximal for that flash */ 244 /* type, last sector is erased. */ 245 ); 246 STATUS 247 sysFlashWrite_protected_info( 248 const FLASH_DEF_INF *flash_info, /*Flash information*/ 249 FLASH_DEF *pFB, /* string to be copied; use <value> if NULL */ 250 int size, /* size to program in bytes */ 251 int offset, /* byte offset into flash memory */ 252 FLASH_DEF value, /* value to program */ 253 int (*poll_indication_func)(unsigned long current_work_load) /* Function to call when polling the Flash.*/ 254 /* If NULL then call no function. */ 255 ); 256 257 #endif /* (defined(LINUX) || defined(UNIX)) || defined(__DUNE_GTO_BCM_CPU__) */ 258 259 260 STATUS 261 d_taskLock( 262 void 263 ) ; 264 STATUS 265 d_taskUnlock( 266 void 267 ) ; 268 STATUS 269 d_taskDelete( 270 sal_thread_t tid /* task ID of task to delete */ 271 ) ; 272 STATUS 273 d_taskSafe( 274 void 275 ) ; 276 STATUS 277 d_taskUnsafe( 278 void 279 ) ; 280 int 281 d_is_task_safe( 282 void 283 ) ; 284 void 285 d_force_task_unsafe( 286 int task_id 287 ) ; 288 sal_thread_t 289 d_taskSpawn( 290 char *name, /* name of new task (stored at pStackBase) */ 291 int priority, /* priority of new task */ 292 int options, /* task option word */ 293 int stackSize, /* size (bytes) of stack needed plus name */ 294 FUNCPTR_BCM entryPt, /* entry point of new task */ 295 int arg1, /* 1st of 10 req'd task args to pass to func */ 296 int arg2, 297 int arg3, 298 int arg4, 299 int arg5, 300 int arg6, 301 int arg7, 302 int arg8, 303 int arg9, 304 int arg10, 305 int private_task_id 306 ) ; 307 STATUS 308 d_taskDelay( 309 int ticks 310 ) ; 311 STATUS 312 d_taskDelayMicroSec( 313 const long int delay_in_microsec 314 ) ; 315 int 316 d_strnicmp( 317 const char *str1, 318 const char *str2, 319 size_t n 320 ); 321 int 322 d_write( 323 int fd, /* file descriptor on which to write */ 324 char *buffer, /* buffer containing bytes to be written */ 325 int nbytes, /* number of bytes to write */ 326 int std_out_target 327 ) ; 328 int 329 d_ioGlobalStdGet( 330 int stdFd /* std input (0), output (1), or error (2) */ 331 ) ; 332 void 333 d_ioGlobalStdSet( 334 int stdFd, /* std input (0), output (1), or error (2) */ 335 int newFd /* new underlying file descriptor */ 336 ) ; 337 void 338 d_ioTaskStdSet( 339 int taskId, /* task whose std fd is to be set (0 = self) */ 340 int stdFd, /* std input (0), output (1), or error (2) */ 341 int newFd /* new underlying file descriptor */ 342 ) ; 343 int 344 d_ioctl( 345 int fd, /* file descriptor */ 346 int function, /* function code */ 347 int arg /* arbitrary argument */ 348 ) ; 349 int 350 d_timer_create( 351 clockid_t clock_id, /* clock ID (always CLOCK_REALTIME) */ 352 struct sigevent *evp, /* user event handler */ 353 timer_t *pTimer /* ptr to return value */ 354 ) ; 355 int 356 d_restart_shell( 357 void 358 ) ; 359 360 361 /* debug Dune integration */ 362 #define D_TO_STR(x) #x 363 364 #define FLASH_28F320_SECTOR 0x20000 365 366 #define FLASH1_MEM_BASE_ADRS_8MEG 0xFF800000 367 #define FLASH1_MEM_BASE_ADRS_4MEG 0xFFC00000 368 #define BOOT_FLASH_BASE_ADRS 0xFFF00000 369 370 #define FLASH1_MEM_SIZE_4MEG 0x00400000 371 #define FLASH_SIZE_4MEG FLASH1_MEM_SIZE_4MEG 372 373 #define FLASH1_MEM_SIZE_8MEG 0x00800000 374 #define FLASH_SIZE_8MEG FLASH1_MEM_SIZE_8MEG 375 376 #include <bcm/types.h> 377 typedef void* ESFPPC; 378 379 #ifndef __KERNEL__ 380 extern STATUS sysNvRamGet (); 381 extern STATUS sysNvRamSet (); 382 #endif 383 384 #if !defined(__DUNE_GTO_BCM_CPU__) 385 #define SEM_FULL 0x01 386 #define SEM_Q_PRIORITY 0x01 387 #define SEM_DELETE_SAFE 0x04 388 #define SEM_INVERSION_SAFE 0x08 389 #endif 390 391 extern SEM_ID semMCreate( int opt ); 392 393 extern 394 sal_mutex_t 395 I2c_bus_semaphore; 396 397 void 398 i2c_start( 399 void 400 ) ; 401 int 402 i2c_poll_tx( 403 unsigned int *err_flg, 404 char *err_msg 405 ) ; 406 int 407 i2c_load_buffer( 408 unsigned char dest_address, 409 unsigned short i2c_data_len, 410 unsigned char *i2c_data, 411 unsigned int *err_flg, 412 char *err_msg 413 ) ; 414 int 415 i2c_get_buffer( 416 unsigned short *i2c_data_len, 417 unsigned char *i2c_data, 418 unsigned int *err_flg, 419 char *err_msg 420 ) ; 421 422 int 423 take_flash_sem( 424 void 425 ); 426 int 427 give_back_flash_sem( 428 void 429 ); 430 431 void load_indication_start(unsigned long total_work_load); 432 int load_indication_run(unsigned long current_work_load); 433 434 int get_prog_ver(void); 435 436 437 int 438 ee_offset_to_block_id( 439 unsigned int offset, 440 unsigned int size, 441 unsigned int *block_id 442 ) ; 443 int 444 check_block_crc( 445 unsigned int block_id 446 ) ; 447 int 448 update_block_crc( 449 unsigned int block_id 450 ) ; 451 int 452 get_defaults( 453 char *string, 454 int strLen, 455 int offset 456 ) ; 457 int 458 load_defaults( 459 unsigned int block_id 460 ) ; 461 462 int 463 get_run_vals( 464 char *string, 465 int strLen, 466 int offset 467 ) ; 468 469 /* MEMC registers */ 470 #define BR4(base) (CAST(VUINT32 *)((base) + 0x0120)) /* Base Reg bank 4 */ 471 #define OR4(base) (CAST(VUINT32 *)((base) + 0x0124)) /* Opt Reg bank 4*/ 472 #define BR5(base) (CAST(VUINT32 *)((base) + 0x0128)) /* Base Reg bank 5 */ 473 #define OR5(base) (CAST(VUINT32 *)((base) + 0x012C)) /* Opt Reg bank 5*/ 474 475 /* Device Version managment { */ 476 #define SOC_PETRA_REVISION_FLD_VAL_A0 0x0 477 #define SOC_PETRA_REVISION_FLD_VAL_A1 0x10 478 #define SOC_PETRA_REVISION_FLD_VAL_A2 0x30 479 #define SOC_PETRA_REVISION_FLD_VAL_A3 0x32 480 #define SOC_PETRA_REVISION_FLD_VAL_A4 0x832 481 482 typedef enum 483 { 484 D_SOFT_REBOOT = 0, 485 D_HARD_REBOOT = 1 486 } D_REBOOT_TYPE; 487 488 #endif /* !DUNE_BCM */ 489 490 /**************************************************************************/ 491 /* When the Utils module run as stand alone, some Negev/GFA/BSP dedicated */ 492 /* Macro definition are missing. */ 493 /* Bellow are the definitions of those MACROS. */ 494 /* The values should be the same values, as in the Negev/GFA/BSP system */ 495 /**************************************************************************/ 496 #ifndef B_HOST_MAX_DEFAULT_BOARD_VERSION_LEN 497 #define B_HOST_MAX_DEFAULT_BOARD_VERSION_LEN 7 498 #endif 499 500 #ifndef B_HOST_MAX_PARAM_LEN 501 #define B_HOST_MAX_PARAM_LEN 20 502 #endif 503 504 /* 505 * PROTOTYPES 506 * { 507 */ 508 /* 509 * Procedures related to DUNE chip set 510 * { 511 */ 512 #if (SIMULATE_DUNE_CHIP || SIMULATE_CHIP_SIM) 513 /* { */ 514 void 515 inc_control_cells_cntr_1( 516 unsigned long val_to_add 517 ) ; 518 void 519 inc_control_cells_cntr_2( 520 unsigned long val_to_add 521 ) ; 522 /* } */ 523 #endif 524 525 /* 526 * MACROS 527 */ 528 #define UTILS_DEFX_DEBUG 1 529 530 #if UTILS_DEFX_DEBUG 531 #define UTILS_DEFX_DBG_ID "**DEBUG--> " 532 #define UTILS_DEFX_DBG \ 533 { \ 534 soc_sand_os_printf("\n%sFile : %s \n%sFunction: %s line %u\n", UTILS_DEFX_DBG_ID, __FILE__, UTILS_DEFX_DBG_ID, FUNCTION_NAME(), __LINE__);\ 535 } 536 #else 537 #define UTILS_DEFX_DBG 538 #endif 539 540 #define UTILS_STRCAT_SAFE(param_dst,param_src,param_dst_size) \ 541 if ((strlen(param_dst) + strlen(param_src))>= (param_dst_size)) \ 542 { \ 543 soc_sand_os_printf( \ 544 "******************************************************* \n\r" \ 545 " Error: Concatenation overflow the Destination buffer. \n\r" \ 546 " Stopping before parameter %s ...\n\r" \ 547 "******************************************************* \n\r", param_src); \ 548 UTILS_DEFX_DBG; \ 549 goto exit; \ 550 } \ 551 else strcat(param_dst, param_src); 552 553 554 void 555 set_pointed_fe_default( 556 void 557 ) ; 558 void 559 set_pointed_fe( 560 unsigned int val 561 ) ; 562 unsigned int 563 get_pointed_fe( 564 void 565 ) ; 566 void 567 set_desc_fe_reg_size( 568 unsigned int size 569 ) ; 570 unsigned 571 int 572 get_desc_fe_reg_size( 573 void 574 ) ; 575 int 576 write_to_fe( 577 unsigned long *array, 578 unsigned long offset, 579 unsigned long size 580 ); 581 int 582 read_from_fe( 583 unsigned long *array, 584 unsigned long offset, 585 unsigned long size 586 ); 587 int 588 should_update_conf_from_nvram( 589 void 590 ); 591 unsigned 592 long 593 get_conf_from_nvram( 594 void 595 ); 596 597 /* 598 * } 599 */ 600 void 601 appLedBarInvert( 602 unsigned char value, 603 unsigned char action 604 ); 605 void 606 appLedBarOff( 607 unsigned char value, 608 unsigned char action 609 ); 610 void 611 appLedBarOn( 612 unsigned char value, 613 unsigned char action 614 ); 615 int 616 utils_led_start_blink_led( 617 unsigned int led_color, 618 unsigned int nof_delay_ticks 619 ); 620 void 621 utils_led_stop_blink_led( 622 unsigned int led_color, 623 unsigned int keep_it_on 624 ); 625 626 627 /* 628 * Object: Semaphore protecting 'screen' operations 629 * (specifically 'send_XXX_to_screen()) 630 * 631 * { 632 */ 633 int 634 create_screen_semaphore( 635 void 636 ) ; 637 int 638 is_screen_semaphore_owned_by_this_task( 639 void 640 ) ; 641 int 642 give_screen_semaphore( 643 void 644 ); 645 int 646 take_screen_semaphore( 647 void 648 ) ; 649 int 650 release_print_safe( 651 int *safe_count, 652 int *print_sem_count 653 ) ; 654 int 655 restore_print_safe( 656 int safe_count, 657 int print_sem_count 658 ) ; 659 void 660 start_print_services( 661 void 662 ) ; 663 void 664 end_print_services( 665 void 666 ) ; 667 /* 668 * } 669 */ 670 /* 671 * OBJECT: 672 * Periodic display 673 * Handling of periodic display 674 * (continuous, repetitive, on the same line). 675 * { 676 */ 677 void 678 set_display_periodic_off( 679 void 680 ) ; 681 int 682 is_display_periodic_on( 683 void 684 ) ; 685 int 686 is_periodic_on( 687 void 688 ) ; 689 void 690 set_periodic_on( 691 void 692 ) ; 693 void 694 set_periodic_off( 695 void 696 ) ; 697 void 698 elapse_periodic( 699 void 700 ) ; 701 /* 702 * } 703 */ 704 705 typedef enum 706 { 707 PERIODIC_WAIT_AND_PRINT_STYLE_NOT_VALID = 0, 708 709 /* 710 * Currently only one style 711 */ 712 PERIODIC_WAIT_AND_PRINT_STYLE_DEFAULT 713 714 } PERIODIC_WAIT_AND_PRINT_STYLE; 715 716 717 void 718 periodic_wait_and_print( 719 const unsigned long nof_secs, 720 const unsigned int print_style 721 ); 722 723 int 724 clock_step_passed( 725 bcm_time_spec_t *reference_time, 726 bcm_time_spec_t *step_time, 727 bcm_time_spec_t *current_time 728 ) ; 729 int 730 clock_from_startup( 731 unsigned long *time_from_startup, 732 unsigned int use_10_ms 733 ) ; 734 int 735 clock_get_diff( 736 bcm_time_spec_t *reference_time, 737 bcm_time_spec_t *diff_time, 738 bcm_time_spec_t *input_time 739 ) ; 740 void 741 ms_to_timespec( 742 bcm_time_spec_t *timespec_struct, 743 unsigned long input_ms 744 ) ; 745 void 746 timespec_to_ms( 747 unsigned long *ms, 748 bcm_time_spec_t *input_timespec_struct 749 ); 750 #if !DUNE_BCM 751 void 752 ms_to_timeval( 753 struct timeval *timeval_struct, 754 unsigned long input_ms 755 ); 756 void 757 timeval_to_ms( 758 unsigned long *ms, 759 struct timeval *input_timeval_struct 760 ); 761 #endif 762 void 763 ms_to_ticks( 764 unsigned long *ticks, 765 unsigned long input_ms 766 ); 767 768 void 769 ticks_to_ms( 770 unsigned long *ms, 771 unsigned long input_ticks 772 ); 773 774 #if (defined(LINUX) || defined(UNIX)) || defined(__DUNE_GTO_BCM_CPU__) 775 /* { */ 776 int 777 set_watchdog_inject_time( 778 void 779 ); 780 781 unsigned 782 long 783 get_watchdog_time( 784 unsigned int use_10_ms 785 ); 786 /* } */ 787 #endif 788 789 /* 790 * OBJECT: 791 * Real Time Trace Utility 792 * { 793 */ 794 void 795 init_trace_fifo( 796 void 797 ) ; 798 void 799 put_in_trace_fifo( 800 int trace_event_id, 801 unsigned int trace_event_text_size, 802 char *trace_event_text, 803 unsigned long trace_param_1, 804 unsigned long trace_param_2, 805 unsigned long trace_param_3, 806 unsigned long trace_param_4 807 ) ; 808 int 809 get_next_from_trace_fifo( 810 int *trace_event_id_ptr, 811 unsigned long *trace_event_time_ptr, 812 char *trace_event_text_ptr, 813 unsigned long *trace_params_ptr 814 ) ; 815 int 816 get_direct_from_trace_fifo( 817 unsigned int trace_event_index, 818 int *trace_event_id_ptr, 819 unsigned long *trace_event_time_ptr, 820 char *trace_event_text_ptr, 821 unsigned long *trace_params_ptr 822 ) ; 823 int 824 is_trace_fifo_locked( 825 void 826 ) ; 827 unsigned 828 int 829 get_num_elements_trace_fifo( 830 void 831 ) ; 832 unsigned 833 int 834 get_clear_load_while_locked_trace_fifo( 835 void 836 ) ; 837 void 838 lock_trace_fifo( 839 void 840 ) ; 841 void 842 unlock_trace_fifo( 843 void 844 ) ; 845 /* 846 * } 847 */ 848 /* 849 * OBJECT: 850 * In ISR 851 * Utilities related to status of processor: 852 * Is it within an ISR or not. 853 * If 'In_isr' is 'true' then system is within 854 * ISR and some operating system calls may not 855 * be called and, if they do, will do nothing. 856 * { 857 */ 858 void 859 set_in_isr( 860 unsigned int in_isr 861 ) ; 862 int 863 is_in_isr( 864 void 865 ) ; 866 /* 867 * } 868 */ 869 /* 870 * OBJECT: 871 * Event log utilities 872 * Utilities related to handling of event 873 * log in NVRAM. 874 * { 875 */ 876 int 877 display_event_log_block( 878 void 879 ) ; 880 /* 881 * } 882 */ 883 /* 884 * OBJECT: 885 * NMI utilities 886 * Utilities related to handling of NMI/IRQ0 887 * which is triggered by the watchdog timer. 888 * { 889 */ 890 int 891 do_watchdog_reset( 892 void 893 ) ; 894 void 895 load_do_watchdog_reset( 896 unsigned int val 897 ) ; 898 int 899 display_watchdog_block( 900 unsigned int check_new_n_valid, 901 unsigned int clear_new_n_valid, 902 unsigned int store_in_nvlog 903 ) ; 904 void 905 watchdog_handler( 906 ESFPPC *pEsf 907 ) ; 908 /* 909 * } 910 */ 911 /* 912 * OBJECT: 913 * Utilities related to handling 914 * Software Emulation Exception. 915 * { 916 */ 917 int 918 display_software_exception_block( 919 unsigned int check_new_n_valid, 920 unsigned int clear_new_n_valid, 921 unsigned int store_in_nvlog 922 ) ; 923 void 924 soft_emu_exp_handler( 925 ESFPPC *pEsf 926 ) ; 927 void 928 alignment_exception_handler( 929 ESFPPC *pEsf 930 ) ; 931 void 932 data_tlb_error_handler( 933 ESFPPC *pEsf 934 ) ; 935 void 936 inst_tlb_error_handler( 937 ESFPPC *pEsf 938 ) ; 939 void 940 set_software_emulation_exp_testing( 941 const int x 942 ) ; 943 /* 944 * } 945 */ 946 947 /* 948 * Temperature structures 949 */ 950 typedef struct{ 951 int temperature_integral; 952 /*0-10000*/ 953 int temperature_frac; 954 /* 955 * time from reset. 956 * 10_msec resolution. 957 */ 958 unsigned long time_stamp; 959 }TEMPERATURE_INFO; 960 961 typedef struct{ 962 TEMPERATURE_INFO current; 963 TEMPERATURE_INFO max_from_reset; 964 TEMPERATURE_INFO clearable_max; 965 }TEMPERATURE_STATUS; 966 967 968 /* 969 * Procedures related to Temperature object 970 * { 971 */ 972 void 973 set_last_thermo_reading( 974 unsigned int index, 975 char *temperature 976 ) ; 977 TEMPERATURE_STATUS * 978 get_thermo_reading( 979 unsigned int index 980 ); 981 void 982 clear_clearable_max_temperature( 983 unsigned int index 984 ); 985 986 int 987 is_temperature_valid( 988 void 989 ) ; 990 void 991 set_temperature_invalid( 992 void 993 ) ; 994 void 995 set_temperature_valid( 996 void 997 ); 998 /* 999 * } 1000 */ 1001 /* 1002 * Procedures related to Thermometer reading: DS1721 1003 * { 1004 */ 1005 int 1006 init_thermometer( 1007 void 1008 ) ; 1009 int 1010 collect_temperature( 1011 char *temperature, 1012 unsigned char read_addr, 1013 unsigned char write_addr 1014 ) ; 1015 int 1016 collect_all_temperatures( 1017 void 1018 ); 1019 /* 1020 * } 1021 */ 1022 /* 1023 * Object: Task IDs. 1024 * { 1025 */ 1026 void 1027 init_task_id( 1028 void 1029 ) ; 1030 void 1031 set_task_id( 1032 int task_private_index, 1033 int tid 1034 ) ; 1035 void 1036 clear_task_id( 1037 int task_private_index 1038 ) ; 1039 int 1040 is_task_alive( 1041 int task_private_index 1042 ) ; 1043 int 1044 get_task_id( 1045 int task_private_index 1046 ) ; 1047 int 1048 get_private_task_id( 1049 int task_id 1050 ) ; 1051 /* 1052 * End object 1053 * } 1054 */ 1055 /* 1056 * Object: Private shell file descriptor (via "/pipe/shell"). 1057 * { 1058 */ 1059 void 1060 set_shell_file_descriptor( 1061 int fd 1062 ) ; 1063 int 1064 get_shell_file_descriptor( 1065 void 1066 ) ; 1067 /* 1068 * End object 1069 * } 1070 */ 1071 /* 1072 * Object: Private user interface file descriptor 1073 * (related to the pipe: "/pipe/userIf"). 1074 * { 1075 */ 1076 void 1077 set_user_if_file_descriptor( 1078 int fd 1079 ) ; 1080 int 1081 get_user_if_file_descriptor( 1082 void 1083 ) ; 1084 /* 1085 * End object 1086 * } 1087 */ 1088 /* 1089 * Object: Startup IO file descriptor 1090 * 1091 * This is the file descriptor of the standard IO 1092 * with which the system gets started. 1093 * { 1094 */ 1095 void 1096 set_startup_io_file_descriptor( 1097 int fd 1098 ) ; 1099 int 1100 get_startup_io_file_descriptor( 1101 void 1102 ) ; 1103 /* 1104 * End object 1105 * } 1106 */ 1107 /* 1108 * OBJECT: 1109 * Current_ui_fd 1110 * File descriptor for standard IO which is currently 1111 * used in user interface task. 1112 * Monitored routinely to make sure it is up to date. 1113 * (It is changed by telnet) 1114 * { 1115 */ 1116 void 1117 set_current_ui_fd( 1118 int fd 1119 ) ; 1120 int 1121 get_current_ui_fd( 1122 void 1123 ) ; 1124 /* 1125 * } 1126 */ 1127 /* 1128 * Object: Block STD IO. 1129 * { 1130 */ 1131 int 1132 is_std_io_blocked( 1133 void 1134 ) ; 1135 void 1136 set_std_io_blocked( 1137 int val 1138 ) ; 1139 /* 1140 * End object 1141 * } 1142 */ 1143 /* { */ 1144 /* 1145 * OBJECT: 1146 * Ui_timer_id 1147 * Timer activated routinely from user if task 1148 * to make sure it is pending on the right standard 1149 * file descriptor. 1150 * { 1151 */ 1152 #if !DUNE_BCM 1153 void 1154 set_ui_timer_id( 1155 timer_t id 1156 ) ; 1157 timer_t 1158 get_ui_timer_id( 1159 void 1160 ) ; 1161 #endif 1162 /* 1163 * } 1164 */ 1165 int 1166 d_printf( 1167 const char *fmt, 1168 ... 1169 ); 1170 int 1171 task_create_proc( 1172 void 1173 ) ; 1174 1175 #if !DUNE_BCM 1176 1177 int 1178 d_write( 1179 int fd, /* file descriptor on which to write */ 1180 char *buffer, /* buffer containing bytes to be written */ 1181 int nbytes, /* number of bytes to write */ 1182 int std_out_target 1183 ) ; 1184 int 1185 d_read( 1186 int fd, 1187 char *buffer, 1188 size_t maxbytes 1189 ) ; 1190 int 1191 d_open( 1192 const char *name, 1193 int flags, 1194 int mode 1195 ) ; 1196 int 1197 d_ioGlobalStdGet( 1198 int stdFd /* std input (0), output (1), or error (2) */ 1199 ) ; 1200 void 1201 d_ioGlobalStdSet( 1202 int stdFd, /* std input (0), output (1), or error (2) */ 1203 int newFd /* new underlying file descriptor */ 1204 ) ; 1205 void 1206 d_ioTaskStdSet( 1207 int taskId, /* task whose std fd is to be set (0 = self) */ 1208 int stdFd, /* std input (0), output (1), or error (2) */ 1209 int newFd /* new underlying file descriptor */ 1210 ) ; 1211 int 1212 d_ioctl( 1213 int fd, /* file descriptor */ 1214 int function, /* function code */ 1215 int arg /* arbitrary argument */ 1216 ) ; 1217 /* 1218 */ 1219 typedef enum 1220 { 1221 D_SOFT_REBOOT = 0, 1222 D_HARD_REBOOT = 1 1223 } D_REBOOT_TYPE; 1224 void 1225 d_reboot( 1226 D_REBOOT_TYPE reboot_type, 1227 int start_type /* If D_SOFT_REBOOT than how the boot ROMS will reboot */ 1228 ) ; 1229 int 1230 d_restart_shell( 1231 void 1232 ) ; 1233 STATUS 1234 d_taskDelete( 1235 sal_thread_t tid /* task ID of task to delete */ 1236 ) ; 1237 sal_thread_t 1238 d_taskSpawn( 1239 char *name, /* name of new task (stored at pStackBase) */ 1240 int priority, /* priority of new task */ 1241 int options, /* task option word */ 1242 int stackSize, /* size (bytes) of stack needed plus name */ 1243 FUNCPTR entryPt, /* entry point of new task */ 1244 int arg1, /* 1st of 10 req'd task args to pass to func */ 1245 int arg2, 1246 int arg3, 1247 int arg4, 1248 int arg5, 1249 int arg6, 1250 int arg7, 1251 int arg8, 1252 int arg9, 1253 int arg10, 1254 int private_task_id 1255 ) ; 1256 void 1257 d_force_task_unsafe( 1258 int task_id 1259 ) ; 1260 int 1261 d_is_task_safe( 1262 void 1263 ) ; 1264 int 1265 d_is_this_task_owner_of_sem( 1266 SEM_ID semaphore 1267 ) ; 1268 STATUS 1269 d_taskSafe( 1270 void 1271 ) ; 1272 STATUS 1273 d_taskUnsafe( 1274 void 1275 ) ; 1276 int 1277 d_intLock( 1278 void 1279 ) ; 1280 void 1281 d_intUnlock( 1282 int lockKey 1283 ) ; 1284 BOOL 1285 utils_d_is_interrupt_enable( 1286 void 1287 ); 1288 STATUS 1289 d_taskDelay( 1290 int ticks 1291 ) ; 1292 STATUS 1293 d_taskDelaySec( 1294 const long int delay_in_sec 1295 ) ; 1296 STATUS 1297 d_taskDelayMicroSec( 1298 const long int delay_in_microsec 1299 ) ; 1300 int 1301 d_clock_gettime( 1302 clockid_t clock_id, /* clock ID (always CLOCK_REALTIME) */ 1303 bcm_time_spec_t *tp /* where to store current time */ 1304 ) ; 1305 int 1306 d_clock( 1307 void 1308 ) ; 1309 unsigned 1310 long 1311 d_tickGet( 1312 void 1313 ) ; 1314 int 1315 d_taskIdSelf( 1316 void 1317 ) ; 1318 1319 char 1320 *d_taskName( 1321 sal_thread_t tid /* task ID of task to delete */ 1322 ) ; 1323 STATUS 1324 d_taskRestart( 1325 sal_thread_t tid /* task ID of task to restart */ 1326 ) ; 1327 STATUS 1328 d_taskResume( 1329 sal_thread_t tid /* task ID of task to resume */ 1330 ) ; 1331 STATUS 1332 d_taskSuspend( 1333 sal_thread_t tid /* task ID of task to suspend */ 1334 ) ; 1335 STATUS 1336 d_taskIdVerify ( 1337 sal_thread_t tid 1338 ) ; 1339 int 1340 d_socket( 1341 int domain, 1342 int type, 1343 int protocol 1344 ) ; 1345 int 1346 d_bind( 1347 int s, 1348 struct sockaddr *name, 1349 int namelen 1350 ) ; 1351 int 1352 d_sendto( 1353 int s, 1354 caddr_t buf, 1355 int bufLen, 1356 int flags, 1357 struct sockaddr *to, 1358 int tolen 1359 ); 1360 int 1361 d_syslog( 1362 int pri, 1363 char *message 1364 ) ; 1365 1366 unsigned long 1367 d_inet_addr( 1368 const char* cp 1369 ); 1370 1371 int 1372 d_strnicmp( 1373 const char *str1, 1374 const char *str2, 1375 size_t n 1376 ); 1377 1378 int 1379 d_stricmp( 1380 const char *str1, 1381 const char *str2 1382 ); 1383 1384 #endif /* !DUNE_BCM */ 1385 /* 1386 * Error identifiers { 1387 */ 1388 #define STARTERPROC_ERR_03 1 1389 #define D_TIMER_CREATE_ERR_01 2 1390 #define D_IOCTL_ERR_01 3 1391 #define D_TASKDELETE_ERR_01 4 1392 #define D_TASKDELETE_ERR_02 5 1393 #define D_TASKDELETE_ERR_03 6 1394 #define D_TASKDELETE_ERR_04 7 1395 #define STARTERPROC_ERR_01 11 1396 #define STARTERPROC_ERR_02 12 1397 #define UI_PROC_SIGNAL_ERR_01 18 1398 #define UI_PROC_SIGNAL_ERR_02 19 1399 #define UI_PROC_SIGNAL_ERR_03 20 1400 #define UI_TMR_NEW_N_KICK_ERR_01 21 1401 #define UI_TMR_NEW_N_KICK_ERR_02 22 1402 #define UI_TMR_NEW_N_KICK_ERR_03 23 1403 #define HANDLE_NEXT_CHAR_ERR_02 25 1404 #define HANDLE_NEXT_CHAR_ERR_04 27 1405 #define HANDLE_NEXT_CHAR_ERR_05 28 1406 #define HANDLE_NEXT_CHAR_ERR_06 29 1407 #define UI_PREP_PROC_ERR_03 33 1408 #define UI_PREP_PROC_ERR_04 34 1409 #define UI_PREP_PROC_ERR_05 35 1410 #define INIT_UI_MODULE_ERR_01 36 1411 #define INIT_UI_MODULE_ERR_02 37 1412 #define INIT_UI_MODULE_ERR_03 38 1413 #define INIT_UI_MODULE_ERR_04 39 1414 #define INIT_UI_MODULE_ERR_05 40 1415 #define INIT_UI_MODULE_ERR_06 41 1416 #define INIT_UI_MODULE_ERR_07 42 1417 #define INIT_UI_MODULE_ERR_08 43 1418 #define D_WRITE_ERR_01 44 1419 #define PRINT_DETAILED_HELP_ERR_01 45 1420 #define INIT_UI_INTERPRETER_ERR_01 47 1421 #define INIT_UI_INTERPRETER_ERR_02 48 1422 #define INIT_UI_INTERPRETER_ERR_03 49 1423 #define INIT_UI_INTERPRETER_ERR_04 50 1424 #define SYS_GETCH_ERR_01 55 1425 #define ASK_GET_ERR_01 56 1426 #define ASK_GET_ERR_02 57 1427 #define ASK_GET_ERR_05 60 1428 #define D_CLOCK_GETTIME_ERR_01 64 1429 #define D_RESTART_SHELL_ERR_01 82 1430 #define D_RESTART_SHELL_ERR_02 83 1431 #define D_IOGLOBALSTDGET_ERR_01 84 1432 #define D_CLOCK_ERR_01 88 1433 #define D_TASKNAME_ERR_01 89 1434 #define D_TASK_LOCK_ERR_01 92 1435 #define D_TASK_UNLOCK_ERR_01 93 1436 #define LINE_MODE_HANDLING_ERR_01 94 1437 #define EXERCISES_ERR_01 108 1438 #define EXERCISES_ERR_03 110 1439 #define EXERCISES_ERR_04 111 1440 #define FIELD_LEGITIMATE_TEXT_ERR_01 114 1441 #define EXERCISES_ERR_05 115 1442 #define EXERCISES_ERR_06 116 1443 #define GET_APPLICATION_VERION_ERR_01 117 1444 #define DOWNLOAD_APPLICATION_TO_FLASH_ERR_01 118 1445 #define DOWNLOAD_BOOT_TO_FLASH_ERR_01 119 1446 #define HANDLE_BACK_SPACE_ERR_01 122 1447 #define PROGSTART_ERR_01 124 1448 #define UI_PREP_PROC_ERR_06 125 1449 #define UI_PREP_PROC_ERR_07 126 1450 #define UI_PREP_PROC_ERR_08 127 1451 #define UI_PREP_PROC_ERR_09 128 1452 #define HIGH_LEVEL_LOCAL_APP_ERR_05 131 1453 #define DUMMY_CONSOLE_ERR_01 146 1454 #define DUMMY_CONSOLE_ERR_02 147 1455 #define DUMMY_CONSOLE_ERR_03 148 1456 #define DUMMY_TELNET_ERR_01 150 1457 #define DUMMY_TELNET_ERR_02 151 1458 #define DUMMY_TELNET_ERR_03 152 1459 #define DUMMY_TELNET_ERR_04 153 1460 #define DUMMY_TELNET_ERR_05 154 1461 1462 #define HIGH_LEVEL_LOCAL_APP_ERR_01 224 1463 #define D_APP_ACTIVATE_GET_01 225 1464 #define HIGH_LEVEL_LOCAL_APP_ERR_04 235 1465 1466 1467 #define CHAR_Q_INTERNAL_ERR 315 1468 #define GET_APPLICATION_VERION_FROM_ZIP_ERR_01 320 1469 #define D_TASKRESTART_ERR_01 327 1470 #define D_TASKRESTART_ERR_02 328 1471 #define D_TASKRESTART_ERR_03 329 1472 #define D_TASKRESTART_ERR_04 330 1473 #define D_TASKRESUME_ERR_01 331 1474 #define D_TASKRESUME_ERR_02 332 1475 #define D_TASKRESUME_ERR_04 334 1476 #define D_TASKSUSPEND_ERR_01 335 1477 #define D_TASKSUSPEND_ERR_02 336 1478 #define D_TASKSUSPEND_ERR_03 337 1479 #define D_TASKSUSPEND_ERR_04 338 1480 1481 #define SWEEP_PETRA_APP_INIT_ERR 352 1482 1483 #define HIGH_LEVEL_LOCAL_APP_ERR_02 396 1484 #define HIGH_LEVEL_LOCAL_APP_ERR_03 397 1485 #define INIT_HIGH_LEVEL_CHECK_CRATE_ERR_01 398 1486 #define INIT_HIGH_LEVEL_CHECK_CRATE_ERR_02 399 1487 #define INIT_HIGH_LEVEL_CHECK_CRATE_ERR_03 400 1488 1489 #define DFFS_DESCRIPTOR_CRC_ERR 410 1490 #define DFFS_FILE_CRC_ERR 411 1491 1492 1493 #define DCL_SKT_ERR_BASE 600 1494 1495 enum { 1496 DCL_SKT_ERR_01 = DCL_SKT_ERR_BASE, 1497 DCL_SKT_ERR_02, 1498 DCL_SKT_ERR_03, 1499 DCL_SKT_ERR_04, 1500 DCL_SKT_ERR_05, 1501 DCL_SKT_ERR_06, 1502 DCL_SKT_ERR_07, 1503 DCL_SKT_ERR_08, 1504 DCL_SKT_ERR_09, 1505 1506 DCL_SKT_ERR_LAST 1507 } ; 1508 1509 /* 1510 * } 1511 */ 1512 /* 1513 * Definitions related to 'gen_err'. 1514 * { 1515 */ 1516 /* 1517 * Definitions related to 'severity' parameter of 1518 * 'gen_err'. 1519 */ 1520 #define SVR_MSG 0 1521 #define SVR_WRN 1 1522 #define SVR_ERR 2 1523 #define SVR_FTL 3 1524 1525 /* Highest possible value for severity - 1526 Used in the syslog mechanism as a flag 1527 that disables remote logging. */ 1528 #define SVR_LAST 255 1529 /* 1530 * Debug purposes only. See gen_err. 1531 */ 1532 #define SVR_DBG_ONLY BIT(8) 1533 /* 1534 * Semaphore handling for RUNTIME event log file protection. 1535 * { 1536 * 1537 * Semaphore is taken every time RUNTIME event log is accessed and 1538 * released when access has ended. 1539 * Use mutual exclusion semaphore rather since we want the 1540 * 'recursive' option. 1541 * 1542 * For all utilities: Returning a non-zero value indicates error. 1543 * 1544 * To carry out direct RUNTIME event log access, use 'ignore_rtlog_sem()' 1545 */ 1546 unsigned 1547 int 1548 get_use_rt_log_sem( 1549 void 1550 ) ; 1551 void 1552 set_use_rt_log_sem( 1553 unsigned int val 1554 ) ; 1555 int 1556 init_rt_log_sem( 1557 void 1558 ) ; 1559 int 1560 take_rt_log_sem( 1561 void 1562 ) ; 1563 int 1564 give_back_rt_log_sem( 1565 void 1566 ) ; 1567 /* 1568 * } 1569 */ 1570 /* 1571 * Definitions related to 'pcket injection' test of FAP. 1572 * { 1573 */ 1574 /* 1575 * Prototypes 1576 * { 1577 */ 1578 int 1579 line_card_packet_inject_test( 1580 unsigned int action, 1581 unsigned int num_cycles_to_do, 1582 unsigned int trace_print, 1583 unsigned int *num_cycles_done, 1584 unsigned int *manual_break, 1585 unsigned int *fail_indication, 1586 unsigned long *pattern, 1587 unsigned int pattern_type, 1588 unsigned int packet_size 1589 ) ; 1590 /* 1591 * } 1592 */ 1593 /* 1594 * } 1595 */ 1596 1597 #if !DUNE_BCM 1598 #if !(defined(LINUX) || defined(UNIX)) 1599 #endif 1600 #endif 1601 /* { */ 1602 1603 /* 1604 * Definitions related to 'runtime event log': 1605 * Events that are temporarily stored in a RAM 1606 * area and are periodically flushed into NVRAM in 1607 * a background process. 1608 * It is assumed, at this point, that all definitions 1609 * related to event log in NVRAM are already 1610 * known (from eeprom.h) 1611 * Note that Runtime_event_log_table is packed. 1612 * This is just to make surethat the event_log_item 1613 * array, contained in it, is packed (Altjough it 1614 * is so defined, we just make sure that this 1615 * definition is not changed by the encapsulating 1616 * structure). 1617 * { 1618 */ 1619 /* 1620 * Number of elements in Runtime_event_log_table. 1621 */ 1622 1623 #define NUM_RUNTIME_EVENT_LOG_ELEMENTS (NUM_EVENT_LOG_ITEMS * 2) 1624 typedef struct 1625 { 1626 /* 1627 * Index in array 'Runtime_event_log_table' of next item 1628 * to load. 1629 */ 1630 unsigned int next_in_index ; 1631 /* 1632 * Number of meaningful events logged in array 1633 * 'Runtime_event_log_table'. Events are stored 1634 * cyclicly. 1635 * For example, if 'NUM_RUNTIME_EVENT_LOG_ELEMENTS' 1636 * is 20, 'next_in_index' is 5 and 'num_events_logged' 1637 * is 7 then the index of the first meaningful 1638 * entry is 18. 1639 */ 1640 unsigned int num_events_logged ; 1641 /* 1642 * Index in array 'Runtime_event_log_table' of next item 1643 * to flush into NVRAM. 1644 */ 1645 unsigned int next_flush_index ; 1646 /* 1647 * Number of meaningful events logged in array 1648 * 'Runtime_event_log_table' which still need to be 1649 * flushed into NVRAM. Events are stored 1650 * cyclicly, as explained above. 1651 */ 1652 unsigned int num_events_to_flush ; 1653 /* 1654 * Array of flags, each corresponding to one event, which 1655 * indicate whether this event should go into NVRAM. 1656 */ 1657 unsigned char store_in_nv[NUM_RUNTIME_EVENT_LOG_ELEMENTS] ; 1658 /* 1659 * Array of events pushed into this log file. 1660 */ 1661 EVENT_LOG_ITEM event_log_item[NUM_RUNTIME_EVENT_LOG_ELEMENTS] ; 1662 } __ATTRIBUTE_PACKED__ RUNTIME_EVENT_LOG_TABLE ; 1663 /* 1664 * Flush RUNTIME to NVRAM log period: 1665 * Seconds and nanoseconds. 1666 * Make it 50 milliseconds. 1667 */ 1668 /* 1669 * Prototypes: 1670 * { 1671 */ 1672 unsigned 1673 int 1674 is_runtime_event_log_initialized( 1675 void 1676 ) ; 1677 RUNTIME_EVENT_LOG_TABLE 1678 *get_runtime_event_log_ptr( 1679 void 1680 ) ; 1681 int 1682 init_runtime_event_log( 1683 void 1684 ) ; 1685 int 1686 display_runtime_log_block( 1687 void 1688 ) ; 1689 int 1690 clear_runtime_log_block( 1691 void 1692 ) ; 1693 int 1694 next_event_to_runtime( 1695 EVENT_LOG_ITEM *event_item_ptr, 1696 unsigned char store_in_nv 1697 ) ; 1698 int 1699 next_runtime_to_nv_log( 1700 unsigned int *empty_ptr 1701 ) ; 1702 /* 1703 * } 1704 */ 1705 /* 1706 * } 1707 */ 1708 /* 1709 * Definitions related to 'active events': 1710 * Events that are temporarily stored and used for alarm 1711 * handling and for handling of event storms. 1712 * { 1713 */ 1714 /* 1715 * Structure to use as basic unit of 'active_event' 1716 * object, which contains events which were reported 1717 * during the very near past. (shock absorber for 1718 * repeated events). 1719 */ 1720 typedef struct active_event_str 1721 { 1722 /* 1723 * Full identifier of the event 1724 */ 1725 int event_id ; 1726 /* 1727 * Severity of event. 1728 * Values 1729 * SVR_MSG 0 1730 * SVR_WRN 1 1731 * SVR_ERR 2 1732 * SVR_FTL 4 1733 */ 1734 int severity ; 1735 /* 1736 * Time from startup, in units of 10 milliseconds, 1737 * when event was last displayed/stored. 1738 */ 1739 unsigned long displayed_time ; 1740 /* 1741 * Number of times event was encountered since it 1742 * was last displayed. 1743 */ 1744 unsigned short num_accumulated ; 1745 /* 1746 * Minimal time, in units of 10 ms, between two display/store 1747 * actions on this event. 1748 */ 1749 unsigned short event_period ; 1750 /* 1751 * Text to display when scanning of events (for aging) finds 1752 * an event which has non-zero num_accumulated element and 1753 * which is still pending. 1754 */ 1755 char event_text[80] ; 1756 /* 1757 * Flags: bit map. Specify whether this event is an 1758 * alarm [BIT(0) set]. 1759 * Values: 1760 * SET_ALARM BIT(0) 1761 * Also conains field specifying type of alarm (which 1762 * may be an indication for the led to set) stored 1763 * in ALARM_TYPE_MASK (second LS byte) 1764 */ 1765 unsigned int alarm_flags ; 1766 /* 1767 * Flag. Set to non-zero value when this entry is loaded and 1768 * back to zero when this entry is aged out. 1769 */ 1770 unsigned char pending ; 1771 /* 1772 * Name of task at which event was detected. 1773 */ 1774 char task_name[10] ; 1775 /* 1776 * Name of procedure at which event was detected. 1777 */ 1778 char proc_name[16] ; 1779 /* 1780 * Error reported by OS when event was first 1781 * reported. 1782 */ 1783 int vx_works_error ; 1784 /* 1785 * Flag indicating whether event should be stored in NVRAM 1786 * log file. 1787 */ 1788 unsigned int store_in_nv ; 1789 } ACTIVE_EVENT ; 1790 /* 1791 * Bit indicating the number of active event entries. 1792 * The number of active events is BIT(ACTIVE_EVENT_BIT) 1793 */ 1794 #define ACTIVE_EVENT_BIT 11 1795 /* 1796 * Bit mask to use as hash to active_event_table. When 1797 * anded with event_id, this gives the index of the 1798 * corresponding entry. 1799 */ 1800 #define ACTIVE_EVENT_MASK UPTO_BIT( ACTIVE_EVENT_BIT ) 1801 /* 1802 * Number of elements in active_event_table. 1803 */ 1804 #define NUM_ACTIVE_EVENT_ELEMENTS ( ACTIVE_EVENT_MASK + 1 ) 1805 /* 1806 * Number of elements in active_event_table to scan 1807 * every pass in background task. 1808 * Make it a small number since task switching is 1809 * disabled while aging! 1810 */ 1811 #define NUM_ACTIVE_EVENT_TO_AGE ( NUM_ACTIVE_EVENT_ELEMENTS / 20 ) 1812 1813 1814 #if (NUM_ACTIVE_EVENT_TO_AGE == 0) 1815 #define NUM_ACTIVE_EVENT_TO_AGE 1 1816 #endif 1817 1818 1819 /* 1820 * Active events aging period: Seconds and nanoseconds. 1821 * Make it 100 milliseconds. 1822 */ 1823 /* 1824 * Definitions related to 'load_active_entry' 1825 */ 1826 /* 1827 * Entry was loaded as required 1828 */ 1829 /* 1830 * Entry was found occupied by another event 1831 */ 1832 /* 1833 * Entry was stored with one alarm attribute and it 1834 * is attempted to update it with another alarm attribute. 1835 */ 1836 /* 1837 * Entry was found to have timed out (requires display) 1838 */ 1839 int 1840 load_active_entry( 1841 int event_id, 1842 int severity, 1843 unsigned short event_period, 1844 const char *event_text, 1845 unsigned int alarm_flags, 1846 const char *task_name, 1847 const char *proc_name, 1848 unsigned int store_in_nv, 1849 int vx_works_error, 1850 unsigned int dbg_inject 1851 ) ; 1852 /* 1853 * Alarm_flags: Bits and fields 1854 */ 1855 #define SET_ALARM BIT(0) 1856 #define RESET_ALARM BIT(1) 1857 #define ALARM_EVENT (SET_ALARM | RESET_ALARM) 1858 #define ALARM_TYPE_MASK 0x0000FF00 1859 /* 1860 * Minimal time, in units of 10 milliseconds, between two 1861 * display/store actions of a specific event (related to gen_err). 1862 */ 1863 /* 1864 * Minimal severity, above which events are stored in 1865 * NV ram (related to gen_err). 1866 */ 1867 int 1868 get_store_in_nv( 1869 int event_id 1870 ) ; 1871 void 1872 age_active_entries( 1873 int num_entries 1874 ) ; 1875 int 1876 print_active_entry( 1877 int event_id, 1878 unsigned int alarm_flag 1879 ) ; 1880 int 1881 active_entry_to_event_log( 1882 int event_id, 1883 EVENT_LOG_ITEM *event_log_item 1884 ) ; 1885 void 1886 init_repeat_period( 1887 void 1888 ) ; 1889 void 1890 set_repeat_period( 1891 unsigned short val 1892 ) ; 1893 unsigned 1894 short 1895 get_repeat_period( 1896 void 1897 ) ; 1898 /* 1899 * } 1900 */ 1901 1902 #if !DUNE_BCM 1903 #endif /*} LINUX */ 1904 1905 char 1906 *severity_to_text( 1907 int severity 1908 ) ; 1909 void 1910 err_gen_err( 1911 int event_id, 1912 int severity, 1913 char *event_text 1914 ) ; 1915 void 1916 print_gen_err( 1917 char *text, 1918 int severity 1919 ) ; 1920 void 1921 init_gen_err( 1922 void 1923 ) ; 1924 int 1925 gen_err( 1926 int compare, 1927 int reverse_logic, 1928 int status, 1929 int reference, 1930 const char *msg, 1931 const char *proc_name, 1932 int severity, 1933 int err_id, 1934 unsigned int store_in_nv, 1935 unsigned int alarm_flags, 1936 short min_time_between_events, 1937 unsigned int send_trap 1938 ) ; 1939 int 1940 gen_err_msg( 1941 const char *msg, 1942 const char *proc_name, 1943 unsigned int store_in_nv, 1944 unsigned int alarm_flags, 1945 short min_time_between_events, 1946 unsigned int send_trap 1947 ); 1948 1949 /* 1950 * } 1951 */ 1952 void 1953 proc_print( 1954 char *msg, 1955 char *proc_name, 1956 unsigned int num_pars, 1957 int par1, 1958 int par2 1959 ) ; 1960 void 1961 set_bits( 1962 unsigned char *src_ptr, 1963 unsigned long bit_offset, 1964 unsigned long num_bits 1965 ) ; 1966 int 1967 test_bits( 1968 unsigned char *src_ptr, 1969 unsigned long bit_offset, 1970 unsigned long num_bits 1971 ) ; 1972 int 1973 fill_water_marks( 1974 unsigned char *buffer, 1975 unsigned long buffer_len 1976 ) ; 1977 int 1978 get_water_size( 1979 unsigned char *buffer, 1980 unsigned long buffer_len, 1981 unsigned long *estimated_size 1982 ) ; 1983 void 1984 init_utils( 1985 void 1986 ) ; 1987 void 1988 init_software_exception_module( 1989 void 1990 ) ; 1991 void 1992 init_watchdog_module( 1993 void 1994 ) ; 1995 int 1996 first_nz_bit( 1997 unsigned char in_byte 1998 ) ; 1999 int 2000 one_nz_bits( 2001 unsigned char in_byte 2002 ) ; 2003 int 2004 num_nz_bits( 2005 unsigned char in_byte 2006 ) ; 2007 int 2008 test_task_delay_and_resume( 2009 void 2010 ); 2011 /* 2012 * } 2013 */ 2014 #if (SIMULATE_DUNE_CHIP || SIMULATE_CHIP_SIM) 2015 /* { */ 2016 extern 2017 FE_REGS 2018 Fe_regs[] ; 2019 extern 2020 FAP10M_REGS 2021 Fap10m_regs[] ; 2022 /* } */ 2023 #endif 2024 /* 2025 * Object: Buff_mem 2026 * This object enables the user to store 'mem read' results 2027 * in local memory to later be retriebed. This feature enables 2028 * faster working with an external script agent (like proComm). 2029 * Storage is always in units of char (one byte). 2030 * { 2031 */ 2032 extern 2033 unsigned 2034 char 2035 Buff_mem[] ; 2036 /* 2037 * } 2038 */ 2039 2040 #ifdef __cplusplus 2041 } 2042 #endif 2043 2044 /* } */ 2045 #endif