Commit | Line | Data |
---|---|---|
86530b38 AT |
1 | /***************************************************************************** |
2 | ||
3 | The following code is derived, directly or indirectly, from the SystemC | |
4 | source code Copyright (c) 1996-2004 by all Contributors. | |
5 | All Rights reserved. | |
6 | ||
7 | The contents of this file are subject to the restrictions and limitations | |
8 | set forth in the SystemC Open Source License Version 2.4 (the "License"); | |
9 | You may not use this file except in compliance with such restrictions and | |
10 | limitations. You may obtain instructions on how to receive a copy of the | |
11 | License at http://www.systemc.org/. Software distributed by Contributors | |
12 | under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF | |
13 | ANY KIND, either express or implied. See the License for the specific | |
14 | language governing rights and limitations under the License. | |
15 | ||
16 | *****************************************************************************/ | |
17 | ||
18 | ||
19 | ||
20 | #ifndef _TLM_STATUS_H_ | |
21 | #define _TLM_STATUS_H_ | |
22 | ||
23 | //---------------------------------------------------------------------------- | |
24 | /// Class status: status of a the TLM transaction (included in the response) | |
25 | /** | |
26 | * This class defines the status of an initiator request within the a tlm protocol. | |
27 | * \n The status value is set by the target (slave or router) and used by initiators if required | |
28 | * \n A status object is a member of the response structure and is passed | |
29 | * by value. | |
30 | * The status value is set to TLM_ERROR in the constructor. | |
31 | **/ | |
32 | class tlm_status { | |
33 | ||
34 | public: | |
35 | ||
36 | //--------------- | |
37 | // Constructor | |
38 | //--------------- | |
39 | /// @name Constructor | |
40 | /// Status is set to "TLM_ERROR" by default | |
41 | /// @{ | |
42 | tlm_status() : | |
43 | m_status(TLM_ERROR_FLAG) { | |
44 | } | |
45 | /// @} | |
46 | ||
47 | //------------------------------------------ | |
48 | // Data member access methods | |
49 | //------------------------------------------ | |
50 | ||
51 | /** @name success flag accessors | |
52 | * This flag is reset by the target of a transaction to | |
53 | * indicate the success of the transport operation | |
54 | * @{ | |
55 | **/ | |
56 | inline bool is_ok() const { | |
57 | return (!is_error()); | |
58 | } | |
59 | inline void set_ok() { | |
60 | reset_error(); | |
61 | } | |
62 | /* @} */ | |
63 | ||
64 | /** @name Error flag accessors | |
65 | * This flag is set by the target of a transaction to | |
66 | * indicate the failure of the transport operation | |
67 | * @{ | |
68 | **/ | |
69 | inline bool is_error() const { | |
70 | return (m_status & TLM_ERROR_FLAG); | |
71 | } | |
72 | inline void set_error() { | |
73 | m_status |= TLM_ERROR_FLAG; | |
74 | } | |
75 | inline void reset_error() { | |
76 | m_status &= ~TLM_ERROR_FLAG; | |
77 | } | |
78 | /* @} */ | |
79 | ||
80 | /** @name No response flag accessors | |
81 | * This flag is set by the router to | |
82 | * indicate a failure of the routing operation: | |
83 | * no target mapped at the requested address | |
84 | * @{ | |
85 | **/ | |
86 | inline bool is_no_response() const { | |
87 | return (m_status & TLM_NO_RESPONSE_FLAG); | |
88 | } | |
89 | inline void set_no_response() { | |
90 | m_status |= TLM_NO_RESPONSE_FLAG; | |
91 | } | |
92 | inline void reset_no_response() { | |
93 | m_status &= ~TLM_NO_RESPONSE_FLAG; | |
94 | } | |
95 | /* @} */ | |
96 | ||
97 | protected : | |
98 | ||
99 | /// Status content | |
100 | unsigned int m_status; | |
101 | ||
102 | /// Status codes list | |
103 | enum status_list { | |
104 | TLM_SUCCESS = 0, ///< Successful completion | |
105 | TLM_ERROR, ///< Target indicates an error occurs during the access | |
106 | TLM_NO_RESPONSE ///< No target response to the initiator's request | |
107 | ||
108 | }; | |
109 | ||
110 | /// Bits flags definitions | |
111 | enum status_flags { | |
112 | TLM_ERROR_FLAG = 0x01ul << TLM_ERROR, ///< Mask to set and reset TLM_ERROR flag | |
113 | TLM_NO_RESPONSE_FLAG = 0x01ul << TLM_NO_RESPONSE, ///< Mask to set and reset TLM_NO_RESPONSE flag | |
114 | }; | |
115 | ||
116 | }; | |
117 | ||
118 | #endif /* _TLM_STATUS_H_ */ | |
119 | ||
120 |