system.hh revision 10810:683ab55819fd
1/*
2 * Copyright (c) 2015 Ruslan Bukin <br@bsdpad.com>
3 * All rights reserved.
4 *
5 * This software was developed by the University of Cambridge Computer
6 * Laboratory as part of the CTSRD Project, with support from the UK Higher
7 * Education Innovation Fund (HEIF).
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions are
11 * met: redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer;
13 * redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution;
16 * neither the name of the copyright holders nor the names of its
17 * contributors may be used to endorse or promote products derived from
18 * this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
32
33#ifndef __ARCH_ARM_FREEBSD_SYSTEM_HH__
34#define __ARCH_ARM_FREEBSD_SYSTEM_HH__
35
36#include <cstdio>
37#include <map>
38#include <string>
39#include <vector>
40
41#include "arch/arm/system.hh"
42#include "base/output.hh"
43#include "kern/freebsd/events.hh"
44#include "params/FreebsdArmSystem.hh"
45#include "sim/core.hh"
46
47class DumpStatsPCEventF;
48
49class FreebsdArmSystem : public GenericArmSystem
50{
51  protected:
52    DumpStatsPCEventF *dumpStatsPCEventF;
53
54  public:
55    /** Boilerplate params code */
56    typedef FreebsdArmSystemParams Params;
57    const Params *
58    params() const
59    {
60        return dynamic_cast<const Params *>(_params);
61    }
62
63    /** When enabled, dump stats/task info on context switches for
64     *  Streamline and per-thread cache occupancy studies, etc. */
65    bool enableContextSwitchStatsDump;
66
67    /** This map stores a mapping of OS process IDs to internal Task IDs. The
68     * mapping is done because the stats system doesn't tend to like vectors
69     * that are much greater than 1000 items and the entire process space is
70     * 65K. */
71    std::map<uint32_t, uint32_t> taskMap;
72
73    /** This is a file that is placed in the run directory that prints out
74     * mappings between taskIds and OS process IDs */
75    std::ostream* taskFile;
76
77    FreebsdArmSystem(Params *p);
78    ~FreebsdArmSystem();
79
80    void initState();
81
82    bool adderBootUncacheable(Addr a);
83
84    void startup();
85
86    /** This function creates a new task Id for the given pid.
87     * @param tc thread context that is currentyl executing  */
88    void mapPid(ThreadContext* tc, uint32_t pid);
89
90  private:
91    /** Event to halt the simulator if the kernel calls panic()  */
92    PCEvent *kernelPanicEvent;
93
94    /** Event to halt the simulator if the kernel calls oopses  */
95    PCEvent *kernelOopsEvent;
96
97    /**
98     * PC based event to skip udelay(<time>) calls and quiesce the
99     * processor for the appropriate amount of time. This is not functionally
100     * required but does speed up simulation.
101     */
102    FreeBSD::UDelayEvent *uDelaySkipEvent;
103
104    /** Another PC based skip event for const_udelay(). Similar to the udelay
105     * skip, but this function precomputes the first multiply that is done
106     * in the generic case since the parameter is known at compile time.
107     * Thus we need to do some division to get back to us.
108     */
109    FreeBSD::UDelayEvent *constUDelaySkipEvent;
110
111    /** These variables store addresses of important data structures
112     * that are normaly kept coherent at boot with cache mainetence operations.
113     * Since these operations aren't supported in gem5, we keep them coherent
114     * by making them uncacheable until all processors in the system boot.
115     */
116    Addr secDataPtrAddr;
117    Addr secDataAddr;
118    Addr penReleaseAddr;
119    Addr pen64ReleaseAddr;
120    Addr bootReleaseAddr;
121};
122
123class DumpStatsPCEventF : public PCEvent
124{
125  public:
126    DumpStatsPCEventF(PCEventQueue *q, const std::string &desc, Addr addr)
127        : PCEvent(q, desc, addr)
128    {}
129
130    virtual void process(ThreadContext* tc);
131};
132
133
134#endif // __ARCH_ARM_FREEBSD_SYSTEM_HH__
135
136