gem5  v20.0.0.2
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
events.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016 ARM Limited
3  * All rights reserved
4  *
5  * The license below extends only to copyright in the software and shall
6  * not be construed as granting a license to any other intellectual
7  * property including but not limited to intellectual property relating
8  * to a hardware implementation of the functionality of the software
9  * licensed hereunder. You may use the software subject to the license
10  * terms below provided that you ensure that this notice is replicated
11  * unmodified and in its entirety in all distributions of the software,
12  * modified or unmodified, in source code or in binary form.
13  *
14  * Copyright (c) 2004-2006 The Regents of The University of Michigan
15  * All rights reserved.
16  *
17  * Redistribution and use in source and binary forms, with or without
18  * modification, are permitted provided that the following conditions are
19  * met: redistributions of source code must retain the above copyright
20  * notice, this list of conditions and the following disclaimer;
21  * redistributions in binary form must reproduce the above copyright
22  * notice, this list of conditions and the following disclaimer in the
23  * documentation and/or other materials provided with the distribution;
24  * neither the name of the copyright holders nor the names of its
25  * contributors may be used to endorse or promote products derived from
26  * this software without specific prior written permission.
27  *
28  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39  */
40 
41 #ifndef __KERN_LINUX_EVENTS_HH__
42 #define __KERN_LINUX_EVENTS_HH__
43 
44 #include <functional>
45 #include <string>
46 
47 #include "base/trace.hh"
48 #include "debug/DebugPrintf.hh"
49 #include "kern/linux/printk.hh"
50 #include "kern/system_events.hh"
51 #include "sim/guest_abi.hh"
52 
53 class ThreadContext;
54 
55 namespace Linux
56 {
57 
58 template <typename Base>
59 class DebugPrintk : public Base
60 {
61  public:
62  using Base::Base;
63  void
64  process(ThreadContext *tc) override
65  {
66  if (DTRACE(DebugPrintf)) {
67  std::string str;
68  std::function<int(ThreadContext *, Addr, PrintkVarArgs)> func =
69  [&str](ThreadContext *tc, Addr format_ptr,
70  PrintkVarArgs args) -> int {
71  return printk(str, tc, format_ptr, args);
72  };
73  invokeSimcall<typename Base::ABI>(tc, func);
74  DPRINTFN("%s", str);
75  }
76  Base::process(tc);
77  }
78 };
79 
88 class DmesgDump : public PCEvent
89 {
90  protected:
91  std::string fname;
92 
93  public:
94  DmesgDump(PCEventScope *s, const std::string &desc, Addr addr,
95  const std::string &_fname) :
96  PCEvent(s, desc, addr), fname(_fname)
97  {}
98  void process(ThreadContext *tc) override;
99 };
100 
109 class KernelPanic : public PCEvent
110 {
111  protected:
112  std::string fname;
113 
114  public:
115  KernelPanic(PCEventScope *s, const std::string &desc, Addr addr,
116  const std::string &_fname) :
117  PCEvent(s, desc, addr), fname(_fname)
118  {}
119  void process(ThreadContext *tc) override;
120 };
121 
122 void onUDelay(ThreadContext *tc, uint64_t div, uint64_t mul);
123 
130 template <typename Base>
131 class SkipUDelay : public Base
132 {
133  private:
140  uint64_t argDivToNs;
141 
147  uint64_t argMultToNs;
148 
149  public:
150  SkipUDelay(PCEventScope *s, const std::string &desc, Addr addr,
151  uint64_t mult, uint64_t div) :
152  Base(s, desc, addr), argDivToNs(div), argMultToNs(mult)
153  {}
154 
155  void
156  process(ThreadContext *tc) override
157  {
158  onUDelay(tc, argDivToNs, argMultToNs);
159  Base::process(tc);
160  }
161 };
162 
163 } // namespace Linux
164 
165 #endif // __KERN_LINUX_EVENTS_HH__
void process(ThreadContext *tc) override
Definition: events.hh:156
uint64_t argMultToNs
Value to multiple arg by to create ns.
Definition: events.hh:147
Dump the guest kernel&#39;s dmesg buffer to a file in gem5&#39;s output directory and panic.
Definition: events.hh:109
ip6_addr_t addr
Definition: inet.hh:330
#define DTRACE(x)
Definition: debug.hh:143
int printk(std::string &str, ThreadContext *tc, Addr format_ptr, PrintkVarArgs args)
Definition: printk.cc:44
ThreadContext is the external interface to all thread state for anything outside of the CPU...
#define DPRINTFN(...)
Definition: trace.hh:226
std::string fname
Definition: events.hh:112
void onUDelay(ThreadContext *tc, uint64_t div, uint64_t mul)
Definition: events.cc:81
DmesgDump(PCEventScope *s, const std::string &desc, Addr addr, const std::string &_fname)
Definition: events.hh:94
Bitfield< 4 > s
uint64_t argDivToNs
Value to divide arg by to create ns.
Definition: events.hh:140
A class to skip udelay() and related calls in the kernel.
Definition: events.hh:131
void process(ThreadContext *tc) override
Definition: events.hh:64
SkipUDelay(PCEventScope *s, const std::string &desc, Addr addr, uint64_t mult, uint64_t div)
Definition: events.hh:150
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:140
GuestABI::VarArgs< Addr, int32_t, uint32_t, int64_t, uint64_t > PrintkVarArgs
Definition: printk.hh:41
KernelPanic(PCEventScope *s, const std::string &desc, Addr addr, const std::string &_fname)
Definition: events.hh:115
Dump the guest kernel&#39;s dmesg buffer to a file in gem5&#39;s output directory and print a warning...
Definition: events.hh:88
std::string fname
Definition: events.hh:91

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