34 #include "iris/detail/IrisCppAdapter.h" 35 #include "iris/detail/IrisObjects.h" 46 call().perInstanceExecution_getState(
_instId, enabled);
55 iris::EventSourceInfo evSrcInfo;
57 client.registerEventCallback<Self, &Self::breakpointHit>(
58 this,
"ec_IRIS_BREAKPOINT_HIT",
59 "Handle hitting a breakpoint",
"Iris::ThreadContext");
60 call().event_getEventSource(
_instId, evSrcInfo,
"IRIS_BREAKPOINT_HIT");
62 evSrcInfo.evSrcId,
client.getInstId());
64 for (
auto it =
bps.begin(); it !=
bps.end(); it++)
72 return resources.at(name).rscId;
80 for (
const auto &idx_name: idx_names) {
81 int idx = idx_name.first;
82 const std::string &
name = idx_name.second;
84 if (idx >= ids.size())
85 ids.resize(idx + 1, iris::IRIS_UINT64_MAX);
114 Tick remaining = next - now;
115 call().step_setup(
_instId, remaining,
"instruction");
123 auto pc_it =
bps.find(pc);
125 if (pc_it !=
bps.end())
128 auto res =
bps.emplace(std::make_pair(pc,
new BpInfo(pc)));
129 panic_if(!res.second,
"Inserting breakpoint failed.");
139 call().breakpoint_set_code(
_instId,
id, pc, space_id, 0,
true);
147 it->second->clearId();
154 "BP info still had events associated with it.");
156 if (it->second->validId())
164 uint64_t esId,
const iris::IrisValueMap &fields, uint64_t time,
165 uint64_t sInstId,
bool syncEc, std::string &error_message_out)
167 const std::string &
event = fields.at(
"EVENT").getString();
168 const iris::InstanceId
id = fields.at(
"INST_ID").getU64();
169 const std::string &
name = fields.at(
"INST_NAME").getString();
174 if (
event ==
"added")
176 else if (
event ==
"removed")
177 _instId = iris::IRIS_UINT64_MAX;
186 uint64_t esId,
const iris::IrisValueMap &fields, uint64_t time,
187 uint64_t sInstId,
bool syncEc, std::string &error_message_out)
193 for (
auto &resource: resources)
194 resourceMap[resource.name] = resource;
203 uint64_t esId,
const iris::IrisValueMap &fields, uint64_t time,
204 uint64_t sInstId,
bool syncEc, std::string &error_message_out)
206 if (fields.at(
"RUNNING").getAsBool()) {
218 call().simulationTime_run(iris::IrisInstIdSimulationEngine);
225 uint64_t esId,
const iris::IrisValueMap &fields, uint64_t time,
226 uint64_t sInstId,
bool syncEc, std::string &error_message_out)
228 Addr pc = fields.at(
"PC").getU64();
232 auto e_it = it->second->events.begin();
233 while (e_it != it->second->events.end()) {
245 iris::IrisConnectionInterface *iris_if,
const std::string &iris_path) :
250 client(iris_if,
"client." + iris_path)
252 iris::InstanceInfo info;
253 auto ret_code =
noThrow().instanceRegistry_getInstanceInfoByName(
254 info,
"component." + iris_path);
255 if (ret_code == iris::E_ok) {
260 _instId = iris::IRIS_UINT64_MAX;
264 iris::EventSourceInfo evSrcInfo;
266 client.registerEventCallback<Self, &Self::instanceRegistryChanged>(
267 this,
"ec_IRIS_INSTANCE_REGISTRY_CHANGED",
268 "Install the iris instance ID",
"Iris::ThreadContext");
269 call().event_getEventSource(iris::IrisInstIdGlobalInstance, evSrcInfo,
270 "IRIS_INSTANCE_REGISTRY_CHANGED");
273 {
"EVENT",
"INST_ID",
"INST_NAME" };
275 evSrcInfo.evSrcId,
client.getInstId(), &fields);
277 client.registerEventCallback<Self, &Self::phaseInitLeave>(
278 this,
"ec_IRIS_SIM_PHASE_INIT_LEAVE",
279 "Initialize register contexts",
"Iris::ThreadContext");
280 call().event_getEventSource(iris::IrisInstIdSimulationEngine, evSrcInfo,
281 "IRIS_SIM_PHASE_INIT_LEAVE");
283 call().eventStream_create(
285 evSrcInfo.evSrcId,
client.getInstId());
287 client.registerEventCallback<Self, &Self::simulationTimeEvent>(
288 this,
"ec_IRIS_SIMULATION_TIME_EVENT",
289 "Handle simulation time stopping for breakpoints or stepping",
290 "Iris::ThreadContext");
291 call().event_getEventSource(iris::IrisInstIdSimulationEngine, evSrcInfo,
292 "IRIS_SIMULATION_TIME_EVENT");
294 call().eventStream_create(
296 evSrcInfo.evSrcId,
client.getInstId());
303 call().eventStream_destroy(
306 client.unregisterEventCallback(
"ec_IRIS_SIM_PHASE_INIT_LEAVE");
308 call().eventStream_destroy(
311 client.unregisterEventCallback(
"ec_IRIS_INSTANCE_REGISTRY_CHANGED");
313 call().eventStream_destroy(
316 client.unregisterEventCallback(
"ec_IRIS_SIMULATION_TIME_EVENT");
323 it->second->events.push_back(e);
325 if (
_instId != iris::IRIS_UINT64_MAX && !it->second->validId())
335 it->second->events.remove(e);
337 if (it->second->empty())
347 iris::MemoryAddressTranslationResult result;
348 auto ret =
noThrow().memory_translateAddress(
349 _instId, result, v_space, vaddr, p_space);
351 if (ret != iris::E_ok) {
355 if (trans.inSpaceId == v_space && trans.outSpaceId == p_space)
358 panic(
"No legal translation IRIS address translation found.");
361 if (result.address.empty())
364 if (result.address.size() > 1) {
365 warn(
"Multiple mappings for address %#x.", vaddr);
369 paddr = result.address[0];
379 call().simulationTime_stop(iris::IrisInstIdSimulationEngine);
395 auto ret =
call().step_getStepCounterValue(
_instId, count,
"instruction");
396 panic_if(ret != iris::E_ok,
"Failed to get instruction count.");
425 if (new_status ==
Active) {
427 call().perInstanceExecution_setState(
_instId,
true);
430 call().perInstanceExecution_setState(
_instId,
false);
442 pc.nextThumb(pc.thumb());
444 pc.nextJazelle(cpsr.j);
445 pc.aarch64(!cpsr.width);
446 pc.nextAArch64(!cpsr.width);
447 pc.illegalExec(
false);
449 iris::ResourceReadResult result;
452 if (cpsr.width && cpsr.t)
464 if (cpsr.width && cpsr.t)
467 iris::ResourceWriteResult result;
480 return pcState().nextInstAddr();
486 iris::ResourceReadResult result;
488 return result.data.at(0);
494 iris::ResourceWriteResult result;
503 iris::ResourceReadResult result;
508 return result.data.at(0);
516 iris::ResourceWriteResult result;
533 if (res_id == iris::IRIS_UINT64_MAX)
535 iris::ResourceReadResult result;
537 return result.data.at(0);
543 iris::ResourceId res_id =
546 panic_if(res_id == iris::IRIS_UINT64_MAX,
547 "Int reg %d is not supported by fast model.", idx);
548 iris::ResourceWriteResult result;
557 iris::ResourceReadResult result;
559 return result.data.at(0);
566 "CC reg %d is not supported by fast model.", idx);
567 iris::ResourceWriteResult result;
584 iris::ResourceReadResult result;
586 size_t data_size = result.data.size() * (
sizeof(*result.data.data()));
587 size_t size = std::min(data_size, reg.SIZE);
588 memcpy(reg.raw_ptr<
void>(), (
void *)result.data.data(), size);
610 iris::ResourceReadResult result;
614 size_t num_bits = reg.NUM_BITS;
615 uint8_t *bytes = (uint8_t *)result.data.data();
616 while (num_bits > 8) {
617 reg.set_bits(offset, 8, *bytes);
623 reg.set_bits(offset, num_bits, *bytes);
void setStatus(Status new_status) override
void setCCRegFlat(RegIndex idx, RegVal val) override
#define panic(...)
This implements a cprintf based panic() function.
A TranslatingPortProxy in FS mode translates a virtual address to a physical address and then calls t...
bool remove(PCEvent *e) override
Addr instAddr() const override
RegVal readCCRegFlat(RegIndex idx) const override
const std::string & name()
std::vector< iris::MemorySpaceInfo > memorySpaces
void deschedule(Event *event)
Deschedule the specified event.
iris::EventStreamId initEventStreamId
std::vector< ArmISA::VecPredRegContainer > vecPredRegs
const VecPredRegContainer & readVecPredRegFlat(RegIndex idx) const override
bool FullSystem
The FullSystem variable can be used to determine the current mode of simulation.
iris::IrisCppAdapter & noThrow() const
std::vector< iris::MemorySupportedAddressTranslationResult > translations
BpInfoIt getOrAllocBp(Addr pc)
const VecRegContainer & readVecReg(const RegId ®) const override
ArmISA::PCState pcState() const override
std::unique_ptr< PortProxy > physProxy
void setMiscRegNoEffect(RegIndex misc_reg, const RegVal val) override
RegVal readIntRegFlat(RegIndex idx) const override
Flat register interfaces.
std::map< std::string, iris::ResourceInfo > ResourceMap
void setIntReg(RegIndex reg_idx, RegVal val) override
iris::EventStreamId timeEventStreamId
PortProxy::SendFunctionalFunc getSendFunctional() override
Returns a sendFunctional delegate for use with port proxies.
RegVal readMiscRegNoEffect(RegIndex misc_reg) const override
void setIntRegFlat(RegIndex idx, uint64_t val) override
void descheduleInstCountEvent(Event *event) override
RegVal readIntReg(RegIndex reg_idx) const override
EventQueue comInstEventQueue
std::unique_ptr< PortProxy > virtProxy
const VecRegContainer & readVecRegFlat(RegIndex idx) const override
virtual void initFromIrisInstance(const ResourceMap &resources)
iris::IrisErrorCode phaseInitLeave(uint64_t esId, const iris::IrisValueMap &fields, uint64_t time, uint64_t sInstId, bool syncEc, std::string &error_message_out)
uint64_t Tick
Tick count type.
VecPredReg::Container VecPredRegContainer
virtual iris::MemorySpaceId getBpSpaceId(Addr pc) const =0
iris::ResourceId extractResourceId(const ResourceMap &resources, const std::string &name)
iris::EventStreamId regEventStreamId
void serviceEvents(Tick when)
iris::IrisCppAdapter & call() const
iris::IrisErrorCode breakpointHit(uint64_t esId, const iris::IrisValueMap &fields, uint64_t time, uint64_t sInstId, bool syncEc, std::string &error_message_out)
iris::IrisErrorCode simulationTimeEvent(uint64_t esId, const iris::IrisValueMap &fields, uint64_t time, uint64_t sInstId, bool syncEc, std::string &error_message_out)
bool schedule(PCEvent *e) override
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
BpInfoMap::iterator BpInfoIt
Tick getCurrentInstCount() override
virtual void process(ThreadContext *tc)=0
void initMemProxies(::ThreadContext *tc) override
This object is a proxy for a port or other object which implements the functional response protocol...
const VecPredRegContainer & readVecPredReg(const RegId ®) const override
unsigned int cacheLineSize() const
Get the cache line size of the system.
VecReg::Container VecRegContainer
std::map< int, std::string > IdxNameMap
GenericISA::SimplePCState< MachInst > PCState
ResourceIds vecPredRegIds
std::vector< ArmISA::VecRegContainer > vecRegs
void schedule(Event *event, Tick when, bool global=false)
Schedule the given event on this queue.
ResourceIds flattenedIntIds
Process * getProcessPtr() override
TranslatingPortProxy Object Declaration for FS.
TranslatingPortProxy Object Declaration for SE.
const RegIndex & index() const
Index accessors.
void uninstallBp(BpInfoIt it)
Status status() const override
ThreadContext(::BaseCPU *cpu, int id, System *system, ::BaseTLB *dtb, ::BaseTLB *itb, iris::IrisConnectionInterface *iris_if, const std::string &iris_path)
Register ID: describe an architectural register with its class and index.
Addr nextInstAddr() const override
iris::IrisInstance client
void suspend() override
Set the status to Suspended.
iris::EventStreamId breakpointEventStreamId
iris::IrisErrorCode instanceRegistryChanged(uint64_t esId, const iris::IrisValueMap &fields, uint64_t time, uint64_t sInstId, bool syncEc, std::string &error_message_out)
void extractResourceMap(ResourceIds &ids, const ResourceMap &resources, const IdxNameMap &idx_names)
#define panic_if(cond,...)
Conditional panic macro that checks the supplied condition and only panics if the condition is true a...
void installBp(BpInfoIt it)
void scheduleInstCountEvent(Event *event, Tick count) override
bool translateAddress(Addr &paddr, iris::MemorySpaceId p_space, Addr vaddr, iris::MemorySpaceId v_space)