gem5  v20.1.0.0
fs_workload.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 Ruslan Bukin <br@bsdpad.com>
3  * All rights reserved.
4  *
5  * This software was developed by the University of Cambridge Computer
6  * Laboratory as part of the CTSRD Project, with support from the UK Higher
7  * Education Innovation Fund (HEIF).
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions are
11  * met: redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer;
13  * redistributions in binary form must reproduce the above copyright
14  * notice, this list of conditions and the following disclaimer in the
15  * documentation and/or other materials provided with the distribution;
16  * neither the name of the copyright holders nor the names of its
17  * contributors may be used to endorse or promote products derived from
18  * this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 
34 
35 #include "arch/arm/isa_traits.hh"
36 #include "arch/arm/utility.hh"
38 #include "base/loader/dtb_file.hh"
40 #include "base/loader/symtab.hh"
41 #include "cpu/base.hh"
42 #include "cpu/pc_event.hh"
43 #include "cpu/thread_context.hh"
44 #include "debug/Loader.hh"
45 #include "kern/freebsd/events.hh"
46 #include "mem/physical.hh"
47 #include "sim/stat_control.hh"
48 
49 using namespace FreeBSD;
50 
51 namespace ArmISA
52 {
53 
54 FsFreebsd::FsFreebsd(Params *p) : ArmISA::FsWorkload(p),
55  enableContextSwitchStatsDump(p->enable_context_switch_stats_dump)
56 {
57  if (p->panic_on_panic) {
58  kernelPanic = addKernelFuncEventOrPanic<PanicPCEvent>(
59  "panic", "Kernel panic in simulated kernel");
60  } else {
61 #ifndef NDEBUG
62  kernelPanic = addKernelFuncEventOrPanic<BreakPCEvent>("panic");
63 #endif
64  }
65 
66  if (p->panic_on_oops) {
67  kernelOops = addKernelFuncEventOrPanic<PanicPCEvent>(
68  "oops_exit", "Kernel oops in guest");
69  }
70 
71  skipUDelay = addKernelFuncEvent<SkipUDelay<ArmISA::SkipFunc>>(
72  "DELAY", "DELAY", 1000, 0);
73 }
74 
75 void
77 {
79 
80  // Load symbols at physical address, we might not want
81  // to do this permanently, for but early bootup work
82  // it is helpful.
83  if (params()->early_kernel_symbols) {
84  auto phys_globals = kernelObj->symtab().globals()->mask(_loadAddrMask);
85  kernelSymtab.insert(*phys_globals);
86  Loader::debugSymbolTable.insert(*phys_globals);
87  }
88 
89  // Check if the kernel image has a symbol that tells us it supports
90  // device trees.
91  fatal_if(kernelSymtab.find("fdt_get_range") == kernelSymtab.end(),
92  "Kernel must have fdt support.");
93  fatal_if(params()->dtb_filename == "", "dtb file is not specified.");
94 
95  // Kernel supports flattened device tree and dtb file specified.
96  // Using Device Tree Blob to describe system configuration.
97  inform("Loading DTB file: %s at address %#x\n", params()->dtb_filename,
98  params()->atags_addr + _loadAddrOffset);
99 
100  auto *dtb_file = new ::Loader::DtbFile(params()->dtb_filename);
101 
102  warn_if(!dtb_file->addBootCmdLine(commandLine.c_str(), commandLine.size()),
103  "Couldn't append bootargs to DTB file: %s",
104  params()->dtb_filename);
105 
106  Addr ra = dtb_file->findReleaseAddr();
107  if (ra)
108  bootReleaseAddr = ra & ~ULL(0x7F);
109 
110  dtb_file->buildImage().
111  offset(params()->atags_addr + _loadAddrOffset).
112  write(system->physProxy);
113  delete dtb_file;
114 
115  // Kernel boot requirements to set up r0, r1 and r2 in ARMv7
116  for (auto *tc: system->threads) {
117  tc->setIntReg(0, 0);
118  tc->setIntReg(1, params()->machine_type);
119  tc->setIntReg(2, params()->atags_addr + _loadAddrOffset);
120  }
121 }
122 
124 {
125  delete skipUDelay;
126 }
127 
128 } // namespace ArmISA
129 
131 ArmFsFreebsdParams::create()
132 {
133  return new ArmISA::FsFreebsd(this);
134 }
System::physProxy
PortProxy physProxy
Port to physical memory used for writing object files into ram at boot.
Definition: system.hh:324
events.hh
ArmISA::FsWorkload::initState
void initState() override
initState() is called on each SimObject when not restoring from a checkpoint.
Definition: fs_workload.cc:98
dtb_file.hh
Workload::system
System * system
Definition: workload.hh:64
ArmISA::FsFreebsd::Params
ArmFsFreebsdParams Params
Boilerplate params code.
Definition: fs_workload.hh:49
ArmISA
Definition: ccregs.hh:41
ArmISA::FsFreebsd
Definition: fs_workload.hh:45
fs_workload.hh
Loader::SymbolTable::find
const_iterator find(Addr address) const
Definition: symtab.hh:181
KernelWorkload::kernelSymtab
Loader::SymbolTable kernelSymtab
Definition: kernel_workload.hh:74
ArmISA::FsFreebsd::~FsFreebsd
~FsFreebsd()
Definition: fs_workload.cc:123
Loader::debugSymbolTable
SymbolTable debugSymbolTable
Global unified debugging symbol table (for target).
Definition: symtab.cc:47
Loader::ObjectFile::symtab
const SymbolTable & symtab() const
Definition: object_file.hh:102
KernelWorkload::_loadAddrOffset
Addr _loadAddrOffset
Offset that should be used for binary/symbol loading.
Definition: kernel_workload.hh:65
PowerISA::ra
Bitfield< 20, 16 > ra
Definition: types.hh:45
ArmISA::FsWorkload
Definition: fs_workload.hh:62
KernelWorkload::kernelObj
Loader::ObjectFile * kernelObj
Definition: kernel_workload.hh:71
Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
utility.hh
Loader::SymbolTable::globals
SymbolTablePtr globals() const
Definition: symtab.hh:159
Loader::SymbolTable::end
const_iterator end() const
Definition: symtab.hh:126
stat_control.hh
warn_if
#define warn_if(cond,...)
Conditional warning macro that checks the supplied condition and only prints a warning if the conditi...
Definition: logging.hh:263
System::threads
Threads threads
Definition: system.hh:309
inform
#define inform(...)
Definition: logging.hh:240
base.hh
pc_event.hh
physical.hh
isa_traits.hh
ArmISA::FsFreebsd::kernelPanic
PCEvent * kernelPanic
Event to halt the simulator if the kernel calls panic()
Definition: fs_workload.hh:81
FreeBSD
Definition: threadinfo.hh:39
Loader::SymbolTable::insert
bool insert(const Symbol &symbol)
Definition: symtab.cc:58
symtab.hh
MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:323
KernelWorkload::commandLine
const std::string commandLine
Definition: kernel_workload.hh:76
threadinfo.hh
fatal_if
#define fatal_if(cond,...)
Conditional fatal macro that checks the supplied condition and only causes a fatal error if the condi...
Definition: logging.hh:219
ArmISA::FsFreebsd::skipUDelay
PCEvent * skipUDelay
PC based event to skip udelay(<time>) calls and quiesce the processor for the appropriate amount of t...
Definition: fs_workload.hh:91
ArmISA::FsFreebsd::params
const Params * params() const
Definition: fs_workload.hh:51
ArmISA::FsFreebsd::bootReleaseAddr
Addr bootReleaseAddr
Definition: fs_workload.hh:102
object_file.hh
ArmISA::FsFreebsd::kernelOops
PCEvent * kernelOops
Event to halt the simulator if the kernel calls oopses
Definition: fs_workload.hh:84
thread_context.hh
ULL
#define ULL(N)
uint64_t constant
Definition: types.hh:50
KernelWorkload::_loadAddrMask
Addr _loadAddrMask
Mask that should be anded for binary/symbol loading.
Definition: kernel_workload.hh:58
ArmISA::FsFreebsd::initState
void initState() override
initState() is called on each SimObject when not restoring from a checkpoint.
Definition: fs_workload.cc:76
ArmISA::offset
Bitfield< 23, 0 > offset
Definition: types.hh:153

Generated on Wed Sep 30 2020 14:01:59 for gem5 by doxygen 1.8.17