diff options
-rw-r--r-- | main.c | 16 | ||||
-rw-r--r-- | nios2sim-ng.h | 5 |
2 files changed, 16 insertions, 5 deletions
@@ -36,6 +36,8 @@ #define DEFAULT_MEM_SIZE (16 * 1024 * 1024) +bool verbose = false; + static void usage(const int status) { fprintf(stdout, "Usage: %s [OPTION...] IMAGE\n" @@ -67,12 +69,13 @@ static const struct option long_opts[] = { { "cmdline", required_argument, NULL, 'c' }, { "initrd", required_argument, NULL, 'r' }, { "fs_image", required_argument, NULL, 'f' }, + { "verbose", no_argument, NULL, 'v' }, { "version", no_argument, NULL, 'V' }, { "help", no_argument, NULL, 'h' }, { NULL, 0, NULL, 0 } }; -static const char *short_opts = "sm:db:p:c:r:f:Vh"; +static const char *short_opts = "sm:db:p:c:r:f:vVh"; static size_t parse_mem_size(char *opt) { @@ -143,6 +146,9 @@ int main(int argc, char *argv[]) case 'f': // set_fs_image(optarg); break; + case 'v': + verbose = true; + break; case 'V': info("%s %s\n", PROGRAM_NAME, PROGRAM_VERSION); exit(EXIT_SUCCESS); @@ -170,10 +176,10 @@ int main(int argc, char *argv[]) if (image_load(image_path, image_format, mem_base, mem_size)) exit(EXIT_FAILURE); - info(" Image file: %s\n", image_path); - info(" Image format: %s\n", image_format_str(image_format)); - info(" Memory size: %zu %sbytes\n", size_scale(mem_size), size_postfix(mem_size)); - info(" Memory base: %p\n", mem_base); + vinfo(" Image file: %s\n", image_path); + vinfo(" Image format: %s\n", image_format_str(image_format)); + vinfo(" Memory size: %zu %sbytes\n", size_scale(mem_size), size_postfix(mem_size)); + vinfo(" Memory base: %p\n", mem_base); #if 0 printf("Base address:0x%08X, Entry address:0x%08X\n",image_info.base_addr, diff --git a/nios2sim-ng.h b/nios2sim-ng.h index 7a3d711..6b45405 100644 --- a/nios2sim-ng.h +++ b/nios2sim-ng.h @@ -7,15 +7,20 @@ #include <stdlib.h> #include <stdint.h> +#include <stdbool.h> #include "compiler.h" +extern bool verbose; + #define __round_mask(x, y) ((__typeof__(x))((y) - 1)) #define round_up(x, y) ((((x) - 1) | __round_mask(x, y)) + 1) #define err(fmt, args...) fprintf(stderr, "Error: " fmt, ##args) #define warn(fmt, args...) fprintf(stderr, "Warning: " fmt, ##args) #define info(fmt, args...) fprintf(stdout, fmt, ##args) +#define vinfo(fmt, args...) \ + do { if (verbose) fprintf(stdout, fmt, ##args); } while (0) #ifdef DEBUG # define dbg(fmt, args...) fprintf(stdout, fmt, ##args) #else |