Go to the documentation of this file.
54 #include "debug/Loader.hh"
61 using namespace Linux;
67 enableContextSwitchStatsDump(
p.enable_context_switch_stats_dump)
78 if (
params().early_kernel_symbols) {
87 bool kernel_has_fdt_support =
89 bool dtb_file_specified =
params().dtb_filename !=
"";
91 if (kernel_has_fdt_support && dtb_file_specified) {
94 inform(
"Loading DTB file: %s at address %#x\n",
params().dtb_filename,
97 auto *dtb_file = new ::Loader::DtbFile(
params().dtb_filename);
99 if (!dtb_file->addBootCmdLine(
101 warn(
"couldn't append bootargs to DTB file: %s\n",
105 dtb_file->buildImage().offset(
params().dtb_addr)
111 if (kernel_has_fdt_support) {
112 assert(!dtb_file_specified);
113 warn(
"Kernel supports device tree, but no DTB file specified\n");
116 if (dtb_file_specified) {
117 assert(!kernel_has_fdt_support);
118 warn(
"DTB file specified, but no device tree support in kernel\n");
128 "Expected a single ATAG memory entry but got %d",
131 am.memSize(atagRanges.begin()->size());
132 am.memStart(atagRanges.begin()->start());
142 uint32_t size =
ac.size() +
am.size() + ad.
size() + an.
size();
144 uint8_t *boot_data =
new uint8_t[size << 2];
151 DPRINTF(
Loader,
"Boot atags was %d bytes in total\n", size << 2);
155 boot_data, size << 2);
165 tc->setIntReg(0,
params().dtb_addr);
166 tc->setIntReg(5,
params().cpu_release_addr);
172 tc->setIntReg(1,
params().machine_type);
173 tc->setIntReg(2,
params().dtb_addr);
196 dumpStats = addKernelFuncEvent<DumpStats64>(
"__switch_to");
198 dumpStats = addKernelFuncEvent<DumpStats>(
"__switch_to");
202 std::string task_filename =
"tasks.txt";
206 uint32_t pid = tc->getCpuPtr()->getPid();
209 tc->getCpuPtr()->taskId(
taskMap[pid]);
214 const std::string dmesg_output =
name() +
".dmesg";
215 if (
params().panic_on_panic) {
216 kernelPanic = addKernelFuncEventOrPanic<Linux::KernelPanic>(
217 "panic",
"Kernel panic in simulated kernel", dmesg_output);
219 kernelPanic = addKernelFuncEventOrPanic<Linux::DmesgDump>(
220 "panic",
"Kernel panic in simulated kernel", dmesg_output);
223 if (
params().panic_on_oops) {
224 kernelOops = addKernelFuncEventOrPanic<Linux::KernelPanic>(
225 "oops_exit",
"Kernel oops in guest", dmesg_output);
227 kernelOops = addKernelFuncEventOrPanic<Linux::DmesgDump>(
228 "oops_exit",
"Kernel oops in guest", dmesg_output);
234 "__loop_udelay",
"__udelay", 1000, 0);
237 "__udelay",
"__udelay", 1000, 0);
243 "__loop_const_udelay",
"__const_udelay", 1000, 107374);
246 "__const_udelay",
"__const_udelay", 1000, 107374);
256 std::map<uint32_t, uint32_t>::iterator itr =
taskMap.find(pid);
258 uint32_t map_size =
taskMap.size();
260 warn_once(
"Error out of identifiers for cache occupancy stats");
284 uint32_t &tgid, std::string &next_task_str, int32_t &
mm) {
288 pid =
ti.curTaskPID(task_descriptor);
289 tgid =
ti.curTaskTGID(task_descriptor);
290 next_task_str =
ti.curTaskName(task_descriptor);
294 mm =
ti.curTaskMm(task_descriptor);
306 uint32_t &tgid, std::string &next_task_str, int32_t &
mm) {
310 pid =
ti.curTaskPIDFromTaskStruct(task_struct);
311 tgid =
ti.curTaskTGIDFromTaskStruct(task_struct);
312 next_task_str =
ti.curTaskNameFromTaskStruct(task_struct);
316 mm =
ti.curTaskMmFromTaskStruct(task_struct);
327 std::string next_task_str;
332 bool is_kernel = (
mm == 0);
333 if (is_kernel && (pid != 0)) {
336 next_task_str =
"kernel";
340 panic_if(!wl,
"System workload is not ARM Linux!");
341 std::map<uint32_t, uint32_t>& taskMap = wl->
taskMap;
355 "tick=%lld %d cpu_id=%d next_pid=%d next_tgid=%d next_task=%s\n",
356 curTick(), taskMap[pid], tc->
cpuId(), (
int)pid, (
int)tgid,
358 taskFile->
stream()->flush();
bool enableContextSwitchStatsDump
When enabled, dump stats/task info on context switches for Streamline and per-thread cache occupancy ...
PortProxy physProxy
Port to physical memory used for writing object files into ram at boot.
PCEvent * kernelOops
Event to halt the simulator if the kernel calls oopses
PCEvent * debugPrintk
PC based event to skip the dprink() call and emulate its functionality.
OutputStream * taskFile
This is a file that is placed in the run directory that prints out mappings between taskIds and OS pr...
OutputStream * create(const std::string &name, bool binary=false, bool no_gz=false)
Creates a file in this directory (optionally compressed).
void initState() override
initState() is called on each SimObject when not restoring from a checkpoint.
void process(ThreadContext *tc) override
This function is called whenever the the kernel function "__switch_to" is called to change running ta...
static const uint32_t invldPid
Invalid or unknown Pid.
PhysicalMemory & getPhysMem()
Get a pointer to access the physical memory of the system.
const_iterator find(Addr address) const
void writeBlob(Addr addr, const void *p, int size) const
Same as tryWriteBlob, but insists on success.
virtual void startup()
startup() is the final initialization call before simulation.
Loader::SymbolTable kernelSymtab
SymbolTable debugSymbolTable
Global unified debugging symbol table (for target).
Workload * workload
OS kernel.
const SymbolTable & symtab() const
ThreadContext is the external interface to all thread state for anything outside of the CPU.
void mapPid(ThreadContext *tc, uint32_t pid)
This function creates a new task Id for the given pid.
std::ostream * stream() const
Get the output underlying output stream.
PCEvent * skipConstUDelay
Another PC based skip event for const_udelay().
virtual int cpuId() const =0
void setPid(uint32_t pid)
void startup() override
startup() is the final initialization call before simulation.
Loader::ObjectFile * kernelObj
Loader::Arch getArch() const override
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
virtual void getTaskDetails(ThreadContext *tc, uint32_t &pid, uint32_t &tgid, std::string &next_task_str, int32_t &mm)
Extracts the information used by the DumpStatsPCEvent by reading the thread_info pointer passed to __...
#define DDUMP(x, data, count)
DPRINTF is a debugging trace facility that allows one to selectively enable tracing statements.
void schedStatEvent(bool dump, bool reset, Tick when, Tick repeat)
Schedule statistics dumping.
SymbolTablePtr globals() const
std::map< uint32_t, uint32_t > taskMap
This map stores a mapping of OS process IDs to internal Task IDs.
uint32_t taskId() const
Get cpu task id.
void dumpDmesg()
Dump the kernel's dmesg buffer to stdout.
virtual const std::string name() const
void cmdline(const std::string &s)
const_iterator end() const
#define panic_if(cond,...)
Conditional panic macro that checks the supplied condition and only panics if the condition is true a...
PCEvent * skipUDelay
PC based event to skip udelay(<time>) calls and quiesce the processor for the appropriate amount of t...
PCEvent * kernelPanic
Event to halt the simulator if the kernel calls panic()
void ccprintf(cp::Print &print)
void dumpDmesg(ThreadContext *tc, std::ostream &os)
Dump Linux's dmesg log buffer to the an output stream.
Tick curTick()
The universal simulation clock.
bool insert(const Symbol &symbol)
AddrRangeList getConfAddrRanges() const
Get the memory ranges for all memories that are to be reported to the configuration table.
const Params & params() const
const std::string commandLine
virtual RegVal readIntReg(RegIndex reg_idx) const =0
#define fatal_if(cond,...)
Conditional fatal macro that checks the supplied condition and only causes a fatal error if the condi...
virtual BaseCPU * getCpuPtr()=0
void initState() override
initState() is called on each SimObject when not restoring from a checkpoint.
virtual System * getSystemPtr()=0
Addr _loadAddrMask
Mask that should be anded for binary/symbol loading.
void getTaskDetails(ThreadContext *tc, uint32_t &pid, uint32_t &tgid, std::string &next_task_str, int32_t &mm) override
Extracts the information used by the DumpStatsPCEvent64 by reading the task_struct pointer passed to ...
Generated on Tue Jun 22 2021 15:28:20 for gem5 by doxygen 1.8.17