xref: /freebsd-src/contrib/opencsd/decoder/include/interfaces/trc_tgt_mem_access_i.h (revision 46e6e290975f19ea62d03f90ac3e523af4dae557)
1c120c564SAndrew Turner /*
2c120c564SAndrew Turner  * \file       trc_tgt_mem_access_i.h
3c120c564SAndrew Turner  * \brief      OpenCSD : Target memory read interface.
4c120c564SAndrew Turner  *
5c120c564SAndrew Turner  * \copyright  Copyright (c) 2015, ARM Limited. All Rights Reserved.
6c120c564SAndrew Turner  */
7c120c564SAndrew Turner 
8c120c564SAndrew Turner /*
9c120c564SAndrew Turner  * Redistribution and use in source and binary forms, with or without modification,
10c120c564SAndrew Turner  * are permitted provided that the following conditions are met:
11c120c564SAndrew Turner  *
12c120c564SAndrew Turner  * 1. Redistributions of source code must retain the above copyright notice,
13c120c564SAndrew Turner  * this list of conditions and the following disclaimer.
14c120c564SAndrew Turner  *
15c120c564SAndrew Turner  * 2. Redistributions in binary form must reproduce the above copyright notice,
16c120c564SAndrew Turner  * this list of conditions and the following disclaimer in the documentation
17c120c564SAndrew Turner  * and/or other materials provided with the distribution.
18c120c564SAndrew Turner  *
19c120c564SAndrew Turner  * 3. Neither the name of the copyright holder nor the names of its contributors
20c120c564SAndrew Turner  * may be used to endorse or promote products derived from this software without
21c120c564SAndrew Turner  * specific prior written permission.
22c120c564SAndrew Turner  *
23c120c564SAndrew Turner  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND
24c120c564SAndrew Turner  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25c120c564SAndrew Turner  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
26c120c564SAndrew Turner  * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
27c120c564SAndrew Turner  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28c120c564SAndrew Turner  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29c120c564SAndrew Turner  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
30c120c564SAndrew Turner  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31c120c564SAndrew Turner  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32c120c564SAndrew Turner  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33c120c564SAndrew Turner  */
34c120c564SAndrew Turner 
35c120c564SAndrew Turner #ifndef ARM_TRC_TGT_MEM_ACCESS_I_H_INCLUDED
36c120c564SAndrew Turner #define ARM_TRC_TGT_MEM_ACCESS_I_H_INCLUDED
37c120c564SAndrew Turner 
38c120c564SAndrew Turner /*!
39c120c564SAndrew Turner  * @class ITargetMemAccess
40c120c564SAndrew Turner  *
41c120c564SAndrew Turner  * @brief Interface to target memory access.
42c120c564SAndrew Turner  *
43c120c564SAndrew Turner  * @ingroup ocsd_interfaces
44c120c564SAndrew Turner  *
45c120c564SAndrew Turner  * Read Target memory call is used by the decoder to access the memory location in the
46c120c564SAndrew Turner  * target memory space for the next instruction(s) to be traced.
47c120c564SAndrew Turner  *
48c120c564SAndrew Turner  * Memory data returned is to be little-endian.
49c120c564SAndrew Turner  *
50c120c564SAndrew Turner  * The implementator of this interface could either use file(s) containing dumps of memory
51c120c564SAndrew Turner  * locations from the target, be an elf file reader extracting code, or a live target
52c120c564SAndrew Turner  * connection, depending on the tool execution context.
53c120c564SAndrew Turner  *
54c120c564SAndrew Turner  *
55c120c564SAndrew Turner  */
56c120c564SAndrew Turner class ITargetMemAccess
57c120c564SAndrew Turner {
58c120c564SAndrew Turner public:
ITargetMemAccess()59c120c564SAndrew Turner     ITargetMemAccess() {}; /**< default interface constructor */
~ITargetMemAccess()60c120c564SAndrew Turner     virtual ~ITargetMemAccess() {}; /**< default interface destructor */
61c120c564SAndrew Turner 
62c120c564SAndrew Turner     /*!
63c120c564SAndrew Turner      * Read a block of target memory into supplied buffer.
64c120c564SAndrew Turner      *
65c120c564SAndrew Turner      * Bytes read set less than bytes required, along with a success return code indicates full memory
66c120c564SAndrew Turner      * location not accessible. Function will return all accessible bytes from the address up to the point
67c120c564SAndrew Turner      * where the first inaccessible location appears.
68c120c564SAndrew Turner      *
69c120c564SAndrew Turner      * The cs_trace_id associates a memory read with a core. Different cores may have different memory spaces,
70c120c564SAndrew Turner      * the memory access may take this into account. Access will first look in the registered memory areas
71c120c564SAndrew Turner      * associated with the ID, failing that will look into any global memory spaces.
72c120c564SAndrew Turner      *
73c120c564SAndrew Turner      * @param address : Address to access.
74c120c564SAndrew Turner      * @param cs_trace_id : protocol source trace ID.
75c120c564SAndrew Turner      * @param mem_space : Memory space to access, (secure, non-secure, optionally with EL, or any).
76c120c564SAndrew Turner      * @param num_bytes : [in] Number of bytes required. [out] Number of bytes actually read.
77c120c564SAndrew Turner      * @param *p_buffer : Buffer to fill with the bytes.
78c120c564SAndrew Turner      *
79c120c564SAndrew Turner      * @return ocsd_err_t : OCSD_OK on successful access (including memory not available)
80c120c564SAndrew Turner      */
81c120c564SAndrew Turner     virtual ocsd_err_t ReadTargetMemory(   const ocsd_vaddr_t address,
82c120c564SAndrew Turner                                             const uint8_t cs_trace_id,
83c120c564SAndrew Turner                                             const ocsd_mem_space_acc_t mem_space,
84c120c564SAndrew Turner                                             uint32_t *num_bytes,
85c120c564SAndrew Turner                                             uint8_t *p_buffer) = 0;
86*46e6e290SRuslan Bukin 
87*46e6e290SRuslan Bukin     /*!
88*46e6e290SRuslan Bukin      * Invalidate any caching that the memory accessor functions are using.
89*46e6e290SRuslan Bukin      * Generally called when a memory context changes in the trace.
90*46e6e290SRuslan Bukin      *
91*46e6e290SRuslan Bukin      * @param cs_trace_id : protocol source trace ID.
92*46e6e290SRuslan Bukin      */
93*46e6e290SRuslan Bukin     virtual void InvalidateMemAccCache(const uint8_t cs_trace_id) = 0;
94c120c564SAndrew Turner };
95c120c564SAndrew Turner 
96c120c564SAndrew Turner 
97c120c564SAndrew Turner #endif // ARM_TRC_TGT_MEM_ACCESS_I_H_INCLUDED
98c120c564SAndrew Turner 
99c120c564SAndrew Turner /* End of File trc_tgt_mem_access_i.h */
100