12212SN/A/*
211538Sandreas.sandberg@arm.com * Copyright (c) 2016 ARM Limited
311538Sandreas.sandberg@arm.com * All rights reserved
411538Sandreas.sandberg@arm.com *
511538Sandreas.sandberg@arm.com * The license below extends only to copyright in the software and shall
611538Sandreas.sandberg@arm.com * not be construed as granting a license to any other intellectual
711538Sandreas.sandberg@arm.com * property including but not limited to intellectual property relating
811538Sandreas.sandberg@arm.com * to a hardware implementation of the functionality of the software
911538Sandreas.sandberg@arm.com * licensed hereunder.  You may use the software subject to the license
1011538Sandreas.sandberg@arm.com * terms below provided that you ensure that this notice is replicated
1111538Sandreas.sandberg@arm.com * unmodified and in its entirety in all distributions of the software,
1211538Sandreas.sandberg@arm.com * modified or unmodified, in source code or in binary form.
1311538Sandreas.sandberg@arm.com *
142212SN/A * Copyright (c) 2004-2006 The Regents of The University of Michigan
152212SN/A * All rights reserved.
162212SN/A *
172212SN/A * Redistribution and use in source and binary forms, with or without
182212SN/A * modification, are permitted provided that the following conditions are
192212SN/A * met: redistributions of source code must retain the above copyright
202212SN/A * notice, this list of conditions and the following disclaimer;
212212SN/A * redistributions in binary form must reproduce the above copyright
222212SN/A * notice, this list of conditions and the following disclaimer in the
232212SN/A * documentation and/or other materials provided with the distribution;
242212SN/A * neither the name of the copyright holders nor the names of its
252212SN/A * contributors may be used to endorse or promote products derived from
262212SN/A * this software without specific prior written permission.
272212SN/A *
282212SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
292212SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
302212SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
312212SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
322212SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
332212SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
342212SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
352212SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
362212SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
372212SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
382212SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
392665Ssaidi@eecs.umich.edu *
402760Sbinkertn@umich.edu * Authors: Nathan Binkert
412760Sbinkertn@umich.edu *          Ali Saidi
422212SN/A */
432212SN/A
442212SN/A#ifndef __KERN_LINUX_EVENTS_HH__
452212SN/A#define __KERN_LINUX_EVENTS_HH__
462212SN/A
472212SN/A#include "kern/system_events.hh"
482212SN/A
492212SN/Anamespace Linux {
502212SN/A
512212SN/Aclass DebugPrintkEvent : public SkipFuncEvent
522212SN/A{
532212SN/A  public:
544429Ssaidi@eecs.umich.edu    DebugPrintkEvent(PCEventQueue *q, const std::string &desc, Addr addr)
554429Ssaidi@eecs.umich.edu        : SkipFuncEvent(q, desc, addr) {}
562680Sktlim@umich.edu    virtual void process(ThreadContext *xc);
572212SN/A};
582212SN/A
5911538Sandreas.sandberg@arm.com/**
6011538Sandreas.sandberg@arm.com * Dump the guest kernel's dmesg buffer to a file in gem5's output
6111538Sandreas.sandberg@arm.com * directory and print a warning.
6211538Sandreas.sandberg@arm.com *
6311538Sandreas.sandberg@arm.com * @warn This event uses Linux::dumpDmesg() and comes with the same
6411538Sandreas.sandberg@arm.com * limitations. Most importantly, the kernel's address mappings must
6511538Sandreas.sandberg@arm.com * be available to the translating proxy.
6611538Sandreas.sandberg@arm.com */
6711538Sandreas.sandberg@arm.comclass DmesgDumpEvent : public PCEvent
6811538Sandreas.sandberg@arm.com{
6911538Sandreas.sandberg@arm.com  protected:
7011538Sandreas.sandberg@arm.com    std::string fname;
7111538Sandreas.sandberg@arm.com
7211538Sandreas.sandberg@arm.com  public:
7311538Sandreas.sandberg@arm.com    DmesgDumpEvent(PCEventQueue *q, const std::string &desc, Addr addr,
7411538Sandreas.sandberg@arm.com                   const std::string &_fname)
7511538Sandreas.sandberg@arm.com        : PCEvent(q, desc, addr), fname(_fname) {}
7611538Sandreas.sandberg@arm.com    virtual void process(ThreadContext *xc);
7711538Sandreas.sandberg@arm.com};
7811538Sandreas.sandberg@arm.com
7911538Sandreas.sandberg@arm.com/**
8011538Sandreas.sandberg@arm.com * Dump the guest kernel's dmesg buffer to a file in gem5's output
8111538Sandreas.sandberg@arm.com * directory and panic.
8211538Sandreas.sandberg@arm.com *
8311538Sandreas.sandberg@arm.com * @warn This event uses Linux::dumpDmesg() and comes with the same
8411538Sandreas.sandberg@arm.com * limitations. Most importantly, the kernel's address mappings must
8511538Sandreas.sandberg@arm.com * be available to the translating proxy.
8611538Sandreas.sandberg@arm.com */
8711538Sandreas.sandberg@arm.comclass KernelPanicEvent : public PCEvent
8811538Sandreas.sandberg@arm.com{
8911538Sandreas.sandberg@arm.com  protected:
9011538Sandreas.sandberg@arm.com    std::string fname;
9111538Sandreas.sandberg@arm.com
9211538Sandreas.sandberg@arm.com  public:
9311538Sandreas.sandberg@arm.com    KernelPanicEvent(PCEventQueue *q, const std::string &desc, Addr addr,
9411538Sandreas.sandberg@arm.com               const std::string &_fname)
9511538Sandreas.sandberg@arm.com        : PCEvent(q, desc, addr), fname(_fname) {}
9611538Sandreas.sandberg@arm.com    virtual void process(ThreadContext *xc);
9711538Sandreas.sandberg@arm.com};
9811538Sandreas.sandberg@arm.com
998143SAli.Saidi@ARM.com/** A class to skip udelay() and related calls in the kernel.
1008143SAli.Saidi@ARM.com * This class has two additional parameters that take the argument to udelay and
1018143SAli.Saidi@ARM.com * manipulated it to come up with ns and eventually ticks to quiesce for.
1028143SAli.Saidi@ARM.com * See descriptions of argDivToNs and argMultToNs below.
1038143SAli.Saidi@ARM.com */
1048143SAli.Saidi@ARM.comclass UDelayEvent : public SkipFuncEvent
1058143SAli.Saidi@ARM.com{
1068143SAli.Saidi@ARM.com  private:
1078143SAli.Saidi@ARM.com    /** value to divide arg by to create ns. This is present beacues the linux
1088143SAli.Saidi@ARM.com     * kernel code sometime precomputes the first multiply that is done in
1098143SAli.Saidi@ARM.com     * udelay() if the parameter is a constant. We need to undo it so here is
1108143SAli.Saidi@ARM.com     * how. */
1118143SAli.Saidi@ARM.com    uint64_t argDivToNs;
1128143SAli.Saidi@ARM.com
1138143SAli.Saidi@ARM.com    /** value to multiple arg by to create ns. Nominally, this is 1000 to
1148143SAli.Saidi@ARM.com     * convert us to ns, but since linux can do some preprocessing of constant
1158143SAli.Saidi@ARM.com     * values something else might be required. */
1168143SAli.Saidi@ARM.com    uint64_t argMultToNs;
1178143SAli.Saidi@ARM.com
1188143SAli.Saidi@ARM.com  public:
1198143SAli.Saidi@ARM.com    UDelayEvent(PCEventQueue *q, const std::string &desc, Addr addr,
1208143SAli.Saidi@ARM.com            uint64_t mult, uint64_t div)
1218143SAli.Saidi@ARM.com        : SkipFuncEvent(q, desc, addr), argDivToNs(div), argMultToNs(mult) {}
1228143SAli.Saidi@ARM.com    virtual void process(ThreadContext *xc);
1238143SAli.Saidi@ARM.com};
1248143SAli.Saidi@ARM.com
1258143SAli.Saidi@ARM.com
1262212SN/A}
1272212SN/A
1282212SN/A#endif
129