diff options
Diffstat (limited to 'src/mem/gems_common/ioutil')
-rw-r--r-- | src/mem/gems_common/ioutil/FakeSimicsDataTypes.hh | 63 | ||||
-rw-r--r-- | src/mem/gems_common/ioutil/confio.cc | 2 | ||||
-rw-r--r-- | src/mem/gems_common/ioutil/initvar.cc | 40 | ||||
-rw-r--r-- | src/mem/gems_common/ioutil/initvar.hh | 12 |
4 files changed, 75 insertions, 42 deletions
diff --git a/src/mem/gems_common/ioutil/FakeSimicsDataTypes.hh b/src/mem/gems_common/ioutil/FakeSimicsDataTypes.hh new file mode 100644 index 000000000..b6fcda95c --- /dev/null +++ b/src/mem/gems_common/ioutil/FakeSimicsDataTypes.hh @@ -0,0 +1,63 @@ +#ifndef FAKE_SIMICS_DATA_TYPES_H +#define FAKE_SIMICS_DATA_TYPES_H + +typedef struct attr_value attr_value_t; + +typedef enum { + Sim_Val_Invalid = 0, + Sim_Val_String = 1, + Sim_Val_Integer = 2, + Sim_Val_Floating = 3, + Sim_Val_List = 4, + Sim_Val_Data = 5, + Sim_Val_Nil = 6, + Sim_Val_Object = 7 +} attr_kind_t; + +typedef struct attr_list attr_list_t; + +struct attr_list { + int size; + struct attr_value *vector; +}; + +struct attr_value { + attr_kind_t kind; + union { + const char *string; /* Sim_Val_String */ + unsigned long long integer; /* Sim_Val_Integer */ + double floating; /* Sim_Val_Floating */ + void *object; /* Sim_Val_Object */ + attr_list_t list; /* Sim_Val_List */ + } u; +}; + +typedef enum { +Sim_Set_Ok, +Sim_Set_Need_Integer, +Sim_Set_Need_Floating, +Sim_Set_Need_String, +Sim_Set_Need_List, +Sim_Set_Need_Data, +Sim_Set_Need_Object, +Sim_Set_Object_Not_Found, +Sim_Set_Interface_Not_Found, +Sim_Set_Illegal_Value, +Sim_Set_Illegal_Type, +Sim_Set_Illegal_Index, +Sim_Set_Attribute_Not_Found, +Sim_Set_Not_Writable, +Sim_Set_Ignored +} set_error_t; + + +typedef attr_value_t (*get_attr_t)(void *ptr, + void *obj, + attr_value_t *idx); + +typedef set_error_t (*set_attr_t)(void *ptr, + void *obj, + attr_value_t *val, + attr_value_t *idx); + +#endif // #ifndef FAKE_SIMICS_DATA_TYPES_H diff --git a/src/mem/gems_common/ioutil/confio.cc b/src/mem/gems_common/ioutil/confio.cc index ff1e25f12..54a96527e 100644 --- a/src/mem/gems_common/ioutil/confio.cc +++ b/src/mem/gems_common/ioutil/confio.cc @@ -59,8 +59,6 @@ using namespace std; // #endif // }; -#include "FakeSimicsDataTypes.hh" - #include "confio.hh" /*------------------------------------------------------------------------*/ diff --git a/src/mem/gems_common/ioutil/initvar.cc b/src/mem/gems_common/ioutil/initvar.cc index 8a560176a..b6b7ff9e0 100644 --- a/src/mem/gems_common/ioutil/initvar.cc +++ b/src/mem/gems_common/ioutil/initvar.cc @@ -70,8 +70,6 @@ using namespace std; // #endif // }; -#include "FakeSimicsDataTypes.hh" - #include "Global.hh" #include "confio.hh" @@ -124,8 +122,7 @@ static set_error_t initvar_set_attr( void *ptr, void *obj, initvar_t::initvar_t( const char *name, const char *relativeIncludePath, const char *initializingString, void (*allocate_fn)(void), - void (*my_generate_fn)(void), - get_attr_t my_get_attr, set_attr_t my_set_attr ) + void (*my_generate_fn)(void) ) { m_is_init = false; m_name = (char *) malloc( sizeof(char)*(strlen( name ) + 2) ); @@ -135,8 +132,6 @@ initvar_t::initvar_t( const char *name, const char *relativeIncludePath, strcpy( m_rel_include_path, relativeIncludePath ); m_allocate_f = allocate_fn; m_generate_values_f = my_generate_fn; - m_my_get_attr = my_get_attr; - m_my_set_attr = my_set_attr; initvar_t::m_inst = this; init_config_reader( initializingString ); @@ -247,7 +242,7 @@ void initvar_t::checkInitialization( void ) } //************************************************************************** -attr_value_t initvar_t::dispatch_get( void *id, void *obj, +int initvar_t::dispatch_get( void *id, void *obj, attr_value_t *idx ) { const char *command = (const char *) id; @@ -256,13 +251,11 @@ attr_value_t initvar_t::dispatch_get( void *id, void *obj, DEBUG_OUT(" : you must initialize %s with a configuration file first.\n", m_name); DEBUG_OUT(" : use the command \'%s0.init\'\n", m_name); - attr_value_t ret; - ret.kind = Sim_Val_Invalid; - ret.u.integer = 0; - return ret; + return 0; } - return ((*m_my_get_attr)(id, obj, idx)); + std::cerr << __FILE__ << "(" << __LINE__ << "): Not implmented." << std::endl; + return 0; } @@ -331,7 +324,9 @@ set_error_t initvar_t::dispatch_set( void *id, void *obj, return Sim_Set_Illegal_Value; } - return (*m_my_set_attr)( id, obj, val, idx ); + + std::cerr << __FILE__ << "(" << __LINE__ << "): Not implmented." << std::endl; + return Sim_Set_Illegal_Value; } /*------------------------------------------------------------------------*/ @@ -588,22 +583,3 @@ const char *initvar_t::get_config_name( void ) return m_config_filename; } -/*------------------------------------------------------------------------*/ -/* Global functions */ -/*------------------------------------------------------------------------*/ - -//************************************************************************** -attr_value_t initvar_dispatch_get( void *id, void *obj, - attr_value_t *idx ) -{ - initvar_t *init_obj = initvar_t::m_inst; - return (init_obj->dispatch_get( id, obj, idx )); -} - -//************************************************************************** -set_error_t initvar_dispatch_set( void *id, void *obj, - attr_value_t *val, attr_value_t *idx ) -{ - initvar_t *init_obj = initvar_t::m_inst; - return (init_obj->dispatch_set( id, obj, val, idx )); -} diff --git a/src/mem/gems_common/ioutil/initvar.hh b/src/mem/gems_common/ioutil/initvar.hh index d88f80c32..f872e1cd8 100644 --- a/src/mem/gems_common/ioutil/initvar.hh +++ b/src/mem/gems_common/ioutil/initvar.hh @@ -70,8 +70,8 @@ public: initvar_t( const char *name, const char *relativeIncludePath, const char *initializingString, void (*allocate_fn)(void), - void (*my_generate_fn)(void), - get_attr_t my_get_attr, set_attr_t my_set_attr ); + void (*my_generate_fn)(void) + ); /** * Destructor: frees object. @@ -96,8 +96,8 @@ public: const char *get_config_name( void ); /// calls through to the get_attr function, if object is initialized - attr_value_t dispatch_get( void *id, void *obj, - attr_value_t *idx ); + int dispatch_get( void *id, void *obj, + attr_value_t *idx ); /** adds initialization attributes, calls through to the set_attr function, * if object is initialized. @@ -144,10 +144,6 @@ protected: /// a pointer to the generate values function void (*m_generate_values_f)(void); - /// a pointer to the session get function - get_attr_t m_my_get_attr; - /// a pointer to the session set function - set_attr_t m_my_set_attr; }; |