📄 estcpu32.cpp
字号:
/* estcpu32.cpp - back end for EST's CPU32 BDM emulator *//* Copyright 1996 Wind River Systems, Inc. */#include "copyright_wrs.h"/*modification history--------------------01j,13nov96,bss clean up.01i,03oct96,bss fixed clash between WRS's ERROR and MSVC's ERROR macros.01h,23jul96,bss Added support for constructor failure.01g,11jul96,bss WIN32 port. Added EXT_FUNC support.01f,01may96,bss tweaked comments.01e,30apr96,bss moved the back end connect/disconnect functionality into Est_T.01d,26apr96,bss coding convention cleanup.01c,16apr96,bss minor changes for Backend_T interface change.01b,07mar96,bss revised for EST API.01a,06dec95,bss written.*//*DESCRIPTIONestcpu32.cpp is the "main" file for Tornado back end support of EST's visionNET emulator for Motorola CPU32 processors.By using this back end, the Tornado target server canuse EST's visionNET emulator to provide debug agency forthe other Tornado tools. This scheme provides a powerful, system-level debugging capability, while consuming no target memory or I/O resources.This module is effectively the "main" of the back end:it is called by the target server to create the back endobject which performs the real work necessary to operate the EST emulator. This vendor-specific, Est_T back end class is defined in estcpu32Backend.h. Est_T specializes the generic back end framework which is provided by the back end abstract base class, Backend_T, and EST's C API to implementthe required back end services. Backend_T is defined in backend.h.The architecture of this module conforms to the following environment:when the target server is invoked, it loads a user-specifiedback end. After loading the back end, the target serverinvokes the back end's initialization function.This function must be named <backendName>Init.In the case of the estcpu32 back end, estcpu32Init()merely creates a single instance of the Est_T back end object,which provides all other back end services.To use this back end, install the back end dynamically-linkedlibrary in ${WIND_BASE}/host/${WIND_HOST_TYPE}/lib/backend,and invoke the target server with the '-B' option to specifywhich back end to use: % tgtsvr ... -B estcpu32 <emulatorHostName> &where estcpu32 is the name of this back end, and <emulatorHostName> is the host name assigned tothe visionNET emulator.Caveats:The back end will not function correctly unlessthe emulator has been correctly configured withthe emulator's 'cf' and 'cs' commands. In particular,you must configure the chip-selects, and enable the locking of interrupts when single-stepping. For more information, see the _visionCONTROL and visionNET User's Manual_ from EST and the application note,_Background Mode Debugging with EST's visionNETEmulator_, provided with the back end.*//* includes */#ifdef WIN32/* fix clash between Wind River's ERROR and MSVC's ERROR macros. */#ifdef ERROR#undef ERROR#endif#include <windows.h>#endif /* #ifdef WIN32 */#include <fcntl.h>#include <signal.h>#ifndef WIN32#include <sys/filio.h>#include <sys/time.h>#endif/* re-enable Wind River's ERROR macro. */#ifdef WIN32#ifdef ERROR#undef ERROR#endif /* #ifdef ERROR */#define ERROR (-1)#endif /* #ifdef WIN32 */#include "host.h"#include "tgtlib.h"#include "wpwrutil.h"#include "checksum.h"#include "estcpu32Backend.h"/* forwards */// C linkage is needed so that the target server will// know the name of the initialization function.extern "C" STATUS estcpu32Init (char * tgtName, u_int timeout, u_int retryNum, char * devName, u_int param, TGT_OPS * pTgtOps, EXT_FUNCS * pExtFuncs);#ifndef WIN32/********************************************************************************* estcpu32SigInit - perform extra signal initialization needed by back end.** Masks SIGALRM which is sent by FlexLM. If SIGALRM is not masked,* select () calls in EST API are aborted causing EST_Service () to* fail. This is SPR 6343.*/LOCAL void estcpu32SigInit () { sigset_t ss; // set of signals to mask. // mask SIGALRM which is due to FlexLM. sigemptyset (&ss); sigaddset (&ss, SIGALRM); sigprocmask (SIG_BLOCK, &ss, NULL); }#endif /* #ifndef WIN32 *//********************************************************************************* estcpu32Init - initialize the estcpu32 interface.** The target server calls this function after loading the back end * in order to initialize the back end. This function allocates the back * end object, and initializes the TGT_OPS structure, which provides the* information the target server needs to operate the back end. The * back end objects's constructors do all of the actual work. This function* must have the name <backendName>Init, or estcpu32Init in the case* of the estcpu32 back end.*/STATUS estcpu32Init ( char * tgtName, /* target name to connect to */ u_int timeout, /* the default timeout value in second */ u_int recallNum, /* nb of time a request is send before timeout*/ char * pTtyDevName, /* serial line device name (unused) */ u_int baudRate, /* serial line baud rate (unused) */ TGT_OPS * pTgtOps, /* backend function */ EXT_FUNCS * pExtFuncs /* external functions addresses (WIN32)*/ ) { Backend_T * pTheBkEnd; // Signal Initialization. // // This is a work-around for SPR 6343: that FlexLM periodically // generates SIGALRMs, causing the EST API's select() call // to abort. #ifndef WIN32 estcpu32SigInit (); #endif // Create Backend pTheBkEnd = new Est_T (tgtName, timeout, recallNum, pTtyDevName, baudRate, pTgtOps, pExtFuncs); if (pTheBkEnd == NULL) { WPWR_LOG_ERR ("estcpu32Init(): new() failed.\n"); return (ERROR); } if ( ! pTheBkEnd->isValid_m ()) { WPWR_LOG_ERR ("estcpu32Init(): back end initialization failed.\n"); return (ERROR); } return (OK); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -