2 * Copyright (c) 2009 Mark D. Hill and David A. Wood
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;
9 * redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution;
12 * neither the name of the copyright holders nor the names of its
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 #ifndef __MEM_RUBY_LIBRUBY_HH__
30 #define __MEM_RUBY_LIBRUBY_HH__
34 #include "base/types.hh"
35 #include "mem/packet.hh"
37 typedef void* RubyPortHandle;
38 enum RubyRequestType {
40 RubyRequestType_IFETCH,
43 RubyRequestType_Locked_Read,
44 RubyRequestType_Locked_Write,
45 RubyRequestType_RMW_Read,
46 RubyRequestType_RMW_Write,
52 RubyAccessMode_Supervisor,
63 RubyAccessMode access_mode;
68 RubyRequest(uint64_t _paddr,
72 RubyRequestType _type,
73 RubyAccessMode _access_mode,
75 unsigned _proc_id = 100)
81 access_mode(_access_mode),
87 std::ostream& operator<<(std::ostream& out, const RubyRequest& obj);
90 * Initialize the system. cfg_file is a Ruby-lang configuration script
92 void libruby_init(const char* cfg_file);
95 * Tear down a configured system. Must be invoked after a call to
98 void libruby_destroy();
101 * Print the last error encountered by ruby. Currently unimplemented.
103 const char* libruby_last_error();
106 * Retrieve a handle to a RubyPort object, identified by name in the
107 * configuration. You also pass in the callback function you want
108 * this port to use when a request completes. Only one handle to a
109 * port is allowed at a time.
111 RubyPortHandle libruby_get_port(const char* name,
112 void (*hit_callback)(int64_t access_id));
115 * Retrieve a handle to a RubyPort object, identified by name in the
118 RubyPortHandle libruby_get_port_by_name(const char* name);
121 * issue_request returns a unique access_id to identify the ruby
122 * transaction. This access_id is later returned to the caller via
123 * hit_callback (passed to libruby_get_port)
125 int64_t libruby_issue_request(RubyPortHandle p, struct RubyRequest request);
128 * writes data directly into Ruby's data array. Note that this
129 * ignores caches, and should be considered incoherent after
132 void libruby_write_ram(uint64_t paddr, uint8_t *data, int len);
135 * reads data directory from Ruby's data array. Note that this
136 * ignores caches, and should be considered incoherent after
139 void libruby_read_ram(uint64_t paddr, uint8_t *data, int len);
142 * tick the system n cycles. Eventually, will return the number of
143 * cycles until the next event, but for now it always returns 0
145 int libruby_tick(int n);
150 void libruby_print_config(std::ostream &out);
155 void libruby_print_stats(std::ostream &out);
158 * does not return until done
160 void libruby_playback_trace(char *trace_filename);
163 * enables the tracer and opens the trace file
165 void libruby_start_tracing(char *record_filename);
168 * closes the trace file
170 void libruby_stop_tracing();
175 uint64_t libruby_get_time();
177 #endif // __MEM_RUBY_LIBRUBY_HH__