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

util.c (1335B)


      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:        util.c
      8  *
      9  * Provides:
     10  *     pcid_x2i
     11  *     pcid_type_name
     12  *
     13  * Requires: types and memory type enumeration from verinet.h
     14  */
     15 
     16 #include <sys/types.h>
     17 #include <soc/types.h>
     18 #include <bde/pli/verinet.h>
     19 #include <string.h>
     20 
     21 int
     22 pcid_x2i(int digit)
     23 {
     24     if (digit >= '0' && digit <= '9') return (digit - '0'     );
     25     if (digit >= 'a' && digit <= 'f') return (digit - 'a' + 10);
     26     if (digit >= 'A' && digit <= 'F') return (digit - 'A' + 10);
     27     return 0;
     28 }
     29 
     30 
     31 /*
     32  * type_name
     33  */
     34 
     35 void pcid_type_name(char *buffer, uint32 type)
     36 {
     37     switch (type) {
     38     case PCI_CONFIG:
     39     /* coverity[secure_coding] */
     40 	strcpy(buffer, "PCI CONFIG");
     41 	break;
     42     case PCI_MEMORY:
     43     /* coverity[secure_coding] */
     44 	strcpy(buffer, "PCI MEMORY");
     45 	break;
     46     case I2C_CONFIG:
     47     /* coverity[secure_coding] */
     48 	strcpy(buffer, "I2C CONFIG");
     49 	break;
     50     case PLI_CONFIG:
     51     /* coverity[secure_coding] */
     52 	strcpy(buffer, "PLI CONFIG");
     53 	break;
     54     case JTAG_CONFIG:
     55     /* coverity[secure_coding] */
     56 	strcpy(buffer, "JTAG");
     57 	break;
     58     default:
     59     /* coverity[secure_coding] */
     60 	strcpy(buffer, "UNKNOWN");
     61 	break;
     62     }
     63 }