gem5  v20.1.0.0
mm.h
Go to the documentation of this file.
1 
2 // *******************************************************************
3 // User-defined memory manager, which maintains a pool of transactions
4 // *******************************************************************
5 
6 #include "tlm.h"
7 
8 class mm: public tlm::tlm_mm_interface
9 {
11 
12 public:
13  mm() : free_list(0), empties(0) {}
14 
15  virtual ~mm()
16  {
17  gp_t* ptr;
18 
19  while (free_list)
20  {
21  ptr = free_list->trans;
22 
23  // Delete generic payload and all extensions
24  sc_assert(ptr);
25  delete ptr;
26 
28  }
29 
30  while (empties)
31  {
32  access* x = empties;
33  empties = empties->next;
34 
35  // Delete free list access struct
36  delete x;
37  }
38  }
39 
40  gp_t* allocate();
41  void free(gp_t* trans);
42 
43 private:
44  struct access
45  {
46  gp_t* trans;
47  access* next;
48  access* prev;
49  };
50 
51  access* free_list;
52  access* empties;
53 };
54 
56 {
57  gp_t* ptr;
58  if (free_list)
59  {
60  ptr = free_list->trans;
63  }
64  else
65  {
66  ptr = new gp_t(this);
67  }
68  return ptr;
69 }
70 
71 void mm::free(gp_t* trans)
72 {
73  trans->reset(); // Delete auto extensions
74  if (!empties)
75  {
76  empties = new access;
78  empties->prev = 0;
79  if (free_list)
81  }
83  free_list->trans = trans;
85 }
mm::mm
mm()
Definition: mm.h:13
mm::access::next
access * next
Definition: mm.h:47
mm::empties
access * empties
Definition: mm.h:52
mm::~mm
virtual ~mm()
Definition: mm.h:15
sc_assert
#define sc_assert(expr)
Definition: sc_report_handler.hh:135
mm::access::trans
gp_t * trans
Definition: mm.h:46
mm
Definition: mm.h:8
RiscvISA::x
Bitfield< 3 > x
Definition: pagetable.hh:69
mm::free
void free(gp_t *trans)
Definition: mm.h:71
mm::allocate
gp_t * allocate()
Definition: mm.h:55
tlm::tlm_generic_payload
Definition: gp.hh:133
mm::free_list
access * free_list
Definition: mm.h:51
mm::gp_t
tlm::tlm_generic_payload gp_t
Definition: mm.h:10
mm::access::prev
access * prev
Definition: mm.h:48
tlm::tlm_mm_interface
Definition: gp.hh:50
mm::access
Definition: mm.h:44

Generated on Wed Sep 30 2020 14:02:18 for gem5 by doxygen 1.8.17