gem5
v24.0.0.0
Loading...
Searching...
No Matches
systemc
tests
tlm
update_original
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
{
10
typedef
tlm::tlm_generic_payload
gp_t
;
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
27
free_list
=
free_list
->
next
;
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
55
mm::gp_t
*
mm::allocate
()
56
{
57
gp_t
* ptr;
58
if
(
free_list
)
59
{
60
ptr =
free_list
->
trans
;
61
empties
=
free_list
;
62
free_list
=
free_list
->
next
;
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;
77
empties
->
next
=
free_list
;
78
empties
->
prev
= 0;
79
if
(
free_list
)
80
free_list
->
prev
=
empties
;
81
}
82
free_list
=
empties
;
83
free_list
->
trans
= trans;
84
empties
=
free_list
->
prev
;
85
}
mm
Definition
mm.h:9
mm::allocate
gp_t * allocate()
mm::free_list
access * free_list
Definition
mm.h:51
mm::gp_t
tlm::tlm_generic_payload gp_t
Definition
mm.h:10
mm::mm
mm()
Definition
mm.h:13
mm::allocate
gp_t * allocate()
Definition
mm.h:55
mm::~mm
virtual ~mm()
Definition
mm.h:15
mm::free
void free(gp_t *trans)
mm::empties
access * empties
Definition
mm.h:52
tlm::tlm_generic_payload
Definition
gp.hh:117
tlm::tlm_mm_interface
Definition
gp.hh:34
sc_assert
#define sc_assert(expr)
Definition
sc_report_handler.hh:135
mm::access
Definition
mm.h:45
mm::access::trans
gp_t * trans
Definition
mm.h:46
mm::access::next
access * next
Definition
mm.h:47
mm::access::prev
access * prev
Definition
mm.h:48
Generated on Tue Jun 18 2024 16:24:07 for gem5 by
doxygen
1.11.0