summaryrefslogtreecommitdiffstats
path: root/src/usr/pore/poreve/porevesrc/pore.H
blob: 3668f23bbc5daa9825562935f1b0af3a3b89df18 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/pore/poreve/porevesrc/pore.H $                        */
/*                                                                        */
/* IBM CONFIDENTIAL                                                       */
/*                                                                        */
/* COPYRIGHT International Business Machines Corp. 2012,2013              */
/*                                                                        */
/* p1                                                                     */
/*                                                                        */
/* Object Code Only (OCO) source materials                                */
/* Licensed Internal Code Source Materials                                */
/* IBM HostBoot Licensed Internal Code                                    */
/*                                                                        */
/* The source code for this program is not published or otherwise         */
/* divested of its trade secrets, irrespective of what has been           */
/* deposited with the U.S. Copyright Office.                              */
/*                                                                        */
/* Origin: 30                                                             */
/*                                                                        */
/* IBM_PROLOG_END_TAG                                                     */
#ifndef __VSBE_PORE_H
#define __VSBE_PORE_H

// $Id: pore.H,v 1.17 2013/04/05 19:33:28 jeshua Exp $

/// \file pore.H
/// \brief The implementation of the PoreInterface for the PoreVe environment

#include <fapi.H>

#include "bus.H"
#include "poremodel.H"
#include "hookmanager.H"

 #ifdef VBU_HACKS
 #include "fapiSharedUtils.H"
 #include "ecmdUtils.H"
 #endif  // VBU_HACKS


namespace vsbe {
    
    class Pore;

    /// This is the putative tick frequency of the simulation environment,
    /// used to model the wait() method.
    const double SIMULATOR_TICK_FREQUENCY = 12e9;

    /// This is the expected operating frequency of the PORE hardware engine,
    /// used to model the wait() method.
    const double PORE_FREQUENCY = 600e6;
};


/// The implementation of the PoreInterface for the PoreVe environment
///
/// This class provides implementations of the virtual interface to the
/// PoreModel for the PoreVe environment.  The Pore is configured by providing
/// pointers to the PIB and OCI bus models of the environment.  The Pore also
/// contains the last FAPI return code produced by an operation in the virtual
/// environment.
///
/// The Pore class is also derived from the PibSlave class.  This enables the
/// PORE engine to 'self-SCOM' PORE control registers that are not visible as
/// part of the architected state.  Since our PoreVe environment does not
/// included a generic OCB bridge, all self-SCOM must be programmed using PIB
/// addresses.

