m5.c (8659:78f27ef5e919) m5.c (8734:79592b2b1d55)
1/*
2 * Copyright (c) 2011 ARM Limited
3 * All rights reserved
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software

--- 74 unchanged lines hidden (view full) ---

83 memset(buf, 0, sizeof(buf));
84
85 while ((len = m5_readfile(buf, sizeof(buf), offset)) > 0) {
86 write(dest_fid, buf, len);
87 offset += len;
88 }
89}
90
1/*
2 * Copyright (c) 2011 ARM Limited
3 * All rights reserved
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software

--- 74 unchanged lines hidden (view full) ---

83 memset(buf, 0, sizeof(buf));
84
85 while ((len = m5_readfile(buf, sizeof(buf), offset)) > 0) {
86 write(dest_fid, buf, len);
87 offset += len;
88 }
89}
90
91int
92write_file(const char *filename)
93{
94 fprintf(stderr, "opening %s\n", filename);
95 int src_fid = open(filename, O_RDONLY);
96
97 if (src_fid < 0) {
98 fprintf(stderr, "error opening %s\n", filename);
99 return;
100 }
101
102 char buf[256*1024];
103 int offset = 0;
104 int len;
105 int bytes = 0;
106
107 memset(buf, 0, sizeof(buf));
108
109 while ((len = read(src_fid, buf, sizeof(buf))) > 0) {
110 bytes += m5_writefile(buf, len, offset, filename);
111 offset += len;
112 }
113 fprintf(stderr, "written %d bytes\n", bytes);
114
115 close(src_fid);
116}
117
91void
92do_exit(int argc, char *argv[])
93{
94 if (argc > 1)
95 usage();
96
97 m5_exit((argc > 0) ? strtoul(argv[0], NULL, 0) : 0);
98}

--- 27 unchanged lines hidden (view full) ---

126{
127 if (argc > 0)
128 usage();
129
130 read_file(STDOUT_FILENO);
131}
132
133void
118void
119do_exit(int argc, char *argv[])
120{
121 if (argc > 1)
122 usage();
123
124 m5_exit((argc > 0) ? strtoul(argv[0], NULL, 0) : 0);
125}

--- 27 unchanged lines hidden (view full) ---

153{
154 if (argc > 0)
155 usage();
156
157 read_file(STDOUT_FILENO);
158}
159
160void
161do_write_file(int argc, char *argv[])
162{
163 if (argc != 1)
164 usage();
165
166 const char *filename = argv[0];
167
168 write_file(filename);
169}
170
171void
134do_exec_file(int argc, char *argv[])
135{
136 if (argc > 0)
137 usage();
138
139 const char *destname = "/tmp/execfile";
140
141 int fid = open(destname, O_WRONLY, 0777);

--- 80 unchanged lines hidden (view full) ---

222 char *usage;
223};
224
225struct MainFunc mainfuncs[] = {
226 { "exit", do_exit, "[delay]" },
227 { "resetstats", do_reset_stats, "[delay [period]]" },
228 { "dumpstats", do_dump_stats, "[delay [period]]" },
229 { "dumpresetstats", do_dump_reset_stats, "[delay [period]]" },
172do_exec_file(int argc, char *argv[])
173{
174 if (argc > 0)
175 usage();
176
177 const char *destname = "/tmp/execfile";
178
179 int fid = open(destname, O_WRONLY, 0777);

--- 80 unchanged lines hidden (view full) ---

260 char *usage;
261};
262
263struct MainFunc mainfuncs[] = {
264 { "exit", do_exit, "[delay]" },
265 { "resetstats", do_reset_stats, "[delay [period]]" },
266 { "dumpstats", do_dump_stats, "[delay [period]]" },
267 { "dumpresetstats", do_dump_reset_stats, "[delay [period]]" },
230 { "readfile", do_read_file, "[filename]" },
231 { "execfile", do_exec_file, "<filename>" },
268 { "readfile", do_read_file, "" },
269 { "writefile", do_write_file, "<filename>" },
270 { "execfile", do_exec_file, "" },
232 { "checkpoint", do_checkpoint, "[delay [period]]" },
233 { "loadsymbol", do_load_symbol, "<address> <symbol>" },
234 { "initparam", do_initparam, "" },
235 { "sw99param", do_sw99param, "" },
236#ifdef linux
237 { "pin", do_pin, "<cpu> <program> [args ...]" }
238#endif
239};

--- 41 unchanged lines hidden ---
271 { "checkpoint", do_checkpoint, "[delay [period]]" },
272 { "loadsymbol", do_load_symbol, "<address> <symbol>" },
273 { "initparam", do_initparam, "" },
274 { "sw99param", do_sw99param, "" },
275#ifdef linux
276 { "pin", do_pin, "<cpu> <program> [args ...]" }
277#endif
278};

--- 41 unchanged lines hidden ---