5 static char *deck_head
=
7 "# NOTE: This file was automatically generated by " __FILE__
"\n"
9 "# During the system IPL, 24 bytes are read from the device.\n"
11 "# NOTE: zArch IPLs in ESA/390 mode.\n"
14 static char *card_head
=
16 "#######################################################################\n"
18 "#######################################################################\n";
20 static char *psw_head
=
22 "# Bytes 0-7 contain PSW to be loaded after IO operation completes\n"
27 " # bits value name desc\n"
29 " # 1 0 PER Mask (R) disabled\n"
31 " # 5 0 DAT Mode (T) disabled\n"
32 " # 6 0 I/O Mask (IO) disabled\n"
33 " # 7 0 External Mask (EX) disabled\n"
36 " # bits value name desc\n"
39 " # 13 0 Machine-Check Mask (M) disabled\n"
40 " # 14 0 Wait State (W) executing\n"
41 " # 15 0 Problem State (P) supervisor state\n"
44 " # bits value name desc\n"
45 " # 16-17 0 Address-Space Control (AS) disabled\n"
46 " # 18-19 0 Condition Code (CC)\n"
47 " # 20-23 0 Program Mask exceptions disabled\n"
50 " # bits value name desc\n"
52 " # 31 0 Extended Addressing (EA) ! 64 mode\n"
54 " .byte 0x%c%c # bits 32-39\n"
55 " .byte 0x%c%c # bits 40-47\n"
56 " .byte 0x%c%c # bits 48-55\n"
57 " .byte 0x%c%c # bits 56-63\n"
58 " # bits value name desc\n"
59 " # 32 1 Basic Addressing (BA) BA = 31, !BA = 24\n"
60 " # 33-63 addr Instruction Address Address to exec\n";
62 static char *psw_tail
=
65 "# The remaining 16 bytes should contain CCW to read data from device\n"
71 "# 8-31 Data Address\n"
72 "# 32 Chain-Data (CD)\n"
73 "# 33 Chain-Command (CC)\n"
74 "# 34 Sup.-Len.-Inditcation (SLI)\n"
76 "# 36 Prog.-Contr.-Inter. (PCI)\n"
77 "# 37 Indir.-Data-Addr. (IDA)\n"
79 "# 39 Modified I.D.A. (MIDA)\n"
81 "# 48-63 number of bytes to read\n"
84 " # READ 80 bytes of CCWs to 0x%06X\n"
85 " .byte 0x02, 0x%02X, 0x%02X, 0x%02X\n"
86 " .byte 0x%02X, 0x00, 0x00, 0x50\n"
90 " .byte 0x08, 0x%02X, 0x%02X, 0x%02X\n"
91 " .byte 0x00, 0x00, 0x00, 0x00\n";
98 " .byte 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40\n"
99 " .byte 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40\n"
100 " .byte 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40\n"
101 " .byte 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40\n"
102 " .byte 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40\n"
103 " .byte 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40\n"
104 " .byte 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40\n";
106 static char *cp_ccw
=
109 " .byte 0x02, 0x%02X, 0x%02X, 0x%02X\n"
110 " .byte 0x40, 0x00, 0x00, 0x50\n";
114 static char *data_ccw
=
117 " .byte 0x02, 0x%02X, 0x%02X, 0x%02X\n"
118 " .byte 0x%02X, 0x00, 0x00, 0x50\n";
120 static char *nop_ccw
=
123 " .byte 0x03, 0x00, 0x00, 0x08\n"
124 " .byte 0x60, 0x00, 0x00, 0x01\n";
126 #define ADDR(x) (((x)[0]<<16) | \
130 #define ADDRS(x) (x)[0], (x)[1], (x)[2]
132 static void die(char *pgm
, char *s
)
134 fprintf(stderr
, "Error: %s\n", s
);
135 fprintf(stderr
, "Usage: %s <psw word 1> <psw word 2> <file size> "
136 "<address> <channel pgm addr>\n", pgm
);
140 static unsigned int unhex(char *pgm
, char c
)
142 if ((c
>= '0') && (c
<= '9'))
144 if ((c
>= 'A') && (c
<= 'F'))
146 if ((c
>= 'a') && (c
<= 'f'))
148 die(pgm
, "Argument not hexadecimal");
152 static void __add(unsigned int *addr
, int a
)
157 for(i
=2; i
>=0; i
--) {
159 addr
[i
-1] += addr
[i
] / 256;
165 int main(int argc
, char **argv
)
169 unsigned int ccw_addr
[3];
170 unsigned int addr
[3];
172 unsigned int data_cards
;
175 die(argv
[0], "Invalid number of args");
177 if ((strlen(argv
[1]) != 8) ||
178 (strlen(argv
[2]) != 8))
179 die(argv
[0], "Invalid PSW argument length");
181 size
= atol(argv
[3]);
183 die(argv
[0], "Invalid file size");
185 if ((strlen(argv
[4]) != 6) ||
186 (strlen(argv
[5]) != 6))
187 die(argv
[0], "Invalid addr argument length");
189 addr
[0] = (unhex(argv
[0], argv
[4][0]) << 4) |
190 unhex(argv
[0], argv
[4][1]);
191 addr
[1] = (unhex(argv
[0], argv
[4][2]) << 4) |
192 unhex(argv
[0], argv
[4][3]);
193 addr
[2] = (unhex(argv
[0], argv
[4][4]) << 4) |
194 unhex(argv
[0], argv
[4][5]);
196 ccw_addr
[0] = (unhex(argv
[0], argv
[5][0]) << 4) |
197 unhex(argv
[0], argv
[5][1]);
198 ccw_addr
[1] = (unhex(argv
[0], argv
[5][2]) << 4) |
199 unhex(argv
[0], argv
[5][3]);
200 ccw_addr
[2] = (unhex(argv
[0], argv
[5][4]) << 4) |
201 unhex(argv
[0], argv
[5][5]);
205 size
= size
- (size
% 80) + 80;
207 data_cards
= size
/ 80;
211 printf(card_head
, i
);
214 argv
[1][0], argv
[1][1], argv
[1][2], argv
[1][3],
215 argv
[1][4], argv
[1][5], argv
[1][6], argv
[1][7],
216 argv
[2][0], argv
[2][1], argv
[2][2], argv
[2][3],
217 argv
[2][4], argv
[2][5], argv
[2][6], argv
[2][7]);
220 die(argv
[0], "Cannot handle the case where size <= 80");
226 printf(psw_tail
, ADDR(ccw_addr
), ADDRS(ccw_addr
), CHAIN
,
227 ADDR(ccw_addr
), ADDRS(ccw_addr
));
231 for(i
=0; i
<=((data_cards
+9)/10) + (((data_cards
+9)/10)+9)/10 - 2; i
++) {
232 printf(cp_ccw
, i
+3, ADDRS(ccw_addr
));
241 for(i
=1; i
<=data_cards
; i
++) {
242 printf(data_ccw
, i
, ADDRS(addr
),
243 (i
== data_cards
) ? 0 : CHAIN
);
250 printf(card_head
, card
++);