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.
34 #include "mem/packet.hh"
36 typedef void* RubyPortHandle;
37 enum RubyRequestType {
39 RubyRequestType_IFETCH,
42 RubyRequestType_Locked_Read,
43 RubyRequestType_Locked_Write,
44 RubyRequestType_RMW_Read,
45 RubyRequestType_RMW_Write,
51 RubyAccessMode_Supervisor,
61 RubyAccessMode access_mode;
66 RubyRequest(uint64_t _paddr,
70 RubyRequestType _type,
71 RubyAccessMode _access_mode,
73 unsigned _proc_id = 100)
79 access_mode(_access_mode),
85 std::ostream& operator<<(std::ostream& out, const RubyRequest& obj);
88 * Initialize the system. cfg_file is a Ruby-lang configuration script
90 void libruby_init(const char* cfg_file);
93 * Tear down a configured system. Must be invoked after a call to libruby_init.
95 void libruby_destroy();
98 * Print the last error encountered by ruby. Currently unimplemented.
100 const char* libruby_last_error();
103 * Retrieve a handle to a RubyPort object, identified by name in the
104 * configuration. You also pass in the callback function you want
105 * this port to use when a request completes. Only one handle to a
106 * port is allowed at a time.
108 RubyPortHandle libruby_get_port(const char* name, void (*hit_callback)(int64_t access_id));
111 * Retrieve a handle to a RubyPort object, identified by name in the
114 RubyPortHandle libruby_get_port_by_name(const char* name);
118 * issue_request returns a unique access_id to identify the ruby
119 * transaction. This access_id is later returned to the caller via
120 * hit_callback (passed to libruby_get_port)
122 int64_t libruby_issue_request(RubyPortHandle p, struct RubyRequest request);
125 * writes data directly into Ruby's data array. Note that this
126 * ignores caches, and should be considered incoherent after
129 void libruby_write_ram(uint64_t paddr, uint8_t * data, int len);
132 * reads data directory from Ruby's data array. Note that this
133 * ignores caches, and should be considered incoherent after
136 void libruby_read_ram(uint64_t paddr, uint8_t * data, int len);
139 * tick the system n cycles. Eventually, will return the number of
140 * cycles until the next event, but for now it always returns 0
142 int libruby_tick(int n);
147 void libruby_print_config(std::ostream & out);
152 void libruby_print_stats(std::ostream & out);
155 * does not return until done
157 void libruby_playback_trace(char * trace_filename);
160 * enables the tracer and opens the trace file
162 void libruby_start_tracing(char * record_filename);
165 * closes the trace file
167 void libruby_stop_tracing();
172 uint64_t libruby_get_time();