xref: /freebsd/contrib/opencsd/decoder/source/mem_acc/trc_mem_acc_cb.cpp (revision c120c5646da1a1d2c4d90fd069a7e2a8d559eb46)
1 /*!
2  * \file       trc_mem_acc_cb.cpp
3  * \brief      OpenCSD : Trace Mem accessor - callback function
4  *
5  * \copyright  Copyright (c) 2015, ARM Limited. All Rights Reserved.
6  */
7 
8 #include "mem_acc/trc_mem_acc_cb.h"
9 
TrcMemAccCB(const ocsd_vaddr_t s_address,const ocsd_vaddr_t e_address,const ocsd_mem_space_acc_t mem_space)10 TrcMemAccCB::TrcMemAccCB(const ocsd_vaddr_t s_address,
11                 const ocsd_vaddr_t e_address,
12                 const ocsd_mem_space_acc_t mem_space) :
13     TrcMemAccessorBase(MEMACC_CB_IF, s_address, e_address),
14     m_p_CBclass(0),
15     m_p_CBfn(0),
16     m_p_cbfn_context(0)
17 {
18     setMemSpace(mem_space);
19 }
20 
21 /** Memory access override - allow decoder to read bytes from the buffer. */
readBytes(const ocsd_vaddr_t address,const ocsd_mem_space_acc_t memSpace,const uint8_t trcID,const uint32_t reqBytes,uint8_t * byteBuffer)22 const uint32_t TrcMemAccCB::readBytes(const ocsd_vaddr_t address, const ocsd_mem_space_acc_t memSpace, const uint8_t trcID, const uint32_t reqBytes, uint8_t *byteBuffer)
23 {
24     // if we have a callback object, use it to call back.
25     if(m_p_CBclass)
26         return m_p_CBclass->readBytes(address,memSpace,reqBytes,byteBuffer);
27     if(m_p_CBfn)
28         return m_p_CBfn(m_p_cbfn_context, address,memSpace,reqBytes,byteBuffer);
29     if (m_p_CBIDfn)
30         return m_p_CBIDfn(m_p_cbfn_context, address, memSpace, trcID, reqBytes, byteBuffer);
31     return 0;
32 }
33 
34 /* End of File trc_mem_acc_cb.cpp */
35