openbcm

Git mirror of https://github.com/Broadcom-Network-Switching-Software/OpenBCM
git clone git://git.finwo.net/mirror/broadcom/openbcm
Log | Files | Refs | README

ukernel_debug.c (3231B)


      1 /*
      2  * 
      3  * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file.
      4  * 
      5  * Copyright 2007-2019 Broadcom Inc. All rights reserved.
      6  *
      7  * File:    ukernel_debug.c
      8  * Purpose:  
      9  */
     10 
     11 #include <stddef.h>
     12 #include <sal/core/libc.h>
     13 #include <shared/alloc.h>
     14 #include <sal/core/boot.h>
     15 #include <sal/core/dpc.h>
     16 #include <sal/core/time.h>
     17 #include <appl/diag/system.h>
     18 #include <appl/diag/dport.h>
     19 #include <bcm/error.h>
     20 #include <shared/pack.h>
     21 
     22 #if defined(VXWORKS)
     23 #include <vxWorks.h>
     24 #include <version.h>
     25 #include "config.h"
     26 #include <time.h>
     27 #include <stdlib.h>
     28 #endif
     29 
     30 #if defined(UNIX) && !defined(__KERNEL__)
     31 #include <time.h>
     32 #include <stdlib.h>
     33 #endif
     34 
     35 #if defined(SOC_UKERNEL_DEBUG)
     36 #if defined(BCM_CMICM_SUPPORT) || defined(BCM_IPROC_SUPPORT)
     37 #include <soc/uc_dbg.h>
     38 #include <appl/diag/ukernel_debug.h>
     39 
     40 #define UCDBG_COMMAND_USAGE \
     41     "ucdbg <subcommand>\n" \
     42     "\t ucdbg start     starts showing ukernel debug log\n" \
     43     "\t ucdbg stop      stops showing ukernel debug log\n" \
     44     "\t ucdbg status    shows ukernel debug module status\n"
     45 
     46 char cmd_cmic_ucdebug_usage[] = "Usages:\n"
     47 #ifdef COMPILER_STRING_CONST_LIMIT
     48     "   ucdbg <option> [args...]\n"
     49 #else
     50     "   " UCDBG_COMMAND_USAGE "\n"
     51 #endif /* COMPILER_STRING_CONST_LIMIT */
     52     ;
     53 
     54 
     55 cmd_result_t 
     56 cmd_cmic_ucdebug_dump_start(int unit, args_t *a)
     57 {
     58     int rval = 0;
     59     
     60     rval = soc_cmic_ucdebug_dump_start(unit);
     61     switch (rval) {
     62         case BCM_E_UNAVAIL:
     63             return (CMD_NOTIMPL);
     64             break;
     65         case BCM_E_FAIL:
     66             return (CMD_FAIL);
     67     }
     68     return (CMD_OK);
     69 }
     70 
     71 cmd_result_t
     72 cmd_cmic_ucdebug_dump_stop(int unit, args_t *a)
     73 {
     74     int rval = 0;
     75     
     76     rval = soc_cmic_ucdebug_dump_stop(unit);
     77     switch (rval) {
     78         case BCM_E_UNAVAIL:
     79             return (CMD_NOTIMPL);
     80             break;
     81         case BCM_E_FAIL:
     82             return (CMD_FAIL);
     83     }
     84     return (CMD_OK);
     85 
     86 }
     87 
     88 cmd_result_t
     89 cmd_cmic_ucdebug_status(int unit, args_t *a)
     90 {
     91     int rval = 0;
     92     
     93     rval = soc_cmic_ucdebug_status(unit);
     94     switch (rval) {
     95         case BCM_E_UNAVAIL:
     96             return (CMD_NOTIMPL);
     97             break;
     98         case BCM_E_FAIL:
     99             return (CMD_FAIL);
    100     }
    101     return (CMD_OK);
    102 }
    103 
    104 /************* Main cmic_uc Debug command *******************/    
    105 typedef struct {
    106     char *str;
    107     cmd_result_t (*func)(int unit, args_t *args);
    108 } uc_debug_subcommand_t;
    109 
    110 cmd_result_t
    111 cmd_cmic_ucdebug(int unit, args_t *a)
    112 {
    113     uc_debug_subcommand_t subcommands[] = {
    114 #ifndef __KERNEL__
    115         {"start", cmd_cmic_ucdebug_dump_start},
    116         {"stop", cmd_cmic_ucdebug_dump_stop},
    117         {"status", cmd_cmic_ucdebug_status},
    118 #endif
    119     };
    120     int i;
    121     const char *arg;
    122 
    123     if(!soc_feature(unit, soc_feature_ukernel_debug)) {
    124         return (CMD_NOTIMPL);
    125     }
    126     arg = ARG_GET(a);
    127     if (!arg) {
    128        return (CMD_USAGE);
    129     }
    130 
    131     for (i = 0; i < sizeof(subcommands) / sizeof(subcommands[0]); ++i) {
    132         if (parse_cmp(subcommands[i].str, arg, 0)) {
    133             return (*subcommands[i].func)(unit, a);
    134         }
    135     }
    136 
    137     return (CMD_USAGE);
    138 }
    139 
    140 #endif /* #if defined(BCM_CMICM_SUPPORT) || defined(BCM_IPROC_SUPPORT) */
    141 #endif