OpenCSD - CoreSight Trace Decode Library  1.3.3
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 */
Handler for the ocsd_pe_context structure.
void setCtxtID(const uint32_t id)
void setVMID(const uint32_t id)
const bool ELvalid() const
void setEL(const ocsd_ex_level el)
const uint32_t getVMID() const
const ocsd_ex_level getEL() const
const bool ctxtIDvalid() const
void set64bit(const bool is64bit)
OcsdPeContext & operator=(const OcsdPeContext &ctxt)
void setSecLevel(const ocsd_sec_level sl)
const bool VMIDvalid() const
const ocsd_sec_level getSecLevel() const
const uint32_t getCtxtID() const
enum _ocsd_sec_level ocsd_sec_level
enum _ocsd_ex_level ocsd_ex_level
@ ocsd_EL_unknown
@ ocsd_sec_secure
OpenCSD : Standard Types used in the library interfaces.
ocsd_sec_level security_level
ocsd_ex_level exception_level
uint32_t ctxt_id_valid