• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • File List
  • Globals

sst/elements/include/memoryDev2.h

00001 // Copyright 2009-2010 Sandia Corporation. Under the terms
00002 // of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S.
00003 // Government retains certain rights in this software.
00004 // 
00005 // Copyright (c) 2009-2010, Sandia Corporation
00006 // All rights reserved.
00007 // 
00008 // This file is part of the SST software package. For license
00009 // information, see the LICENSE file in the top level directory of the
00010 // distribution.
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             //*foo->second = event->data;
00083         }
00084         delete foo;
00085         delete event;
00086     }
00087 
00088     return ret;
00089 }

Generated on Fri Oct 22 2010 11:02:25 for SST by  doxygen 1.7.1