gem5  v20.1.0.0
kernel_workload.hh
Go to the documentation of this file.
1 /*
2  * Copyright 2019 Google Inc.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are
6  * met: redistributions of source code must retain the above copyright
7  * notice, this list of conditions and the following disclaimer;
8  * redistributions in binary form must reproduce the above copyright
9  * notice, this list of conditions and the following disclaimer in the
10  * documentation and/or other materials provided with the distribution;
11  * neither the name of the copyright holders nor the names of its
12  * contributors may be used to endorse or promote products derived from
13  * this software without specific prior written permission.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  */
27 
28 #ifndef __SIM_KERNEL_WORKLOAD_HH__
29 #define __SIM_KERNEL_WORKLOAD_HH__
30 
31 #include <string>
32 #include <vector>
33 
35 #include "base/loader/symtab.hh"
36 #include "base/types.hh"
37 #include "params/KernelWorkload.hh"
38 #include "sim/workload.hh"
39 
40 class System;
41 
42 class KernelWorkload : public Workload
43 {
44  public:
45  using Params = KernelWorkloadParams;
46 
47  protected:
48  const Params &_params;
49 
51 
59 
66 
68 
70 
72  // Keep a separate copy of the kernel's symbol table so we can add things
73  // to it.
75 
76  const std::string commandLine;
77 
78  public:
79  const Params &params() const { return _params; }
80 
81  Addr start() const { return _start; }
82  Addr end() const { return _end; }
83  Addr loadAddrMask() const { return _loadAddrMask; }
84  Addr loadAddrOffset() const { return _loadAddrOffset; }
85 
86  KernelWorkload(const Params &p);
87 
88  Addr getEntry() const override { return kernelObj->entryPoint(); }
90  getArch() const override
91  {
92  return kernelObj->getArch();
93  }
94 
95  const Loader::SymbolTable &
96  symtab(ThreadContext *tc) override
97  {
98  return kernelSymtab;
99  }
100 
101  bool
102  insertSymbol(const Loader::Symbol &symbol) override
103  {
104  return kernelSymtab.insert(symbol);
105  }
106 
107  void initState() override;
108 
109  void serialize(CheckpointOut &cp) const override;
110  void unserialize(CheckpointIn &cp) override;
111 
127  template <class T, typename... Args>
128  T *
129  addKernelFuncEvent(const char *lbl, Args... args)
130  {
131  return addFuncEvent<T>(kernelSymtab, lbl, std::forward<Args>(args)...);
132  }
133 
134  template <class T, typename... Args>
135  T *
136  addKernelFuncEventOrPanic(const char *lbl, Args... args)
137  {
138  T *e = addFuncEvent<T>(kernelSymtab, lbl, std::forward<Args>(args)...);
139  panic_if(!e, "Failed to find kernel symbol '%s'", lbl);
140  return e;
141  }
143 };
144 
145 #endif // __SIM_KERNEL_WORKLOAD_HH__
KernelWorkload::addKernelFuncEventOrPanic
T * addKernelFuncEventOrPanic(const char *lbl, Args... args)
Definition: kernel_workload.hh:136
KernelWorkload::image
Loader::MemoryImage image
Definition: kernel_workload.hh:50
KernelWorkload::getEntry
Addr getEntry() const override
Definition: kernel_workload.hh:88
Workload
Definition: workload.hh:40
KernelWorkload
Definition: kernel_workload.hh:42
KernelWorkload::addKernelFuncEvent
T * addKernelFuncEvent(const char *lbl, Args... args)
Add a function-based event to a kernel symbol.
Definition: kernel_workload.hh:129
KernelWorkload::loadAddrOffset
Addr loadAddrOffset() const
Definition: kernel_workload.hh:84
Loader::SymbolTable
Definition: symtab.hh:59
KernelWorkload::getArch
Loader::Arch getArch() const override
Definition: kernel_workload.hh:90
KernelWorkload::unserialize
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: kernel_workload.cc:134
std::vector< Loader::ObjectFile * >
workload.hh
Loader::MemoryImage
Definition: memory_image.hh:48
KernelWorkload::_end
Addr _end
Definition: kernel_workload.hh:67
KernelWorkload::kernelSymtab
Loader::SymbolTable kernelSymtab
Definition: kernel_workload.hh:74
Loader::ObjectFile
Definition: object_file.hh:70
cp
Definition: cprintf.cc:40
KernelWorkload::initState
void initState() override
initState() is called on each SimObject when not restoring from a checkpoint.
Definition: kernel_workload.cc:86
Loader::ObjectFile::entryPoint
Addr entryPoint() const
Definition: object_file.hh:108
ThreadContext
ThreadContext is the external interface to all thread state for anything outside of the CPU.
Definition: thread_context.hh:88
KernelWorkload::params
const Params & params() const
Definition: kernel_workload.hh:79
KernelWorkload::_loadAddrOffset
Addr _loadAddrOffset
Offset that should be used for binary/symbol loading.
Definition: kernel_workload.hh:65
System
Definition: system.hh:73
KernelWorkload::start
Addr start() const
Definition: kernel_workload.hh:81
KernelWorkload::_start
Addr _start
Definition: kernel_workload.hh:67
KernelWorkload::kernelObj
Loader::ObjectFile * kernelObj
Definition: kernel_workload.hh:71
KernelWorkload::symtab
const Loader::SymbolTable & symtab(ThreadContext *tc) override
Definition: kernel_workload.hh:96
Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
ArmISA::e
Bitfield< 9 > e
Definition: miscregs_types.hh:61
KernelWorkload::serialize
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: kernel_workload.cc:128
KernelWorkload::Params
KernelWorkloadParams Params
Definition: kernel_workload.hh:45
panic_if
#define panic_if(cond,...)
Conditional panic macro that checks the supplied condition and only panics if the condition is true a...
Definition: logging.hh:197
Loader::Arch
Arch
Definition: object_file.hh:44
Loader::ObjectFile::getArch
Arch getArch() const
Definition: object_file.hh:99
Loader::Symbol
Definition: symtab.hh:46
types.hh
KernelWorkload::loadAddrMask
Addr loadAddrMask() const
Definition: kernel_workload.hh:83
KernelWorkload::end
Addr end() const
Definition: kernel_workload.hh:82
CheckpointOut
std::ostream CheckpointOut
Definition: serialize.hh:63
Loader::SymbolTable::insert
bool insert(const Symbol &symbol)
Definition: symtab.cc:58
symtab.hh
KernelWorkload::extras
std::vector< Loader::ObjectFile * > extras
Definition: kernel_workload.hh:69
KernelWorkload::KernelWorkload
KernelWorkload(const Params &p)
Definition: kernel_workload.cc:34
KernelWorkload::_params
const Params & _params
Definition: kernel_workload.hh:48
MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:323
KernelWorkload::commandLine
const std::string commandLine
Definition: kernel_workload.hh:76
KernelWorkload::insertSymbol
bool insertSymbol(const Loader::Symbol &symbol) override
Definition: kernel_workload.hh:102
CheckpointIn
Definition: serialize.hh:67
object_file.hh
KernelWorkload::_loadAddrMask
Addr _loadAddrMask
Mask that should be anded for binary/symbol loading.
Definition: kernel_workload.hh:58

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