trc_mem_acc_mapper.h
Go to the documentation of this file.
/*
* \file trc_mem_acc_mapper.h
* \brief OpenCSD :
*
* \copyright Copyright (c) 2015, ARM Limited. All Rights Reserved.
*/
/*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef ARM_TRC_MEM_ACC_MAPPER_H_INCLUDED
#define ARM_TRC_MEM_ACC_MAPPER_H_INCLUDED
#include <vector>
#include "opencsd/ocsd_if_types.h"
#include "interfaces/trc_tgt_mem_access_i.h"
#include "interfaces/trc_error_log_i.h"
#include "mem_acc/trc_mem_acc_base.h"
#include "mem_acc/trc_mem_acc_cache.h"
typedef enum _memacc_mapper_t {
MEMACC_MAP_GLOBAL,
} memacc_mapper_t;
class TrcMemAccMapper : public ITargetMemAccess
{
public:
TrcMemAccMapper();
TrcMemAccMapper(bool using_trace_id);
virtual ~TrcMemAccMapper();
// decoder memory access interface
virtual ocsd_err_t ReadTargetMemory( const ocsd_vaddr_t address,
const uint8_t cs_trace_id,
const ocsd_mem_space_acc_t mem_space,
uint32_t *num_bytes,
uint8_t *p_buffer);
// mapper memory area configuration interface
// add an accessor to this map
virtual ocsd_err_t AddAccessor(TrcMemAccessorBase *p_accessor, const uint8_t cs_trace_id) = 0;
// remove a specific accessor
virtual ocsd_err_t RemoveAccessor(const TrcMemAccessorBase *p_accessor) = 0;
// clear all attached accessors from the map
void RemoveAllAccessors();
// remove a single accessor based on address.
ocsd_err_t RemoveAccessorByAddress(const ocsd_vaddr_t st_address, const ocsd_mem_space_acc_t mem_space, const uint8_t cs_trace_id = 0);
// set the error log.
void setErrorLog(ITraceErrorLog *err_log_i);
// print out the ranges in this mapper.
virtual void logMappedRanges() = 0;
protected:
virtual bool findAccessor(const ocsd_vaddr_t address, const ocsd_mem_space_acc_t mem_space, const uint8_t cs_trace_id) = 0; // set m_acc_curr if found valid range, leave unchanged if not.
virtual bool readFromCurrent(const ocsd_vaddr_t address, const ocsd_mem_space_acc_t mem_space, const uint8_t cs_trace_id) = 0;
virtual TrcMemAccessorBase *getFirstAccessor() = 0;
virtual TrcMemAccessorBase *getNextAccessor() = 0;
virtual void clearAccessorList() = 0;
void LogMessage(const std::string &msg);
void LogWarn(const ocsd_err_t err, const std::string &msg);
TrcMemAccessorBase *m_acc_curr; // most recently used - try this first.
uint8_t m_trace_id_curr; // trace ID for the current accessor
const bool m_using_trace_id; // true if we are using separate memory spaces by TraceID.
ITraceErrorLog *m_err_log; // error log to print out mappings on request.
TrcMemAccCache m_cache; // memory accessor caching.
};
// address spaces common to all sources using this mapper.
// trace id unused.
class TrcMemAccMapGlobalSpace : public TrcMemAccMapper
{
public:
TrcMemAccMapGlobalSpace();
virtual ~TrcMemAccMapGlobalSpace();
// mapper creation interface - prevent overlaps
virtual ocsd_err_t AddAccessor(TrcMemAccessorBase *p_accessor, const uint8_t cs_trace_id);
// print out the ranges in this mapper.
virtual void logMappedRanges();
protected:
virtual bool findAccessor(const ocsd_vaddr_t address, const ocsd_mem_space_acc_t mem_space, const uint8_t cs_trace_id);
virtual bool readFromCurrent(const ocsd_vaddr_t address,const ocsd_mem_space_acc_t mem_space, const uint8_t cs_trace_id);
virtual TrcMemAccessorBase *getFirstAccessor();
virtual TrcMemAccessorBase *getNextAccessor();
virtual void clearAccessorList();
virtual ocsd_err_t RemoveAccessor(const TrcMemAccessorBase *p_accessor);
std::vector<TrcMemAccessorBase *> m_acc_global;
std::vector<TrcMemAccessorBase *>::iterator m_acc_it;
};
#endif // ARM_TRC_MEM_ACC_MAPPER_H_INCLUDED
/* End of File trc_mem_acc_mapper.h */
trc_mem_acc_base.h
OpenCSD : Memory accessor base class.
TrcMemAccMapper::getNextAccessor
virtual TrcMemAccessorBase * getNextAccessor()=0
ocsd_err_t
enum _ocsd_err_t ocsd_err_t
TrcMemAccMapper::RemoveAccessorByAddress
ocsd_err_t RemoveAccessorByAddress(const ocsd_vaddr_t st_address, const ocsd_mem_space_acc_t mem_space, const uint8_t cs_trace_id=0)
TrcMemAccMapGlobalSpace::m_acc_global
std::vector< TrcMemAccessorBase * > m_acc_global
Definition: trc_mem_acc_mapper.h:125
TrcMemAccMapper::LogMessage
void LogMessage(const std::string &msg)
TrcMemAccMapper::RemoveAllAccessors
void RemoveAllAccessors()
ITraceErrorLog
Error logging interface.
Definition: trc_error_log_i.h:56
memacc_mapper_t
enum _memacc_mapper_t memacc_mapper_t
TrcMemAccMapper::logMappedRanges
virtual void logMappedRanges()=0
TrcMemAccMapGlobalSpace::logMappedRanges
virtual void logMappedRanges()
TrcMemAccMapper::readFromCurrent
virtual bool readFromCurrent(const ocsd_vaddr_t address, const ocsd_mem_space_acc_t mem_space, const uint8_t cs_trace_id)=0
TrcMemAccessorBase
Memory range to access by trace decoder.
Definition: trc_mem_acc_base.h:52
TrcMemAccMapper::m_cache
TrcMemAccCache m_cache
Definition: trc_mem_acc_mapper.h:99
TrcMemAccCache
Definition: trc_mem_acc_cache.h:58
ocsd_if_types.h
OpenCSD : Standard Types used in the library interfaces.
MEMACC_MAP_GLOBAL
Definition: trc_mem_acc_mapper.h:47
TrcMemAccMapGlobalSpace::readFromCurrent
virtual bool readFromCurrent(const ocsd_vaddr_t address, const ocsd_mem_space_acc_t mem_space, const uint8_t cs_trace_id)
TrcMemAccMapper::ReadTargetMemory
virtual ocsd_err_t ReadTargetMemory(const ocsd_vaddr_t address, const uint8_t cs_trace_id, const ocsd_mem_space_acc_t mem_space, uint32_t *num_bytes, uint8_t *p_buffer)
TrcMemAccMapper::RemoveAccessor
virtual ocsd_err_t RemoveAccessor(const TrcMemAccessorBase *p_accessor)=0
ocsd_vaddr_t
uint64_t ocsd_vaddr_t
Definition: ocsd_if_types.h:308
TrcMemAccMapper::m_err_log
ITraceErrorLog * m_err_log
Definition: trc_mem_acc_mapper.h:98
TrcMemAccMapper::AddAccessor
virtual ocsd_err_t AddAccessor(TrcMemAccessorBase *p_accessor, const uint8_t cs_trace_id)=0
trc_error_log_i.h
OpenCSD :
TrcMemAccMapper::clearAccessorList
virtual void clearAccessorList()=0
ITargetMemAccess
Interface to target memory access.
Definition: trc_tgt_mem_access_i.h:56
TrcMemAccMapper::findAccessor
virtual bool findAccessor(const ocsd_vaddr_t address, const ocsd_mem_space_acc_t mem_space, const uint8_t cs_trace_id)=0
trc_mem_acc_cache.h
OpenCSD : Memory accessor cache.
TrcMemAccMapper::getFirstAccessor
virtual TrcMemAccessorBase * getFirstAccessor()=0
TrcMemAccMapper::setErrorLog
void setErrorLog(ITraceErrorLog *err_log_i)
TrcMemAccMapper::LogWarn
void LogWarn(const ocsd_err_t err, const std::string &msg)
TrcMemAccMapper::~TrcMemAccMapper
virtual ~TrcMemAccMapper()
TrcMemAccMapper::m_acc_curr
TrcMemAccessorBase * m_acc_curr
Definition: trc_mem_acc_mapper.h:95
TrcMemAccMapper
Definition: trc_mem_acc_mapper.h:50
TrcMemAccMapGlobalSpace::~TrcMemAccMapGlobalSpace
virtual ~TrcMemAccMapGlobalSpace()
TrcMemAccMapGlobalSpace::getFirstAccessor
virtual TrcMemAccessorBase * getFirstAccessor()
TrcMemAccMapGlobalSpace::m_acc_it
std::vector< TrcMemAccessorBase * >::iterator m_acc_it
Definition: trc_mem_acc_mapper.h:126
_memacc_mapper_t
_memacc_mapper_t
Definition: trc_mem_acc_mapper.h:46
TrcMemAccMapper::m_trace_id_curr
uint8_t m_trace_id_curr
Definition: trc_mem_acc_mapper.h:96
TrcMemAccMapGlobalSpace::clearAccessorList
virtual void clearAccessorList()
TrcMemAccMapGlobalSpace::TrcMemAccMapGlobalSpace
TrcMemAccMapGlobalSpace()
ocsd_mem_space_acc_t
enum _ocsd_mem_space_acc_t ocsd_mem_space_acc_t
TrcMemAccMapGlobalSpace::RemoveAccessor
virtual ocsd_err_t RemoveAccessor(const TrcMemAccessorBase *p_accessor)
TrcMemAccMapper::m_using_trace_id
const bool m_using_trace_id
Definition: trc_mem_acc_mapper.h:97
trc_tgt_mem_access_i.h
TrcMemAccMapGlobalSpace::findAccessor
virtual bool findAccessor(const ocsd_vaddr_t address, const ocsd_mem_space_acc_t mem_space, const uint8_t cs_trace_id)
TrcMemAccMapGlobalSpace::AddAccessor
virtual ocsd_err_t AddAccessor(TrcMemAccessorBase *p_accessor, const uint8_t cs_trace_id)
TrcMemAccMapGlobalSpace::getNextAccessor
virtual TrcMemAccessorBase * getNextAccessor()
TrcMemAccMapGlobalSpace
Definition: trc_mem_acc_mapper.h:105
TrcMemAccMapper::TrcMemAccMapper
TrcMemAccMapper()