class 
vsbe::Pore : public PoreInterface, 
             public PibSlave 
{

public:

    ///////////////////////// Control Interface  /////////////////////////

    /// Force a branch to a global symbol name
    ///
    /// \param[in] i_symbol A global symbol name; the branch target
    ///
    /// Pore provides a variant of PoreModel::forceBranch() that forces a
    /// branch to a global symbol, assuming the global symbol is known to
    /// HookManager.  The error code ME_ILLEGAL_FORCED_BRANCH is returned if
    /// the symbol is not known to the HookManager.
    ///
    /// See PoreModel::forceBranch() for more information
    ///
    /// \retval me Either 0 for success or a ModelError code.
    virtual ModelError
    forceBranch(const char* i_symbol);


    ////////////////////  PoreInterface Methods  /////////////////////////

    /// See PoreModel::pibMaster() for the interface specification
    ///
    /// Run the transaction on the PoreVe PIB Bus model.  FAPI errors from
    /// running PIB/PCB transactions are converted to PCB return codes and
    /// stored in the \a iv_pcbReturnCode field of the \a io_transaction.
    void
    pibMaster(PibTransaction& io_transaction);

    /// See PoreModel::ociMaster() for the interface specification
    ///
    /// Run the transaction on the PoreVe OCI Bus model.  FAPI errors from
    /// running OCI transactions are converted to abstract return codes and
    /// stored in the \a iv_ociReturnCode field of the \a io_transaction.

    void
    ociMaster(OciTransaction& io_transaction);

    /// See PoreModel::wait() for the interface specification
    ///
    /// Simulate a WAIT of \a i_count PORE cycles.  The implementation
    /// attempts to accurately model the wait based on the assumed PORE clock
    /// frequency, and for simulation, the assumed simulation clock frequency.
    /// If execution of the WAIT results in a FAPI error, the FAPI error is
    /// stored in the \a iv_fapiReturnCode.

    void
    wait(const uint32_t i_count);

    /// See PoreModel::hookInstruction() for the interface specification
    ///
    /// Use the HookManager to run the numbered hook called out by a PORE
    /// HOOKI instruction. It is not considered an error to request a hook
    /// that is not mapped in the HookManager.  If execution of the hook
    /// results in a FAPI error, the FAPI error is stored in the
    /// \a iv_fapiReturnCode.
    void
    hookInstruction(const PoreAddress& i_address, 
                    const uint32_t i_hook,
                    const uint64_t i_parameter);

    /// See PoreModel::hookRead() for the interface specification
    ///
    /// Run any hooks associated with a read of the given effective address.
    /// If execution of the hook results in a FAPI error, the FAPI error is
    /// stored in the \a iv_fapiReturnCode.
    void
    hookRead(const PoreAddress& i_address);

    /// See PoreModel::hookWrite() for the interface specification
    ///
    /// Run any hooks associated with a write of the given effective address.
    /// If execution of the hook results in a FAPI error, the FAPI error is
    /// stored in the \a iv_fapiReturnCode.
    void
    hookWrite(const PoreAddress& i_address);

    /// See PoreModel::hookFetch() for the interface specification
    ///
    /// Run any hooks associated with an instruction fetch of the given
    /// effective address.  If execution of the hook results in a FAPI error,
    /// the FAPI error is stored in the \a iv_fapiReturnCode.
    void
    hookFetch(const PoreAddress& i_address);

    /// See PoreModel::errorIntr() for the interface specification
    ///
    /// Currently not implemented by Pore.
    void
    errorIntr(void) {}
    
    /// See PoreModel::fatalErrorIntr() for the interface specification
    ///
    /// Currently not implemented by Pore.
    void
    fatalErrorIntr(void) {}
    

    ////////////////////////  PibSlave Methods ////////////////////////////

    /// See Slave::operation() for the interface specification
    virtual fapi::ReturnCode
    operation(Transaction& io_transaction);


    ////////////////////////////// Creators //////////////////////////////

    /// Create the Pore
    ///
    /// \param[in] i_id The IBUF ID (PORE engine type) of the PORE model to
    /// create.
    Pore(PoreIbufId i_id);

    virtual ~Pore();

    ////////////////////  Interface Extensions  /////////////////////////

    /// Configure the Pore model by providing pointers to the Bus models
    ///
    /// \param[in] i_target A pointer to the FAPI target object associated
    /// with the PORE model, for use in hooks and for purposes of the
    /// PibSlave. 
    ///
    /// \param[in] i_pib A Bus model (to be) configured as a PIB bus.
    ///
    /// \param[in] i_oci A Bus model (to be) configured as an OCI bus.
    ///
    /// \param[in] i_dataBuffer See Slave::configure()
    ///
    /// \param[in] i_base See Slave::configure()
    ///
    /// \param[in] i_size See Slave::configure()
    ///
    /// \param[in] i_permissions See Slave::configure()
    ///
    /// This interface is introduced simply to encapsulate everything about
    /// the Pore that needs to be configured to create a system.  
    void
    configure(fapi::Target* i_target, Bus* i_pib, Bus* i_oci,
              ecmdDataBufferBase* i_dataBuffer,
              uint32_t i_base, uint64_t i_size, int i_permissions);

    /// Get the FAPI return code from the model
    ///
    /// \retval rc The last FAPI return code from any PORE operations in the
    /// environment. 
    fapi::ReturnCode
    getFapiReturnCode();

    /// Dump the state of the engine using FAPI_ERR
    ///
    /// The dump is made using FAPI_ERR() because this is currently the only
    /// way to guarantee that the dump will appear regardless of the Cronus
    /// debug settings.
    void
    dump();

    /// Call dump() if it hasn't been called yet
    ///
    /// If iv_dumpDone is false, then dump() will be called. Otherwise it
    /// will just return without doing anything.
    void
    dumpOnce();


    ////////////////////////// Implementation ////////////////////////////

protected:

    /// The PoreVe PIB Bus model
    Bus* iv_pib;

    /// The PoreVe OCI Bus model
    Bus* iv_oci;

    /// The last FAPI return code
    ///
    /// Operations in the PoreVe environment return FAPI ReturnCode objects.
    /// The FAPI return code is stored here, and the ModelError returned to
    /// the PoreModel dependson the type of error.
    fapi::ReturnCode iv_fapiReturnCode;

    /// A pointer to the FAPI target associated with this PORE engine
    ///
    /// The Pore object holds this pointer for use as an argument to hook
    /// routines. 
    fapi::Target* iv_target;

    /// Keeps track of whether or not a dump has been printed
    ///
    /// This will be set to true on the first dump so that subsequent dumps
    /// could be skipped
    bool iv_dumpDone;


    ///////////////////////////// Safety //////////////////////////////////

private:

    Pore(const Pore& i_rhs);
    Pore& operator=(const Pore& i_rhs);
};

#endif  // __VSBE_PORE_H
OpenPOWER on IntegriCloud