Hercules Setup and IPL

First we need to create a Hercules configuration file.  I used the configuration file for my MVS system and stripped almost everything out.

#
# Configuration file for Hercules CARD80 Stand Alone IPL Program
#

CPUSERIAL 068068
CPUMODEL 0158
ARCHMODE S/370
MAINSIZE 2
CNSLPORT 8270
NUMCPU 1
#

000C 3505 card80.ipl
000E 1403 card80.txt

There are only a few critical lines in the conf file.  We must set ARCHMODE to S/370.  We can set MAINSIZE to just about anything since we only use a very small amount of man memory.  I set CNSLPORT to 8270 since my Hercules system running MVS uses 3270 as the console port.

We only need to define two devices, our card reader and a printer.  The card reader is defined at the standard  address for a reader X’00C’ and the printer at X’00E’.  The address of the printer must match what we coded in our program we will IPL.  The reader is associated with the file created when we punched the output from our program running on MVS.  It contains our standalone IPL deck and some data cards.  The printer is associated with a file that will receive the output from the printer.

Now we can fire up Hercules and try to IPL.

> hercules -f ./card80.conf > ./card80.log

This will start up a Hercules instance and use our card80.conf file for the configuration. Console messages will be saved in the file card80.log.

17:39:58 Hercules Version 3.06
17:39:58 (c)Copyright 1999-2009 by Roger Bowler, Jan Jaeger, and others
17:39:58 Built on Nov 19 2009 at 14:40:57
17:39:58 Build information:
17:39:58   Modes: S/370 ESA/390 z/Arch
17:39:58   Max CPU Engines: 8
17:39:58   Using setresuid() for setting privileges
17:39:58   Dynamic loading support
17:39:58   Using shared libraries
17:39:58   No External GUI support
17:39:58   HTTP Server support
17:39:58   Regular Expressions support
17:39:58   Automatic Operator support
17:39:58   National Language Support
17:39:58   Machine dependent assists: cmpxchg1 cmpxchg4 cmpxchg8 fetch_dw store_dw multi_byte
17:39:58 Running on mvs Linux-2.6.13-15-default.#1 Tue Sep 13 14:56:15 UTC 2005 i686 UP
17:39:58 HHCHD018I Loadable module directory is /usr/local/lib/hercules
17:39:58 Crypto module loaded (c) Copyright Bernard van der Helm, 2003-2009
17:39:58   Active: Message Security Assist
17:39:58           Message Security Assist Extension 1
17:39:58           Message Security Assist Extension 2
17:39:58 HHCHT001I HTTP listener thread started: tid=40968BB0, pid=4423
17:39:58 HHCHT013I Using HTTPROOT directory "/usr/local/share/hercules/"
17:39:58 HHCHT006I Waiting for HTTP requests on port 8555
17:39:58 HHCCF065I Hercules: tid=4062CDC0, pid=4423, pgid=4422, priority=0
17:39:58 HHCTT002I Timer thread started: tid=41B79BB0, pid=4423, priority=0
17:39:58 HHCCP002I CPU0000 thread started: tid=41A78BB0, pid=4423, priority=15
17:39:58 HHCCP003I CPU0000 architecture mode S/370
17:39:58 HHCPN001I Control panel thread started: tid=4062CDC0, pid=4423
17:39:58 HHCAO001I Hercules Automatic Operator thread started;
17:39:58           tid=41F0BBB0, pri=0, pid=4423

Now we can issue the IPL command to Hercules – IPL 00C

17:40:01 ipl 00c
17:40:01 HHCCP048I 000C:CCW=020004C2 00000050=>F1F0405A 5A5A5A5A 5A5A5A5A 5A5A5A5A 10 !!!!!!!!!!!!!
17:40:01 HHCCP075I 000C:Stat=0E40 Count=0050 =>F1F0405A 5A5A5A5A 5A5A5A5A 5A5A5A5A 10 !!!!!!!!!!!!!
17:40:01 HHCCP076I 000C:Sense=40100000 00000000 00000000 00000000 00000000 00000000
17:40:01 HHCCP077I 000C:Sense=INTREQ MSG
17:40:01 HHCCP011I CPU0000: Disabled wait state
17:40:01           PSW=00020000 80000E40

If all goes well our IPL deck will load into memory and begin execution. The next message we receive is an exceptional condition on the card reader. We can see the CCW “020004C2 00000050” which is an attempt to read 80 (x’50’) bytes of data. A Channel Status of X’0E40′ with a residual count of 80 is returned. (The data F1F0405A5A… is what is in our I/O buffer left over from the last successful read operation.) The CSW indicates: Channel End, Device End, Unit Check, and Incorrect Length. The Unit Check is our clue that there are no more cards in the reader (we hit end-of-file).

We also see that the CPU has entered a Disabled Wait State with a PSW of “00020000 80000E40”.  This is a PSW with the Wait Bit set to one.  The low order value (normally containing the instruction address) is used as a Wait Code to communicate back with the operator.  Our stand alone program simply moved the CSW status into the wait PSW giving us a wait code of x’0E40′.

From these messages we have determined we achieved the expected results and therefore Hercules can now be shut down.

Looking at our printer file (card80.txt) we can verify the results of execution.

