Go to the documentation of this file.
52 #include "iris/detail/IrisCppAdapter.h"
53 #include "iris/detail/IrisObjects.h"
81 iris::EventSourceInfo evSrcInfo;
83 client.registerEventCallback<Self, &Self::breakpointHit>(
84 this,
"ec_IRIS_BREAKPOINT_HIT",
85 "Handle hitting a breakpoint",
"Iris::ThreadContext");
86 call().event_getEventSource(
_instId, evSrcInfo,
"IRIS_BREAKPOINT_HIT");
88 evSrcInfo.evSrcId,
client.getInstId());
90 for (
auto it =
bps.begin(); it !=
bps.end(); it++)
93 client.registerEventCallback<Self, &Self::semihostingEvent>(
94 this,
"ec_IRIS_SEMIHOSTING_CALL_EXTENSION",
95 "Handle a semihosting call",
"Iris::ThreadContext");
97 "IRIS_SEMIHOSTING_CALL_EXTENSION");
99 evSrcInfo.evSrcId,
client.getInstId(),
102 nullptr,
"",
false, 0,
nullptr,
false,
false,
true);
109 return resources.at(
name).rscId;
117 for (
const auto &idx_name: idx_names) {
118 int idx = idx_name.first;
119 const std::string &
name = idx_name.second;
121 if (idx >=
ids.size())
122 ids.resize(idx + 1, iris::IRIS_UINT64_MAX);
132 return it ==
memorySpaceIds.end() ? iris::IRIS_UINT64_MAX : it->second;
158 Tick remaining = next - now;
159 call().step_setup(
_instId, remaining,
"instruction");
167 auto pc_it =
bps.find(
pc);
169 if (pc_it !=
bps.end())
173 panic_if(!res.second,
"Inserting breakpoint failed.");
182 for (
auto sid: space_ids) {
185 it->second->ids.push_back(
id);
192 for (
auto id: it->second->ids)
194 it->second->clearIds();
201 "BP info still had events associated with it.");
203 if (it->second->validIds())
211 uint64_t esId,
const iris::IrisValueMap &fields, uint64_t time,
212 uint64_t sInstId,
bool syncEc, std::string &error_message_out)
214 const std::string &
event = fields.at(
"EVENT").getString();
215 const iris::InstanceId
id = fields.at(
"INST_ID").getU64();
216 const std::string &
name = fields.at(
"INST_NAME").getString();
221 if (
event ==
"added")
223 else if (
event ==
"removed")
224 _instId = iris::IRIS_UINT64_MAX;
233 uint64_t esId,
const iris::IrisValueMap &fields, uint64_t time,
234 uint64_t sInstId,
bool syncEc, std::string &error_message_out)
239 std::map<iris::ResourceId, const iris::ResourceInfo *>
241 for (
const auto &resource: resources) {
242 idToResource[resource.rscId] = &resource;
245 for (
const auto &resource: resources) {
246 std::string
name = resource.name;
247 iris::ResourceId parentId = resource.parentRscId;
248 while (parentId != iris::IRIS_UINT64_MAX) {
249 const auto *parent = idToResource[parentId];
251 parentId = parent->parentRscId;
253 resourceMap[
name] = resource;
263 uint64_t esId,
const iris::IrisValueMap &fields, uint64_t time,
264 uint64_t sInstId,
bool syncEc, std::string &error_message_out)
266 if (fields.at(
"RUNNING").getAsBool()) {
278 call().simulationTime_run(iris::IrisInstIdSimulationEngine);
285 uint64_t esId,
const iris::IrisValueMap &fields, uint64_t time,
286 uint64_t sInstId,
bool syncEc, std::string &error_message_out)
288 Addr pc = fields.at(
"PC").getU64();
292 std::shared_ptr<BpInfo::EventList> events = it->second->events;
293 auto e_it = events->begin();
294 while (e_it != events->end()) {
306 uint64_t esId,
const iris::IrisValueMap &fields, uint64_t time,
307 uint64_t sInstId,
bool syncEc, std::string &error_message_out)
312 call().perInstanceExecution_setState(
_instId,
false);
328 BaseISA *isa, iris::IrisConnectionInterface *iris_if,
329 const std::string &iris_path) :
330 _cpu(cpu), _threadId(
id), _system(
system), _mmu(mmu), _isa(isa),
331 _irisPath(iris_path), vecRegs(ArmISA::
NumVecRegs),
333 comInstEventQueue(
"instruction-based event queue"),
334 client(iris_if,
"client." + iris_path)
336 iris::InstanceInfo info;
337 auto ret_code =
noThrow().instanceRegistry_getInstanceInfoByName(
338 info,
"component." + iris_path);
339 if (ret_code == iris::E_ok) {
344 _instId = iris::IRIS_UINT64_MAX;
348 iris::EventSourceInfo evSrcInfo;
350 client.registerEventCallback<Self, &Self::instanceRegistryChanged>(
351 this,
"ec_IRIS_INSTANCE_REGISTRY_CHANGED",
352 "Install the iris instance ID",
"Iris::ThreadContext");
353 call().event_getEventSource(iris::IrisInstIdGlobalInstance, evSrcInfo,
354 "IRIS_INSTANCE_REGISTRY_CHANGED");
357 {
"EVENT",
"INST_ID",
"INST_NAME" };
359 evSrcInfo.evSrcId,
client.getInstId(), &fields);
361 client.registerEventCallback<Self, &Self::phaseInitLeave>(
362 this,
"ec_IRIS_SIM_PHASE_INIT_LEAVE",
363 "Initialize register contexts",
"Iris::ThreadContext");
364 call().event_getEventSource(iris::IrisInstIdSimulationEngine, evSrcInfo,
365 "IRIS_SIM_PHASE_INIT_LEAVE");
367 call().eventStream_create(
369 evSrcInfo.evSrcId,
client.getInstId());
371 client.registerEventCallback<Self, &Self::simulationTimeEvent>(
372 this,
"ec_IRIS_SIMULATION_TIME_EVENT",
373 "Handle simulation time stopping for breakpoints or stepping",
374 "Iris::ThreadContext");
375 call().event_getEventSource(iris::IrisInstIdSimulationEngine, evSrcInfo,
376 "IRIS_SIMULATION_TIME_EVENT");
378 call().eventStream_create(
380 evSrcInfo.evSrcId,
client.getInstId());
385 auto enable_lambda = [
this]{
386 call().perInstanceExecution_setState(
_instId,
true);
389 enable_lambda,
"resume after pseudo inst",
395 call().eventStream_destroy(
398 client.unregisterEventCallback(
"ec_IRIS_SIM_PHASE_INIT_LEAVE");
400 call().eventStream_destroy(
403 client.unregisterEventCallback(
"ec_IRIS_INSTANCE_REGISTRY_CHANGED");
405 call().eventStream_destroy(
408 client.unregisterEventCallback(
"ec_IRIS_SIMULATION_TIME_EVENT");
419 it->second->events->push_back(
e);
421 if (
_instId != iris::IRIS_UINT64_MAX && !it->second->validIds())
431 it->second->events->remove(
e);
433 if (it->second->empty())
441 iris::MemorySpaceId space,
Addr addr,
void *
p,
size_t size)
443 iris::r0master::MemoryReadResult
r;
445 panic_if(
err != iris::r0master::E_ok,
"readMem failed.");
446 std::memcpy(
p,
r.data.data(), size);
451 iris::MemorySpaceId space,
Addr addr,
const void *
p,
size_t size)
454 std::memcpy(
data.data(),
p, size);
455 iris::MemoryWriteResult
r;
457 panic_if(
err != iris::r0master::E_ok,
"writeMem failed.");
464 iris::MemoryAddressTranslationResult result;
465 auto ret =
noThrow().memory_translateAddress(
468 if (ret != iris::E_ok) {
472 if (trans.inSpaceId == v_space && trans.outSpaceId == p_space)
475 panic(
"No legal translation IRIS address translation found.");
478 if (result.address.empty())
481 if (result.address.size() > 1) {
482 warn(
"Multiple mappings for address %#x.",
vaddr);
486 paddr = result.address[0];
496 call().simulationTime_stop(iris::IrisInstIdSimulationEngine);
513 panic_if(ret != iris::E_ok,
"Failed to get instruction count.");
546 if (new_status ==
Active) {
548 call().perInstanceExecution_setState(
_instId,
true);
551 call().perInstanceExecution_setState(
_instId,
false);
562 pc.nextThumb(
pc.thumb());
564 pc.nextJazelle(cpsr.j);
565 pc.aarch64(!cpsr.width);
566 pc.nextAArch64(!cpsr.width);
567 pc.illegalExec(
false);
571 iris::ResourceReadResult result;
574 if (cpsr.width && cpsr.t)
586 if (cpsr.width && cpsr.t)
589 iris::ResourceWriteResult result;
596 iris::ResourceReadResult result;
598 return result.data.at(0);
604 iris::ResourceWriteResult result;
647 panic(
"MiscRegs should not be read with getReg.");
649 panic(
"Unrecognized register class type %d.",
type);
678 panic(
"MiscRegs should not be read with getReg.");
680 panic(
"Unrecognized register class type %d.",
type);
694 panic(
"Unrecognized register class type %d.",
type);
734 panic(
"MiscRegs should not be read with getReg.");
736 panic(
"Unrecognized register class type %d.",
type);
762 panic(
"MiscRegs should not be read with getReg.");
764 panic(
"Unrecognized register class type %d.",
type);
779 panic(
"Unrecognized register class type %d.",
type);
788 iris::ResourceReadResult result;
793 return result.data.at(0);
801 iris::ResourceWriteResult result;
818 if (res_id == iris::IRIS_UINT64_MAX)
820 iris::ResourceReadResult result;
822 return result.data.at(0);
828 iris::ResourceId res_id =
831 panic_if(res_id == iris::IRIS_UINT64_MAX,
832 "Int reg %d is not supported by fast model.", idx);
833 iris::ResourceWriteResult result;
842 iris::ResourceReadResult result;
844 return result.data.at(0);
851 "CC reg %d is not supported by fast model.", idx);
852 iris::ResourceWriteResult result;
869 iris::ResourceReadResult result;
871 size_t data_size = result.data.size() * (
sizeof(*result.data.data()));
872 size_t size = std::min(data_size,
reg.size());
873 memcpy(
reg.as<uint8_t>(), (
void *)result.data.data(), size);
895 iris::ResourceReadResult result;
899 size_t num_bits =
reg.NUM_BITS;
900 uint8_t *bytes = (uint8_t *)result.data.data();
901 while (num_bits > 8) {
Tick curTick()
The universal simulation clock.
std::map< int, std::string > IdxNameMap
@ PhysicalMemoryNonSecureMsn
@ PhysicalMemorySecureMsn
RegVal readFloatReg(RegIndex reg_idx) const
VecPredReg::Container VecPredRegContainer
virtual const ArmISA::VecRegContainer & readVecRegFlat(RegIndex idx) const
@ VecElemClass
Vector Register Native Elem lane.
iris::EventStreamId regEventStreamId
virtual const ArmISA::VecPredRegContainer & readVecPredReg(const RegId ®) const
void * getWritableRegFlat(const RegId ®) override
void setReg(const RegId ®, RegVal val) override
void setRegFlat(const RegId ®, RegVal val) override
@ CCRegClass
Condition-code register.
const PCStateBase & pcState() const override
virtual void setCCRegFlat(RegIndex idx, RegVal val)
iris::IrisCppAdapter & call() const
static bool callSemihosting(ThreadContext *tc, bool gem5_ops=false)
Make a Semihosting call from either aarch64 or aarch32.
virtual RegVal readIntReg(RegIndex reg_idx) const
iris::IrisErrorCode breakpointHit(uint64_t esId, const iris::IrisValueMap &fields, uint64_t time, uint64_t sInstId, bool syncEc, std::string &error_message_out)
void sendFunctional(PacketPtr pkt) override
void descheduleInstCountEvent(Event *event) override
void installBp(BpInfoIt it)
virtual void initFromIrisInstance(const ResourceMap &resources)
BpInfoIt getOrAllocBp(Addr pc)
void uninstallBp(BpInfoIt it)
gem5::BaseCPU * getCpuPtr() override
void serviceEvents(Tick when)
process all events up to the given timestamp.
virtual void setVecPredRegFlat(RegIndex idx, const ArmISA::VecPredRegContainer &val)
Event * enableAfterPseudoEvent
iris::EventStreamId breakpointEventStreamId
std::vector< iris::MemorySpaceInfo > memorySpaces
std::vector< ArmISA::VecPredRegContainer > vecPredRegs
void suspend() override
Set the status to Suspended.
virtual ArmISA::VecRegContainer & getWritableVecReg(const RegId ®)
MemorySpaceMap memorySpaceIds
iris::IrisCppAdapter & noThrow() const
virtual void setVecRegFlat(RegIndex idx, const ArmISA::VecRegContainer &val)
@ FloatRegClass
Floating-point register.
iris::IrisErrorCode simulationTimeEvent(uint64_t esId, const iris::IrisValueMap &fields, uint64_t time, uint64_t sInstId, bool syncEc, std::string &error_message_out)
virtual RegVal readCCRegFlat(RegIndex idx) const
virtual void setVecElemFlat(RegIndex idx, RegVal val)
Vector Register Abstraction This generic class is the model in a particularization of MVC,...
RegVal getReg(const RegId ®) const override
@ Suspended
Temporarily inactive.
BpInfoMap::iterator BpInfoIt
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
void deschedule(Event *event)
Deschedule the specified event.
void readMem(iris::MemorySpaceId space, Addr addr, void *p, size_t size)
uint64_t Tick
Tick count type.
void setMiscRegNoEffect(RegIndex misc_reg, const RegVal val) override
ThreadContext(gem5::BaseCPU *cpu, int id, System *system, gem5::BaseMMU *mmu, gem5::BaseISA *isa, iris::IrisConnectionInterface *iris_if, const std::string &iris_path)
iris::IrisErrorCode phaseInitLeave(uint64_t esId, const iris::IrisValueMap &fields, uint64_t time, uint64_t sInstId, bool syncEc, std::string &error_message_out)
std::vector< iris::MemorySupportedAddressTranslationResult > translations
bool empty() const
Returns true if no events are queued.
void extractResourceMap(ResourceIds &ids, const ResourceMap &resources, const IdxNameMap &idx_names)
virtual const ArmISA::VecRegContainer & readVecReg(const RegId ®) const
ResourceIds flattenedIntIds
virtual void setIntRegFlat(RegIndex idx, uint64_t val)
virtual RegVal readIntRegFlat(RegIndex idx) const
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
std::vector< ArmISA::VecRegContainer > vecRegs
const std::string & name()
iris::ResourceId extractResourceId(const ResourceMap &resources, const std::string &name)
virtual ArmISA::VecPredRegContainer & getWritableVecPredRegFlat(RegIndex idx)
bool isSecure(ThreadContext *tc)
ResourceIds vecPredRegIds
void * getWritableReg(const RegId ®) override
iris::EventStreamId timeEventStreamId
iris::IrisErrorCode semihostingEvent(uint64_t esId, const iris::IrisValueMap &fields, uint64_t time, uint64_t sInstId, bool syncEc, std::string &error_message_out)
RegVal readMiscRegNoEffect(RegIndex misc_reg) const override
void scheduleInstCountEvent(Event *event, Tick count) override
@ IntRegClass
Integer register.
iris::IrisErrorCode instanceRegistryChanged(uint64_t esId, const iris::IrisValueMap &fields, uint64_t time, uint64_t sInstId, bool syncEc, std::string &error_message_out)
Tick getCurrentInstCount() override
#define panic_if(cond,...)
Conditional panic macro that checks the supplied condition and only panics if the condition is true a...
EventQueue comInstEventQueue
virtual void setCCReg(RegIndex reg_idx, RegVal val)
virtual ArmISA::VecPredRegContainer readVecPredRegFlat(RegIndex idx) const
RegClassType
Enumerate the classes of registers.
std::map< std::string, iris::ResourceInfo > ResourceMap
@ MiscRegClass
Control (misc) register.
bool translateAddress(Addr &paddr, iris::MemorySpaceId p_space, Addr vaddr, iris::MemorySpaceId v_space)
virtual ArmISA::VecPredRegContainer & getWritableVecPredReg(const RegId ®)
virtual const std::vector< iris::MemorySpaceId > & getBpSpaceIds() const =0
virtual RegVal readVecElem(const RegId ®) const
virtual RegVal readCCReg(RegIndex reg_idx) const
void makeResponse()
Take a request packet and modify it in place to be suitable for returning as a response to that reque...
virtual void setIntReg(RegIndex reg_idx, RegVal val)
void schedule(Event *event, Tick when, bool global=false)
Schedule the given event on this queue.
iris::EventStreamId semihostingEventStreamId
iris::MemorySpaceId getMemorySpaceId(const Iris::CanonicalMsn &msn) const
void setStatus(Status new_status) override
void setFloatReg(RegIndex reg_idx, RegVal val)
bool remove(PCEvent *e) override
Status status() const override
@ VecRegClass
Vector Register.
constexpr RegIndex index() const
Index accessors.
virtual void setVecElem(const RegId ®, RegVal val)
iris::EventStreamId initEventStreamId
static uint8_t itState(CPSR psr)
RegVal getRegFlat(const RegId ®) const override
Flat register interfaces.
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
bool schedule(PCEvent *e) override
iris::IrisInstance client
virtual ArmISA::VecRegContainer & getWritableVecRegFlat(RegIndex idx)
virtual RegVal readVecElemFlat(RegIndex idx) const
bool scheduled() const
Determine if the current event is scheduled.
static const Priority Sim_Exit_Pri
If we want to exit on this cycle, it's the very last thing we do.
virtual void setVecReg(const RegId ®, const ArmISA::VecRegContainer &val)
Register ID: describe an architectural register with its class and index.
void writeMem(iris::MemorySpaceId space, Addr addr, const void *p, size_t size)
#define panic(...)
This implements a cprintf based panic() function.
T * getPtr()
get a pointer to the data ptr.
virtual void setVecPredReg(const RegId ®, const ArmISA::VecPredRegContainer &val)
Generated on Thu Jul 28 2022 13:32:22 for gem5 by doxygen 1.8.17