⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 testmgr.c

📁 开发Inetl IXP2400平台所必须的硬件诊断和测试程序。该软件包支持的功能包括CPU基本功能检测
💻 C
📖 第 1 页 / 共 2 页
字号:
/*
*---------------------------------------------------------------------------
*                                                                      
*                  I N T E L   P R O P R I E T A R Y                   
*                                                                      
*     COPYRIGHT (c)  2001 BY  INTEL  CORPORATION.  ALL RIGHTS          
*     RESERVED.   NO  PART  OF THIS PROGRAM  OR  PUBLICATION  MAY      
*     BE  REPRODUCED,   TRANSMITTED,   TRANSCRIBED,   STORED  IN  A    
*     RETRIEVAL SYSTEM, OR TRANSLATED INTO ANY LANGUAGE OR COMPUTER    
*     LANGUAGE IN ANY FORM OR BY ANY MEANS, ELECTRONIC, MECHANICAL,    
*     MAGNETIC,  OPTICAL,  CHEMICAL, MANUAL, OR OTHERWISE,  WITHOUT    
*     THE PRIOR WRITTEN PERMISSION OF :                                
*                                                                      
*                        INTEL  CORPORATION                            
*                                                                     
*                     2200 MISSION COLLEGE BLVD                        
*                                                                      
*               SANTA  CLARA,  CALIFORNIA  95052-8119                  
*                                                                      
*---------------------------------------------------------------------------
*/

#include "memory.h"
#include "common.h"
#include "diagstruct.h"
#include "bdw.h"
#include "common_types.h"
#include "common_def.h"
#include "ixf_api_d.h"
#include "ixf_api.h"
#include "ixf6048.h"
#include "bdwtests.h"
#include "i2c.h"
#include "i2c_test.h"
#include "uart.h"
#include "hal_ixdp2400.h"
#include "console_monitor.h"
#include "diag_utils.h"
#include "misc_func.h"

// function prototypes
extern char* Get_CPU(void);
extern int Get_CPU_Speed(void);
extern int Get_CPU_Rev(void);
extern int Get_SRAM_Size(void);
extern int Get_SDRAM_Size(void);
extern int Get_Host_Type(void);

extern void I2C_Test(void);
extern void BdwUnit_All(void);
void DiagTests(void);
void PrintBanner(void);
extern void cmd_reset(void);
void parseCmd(char *string, UINT pntr, int index);

extern void makeNumber(int i);
DiagCmd *findCmd(unsigned int pntr, int idx);
void cmd_help(void);
void GetI2CData(I2Cstruct_t *data);
void cmd_i2crd(void);
void cmd_i2cwr(void);

extern UINT32 sram_size[2];

/* Main Command Table */
DiagCmd bdwcmdarray[] = {
    { "help",     "s",    5,  cmd_help,       0, "print this message" },
    { "?",        "s",    5,  cmd_help,       0, "print this message" },
    { "h",        "s",    5,  cmd_help,       0, "print this message" },
    { "test",  "s",    3,  DiagTests,      0, "test, type t <cr> for help"},
    { "t",       "s",    3,  DiagTests,      0, "test, type t <cr> for help"},
    { "banner",   "",     0,  PrintBanner,    1, "Print Banner "},
    { "exit",     "",     0,  cmd_reset,      1, "Exit Diagnostics"},
    { "p", "xx", 0,cmd_print, 0, "<low> <high> print memory (32 bit)" },
    { "pb", "xx", 0,cmd_print, 2, "<low> <high> print memory (8 bit)" },
    { "pw", "xx", 0,cmd_print, 1,"<low> <high> print memory (16 bit)" },
    { "pd", "xx", 0,cmd_print, 0, "<low> <high> print memory (32 bit)" },
    { "c", "x", 0,cmd_change, 0, "change memory (32 bits)" },
    { "cb", "x", 0,cmd_change, 2, "change memory (8 bits)" },
    { "cw", "x", 0,cmd_change, 1, "change memory (16 bits)" },
    { "cd", "x", 0,cmd_change, 0, "change memory (32 bits)" },
    { "i2cread", "XXD", 0, cmd_i2crd, 1," I2C read <X:slave_addr> <X:offset_addr> <D:count>"},
    { "i2cwrite", "XXS", 0, cmd_i2cwr, 1," I2C write <X:slave_addr> <X:offset_addr> <S:data>"},
    { "viewlog", "D", 0, cmd_viewlog, 1, "View the entries in the log"},
	{ "clearlog", "", 0, syslog_clear, 0, "Clear all entries in the log"},
	{ "setverbose", "d", 0, cmd_set_verbose, 1, "Set verbose level <verbose_level>"},
    { 0,          0,      0,  0,0,0}
};


/* Diagnostic Command Table */
DiagCmd bdwtestarray   [] = {
    { "i2c",      "sxx",  0,  I2C_Test,       0, ""},
    { "unit",     "sddd", 0,  BdwUnit_Test,   0, ""},
    { "all",	  "d",	  0,  BdwUnit_All,	  0, "[d:loops]"},
    {0,0,0,0,0,0}
};

void DiagTests(void)
{
    register eduCommon* acL = (eduCommon *) ACADDRESS;
    DiagCmd *findCmd(UINT, int), *cmd;

    if (acL->dc.argc == 1)
    {
        eprintf("\nusage: t 'name' <args>\n");
        eprintf("where 'name' <args> is one of the following:\n\n");
        eprintf("t unit r <iterations>        (performs the R/W test)\n");
        eprintf("t unit l chan<0-3> mode<0 or 1> time<in seconds> (performs PRBS loopback test)\n");
        eprintf("t i2c                        (performs test on I2C)\n");
        eprintf("t all                        (performs all tests)\n");
        return;
    }
    cmd = findCmd((UINT)bdwtestarray,1);   /* find the command in our table */
    if (cmd != 0)
    {
        acL->dc.numArgs = cmd->numArg;  /* load up the arguments */
        (*(cmd->routine))();        /* call the requested routine now... */
    }
    else
        eprintf("unknown test command\n");
}


