Go to the documentation of this file.
53 #include "debug/Loader.hh"
63 using namespace linux;
69 enableContextSwitchStatsDump(
p.enable_context_switch_stats_dump)
80 if (
params().early_kernel_symbols) {
89 bool kernel_has_fdt_support =
91 bool dtb_file_specified =
params().dtb_filename !=
"";
93 if (kernel_has_fdt_support && dtb_file_specified) {
94 bool initrd_file_specified =
params().initrd_filename !=
"";
95 size_t initrd_len = 0;
97 if (initrd_file_specified) {
98 inform(
"Loading initrd file: %s at address %#x\n",
104 initrd_file_data->data(),
105 initrd_file_data->len());
106 initrd_len = initrd_file_data->len();
111 inform(
"Loading DTB file: %s at address %#x\n",
params().dtb_filename,
117 params().initrd_addr, initrd_len)) {
118 warn(
"couldn't append bootargs to DTB file: %s\n",
122 dtb_file->buildImage().offset(
params().dtb_addr)
128 if (kernel_has_fdt_support) {
129 assert(!dtb_file_specified);
130 warn(
"Kernel supports device tree, but no DTB file specified\n");
133 if (dtb_file_specified) {
134 assert(!kernel_has_fdt_support);
135 warn(
"DTB file specified, but no device tree support in kernel\n");
145 "Expected a single ATAG memory entry but got %d",
148 am.memSize(atagRanges.begin()->size());
149 am.memStart(atagRanges.begin()->start());
154 DPRINTF(Loader,
"boot command line %d bytes: %s\n",
159 uint32_t size =
ac.size() +
am.size() + ad.
size() + an.
size();
161 uint8_t *boot_data =
new uint8_t[size << 2];
168 DPRINTF(Loader,
"Boot atags was %d bytes in total\n", size << 2);
169 DDUMP(Loader, boot_data, size << 2);
172 boot_data, size << 2);
213 dumpStats = addKernelFuncEvent<DumpStats64>(
"__switch_to");
215 dumpStats = addKernelFuncEvent<DumpStats>(
"__switch_to");
219 std::string task_filename =
"tasks.txt";
223 uint32_t pid = tc->getCpuPtr()->getPid();
226 tc->getCpuPtr()->taskId(
taskMap[pid]);
231 const std::string dmesg_output =
name() +
".dmesg";
232 if (
params().panic_on_panic) {
233 kernelPanic = addKernelFuncEventOrPanic<linux::KernelPanic>(
234 "panic",
"Kernel panic in simulated kernel", dmesg_output);
236 kernelPanic = addKernelFuncEventOrPanic<linux::DmesgDump>(
237 "panic",
"Kernel panic in simulated kernel", dmesg_output);
240 if (
params().panic_on_oops) {
241 kernelOops = addKernelFuncEventOrPanic<linux::KernelPanic>(
242 "oops_exit",
"Kernel oops in guest", dmesg_output);
244 kernelOops = addKernelFuncEventOrPanic<linux::DmesgDump>(
245 "oops_exit",
"Kernel oops in guest", dmesg_output);
251 "__loop_udelay",
"__udelay", 1000, 0);
254 "__udelay",
"__udelay", 1000, 0);
260 "__loop_const_udelay",
"__const_udelay", 1000, 107374);
263 "__const_udelay",
"__const_udelay", 1000, 107374);
273 std::map<uint32_t, uint32_t>::iterator itr =
taskMap.find(pid);
275 uint32_t map_size =
taskMap.size();
277 warn_once(
"Error out of identifiers for cache occupancy stats");
301 uint32_t &tgid, std::string &next_task_str, int32_t &
mm) {
305 pid =
ti.curTaskPID(task_descriptor);
306 tgid =
ti.curTaskTGID(task_descriptor);
307 next_task_str =
ti.curTaskName(task_descriptor);
311 mm =
ti.curTaskMm(task_descriptor);
323 uint32_t &tgid, std::string &next_task_str, int32_t &
mm) {
327 pid =
ti.curTaskPIDFromTaskStruct(task_struct);
328 tgid =
ti.curTaskTGIDFromTaskStruct(task_struct);
329 next_task_str =
ti.curTaskNameFromTaskStruct(task_struct);
333 mm =
ti.curTaskMmFromTaskStruct(task_struct);
344 std::string next_task_str;
349 bool is_kernel = (
mm == 0);
350 if (is_kernel && (pid != 0)) {
353 next_task_str =
"kernel";
357 panic_if(!wl,
"System workload is not ARM Linux!");
358 std::map<uint32_t, uint32_t>& taskMap = wl->
taskMap;
372 "tick=%lld %d cpu_id=%d next_pid=%d next_tgid=%d next_task=%s\n",
373 curTick(), taskMap[pid], tc->
cpuId(), (
int)pid, (
int)tgid,
375 taskFile->
stream()->flush();
Tick curTick()
The universal simulation clock.
Addr _loadAddrMask
Mask that should be anded for binary/symbol loading.
virtual System * getSystemPtr()=0
void writeBlob(Addr addr, const void *p, int size) const
Same as tryWriteBlob, but insists on success.
SymbolTablePtr globals() const
Generates a new symbol table containing only global symbols.
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 __...
PCEvent * skipUDelay
PC based event to skip udelay(<time>) calls and quiesce the processor for the appropriate amount of t...
virtual RegVal getReg(const RegId ®) const
PCEvent * skipConstUDelay
Another PC based skip event for const_udelay().
PortProxy physProxy
Port to physical memory used for writing object files into ram at boot.
const std::string commandLine
void mapPid(ThreadContext *tc, uint32_t pid)
This function creates a new task Id for the given pid.
void initState() override
initState() is called on each SimObject when not restoring from a checkpoint.
const_iterator end() const
bool enableContextSwitchStatsDump
When enabled, dump stats/task info on context switches for Streamline and per-thread cache occupancy ...
static const uint32_t invldPid
Invalid or unknown Pid.
Workload * workload
OS kernel.
OutputStream * create(const std::string &name, bool binary=false, bool no_gz=false)
Creates a file in this directory (optionally compressed).
const SymbolTable & symtab() const
loader::ObjectFile * kernelObj
virtual int cpuId() const =0
void setPid(uint32_t pid)
void ccprintf(cp::Print &print)
std::map< uint32_t, uint32_t > taskMap
This map stores a mapping of OS process IDs to internal Task IDs.
PCEvent * debugPrintk
PC based event to skip the dprink() call and emulate its functionality.
std::ostream * stream() const
Get the output underlying output stream.
uint32_t taskId() const
Get cpu task id.
PCEvent * kernelPanic
Event to halt the simulator if the kernel calls panic()
void startup() override
startup() is the final initialization call before simulation.
ThreadContext is the external interface to all thread state for anything outside of the CPU.
virtual std::string name() const
const Params & params() const
loader::SymbolTable kernelSymtab
void dumpDmesg()
Dump the kernel's dmesg buffer to stdout.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
loader::Arch getArch() const override
#define DDUMP(x, data, count)
DPRINTF is a debugging trace facility that allows one to selectively enable tracing statements.
void dumpDmesg(ThreadContext *tc, std::ostream &os)
Dump Linux's dmesg log buffer to the an output stream.
const_iterator find(Addr address) const
Search for a symbol by its address.
#define panic_if(cond,...)
Conditional panic macro that checks the supplied condition and only panics if the condition is true a...
OutputStream * taskFile
This is a file that is placed in the run directory that prints out mappings between taskIds and OS pr...
void cmdline(const std::string &s)
bool insert(const Symbol &symbol)
Insert a new symbol in the table if it does not already exist.
void process(ThreadContext *tc) override
This function is called whenever the the kernel function "__switch_to" is called to change running ta...
PCEvent * kernelOops
Event to halt the simulator if the kernel calls oopses
void startup() override
startup() is the final initialization call before simulation.
std::shared_ptr< ImageFileData > ImageFileDataPtr
void initState() override
initState() is called on each SimObject when not restoring from a checkpoint.
virtual BaseCPU * getCpuPtr()=0
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 ...
SymbolTable debugSymbolTable
Global unified debugging symbol table (for target).
memory::PhysicalMemory & getPhysMem()
Get a pointer to access the physical memory of the system.
#define fatal_if(cond,...)
Conditional fatal macro that checks the supplied condition and only causes a fatal error if the condi...
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
AddrRangeList getConfAddrRanges() const
Get the memory ranges for all memories that are to be reported to the configuration table.
void schedStatEvent(bool dump, bool reset, Tick when, Tick repeat)
Schedule statistics dumping.
Generated on Sun Jul 30 2023 01:56:47 for gem5 by doxygen 1.8.17