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> |
57#include <unistd.h> 58 59#include "m5op.h" 60 |
61void *m5_mem = NULL; 62 |
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 |
343int 344main(int argc, char *argv[]) 345{ 346 progname = argv[0]; 347 if (argc < 2) 348 usage(1); 349 |
350 map_m5_mem(); 351 |
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} |