2 * Copyright 2019 Google, Inc.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met: redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer;
8 * redistributions in binary form must reproduce the above copyright
9 * notice, this list of conditions and the following disclaimer in the
10 * documentation and/or other materials provided with the distribution;
11 * neither the name of the copyright holders nor the names of its
12 * contributors may be used to endorse or promote products derived from
13 * this software without specific prior written permission.
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 #ifndef __ARCH_ARM_FASTMODEL_IRIS_THREAD_CONTEXT_HH__
31 #define __ARCH_ARM_FASTMODEL_IRIS_THREAD_CONTEXT_HH__
33 #include "cpu/base.hh"
34 #include "cpu/thread_context.hh"
35 #include "iris/IrisInstance.h"
36 #include "iris/detail/IrisErrorCode.h"
37 #include "iris/detail/IrisObjects.h"
38 #include "sim/system.hh"
43 // This class is the base for ThreadContexts which read and write state using
45 class ThreadContext : public ::ThreadContext
48 typedef std::map<std::string, iris::ResourceInfo> ResourceMap;
50 typedef std::vector<iris::ResourceId> ResourceIds;
51 typedef std::map<int, std::string> IdxNameMap;
59 std::string _irisPath;
60 iris::InstanceId _instId;
64 virtual void initFromIrisInstance(const ResourceMap &resources);
66 iris::ResourceId extractResourceId(
67 const ResourceMap &resources, const std::string &name);
68 void extractResourceMap(ResourceIds &ids,
69 const ResourceMap &resources, const IdxNameMap &idx_names);
72 ResourceIds miscRegIds;
73 ResourceIds intRegIds;
76 iris::IrisErrorCode instanceRegistryChanged(
77 uint64_t esId, const iris::IrisValueMap &fields, uint64_t time,
78 uint64_t sInstId, bool syncEc, std::string &error_message_out);
79 iris::IrisErrorCode phaseInitLeave(
80 uint64_t esId, const iris::IrisValueMap &fields, uint64_t time,
81 uint64_t sInstId, bool syncEc, std::string &error_message_out);
83 iris::EventStreamId regEventStreamId;
84 iris::EventStreamId initEventStreamId;
86 mutable iris::IrisInstance client;
87 iris::IrisCppAdapter &call() const { return client.irisCall(); }
88 iris::IrisCppAdapter &noThrow() const { return client.irisCallNoThrow(); }
91 ThreadContext(::BaseCPU *cpu, int id, System *system,
92 iris::IrisConnectionInterface *iris_if,
93 const std::string &iris_path);
94 virtual ~ThreadContext();
96 bool schedule(PCEvent *e) override { return false; }
97 bool remove(PCEvent *e) override { return false; }
99 void scheduleInstCountEvent(Event *event, Tick count) override {}
100 void descheduleInstCountEvent(Event *event) override {}
101 Tick getCurrentInstCount() override;
103 ::BaseCPU *getCpuPtr() override { return _cpu; }
104 int cpuId() const override { return _cpu->cpuId(); }
105 uint32_t socketId() const override { return _cpu->socketId(); }
107 int threadId() const override { return _threadId; }
108 void setThreadId(int id) override { _threadId = id; }
110 int contextId() const override { return _contextId; }
111 void setContextId(int id) override { _contextId = id; }
116 panic("%s not implemented.", __FUNCTION__);
121 panic("%s not implemented.", __FUNCTION__);
124 getCheckerCpuPtr() override
126 panic("%s not implemented.", __FUNCTION__);
129 getDecoderPtr() override
131 panic("%s not implemented.", __FUNCTION__);
134 System *getSystemPtr() override { return _cpu->system; }
137 getKernelStats() override
139 panic("%s not implemented.", __FUNCTION__);
142 getPhysProxy() override
144 panic("%s not implemented.", __FUNCTION__);
147 getVirtProxy() override
149 panic("%s not implemented.", __FUNCTION__);
152 initMemProxies(::ThreadContext *tc) override
154 panic("%s not implemented.", __FUNCTION__);
157 getProcessPtr() override
159 panic("%s not implemented.", __FUNCTION__);
162 setProcessPtr(Process *p) override
164 panic("%s not implemented.", __FUNCTION__);
167 Status status() const override;
168 void setStatus(Status new_status) override;
169 void activate() override { setStatus(Active); }
170 void suspend() override { setStatus(Suspended); }
171 void halt() override { setStatus(Halted); }
174 dumpFuncProfile() override
176 panic("%s not implemented.", __FUNCTION__);
180 takeOverFrom(::ThreadContext *old_context) override
182 panic("%s not implemented.", __FUNCTION__);
185 void regStats(const std::string &name) override {}
188 getQuiesceEvent() override
190 panic("%s not implemented.", __FUNCTION__);
193 // Not necessarily the best location for these...
194 // Having an extra function just to read these is obnoxious
196 readLastActivate() override
198 panic("%s not implemented.", __FUNCTION__);
200 Tick readLastSuspend() override
202 panic("%s not implemented.", __FUNCTION__);
206 profileClear() override
208 panic("%s not implemented.", __FUNCTION__);
211 profileSample() override
213 panic("%s not implemented.", __FUNCTION__);
217 copyArchRegs(::ThreadContext *tc) override
219 panic("%s not implemented.", __FUNCTION__);
223 clearArchRegs() override
225 panic("%s not implemented.", __FUNCTION__);
229 // New accessors for new decoder.
231 RegVal readIntReg(RegIndex reg_idx) const override;
234 readFloatReg(RegIndex reg_idx) const override
236 panic("%s not implemented.", __FUNCTION__);
239 const VecRegContainer &
240 readVecReg(const RegId ®) const override
242 panic("%s not implemented.", __FUNCTION__);
245 getWritableVecReg(const RegId ®) override
247 panic("%s not implemented.", __FUNCTION__);
250 /** Vector Register Lane Interfaces. */
252 /** Reads source vector 8bit operand. */
254 readVec8BitLaneReg(const RegId ®) const override
256 panic("%s not implemented.", __FUNCTION__);
259 /** Reads source vector 16bit operand. */
261 readVec16BitLaneReg(const RegId ®) const override
263 panic("%s not implemented.", __FUNCTION__);
266 /** Reads source vector 32bit operand. */
268 readVec32BitLaneReg(const RegId ®) const override
270 panic("%s not implemented.", __FUNCTION__);
273 /** Reads source vector 64bit operand. */
275 readVec64BitLaneReg(const RegId ®) const override
277 panic("%s not implemented.", __FUNCTION__);
280 /** Write a lane of the destination vector register. */
282 setVecLane(const RegId ®, const LaneData<LaneSize::Byte> &val) override
284 panic("%s not implemented.", __FUNCTION__);
287 setVecLane(const RegId ®,
288 const LaneData<LaneSize::TwoByte> &val) override
290 panic("%s not implemented.", __FUNCTION__);
293 setVecLane(const RegId ®,
294 const LaneData<LaneSize::FourByte> &val) override
296 panic("%s not implemented.", __FUNCTION__);
299 setVecLane(const RegId ®,
300 const LaneData<LaneSize::EightByte> &val) override
302 panic("%s not implemented.", __FUNCTION__);
307 readVecElem(const RegId ®) const override
309 panic("%s not implemented.", __FUNCTION__);
312 const VecPredRegContainer &
313 readVecPredReg(const RegId ®) const override
315 panic("%s not implemented.", __FUNCTION__);
317 VecPredRegContainer &
318 getWritableVecPredReg(const RegId ®) override
320 panic("%s not implemented.", __FUNCTION__);
324 readCCReg(RegIndex reg_idx) const override
326 panic("%s not implemented.", __FUNCTION__);
329 void setIntReg(RegIndex reg_idx, RegVal val) override;
332 setFloatReg(RegIndex reg_idx, RegVal val) override
334 panic("%s not implemented.", __FUNCTION__);
338 setVecReg(const RegId ®, const VecRegContainer &val) override
340 panic("%s not implemented.", __FUNCTION__);
344 setVecElem(const RegId& reg, const VecElem& val) override
346 panic("%s not implemented.", __FUNCTION__);
350 setVecPredReg(const RegId ®,
351 const VecPredRegContainer &val) override
353 panic("%s not implemented.", __FUNCTION__);
357 setCCReg(RegIndex reg_idx, RegVal val) override
359 panic("%s not implemented.", __FUNCTION__);
362 void pcStateNoRecord(const TheISA::PCState &val) override { pcState(val); }
363 MicroPC microPC() const override { return 0; }
365 RegVal readMiscRegNoEffect(RegIndex misc_reg) const override;
367 readMiscReg(RegIndex misc_reg) override
369 return readMiscRegNoEffect(misc_reg);
372 void setMiscRegNoEffect(RegIndex misc_reg, const RegVal val) override;
374 setMiscReg(RegIndex misc_reg, const RegVal val) override
376 setMiscRegNoEffect(misc_reg, val);
380 flattenRegId(const RegId& regId) const override
382 panic("%s not implemented.", __FUNCTION__);
385 // Also not necessarily the best location for these two. Hopefully will go
386 // away once we decide upon where st cond failures goes.
388 readStCondFailures() const override
390 panic("%s not implemented.", __FUNCTION__);
394 setStCondFailures(unsigned sc_failures) override
396 panic("%s not implemented.", __FUNCTION__);
399 // Same with st cond failures.
401 readFuncExeInst() const override
403 panic("%s not implemented.", __FUNCTION__);
407 syscall(int64_t callnum, Fault *fault) override
409 panic("%s not implemented.", __FUNCTION__);
414 * Flat register interfaces
416 * Some architectures have different registers visible in
417 * different modes. Such architectures "flatten" a register (see
418 * flattenRegId()) to map it into the
419 * gem5 register file. This interface provides a flat interface to
420 * the underlying register file, which allows for example
421 * serialization code to access all registers.
425 readIntRegFlat(RegIndex idx) const override
427 panic("%s not implemented.", __FUNCTION__);
430 setIntRegFlat(RegIndex idx, uint64_t val) override
432 panic("%s not implemented.", __FUNCTION__);
436 readFloatRegFlat(RegIndex idx) const override
438 panic("%s not implemented.", __FUNCTION__);
441 setFloatRegFlat(RegIndex idx, RegVal val) override
443 panic("%s not implemented.", __FUNCTION__);
446 const VecRegContainer &
447 readVecRegFlat(RegIndex idx) const override
449 panic("%s not implemented.", __FUNCTION__);
452 getWritableVecRegFlat(RegIndex idx) override
454 panic("%s not implemented.", __FUNCTION__);
457 setVecRegFlat(RegIndex idx, const VecRegContainer &val) override
459 panic("%s not implemented.", __FUNCTION__);
463 readVecElemFlat(RegIndex idx, const ElemIndex& elemIdx) const override
465 panic("%s not implemented.", __FUNCTION__);
468 setVecElemFlat(RegIndex idx, const ElemIndex &elemIdx,
469 const VecElem &val) override
471 panic("%s not implemented.", __FUNCTION__);
474 const VecPredRegContainer &
475 readVecPredRegFlat(RegIndex idx) const override
477 panic("%s not implemented.", __FUNCTION__);
479 VecPredRegContainer &
480 getWritableVecPredRegFlat(RegIndex idx) override
482 panic("%s not implemented.", __FUNCTION__);
485 setVecPredRegFlat(RegIndex idx, const VecPredRegContainer &val) override
487 panic("%s not implemented.", __FUNCTION__);
491 readCCRegFlat(RegIndex idx) const override
493 panic("%s not implemented.", __FUNCTION__);
496 setCCRegFlat(RegIndex idx, RegVal val) override
498 panic("%s not implemented.", __FUNCTION__);
506 #endif // __ARCH_ARM_FASTMODEL_IRIS_THREAD_CONTEXT_HH__