FreeCalypso > hg > freecalypso-hwlab
comparison simtool/readcmd.c @ 95:5f826e428641
fc-simtool: readef command implemented
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 24 Jan 2021 20:47:00 +0000 |
parents | 0ead9444a698 |
children |
comparison
equal
deleted
inserted
replaced
94:b84df973cd8b | 95:5f826e428641 |
---|---|
59 if (rc < 0) | 59 if (rc < 0) |
60 return(rc); | 60 return(rc); |
61 display_sim_resp_in_hex(); | 61 display_sim_resp_in_hex(); |
62 return(0); | 62 return(0); |
63 } | 63 } |
64 | |
65 cmd_readef(argc, argv) | |
66 char **argv; | |
67 { | |
68 int file_id, rc; | |
69 unsigned readlen; | |
70 | |
71 if (isxdigit(argv[1][0]) && isxdigit(argv[1][1]) && | |
72 isxdigit(argv[1][2]) && isxdigit(argv[1][3]) && !argv[1][4]) | |
73 file_id = strtoul(argv[1], 0, 16); | |
74 else | |
75 file_id = find_symbolic_file_name(argv[1]); | |
76 if (file_id < 0) { | |
77 fprintf(stderr, | |
78 "error: file ID argument is not a hex value or a recognized symbolic name\n"); | |
79 return(-1); | |
80 } | |
81 rc = select_op(file_id); | |
82 if (rc < 0) | |
83 return(rc); | |
84 rc = parse_ef_select_response(); | |
85 if (rc < 0) | |
86 return(rc); | |
87 if (curfile_structure != 0x00) { | |
88 fprintf(stderr, | |
89 "error: readef command is only for transparent EFs\n"); | |
90 return(-1); | |
91 } | |
92 printf("Transparent EF of %u byte(s)\n", curfile_total_size); | |
93 printf("File status: %02X\n", sim_resp_data[11]); | |
94 show_access_conditions("UPDATE", sim_resp_data[8] & 0xF); | |
95 show_access_conditions("READ & SEEK", sim_resp_data[8] >> 4); | |
96 show_access_conditions("INCREASE", sim_resp_data[9] >> 4); | |
97 show_access_conditions("INVALIDATE", sim_resp_data[10] & 0xF); | |
98 show_access_conditions("REHABILITATE", sim_resp_data[10] >> 4); | |
99 if (!curfile_total_size) | |
100 return(0); | |
101 readlen = curfile_total_size; | |
102 if (readlen > 256) | |
103 readlen = 256; | |
104 rc = readbin_op(0, readlen); | |
105 if (rc < 0) | |
106 return(rc); | |
107 display_sim_resp_in_hex(); | |
108 return(0); | |
109 } |