Go to the documentation of this file.
46 #include "iris/detail/IrisCppAdapter.h"
47 #include "iris/detail/IrisObjects.h"
68 iris::EventSourceInfo evSrcInfo;
70 client.registerEventCallback<Self, &Self::breakpointHit>(
71 this,
"ec_IRIS_BREAKPOINT_HIT",
72 "Handle hitting a breakpoint",
"Iris::ThreadContext");
73 call().event_getEventSource(
_instId, evSrcInfo,
"IRIS_BREAKPOINT_HIT");
75 evSrcInfo.evSrcId,
client.getInstId());
77 for (
auto it =
bps.begin(); it !=
bps.end(); it++)
80 client.registerEventCallback<Self, &Self::semihostingEvent>(
81 this,
"ec_IRIS_SEMIHOSTING_CALL_EXTENSION",
82 "Handle a semihosting call",
"Iris::ThreadContext");
84 "IRIS_SEMIHOSTING_CALL_EXTENSION");
86 evSrcInfo.evSrcId,
client.getInstId(),
89 nullptr,
"",
false, 0,
nullptr,
false,
false,
true);
96 return resources.at(
name).rscId;
104 for (
const auto &idx_name: idx_names) {
105 int idx = idx_name.first;
106 const std::string &
name = idx_name.second;
108 if (idx >=
ids.size())
109 ids.resize(idx + 1, iris::IRIS_UINT64_MAX);
138 Tick remaining = next - now;
139 call().step_setup(
_instId, remaining,
"instruction");
147 auto pc_it =
bps.find(
pc);
149 if (pc_it !=
bps.end())
153 panic_if(!res.second,
"Inserting breakpoint failed.");
162 for (
auto sid: space_ids) {
165 it->second->ids.push_back(
id);
172 for (
auto id: it->second->ids)
174 it->second->clearIds();
181 "BP info still had events associated with it.");
183 if (it->second->validIds())
191 uint64_t esId,
const iris::IrisValueMap &fields, uint64_t time,
192 uint64_t sInstId,
bool syncEc, std::string &error_message_out)
194 const std::string &
event = fields.at(
"EVENT").getString();
195 const iris::InstanceId
id = fields.at(
"INST_ID").getU64();
196 const std::string &
name = fields.at(
"INST_NAME").getString();
201 if (
event ==
"added")
203 else if (
event ==
"removed")
204 _instId = iris::IRIS_UINT64_MAX;
213 uint64_t esId,
const iris::IrisValueMap &fields, uint64_t time,
214 uint64_t sInstId,
bool syncEc, std::string &error_message_out)
219 std::map<iris::ResourceId, const iris::ResourceInfo *>
221 for (
const auto &resource: resources) {
222 idToResource[resource.rscId] = &resource;
225 for (
const auto &resource: resources) {
226 std::string
name = resource.name;
227 iris::ResourceId parentId = resource.parentRscId;
228 while (parentId != iris::IRIS_UINT64_MAX) {
229 const auto *parent = idToResource[parentId];
231 parentId = parent->parentRscId;
233 resourceMap[
name] = resource;
243 uint64_t esId,
const iris::IrisValueMap &fields, uint64_t time,
244 uint64_t sInstId,
bool syncEc, std::string &error_message_out)
246 if (fields.at(
"RUNNING").getAsBool()) {
258 call().simulationTime_run(iris::IrisInstIdSimulationEngine);
265 uint64_t esId,
const iris::IrisValueMap &fields, uint64_t time,
266 uint64_t sInstId,
bool syncEc, std::string &error_message_out)
268 Addr pc = fields.at(
"PC").getU64();
272 std::shared_ptr<BpInfo::EventList> events = it->second->events;
273 auto e_it = events->begin();
274 while (e_it != events->end()) {
286 uint64_t esId,
const iris::IrisValueMap &fields, uint64_t time,
287 uint64_t sInstId,
bool syncEc, std::string &error_message_out)
292 call().perInstanceExecution_setState(
_instId,
false);
308 BaseISA *isa, iris::IrisConnectionInterface *iris_if,
309 const std::string &iris_path) :
310 _cpu(cpu), _threadId(
id), _system(
system), _mmu(mmu), _isa(isa),
313 comInstEventQueue(
"instruction-based event queue"),
314 client(iris_if,
"client." + iris_path)
316 iris::InstanceInfo info;
317 auto ret_code =
noThrow().instanceRegistry_getInstanceInfoByName(
318 info,
"component." + iris_path);
319 if (ret_code == iris::E_ok) {
324 _instId = iris::IRIS_UINT64_MAX;
328 iris::EventSourceInfo evSrcInfo;
330 client.registerEventCallback<Self, &Self::instanceRegistryChanged>(
331 this,
"ec_IRIS_INSTANCE_REGISTRY_CHANGED",
332 "Install the iris instance ID",
"Iris::ThreadContext");
333 call().event_getEventSource(iris::IrisInstIdGlobalInstance, evSrcInfo,
334 "IRIS_INSTANCE_REGISTRY_CHANGED");
337 {
"EVENT",
"INST_ID",
"INST_NAME" };
339 evSrcInfo.evSrcId,
client.getInstId(), &fields);
341 client.registerEventCallback<Self, &Self::phaseInitLeave>(
342 this,
"ec_IRIS_SIM_PHASE_INIT_LEAVE",
343 "Initialize register contexts",
"Iris::ThreadContext");
344 call().event_getEventSource(iris::IrisInstIdSimulationEngine, evSrcInfo,
345 "IRIS_SIM_PHASE_INIT_LEAVE");
347 call().eventStream_create(
349 evSrcInfo.evSrcId,
client.getInstId());
351 client.registerEventCallback<Self, &Self::simulationTimeEvent>(
352 this,
"ec_IRIS_SIMULATION_TIME_EVENT",
353 "Handle simulation time stopping for breakpoints or stepping",
354 "Iris::ThreadContext");
355 call().event_getEventSource(iris::IrisInstIdSimulationEngine, evSrcInfo,
356 "IRIS_SIMULATION_TIME_EVENT");
358 call().eventStream_create(
360 evSrcInfo.evSrcId,
client.getInstId());
365 auto enable_lambda = [
this]{
366 call().perInstanceExecution_setState(
_instId,
true);
369 enable_lambda,
"resume after pseudo inst",
375 call().eventStream_destroy(
378 client.unregisterEventCallback(
"ec_IRIS_SIM_PHASE_INIT_LEAVE");
380 call().eventStream_destroy(
383 client.unregisterEventCallback(
"ec_IRIS_INSTANCE_REGISTRY_CHANGED");
385 call().eventStream_destroy(
388 client.unregisterEventCallback(
"ec_IRIS_SIMULATION_TIME_EVENT");
399 it->second->events->push_back(
e);
401 if (
_instId != iris::IRIS_UINT64_MAX && !it->second->validIds())
411 it->second->events->remove(
e);
413 if (it->second->empty())
423 iris::MemoryAddressTranslationResult result;
424 auto ret =
noThrow().memory_translateAddress(
427 if (ret != iris::E_ok) {
431 if (trans.inSpaceId == v_space && trans.outSpaceId == p_space)
434 panic(
"No legal translation IRIS address translation found.");
437 if (result.address.empty())
440 if (result.address.size() > 1) {
441 warn(
"Multiple mappings for address %#x.",
vaddr);
445 paddr = result.address[0];
455 call().simulationTime_stop(iris::IrisInstIdSimulationEngine);
472 panic_if(ret != iris::E_ok,
"Failed to get instruction count.");
502 if (new_status ==
Active) {
504 call().perInstanceExecution_setState(
_instId,
true);
507 call().perInstanceExecution_setState(
_instId,
false);
519 pc.nextThumb(
pc.thumb());
521 pc.nextJazelle(cpsr.j);
522 pc.aarch64(!cpsr.width);
523 pc.nextAArch64(!cpsr.width);
524 pc.illegalExec(
false);
528 iris::ResourceReadResult result;
531 if (cpsr.width && cpsr.t)
543 if (cpsr.width && cpsr.t)
546 iris::ResourceWriteResult result;
559 return pcState().nextInstAddr();
565 iris::ResourceReadResult result;
567 return result.data.at(0);
573 iris::ResourceWriteResult result;
582 iris::ResourceReadResult result;
587 return result.data.at(0);
595 iris::ResourceWriteResult result;
612 if (res_id == iris::IRIS_UINT64_MAX)
614 iris::ResourceReadResult result;
616 return result.data.at(0);
622 iris::ResourceId res_id =
625 panic_if(res_id == iris::IRIS_UINT64_MAX,
626 "Int reg %d is not supported by fast model.", idx);
627 iris::ResourceWriteResult result;
636 iris::ResourceReadResult result;
638 return result.data.at(0);
645 "CC reg %d is not supported by fast model.", idx);
646 iris::ResourceWriteResult result;
663 iris::ResourceReadResult result;
665 size_t data_size = result.data.size() * (
sizeof(*result.data.data()));
666 size_t size = std::min(data_size,
reg.size());
667 memcpy(
reg.raw_ptr<
void>(), (
void *)result.data.data(), size);
689 iris::ResourceReadResult result;
693 size_t num_bits =
reg.NUM_BITS;
694 uint8_t *bytes = (uint8_t *)result.data.data();
695 while (num_bits > 8) {
void setMiscRegNoEffect(RegIndex misc_reg, const RegVal val) override
void initMemProxies(::ThreadContext *tc) override
bool scheduled() const
Determine if the current event is scheduled.
void setIntReg(RegIndex reg_idx, RegVal val) override
iris::IrisCppAdapter & noThrow() const
void uninstallBp(BpInfoIt it)
const VecRegContainer & readVecRegFlat(RegIndex idx) const override
VecReg::Container VecRegContainer
Event * enableAfterPseudoEvent
ArmISA::PCState pcState() const override
std::unique_ptr< PortProxy > virtProxy
iris::EventStreamId timeEventStreamId
iris::EventStreamId breakpointEventStreamId
std::vector< ArmISA::VecPredRegContainer > vecPredRegs
unsigned int cacheLineSize() const
Get the cache line size of the system.
std::unique_ptr< PortProxy > physProxy
const VecPredRegContainer & readVecPredRegFlat(RegIndex idx) const override
uint64_t Tick
Tick count type.
VecPredReg::Container VecPredRegContainer
static uint8_t itState(CPSR psr)
void setIntRegFlat(RegIndex idx, uint64_t val) override
iris::EventStreamId initEventStreamId
void deschedule(Event &event)
iris::IrisErrorCode instanceRegistryChanged(uint64_t esId, const iris::IrisValueMap &fields, uint64_t time, uint64_t sInstId, bool syncEc, std::string &error_message_out)
void installBp(BpInfoIt it)
iris::EventStreamId regEventStreamId
bool FullSystem
The FullSystem variable can be used to determine the current mode of simulation.
bool schedule(PCEvent *e) override
virtual const std::vector< iris::MemorySpaceId > & getBpSpaceIds() const =0
static bool callSemihosting(ThreadContext *tc, bool gem5_ops=false)
Make a Semihosting call from either aarch64 or aarch32.
std::vector< iris::MemorySupportedAddressTranslationResult > translations
BpInfoIt getOrAllocBp(Addr pc)
PortProxy::SendFunctionalFunc getSendFunctional() override
Returns a sendFunctional delegate for use with port proxies.
Status status() const override
Register ID: describe an architectural register with its class and index.
Addr nextInstAddr() const override
bool translateAddress(Addr &paddr, iris::MemorySpaceId p_space, Addr vaddr, iris::MemorySpaceId v_space)
std::vector< iris::MemorySpaceInfo > memorySpaces
iris::IrisErrorCode phaseInitLeave(uint64_t esId, const iris::IrisValueMap &fields, uint64_t time, uint64_t sInstId, bool syncEc, std::string &error_message_out)
iris::IrisErrorCode semihostingEvent(uint64_t esId, const iris::IrisValueMap &fields, uint64_t time, uint64_t sInstId, bool syncEc, std::string &error_message_out)
void schedule(Event &event, Tick when)
static const Priority Sim_Exit_Pri
If we want to exit on this cycle, it's the very last thing we do.
Addr instAddr() const override
iris::IrisErrorCode breakpointHit(uint64_t esId, const iris::IrisValueMap &fields, uint64_t time, uint64_t sInstId, bool syncEc, std::string &error_message_out)
RegVal readIntReg(RegIndex reg_idx) const override
ThreadContext(::BaseCPU *cpu, int id, System *system, ::BaseMMU *mmu, ::BaseISA *isa, iris::IrisConnectionInterface *iris_if, const std::string &iris_path)
bool empty() const
Returns true if no events are queued.
void serviceEvents(Tick when)
process all events up to the given timestamp.
const VecPredRegContainer & readVecPredReg(const RegId ®) const override
RegVal readCCRegFlat(RegIndex idx) const override
std::map< int, std::string > IdxNameMap
std::vector< ArmISA::VecRegContainer > vecRegs
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
iris::IrisCppAdapter & call() const
void scheduleInstCountEvent(Event *event, Tick count) override
const std::string & name()
RegVal readMiscRegNoEffect(RegIndex misc_reg) const override
bool remove(PCEvent *e) override
void schedule(Event *event, Tick when, bool global=false)
Schedule the given event on this queue.
This proxy attempts to translate virtual addresses using the TLBs.
iris::EventStreamId semihostingEventStreamId
#define panic_if(cond,...)
Conditional panic macro that checks the supplied condition and only panics if the condition is true a...
@ VecRegClass
Vector Register.
@ Suspended
Temporarily inactive.
iris::IrisInstance client
This object is a proxy for a port or other object which implements the functional response protocol,...
void extractResourceMap(ResourceIds &ids, const ResourceMap &resources, const IdxNameMap &idx_names)
::BaseCPU * getCpuPtr() override
GenericISA::DelaySlotPCState< MachInst > PCState
void deschedule(Event *event)
Deschedule the specified event.
BpInfoMap::iterator BpInfoIt
iris::ResourceId extractResourceId(const ResourceMap &resources, const std::string &name)
void setStatus(Status new_status) override
ResourceIds vecPredRegIds
Tick curTick()
The universal simulation clock.
ResourceIds flattenedIntIds
void descheduleInstCountEvent(Event *event) override
const RegIndex & index() const
Index accessors.
Tick getCurrentInstCount() override
std::map< std::string, iris::ResourceInfo > ResourceMap
void setCCRegFlat(RegIndex idx, RegVal val) override
EventQueue comInstEventQueue
iris::IrisErrorCode simulationTimeEvent(uint64_t esId, const iris::IrisValueMap &fields, uint64_t time, uint64_t sInstId, bool syncEc, std::string &error_message_out)
RegVal readIntRegFlat(RegIndex idx) const override
Flat register interfaces.
virtual void initFromIrisInstance(const ResourceMap &resources)
#define panic(...)
This implements a cprintf based panic() function.
void suspend() override
Set the status to Suspended.
const VecRegContainer & readVecReg(const RegId ®) const override
Generated on Tue Jun 22 2021 15:28:19 for gem5 by doxygen 1.8.17