01 *****************************************************************************
02 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
03 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
04 #############################################################################
05 $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
06 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
07 -----------------------------------------------------------------------------
08 (((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((
09 )))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
10 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

All ten data cards have been read from the card reader and then printed on our printer.

[Next – Absolute Object Deck Loader]

Assemble and Execute

I assembled the program using the IFOX00 Assembler running on MVS 3.8 under Hercules.  I then link edited and ran the program using the following JCL:

//CARD80 JOB (TXXOS),'GEN IPL DECK',CLASS=A,MSGCLASS=A
//CARD80 EXEC PGM=CARD80
//STEPLIB  DD DISP=SHR,DSN=TXXOS.CARD.LOAD
//PUNCH    DD UNIT=00D

I chose to send the output directly to the card punch device (located at 00D on my system) instead of sending it to the spool and then punching it using JES2.  Before running the program verify the device address for your punch device and verify it is not allocated to JES2 (using $du).  If necessary you can stop the JES device using something like $ppun1.

Also before running the program you will need to prepare the Hercules punch.  At the Hercules console I used the DEVINIT command:

DEVINIT 00D card.ipl ebcdic

This command tells Hercules to set device 00D to output to the file “card80.ipl”.  You can specify a path if you desire or else the file will be created in the directory you started Hercules from.  For example you might use something like “../punch/card80.ipl” as the file path and name.  I chose to simply place it in the default directory and then move it using a Linux line command.  It is very important you specify ebcdic so Hercules does not attempt to translate the output into ASCII.  ASCII translation will mangle the CCWs and machine code in the IPL deck and the IPL will fail.

Once the program has completed execution you can close the output file by simply using the Hercules command:

DEVINIT 00D

At this point we have our IPL deck and we are ready to set up a Hercules mainframe to run it.

[Next -Hercules Setup and IPL]

CARD80 Assembly Listing

                                                                                                               PAGE    2

  LOC  OBJECT CODE    ADDR1 ADDR2  STMT   SOURCE STATEMENT                                       ASM 0201 17.10 08/19/11

                                      1 **********************************************************************  00010000
                                      2 * CARD80                                                                00020000
                                      3 *                                                                       00030000
                                      4 * PUNCH OUT A CARD DECK THAT WILL IPL AND THEN READ REMAINDING CARD     00040000
                                      5 * IN CARD READER AND LIST THEM TO A PRINTER                             00050000
                                      6 *                                                                       00060000
                                      7 **********************************************************************  00070000
000000                                8 CARD80   CSECT ,                                                        00080000
000000 90EC D00C      0000C           9          STM   R14,R12,12(R13)    SAVE CALLERS REGISTERS                00090000
000004 18CF                          10          LR    R12,R15            R12 IS PROGRAM BASE                   00100000
                            00000    11          USING CARD80,R12                                               00110000
                                     12 *                                                                       00120000
000006 4110 C128      00128          13          LA    R1,SAVEA           POINT TO NEW SAVE AREA                00130000
00000A 5010 D008      00008          14          ST    R1,8(,R13)         CHAIN                                 00140000
00000E 50D0 1004      00004          15          ST    R13,4(,R1)              ON                               00150000
000012 18D1                          16          LR    R13,R1                    SAVEAREA                       00160000
                                     17 *                                                                       00170000
                                     18 *                                                                       00180000
                                     19          OPEN  (PUNCH,OUTPUT)     OPEN OUTPUT FILE                      00190000
000014                               20+         CNOP  0,4                               ALIGN LIST TO FULLWORD 01740001
000014 4510 C01C      0001C          21+         BAL   1,*+8                             LOAD REG1 W/LIST ADDR. 01780000
000018 8F                            22+         DC    AL1(143)                          OPTION BYTE            01900000
000019 000170                        23+         DC    AL3(PUNCH)                        DCB ADDRESS            01920000
00001C 0A13                          24+         SVC   19                                ISSUE OPEN SVC         04000000
                                     25 **********************************************************************  00200000
                                     26 *  WRITE FIRST IPL CARD WITH 24 BYTES OF DATA (PSW,CCW,CCW)             00210000
                                     27 **********************************************************************  00220000
                                     28          PUT   PUNCH,CARD0        WRITE INITIAL IPL RECORD              00230000
00001E 4110 C170      00170          29+         LA    1,PUNCH                           LOAD PARAMETER REG 1   01900002
000022 4100 C1D0      001D0          30+         LA    0,CARD0                           LOAD PARAMETER REG 0   02500002
000026 58F0 1030      00030          31+         L     15,48(0,1)               LOAD PUT ROUTINE ADDR           00550000
00002A 05EF                          32+         BALR  14,15                    LINK TO PUT ROUTINE             00600000
                                     33 **********************************************************************  00240000
                                     34 *  WRITE SECOND IPL CARD WITH ADDITIONAL READ CCW'S                     00250000
                                     35 **********************************************************************  00260000
                                     36          PUT   PUNCH,CARD1        WRITE SECOND IPL RECORD               00270000
00002C 4110 C170      00170          37+         LA    1,PUNCH                           LOAD PARAMETER REG 1   01900002
000030 4100 C220      00220          38+         LA    0,CARD1                           LOAD PARAMETER REG 0   02500002
000034 58F0 1030      00030          39+         L     15,48(0,1)               LOAD PUT ROUTINE ADDR           00550000
000038 05EF                          40+         BALR  14,15                    LINK TO PUT ROUTINE             00600000
                                     41 **********************************************************************  00280000
                                     42 *  WRITE 3 CARDS CONTAINING EXECUTABLE CODE                             00290000
                                     43 **********************************************************************  00300000
                                     44          PUT   PUNCH,CARD2        WRITE DATA                            00310000
                                                                                                               PAGE    3

  LOC  OBJECT CODE    ADDR1 ADDR2  STMT   SOURCE STATEMENT                                       ASM 0201 17.10 08/19/11

00003A 4110 C170      00170          45+         LA    1,PUNCH                           LOAD PARAMETER REG 1   01900002
00003E 4100 C270      00270          46+         LA    0,CARD2                           LOAD PARAMETER REG 0   02500002
000042 58F0 1030      00030          47+         L     15,48(0,1)               LOAD PUT ROUTINE ADDR           00550000
000046 05EF                          48+         BALR  14,15                    LINK TO PUT ROUTINE             00600000
                                     49          PUT   PUNCH,CARD2+80     WRITE DATA                            00320000
000048 4110 C170      00170          50+         LA    1,PUNCH                           LOAD PARAMETER REG 1   01900002
00004C 4100 C2C0      002C0          51+         LA    0,CARD2+80                        LOAD PARAMETER REG 0   02500002
000050 58F0 1030      00030          52+         L     15,48(0,1)               LOAD PUT ROUTINE ADDR           00550000
000054 05EF                          53+         BALR  14,15                    LINK TO PUT ROUTINE             00600000
                                     54          PUT   PUNCH,CARD2+160    WRITE DATA                            00330000
000056 4110 C170      00170          55+         LA    1,PUNCH                           LOAD PARAMETER REG 1   01900002
00005A 4100 C310      00310          56+         LA    0,CARD2+160                       LOAD PARAMETER REG 0   02500002
00005E 58F0 1030      00030          57+         L     15,48(0,1)               LOAD PUT ROUTINE ADDR           00550000
000062 05EF                          58+         BALR  14,15                    LINK TO PUT ROUTINE             00600000
                                     59 **********************************************************************  00340000
                                     60 *                                                                       00350000
                                     61 *        NOW WRITE SOME TEST DATA CARDS BECHIND IPL PROGRAM             00360000
                                     62 *                                                                       00370000
                                     63 **********************************************************************  00380000
000064 4130 000A      0000A          64          LA    R3,10              TIMES TO REPEAT LOOP                  00390000
000068 4140 C0B8      000B8          65          LA    R4,=C'01020304050607080910'                              00400000
00006C 4150 C0CC      000CC          66          LA    R5,=C'*+@#$%-() '                                        00410000
000070                               67 LOOP     DS    0H                                                       00420000
000070 D200 C0D6 5000 000D6 00000    68          MVC   BUF(1),0(R5)       CHAR TO REPEAT                        00430000
000076 D24E C0D7 C0D6 000D7 000D6    69          MVC   BUF+1(79),BUF      FILL BUFFER                           00440000
00007C D201 C0D6 4000 000D6 00000    70          MVC   BUF(2),0(R4)       CARD NUMBER                           00450000
000082 9240 C0D8      000D8          71          MVI   BUF+2,C' '         AND A SPACE                           00460000
                                     72          PUT   PUNCH,BUF                                                00470000
000086 4110 C170      00170          73+         LA    1,PUNCH                           LOAD PARAMETER REG 1   01900002
00008A 4100 C0D6      000D6          74+         LA    0,BUF                             LOAD PARAMETER REG 0   02500002
00008E 58F0 1030      00030          75+         L     15,48(0,1)               LOAD PUT ROUTINE ADDR           00550000
000092 05EF                          76+         BALR  14,15                    LINK TO PUT ROUTINE             00600000
000094 4140 4002      00002          77          LA    R4,2(,R4)          INCREMENT                             00480000
000098 4150 5001      00001          78          LA    R5,1(,R5)                                                00490000
00009C 4630 C070      00070          79          BCT   R3,LOOP            LOOP BACK                             00500000
                                     80 *                                                                       00510000
                                     81          CLOSE (PUNCH)                                                  00520000
0000A0                               82+         CNOP  0,4                               ALIGN LIST TO FULLWORD 02420002
0000A0 4510 C0A8      000A8          83+         BAL   1,*+8                             LOAD REG1 W/LIST ADDR  02460002
0000A4 80                            84+         DC    AL1(128)                          OPTION BYTE            02580000
0000A5 000170                        85+         DC    AL3(PUNCH)                        DCB ADDRESS            02600000
0000A8 0A14                          86+         SVC   20                                ISSUE CLOSE SVC        01640000
                                     87 *                                                                       00530000
                                     88 *                                                                       00540000
                                                                                                               PAGE    4

  LOC  OBJECT CODE    ADDR1 ADDR2  STMT   SOURCE STATEMENT                                       ASM 0201 17.10 08/19/11

0000AA 58D0 D004      00004          89          L     R13,4(,R13)        PREV SAVE AREA                        00550000
0000AE 98EC D00C      0000C          90          LM    R14,R12,12(R13)    RESTORE CALLERS REGISTERS             00560000
0000B2 1FFF                          91          SLR   R15,R15            RC=0                                  00570000
0000B4 07FE                          92          BR    R14                                                      00580000
                                     93 *                                                                       00590000
0000B8                               94          LTORG ,                                                        00600000
0000B8 F0F1F0F2F0F3F0F4              95                =C'01020304050607080910'
0000CC 5C4E7C7B5B6C604D              96                =C'*+@#$%-() '
                                     97 *                                                                       00610000
0000D6                               98 BUF      DS    CL80               CARD BUFFER                           00620000
                                     99 *                                                                       00630000
000128                              100 SAVEA    DS    18F                SAVEA AREA                            00640000
                                    101 *                                                                       00650000
                                    102 *                                                                       00660000
                                    103          PRINT NOGEN                                                    00670000
                                    104 PUNCH    DCB   DSORG=PS,MACRF=PM,BLKSIZE=80,LRECL=80,RECFM=F,          +00680000
                                                       DDNAME=PUNCH                                             00690000
                                    158          PRINT GEN                                                      00700000
                                    159 *                                                                       00710000
                                    160 *                                                                       00720000
                                    161          DROP  R12                                                      00730000
                                    162 **********************************************************************  00740000
                                    163 **********************************************************************  00750000
                                    164 ** FRIST CARD OF OUR IPL DECK                                           00760000
                                    165 **    IT CONTAINS 24 BYTES - PSW AND TWO CCW'S                          00770000
                                    166 **********************************************************************  00780000
                                    167 **********************************************************************  00790000
                                    168 *                                                                       00800000
0001D0                              169          DS    0D                                                       00810000
0001D0 0000000000000000             170 CARD0    DC    80XL1'00'          INITIAL IPL CARD                      00820000
000220                      001D0   171          ORG   CARD0                                                    00830000
                                    172 *                                                                       00840000
                                    173 **********************************************************************  00850000
                                    174 *        PSW                                                            00860000
                                    175 **********************************************************************  00870000
                                    176 *                                                                       00880000
0001D0 00                           177 IPLPSW   DC    X'00'              I/O & EXT INTERRUPTS DISABLED         00890000
0001D1 00                           178          DC    X'00'              KEY=0; BC; EXT INT DISABLED; SUP      00900000
0001D2 0000                         179          DC    X'0000'                                                  00910000
0001D4 00                           180          DC    X'00'              PROG INT DISABLED                     00920000
0001D5 000400                       181          DC    AL3(1024)          INITIAL EXECUTION ADDRESS             00930000
                                    182 *                                                                       00940000
                                    183 **********************************************************************  00950000
                                    184 *        CCW                                                            00960000
                                                                                                               PAGE    5

  LOC  OBJECT CODE    ADDR1 ADDR2  STMT   SOURCE STATEMENT                                       ASM 0201 17.10 08/19/11

                                    185 **********************************************************************  00970000
                                    186 *                                                                       00980000
0001D8 02                           187 CCW1     DC    X'02'              READ                                  00990000
0001D9 000200                       188          DC    AL3(512)           ADDRESS FOR DATA                      01000000
0001DC 60                           189          DC    X'60'              CC + SLI                              01010000
0001DD 00                           190          DC    X'00'                                                    01020000
0001DE 0050                         191          DC    AL2(80)            LENGTH                                01030000
                                    192 *                                                                       01040000
                                    193 **********************************************************************  01050000
                                    194 *        CCW                                                            01060000
                                    195 **********************************************************************  01070000
                                    196 *                                                                       01080000
0001E0 08                           197 CCW2     DC    X'08'              TIC                                   01090000
0001E1 000200                       198          DC    AL3(512)           NEXT CCW ADDRESS                      01100000
0001E4 00                           199          DC    X'00'              CC + SLI                              01110000
0001E5 00                           200          DC    X'00'                                                    01120000
0001E6 0000                         201          DC    AL2(0)             LENGTH                                01130000
                                    202 *                                                                       01140000
                                    203 *                                                                       01150000
0001E8                      00220   204          ORG   ,                  RESTORE LOC TO HIGHEST                01160000
                                    205 *                                                                       01170000
                                    206 **********************************************************************  01180000
                                    207 **********************************************************************  01190000
                                    208 ** SECOND CARD OF OUR IPL DECK                                          01200000
                                    209 **    IT CONTAINS THREE CCW'S                                           01210000
                                    210 **    THESE CCW'S READ THE THREE CARDS CONTAINING EXECUTABLE CODE       01220000
                                    211 **********************************************************************  01230000
                                    212 **********************************************************************  01240000
000220                              213          DS    0D                                                       01250000
000220 0000000000000000             214 CARD1    DC    80XL1'00'          SECOND IPL CARD                       01260000
000270                      00220   215          ORG   CARD1                                                    01270000
                                    216 *                                                                       01280000
                                    217 **********************************************************************  01290000
                                    218 *        CCW                                                            01300000
                                    219 **********************************************************************  01310000
                                    220 *                                                                       01320000
000220 02                           221 CCW3     DC    X'02'              READ                                  01330000
000221 000400                       222          DC    AL3(1024)          ADDRESS FOR DATA                      01340000
000224 60                           223          DC    X'60'              CC + SLI                              01350000
000225 00                           224          DC    X'00'                                                    01360000
000226 0050                         225          DC    AL2(80)            LENGTH                                01370000
                                    226 *                                                                       01380000
                                    227 **********************************************************************  01390000
                                    228 *        CCW                                                            01400000
                                                                                                               PAGE    6

  LOC  OBJECT CODE    ADDR1 ADDR2  STMT   SOURCE STATEMENT                                       ASM 0201 17.10 08/19/11

                                    229 **********************************************************************  01410000
                                    230 *                                                                       01420000
000228 02                           231 CCW4     DC    X'02'              READ                                  01430000
000229 000450                       232          DC    AL3(1024+80)       ADDRESS FOR DATA                      01440000
00022C 60                           233          DC    X'60'              CC + SLI                              01450000
00022D 00                           234          DC    X'00'                                                    01460000
00022E 0050                         235          DC    AL2(80)            LENGTH                                01470000
                                    236 *                                                                       01480000
                                    237 **********************************************************************  01490000
                                    238 *        CCW                                                            01500000
                                    239 **********************************************************************  01510000
                                    240 *                                                                       01520000
000230 02                           241 CCW5     DC    X'02'              READ                                  01530000
000231 0004A0                       242          DC    AL3(1024+160)      ADDRESS FOR DATA                      01540000
000234 20                           243          DC    X'20'              SLI                                   01550000
000235 00                           244          DC    X'00'                                                    01560000
000236 0050                         245          DC    AL2(80)            LENGTH                                01570000
                                    246 *                                                                       01580000
                                    247 *                                                                       01590000
                                    248 *                                                                       01600000
                                    249 *                                                                       01610000
000238                      00270   250          ORG   ,                  RESTORE LOC TO HIGHEST                01620000
                                    251 *                                                                       01630000
                                    252 **********************************************************************  01640000
                                    253 **********************************************************************  01650000
                                    254 ** THIRD, FOURTH AND FIFTH CARDS OF IPL DECK                            01660000
                                    255 **    IT CONTAINS THE EXECUTABLE PROGRAM                                01670000
                                    256 **********************************************************************  01680000
                                    257 **********************************************************************  01690000
000270                              258          DS    0D                                                       01700000
000270                              259 CARD2    DS    0X                 SECOND IPL CARD                       01710000
                                    260 **********************************************************************  01720000
                                    261 *        EXECUTABLE PROGRAM BEINGS HERE                                 01730000
                                    262 **********************************************************************  01740000
000270                              263 BEGIN    DS    0H                                                       01750000
000270 05A0                         264          BALR  R10,0              ESTABLISH BASE REG                    01760000
                            00272   265          USING *,R10                                                    01770000
                                    266 *                                                                       01780000
                                    267 **********************************************************************  01790000
                                    268 *        GET DEVICE PHYSICAL ADDRESSES R3=RDR R4=PRT                    01800000
                                    269 **********************************************************************  01810000
                                    270 *                                                                       01820000
000272 1F33                         271          SLR   R3,R3              CLEAR R3                              01830000
000274 BF33 0002      00002         272          ICM   R3,B'0011',2       GET IPL DEVICE (CARD RDR)             01840000
                                                                                                               PAGE    7

  LOC  OBJECT CODE    ADDR1 ADDR2  STMT   SOURCE STATEMENT                                       ASM 0201 17.10 08/19/11

000278 4140 000E      0000E         273          LA    R4,X'E'            ASSUME PRINTER AT 00E                 01850000
                                    274 *                                                                       01860000
                                    275 **********************************************************************  01870000
                                    276 *        PUT THE I/O BUFFER ADDRESS INTO THE CCW'S                      01880000
                                    277 **********************************************************************  01890000
                                    278 *                                                                       01900000
00027C 4110 A0C0      00332         279          LA    R1,RDBUF           READ BUFFER                           01910000
000280 BE17 A067      002D9         280          STCM  R1,B'0111',RDCCW+1 ADDRESS TO READ CCW                   01920000
000284 BE17 A06F      002E1         281          STCM  R1,B'0111',PRCCW+1 ADDRESS TO PRINT CCW                  01930000
                                    282 *                                                                       01940000
                                    283 **********************************************************************  01950000
                                    284 *        PROGRAM MAIN LOOP                                              01960000
                                    285 **********************************************************************  01970000
                                    286 *                                                                       01980000
000288                              287 RDLP     DS    0H                                                       01990000
000288 4110 A066      002D8         288          LA    R1,RDCCW           GET ADDR OF READ CCW                  02000000
00028C 5010 0048      00048         289          ST    R1,72              PUT INTO CAW                          02010000
                                    290 *                                                                       02020000
000290 9C00 3000      00000         291          SIO   0(R3)              ISSUE READ                            02030000
000294 4770 A080      002F2         292          BNZ   ERR1               BRANCH IF ERROR                       02040000
                                    293 *                                                                       02050000
                                    294 **********************************************************************  02060000
                                    295 *        WAIT FOR READ I/O TO COMPLETE                                  02070000
                                    296 **********************************************************************  02080000
                                    297 *                                                                       02090000
000298                              298 RDTIO    DS    0H                                                       02100000
000298 9D00 3000      00000         299          TIO   0(R3)              CHECK FOR I/O COMPLETION              02110000
00029C 4780 A036      002A8         300          BZ    PRT                GO PRINT IF GOOD                      02120000
0002A0 4710 A084      002F6         301          BC    1,ERR2             BRAHCH IF ERR                         02130000
0002A4 47F0 A026      00298         302          B     RDTIO              WAIT AGAIN                            02140000
                                    303 *                                                                       02150000
                                    304 **********************************************************************  02160000
                                    305 *        CHECK FOR SUCCESSFUL COMPLETION OF I/O                         02170000
                                    306 *                                                                       02180000
                                    307 *        EXPECT ONLY CHANNEL END + DEVICE END                           02190000
                                    308 *                                                                       02200000
                                    309 *        ANYTHING ELSE WE QUIT                                          02210000
                                    310 *                                                                       02220000
                                    311 **********************************************************************  02230000
                                    312 *                                                                       02240000
0002A8                              313 PRT      DS    0H                                                       02250000
0002A8 D501 A0BE 0044 00330 00044   314          CLC   CEDE,68            CE+DE                                 02260000
0002AE 4770 A076      002E8         315          BNE   ERR0               NO - QUIT                             02270000
                                    316 *                                                                       02280000
                                                                                                               PAGE    8

  LOC  OBJECT CODE    ADDR1 ADDR2  STMT   SOURCE STATEMENT                                       ASM 0201 17.10 08/19/11

                                    317 **********************************************************************  02290000
                                    318 *        SET UP CAW FOR PRINT                                           02300000
                                    319 **********************************************************************  02310000
                                    320 *                                                                       02320000
0002B2 4110 A06E      002E0         321          LA    R1,PRCCW           POINT TO PRINT CCW                    02330000
0002B6 5010 0048      00048         322          ST    R1,72              SAVE ADDRESS IN CAW                   02340000
                                    323 *                                                                       02350000
0002BA 9C00 4000      00000         324          SIO   0(R4)              PRINT LINE                            02360000
0002BE 4770 A088      002FA         325          BNZ   ERR3               BRANCH IF ERROR                       02370000
                                    326 *                                                                       02380000
                                    327 **********************************************************************  02390000
                                    328 *        WAIT FOR I/O TO COMPLETE                                       02400000
                                    329 **********************************************************************  02410000
                                    330 *                                                                       02420000
0002C2                              331 PRTTIO   DS    0H                                                       02430000
0002C2 9D00 4000      00000         332          TIO   0(R4)              CHECK FOR I/O COMPLETE                02440000
0002C6 4780 A016      00288         333          BZ    RDLP               DONE - GO READ NEXT CARD              02450000
0002CA 4710 A08C      002FE         334          BC    1,ERR4             BRANCH IF ERROR                       02460000
                                    335 *                                                                       02470000
                                    336 **********************************************************************  02480000
                                    337 *        LOOP BACK AND READ NEXT CARD                                   02490000
                                    338 **********************************************************************  02500000
                                    339 *                                                                       02510000
0002CE 47F0 A050      002C2         340          B     PRTTIO             WAIT AGAIN                            02520000
                                    341 *                                                                       02530000
                                    342 *                                                                       02540000
                                    343 **********************************************************************  02550000
                                    344 *        CCW'S TO READ AND PRINT                                        02560000
                                    345 **********************************************************************  02570000
                                    346 *                                                                       02580000
                                    347 *                                                                       02590000
0002D8                              348          DS    0D                                                       02600000
0002D8 0200000000000050             349 RDCCW    DC    X'02',AL3(0),X'0000',AL2(80)                             02610000
0002E0 0900000000000050             350 PRCCW    DC    X'09',AL3(0),X'0000',AL2(80)                             02620000
                                    351 *                                                                       02630000
                                    352 *                                                                       02640000
                                    353 **********************************************************************  02650000
                                    354 *        ERROR ROUTINES                                                 02660000
                                    355 *           LOAD PSW WITH WAIT BIT SET TO ONE                           02670000
                                    356 **********************************************************************  02680000
                                    357 *                                                                       02690000
                                    358 *                                                                       02700000
0002E8 D201 A09C 0044 0030E 00044   359 ERR0     MVC   PSWERR0+6(2),68                                          02710000
0002EE 8200 A096      00308         360          LPSW  PSWERR0                                                  02720000
                                                                                                               PAGE    9

  LOC  OBJECT CODE    ADDR1 ADDR2  STMT   SOURCE STATEMENT                                       ASM 0201 17.10 08/19/11

0002F2 8200 A09E      00310         361 ERR1     LPSW  PSWERR1                                                  02730000
0002F6 8200 A0A6      00318         362 ERR2     LPSW  PSWERR2                                                  02740000
0002FA 8200 A0AE      00320         363 ERR3     LPSW  PSWERR3                                                  02750000
0002FE 8200 A0B6      00328         364 ERR4     LPSW  PSWERR4                                                  02760000
                                    365 *                                                                       02770000
                                    366 *                                                                       02780000
                                    367 **********************************************************************  02790000
                                    368 *        WAIT PSW'S                                                     02800000
                                    369 **********************************************************************  02810000
                                    370 *                                                                       02820000
                                    371 *                                                                       02830000
000308                              372          DS    0D                                                       02840000
000308 0002000000000000             373 PSWERR0  DC    X'00',X'02',X'0000',X'00',X'000000'                      02850000
000310 0002000000EE0001             374 PSWERR1  DC    X'00',X'02',X'0000',X'00',X'EE0001'                      02860000
000318 0002000000EE0002             375 PSWERR2  DC    X'00',X'02',X'0000',X'00',X'EE0002'                      02870000
000320 0002000000EE0003             376 PSWERR3  DC    X'00',X'02',X'0000',X'00',X'EE0003'                      02880000
000328 0002000000EE0004             377 PSWERR4  DC    X'00',X'02',X'0000',X'00',X'EE0004'                      02890000
                                    378 *                                                                       02900000
                                    379 *                                                                       02910000
                                    380 **********************************************************************  02920000
                                    381 *        CHANNEL END + DEVICE END                                       02930000
                                    382 **********************************************************************  02940000
                                    383 *                                                                       02950000
                                    384 *                                                                       02960000
000330 0C00                         385 CEDE     DC    X'0C00'            CHANNEL END + DEVICE END              02970000
                                    386 *                                                                       02980000
                                    387 *                                                                       02990000
                                    388 **********************************************************************  03000000
                                    389 *        I/O BUFFER AREA                                                03010000
                                    390 **********************************************************************  03020000
                                    391 *                                                                       03030000
                                    392 *                                                                       03040000
                            000C2   393 CARD2LEN EQU   *-CARD2                                                  03050000
000332                              394 RDBUF    DS    0C            I/O BUFFER                                 03060000
000332                      00332   395          ORG   ,                                                        03070000
                                    396 *                                                                       03080000
                                    397 *                                                                       03090000
                                    398 **********************************************************************  03100000
                                    399 *        BUFFER AREA TO MAKE SURE WE HAVE AT LEAST 80 BYTES FOR THE     03110000
                                    400 *        LAST CARD WE WRINTE                                            03120000
                                    401 **********************************************************************  03130000
                                    402 *                                                                       03140000
                                    403 *                                                                       03150000
000332                              404          DS    CL80          *** EXTRA BUFFER AREA ***                  03160000
                                                                                                               PAGE   10

  LOC  OBJECT CODE    ADDR1 ADDR2  STMT   SOURCE STATEMENT                                       ASM 0201 17.10 08/19/11

                                    405 *                                                                       03170000
                                    406 *                                                                       03180000
                                    407 **********************************************************************  03190000
                                    408 *        REGISTER EQUATES                                               03200000
                                    409 **********************************************************************  03210000
                                    410 *                                                                       03220000
                                    411 *                                                                       03230000
                            00000   412 R0       EQU   0                                                        03240000
                            00001   413 R1       EQU   1                                                        03250000
                            00002   414 R2       EQU   2                                                        03260000
                            00003   415 R3       EQU   3                                                        03270000
                            00004   416 R4       EQU   4                                                        03280000
                            00005   417 R5       EQU   5                                                        03290000
                            00006   418 R6       EQU   6                                                        03300000
                            00007   419 R7       EQU   7                                                        03310000
                            00008   420 R8       EQU   8                                                        03320000
                            00009   421 R9       EQU   9                                                        03330000
                            0000A   422 R10      EQU   10                                                       03340000
                            0000B   423 R11      EQU   11                                                       03350000
                            0000C   424 R12      EQU   12                                                       03360000
                            0000D   425 R13      EQU   13                                                       03370000
                            0000E   426 R14      EQU   14                                                       03380000
                            0000F   427 R15      EQU   15                                                       03390000
                                    428 *                                                                       03400000
                                    429 *                                                                       03410000
                                    430          END   ,                                                        03420000

[Next – Assemble and Execute]

Creating The IPL Deck

We can use the Assembler to do the heavy lifting for us.  It is assumed the reader knows the basics of writing, assembling and executing assembler programs.

We are really writing two programs here.  One is the 80-80 list program and the other is a program to create the IPL deck.  When we assemble and run our program only half of the code will be executed – the other half will be punched into a card deck.

We can make use of the ORG Assembler directive to make our work easier.  ORG is not an executable instruction.  It is an instruction to the assembler telling it how to organize storage.   Our first card in the IPL deck is the 24 bytes containing the PSW and two CCWs.  We can get the assembler to help us create it by using:

CARD0    DS    80XL1'00'
         ORG   CARD0
IPLPSW   DC    X'00',X'00',X'0000',X'00',AL3(1024)
CCW1     DC    X'02',AL3(512),X'60',X'00',AL2(80)
CCW2     DC    X'08',AL3(512),X'00',X'00',AL2(0)
         ORG   ,

First we create an area of 80 bytes of hex zeros.  We can then use ORG to reset the address back to the beginning of the card area.  This will cause the 80 bytes of zeros to be overlayed with the data for the PSW and CCWs.  After we define the PSW and CCWs we use ORG with no operand to reset the address to the highest address previously used before we reset it with the first ORG.  This keeps us from having to count bytes and manually pad out the unused portion of our 80 bytes card area.

We can create our second card containing the additional read CCWs the same way.

         DS    0D
CARD1    DC    80XL1'00'            Second IPL Card
         ORG   CARD1
*
CCW3     DC    X'02',AL3(1024),X'60',x'00',AL2(80)
CCW4     DC    X'02',AL3(1024+80),X'60',X'00',AL2(80)
CCW5     DC    X'02',AL3(1024+160),X'20',X'00',AL2(80)
*
         ORG   ,

The third, fourth and fifth cards of our IPL deck come from the code of our executable program.

Here is the program to punch out our IPL deck:

CARD80   CSECT ,
         STM   R14,R12,12(R13)      Save callers registers
         LR    R12,R15              Use R12 as our program base
         USING CARD80,R12
*
         LA    R1,SAVEA             Point to new Save Area
         ST    R1,8(,R13)           Chain
         ST    R13,4(,R1)                On
         LR    R13,R1                      Save Area
*
         OPEN  (PUNCH,OUTPUT)       Open Output File
*
         PUT   PUNCH,CARD0          Write First Card
*
         PUT   PUNCH,CARD1          Write Second Card
*
* Write Three Cards of Executable Code
*
         PUT   PUNCH,CARD2
         PUT   PUNCH,CARD2+80
         PUT   PUNCH,CARD2+160
*

The way I know to punch three cards for the executable code is simple.  I assembled the program and then looked at the listing to determine the size in bytes of the IPL program.  It was then a simple matter of dividing by 80 and adding one for any nonzero remainder to get the number of cards required.

At this point, we have written five cards that contain our IPL stand alone program, and if we were working with real cards, we would be done, because we would just put some data cards behind our IPL deck after it was punched out and then input the combined deck via the card reader. However, since we are working with virtual cards rather than real ones that we already have on hand, we must also create the data cards we will use for our testing.

To do this, we will generate ten additional data cards. Our first step will be to fill an entire card image with 80 instances of a certain character, and then we will overlay the first three card columns of this card image with a number from 01 to 10, followed by a space. Thus, our first data card will look like the following.

 

01 *****************...

Here is the code I use to create my data cards.

         LA    R3,10          Number of times to repeat
         LA    R4,=C'01020304050607080910'
         LA    R5,=C'*+@#$%-() '
LOOP     DS    0H
         MVC   BUF(1),0(R5)   Move in char to repeat
         MVC   BUF+1(79),BUF  Fill buffer with repeated char
         MVC   BUF(2),0(R4)   Move in card number
         MVI   BUF+2,C' '     Followed by a space
*
         PUT   PUNCH,BUF      Write out card record
*
         LA    R4,2(,R4)      Point to next card number
         LA    R5,1(,R5)      Point to next repeating character
         BCT   R3,LOOP        Loop back for next card image
*

Now we are almost done creating the card deck and we can close the DCB, restore the caller’s registers and exit our program.

         CLOSE (PUNCH)         Close output DCB
*
         L     R13,4(,R13)     Point to caller's save area
         LM    R14,R12,12(R13) Restore caller's registers
         SLR   R15,R15         Set RC=0
         BR    R14             Return to caller
*

All we are missing is some data areas which we now add, as follows.

         LTORG ,               Generate literals here
*
BUF      DS    CL80            Output Buffer
*
SAVEA    DS    18F             Register Save Area
*
PUNCH    DCB   DSORG=PS,MACRF=PM,BLKSIZE=80,LRECL=80,
               RECFM=F,DDNAME=PUNCH
*
*
         DROP  R12              No longer used as a base register

[Next – Card80 Assembly Listing ]

80-80 List Exectable Code

Now we need to write our executable program.  For now we will focus on our program and not worry about how to get it punched into 80-byte cards.

First we need to establish a base register.  This code is written to be relocatable so it should run from anywhere we place it in memory.  We can move it to somewhere else other than location 1024 by modifying the PSW and the three CCWs used to read in the program.

BEGIN    DS    0D
         BALR  R10,0                * Establish a Base Address
         USING *,R10                * Tell the assembler
*

Next we need to get the device address for the card reader  used for the IPL process.  This is where we will expect to find our data cards.  When the CPU completes the IPL process and loads our initial PSW but before execution begins, the address of the IPL device is saved.  Since we are loading a BC PSW the IPL device address is saved in locations 2 and 3.

         SLR   R3,R3                * Clear Register 3
         ICM   R3,B'0011',2         * Load IPL Device Address
         LA    R4,X'E'              * Assume Printer at 00E
*

We will assume the printer is at device address X’00E’ which is usually a standard place to define a printer.  The standard location for the card reader is X’00C’ and that for the card punch is X’00D’.

Now we can handle some housekeeping to make our program relocatable.  If we were running with the help of an operating system we would probably have a relocating loader.  This means we could use an address constant (ADCON) in our CCW to point to the buffer.  When the loader read our program into memory the value in the ADCON would be relocated or updated to reflect our actual location in memory.

Since we are Bare Metal programming we don’t have an operating system or relocating loader.  In fact our loader is just some CCWs that are executed by the channel at IPL.  We will use a LA and STCM to get the actual address of the buffer at run time and store it into our CCWs.

         LA    R1,RDBUF          * Get the address of the I/O Buf
         STCM  R1,B'0111',RDCCW+1  Place address into Read CCW
         STCM  R1,B'0111',PRCCW+1  Place address into Print CCW

Now we are ready to enter the main loop for our 80-80 List program.  The first thing we want to do is attempt to read a card from the same card reader that was used as the IPL device.  Before issuing the Start I/O we need to place the address of our read CCW into the CAW.

         LA    R1,RDCCW          * Get address of Read CCW
         ST    R1,72             * Place into CAW (location 72)

Our Read CCW should look very familiar since it is almost exactly like the CCWs used in our IPL process.  We will not set any flags in the CCW this time.  Since we are not command chaining our CCW program will consist of a single CCW.  We are using command code X’02’ to read, the address is filled in at run time, and we are expecting 80 bytes of data.  This time we will leave the SLI bit off and if the card reader attempts to transfer more or less than 80 bytes an exceptional condition will occur.

RDCCW    DC    X'02',AL3(0),X'0000',AL2(80)

Now we can issue the Start I/O instruction to cause the channel to execute our channel program.  We have saved the address of the card reader in register three.  We then check the condition code to see if the channel is processing our request.  If not we load a Wait PSW and halt execution.

         SIO   0(R3)             * Issure Start I/O to Channel
         BNZ   ERR1              * If Chan not processing - error

Now we have to wait for the I/O to complete.  Since we have masked all I/O interrupts the CPU will not generate an interrupt when the I/O is complete.  Instead we will use the Test I/O instruction to check on the progress of the channel program.  If the I/O is complete we will branch out of our wait loop.  If the return code indicates the channel or device is not operational we will load a Wait PSW.  If the channel is still busy we will loop back and issue the Test I/O again.

RDTIO    DS    0H
         TIO   0(R3)             * Test for I/O Completion
         BZ    PRT               * Branch if I/O Complete
         BC    1,ERR2            * Branch if not operational
         B     RDTIO             * Loop back and wait for I/O

Now we need to check for successful completion of our channel program.  We know that it completed and the completion status was stored into the CSW as a result of our issuing a Test I/O against the device.  We will test the status bits and we only expect to find Channel End and Device End set.  If we find anything else some type of exceptional condition has occurred.  We use a CLC to compare the two bytes of status bits in the CSW (located at fixed location 68) to a constant with just the Channel End and Device End bits set X’0C00′

PRT      DS    0H
         CLC   CEDE,68           * Compare status bits
         BNE   ERR0              * Branch if not CE+DE
          .
          .
CEDE     DC    X'0C00'           * CE+DE

If we get anything else other than CE+DE we will save the status bits of the CCW into the address portion of a Wait PSW and then load that PSW to halt execution.  The reason we store the status bits in the CSW is so they become the wait code (the address portion of the wait PSW) and are visible on the operator console.

ERR0     MVC   PSWERR0+6(2),68   * Move CSW status bits to PSW
         LPSW  PSWERR0           * Load Wait PSW
          .
          .
PSWERR0  DC    X'00',X'02',X'0000',x'00',x'000000'

If there is no error then we issue a Start and I/O to the printer to print out the contents of the card we just read.  Just as with reading a card we store the address of the CCW into the CAW and then issue the Start I/O against the device.  We check the condition code from the Start I/O to verify the channel program is active.

         LA    R1,PRCCW          * Point to Print CCW
         ST    R1,72             * Store into CAW
         SIO   0(R4)             * Start I/O on Printer
         BNZ   ERR3              * Branch if Error

The CCW to print is similar to the CCW to read a card from the card reader.  Each device has its own set of command codes.  Printers have a number of command codes they respond to. Below is a quick summary of a few command codes for a printer.

01 - Write and Do Not Space
09 - Write and Space 1 Line
11 - Write and Space 2 Lines
19 - Write and Space 3 Lines
0B - Space 1 Line Immediate
13 - Space 2 Lines Immediate
1B - Space 3 Lines Immediate

We will use command code X’09’ to write a line and then space down to the next line.

PRCCW    DC    X'09',AL3(0),X'0000',AL2(80)

As with the read CCW, the data address is filled in at run time.  We will print 80 bytes of data and no flags are set.  Our channel program will consist of a single CCW.

Next we enter a Test I/O loop to wait for completion of the I/O.  For now when the I/O is complete we assume it was successful.  We could check the CSW status bits for any exceptional conditions but we don’t for now to make our program smaller and simpler.

PRTTIO   DS    0H
         TIO   0(R4)             * Wait for I/O to Complete
         BZ    RDLP              * Done - Go read next card
         BC    1,ERR4            * Branch if error
         B     PRTTIO            * Loop back and test again

[Next - Creating The IPL Deck]

Second IPL Card

Now we create our second IPL card containing additional CCWs for reading the cards containing the executable program.  The first CCW contained on this card is branched to by the channel because of the TIC (Transfer In Command) CCW in the previous card.

CARD1    DS    0D
*
CCW3     DC    X’02’         * Read
         DC    AL3(1024)     * Storage Address For Data
         DC    X’60’         * SLI + CC
         DC    X’00’
         DC    AL2(80)       * Length
*
*
CCW4     DC    X’02’         * Read
         DC    AL3(1024+80)  * Storage Address For Data
         DC    X’60’         * SLI + CC
         DC    X’00’
         DC    AL2(80)       * Length
*
*
CCW5     DC    X’02’         * Read
         DC    AL3(1024+160) * Storage Address For Data
         DC    X’20’         * SLI
         DC    X’00’
         DC    AL2(80)       * Length
*
*

There are three CCWs used to read the next three cards.  The first card will be read into location 1024.  The second card will be read into location 1104 (1024+80) and the third to location 1184 (1024+160).  The final CCW does not have the Command Chain bit set.  This will cause the channel program to end after this read is completed.

When the CCWs on this card have executed we will have read 240 bytes of data into memory beginning at location 1024.  This is the same address we specified as the beginning execution address in our load PSW on the first card.

When the final IPL CCW has completed successfully, the CPU will complete the IPL process by loading the initial PSW and begin execution at the address specified.  This will cause our small program to begin executing.

[Next – 80-80 List Executable Code]

80-80 List Stand Alone Program

Now that we have covered the basics we can begin writing our first Bare Metal, Stand Alone program.  This program will IPL from the card reader and execute without any help from an operating system.

For our first program we will attempt something very simple.  We will read cards from a card reader and print them to a printer.  We will call it 80-80 List because it will read eighty bytes from the card reader and print eighty bytes to a printer.

Our IPL deck will consist of five cards.  The first card will contain the 24-byte IPL record expected by the IPL process.  It will read in a second card containing additional CCWs used to read additional cards containing executable code.

For this simple program we will require three cards to contain our executable code so our IPL deck will be a total of five cards.

Immediately following our 5-card IPL deck are the data cards for our program.  The program will continue reading and printing cards until an exceptional condition is detected on the card reader – usually because it is out of cards to read.

If an error condition is detected or when an exceptional condition is encountered on a read operation, a PSW with the wait bit turned on will be loaded with a LPSW command.  This will cause the CPU to stop execution and go into wait mode.

Download the source code: card80

[Next – First IPL Card]

First IPL Card

Now that we have been through an overview of the IPL process and the basic concepts of the PSW and I/O we can begin to construct a deck of cards to IPL from.   We know that if we set the IPL device address to that of a card reader and press the IPL key the CPU will read a single card and transfer the first 24 bytes of data (card columns 1-24) and ignore the rest of the card.

The contents of our first card should be a PSW followed by two CCWs.

IPLCARD0 DS    0D
*
PSW      DC    X’00’       * I/O & External Interrupts Disabled
         DC    X’00’       * Key=0; BC; Ext Int Disabled; Sup State
         DC    X’0000’
         DC    X’00’       * Prog Int Disabled
         DC    AL3(1024)   * Address to begin Execution
*
*
CCW1     DC    X’02’       * Read
         DC    AL3(512)    * Storage Address For Data
         DC    X’60’       * SLI + CC
         DC    X’00’
         DC    AL2(80)     * Length
*
*
CCW2     DC    X’08’       * Transfer In Channel (TIC)
         DC    AL3(512)    * Address of next CCW
         DC    X’00’
         DC    X’00’
         DC    AL2(0)      * Length Not Used For TIC
*
*

 

This makes up the contents of our first IPL record.  The first eight bytes become our initial PSW when the IPL CCW chain is completed.  The first byte contains the interrupt mask flags for channels 0 through 5, the I/O mask bit (for channels 6 and higher) and the External Interrupt mask.  We set all of these to zero which inhibits these conditions from generating an interrupt.

The next byte contains the protection key in the first four bits.  We will initially set our key to zero which will allow us to access any valid memory location.

The next bit is set to zero to indicate a BC mode PSW.  The Machine Check Interrupt mask is set to zero to inhibit interruptions.  The Wait bit is set to zero so the CPU will immediately begin executing instructions.  The Problem State bit is set to zero placing us in Supervisor State therefore allowing us to execute privileged instructions.

The next two bytes are set to all zeros.  These bytes contain the interruption code and are only meaningful in an Old PSW to indicate the source of the interruption.  When the IPL process is completed the address of the IPL device will be stored here.

The next byte contains the Instruction Length Code (ILC), Condition Code and Program Mask.  We set all of these to zero and disallow any of the related program checks from generating interrupts.

The next three bytes contain the memory address of the first instruction to be executed.  It is our responsibility to load a valid instruction sequence into memory starting at this address.

Following the PSW are two CCWs.  The First CCW is a read command (command code = x’02’).  This will cause the next card in our IPL Deck to be read.  We specify a storage location to receive the contents of the card.  The next byte specifies the flags.  We set the Command Chain flag so a new CCW will be fetched upon completion of the read command.  The Suppress Incorrect Length  (SLI) bit is also set to avoid any problems with reading a short or long block of data.  Since we are reading from a card device the block size is set at 80 so we really shouldn’t need to set this flag.  In general it is a good idea to suppress any exceptional conditions possible since at this time there is no option for error recovery.

The next CCW is a Transfer In Channel (TIC) command.  A TIC is a branch command in a channel program.  The TIC will cause a new CCW to be fetched from the address specified.  We will set the address to point to the contents of the card that was read by the previous CCW.

At this point the IPL process has read two cards into memory.  The first card contained two CCWs to read the second card and then load a new CCW.

Card two needs to contain additional CCWs to read additional cards into memory that contain executable code.

[Next – Second IPL Card]

IPL Process

With a basic understanding of the PSW and the I/O process we can now explore the IPL process.  The IPL is initiated by the operator.  The device address of the IPL device is selected by the operator.  When the IPL key is pressed the CPU initiates a read command to the specified IPL device.

The initial read is executed by the channel just as if a Start I/O command had been issued.  An “implied” CCW is generated for this read command.  The protect key value for the CAW is zero.  The implied CCW is a read command with a data address of zero and a length of 24.  The Command Chain and Suppress Incorrect Length bits are set.  The implied CCW address is zero so when the CCW command successfully completes a new CCW will be fetched from location 8 (because the Command Chain flag is set).

When the device signals Device End for the last CCW in the chain and there are no exception conditions a new PSW is loaded from locations 0-7.

When the PSW that is loaded is in BC mode, the I/O address of the IPL device is stored in locations 2 and 3.  When in EC mode the device address is stored in locations 186-187.

The information read into locations 8-15 and 16-23 by the IPL process should contain CCWs for reading additional information into memory.

[Next – 80-80 List Stand Alone Program]

I/O Machine Instructions

There are several machine instructions dedicated to performing I/O operations.  These include Start I/O (SIO), Start I/O Fast Release (SIOF), Test I/O (TIO), Clear I/O (CLRIO), Halt I/O (HIO), Halt Device (HDV), Store Channel ID (STIDC), and Test Channel (TCH).  All I/O instructions are privileged and can only be executed in supervisor state.

Each of these instructions has a single operand in the D2(B2) format where D2 is a displacement value and B2 is a register (0-15).  The operand does not refer to a storage address but instead bits 16-31 of the address value are used to identify a channel/device address for the instruction.

If a register of zero is specified then only the contents of the displacement value are used to specify the device address.

Examples

SIO     X’580’               * Start I/O on device 580

 

LA       1,X’580’

SIO     0(1)                 * Start I/O on device 580

 

LA       1,X’580′

SIO     1(1)                  * Start I/O on device 581

 

Start I/O (SIO)

An I/O operation (write, read, read-backward, control or sense) operation is initiated on the device with the specified channel and device address.  The Channel Address Word (CAW) at storage location 72 must be set prior to the SIO being issued.  The CAW contains the protection key for the channel (in bits 0-3) and the address of the first CCW (in bits 8-31).  A condition code is set to indicate the status of the SIO request.

0 – I/O operation initiated and channel is processing the channel program

1 – CSW stored

2 – Channel or subchannel busy

3 – Not operational

 

Test I/O (TIO)

Returns the status of the channel, subchannel and device by setting the condition code.

0 – Available

1 – CSW Stored

2 – Channel or subchannel busy

3 – Not operational

 

[Next – IPL Process]