ruby: Fixed Directory memory destructor
[gem5.git] / src / mem / ruby / libruby.hh
1
2 #ifndef LIBRUBY_H
3 #define LIBRUBY_H
4
5 #include <stdint.h>
6 #include <ostream>
7
8 typedef void* RubyPortHandle;
9 enum RubyRequestType {
10 RubyRequestType_NULL,
11 RubyRequestType_IFETCH,
12 RubyRequestType_LD,
13 RubyRequestType_ST,
14 RubyRequestType_Locked_Read,
15 RubyRequestType_Locked_Write,
16 RubyRequestType_RMW_Read,
17 RubyRequestType_RMW_Write,
18 RubyRequestType_NUM
19 };
20
21 enum RubyAccessMode {
22 RubyAccessMode_User,
23 RubyAccessMode_Supervisor,
24 RubyAccessMode_Device
25 };
26
27 struct RubyRequest {
28 uint64_t paddr;
29 uint8_t* data;
30 int len;
31 uint64_t pc;
32 RubyRequestType type;
33 RubyAccessMode access_mode;
34 unsigned proc_id;
35
36 RubyRequest() {}
37 RubyRequest(uint64_t _paddr, uint8_t* _data, int _len, uint64_t _pc, RubyRequestType _type, RubyAccessMode _access_mode, unsigned _proc_id = 0)
38 : paddr(_paddr), data(_data), len(_len), pc(_pc), type(_type), access_mode(_access_mode), proc_id(_proc_id)
39 {}
40 };
41
42 std::ostream& operator<<(std::ostream& out, const RubyRequest& obj);
43
44 /**
45 * Initialize the system. cfg_file is a Ruby-lang configuration script
46 */
47 void libruby_init(const char* cfg_file);
48
49 /**
50 * Tear down a configured system. Must be invoked after a call to libruby_init.
51 */
52 void libruby_destroy();
53
54 /**
55 * Print the last error encountered by ruby. Currently unimplemented.
56 */
57 const char* libruby_last_error();
58
59 /**
60 * Retrieve a handle to a RubyPort object, identified by name in the
61 * configuration. You also pass in the callback function you want
62 * this port to use when a request completes. Only one handle to a
63 * port is allowed at a time.
64 */
65 RubyPortHandle libruby_get_port(const char* name, void (*hit_callback)(int64_t access_id));
66
67 /**
68 * Retrieve a handle to a RubyPort object, identified by name in the
69 * configuration.
70 */
71 RubyPortHandle libruby_get_port_by_name(const char* name);
72
73
74 /**
75 * issue_request returns a unique access_id to identify the ruby
76 * transaction. This access_id is later returned to the caller via
77 * hit_callback (passed to libruby_get_port)
78 */
79 int64_t libruby_issue_request(RubyPortHandle p, struct RubyRequest request);
80
81 /**
82 * writes data directly into Ruby's data array. Note that this
83 * ignores caches, and should be considered incoherent after
84 * simulation starts.
85 */
86 void libruby_write_ram(uint64_t paddr, uint8_t * data, int len);
87
88 /**
89 * reads data directory from Ruby's data array. Note that this
90 * ignores caches, and should be considered incoherent after
91 * simulation starts
92 */
93 void libruby_read_ram(uint64_t paddr, uint8_t * data, int len);
94
95 /**
96 * tick the system n cycles. Eventually, will return the number of
97 * cycles until the next event, but for now it always returns 0
98 */
99 int libruby_tick(int n);
100
101 /**
102 * self explainitory
103 */
104 void libruby_print_config(std::ostream & out);
105
106 /**
107 * self explainitory
108 */
109 void libruby_print_stats(std::ostream & out);
110
111 /**
112 * does not return until done
113 */
114 void libruby_playback_trace(char * trace_filename);
115
116 /*
117 * enables the tracer and opens the trace file
118 */
119 void libruby_start_tracing(char * record_filename);
120
121 /*
122 * closes the trace file
123 */
124 void libruby_stop_tracing();
125
126 /**
127 * get time
128 */
129 uint64_t libruby_get_time();
130 #endif