1 | #include <iostream> |
---|
2 | #include "memo.h" |
---|
3 | |
---|
4 | void print_help(); |
---|
5 | |
---|
6 | int main(int argc, char *argv[]) |
---|
7 | { |
---|
8 | std::string map_path(""); |
---|
9 | std::string soft_path("soft.elf"); |
---|
10 | bool show = false; |
---|
11 | bool show_map = false; |
---|
12 | |
---|
13 | if (argc > 1) |
---|
14 | { |
---|
15 | for( int n=1 ; n<argc ; n++ ) |
---|
16 | { |
---|
17 | if( (strcmp(argv[n],"-o") == 0) && (n+1<argc) ) |
---|
18 | { |
---|
19 | soft_path = argv[n+1]; |
---|
20 | n++; |
---|
21 | } |
---|
22 | else |
---|
23 | if( (strcmp(argv[n],"-v") == 0)) |
---|
24 | show = true; |
---|
25 | else |
---|
26 | if( (strcmp(argv[n],"-sm") == 0)) |
---|
27 | show_map = true; |
---|
28 | else |
---|
29 | map_path = std::string(argv[n]); |
---|
30 | |
---|
31 | } |
---|
32 | }else |
---|
33 | { |
---|
34 | print_help(); |
---|
35 | } |
---|
36 | |
---|
37 | //std::cout << map_path << std::endl; |
---|
38 | //std::cout << soft_path << std::endl; |
---|
39 | |
---|
40 | MeMo memo(map_path); |
---|
41 | |
---|
42 | memo.buildSoft(soft_path); |
---|
43 | |
---|
44 | if(show) |
---|
45 | std::cout << memo << std::endl; |
---|
46 | |
---|
47 | if(show_map) |
---|
48 | memo.print_mapping(); |
---|
49 | |
---|
50 | std::cout << "Done: " << soft_path << std::endl; |
---|
51 | |
---|
52 | return 0; |
---|
53 | } |
---|
54 | |
---|
55 | void print_help() |
---|
56 | { |
---|
57 | |
---|
58 | std::cout << "***Arguments are:***" << std::endl; |
---|
59 | std::cout << " +mandatory argument:" << std::endl; |
---|
60 | std::cout << " `mappath`: mapping info structure path" << std::endl; |
---|
61 | std::cout << " +other argument:" << std::endl; |
---|
62 | std::cout << " \"-v\" for a verbose printing" << std::endl; |
---|
63 | std::cout << " \"-o\" output filename (default soft.bin)" << std::endl; |
---|
64 | std::cout << " \"-sm\" print the content of each physical segment" << std::endl; |
---|
65 | std::cout << "***Examples:***" << std::endl; |
---|
66 | std::cout << "./memo map.bin" << std::endl; |
---|
67 | std::cout << "./memo map.bin -v" << std::endl; |
---|
68 | std::cout << "./memo map.bin -v -o mysoft.bin -sm" << std::endl; |
---|
69 | } |
---|