sc_process_handle.hh revision 12899
112838Sgabeblack@google.com/*
212838Sgabeblack@google.com * Copyright 2018 Google, Inc.
312838Sgabeblack@google.com *
412838Sgabeblack@google.com * Redistribution and use in source and binary forms, with or without
512838Sgabeblack@google.com * modification, are permitted provided that the following conditions are
612838Sgabeblack@google.com * met: redistributions of source code must retain the above copyright
712838Sgabeblack@google.com * notice, this list of conditions and the following disclaimer;
812838Sgabeblack@google.com * redistributions in binary form must reproduce the above copyright
912838Sgabeblack@google.com * notice, this list of conditions and the following disclaimer in the
1012838Sgabeblack@google.com * documentation and/or other materials provided with the distribution;
1112838Sgabeblack@google.com * neither the name of the copyright holders nor the names of its
1212838Sgabeblack@google.com * contributors may be used to endorse or promote products derived from
1312838Sgabeblack@google.com * this software without specific prior written permission.
1412838Sgabeblack@google.com *
1512838Sgabeblack@google.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1612838Sgabeblack@google.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1712838Sgabeblack@google.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1812838Sgabeblack@google.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
1912838Sgabeblack@google.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2012838Sgabeblack@google.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2112838Sgabeblack@google.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2212838Sgabeblack@google.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2312838Sgabeblack@google.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2412838Sgabeblack@google.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2512838Sgabeblack@google.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2612838Sgabeblack@google.com *
2712838Sgabeblack@google.com * Authors: Gabe Black
2812838Sgabeblack@google.com */
2912838Sgabeblack@google.com
3012838Sgabeblack@google.com#ifndef __SYSTEMC_EXT_CORE_SC_PROCESS_HANDLE_HH__
3112838Sgabeblack@google.com#define __SYSTEMC_EXT_CORE_SC_PROCESS_HANDLE_HH__
3212838Sgabeblack@google.com
3312838Sgabeblack@google.com#include <exception>
3412838Sgabeblack@google.com#include <vector>
3512838Sgabeblack@google.com
3612852Sgabeblack@google.comnamespace sc_gem5
3712852Sgabeblack@google.com{
3812852Sgabeblack@google.com
3912852Sgabeblack@google.comclass Process;
4012852Sgabeblack@google.com
4112852Sgabeblack@google.com} // namespace sc_gem5
4212852Sgabeblack@google.com
4312838Sgabeblack@google.comnamespace sc_core
4412838Sgabeblack@google.com{
4512838Sgabeblack@google.com
4612838Sgabeblack@google.comclass sc_event;
4712838Sgabeblack@google.comclass sc_object;
4812838Sgabeblack@google.com
4912838Sgabeblack@google.comenum sc_curr_proc_kind
5012838Sgabeblack@google.com{
5112838Sgabeblack@google.com    SC_NO_PROC_,
5212838Sgabeblack@google.com    SC_METHOD_PROC_,
5312838Sgabeblack@google.com    SC_THREAD_PROC_,
5412838Sgabeblack@google.com    SC_CTHREAD_PROC_
5512838Sgabeblack@google.com};
5612838Sgabeblack@google.com
5712838Sgabeblack@google.comenum sc_descendent_inclusion_info
5812838Sgabeblack@google.com{
5912838Sgabeblack@google.com    SC_NO_DESCENDANTS,
6012838Sgabeblack@google.com    SC_INCLUDE_DESCENDANTS
6112838Sgabeblack@google.com};
6212838Sgabeblack@google.com
6312838Sgabeblack@google.comclass sc_unwind_exception : public std::exception
6412838Sgabeblack@google.com{
6512838Sgabeblack@google.com  public:
6612838Sgabeblack@google.com    virtual const char *what() const throw();
6712838Sgabeblack@google.com    virtual bool is_reset() const;
6812838Sgabeblack@google.com
6912898Sgabeblack@google.com    // Nonstandard.
7012898Sgabeblack@google.com    // These should be protected, but I think this is to enable catch by
7112898Sgabeblack@google.com    // value.
7212898Sgabeblack@google.com  public:
7312898Sgabeblack@google.com    sc_unwind_exception(const sc_unwind_exception &);
7412898Sgabeblack@google.com    virtual ~sc_unwind_exception() throw();
7512898Sgabeblack@google.com
7612838Sgabeblack@google.com  protected:
7712838Sgabeblack@google.com    sc_unwind_exception();
7812838Sgabeblack@google.com};
7912838Sgabeblack@google.com
8012838Sgabeblack@google.comclass sc_process_handle
8112838Sgabeblack@google.com{
8212852Sgabeblack@google.com  private:
8312852Sgabeblack@google.com    ::sc_gem5::Process *_gem5_process;
8412852Sgabeblack@google.com
8512838Sgabeblack@google.com  public:
8612838Sgabeblack@google.com    sc_process_handle();
8712838Sgabeblack@google.com    sc_process_handle(const sc_process_handle &);
8812838Sgabeblack@google.com    explicit sc_process_handle(sc_object *);
8912838Sgabeblack@google.com    ~sc_process_handle();
9012838Sgabeblack@google.com
9112852Sgabeblack@google.com    // These non-standard operators provide access to the data structure which
9212852Sgabeblack@google.com    // actually tracks the process within gem5. By making them operators, we
9312852Sgabeblack@google.com    // can minimize the symbols added to the class namespace.
9412852Sgabeblack@google.com    operator ::sc_gem5::Process * () const { return _gem5_process; }
9512852Sgabeblack@google.com    sc_process_handle &
9612852Sgabeblack@google.com    operator = (::sc_gem5::Process *p)
9712852Sgabeblack@google.com    {
9812852Sgabeblack@google.com        _gem5_process = p;
9912852Sgabeblack@google.com        return *this;
10012852Sgabeblack@google.com    }
10112852Sgabeblack@google.com
10212838Sgabeblack@google.com    bool valid() const;
10312838Sgabeblack@google.com
10412838Sgabeblack@google.com    sc_process_handle &operator = (const sc_process_handle &);
10512838Sgabeblack@google.com    bool operator == (const sc_process_handle &) const;
10612838Sgabeblack@google.com    bool operator != (const sc_process_handle &) const;
10712838Sgabeblack@google.com    bool operator < (const sc_process_handle &) const;
10812838Sgabeblack@google.com    bool swap(sc_process_handle &);
10912838Sgabeblack@google.com
11012838Sgabeblack@google.com    const char *name() const;
11112838Sgabeblack@google.com    sc_curr_proc_kind proc_kind() const;
11212838Sgabeblack@google.com    const std::vector<sc_object *> &get_child_objects() const;
11312838Sgabeblack@google.com    const std::vector<sc_event *> &get_child_events() const;
11412838Sgabeblack@google.com    sc_object *get_parent_object() const;
11512838Sgabeblack@google.com    sc_object *get_process_object() const;
11612838Sgabeblack@google.com    bool dynamic() const;
11712838Sgabeblack@google.com    bool terminated() const;
11812838Sgabeblack@google.com    const sc_event &terminated_event() const;
11912838Sgabeblack@google.com
12012838Sgabeblack@google.com    void suspend(sc_descendent_inclusion_info include_descendants=
12112838Sgabeblack@google.com                 SC_NO_DESCENDANTS);
12212838Sgabeblack@google.com    void resume(sc_descendent_inclusion_info include_descendants=
12312838Sgabeblack@google.com                SC_NO_DESCENDANTS);
12412838Sgabeblack@google.com    void disable(sc_descendent_inclusion_info include_descendants=
12512838Sgabeblack@google.com                 SC_NO_DESCENDANTS);
12612838Sgabeblack@google.com    void enable(sc_descendent_inclusion_info include_descendants=
12712838Sgabeblack@google.com                SC_NO_DESCENDANTS);
12812838Sgabeblack@google.com    void kill(sc_descendent_inclusion_info include_descendants=
12912838Sgabeblack@google.com              SC_NO_DESCENDANTS);
13012838Sgabeblack@google.com    void reset(sc_descendent_inclusion_info include_descendants=
13112838Sgabeblack@google.com               SC_NO_DESCENDANTS);
13212838Sgabeblack@google.com    bool is_unwinding();
13312838Sgabeblack@google.com    const sc_event &reset_event() const;
13412838Sgabeblack@google.com
13512838Sgabeblack@google.com    void sync_reset_on(sc_descendent_inclusion_info include_descendants=
13612838Sgabeblack@google.com                       SC_NO_DESCENDANTS);
13712838Sgabeblack@google.com    void sync_reset_off(sc_descendent_inclusion_info include_descendants=
13812838Sgabeblack@google.com                        SC_NO_DESCENDANTS);
13912838Sgabeblack@google.com
14012838Sgabeblack@google.com    void warn_unimpl(const char *func);
14112838Sgabeblack@google.com    template <typename T>
14212838Sgabeblack@google.com    void throw_it(const T &user_defined_exception,
14312838Sgabeblack@google.com                  sc_descendent_inclusion_info include_descendants=
14412838Sgabeblack@google.com                  SC_NO_DESCENDANTS)
14512838Sgabeblack@google.com    {
14612838Sgabeblack@google.com        warn_unimpl(__PRETTY_FUNCTION__);
14712838Sgabeblack@google.com    }
14812838Sgabeblack@google.com};
14912838Sgabeblack@google.com
15012838Sgabeblack@google.comsc_process_handle sc_get_current_process_handle();
15112838Sgabeblack@google.combool sc_is_unwinding();
15212838Sgabeblack@google.com
15312899Sgabeblack@google.com// Nonstandard
15412899Sgabeblack@google.com// See Accellera's kernel/sim_context.cpp for an explanation of what this is
15512899Sgabeblack@google.com// supposed to do. It essentially selects what happens during certain
15612899Sgabeblack@google.com// undefined situations.
15712899Sgabeblack@google.comextern bool sc_allow_process_control_corners;
15812899Sgabeblack@google.com
15912838Sgabeblack@google.com} // namespace sc_core
16012838Sgabeblack@google.com
16112838Sgabeblack@google.com#endif  //__SYSTEMC_EXT_CORE_SC_PROCESS_HANDLE_HH__
162