36#include "debug/Quiesce.hh"
37#include "debug/Timer.hh"
43using namespace SparcISA;
52 if (pil < 14 && softint & 0x10000)
56 if (pil < 14 && softint & 0x1)
62 for (
int bit = 15; bit > 0; --bit) {
63 if (1 << bit & softint && bit > pil)
71static inline std::string
75 {
"asi",
"tick",
"fprs",
"pcr",
"pic",
76 "gsr",
"softint_set",
"softint_clr",
"softint",
"tick_cmpr",
77 "stick",
"stick_cmpr",
78 "tpc",
"tnpc",
"tstate",
"tt",
"privtick",
"tba",
"pstate",
"tl",
81 "hpstate",
"htstate",
"hintp",
"htba",
"hver",
"strand_sts_reg",
83 "fsr",
"prictx",
"secctx",
"partId",
"lsuCtrlReg",
84 "scratch0",
"scratch1",
"scratch2",
"scratch3",
"scratch4",
85 "scratch5",
"scratch6",
"scratch7",
"cpuMondoHead",
"cpuMondoTail",
86 "devMondoHead",
"devMondoTail",
"resErrorHead",
"resErrorTail",
87 "nresErrorHead",
"nresErrorTail",
"TlbData" };
109 if (tickCompare == NULL)
112 if ((tick_cmpr & ~
mask(63)) && tickCompare->scheduled())
114 time = (tick_cmpr &
mask(63)) - (tick &
mask(63));
115 if (!(tick_cmpr & ~
mask(63)) && time > 0) {
116 if (tickCompare->scheduled())
120 DPRINTF(Timer,
"writing to TICK compare register value %#X\n",
val);
124 if (sTickCompare == NULL)
127 if ((stick_cmpr & ~
mask(63)) && sTickCompare->scheduled())
129 time = ((int64_t)(stick_cmpr &
mask(63)) - (int64_t)stick) -
131 if (!(stick_cmpr & ~
mask(63)) && time > 0) {
132 if (sTickCompare->scheduled())
136 DPRINTF(Timer,
"writing to sTICK compare register value %#X\n",
val);
149 panic(
"Shouldn't be writing HVER\n");
167 if (cpu_mondo_head != cpu_mondo_tail)
175 if (dev_mondo_head != dev_mondo_tail)
183 if (res_error_head != res_error_tail)
195 if (hSTickCompare == NULL)
198 if ((hstick_cmpr & ~
mask(63)) && hSTickCompare->scheduled())
200 time = ((int64_t)(hstick_cmpr &
mask(63)) - (int64_t)stick) -
202 if (!(hstick_cmpr & ~
mask(63)) && time > 0) {
203 if (hSTickCompare->scheduled())
207 DPRINTF(Timer,
"writing to hsTICK compare register value %#X\n",
val);
212 HPSTATE newVal =
val;
217 if (newVal.tlz &&
tl == 0 && !newVal.hpriv)
229 panic(
"No support for setting spec_en bit\n");
232 DPRINTF(Quiesce,
"Cpu executed quiescing instruction\n");
242 panic(
"Invalid write to FS misc register %s\n",
276 return 0x3eULL << 48 |
296 switch (sys->
threads[
x]->status()) {
298 temp |= STS::st_run << (STS::shft_fsm0 -
299 ((
x & 0x3) * (STS::shft_fsm0-STS::shft_fsm1)));
303 temp |= STS::st_idle << (STS::shft_fsm0 -
304 ((
x & 0x3) * (STS::shft_fsm0-STS::shft_fsm1)));
307 temp |= STS::st_halt << (STS::shft_fsm0 -
308 ((
x & 0x3) * (STS::shft_fsm0-STS::shft_fsm1)));
311 panic(
"What state are we in?!\n");
317 panic(
"Invalid read to FS misc register\n");
324 panic(
"tick compare not implemented\n");
336 delay = ((int64_t)(stick_cmpr &
mask(63)) - (int64_t)stick) -
338 assert(delay >= 0 &&
"stick compare missed interrupt cycle");
341 DPRINTF(Timer,
"STick compare cycle reached at %#x\n",
342 (stick_cmpr &
mask(63)));
363 delay = ((int64_t)(hstick_cmpr &
mask(63)) - (int64_t)stick) -
365 assert(delay >= 0 &&
"hstick compare missed interrupt cycle");
368 DPRINTF(Timer,
"HSTick compare cycle reached at %#x\n",
369 (stick_cmpr &
mask(63)));
void setMiscRegNoEffect(RegIndex idx, RegVal val) override
RegVal readMiscRegNoEffect(RegIndex idx) const override
void setMiscReg(RegIndex, RegVal val) override
void postInterrupt(ThreadID tid, int int_num, int index)
void clearInterrupt(ThreadID tid, int int_num, int index)
Tick clockEdge(Cycles cycles=Cycles(0)) const
Determine the tick when a cycle begins, by default the current one, but the argument also enables the...
Cycles is a wrapper class for representing cycle counts, i.e.
Wrap a member function inside MemberEventWrapper to use it as an event callback.
void setFSReg(int miscReg, RegVal val)
void processHSTickCompare()
void processSTickCompare()
void processTickCompare()
Process a tick compare event and generate an interrupt on the cpu if appropriate.
RegVal readFSReg(int miscReg)
Workload * workload
OS kernel.
virtual System * getSystemPtr()=0
virtual BaseCPU * getCpuPtr()=0
@ Halted
Permanently shut down.
@ Suspended
Temporarily inactive.
virtual Status status() const =0
virtual RegVal readMiscRegNoEffect(RegIndex misc_reg) const =0
virtual ContextID contextId() const =0
virtual void suspend()=0
Set the status to Suspended.
constexpr T bits(T val, unsigned first, unsigned last)
Extract the bitfield from position 'first' to 'last' (inclusive) from 'val' and right justify it.
void deschedule(Event &event)
void schedule(Event &event, Tick when)
#define panic(...)
This implements a cprintf based panic() function.
const char *const miscRegName[]
@ MISCREG_QUEUE_RES_ERROR_HEAD
@ MISCREG_HPSTATE
Hyper privileged registers.
@ MISCREG_QUEUE_DEV_MONDO_TAIL
@ MISCREG_QUEUE_CPU_MONDO_HEAD
@ MISCREG_QUEUE_NRES_ERROR_TAIL
@ MISCREG_QUEUE_CPU_MONDO_TAIL
@ MISCREG_QUEUE_DEV_MONDO_HEAD
@ MISCREG_QUEUE_RES_ERROR_TAIL
@ MISCREG_QUEUE_NRES_ERROR_HEAD
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
static std::string getMiscRegName(RegIndex index)