annotate simtool/writecmd.c @ 225:208ae1633f6c

simtool code: sysmo.c renamed to sjs1_hacks.c, comments changed to clarify that these special commands apply only to the recently discontinued SJS1 cards and not to the SJA2 successor.
author Mychaela Falconia <falcon@freecalypso.org>
date Wed, 10 Mar 2021 19:39:33 +0000
parents f1cf569dbba3
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 #include <sys/types.h>
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 #include <stdio.h>
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 #include <stdlib.h>
202
3f6f50103dd3 fc-simtool: update-rec-prev separate command eliminated,
Mychaela Falconia <falcon@freecalypso.org>
parents: 141
diff changeset
4 #include <string.h>
3f6f50103dd3 fc-simtool: update-rec-prev separate command eliminated,
Mychaela Falconia <falcon@freecalypso.org>
parents: 141
diff changeset
5 #include <strings.h>
1
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include "curfile.h"
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 cmd_update_bin(argc, argv)
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 char **argv;
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 {
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 unsigned offset, len;
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 u_char data[255];
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 int rc;
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 offset = strtoul(argv[1], 0, 0);
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 if (offset > 0xFFFF) {
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 fprintf(stderr, "error: offset argument is out of range\n");
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 return(-1);
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 }
141
a1aa8ee2da85 read_hex_data_file(): add maxlen argument
Mychaela Falconia <falcon@freecalypso.org>
parents: 78
diff changeset
20 rc = read_hex_data_file(argv[2], data, 255);
1
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 if (rc < 0)
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 return(rc);
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 len = rc;
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 return update_bin_op(offset, data, len);
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 }
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 cmd_update_bin_imm(argc, argv)
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 char **argv;
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 {
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 unsigned offset, len;
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 u_char data[255];
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 int rc;
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 offset = strtoul(argv[1], 0, 0);
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 if (offset > 0xFFFF) {
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 fprintf(stderr, "error: offset argument is out of range\n");
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 return(-1);
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 }
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 rc = decode_hex_data_from_string(argv[2], data, 1, 255);
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 if (rc < 0)
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 return(rc);
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 len = rc;
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 return update_bin_op(offset, data, len);
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 }
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 cmd_update_rec(argc, argv)
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 char **argv;
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 {
202
3f6f50103dd3 fc-simtool: update-rec-prev separate command eliminated,
Mychaela Falconia <falcon@freecalypso.org>
parents: 141
diff changeset
49 unsigned recno, mode;
1
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 u_char data[255];
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 int rc;
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52
202
3f6f50103dd3 fc-simtool: update-rec-prev separate command eliminated,
Mychaela Falconia <falcon@freecalypso.org>
parents: 141
diff changeset
53 if (!strcmp(argv[1], "prev")) {
3f6f50103dd3 fc-simtool: update-rec-prev separate command eliminated,
Mychaela Falconia <falcon@freecalypso.org>
parents: 141
diff changeset
54 recno = 0;
3f6f50103dd3 fc-simtool: update-rec-prev separate command eliminated,
Mychaela Falconia <falcon@freecalypso.org>
parents: 141
diff changeset
55 mode = 0x03;
3f6f50103dd3 fc-simtool: update-rec-prev separate command eliminated,
Mychaela Falconia <falcon@freecalypso.org>
parents: 141
diff changeset
56 } else {
3f6f50103dd3 fc-simtool: update-rec-prev separate command eliminated,
Mychaela Falconia <falcon@freecalypso.org>
parents: 141
diff changeset
57 recno = strtoul(argv[1], 0, 0);
3f6f50103dd3 fc-simtool: update-rec-prev separate command eliminated,
Mychaela Falconia <falcon@freecalypso.org>
parents: 141
diff changeset
58 if (recno < 1 || recno > 255) {
3f6f50103dd3 fc-simtool: update-rec-prev separate command eliminated,
Mychaela Falconia <falcon@freecalypso.org>
parents: 141
diff changeset
59 fprintf(stderr,
1
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 "error: record number argument is out of range\n");
202
3f6f50103dd3 fc-simtool: update-rec-prev separate command eliminated,
Mychaela Falconia <falcon@freecalypso.org>
parents: 141
diff changeset
61 return(-1);
3f6f50103dd3 fc-simtool: update-rec-prev separate command eliminated,
Mychaela Falconia <falcon@freecalypso.org>
parents: 141
diff changeset
62 }
3f6f50103dd3 fc-simtool: update-rec-prev separate command eliminated,
Mychaela Falconia <falcon@freecalypso.org>
parents: 141
diff changeset
63 mode = 0x04;
1
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 }
141
a1aa8ee2da85 read_hex_data_file(): add maxlen argument
Mychaela Falconia <falcon@freecalypso.org>
parents: 78
diff changeset
65 rc = read_hex_data_file(argv[2], data, 255);
1
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66 if (rc < 0)
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67 return(rc);
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
68 if (rc != curfile_record_len) {
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69 fprintf(stderr, "error: hex data length != EF record length\n");
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70 return(-1);
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
71 }
202
3f6f50103dd3 fc-simtool: update-rec-prev separate command eliminated,
Mychaela Falconia <falcon@freecalypso.org>
parents: 141
diff changeset
72 return update_rec_op(recno, mode, data, curfile_record_len);
1
2071b28cd0c7 simtool: first refactored version
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
73 }
203
647267e39c21 fc-simtool update-rec-imm command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 202
diff changeset
74
647267e39c21 fc-simtool update-rec-imm command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 202
diff changeset
75 cmd_update_rec_imm(argc, argv)
647267e39c21 fc-simtool update-rec-imm command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 202
diff changeset
76 char **argv;
647267e39c21 fc-simtool update-rec-imm command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 202
diff changeset
77 {
647267e39c21 fc-simtool update-rec-imm command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 202
diff changeset
78 unsigned recno, mode;
647267e39c21 fc-simtool update-rec-imm command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 202
diff changeset
79 u_char data[255];
647267e39c21 fc-simtool update-rec-imm command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 202
diff changeset
80 int rc;
647267e39c21 fc-simtool update-rec-imm command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 202
diff changeset
81
647267e39c21 fc-simtool update-rec-imm command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 202
diff changeset
82 if (!strcmp(argv[1], "prev")) {
647267e39c21 fc-simtool update-rec-imm command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 202
diff changeset
83 recno = 0;
647267e39c21 fc-simtool update-rec-imm command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 202
diff changeset
84 mode = 0x03;
647267e39c21 fc-simtool update-rec-imm command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 202
diff changeset
85 } else {
647267e39c21 fc-simtool update-rec-imm command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 202
diff changeset
86 recno = strtoul(argv[1], 0, 0);
647267e39c21 fc-simtool update-rec-imm command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 202
diff changeset
87 if (recno < 1 || recno > 255) {
647267e39c21 fc-simtool update-rec-imm command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 202
diff changeset
88 fprintf(stderr,
647267e39c21 fc-simtool update-rec-imm command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 202
diff changeset
89 "error: record number argument is out of range\n");
647267e39c21 fc-simtool update-rec-imm command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 202
diff changeset
90 return(-1);
647267e39c21 fc-simtool update-rec-imm command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 202
diff changeset
91 }
647267e39c21 fc-simtool update-rec-imm command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 202
diff changeset
92 mode = 0x04;
647267e39c21 fc-simtool update-rec-imm command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 202
diff changeset
93 }
647267e39c21 fc-simtool update-rec-imm command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 202
diff changeset
94 rc = decode_hex_data_from_string(argv[2], data, 1, 255);
647267e39c21 fc-simtool update-rec-imm command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 202
diff changeset
95 if (rc < 0)
647267e39c21 fc-simtool update-rec-imm command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 202
diff changeset
96 return(rc);
647267e39c21 fc-simtool update-rec-imm command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 202
diff changeset
97 if (rc != curfile_record_len) {
647267e39c21 fc-simtool update-rec-imm command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 202
diff changeset
98 fprintf(stderr, "error: hex data length != EF record length\n");
647267e39c21 fc-simtool update-rec-imm command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 202
diff changeset
99 return(-1);
647267e39c21 fc-simtool update-rec-imm command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 202
diff changeset
100 }
647267e39c21 fc-simtool update-rec-imm command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 202
diff changeset
101 return update_rec_op(recno, mode, data, curfile_record_len);
647267e39c21 fc-simtool update-rec-imm command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 202
diff changeset
102 }
204
a462012c9e67 fc-simtool: update-rec-fill command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 203
diff changeset
103
a462012c9e67 fc-simtool: update-rec-fill command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 203
diff changeset
104 cmd_update_rec_fill(argc, argv)
a462012c9e67 fc-simtool: update-rec-fill command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 203
diff changeset
105 char **argv;
a462012c9e67 fc-simtool: update-rec-fill command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 203
diff changeset
106 {
a462012c9e67 fc-simtool: update-rec-fill command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 203
diff changeset
107 unsigned recno, mode, fill_byte;
a462012c9e67 fc-simtool: update-rec-fill command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 203
diff changeset
108 u_char data[255];
a462012c9e67 fc-simtool: update-rec-fill command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 203
diff changeset
109
a462012c9e67 fc-simtool: update-rec-fill command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 203
diff changeset
110 if (!strcmp(argv[1], "prev")) {
a462012c9e67 fc-simtool: update-rec-fill command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 203
diff changeset
111 recno = 0;
a462012c9e67 fc-simtool: update-rec-fill command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 203
diff changeset
112 mode = 0x03;
a462012c9e67 fc-simtool: update-rec-fill command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 203
diff changeset
113 } else {
a462012c9e67 fc-simtool: update-rec-fill command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 203
diff changeset
114 recno = strtoul(argv[1], 0, 0);
a462012c9e67 fc-simtool: update-rec-fill command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 203
diff changeset
115 if (recno < 1 || recno > 255) {
a462012c9e67 fc-simtool: update-rec-fill command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 203
diff changeset
116 fprintf(stderr,
a462012c9e67 fc-simtool: update-rec-fill command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 203
diff changeset
117 "error: record number argument is out of range\n");
a462012c9e67 fc-simtool: update-rec-fill command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 203
diff changeset
118 return(-1);
a462012c9e67 fc-simtool: update-rec-fill command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 203
diff changeset
119 }
a462012c9e67 fc-simtool: update-rec-fill command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 203
diff changeset
120 mode = 0x04;
a462012c9e67 fc-simtool: update-rec-fill command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 203
diff changeset
121 }
206
f1cf569dbba3 fc-simtool erase-file & update-rec-fill: make fill byte always hex
Mychaela Falconia <falcon@freecalypso.org>
parents: 204
diff changeset
122 fill_byte = strtoul(argv[2], 0, 16);
204
a462012c9e67 fc-simtool: update-rec-fill command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 203
diff changeset
123 if (fill_byte > 0xFF) {
a462012c9e67 fc-simtool: update-rec-fill command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 203
diff changeset
124 fprintf(stderr, "error: invalid fill byte argument\n");
a462012c9e67 fc-simtool: update-rec-fill command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 203
diff changeset
125 return(-1);
a462012c9e67 fc-simtool: update-rec-fill command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 203
diff changeset
126 }
a462012c9e67 fc-simtool: update-rec-fill command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 203
diff changeset
127 memset(data, fill_byte, curfile_record_len);
a462012c9e67 fc-simtool: update-rec-fill command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 203
diff changeset
128 return update_rec_op(recno, mode, data, curfile_record_len);
a462012c9e67 fc-simtool: update-rec-fill command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 203
diff changeset
129 }