55 #include "debug/Loader.hh"
62 using namespace ArmISA;
63 using namespace Linux;
67 enableContextSwitchStatsDump(p->enable_context_switch_stats_dump),
68 taskFile(nullptr), kernelPanicEvent(nullptr), kernelOopsEvent(nullptr)
70 const std::string dmesg_output =
name() +
".dmesg";
71 if (p->panic_on_panic) {
73 "panic",
"Kernel panic in simulated kernel", dmesg_output);
76 "panic",
"Kernel panic in simulated kernel", dmesg_output);
79 if (p->panic_on_oops) {
81 "oops_exit",
"Kernel oops in guest", dmesg_output);
84 "oops_exit",
"Kernel oops in guest", dmesg_output);
90 "__loop_udelay",
"__udelay", 1000, 0);
93 "__udelay",
"__udelay", 1000, 0);
98 "__loop_const_udelay",
"__const_udelay", 1000, 107374);
99 if (!constUDelaySkipEvent)
100 constUDelaySkipEvent = addKernelFuncEventOrPanic<UDelayEvent>(
101 "__const_udelay",
"__const_udelay", 1000, 107374);
117 if (
params()->early_kernel_symbols) {
126 bool kernel_has_fdt_support =
128 bool dtb_file_specified =
params()->dtb_filename !=
"";
130 if (kernel_has_fdt_support && dtb_file_specified) {
133 inform(
"Loading DTB file: %s at address %#x\n",
params()->dtb_filename,
138 fatal(
"couldn't load DTB file: %s\n",
params()->dtb_filename);
145 params()->boot_osflags.size())) {
146 warn(
"couldn't append bootargs to DTB file: %s\n",
150 warn(
"dtb_file cast failed; couldn't append bootargs "
151 "to DTB file: %s\n",
params()->dtb_filename);
160 if (kernel_has_fdt_support) {
161 assert(!dtb_file_specified);
162 warn(
"Kernel supports device tree, but no DTB file specified\n");
165 if (dtb_file_specified) {
166 assert(!kernel_has_fdt_support);
167 warn(
"DTB file specified, but no device tree support in kernel\n");
176 if (atagRanges.size() != 1) {
177 fatal(
"Expected a single ATAG memory entry but got %d\n",
181 am.
memSize(atagRanges.begin()->size());
182 am.
memStart(atagRanges.begin()->start());
187 DPRINTF(Loader,
"boot command line %d bytes: %s\n",
188 ad.
size() <<2,
params()->boot_osflags.c_str());
194 uint8_t *boot_data =
new uint8_t[size << 2];
196 offset += ac.
copyOut(boot_data + offset);
197 offset += am.
copyOut(boot_data + offset);
198 offset += ad.
copyOut(boot_data + offset);
199 offset += an.copyOut(boot_data + offset);
201 DPRINTF(Loader,
"Boot atags was %d bytes in total\n", size << 2);
202 DDUMP(Loader, boot_data, size << 2);
230 LinuxArmSystemParams::create()
241 panic(
"dumpStatsPCEvent not created!");
243 std::string task_filename =
"tasks.txt";
248 uint32_t pid = tc->
getCpuPtr()->getPid();
249 if (pid != BaseCPU::invldPid) {
261 std::map<uint32_t, uint32_t>::iterator itr =
taskMap.find(pid);
263 uint32_t map_size =
taskMap.size();
265 warn_once(
"Error out of identifiers for cache occupancy stats");
291 uint32_t pid = ti.
curTaskPID(task_descriptor);
293 std::string next_task_str = ti.
curTaskName(task_descriptor);
298 bool is_kernel = (mm == 0);
299 if (is_kernel && (pid != 0)) {
302 next_task_str =
"kernel";
307 panic(
"System is not LinuxArmSystem while getting Linux process info!");
309 std::map<uint32_t, uint32_t>& taskMap = sys->
taskMap;
323 "tick=%lld %d cpu_id=%d next_pid=%d next_tgid=%d next_task=%s\n",
324 curTick(), taskMap[pid], tc->
cpuId(), (int) pid, (
int) tgid,
326 taskFile->
stream()->flush();
void ccprintf(cp::Print &print)
std::ostream * stream() const
Get the output underlying output stream.
virtual System * getSystemPtr()=0
virtual void initState()
Initialise the system.
OutputStream * create(const std::string &name, bool binary=false, bool no_gz=false)
Creates a file in this directory (optionally compressed).
void startup()
startup() is the final initialization call before simulation.
virtual bool loadGlobalSymbols(SymbolTable *symtab, Addr base=0, Addr offset=0, Addr mask=maxAddr)=0
void dumpDmesg(ThreadContext *tc, std::ostream &os)
Dump Linux's dmesg log buffer to the an output stream.
PCEvent * kernelPanicEvent
Event to halt the simulator if the kernel calls panic()
LinuxArmSystemParams Params
Boilerplate params code.
#define DDUMP(x, data, count)
void pagesize(uint32_t i)
void dumpDmesg()
Dump the kernel's dmesg buffer to stdout.
SymbolTable * debugSymbolTable
Global unified debugging symbol table (for target).
This implements an object file format to support loading and modifying flattened device tree blobs fo...
std::map< uint32_t, uint32_t > taskMap
This map stores a mapping of OS process IDs to internal Task IDs.
virtual BaseCPU * getCpuPtr()=0
bool findAddress(const std::string &symbol, Addr &address) const
void memStart(uint32_t i)
Linux::UDelayEvent * uDelaySkipEvent
PC based event to skip udelay(<time>) calls and quiesce the processor for the appropriate amount of t...
ThreadContext is the external interface to all thread state for anything outside of the CPU...
LinuxArmSystem(Params *p)
PortProxy physProxy
Port to physical memory used for writing object files into ram at boot.
Tick curTick()
The current simulated tick.
DumpStatsPCEvent * dumpStatsPCEvent
virtual uint64_t readIntReg(int reg_idx)=0
This class encapsulates the types, structures, constants, functions, and syscall-number mappings spec...
AddrRangeList getConfAddrRanges() const
Get the memory ranges for all memories that are to be reported to the configuration table...
void initState()
Initialise the system.
virtual int cpuId() const =0
Linux::UDelayEvent * constUDelaySkipEvent
Another PC based skip event for const_udelay().
Addr loadAddrMask
Mask that should be anded for binary/symbol loading.
const Params * params() const
std::vector< ThreadContext * > threadContexts
virtual void process(ThreadContext *tc)
This function is called whenever the the kernel function "__switch_to" is called to change running ta...
void cmdline(const std::string &s)
ThreadContext * getThreadContext(ContextID tid)
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
virtual bool loadSections(PortProxy &mem_proxy, Addr mask=maxAddr, Addr offset=0)
SymbolTable * kernelSymtab
kernel symbol table
ObjectFile * kernel
Object pointer for the kernel code.
virtual const std::string name() const
int32_t curTaskPID(Addr thread_info=0)
bool addBootCmdLine(const char *_args, size_t len)
Adds the passed in Command Line options for the kernel to the proper location in the device tree...
ObjectFile * createObjectFile(const string &fname, bool raw)
int32_t curTaskMm(Addr thread_info=0)
virtual void writeBlob(Addr addr, const uint8_t *p, int size) const
Write size bytes from p to address.
TranslatingPortProxy Object Declaration for FS.
bool enableContextSwitchStatsDump
When enabled, dump stats/task info on context switches for Streamline and per-thread cache occupancy ...
std::string curTaskName(Addr thread_info=0)
void schedStatEvent(bool dump, bool reset, Tick when, Tick repeat)
Schedule statistics dumping.
PCEvent * kernelOopsEvent
Event to halt the simulator if the kernel calls oopses.
Addr loadAddrOffset
Offset that should be used for binary/symbol loading.
int32_t curTaskTGID(Addr thread_info=0)
OutputStream * taskFile
This is a file that is placed in the run directory that prints out mappings between taskIds and OS pr...
void mapPid(ThreadContext *tc, uint32_t pid)
This function creates a new task Id for the given pid.