00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #define _MD_DBG( fmt, args... ) \
00014 m_dbg.write( "%s():%d: "fmt, __FUNCTION__, __LINE__, ##args)
00015
00016 MEMORYDEV()::MemoryDev( Component& comp,
00017 Component::Params_t params, std::string name ) :
00018 dev_t( comp, params, name ),
00019 m_dbg( *new Log< MEMORYDEV_DBG >( "MemoryDev::", false ) )
00020 {
00021 if ( params.find("debug") != params.end() ) {
00022 if ( params["debug"].compare("yes") == 0 ) {
00023 m_dbg.enable();
00024 }
00025 }
00026 _MD_DBG("\n");
00027 }
00028
00029
00030 MEMORYDEV( inline bool )::read( addr_t addr, cookie_t cookie = NULL )
00031 {
00032 _MD_DBG("\n");
00033 return send( addr, NULL, cookie, event_t::READ );
00034 }
00035
00036 MEMORYDEV( inline bool )::write( addr_t addr, cookie_t cookie = NULL )
00037 {
00038 _MD_DBG("\n");
00039 return send( addr, NULL, cookie, event_t::WRITE );
00040 }
00041
00042 MEMORYDEV( inline bool )::read( addr_t addr, data_t* data,
00043 cookie_t cookie = NULL )
00044 {
00045 _MD_DBG("\n");
00046 return send( addr, data, cookie, event_t::READ );
00047 }
00048
00049 MEMORYDEV( inline bool ) ::write( addr_t addr, data_t* data,
00050 cookie_t cookie = NULL )
00051 {
00052 _MD_DBG("\n");
00053 return send( addr, data, cookie, event_t::WRITE );
00054 }
00055
00056 MEMORYDEV( inline bool )::send( addr_t addr, data_t* data,
00057 cookie_t cookie, typename event_t::reqType_t type )
00058 {
00059 _MD_DBG("addr=%#lx cookie=%#lx type=%d \n", addr, cookie, type );
00060 if ( ! dev_t::ready( event_t::REQUEST ) ) {
00061 return false;
00062 }
00063 event_t* event = new event_t;
00064 event->addr = addr;
00065 event->reqType = type;
00066 event->msgType = event_t::REQUEST;
00067 dev_t::send( event, new foo_t( cookie, data ) );
00068 return true;
00069 }
00070
00071
00072 MEMORYDEV( inline bool )::popCookie( cookieT& cookie )
00073 {
00074 foo_t* foo;
00075 bool ret;
00076 event_t* event;
00077
00078 if ( ( ret = dev_t::recv( &event, &foo ) ) ) {
00079 cookie = foo->first;
00080 _MD_DBG("cookie=%#lx data*=%p\n", cookie, foo->second );
00081 if ( foo->second ) {
00082
00083 }
00084 delete foo;
00085 delete event;
00086 }
00087
00088 return ret;
00089 }