gem5
v20.1.0.0
kern
linux
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 "
mem/se_translating_port_proxy.hh
"
52
#include "
sim/guest_abi.hh
"
53
54
class
ThreadContext
;
55
56
namespace
Linux
57
{
58
59
template
<
typename
Base>
60
class
DebugPrintk
:
public
Base
61
{
62
public
:
63
using
Base::Base;
64
void
65
process
(
ThreadContext
*tc)
override
66
{
67
if
(
DTRACE
(DebugPrintf)) {
68
std::string str;
69
std::function<int(
ThreadContext
*,
Addr
,
PrintkVarArgs
)> func =
70
[&str](
ThreadContext
*tc,
Addr
format_ptr,
71
PrintkVarArgs
args) ->
int
{
72
return
printk
(str, tc, format_ptr, args);
73
};
74
invokeSimcall<typename Base::ABI>(tc, func);
75
DPRINTFN
(
"%s"
, str);
76
}
77
Base::process(tc);
78
}
79
};
80
89
class
DmesgDump
:
public
PCEvent
90
{
91
protected
:
92
std::string
fname
;
93
94
public
:
95
DmesgDump
(
PCEventScope
*
s
,
const
std::string &desc,
Addr
addr
,
96
const
std::string &_fname) :
97
PCEvent
(
s
, desc,
addr
),
fname
(_fname)
98
{}
99
void
process
(
ThreadContext
*tc)
override
;
100
};
101
110
class
KernelPanic
:
public
PCEvent
111
{
112
protected
:
113
std::string
fname
;
114
115
public
:
116
KernelPanic
(
PCEventScope
*
s
,
const
std::string &desc,
Addr
addr
,
117
const
std::string &_fname) :
118
PCEvent
(
s
, desc,
addr
),
fname
(_fname)
119
{}
120
void
process
(
ThreadContext
*tc)
override
;
121
};
122
123
void
onUDelay
(
ThreadContext
*tc, uint64_t div, uint64_t mul);
124
131
template
<
typename
Base>
132
class
SkipUDelay
:
public
Base
133
{
134
private
:
141
uint64_t
argDivToNs
;
142
148
uint64_t
argMultToNs
;
149
150
public
:
151
SkipUDelay
(
PCEventScope
*
s
,
const
std::string &desc,
Addr
addr
,
152
uint64_t mult, uint64_t div) :
153
Base(
s
, desc,
addr
),
argDivToNs
(div),
argMultToNs
(mult)
154
{}
155
156
void
157
process
(
ThreadContext
*tc)
override
158
{
159
onUDelay
(tc,
argDivToNs
,
argMultToNs
);
160
Base::process(tc);
161
}
162
};
163
164
}
// namespace Linux
165
166
#endif // __KERN_LINUX_EVENTS_HH__
Linux::SkipUDelay::SkipUDelay
SkipUDelay(PCEventScope *s, const std::string &desc, Addr addr, uint64_t mult, uint64_t div)
Definition:
events.hh:151
Linux::onUDelay
void onUDelay(ThreadContext *tc, uint64_t div, uint64_t mul)
Definition:
events.cc:81
Linux::SkipUDelay::process
void process(ThreadContext *tc) override
Definition:
events.hh:157
Linux::DmesgDump::DmesgDump
DmesgDump(PCEventScope *s, const std::string &desc, Addr addr, const std::string &_fname)
Definition:
events.hh:95
Linux::printk
int printk(std::string &str, ThreadContext *tc, Addr format_ptr, PrintkVarArgs args)
Definition:
printk.cc:44
DTRACE
#define DTRACE(x)
Definition:
debug.hh:146
Linux::DebugPrintk
Definition:
events.hh:60
Linux::SkipUDelay
A class to skip udelay() and related calls in the kernel.
Definition:
events.hh:132
ThreadContext
ThreadContext is the external interface to all thread state for anything outside of the CPU.
Definition:
thread_context.hh:88
Linux::DmesgDump::fname
std::string fname
Definition:
events.hh:92
Linux::SkipUDelay::argDivToNs
uint64_t argDivToNs
Value to divide arg by to create ns.
Definition:
events.hh:141
Linux::DmesgDump
Dump the guest kernel's dmesg buffer to a file in gem5's output directory and print a warning.
Definition:
events.hh:89
PCEventScope
Definition:
pc_event.hh:64
Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition:
types.hh:142
Linux::KernelPanic::KernelPanic
KernelPanic(PCEventScope *s, const std::string &desc, Addr addr, const std::string &_fname)
Definition:
events.hh:116
Linux::KernelPanic::process
void process(ThreadContext *tc) override
Definition:
events.cc:70
Linux::SkipUDelay::argMultToNs
uint64_t argMultToNs
Value to multiple arg by to create ns.
Definition:
events.hh:148
Linux::DebugPrintk::process
void process(ThreadContext *tc) override
Definition:
events.hh:65
guest_abi.hh
addr
ip6_addr_t addr
Definition:
inet.hh:423
system_events.hh
Linux::PrintkVarArgs
GuestABI::VarArgs< Addr, int32_t, uint32_t, int64_t, uint64_t > PrintkVarArgs
Definition:
printk.hh:41
PCEvent
Definition:
pc_event.hh:42
se_translating_port_proxy.hh
trace.hh
Linux::KernelPanic::fname
std::string fname
Definition:
events.hh:113
DPRINTFN
#define DPRINTFN(...)
Definition:
trace.hh:238
ArmISA::s
Bitfield< 4 > s
Definition:
miscregs_types.hh:556
Linux::KernelPanic
Dump the guest kernel's dmesg buffer to a file in gem5's output directory and panic.
Definition:
events.hh:110
Linux
Definition:
threadinfo.hh:35
Linux::DmesgDump::process
void process(ThreadContext *tc) override
Definition:
events.cc:59
printk.hh
Generated on Wed Sep 30 2020 14:02:12 for gem5 by
doxygen
1.8.17