📄 acecpu32backend.cpp
字号:
/********************************************************************************* Ace_T::contextResume_m - resume a suspended context.** This method returns the target to the RUN state. Only the system* context is supported.*/UINT32 Ace_T::contextResume_m (WDB_CTX * pContext) { int status; if (pContext->contextType != WDB_CTX_SYSTEM) { return (WDB_ERR_AGENT_MODE); } // Clear exception state before resuming target. if (isExcState_m ()) { UINT32 status; status = excStateExit_m (); if (status != WDB_OK) { WPWR_LOG_ERR ("Ace_T::excStateExit_m () failed!\n"); } } ACE_OperatingMode oldState; // Enter background mode. if (stateBDM_m (oldState) != WDB_OK) { return (WDB_ERR_AGENT_MODE); } status = ::ACE_StartTarget (emulator_, 1, // Resume from current PC 0); return (wdbErrFigure_m ("ACE_StartTarget ()", status, WDB_ERR_PROC_FAILED)); }/********************************************************************************* Ace_T::eventpointAdd_m - set an event point.** Note: only software break points on text access are supported.*/UINT32 Ace_T::eventpointAdd_m ( WDB_EVTPT_ADD_DESC * pEventpoint, UINT32 * pEvtptNum ) { ACE_OperatingMode oldState; TGT_ADDR_T tgtAddr; // where to set breakpoint int status; // ACE return value // XXX - WDB_EVT_HW_BP is not supported by ACE's API. if ( (pEventpoint->evtType != WDB_EVT_BP) || (pEventpoint->context.contextType != WDB_CTX_SYSTEM)) { return (WDB_ERR_INVALID_PARAMS); } // Enter background mode. if (stateBDM_m (oldState) != WDB_OK) { return (WDB_ERR_AGENT_MODE); } tgtAddr = * (TGT_ADDR_T *) pEventpoint->args; status = ::ACE_AddBreakpoint (emulator_, (ACE_TargetAddress) tgtAddr); if (status != ACE_SUCCESS) { (void) stateRestore_m (oldState); return (wdbErrFigure_m ("ACE_AddBreakpoint ()", status, WDB_ERR_PROC_FAILED)); } *pEvtptNum = tgtAddr; // using tgtAddr for ID makes deletes easier. return (stateRestore_m (oldState)); }/********************************************************************************* Ace_T::eventpointDelete_m - remove an event point.*/UINT32 Ace_T::eventpointDelete_m (WDB_EVTPT_DEL_DESC * pEventpoint) { int status; // ACE return value ACE_OperatingMode oldState; if (pEventpoint->evtType != WTX_EVENT_TEXT_ACCESS) { return (WDB_ERR_INVALID_PARAMS); } // Enter background mode. if (stateBDM_m (oldState) != WDB_OK) { return (WDB_ERR_AGENT_MODE); } status = ::ACE_DeleteBreakpoint (emulator_, (ACE_TargetAddress) pEventpoint->evtptId); if (status != ACE_SUCCESS) { (void) stateRestore_m (oldState); return (wdbErrFigure_m ("ACE_DeleteBreakpoint ()", status, WDB_ERR_PROC_FAILED)); } return (stateRestore_m (oldState)); }/********************************************************************************* Ace_T::eventGet_m - get target event data.** This method is called by the target server after an event* occurs to get information about the event. This method,* fetches the event at the head of the event queue, passes* the WDB event data to the target server, and deletes the* event.*/UINT32 Ace_T::eventGet_m (WDB_EVT_DATA * pEvtData) { int status; // Check if there is an emulator event. status = ::ACE_Service (emulator_); if (status != ACE_SUCCESS) { WPWR_LOG_ERR ("ACE_Service () failed in Ace_T::eventGet_m ()!\n"); } // Get the event. eventQueueGet_m (pEvtData); return (WDB_OK); }/********************************************************************************* Ace_T::contextCont_m - continue the execution of a context.** This method returns the system to the RUN state. Only the system* context is supported.*/UINT32 Ace_T::contextCont_m (WDB_CTX * pContext) { int status; if (pContext->contextType != WDB_CTX_SYSTEM) { return (WDB_ERR_AGENT_MODE); } // Clear exception state before resuming target. if (isExcState_m ()) { UINT32 status; status = excStateExit_m (); if (status != WDB_OK) { WPWR_LOG_ERR ("Ace_T::excStateExit_m () failed!\n"); } } ACE_OperatingMode oldState; // Enter background mode. if (stateBDM_m (oldState) != WDB_OK) { return (WDB_ERR_AGENT_MODE); } status = ::ACE_StartTarget (emulator_, 1, // Resume from current PC 0); return (wdbErrFigure_m ("ACE_StartTarget ()", status, WDB_ERR_PROC_FAILED)); }/********************************************************************************* Ace_T::contextStep_m - step a context.** This method steps the system context. Stepping of other contexts* are not supported.** This method will fail if the emulator is not configured to* lock interrupts at level 7 when stepping.*/UINT32 Ace_T::contextStep_m (WDB_CTX_STEP_DESC * pContextStep) { int status; ACE_OperatingMode oldState; if (pContextStep->context.contextType != WDB_CTX_SYSTEM) { return (WDB_ERR_AGENT_MODE); } // Enter background mode. // Note: background mode is not exited - the step is assumed to succeed! if (stateBDM_m (oldState) != WDB_OK) { return (WDB_ERR_AGENT_MODE); } // Clear exception state before resuming target. if (isExcState_m ()) { UINT32 status; status = excStateExit_m (FALSE); if (status != WDB_OK) { WPWR_LOG_ERR ("Ace_T::excStateExit_m () failed!\n"); } } // Note an interrupt lock is not required here because // the ACE's SuperBDM emulator locks interupts automatically // when stepping if you use the 'CF SIL 7' when configuring // the emulator's lock level for stepping. if ((pContextStep->startAddr == 0x0) && (pContextStep->endAddr == 0x0)) { // Step one machine instruction. status = ::ACE_StepTarget (emulator_, 1); // number of instructions to step. } else { // Step range. // GDB expects a step range command to stop on the ending address // specified in the step range requace. If step operation does not // stop on this address, GDB will keep stepping until the PC contains // an address where C source starts. Unfortunately, when // the ACE emulator performs a step range (FS), it stops // at an address greater than the ending address. // By decrementing endAddr by 1, we ensure that the step range // command ends on the ending address specified by GDB. ACE_TargetAddress endAddr = pContextStep->endAddr - 1; ACE_TargetAddress startAddr = pContextStep->startAddr; if (endAddr < startAddr ) { return (WDB_ERR_INVALID_PARAMS); } status = ::ACE_StepTargetOutOf (emulator_, startAddr, endAddr); // Generate a breakpoint event, because the tools // expect one. if (status == ACE_SUCCESS) { bpEventGen_m (); } } // Note: no interrupt unlock is required because the firwmare // does the work. return (wdbErrFigure_m ("ACE_StepTarget[OutOf] ()", status, WDB_ERR_PROC_FAILED)); }/********************************************************************************* Ace_T::evtPending_m - check if an event is pending in the back end.** The target server calls this method to check if an event is pending.* If so, the target server will service the event by calling* Backend_T::eventGet_m().*/BOOL Ace_T::evtPending_m (void) { int status; // check if there is a new emulator event. status = ::ACE_Service (emulator_); if (status != ACE_SUCCESS) { WPWR_LOG_ERR ("ACE_Service () failed in Ace_T::evtPending_m ()!\n"); return (FALSE); } return (isEvent_); // isEvent_ is set the by event call back. }/********************************************************************************* Ace_T::evtPendingClear_m - clear the event which was received.** The target server calls this method after getting an event* with Backend_T::eventGet_m() to release any which may have* been used to manage the event.*/void Ace_T::evtPendingClear_m (void) { if (eventQueue_.isEmpty ()) { isEvent_ = FALSE; // Clear event } }/********************************************************************************* Ace_T::serviceCall_m - perform a vendor-specific service.** For this back end, no extra services are provided. Otherwise,* this method could be used to invoke them.*/UINT32 Ace_T::serviceCall_m (u_long procNum, FUNCPTR inProc, char * in, FUNCPTR outProc, char * out) { return (somaUINT32 ("serviceCall_m")); }/********************************************************************************* Ace_T::freeResultArgs_m - frees resources used by a back end method.** This method frees any resources which were used when the* last back end method was invoked.*/BOOL Ace_T::freeResultArgs_m (void) { return (TRUE); }/********************************************************************************* Ace_T::cacheTxtUpdate_m - Update target's instruction cache.** This method is trivial because CPU32 lacks an instruction cache.*/UINT32 Ace_T::cacheTxtUpdate_m (WDB_MEM_REGION * pMemRegion) { return (WDB_OK); }////////////////////////////////////////////////////////////////////////////////// Ace_T helper methods/********************************************************************************* Ace_T::wdbErrFigure_m - Figure WDB error code from ACE return status.** This function maps ACE return status onto WDB error codes. ACE_FAILURE is* mapped to a programer-specified wdbCode.*/UINT32 Ace_T::wdbErrFigure_m ( const char * pStr, int status, UINT32 wdbDefaultCode ) { UINT32 retVal; switch (status) { case ACE_SUCCESS: retVal = WDB_OK; break; case ACE_FAILURE: retVal = wdbDefaultCode; WPWR_LOG_WARN ("%s : ACE_FAILURE - %s!\n", pStr, ::ACE_ErrorImage (status)); break; case ACE_PROTOCOL_ERROR: retVal = WDB_ERR_COMMUNICATION; WPWR_LOG_ERR ("%s : ACE_PROTOCOL_ERROR - %s!\n", pStr, ::ACE_ErrorImage (status)); break; case ACE_TIMEDOUT: retVal = WDB_ERR_COMMUNICATION; WPWR_LOG_ERR ("%s : ACE_TIMEDOUT - %s!\n", pStr, ::ACE_ErrorImage (status)); break; case ACE_INTERNAL_ERROR: retVal = WDB_ERR_PROC_FAILED; WPWR_LOG_ERR ("%s : ACE_INTERNAL_ERROR - %s!\n", pStr, ::ACE_ErrorImage (status)); default: retVal = wdbDefaultCode; WPWR_LOG_ERR ("%s : Unknown ACE - %s!\n", pStr); break; } return (retVal); }/********************************************************************************* Ace_T::bpEventGen_m - generate a dummy breakpoint event. ** This method generates the breakpoint event which the Tornado tools expect * upon the completion of a step-range requace.*/void Ace_T::bpEventGen_m () { ACE_Event dummyEvent; UINT32 status; uint32 aceRegBuf; // buffer for reading a register // Create dummy breakpoint event. ::memset (&dummyEvent, 0x00, sizeof (dummyEvent)); dummyEvent.any.type = ACE_BREAKPOINT; status = regGetOne_m (ACE_REG_PC, &aceRegBuf); if (status != WDB_OK) { aceRegBuf = 0xfefefefe; WPWR_LOG_ERR ("Ace_T::regGetOne_m () failed!\n"); } dummyEvent.bp.address = (TGT_ADDR_T) aceRegBuf; // PC // Queue pEvent Event_T * pWdbEvent = new Event_T (&dummyEvent); eventQueuePut_m (pWdbEvent); }/********************************************************************************* Ace_T::eventCallBack - handles asynchronous events in ACE API.** The ACE API calls this function whenever it detects a target* event. This function handles the event by constructing an* Event_T object with the appropriate event information, and* enqueuing the event.*/void Ace_T::eventCallBack ( ACE_ConnectionHandle emulator, ACE_Event * pEvent, void * pData ) { // Get a back end pointer Ace_T * pBackend = pTheAceBkEnd_s (); // Create an appropriate Event_T object Event_T * pWdbEvent = new Event_T (pEvent); // Queue the event pBackend->eventQueuePut_m (pWdbEvent); }/********************************************************************************* Ace_T::stateBkm_m - Enter background (BDM) mode.** This method saves the old target state and enters background mode* so that debugging operations may be performed.**/UINT32 Ace_T::stateBDM_m (ACE_OperatingMode & oldState)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -