GNU Linux-libre 4.9.318-gnu1
[releases.git] / arch / s390 / kernel / reipl.S
1 /*
2  *    Copyright IBM Corp 2000, 2011
3  *    Author(s): Holger Smolinski <Holger.Smolinski@de.ibm.com>,
4  *               Denis Joseph Barrow,
5  */
6
7 #include <linux/linkage.h>
8 #include <asm/asm-offsets.h>
9 #include <asm/nospec-insn.h>
10 #include <asm/sigp.h>
11
12         GEN_BR_THUNK %r9
13
14 #
15 # Issue "store status" for the current CPU to its prefix page
16 # and call passed function afterwards
17 #
18 # r2 = Function to be called after store status
19 # r3 = Parameter for function
20 #
21 ENTRY(store_status)
22         /* Save register one and load save area base */
23         stg     %r1,__LC_SAVE_AREA_RESTART
24         /* General purpose registers */
25         lghi    %r1,__LC_GPREGS_SAVE_AREA
26         stmg    %r0,%r15,0(%r1)
27         mvc     8(8,%r1),__LC_SAVE_AREA_RESTART
28         /* Control registers */
29         lghi    %r1,__LC_CREGS_SAVE_AREA
30         stctg   %c0,%c15,0(%r1)
31         /* Access registers */
32         lghi    %r1,__LC_AREGS_SAVE_AREA
33         stam    %a0,%a15,0(%r1)
34         /* Floating point registers */
35         lghi    %r1,__LC_FPREGS_SAVE_AREA
36         std     %f0, 0x00(%r1)
37         std     %f1, 0x08(%r1)
38         std     %f2, 0x10(%r1)
39         std     %f3, 0x18(%r1)
40         std     %f4, 0x20(%r1)
41         std     %f5, 0x28(%r1)
42         std     %f6, 0x30(%r1)
43         std     %f7, 0x38(%r1)
44         std     %f8, 0x40(%r1)
45         std     %f9, 0x48(%r1)
46         std     %f10,0x50(%r1)
47         std     %f11,0x58(%r1)
48         std     %f12,0x60(%r1)
49         std     %f13,0x68(%r1)
50         std     %f14,0x70(%r1)
51         std     %f15,0x78(%r1)
52         /* Floating point control register */
53         lghi    %r1,__LC_FP_CREG_SAVE_AREA
54         stfpc   0(%r1)
55         /* CPU timer */
56         lghi    %r1,__LC_CPU_TIMER_SAVE_AREA
57         stpt    0(%r1)
58         /* Store prefix register */
59         lghi    %r1,__LC_PREFIX_SAVE_AREA
60         stpx    0(%r1)
61         /* Clock comparator - seven bytes */
62         lghi    %r1,__LC_CLOCK_COMP_SAVE_AREA
63         larl    %r4,.Lclkcmp
64         stckc   0(%r4)
65         mvc     1(7,%r1),1(%r4)
66         /* Program status word */
67         lghi    %r1,__LC_PSW_SAVE_AREA
68         epsw    %r4,%r5
69         st      %r4,0(%r1)
70         st      %r5,4(%r1)
71         stg     %r2,8(%r1)
72         lgr     %r9,%r2
73         lgr     %r2,%r3
74         BR_EX   %r9
75
76         .section .bss
77         .align  8
78 .Lclkcmp:       .quad   0x0000000000000000
79         .previous
80
81 #
82 # do_reipl_asm
83 # Parameter: r2 = schid of reipl device
84 #
85
86 ENTRY(do_reipl_asm)
87                 basr    %r13,0
88 .Lpg0:          lpswe   .Lnewpsw-.Lpg0(%r13)
89 .Lpg1:          lgr     %r3,%r2
90                 larl    %r2,.Lstatus
91                 brasl   %r14,store_status
92
93 .Lstatus:       lctlg   %c6,%c6,.Lall-.Lpg0(%r13)
94                 lgr     %r1,%r2
95                 mvc     __LC_PGM_NEW_PSW(16),.Lpcnew-.Lpg0(%r13)
96                 stsch   .Lschib-.Lpg0(%r13)
97                 oi      .Lschib+5-.Lpg0(%r13),0x84
98 .Lecs:          xi      .Lschib+27-.Lpg0(%r13),0x01
99                 msch    .Lschib-.Lpg0(%r13)
100                 lghi    %r0,5
101 .Lssch:         ssch    .Liplorb-.Lpg0(%r13)
102                 jz      .L001
103                 brct    %r0,.Lssch
104                 bas     %r14,.Ldisab-.Lpg0(%r13)
105 .L001:          mvc     __LC_IO_NEW_PSW(16),.Lionew-.Lpg0(%r13)
106 .Ltpi:          lpswe   .Lwaitpsw-.Lpg0(%r13)
107 .Lcont:         c       %r1,__LC_SUBCHANNEL_ID
108                 jnz     .Ltpi
109                 clc     __LC_IO_INT_PARM(4),.Liplorb-.Lpg0(%r13)
110                 jnz     .Ltpi
111                 tsch    .Liplirb-.Lpg0(%r13)
112                 tm      .Liplirb+9-.Lpg0(%r13),0xbf
113                 jz      .L002
114                 bas     %r14,.Ldisab-.Lpg0(%r13)
115 .L002:          tm      .Liplirb+8-.Lpg0(%r13),0xf3
116                 jz      .L003
117                 bas     %r14,.Ldisab-.Lpg0(%r13)
118 .L003:          st      %r1,__LC_SUBCHANNEL_ID
119                 lhi     %r1,0            # mode 0 = esa
120                 slr     %r0,%r0          # set cpuid to zero
121                 sigp    %r1,%r0,SIGP_SET_ARCHITECTURE # switch to esa mode
122                 lpsw    0
123 .Ldisab:        sll     %r14,1
124                 srl     %r14,1           # need to kill hi bit to avoid specification exceptions.
125                 st      %r14,.Ldispsw+12-.Lpg0(%r13)
126                 lpswe   .Ldispsw-.Lpg0(%r13)
127                 .align  8
128 .Lall:          .quad   0x00000000ff000000
129                 .align  16
130 /*
131  * These addresses have to be 31 bit otherwise
132  * the sigp will throw a specifcation exception
133  * when switching to ESA mode as bit 31 be set
134  * in the ESA psw.
135  * Bit 31 of the addresses has to be 0 for the
136  * 31bit lpswe instruction a fact they appear to have
137  * omitted from the pop.
138  */
139 .Lnewpsw:       .quad   0x0000000080000000
140                 .quad   .Lpg1
141 .Lpcnew:        .quad   0x0000000080000000
142                 .quad   .Lecs
143 .Lionew:        .quad   0x0000000080000000
144                 .quad   .Lcont
145 .Lwaitpsw:      .quad   0x0202000080000000
146                 .quad   .Ltpi
147 .Ldispsw:       .quad   0x0002000080000000
148                 .quad   0x0000000000000000
149 .Liplccws:      .long   0x02000000,0x60000018
150                 .long   0x08000008,0x20000001
151 .Liplorb:       .long   0x0049504c,0x0040ff80
152                 .long   0x00000000+.Liplccws
153 .Lschib:        .long   0x00000000,0x00000000
154                 .long   0x00000000,0x00000000
155                 .long   0x00000000,0x00000000
156                 .long   0x00000000,0x00000000
157                 .long   0x00000000,0x00000000
158                 .long   0x00000000,0x00000000
159 .Liplirb:       .long   0x00000000,0x00000000
160                 .long   0x00000000,0x00000000
161                 .long   0x00000000,0x00000000
162                 .long   0x00000000,0x00000000
163                 .long   0x00000000,0x00000000
164                 .long   0x00000000,0x00000000
165                 .long   0x00000000,0x00000000
166                 .long   0x00000000,0x00000000