📄 csstest.c
字号:
/************************************************************************** * * Copyright (c) 2005 Curtiss-Wright Controls, Inc. All rights * reserved. This Source Code is the Property of Curtiss-Wright * Controls, Inc. and can only be used in accordance with Source * Code License Agreement(s) of Curtiss-Wright Controls, Inc. or any * of its subsidiaries. * **************************************************************************//*FILE HEADER************************************************************** * Product Name: 182 BSP * * Header %name: cssTest.c % * Instance: kanata_1 * * Description: 182 Test CSS wrapper functions * * %created_by: tissa % * %date_created: Tue Dec 13 16:13:39 2005 % * * Notes: created from 181 dmo ver.01c * * History: * * 01b,13dec05,tis changed startAddr for 183/124 boards. * 01a,20oct05,rsr CR3191: Added bsp.h to includes * *END FILE HEADER*********************************************************//*DESCRIPTIONThis module tests the CSS Wrapper funcitons.INCLUDE FILES: vxCss_dy4.h*//* includes */#include <vxWorks.h>#include <stdio.h>#include <intLib.h>#include <logLib.h>#include <taskLib.h>#include <string.h>#include "h/drv/dy4/dy4std.h"#include "h/drv/dy4/vxCss_dy4.h"#include "config.h"#include "bsp.h"/* external declarations */IMPORT char *sysPhysMemTop (void);IMPORT char *sysModel (void);void keyContinue (void) { printf ("\n\rHIT RETURN TO CONTINUE >> \n\r"); getchar(); }/*************************************************************************** ** cssGetLocalRamTest - test cssGetLocalRam function ** This routine compares the results of the cssGetLocalRam function to the* value returned in sysPhysMemTop().** RETURNS: N/A**/void cssGetLocalRamTest (void) { char * memTop; char * memBase; printf ("Testing CSS Get Local RAM Function\n\n"); printf ("Calling sysPhysMemTop(): 0x%x\n\n", (UINT32) sysPhysMemTop()); cssGetLocalRam (&memBase, (UINT *) &memTop); printf ("Calling cssGetLocalRam(): 0x%x\n\n", (UINT32) memTop); printf ("Verify both calls returned the same RAM size.\n\n"); return; }/******************************************************************************** cssNvmpTest() - Tests CSS NVMP Wrapper functions ** This routine tests the CSS Wrapper functions for using NVMP.** RETURNS: N/A**/STATUS cssNvmpTest() {#if defined(VME_183) || defined(SCP_124) void * startAddr = (void *) 0xE2000000; #else void * startAddr = (void *) 0xF2000000; #endif /*defined(VME_183) || defined(SCP_124)*/ UINT nbytes = 0x80000; uint32 pattern = 0x5A5A1234; uint32 status; uint32 blockSize; /* Erasable/Programmable Block Size */ uint32 blockStart; /* Erasable/Programmable Block Start */ uint32 blockEnd; /* Erasable/Programmable Block End */ char * buffAddr; /* start address of alocated buffer */ void * sourceAddr; /* Address of source buffer */ UINT32 temp; printf ("\nTesting the NVM functions.\n"); sourceAddr = malloc (nbytes); /* write pattern into the buffer */ bfill ((char *) sourceAddr, (int) nbytes, (int) pattern); /* * Determine size of erasable/programmable block and malloc buffer of * that size. */ blockSize = cssNVM_get_info (CSS_IDENTIFY, startAddr, 0, NULL, NULL); blockSize = cssNVM_get_info (CSS_ERASE_BLOCK_SIZE, startAddr, 0, NULL, NULL); buffAddr = (char *) malloc (blockSize); /* perfrom unlock */ printf ("Unlocking the flash.\n\n");#if defined(VME_183) || defined(SCP_124) /* 183 cssNVM_lock() accepts only the base address of the bank */ status = cssNVM_lock((UINT32 *)((int)startAddr & 0xf0000000), nbytes, CSS_UNLOCK, NULL);#else status = cssNVM_lock(startAddr, nbytes, CSS_UNLOCK, NULL);#endif if (status != OK) { printf ("cssNVM_lock CSS test FAILED with status %d\n", (UINT32) status); free (sourceAddr); free (buffAddr); return (ERROR); } /* program a pattern and verify it got there */ printf ("Programming the flash.\n\n"); status = cssNVM_program (sourceAddr, startAddr, nbytes, NULL, buffAddr, blockSize, FALSE, NULL); if (status != OK) { printf ("NVM_program Failed with status %x\n", (UINT32) status); free (sourceAddr); free (buffAddr); return (ERROR); } printf ("Comparing the data.\n\n"); for (temp = 0; temp < (nbytes / 4); temp++) { if (*((UINT32 *)startAddr + temp) != *((UINT32 *)sourceAddr + temp)) { printf ("NVM_program data verify failed found (0x%x) should be (0x%x)\n\r", *((UINT32 *)startAddr + temp), *((UINT32 *)sourceAddr + temp)); free (sourceAddr); free (buffAddr); return (ERROR); } } /* erase and verify */ printf ("Erasing the flash.\n\n");#if defined(VME_183) || defined(SCP_124) /* 183 cssNVM_lock() accepts only the base address of the bank */ status = cssNVM_lock((UINT32 *)((int)startAddr & 0xf0000000), nbytes, CSS_UNLOCK, NULL);#else status = cssNVM_lock(startAddr, nbytes, CSS_UNLOCK, NULL);#endif if (status != OK) { printf ("cssNVM_lock FAILED with status %x\n", (UINT32) status); free (sourceAddr); return (ERROR); } /* To Obtain the block size to erase */ blockStart = cssNVM_get_info (CSS_ERASE_SEGMENT_START, startAddr, 0, NULL, NULL); blockEnd = cssNVM_get_info (CSS_ERASE_SEGMENT_END, (startAddr + nbytes), 0, NULL, NULL); status = cssNVM_erase ((void *) blockStart, (blockEnd - blockStart), NULL, 0); if (status != OK) { printf ("NVM_erase Failed with status %x\n", (UINT32) status); free (sourceAddr); free (buffAddr); return (ERROR); } printf ("Verifying the flash was erased.\n\n"); for (temp = 0; temp < (nbytes / 4); temp++) { if (*((UINT32 *)startAddr + temp) != 0xffffffff) { printf ("NVM_erase data verify failed found should be(0xffffffff) not (0x%x)\n", *((UINT32 *)startAddr + temp)); free (sourceAddr); free (buffAddr); return (ERROR); } } printf ("\n NVM Tests PASSED\n\n"); free (sourceAddr); free (buffAddr); return (OK); } /************************************************************************** ** cssTests - The calling function to test the CSS Wrapper Functions. ** This routine calls several tests to verify the CSS Wrapper Functions of the * BSP.** RETURNS: N/A**/void cssTests (void) { STATUS testStatus; printf ("Testing Card Support Service Wrapper Functions.\n\n"); cssGetLocalRamTest(); keyContinue(); testStatus = cssNvmpTest(); keyContinue(); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -