sc_process_handle.hh revision 12939
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 8012939Sgabeblack@google.com// Deprecated 8112939Sgabeblack@google.com// An incomplete version of sc_process_b to satisfy the tests. 8212939Sgabeblack@google.comclass sc_process_b 8312939Sgabeblack@google.com{ 8412939Sgabeblack@google.com public: 8512939Sgabeblack@google.com const char *file; 8612939Sgabeblack@google.com int lineno; 8712939Sgabeblack@google.com const char *name(); 8812939Sgabeblack@google.com const char *kind(); 8912939Sgabeblack@google.com}; 9012939Sgabeblack@google.com 9112939Sgabeblack@google.com// Deprecated 9212939Sgabeblack@google.comsc_process_b *sc_get_curr_process_handle(); 9312939Sgabeblack@google.comstatic inline sc_process_b * 9412939Sgabeblack@google.comsc_get_current_process_b() 9512939Sgabeblack@google.com{ 9612939Sgabeblack@google.com return sc_get_curr_process_handle(); 9712939Sgabeblack@google.com} 9812939Sgabeblack@google.com 9912939Sgabeblack@google.com// Deprecated/nonstandard 10012939Sgabeblack@google.comstruct sc_curr_proc_info 10112939Sgabeblack@google.com{ 10212939Sgabeblack@google.com sc_process_b *process_handle; 10312939Sgabeblack@google.com sc_curr_proc_kind kind; 10412939Sgabeblack@google.com sc_curr_proc_info() : process_handle(NULL), kind(SC_NO_PROC_) {} 10512939Sgabeblack@google.com}; 10612939Sgabeblack@google.comtypedef const sc_curr_proc_info *sc_curr_proc_handle; 10712939Sgabeblack@google.com 10812838Sgabeblack@google.comclass sc_process_handle 10912838Sgabeblack@google.com{ 11012852Sgabeblack@google.com private: 11112852Sgabeblack@google.com ::sc_gem5::Process *_gem5_process; 11212852Sgabeblack@google.com 11312838Sgabeblack@google.com public: 11412838Sgabeblack@google.com sc_process_handle(); 11512838Sgabeblack@google.com sc_process_handle(const sc_process_handle &); 11612838Sgabeblack@google.com explicit sc_process_handle(sc_object *); 11712838Sgabeblack@google.com ~sc_process_handle(); 11812838Sgabeblack@google.com 11912852Sgabeblack@google.com // These non-standard operators provide access to the data structure which 12012852Sgabeblack@google.com // actually tracks the process within gem5. By making them operators, we 12112852Sgabeblack@google.com // can minimize the symbols added to the class namespace. 12212852Sgabeblack@google.com operator ::sc_gem5::Process * () const { return _gem5_process; } 12312852Sgabeblack@google.com sc_process_handle & 12412852Sgabeblack@google.com operator = (::sc_gem5::Process *p) 12512852Sgabeblack@google.com { 12612852Sgabeblack@google.com _gem5_process = p; 12712852Sgabeblack@google.com return *this; 12812852Sgabeblack@google.com } 12912852Sgabeblack@google.com 13012838Sgabeblack@google.com bool valid() const; 13112838Sgabeblack@google.com 13212838Sgabeblack@google.com sc_process_handle &operator = (const sc_process_handle &); 13312838Sgabeblack@google.com bool operator == (const sc_process_handle &) const; 13412838Sgabeblack@google.com bool operator != (const sc_process_handle &) const; 13512838Sgabeblack@google.com bool operator < (const sc_process_handle &) const; 13612838Sgabeblack@google.com bool swap(sc_process_handle &); 13712838Sgabeblack@google.com 13812838Sgabeblack@google.com const char *name() const; 13912838Sgabeblack@google.com sc_curr_proc_kind proc_kind() const; 14012838Sgabeblack@google.com const std::vector<sc_object *> &get_child_objects() const; 14112838Sgabeblack@google.com const std::vector<sc_event *> &get_child_events() const; 14212838Sgabeblack@google.com sc_object *get_parent_object() const; 14312838Sgabeblack@google.com sc_object *get_process_object() const; 14412838Sgabeblack@google.com bool dynamic() const; 14512838Sgabeblack@google.com bool terminated() const; 14612838Sgabeblack@google.com const sc_event &terminated_event() const; 14712838Sgabeblack@google.com 14812838Sgabeblack@google.com void suspend(sc_descendent_inclusion_info include_descendants= 14912838Sgabeblack@google.com SC_NO_DESCENDANTS); 15012838Sgabeblack@google.com void resume(sc_descendent_inclusion_info include_descendants= 15112838Sgabeblack@google.com SC_NO_DESCENDANTS); 15212838Sgabeblack@google.com void disable(sc_descendent_inclusion_info include_descendants= 15312838Sgabeblack@google.com SC_NO_DESCENDANTS); 15412838Sgabeblack@google.com void enable(sc_descendent_inclusion_info include_descendants= 15512838Sgabeblack@google.com SC_NO_DESCENDANTS); 15612838Sgabeblack@google.com void kill(sc_descendent_inclusion_info include_descendants= 15712838Sgabeblack@google.com SC_NO_DESCENDANTS); 15812838Sgabeblack@google.com void reset(sc_descendent_inclusion_info include_descendants= 15912838Sgabeblack@google.com SC_NO_DESCENDANTS); 16012838Sgabeblack@google.com bool is_unwinding(); 16112838Sgabeblack@google.com const sc_event &reset_event() const; 16212838Sgabeblack@google.com 16312838Sgabeblack@google.com void sync_reset_on(sc_descendent_inclusion_info include_descendants= 16412838Sgabeblack@google.com SC_NO_DESCENDANTS); 16512838Sgabeblack@google.com void sync_reset_off(sc_descendent_inclusion_info include_descendants= 16612838Sgabeblack@google.com SC_NO_DESCENDANTS); 16712838Sgabeblack@google.com 16812838Sgabeblack@google.com void warn_unimpl(const char *func); 16912838Sgabeblack@google.com template <typename T> 17012838Sgabeblack@google.com void throw_it(const T &user_defined_exception, 17112838Sgabeblack@google.com sc_descendent_inclusion_info include_descendants= 17212838Sgabeblack@google.com SC_NO_DESCENDANTS) 17312838Sgabeblack@google.com { 17412838Sgabeblack@google.com warn_unimpl(__PRETTY_FUNCTION__); 17512838Sgabeblack@google.com } 17612838Sgabeblack@google.com}; 17712838Sgabeblack@google.com 17812838Sgabeblack@google.comsc_process_handle sc_get_current_process_handle(); 17912838Sgabeblack@google.combool sc_is_unwinding(); 18012838Sgabeblack@google.com 18112899Sgabeblack@google.com// Nonstandard 18212899Sgabeblack@google.com// See Accellera's kernel/sim_context.cpp for an explanation of what this is 18312899Sgabeblack@google.com// supposed to do. It essentially selects what happens during certain 18412899Sgabeblack@google.com// undefined situations. 18512899Sgabeblack@google.comextern bool sc_allow_process_control_corners; 18612899Sgabeblack@google.com 18712838Sgabeblack@google.com} // namespace sc_core 18812838Sgabeblack@google.com 18912838Sgabeblack@google.com#endif //__SYSTEMC_EXT_CORE_SC_PROCESS_HANDLE_HH__ 190