kernel.hh revision 12982
19651SAndreas.Sandberg@ARM.com/*
29651SAndreas.Sandberg@ARM.com * Copyright 2018 Google, Inc.
39651SAndreas.Sandberg@ARM.com *
49651SAndreas.Sandberg@ARM.com * Redistribution and use in source and binary forms, with or without
59651SAndreas.Sandberg@ARM.com * modification, are permitted provided that the following conditions are
69651SAndreas.Sandberg@ARM.com * met: redistributions of source code must retain the above copyright
79651SAndreas.Sandberg@ARM.com * notice, this list of conditions and the following disclaimer;
89651SAndreas.Sandberg@ARM.com * redistributions in binary form must reproduce the above copyright
99651SAndreas.Sandberg@ARM.com * notice, this list of conditions and the following disclaimer in the
109651SAndreas.Sandberg@ARM.com * documentation and/or other materials provided with the distribution;
119651SAndreas.Sandberg@ARM.com * neither the name of the copyright holders nor the names of its
129651SAndreas.Sandberg@ARM.com * contributors may be used to endorse or promote products derived from
139651SAndreas.Sandberg@ARM.com * this software without specific prior written permission.
149651SAndreas.Sandberg@ARM.com *
159651SAndreas.Sandberg@ARM.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
169651SAndreas.Sandberg@ARM.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
179651SAndreas.Sandberg@ARM.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
189651SAndreas.Sandberg@ARM.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
199651SAndreas.Sandberg@ARM.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
209651SAndreas.Sandberg@ARM.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
219651SAndreas.Sandberg@ARM.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
229651SAndreas.Sandberg@ARM.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
239651SAndreas.Sandberg@ARM.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
249651SAndreas.Sandberg@ARM.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
259651SAndreas.Sandberg@ARM.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
269651SAndreas.Sandberg@ARM.com *
279651SAndreas.Sandberg@ARM.com * Authors: Gabe Black
289651SAndreas.Sandberg@ARM.com */
299651SAndreas.Sandberg@ARM.com
309651SAndreas.Sandberg@ARM.com#ifndef __SYSTEMC_KERNEL_HH__
319651SAndreas.Sandberg@ARM.com#define __SYSTEMC_KERNEL_HH__
329651SAndreas.Sandberg@ARM.com
339651SAndreas.Sandberg@ARM.com#include "params/SystemC_Kernel.hh"
349651SAndreas.Sandberg@ARM.com#include "sim/sim_object.hh"
359651SAndreas.Sandberg@ARM.com#include "systemc/ext/core/sc_main.hh"
369651SAndreas.Sandberg@ARM.com
379651SAndreas.Sandberg@ARM.comnamespace sc_gem5
389651SAndreas.Sandberg@ARM.com{
399651SAndreas.Sandberg@ARM.com
409651SAndreas.Sandberg@ARM.com/*
419651SAndreas.Sandberg@ARM.com * This class represents the systemc kernel. There should be exactly one in
429651SAndreas.Sandberg@ARM.com * the simulation. It receives gem5 SimObject lifecycle callbacks (init,
439651SAndreas.Sandberg@ARM.com * regStats, etc.) and manages the lifecycle of the systemc simulation
449651SAndreas.Sandberg@ARM.com * accordingly. It also acts as a collecting point for systemc related
459651SAndreas.Sandberg@ARM.com * control functionality.
469651SAndreas.Sandberg@ARM.com */
479651SAndreas.Sandberg@ARM.comclass Kernel : public SimObject
489651SAndreas.Sandberg@ARM.com{
499651SAndreas.Sandberg@ARM.com  public:
509651SAndreas.Sandberg@ARM.com    typedef SystemC_KernelParams Params;
519657Sandreas.sandberg@arm.com    Kernel(Params *params);
529657Sandreas.sandberg@arm.com
539657Sandreas.sandberg@arm.com    void init() override;
549883Sandreas@sandberg.pp.se    void regStats() override;
559883Sandreas@sandberg.pp.se    void startup() override;
569883Sandreas@sandberg.pp.se
579657Sandreas.sandberg@arm.com    void t0Handler();
589651SAndreas.Sandberg@ARM.com
599651SAndreas.Sandberg@ARM.com    sc_core::sc_status status() { return _status; }
609651SAndreas.Sandberg@ARM.com    void status(sc_core::sc_status s) { _status = s; }
619651SAndreas.Sandberg@ARM.com
629651SAndreas.Sandberg@ARM.com    void stop();
639651SAndreas.Sandberg@ARM.com
649651SAndreas.Sandberg@ARM.com    bool startOfSimulationComplete() { return _startComplete; }
659651SAndreas.Sandberg@ARM.com    bool endOfSimulationComplete() { return _endComplete; }
669651SAndreas.Sandberg@ARM.com
679651SAndreas.Sandberg@ARM.com  private:
68    bool _stopAfterCallbacks;
69    void stopWork();
70
71    bool _startComplete;
72    bool _endComplete;
73    sc_core::sc_status _status;
74
75    EventWrapper<Kernel, &Kernel::t0Handler> t0Event;
76};
77
78extern Kernel *kernel;
79
80} // namespace sc_gem5
81
82#endif // __SYSTEMC_KERNEL_H__
83