OpenCSD - CoreSight Trace Decode Library  0.14.0
ocsd_pe_context.h
Go to the documentation of this file.
1 /*
2  * \file ocsd_pe_context.h
3  * \brief OpenCSD : Wrapper class for PE context
4  *
5  * \copyright Copyright (c) 2016, ARM Limited. All Rights Reserved.
6  */
7 
8 /*
9  * Redistribution and use in source and binary forms, with or without modification,
10  * are permitted provided that the following conditions are met:
11  *
12  * 1. Redistributions of source code must retain the above copyright notice,
13  * this list of conditions and the following disclaimer.
14  *
15  * 2. Redistributions in binary form must reproduce the above copyright notice,
16  * this list of conditions and the following disclaimer in the documentation
17  * and/or other materials provided with the distribution.
18  *
19  * 3. Neither the name of the copyright holder nor the names of its contributors
20  * may be used to endorse or promote products derived from this software without
21  * specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND
24  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
26  * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
27  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
30  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33  */
34 #ifndef ARM_OCSD_PE_CONTEXT_H_INCLUDED
35 #define ARM_OCSD_PE_CONTEXT_H_INCLUDED
36 
37 #include "opencsd/ocsd_if_types.h"
38 
46 {
47 public:
48  OcsdPeContext();
49  OcsdPeContext(const ocsd_pe_context *context);
51 
53  OcsdPeContext &operator =(const ocsd_pe_context *context);
54 
55  void resetCtxt();
56 
57  void setSecLevel(const ocsd_sec_level sl) { m_context.security_level = sl; };
58  void setEL(const ocsd_ex_level el) { m_context.exception_level = el; m_context.el_valid = el > ocsd_EL_unknown ? 1 : 0; };
59  void setCtxtID(const uint32_t id) { m_context.context_id = id; m_context.ctxt_id_valid = 1; };
60  void setVMID(const uint32_t id) { m_context.vmid = id; m_context.vmid_valid = 1; };
61  void set64bit(const bool is64bit) { m_context.bits64 = is64bit ? 1 : 0; };
62 
63  const ocsd_sec_level getSecLevel() const { return m_context.security_level; };
64  const ocsd_ex_level getEL() const { return m_context.exception_level; };
65  const bool ELvalid() const { return (m_context.el_valid == 1); };
66  const uint32_t getCtxtID() const { return (m_context.ctxt_id_valid == 1) ? m_context.context_id : 0; };
67  const bool ctxtIDvalid() const { return (m_context.ctxt_id_valid == 1); };
68  const uint32_t getVMID() const { return (m_context.vmid_valid == 1) ? m_context.vmid : 0; };
69  const bool VMIDvalid() const { return (m_context.vmid_valid == 1); };
70 
71  // only allow an immutable copy of the structure out to C-API land.
72  operator const ocsd_pe_context &() const { return m_context; };
73 
74 private:
75  ocsd_pe_context m_context;
76 };
77 
79 {
80  resetCtxt();
81 }
82 
84 {
85  m_context = *context;
86 }
87 
89 {
90  // initialise the context
91  m_context.bits64 = 0;
92  m_context.context_id = 0;
93  m_context.ctxt_id_valid = 0;
94  m_context.el_valid = 0;
95  m_context.exception_level = ocsd_EL_unknown;
96  m_context.security_level = ocsd_sec_secure;
97  m_context.vmid = 0;
98  m_context.vmid_valid = 0;
99 }
100 
102 {
103  m_context = ctxt;
104  return *this;
105 }
106 
108 {
109  m_context = *context;
110  return *this;
111 }
112 
113 
114 #endif // ARM_OCSD_PE_CONTEXT_H_INCLUDED
115 
116 /* End of File ocsd_pe_context.h */
OcsdPeContext::OcsdPeContext
OcsdPeContext()
Definition: ocsd_pe_context.h:78
_ocsd_pe_context::vmid_valid
uint32_t vmid_valid
Definition: ocsd_if_types.h:414
_ocsd_pe_context::security_level
ocsd_sec_level security_level
Definition: ocsd_if_types.h:407
OcsdPeContext
Handler for the ocsd_pe_context structure.
Definition: ocsd_pe_context.h:45
_ocsd_pe_context::bits64
uint32_t bits64
Definition: ocsd_if_types.h:412
ocsd_EL_unknown
@ ocsd_EL_unknown
Definition: ocsd_if_types.h:347
OcsdPeContext::ELvalid
const bool ELvalid() const
Definition: ocsd_pe_context.h:65
OcsdPeContext::setEL
void setEL(const ocsd_ex_level el)
Definition: ocsd_pe_context.h:58
_ocsd_pe_context::ctxt_id_valid
uint32_t ctxt_id_valid
Definition: ocsd_if_types.h:413
OcsdPeContext::getVMID
const uint32_t getVMID() const
Definition: ocsd_pe_context.h:68
_ocsd_pe_context::el_valid
uint32_t el_valid
Definition: ocsd_if_types.h:415
OcsdPeContext::resetCtxt
void resetCtxt()
Definition: ocsd_pe_context.h:88
ocsd_if_types.h
OpenCSD : Standard Types used in the library interfaces.
_ocsd_pe_context::context_id
uint32_t context_id
Definition: ocsd_if_types.h:409
OcsdPeContext::getEL
const ocsd_ex_level getEL() const
Definition: ocsd_pe_context.h:64
_ocsd_pe_context
Definition: ocsd_if_types.h:406
ocsd_ex_level
enum _ocsd_ex_level ocsd_ex_level
OcsdPeContext::~OcsdPeContext
~OcsdPeContext()
Definition: ocsd_pe_context.h:50
OcsdPeContext::operator=
OcsdPeContext & operator=(const OcsdPeContext &ctxt)
Definition: ocsd_pe_context.h:101
OcsdPeContext::ctxtIDvalid
const bool ctxtIDvalid() const
Definition: ocsd_pe_context.h:67
OcsdPeContext::getSecLevel
const ocsd_sec_level getSecLevel() const
Definition: ocsd_pe_context.h:63
ocsd_sec_level
enum _ocsd_sec_level ocsd_sec_level
ocsd_sec_secure
@ ocsd_sec_secure
Definition: ocsd_if_types.h:339
OcsdPeContext::setSecLevel
void setSecLevel(const ocsd_sec_level sl)
Definition: ocsd_pe_context.h:57
OcsdPeContext::setVMID
void setVMID(const uint32_t id)
Definition: ocsd_pe_context.h:60
OcsdPeContext::setCtxtID
void setCtxtID(const uint32_t id)
Definition: ocsd_pe_context.h:59
OcsdPeContext::set64bit
void set64bit(const bool is64bit)
Definition: ocsd_pe_context.h:61
_ocsd_pe_context::vmid
uint32_t vmid
Definition: ocsd_if_types.h:410
OcsdPeContext::VMIDvalid
const bool VMIDvalid() const
Definition: ocsd_pe_context.h:69
OcsdPeContext::getCtxtID
const uint32_t getCtxtID() const
Definition: ocsd_pe_context.h:66
_ocsd_pe_context::exception_level
ocsd_ex_level exception_level
Definition: ocsd_if_types.h:408