📄 per_port.c
字号:
/*
*-------------------------------------------------------------------------------
*
* I N T E L P R O P R I E T A R Y
*
* COPYRIGHT (c) 2002 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
*
* ------------------------------------------------------------------------------
*/
/**
* System defined include files required.
*/
/**
* User defined include files required.
*/
#include "error_code.h"
#include "diag_utils.h"
#include "syslog.h"
#include "msf_common.h"
#include "led.h"
#include "diagstruct.h"
#include "error_map.h"
#include "reg_api.h"
#include "register_map.h"
#include "diag.h"
#include "prototypes.h"
#include "mac_util.h"
#include "mac_init.h"
/**
* Pre-processor symbols and macros used in this file.
*/
#define PORTREG_START STATION_ADDR_LOW
#define PORTREG_END MUL_PORT_ADDR_HIGH
#define WRITE_VAL 0xA5A5A5A5
/**
* Variable declarations global to this file only. Externs are followed by
* static variables.
*/
unsigned int reg_array[16][2] = {{0x0,0xA5A5A5A5},{0x1,0xFFFF}, {0x3,0x5555},{0x5,0x5A},
{0x6,0xFF},{0x7,0xF05A}, {0x8,0xABCD4321}, {0x9,0xF0F0},
{0xA,0x3A5},{0xB,0x3A5},{0xC,0x3A5},{0xE,0xCAFE},
{0xF,0xFA0},{0x18,0xA5A5},{0x1A,0x1234ABCD},{0x1B,0x5A5A}};
#define reg_arraySz (sizeof(reg_array) /sizeof(reg_array[0]))
extern diag_error *p_aErrorMap;
/**
* Extern function prototypes.
*/
extern void Set_LED(unsigned char* buffer);
extern char *strcpy(char *s1, const char *s2);
extern void eprintf(char *f, ...);
extern UINT32 reg_read( volatile UINT32 offset);
extern void reg_write( volatile UINT32 offset, UINT32 val);
//extern UINT32 generate_pci_doorbell_interrupt(void);
/**
* Static function prototypes.
*/
static UINT32 writePortRegs(void);
static UINT32 read_ValidatePortRegs(void);
/**
* Function definitions.
*/
UINT32 per_port_reg_test(void)
{
UINT32 test_passed = 0;
register PDiagCommon acL = (PDiagCommon) ACADDRESS;
if(acL->HostType == MASTER) // if master NPU
{
spConfig(); // configure slow port
writePortRegs();
/*
** Read and validate the per port control registers.
*/
test_passed=read_ValidatePortRegs();
MSG("test_passed: %u\n",test_passed,0,0);
if (test_passed)
{
eprintf("Per Port Registers read/write test passed.\n");
Set_LED("PORT");
slowport_code[0] = SP_XSC;
slowport_code[1] = SP_PASS;
dump_slowport(slowport_code, 2, SP_NON_FATAL);
} else
{
eprintf("%s\n",ERR_STR(PERPORT_ERR));
Set_LED("PORT");
slowport_code[0] = SP_XSC;
slowport_code[1] = SP_FAIL;
dump_slowport(slowport_code, 2, SP_NON_FATAL);
}
spRestore(); // restore slow port config
return DONE;
}
else
{
eprintf("\nThis test cannot be run directly on the Slave console\n");
return DONE; // To indicate that the slave does not do this.
}
}
static UINT32 writePortRegs(void)
{
UINT32 port = 0;
UINT32 port_index = 0x00;
UINT32 offset=0;
short i=0;
for (port=0;port<=3;port++)
{
for(i=0;i<reg_arraySz;i++)
{
offset=reg_array[i][0];
reg_write((port_index+offset),reg_array[i][1]);
}
port_index+=PORTSZ;
}
return DONE;
}
static UINT32 read_ValidatePortRegs(void)
{
UINT32 port = 0;
UINT32 read_val=0;
UINT32 port_index = 0x00;
UINT32 passed = 1;
UINT32 offset=0;
short i=0;
for (port=0;port<=3;port++)
{
for(i=0;i<reg_arraySz;i++)
{
offset=reg_array[i][0];
read_val=reg_read((port_index+offset));
if (read_val != reg_array[i][1])
{
MSG("expected Reg.Value: %x\t Read Value: %x\n",WRITE_VAL,read_val,0);
MSG("Test Failed !\n",0,0,0);
passed = 0; /* test failed */
break;
}
}
port_index+=PORTSZ;
if (!passed)
break;
}
MSG("Returning passed = %u\n",passed,0,0);
return passed;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -