gem5  v22.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 namespace gem5
41 {
42 
43 class System;
44 
45 class KernelWorkload : public Workload
46 {
47  protected:
49 
57 
64 
66 
68 
70  // Keep a separate copy of the kernel's symbol table so we can add things
71  // to it.
73 
74  const std::string commandLine;
75 
76  public:
78 
79  Addr start() const { return _start; }
80  Addr end() const { return _end; }
81  Addr loadAddrMask() const { return _loadAddrMask; }
82  Addr loadAddrOffset() const { return _loadAddrOffset; }
83 
84  KernelWorkload(const Params &p);
85 
86  Addr getEntry() const override { return kernelObj->entryPoint(); }
87  ByteOrder byteOrder() const override { return kernelObj->getByteOrder(); }
89  getArch() const override
90  {
91  return kernelObj->getArch();
92  }
93 
94  const loader::SymbolTable &
95  symtab(ThreadContext *tc) override
96  {
97  return kernelSymtab;
98  }
99 
100  bool
101  insertSymbol(const loader::Symbol &symbol) override
102  {
103  return kernelSymtab.insert(symbol);
104  }
105 
106  void initState() override;
107 
108  void serialize(CheckpointOut &cp) const override;
109  void unserialize(CheckpointIn &cp) override;
110 
126  template <class T, typename... Args>
127  T *
128  addKernelFuncEvent(const char *lbl, Args... args)
129  {
130  return addFuncEvent<T>(kernelSymtab, lbl, std::forward<Args>(args)...);
131  }
132 
133  template <class T, typename... Args>
134  T *
135  addKernelFuncEventOrPanic(const char *lbl, Args... args)
136  {
137  T *e = addFuncEvent<T>(kernelSymtab, lbl, std::forward<Args>(args)...);
138  panic_if(!e, "Failed to find kernel symbol '%s'", lbl);
139  return e;
140  }
142 };
143 
144 } // namespace gem5
145 
146 #endif // __SIM_KERNEL_WORKLOAD_HH__
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,...
loader::SymbolTable kernelSymtab
const std::string commandLine
void serialize(CheckpointOut &cp) const override
Serialize an object.
PARAMS(KernelWorkload)
loader::Arch getArch() const override
Addr loadAddrMask() const
ByteOrder byteOrder() const override
const loader::SymbolTable & symtab(ThreadContext *tc) override
void initState() override
initState() is called on each SimObject when not restoring from a checkpoint.
loader::ObjectFile * kernelObj
T * addKernelFuncEvent(const char *lbl, Args... args)
Add a function-based event to a kernel symbol.
void unserialize(CheckpointIn &cp) override
Unserialize an object.
bool insertSymbol(const loader::Symbol &symbol) override
Addr _loadAddrOffset
Offset that should be used for binary/symbol loading.
T * addKernelFuncEventOrPanic(const char *lbl, Args... args)
Addr _loadAddrMask
Mask that should be anded for binary/symbol loading.
loader::MemoryImage image
Addr loadAddrOffset() const
KernelWorkload(const Params &p)
std::vector< loader::ObjectFile * > extras
Addr getEntry() const override
SimObjectParams Params
Definition: sim_object.hh:170
ThreadContext is the external interface to all thread state for anything outside of the CPU.
ByteOrder getByteOrder() const
Definition: object_file.hh:129
bool insert(const Symbol &symbol)
Insert a new symbol in the table if it does not already exist.
Definition: symtab.cc:55
STL vector class.
Definition: stl.hh:37
#define panic_if(cond,...)
Conditional panic macro that checks the supplied condition and only panics if the condition is true a...
Definition: logging.hh:204
Bitfield< 9 > e
Definition: misc_types.hh:65
Bitfield< 54 > p
Definition: pagetable.hh:70
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
std::ostream CheckpointOut
Definition: serialize.hh:66
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:147

Generated on Wed Dec 21 2022 10:22:39 for gem5 by doxygen 1.9.1