void PrintBanner(void)
{
    register eduCommon* acL = (eduCommon *) ACADDRESS;
    int i;
    unsigned short regVal;
    char *resultStr;

    eprintf("\n%s Board Diagnostics Build %s, %s\n", acL->dc.targetName, __TIME__, __DATE__);

    eprintf("DRAM:%d Mb,\n", acL->dc.SDRAMSize/1024/1024);
    eprintf("SRAM:%d Mb; Ch0: %d Mb, Ch1: %d Mb,\n",
        acL->dc.SRAMSize/1024/1024,
        sram_size[0]/1024/1024,
        sram_size[1]/1024/1024);

    if(acL->dc.HostType == MASTER)
    {
        unsigned char temp[16];

        eprintf("******************************************************************\n");

        /* Get the I2C Data */
        GetI2CData(&(acL->i2cData));
        
        /* Build a test status result string */
        switch((acL->i2cData.test_status - '1'))
        {
        case 0:
            resultStr = "PASSED";
            break;
        case 1:
            resultStr = "FAILED";
            break;
        default:
            resultStr = "NOT TESTED";
        }
        
        /* Convert string to upper case */
        i=0;
        while(acL->i2cData.model_id[i])
        {
            acL->i2cData.model_id[i] = toupper(acL->i2cData.model_id[i]);
            i++;
        }
        
        if (strcmp(acL->i2cData.model_id, "BW") &&
            strcmp(acL->i2cData.model_id, "BD"))
        {
            strcpy(acL->i2cData.model_id, "UNKNOWN");
        }

        eprintf("Media Card         : ");
        eprintf("%s", acL->i2cData.model_id);
        eprintf("\n");
        
        eprintf("Device Id          : ");
        eprintf("%d", acL->i2cData.dev_id);
        eprintf("\n");
        
        eprintf("Device Rev.        : ");
        eprintf("%c%c", acL->i2cData.part_rev[0], acL->i2cData.part_rev[1]);
        eprintf("\n");

		memset(temp, '\0', 16);
		memcpy(temp, acL->i2cData.part_num, CFG_PARTNUM_LEN);
        eprintf("Part Number        : %s\n", temp);

        memset(temp, '\0', 16);
		memcpy(temp, acL->i2cData.serial_num, CFG_SERIAL_NUM_LEN);
        eprintf("Serial Number      : %s\n", temp);
        
        memset(temp, '\0', 16);
		memcpy(temp, acL->i2cData.date, CFG_DATE_LEN);
        eprintf("Test Date          : %s\n", temp);

        eprintf("Test Status        : ");
        eprintf("%s", resultStr);
        eprintf("\n");
        
        eprintf("Target CPU         : ");
        eprintf("%s", acL->dc.targetCpu);
        eprintf("\n");
        
        IxfApiGenericRead((bb_ChipData_t *) acL->chipId, TWO_BYTES, 0x4001, 1, &regVal);
        eprintf("Media CPLD version : %02d\n", (regVal>>8));
        
        eprintf("******************************************************************\n");
    }
}


/* getCommands

  Function:
*/
void getCommands(void)
{
    register eduCommon* acL = (eduCommon *) ACADDRESS;

    if(acL->dc.HostType == MASTER)
    parseCmd("MSTR_BATTERY_DIAG> ",(UINT)bdwcmdarray,(int)0);  // the prompt of course
    else
        parseCmd("SLV_BATTERY_DIAG> ",(UINT)bdwcmdarray,(int)0);  // the prompt of course
}


//
// Function: parseCmd
//
// Decription:	Displays the prompt, then gets users input.
//				Separates user arguments to their respective
//				arrays. Calls findCmd and calls the routine
//				if the command matches a routine
//
void parseCmd(char *string, UINT pntr, int index)
{
    register eduCommon *acL = (eduCommon *) ACADDRESS;
    DiagCmd *findCmd(UINT, int), *cmd;
    char* s;
    int i = 0;

    bzero(acL->dc.cmdLine, 128); /* initialize the command buffer */
    eprintf("%s",string);

    getCmdLine(acL->dc.cmdLine);	// read user input from command line
    s = acL->dc.cmdLine;	// point to the cmdLine buffer

    // Clear arg count, and all the arguments
    acL->dc.argc = 0;
    for(i = 0; i < 10; i++)
    {
        acL->dc.hexArgOk[i] = FALSE;
        acL->dc.decArgOk[i] = FALSE;
        acL->dc.hexArg[i] = 0;
        acL->dc.decArg[i] = 0;
        acL->dc.argv[i] = 0;
    }

    while(1)
    {
        while(*s == ' ')	// skip spaces
            s++;
        if (*s == 0)	// if end of string, exit scanner
            break;
        acL->dc.argv[acL->dc.argc++] = s;	// store beginning of string
        if (*s == '"')
        {
            acL->dc.argv[acL->dc.argc - 1]++;
            while ((*s != '"') && (*s != 0))
            s++;    // skip argument
            if(*s == '"')
                *s++ = 0;
        }
        else
        {
            while((*s != ' ') && (*s != 0))
            s++;	// skip argument
            if(*s == ' ')

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -