113820Sgabeblack@google.com/*
213820Sgabeblack@google.com * Copyright (c) 2015, University of Kaiserslautern
313820Sgabeblack@google.com * All rights reserved.
413820Sgabeblack@google.com *
513820Sgabeblack@google.com * Redistribution and use in source and binary forms, with or without
613820Sgabeblack@google.com * modification, are permitted provided that the following conditions are
713820Sgabeblack@google.com * met:
813820Sgabeblack@google.com *
913820Sgabeblack@google.com * 1. Redistributions of source code must retain the above copyright notice,
1013820Sgabeblack@google.com *    this list of conditions and the following disclaimer.
1113820Sgabeblack@google.com *
1213820Sgabeblack@google.com * 2. Redistributions in binary form must reproduce the above copyright
1313820Sgabeblack@google.com *    notice, this list of conditions and the following disclaimer in the
1413820Sgabeblack@google.com *    documentation and/or other materials provided with the distribution.
1513820Sgabeblack@google.com *
1613820Sgabeblack@google.com * 3. Neither the name of the copyright holder nor the names of its
1713820Sgabeblack@google.com *    contributors may be used to endorse or promote products derived from
1813820Sgabeblack@google.com *    this software without specific prior written permission.
1913820Sgabeblack@google.com *
2013820Sgabeblack@google.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
2113820Sgabeblack@google.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
2213820Sgabeblack@google.com * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
2313820Sgabeblack@google.com * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER
2413820Sgabeblack@google.com * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
2513820Sgabeblack@google.com * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
2613820Sgabeblack@google.com * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
2713820Sgabeblack@google.com * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
2813820Sgabeblack@google.com * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
2913820Sgabeblack@google.com * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
3013820Sgabeblack@google.com * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3113820Sgabeblack@google.com *
3213820Sgabeblack@google.com * Authors:
3313820Sgabeblack@google.com *    Robert Gernhardt
3413820Sgabeblack@google.com *    Matthias Jung
3513820Sgabeblack@google.com */
3613820Sgabeblack@google.com
3713820Sgabeblack@google.com#ifndef __SYSTEMC_TLM_BRIDGE_SC_MM_HH__
3813820Sgabeblack@google.com#define __SYSTEMC_TLM_BRIDGE_SC_MM_HH__
3913820Sgabeblack@google.com
4013820Sgabeblack@google.com#include <vector>
4113820Sgabeblack@google.com
4213820Sgabeblack@google.com#include "systemc/ext/tlm_core/2/generic_payload/gp.hh"
4313820Sgabeblack@google.com
4413820Sgabeblack@google.comnamespace Gem5SystemC
4513820Sgabeblack@google.com{
4613820Sgabeblack@google.com
4713820Sgabeblack@google.comtypedef tlm::tlm_generic_payload gp;
4813820Sgabeblack@google.com
4913820Sgabeblack@google.comclass MemoryManager : public tlm::tlm_mm_interface
5013820Sgabeblack@google.com{
5113820Sgabeblack@google.com  public:
5213820Sgabeblack@google.com    MemoryManager();
5313820Sgabeblack@google.com    virtual ~MemoryManager();
5413820Sgabeblack@google.com    virtual gp *allocate();
5513820Sgabeblack@google.com    virtual void free(gp *payload);
5613820Sgabeblack@google.com
5713820Sgabeblack@google.com  private:
5813820Sgabeblack@google.com    unsigned int numberOfAllocations;
5913820Sgabeblack@google.com    unsigned int numberOfFrees;
6013820Sgabeblack@google.com    std::vector<gp *> freePayloads;
6113820Sgabeblack@google.com};
6213820Sgabeblack@google.com
6313820Sgabeblack@google.com} // namespace Gem5SystemC
6413820Sgabeblack@google.com
6513820Sgabeblack@google.com#endif // __SYSTEMC_TLM_BRIDGE_SC_MM_HH__
66