m5.c (9457:a4739b6f799d) m5.c (9898:2935441b0870)
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

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

46#endif
47
48#include <err.h>
49#include <fcntl.h>
50#include <inttypes.h>
51#include <stdio.h>
52#include <stdlib.h>
53#include <string.h>
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

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

46#endif
47
48#include <err.h>
49#include <fcntl.h>
50#include <inttypes.h>
51#include <stdio.h>
52#include <stdlib.h>
53#include <string.h>
54#include <sys/mman.h>
55#include <sys/stat.h>
56#include <sys/types.h>
54#include <unistd.h>
55
56#include "m5op.h"
57
57#include <unistd.h>
58
59#include "m5op.h"
60
61void *m5_mem = NULL;
62
58char *progname;
59char *command = "unspecified";
60void usage();
61
62void
63parse_int_args(int argc, char *argv[], uint64_t ints[], int len)
64{
65 if (argc > len)

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

310 header, progname, mainfuncs[i].name, mainfuncs[i].usage);
311 }
312 fprintf(stderr, "\n");
313 fprintf(stderr, "All times in nanoseconds!\n");
314
315 exit(1);
316}
317
63char *progname;
64char *command = "unspecified";
65void usage();
66
67void
68parse_int_args(int argc, char *argv[], uint64_t ints[], int len)
69{
70 if (argc > len)

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

315 header, progname, mainfuncs[i].name, mainfuncs[i].usage);
316 }
317 fprintf(stderr, "\n");
318 fprintf(stderr, "All times in nanoseconds!\n");
319
320 exit(1);
321}
322
323static void
324map_m5_mem()
325{
326#ifdef M5OP_ADDR
327 int fd;
328
329 fd = open("/dev/mem", O_RDWR | O_SYNC);
330 if (fd == -1) {
331 perror("Can't open /dev/mem");
332 exit(1);
333 }
334
335 m5_mem = mmap(NULL, 0x10000, PROT_READ | PROT_WRITE, MAP_SHARED, fd, M5OP_ADDR);
336 if (!m5_mem) {
337 perror("Can't mmap /dev/mem");
338 exit(1);
339 }
340#endif
341}
342
318int
319main(int argc, char *argv[])
320{
321 progname = argv[0];
322 if (argc < 2)
323 usage(1);
324
343int
344main(int argc, char *argv[])
345{
346 progname = argv[0];
347 if (argc < 2)
348 usage(1);
349
350 map_m5_mem();
351
325 command = argv[1];
326
327 argv += 2;
328 argc -= 2;
329
330 int i;
331 for (i = 0; i < numfuncs; ++i) {
332 if (strcmp(command, mainfuncs[i].name) != 0)
333 continue;
334
335 mainfuncs[i].func(argc, argv);
336 exit(0);
337 }
338
339 usage(1);
340}
352 command = argv[1];
353
354 argv += 2;
355 argc -= 2;
356
357 int i;
358 for (i = 0; i < numfuncs; ++i) {
359 if (strcmp(command, mainfuncs[i].name) != 0)
360 continue;
361
362 mainfuncs[i].func(argc, argv);
363 exit(0);
364 }
365
366 usage(1);
367}