gem5  v20.0.0.2
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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 
73 
74  const std::string commandLine;
75 
76  public:
77  const Params &params() const { return _params; }
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);
86 
87  Addr getEntry() const override { return kernelObj->entryPoint(); }
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 #endif // __SIM_KERNEL_WORKLOAD_HH__
bool insertSymbol(const Loader::Symbol &symbol) override
Loader::SymbolTable * kernelSymtab
KernelWorkloadParams Params
std::vector< Loader::ObjectFile * > extras
void unserialize(CheckpointIn &cp) override
Unserialize an object.
T * addKernelFuncEvent(const char *lbl, Args... args)
Add a function-based event to a kernel symbol.
Definition: system.hh:72
const Params & params() const
Definition: cprintf.cc:40
ThreadContext is the external interface to all thread state for anything outside of the CPU...
Addr _loadAddrMask
Mask that should be anded for binary/symbol loading.
STL vector class.
Definition: stl.hh:37
Loader::ObjectFile * kernelObj
Loader::MemoryImage image
void initState() override
initState() is called on each SimObject when not restoring from a checkpoint.
bool insert(const Symbol &symbol)
Definition: symtab.cc:58
const std::string commandLine
Addr loadAddrMask() const
const Loader::SymbolTable * symtab(ThreadContext *tc) override
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,16,32,64}_t.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:140
const Params & _params
T * addKernelFuncEventOrPanic(const char *lbl, Args... args)
Arch getArch() const
Definition: object_file.hh:121
Bitfield< 9 > e
void serialize(CheckpointOut &cp) const override
Serialize an object.
std::ostream CheckpointOut
Definition: serialize.hh:63
Addr entryPoint() const
Definition: object_file.hh:128
Addr loadAddrOffset() const
Addr end() const
Addr start() const
Bitfield< 0 > p
#define panic_if(cond,...)
Conditional panic macro that checks the supplied condition and only panics if the condition is true a...
Definition: logging.hh:181
Addr _loadAddrOffset
Offset that should be used for binary/symbol loading.
KernelWorkload(const Params &p)
Addr getEntry() const override
Loader::Arch getArch() const override

Generated on Mon Jun 8 2020 15:45:13 for gem5 by doxygen 1.8.13