1#
2#  Ipl block for fba devices
3#    Copyright (C) 1998 IBM Corporation
4#    Author(s): Martin Schwidefsky
5#
6#  startup for ipl at address 0
7#  start with restart
8
9# The first 24 byes are loaded by ipl to addresses 0-23 (a PSW and two CCWs).
10# The CCWs on 8-23 are used as a continuation of the implicit ipl channel
11# program. The fba ipl loader only uses the CCW on 8-15 to load the first 512
12# byte block to location 0-511 (the reading starts again at block 0, byte 0).
13# The second CCW is used to store the location of the load list.
14        .org   0
15        .long  0x00080000,0x80000000+_start    # The first 24 byte are loaded
16        .long  0x02000000,0x20000200           # by ipl to addresses 0-23.
17        .long  0x00000001,0x00000001           # (PSW, one CCW & loadlist info).
18
19        .globl _start
20_start:
21	basr  %r13,0
22.LPG0:
23	l     %r1,0xb8                         # load ipl subchannel number
24        lhi   %r2,0x200                        # location for the loadlist
25        lm    %r3,%r4,0x10                     # blocknr and length of loadlist
26        bras  %r14,.Lloader                    # load loadlist
27
28        lhi   %r11,0x400
29        lhi   %r12,0x200                       # load address of loadlist
30        l     %r3,0(%r12)                      # get first block number
31        l     %r4,4(%r12)                      # get first block count
32        la    %r12,8(%r12)
33        j     .Llistloop
34        .org  0x50
35.Llistloop:
36        lr    %r2,%r11                         # load address
37        lr    %r5,%r4                          # block count
38        mhi   %r5,512
39        la    %r11,0(%r5,%r11)                 # update load address
40        bras  %r14,.Lloader                    # load chunk of the image
41        l     %r3,0(%r12)                      # get next block number
42        icm   %r4,15,4(%r12)                   # get next block count
43        la    %r12,8(%r12)
44        jnz   .Llistloop
45
46#
47# everything loaded, go for it
48#
49        l     %r1,.Lstart-.LPG0(%r13)
50	br    %r1
51
52#
53# subroutine for loading a sequence of block from fba
54# %r2: load address (24 bit address)
55# %r3: number of first block (unsigned long)
56# %r4: number of blocks to load (unsigned short)
57#
58        .org  0xC0
59.Lloader:
60        la    %r5,.Llo-.LPG0(%r13)
61        sth   %r4,2(%r5)                       # initialize block count
62        st    %r3,4(%r5)                       # initialize block number
63        la    %r5,.Lccws-.LPG0(%r13)
64        mhi   %r4,512
65        sth   %r4,22(%r5)                      # initialize byte count
66	icm   %r2,8,16(%r5)
67        st    %r2,16(%r5)                      # initialize CCW data address
68
69        slr   %r2,%r2
70        la    %r3,.Lorb-.LPG0(%r13)            # r2 = address of orb into r2
71        la    %r4,.Ltinfo-.LPG0(%r13)          # r3 = address of tpi info block
72        la    %r5,.Lirb-.LPG0(%r13)            # r4 = address of irb
73
74        lctl  %c6,%c6,.Lc6-.LPG0(%r13)
75.Lldlp:
76        ssch  0(%r3)                           # read blocks
77.Ltpi:
78        tpi   0(%r4)                           # test pending interrupt
79        jz    .Ltpi
80        c     %r1,0(%r4)                       # compare subchannel number
81        jne   .Ltpi
82        tsch  0(%r5)
83        slr   %r0,%r0
84        tm    8(%r5),0x82                      # do we have a problem ?
85        jnz   .Ldwpsw
86        tm    8(%r5),0x04                      # got device end ?
87        jz    .Ltpi
88.Lexit:
89        br    %r14
90
91        .align 8
92.Ldwpsw:.long  0x000a0000,0x00000000
93.Lorb:	.long  0x00000000,0x0000ff00,.Lccws
94.Ltinfo:.long  0
95.Lirb:	.long  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
96.Lc6:   .long  0xff000000
97.Lloadp:.long  0,0
98.Lparm:	.long  0x10400
99.Lstart:.long  0x10000
100        .align 8
101.Lccws: .long  0x63000000+.Lde,0x60000010      # define extent
102        .long  0x43000000+.Llo,0x60000008      # locate
103# offset 1 in read CCW: data address (24 bit)
104# offset 6 in read CCW: number of bytes (16 bit)
105        .long  0x42000000,0x20000000           # read
106.Lde:   .long  0x40000200,0x00000000
107        .long  0x00000000,0x00001000
108# offset 2 in .Llo: block count (unsigned short)
109# offset 4 in .Llo: block number (unsigned long)
110.Llo:   .long  0x06000000,0x00000000
111
112        .org   0x200
113        .long  0x00000002,0x0000007f
114        .long  0x00000081,0x0000007f
115        .long  0x00000100,0x0000007f
116        .long  0x0000017f,0x0000007f
117        .long  0x000001fe,0x0000007f
118        .long  0x0000027d,0x0000007f
119        .long  0x000002fc,0x0000007f
120        .long  0x0000037b,0x0000007f
121        .long  0x000003fa,0x0000007f
122        .long  0x00000479,0x0000007f
123        .long  0x000004f8,0x0000007f
124        .long  0x00000577,0x0000007f
125        .long  0x000005f6,0x0000007f
126        .long  0x00000675,0x0000007f
127        .long  0x000006f4,0x0000007f
128        .long  0x00000773,0x0000003f
129        .long  0x00000000,0x00000000
130        .org   0x400
131
132