sc_process_handle.hh revision 12852
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
6912838Sgabeblack@google.com  protected:
7012838Sgabeblack@google.com    sc_unwind_exception();
7112838Sgabeblack@google.com    sc_unwind_exception(const sc_unwind_exception &);
7212838Sgabeblack@google.com    virtual ~sc_unwind_exception() throw();
7312838Sgabeblack@google.com};
7412838Sgabeblack@google.com
7512838Sgabeblack@google.comclass sc_process_handle
7612838Sgabeblack@google.com{
7712852Sgabeblack@google.com  private:
7812852Sgabeblack@google.com    ::sc_gem5::Process *_gem5_process;
7912852Sgabeblack@google.com
8012838Sgabeblack@google.com  public:
8112838Sgabeblack@google.com    sc_process_handle();
8212838Sgabeblack@google.com    sc_process_handle(const sc_process_handle &);
8312838Sgabeblack@google.com    explicit sc_process_handle(sc_object *);
8412838Sgabeblack@google.com    ~sc_process_handle();
8512838Sgabeblack@google.com
8612852Sgabeblack@google.com    // These non-standard operators provide access to the data structure which
8712852Sgabeblack@google.com    // actually tracks the process within gem5. By making them operators, we
8812852Sgabeblack@google.com    // can minimize the symbols added to the class namespace.
8912852Sgabeblack@google.com    operator ::sc_gem5::Process * () const { return _gem5_process; }
9012852Sgabeblack@google.com    sc_process_handle &
9112852Sgabeblack@google.com    operator = (::sc_gem5::Process *p)
9212852Sgabeblack@google.com    {
9312852Sgabeblack@google.com        _gem5_process = p;
9412852Sgabeblack@google.com        return *this;
9512852Sgabeblack@google.com    }
9612852Sgabeblack@google.com
9712838Sgabeblack@google.com    bool valid() const;
9812838Sgabeblack@google.com
9912838Sgabeblack@google.com    sc_process_handle &operator = (const sc_process_handle &);
10012838Sgabeblack@google.com    bool operator == (const sc_process_handle &) const;
10112838Sgabeblack@google.com    bool operator != (const sc_process_handle &) const;
10212838Sgabeblack@google.com    bool operator < (const sc_process_handle &) const;
10312838Sgabeblack@google.com    bool swap(sc_process_handle &);
10412838Sgabeblack@google.com
10512838Sgabeblack@google.com    const char *name() const;
10612838Sgabeblack@google.com    sc_curr_proc_kind proc_kind() const;
10712838Sgabeblack@google.com    const std::vector<sc_object *> &get_child_objects() const;
10812838Sgabeblack@google.com    const std::vector<sc_event *> &get_child_events() const;
10912838Sgabeblack@google.com    sc_object *get_parent_object() const;
11012838Sgabeblack@google.com    sc_object *get_process_object() const;
11112838Sgabeblack@google.com    bool dynamic() const;
11212838Sgabeblack@google.com    bool terminated() const;
11312838Sgabeblack@google.com    const sc_event &terminated_event() const;
11412838Sgabeblack@google.com
11512838Sgabeblack@google.com    void suspend(sc_descendent_inclusion_info include_descendants=
11612838Sgabeblack@google.com                 SC_NO_DESCENDANTS);
11712838Sgabeblack@google.com    void resume(sc_descendent_inclusion_info include_descendants=
11812838Sgabeblack@google.com                SC_NO_DESCENDANTS);
11912838Sgabeblack@google.com    void disable(sc_descendent_inclusion_info include_descendants=
12012838Sgabeblack@google.com                 SC_NO_DESCENDANTS);
12112838Sgabeblack@google.com    void enable(sc_descendent_inclusion_info include_descendants=
12212838Sgabeblack@google.com                SC_NO_DESCENDANTS);
12312838Sgabeblack@google.com    void kill(sc_descendent_inclusion_info include_descendants=
12412838Sgabeblack@google.com              SC_NO_DESCENDANTS);
12512838Sgabeblack@google.com    void reset(sc_descendent_inclusion_info include_descendants=
12612838Sgabeblack@google.com               SC_NO_DESCENDANTS);
12712838Sgabeblack@google.com    bool is_unwinding();
12812838Sgabeblack@google.com    const sc_event &reset_event() const;
12912838Sgabeblack@google.com
13012838Sgabeblack@google.com    void sync_reset_on(sc_descendent_inclusion_info include_descendants=
13112838Sgabeblack@google.com                       SC_NO_DESCENDANTS);
13212838Sgabeblack@google.com    void sync_reset_off(sc_descendent_inclusion_info include_descendants=
13312838Sgabeblack@google.com                        SC_NO_DESCENDANTS);
13412838Sgabeblack@google.com
13512838Sgabeblack@google.com    void warn_unimpl(const char *func);
13612838Sgabeblack@google.com    template <typename T>
13712838Sgabeblack@google.com    void throw_it(const T &user_defined_exception,
13812838Sgabeblack@google.com                  sc_descendent_inclusion_info include_descendants=
13912838Sgabeblack@google.com                  SC_NO_DESCENDANTS)
14012838Sgabeblack@google.com    {
14112838Sgabeblack@google.com        warn_unimpl(__PRETTY_FUNCTION__);
14212838Sgabeblack@google.com    }
14312838Sgabeblack@google.com};
14412838Sgabeblack@google.com
14512838Sgabeblack@google.comsc_process_handle sc_get_current_process_handle();
14612838Sgabeblack@google.combool sc_is_unwinding();
14712838Sgabeblack@google.com
14812838Sgabeblack@google.com} // namespace sc_core
14912838Sgabeblack@google.com
15012838Sgabeblack@google.com#endif  //__SYSTEMC_EXT_CORE_SC_PROCESS_HANDLE_HH__
151