📄 harness.c
字号:
#include <stdio.h>#include <stddef.h>#include <stdlib.h>#include <string.h>#include "stboot.h"#include "stdevice.h"#include "stcommon.h"#include "stboot.h"#include "stpio.h"#include "stuart.h"#include "sttbx.h"#include "stevt.h"#include "tt_uart.h"#include "stfpga.h"#include "statapi.h"#include "testtool.h"#include "stsys.h"#include "sttbx.h"#include "harness.h"#include "wrapper.h"#include "stavfs.h"/* Function Prototypes *//********************************//* Private variables (static) --------------------------------------------- */#define STATAPI_OLD_FPGA/* Allow room for OS20 segments in internal memory */unsigned char InternalBlock[ST20_INTERNAL_MEMORY_SIZE - 1200];#pragma ST_section (InternalBlock, "internal_section")/* Allow some space for static data that may require to be in a non-cached section */unsigned char NcacheMemory[NCACHE_MEMORY_SIZE - (66 * 1024)];#pragma ST_section (NcacheMemory , "ncache_section")unsigned char ExternalBlock[SYSTEM_MEMORY_SIZE];#pragma ST_section (ExternalBlock, "system_section")ST_Partition_t TheInternalPartition;ST_Partition_t TheSystemPartition;ST_Partition_t TheNcachePartition;#if defined( ST_5512 ) /* STi5512 definitions */#if defined(STATAPI_OLD_FPGA) #define ATA_INTERRUPT_NUMBER EXTERNAL_0_INTERRUPT #define ATA_BASE_ADDRESS (volatile U32 *) 0x60000000 #define ATA_HRD_RST (volatile U16 *) 0x60100000#else #define ATA_INTERRUPT_NUMBER EXTERNAL_0_INTERRUPT #define ATA_BASE_ADDRESS (volatile U32 *) 0x70B00000 #define ATA_HRD_RST (volatile U16 *) 0x70A00000#endif#elif defined ( ST_5508 ) || defined ( ST_5518 ) /* STi5508/18 definitions */#define ATA_INTERRUPT_NUMBER EXTERNAL_1_INTERRUPT#define ATA_BASE_ADDRESS (volatile U32 *)0x50000000#define ATA_HRD_RST (volatile U16 *)0x50000000#define REQUIRES_PIO_CONFIG#define PIO_DEV_NAME "PIO_0"#else#error unsupported board#endif/* Typedefs --------------------------------------------------------------- *//* Global ----------------------------------------------------------------- */ST_Partition_t *InternalPartition = &TheInternalPartition;ST_Partition_t *NcachePartition = &TheNcachePartition;ST_Partition_t *SystemPartition = &TheSystemPartition;ST_Partition_t *DriverPartition = &TheSystemPartition;/* the 3 declarations below MUST be kept so os20 doesn't fall over!! */ST_Partition_t *internal_partition = &TheInternalPartition;ST_Partition_t *system_partition = &TheSystemPartition;ST_Partition_t *ncache_partition = &TheNcachePartition;#if D_CACHE_ONSTBOOT_DCache_Area_t DCacheMap[] = { {(U32 *) 0x40080000, (U32 *) 0x4FFFFFFF}, /* Cacheable */ {NULL, NULL} /* End */};#elseSTBOOT_DCache_Area_t DCacheMap[] = NULL;#endif/********************************/extern void InitCommands(void);static BOOL BOOT_Init(ST_DeviceName_t BOOTDeviceName);static BOOL TST_Init(void);static BOOL TBX_Init(ST_DeviceName_t TBXDeviceName);int main(void){ ST_DeviceName_t BOOTDeviceName = "BOOT"; ST_DeviceName_t TBXDeviceName = "TBX"; STTBX_TermParams_t TBXTermParams; STBOOT_TermParams_t BOOTTermParams; #if defined(ST_5518) | defined(ST_5508) STPIO_InitParams_t PIO_Init; STPIO_OpenParams_t PIO_Open; STPIO_Handle_t PIO_Handle; #endif /* Create memory partitions */ partition_init_heap(&TheInternalPartition, (U8 *) InternalBlock, sizeof(InternalBlock)); partition_init_heap(&TheSystemPartition, (U8 *) ExternalBlock, sizeof(ExternalBlock)); partition_init_heap(&TheNcachePartition, (U8 *) NcacheMemory, sizeof(NcacheMemory)); /* Initialise APIs */ if (BOOT_Init(BOOTDeviceName)) { printf("BOOT_Init() failed\n"); return 1; } if (TBX_Init(TBXDeviceName)) { printf("TBX_Init() failed"); return 1; } if (TST_Init()) { printf("TST_Init() failed\n"); return 1; } #if defined(ST_5512) /*---- Let's load the FPGA code ---*/ if(ST_NO_ERROR != STFPGA_Init()) { STTBX_Print(("FPGA Init failed: ")); STTBX_Print(("\n")); } /* Now change the EMI configuration (bank 3) to set PIO mode 4 */#if defined(STATAPI_OLD_FPGA) *(volatile U32*) 0x00002020 = 0x16D1; *(volatile U32*) 0x00002024 = 0x50F0; *(volatile U32*) 0x00002028 = 0x400F; *(volatile U32*) 0x0000202C = 0x0002;#else /* "New" (supported) FPGA */ *(volatile U32*) 0x00002030 = 0x1791; *(volatile U32*) 0x00002034 = 0x50f0; *(volatile U32*) 0x00002038 = 0x50f0; *(volatile U32*) 0x0000203C = 0x0002;#endif#elif defined(ST_5518) || defined(ST_5508) /* Set FEI_ATAPI_CFG register */ STSYS_WriteRegDev8((void*)0x200387A0, 0x01); /* Configure PIO0-1 and PIO0-2 as output */ PIO_Init.BaseAddress = (U32*)PIO_0_BASE_ADDRESS; PIO_Init.InterruptNumber = PIO_0_INTERRUPT; PIO_Init.InterruptLevel = PIO_0_INTERRUPT_LEVEL; PIO_Init.DriverPartition = system_partition; if (ST_NO_ERROR != STPIO_Init(PIO_DEV_NAME, &PIO_Init)) { STTBX_Print(("Init PIO driver (port 0) failed\n")); exit (1); } PIO_Open.ReservedBits=(PIO_BIT_1| PIO_BIT_2); PIO_Open.BitConfigure[1]=STPIO_BIT_OUTPUT; PIO_Open.BitConfigure[2]=STPIO_BIT_OUTPUT; PIO_Open.IntHandler=NULL; if (ST_NO_ERROR != STPIO_Open(PIO_DEV_NAME, &PIO_Open, &PIO_Handle)) { STTBX_Print(("Open PIO driver failed\n")); } #endif { STEVT_InitParams_t EVTInitParams; EVTInitParams.EventMaxNum = 50; EVTInitParams.ConnectMaxNum = 10; EVTInitParams.SubscrMaxNum = 10; EVTInitParams.MemoryPartition = system_partition; if (ST_NO_ERROR != STEVT_Init(EVT_DEVICE_NAME, &EVTInitParams)) { STTBX_Print(("Bad : STEVT_Init()\n")); } } { STATAPI_InitParams_t AtapiInitParams; AtapiInitParams.DeviceType = STATAPI_EMI_PIO4; AtapiInitParams.DriverPartition = system_partition; AtapiInitParams.BaseAddress = ATA_BASE_ADDRESS; AtapiInitParams.HW_ResetAddress = ATA_HRD_RST; AtapiInitParams.InterruptNumber = ATA_INTERRUPT_NUMBER; AtapiInitParams.InterruptLevel = ATA_INTERRUPT_LEVEL; strcpy(AtapiInitParams.EVTDeviceName, EVT_DEVICE_NAME); if (ST_NO_ERROR != STATAPI_Init(ATAPI_DEVICE_NAME, &AtapiInitParams)) { STTBX_Print(("Bad : STATAPI_Init()\n")); } } STTBX_Print(("\nSTAVFS Test harness")); STTBX_Print(("\nLast built %s %s", __TIME__, __DATE__)); STTBX_Print(("\nSTAVFS version: %s \n\n", STAVFS_GetRevision() )); InitCommands(); /* Initialise all of the registered tests */ STTST_SetMode(STTST_BATCH_MODE); /* set to batch mode */ STTST_Start(); /* Launch the Command interpretor */ /* Terminate all drivers */ STTST_Term(); STTBX_Term(TBXDeviceName, &TBXTermParams); STBOOT_Term(BOOTDeviceName, &BOOTTermParams); return 0;}/*------------------------------------------------------------------------- * Function : BOOT_Init * Initialise boot process * Input : ST_DeviceName_t * Output : * Return : TRUE if error, FALSE if success * ----------------------------------------------------------------------*/static BOOL BOOT_Init(ST_DeviceName_t BOOTDeviceName){ ST_ErrorCode_t ErrCode; STBOOT_InitParams_t BootParams; BootParams.SDRAMFrequency = SDRAM_FREQUENCY; BootParams.CacheBaseAddress = (U32 *)CACHE_BASE_ADDRESS; BootParams.DCacheMap = DCacheMap; BootParams.ICacheEnabled = TRUE; BootParams.BackendType.DeviceType = STBOOT_DEVICE_UNKNOWN; BootParams.BackendType.MajorRevision = STBOOT_REVISION_UNKNOWN; BootParams.BackendType.MinorRevision = STBOOT_REVISION_UNKNOWN; BootParams.MemorySize = SDRAM_SIZE; if ((ErrCode = STBOOT_Init(BOOTDeviceName, &BootParams)) != ST_NO_ERROR) { printf("STBOOT_Init(0x%04x)=FAILED\n", ErrCode); } else { printf("STBOOT_Init()= OK\n"); } return (ErrCode == ST_NO_ERROR ? FALSE : TRUE);}/*------------------------------------------------------------------------- * Function : TBX_Init * STTBX Init function * Input : ST_DeviceName_t * Output : * Return : TRUE if error, FALSE if success * ----------------------------------------------------------------------*/BOOL TBX_Init(ST_DeviceName_t TBXDeviceName){ STTBX_InitParams_t TBXInitParams; /* Initialise Toolbox */ TBXInitParams.SupportedDevices = STTBX_DEVICE_DCU; TBXInitParams.DefaultOutputDevice = STTBX_DEVICE_DCU; TBXInitParams.DefaultInputDevice = STTBX_DEVICE_DCU; TBXInitParams.CPUPartition_p = SystemPartition; if (STTBX_Init(TBXDeviceName, &TBXInitParams) == ST_NO_ERROR) { STTBX_Report((STTBX_REPORT_LEVEL_INFO, "STTBX initialised\n")); return (FALSE); } else { printf("STTBX Cannot be initialised\n"); return (TRUE); }}/*------------------------------------------------------------------------- * Function : TST_Init * STTST Init function * Input : None * Output : * Return : TRUE if error, FALSE if success * ----------------------------------------------------------------------*/BOOL TST_Init(void){ STTST_InitParams_t STTST_InitParams; BOOL error; STTST_InitParams.CPUPartition_p = SystemPartition; STTST_InitParams.NbMaxOfSymbols = 300; /* Set input file name array to all zeros */ memset(STTST_InitParams.InputFileName, 0, sizeof(STTST_InitParams.InputFileName)); strcpy(STTST_InitParams.InputFileName, "stavfs.com"); if (STTST_Init(&STTST_InitParams) == ST_NO_ERROR) { printf("STTST_Init()=OK\n"); error = FALSE; } else { printf("STTST_Init()=FAILED\n"); error = TRUE; } return error;}/*------------------------------------------------------------------------- * Function : TST_Init * STTST Init function * Input : None * Output : * Return : TRUE if error, FALSE if success * ----------------------------------------------------------------------*/BOOL EnterInteractiveMode(parse_t * pars_p, char *result_sym_p){ STTST_SetMode(STTST_INTERACTIVE_MODE); /* set to interactive mode */ return FALSE;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -