📄 tastest.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: * * File %name: tasTest.c % * Instance: kanata_1 * * Description: * * %created_by: rdriscol % * %date_created: Thu Oct 13 10:18:24 2005 % * * Notes: * * History: rcd created. * *END FILE HEADER*********************************************************//*Modification History--------------------01b, 07oct05, rcd added read backs of data to ensure sync.01a, 07oct05, rcd created.*/ /*DESCRIPTIONThis file will verify the functionality of the Universe TAS features. Note: Use the macros below to set the master VME A32 address, shared data area and the TAS address before you start.The masterTasTest and slaveTasTest below should be called from the VME master and slave respectively.*/#define MASTER 1#define SLAVE 0#define MASTER_VME_A32_ADRS 0x40000000#define SHARED_DATA_AREA (SM_OBJ_MEM_ADRS+0x1000)#define TAS_ADRS 0x104180/* includes */#include <vxWorks.h>#include <stdio.h>#include <ioLib.h>#include <taskLib.h>#include "config.h"#include "logLib.h"#include "iosLib.h"#include "intLib.h"#include "h/drv/vme/universe_dy4.h"#include "h/drv/vme/universe2_dy4.h"#include "config.h" /* also includes cwvxxx.h and sysFpgaInt.h */#include "sysLib.h"/* locals *//* external declarations */void sysBusTasClear ( volatile char * addr /* address to be tested-and-cleared */ );/* forward declarations *//**************************************************************************** vmeTasTest - Universe TAS Test Program** This routine is intended to be used to test VME bus TAS for protecting* access to a critical region. The function will switch between master* and slave operation depending on the first parameter. The TAS address* should be a typical "safe" address that is visable by both master and* slave. The critical section should be a typical shared data area.* see macros above.** Parameters:* UINT32 master: TRUE=master, FALSE=slave.* UINT32 tasAdrs: test and set address to be used.** RETURNS: N/A* */void vmeTasTest(UINT32 master, UINT32 tasAdrs) { static BOOL firstTime = TRUE; BOOL keepRunning = TRUE; UINT32 numTas = 0; int locked = FALSE; UINT8* criticalSection; UINT8 checkData = 0; printf (">>> Testing Universe TAS <<<\n\n"); if(master) { criticalSection = (UINT8 *)SHARED_DATA_AREA; printf ("Master on VME Bus: Shared Data Area = 0x%x\n", (UINT32)criticalSection); } else { criticalSection = (UINT8 *) (SHARED_DATA_AREA + MASTER_VME_A32_ADRS); printf ("Slave on VME Bus: Shared Data Area = 0x%x\n",(UINT32) criticalSection); } while(keepRunning) { locked = sysBusTas((UINT8 *) tasAdrs); if(locked) { printf("\n"); printf("tasTest: got sem after %d tries.\n", numTas); printf("-------------------------------\n"); if(firstTime) { *criticalSection = 0xbb; firstTime = FALSE; } numTas=0; checkData = *((volatile char *) criticalSection); printf("tasTest: critical data = 0x%x\n",checkData); if((checkData != 0xbb)&&(checkData != 0x66)) { printf("tasTest: critical data is out of sync.\n"); keepRunning = FALSE; } if(master) *criticalSection = 0xaa; else sysOutByte((UINT32)criticalSection, 0x55); checkData = *((volatile char *) criticalSection); printf("tasTest: set critical data to = 0x%x\n", checkData ); printf("tasTest: holding SEM @ TAS addr=0x%x for 50ms\n", tasAdrs ); taskDelay(50); if(master) { checkData = *((volatile char *) criticalSection); if (checkData == 0xaa) { *criticalSection = 0xbb; checkData = *((volatile char *) criticalSection); printf("tasTest: set critical data to = 0x%x\n", checkData ); } else { printf(">>> Critical data was tampered with!!! <<<\n"); printf(">>> critical data is = 0x%x\n", checkData ); keepRunning = FALSE; } } else { checkData = sysInByte((UINT32)criticalSection ); if (checkData == 0x55) { sysOutByte((UINT32) criticalSection, 0x66); checkData = sysInByte((UINT32)criticalSection ); printf("tasTest: set critical data to = 0x%x\n", checkData); } else { printf(">>> Critical data was tampered with!!! <<<\n"); printf(">>> critical data is now = 0x%x\n", checkData); keepRunning = FALSE; } } printf("tasTest: releasing sem.\n"); printf("----------------------\n\n"); sysBusTasClear((UINT8 *)tasAdrs); taskDelay(0); /* give someone else a chance */ } else { numTas++; if(numTas == 1) printf("tasTest: trying TAS until successful...\n"); } } }/**************************************************************************** masterTasTest - Universe TAS Test Program** This routine calls the vmeTasTest with the master flag and* the defined TAS address.** RETURNS: N/A* */void masterTasTest(void) { return(vmeTasTest(MASTER, TAS_ADRS)); }/**************************************************************************** slaveTasTest - Universe TAS Test Program** This routine calls the vmeTasTest with the slave flag and* the defined TAS address offset with the master VME address.** RETURNS: N/A* */void slaveTasTest(void) { return(vmeTasTest(SLAVE, (TAS_ADRS+MASTER_VME_A32_ADRS))); }/* END OF FILE */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -