blob: d8bb68a7252737c7e6ec876eaeeb3dac51db6270 [file] [log] [blame]
Heiko Carstens0ad775d2005-11-07 00:59:12 -08001/*
2 * arch/s390/kernel/head31.S
3 *
Heiko Carstensb1b70302006-06-29 14:58:17 +02004 * Copyright (C) IBM Corp. 2005,2006
Heiko Carstens0ad775d2005-11-07 00:59:12 -08005 *
6 * Author(s): Hartmut Penner <hp@de.ibm.com>
7 * Martin Schwidefsky <schwidefsky@de.ibm.com>
8 * Rob van der Heij <rvdhei@iae.nl>
9 * Heiko Carstens <heiko.carstens@de.ibm.com>
10 *
11 */
12
13#
14# startup-code at 0x10000, running in absolute addressing mode
15# this is called either by the ipl loader or directly by PSW restart
16# or linload or SALIPL
17#
18 .org 0x10000
Heiko Carstensb1b70302006-06-29 14:58:17 +020019startup:basr %r13,0 # get base
20.LPG0: l %r13,0f-.LPG0(%r13)
21 b 0(%r13)
220: .long startup_continue
23
24#
25# params at 10400 (setup.h)
26#
27 .org PARMAREA
28 .long 0,0 # IPL_DEVICE
Heiko Carstens65912a82006-09-20 15:58:41 +020029 .long 0,0 # INITRD_START
30 .long 0,0 # INITRD_SIZE
Heiko Carstensb1b70302006-06-29 14:58:17 +020031
32 .org COMMAND_LINE
33 .byte "root=/dev/ram0 ro"
34 .byte 0
35
36 .org 0x11000
37
38startup_continue:
39 basr %r13,0 # get base
40.LPG1: GET_IPL_DEVICE
Michael Holzheuff6b8ea2006-09-20 15:58:49 +020041 mvi __LC_AR_MODE_ID,0 # set ESA flag (mode 0)
Heiko Carstens0ad775d2005-11-07 00:59:12 -080042 lctl %c0,%c15,.Lctl-.LPG1(%r13) # load control registers
Heiko Carstensb1b70302006-06-29 14:58:17 +020043 l %r12,.Lparmaddr-.LPG1(%r13) # pointer to parameter area
44 # move IPL device to lowcore
Heiko Carstens0ad775d2005-11-07 00:59:12 -080045 mvc __LC_IPLDEV(4),IPL_DEVICE-PARMAREA(%r12)
46
47#
48# clear bss memory
49#
50 l %r2,.Lbss_bgn-.LPG1(%r13) # start of bss
51 l %r3,.Lbss_end-.LPG1(%r13) # end of bss
52 sr %r3,%r2 # length of bss
53 sr %r4,%r4
54 sr %r5,%r5 # set src,length and pad to zero
55 sr %r0,%r0
56 mvcle %r2,%r4,0 # clear mem
57 jo .-4 # branch back, if not finish
58
59 l %r2,.Lrcp-.LPG1(%r13) # Read SCP forced command word
60.Lservicecall:
61 stosm .Lpmask-.LPG1(%r13),0x01 # authorize ext interrupts
62
63 stctl %r0, %r0,.Lcr-.LPG1(%r13) # get cr0
64 la %r1,0x200 # set bit 22
65 o %r1,.Lcr-.LPG1(%r13) # or old cr0 with r1
66 st %r1,.Lcr-.LPG1(%r13)
67 lctl %r0, %r0,.Lcr-.LPG1(%r13) # load modified cr0
68
69 mvc __LC_EXT_NEW_PSW(8),.Lpcext-.LPG1(%r13) # set postcall psw
70 la %r1, .Lsclph-.LPG1(%r13)
71 a %r1,__LC_EXT_NEW_PSW+4 # set handler
72 st %r1,__LC_EXT_NEW_PSW+4
73
Heiko Carstensb1b70302006-06-29 14:58:17 +020074 l %r4,.Lsccbaddr-.LPG1(%r13) # %r4 is our index for sccb stuff
75 lr %r1,%r4 # our sccb
Heiko Carstens0ad775d2005-11-07 00:59:12 -080076 .insn rre,0xb2200000,%r2,%r1 # service call
77 ipm %r1
78 srl %r1,28 # get cc code
79 xr %r3, %r3
80 chi %r1,3
81 be .Lfchunk-.LPG1(%r13) # leave
82 chi %r1,2
83 be .Lservicecall-.LPG1(%r13)
84 lpsw .Lwaitsclp-.LPG1(%r13)
85.Lsclph:
Heiko Carstensb1b70302006-06-29 14:58:17 +020086 lh %r1,.Lsccbr-.Lsccb(%r4)
Heiko Carstens0ad775d2005-11-07 00:59:12 -080087 chi %r1,0x10 # 0x0010 is the sucess code
88 je .Lprocsccb # let's process the sccb
89 chi %r1,0x1f0
90 bne .Lfchunk-.LPG1(%r13) # unhandled error code
91 c %r2, .Lrcp-.LPG1(%r13) # Did we try Read SCP forced
92 bne .Lfchunk-.LPG1(%r13) # if no, give up
93 l %r2, .Lrcp2-.LPG1(%r13) # try with Read SCP
94 b .Lservicecall-.LPG1(%r13)
95.Lprocsccb:
96 lhi %r1,0
Heiko Carstensb1b70302006-06-29 14:58:17 +020097 icm %r1,3,.Lscpincr1-.Lsccb(%r4) # use this one if != 0
Heiko Carstens0ad775d2005-11-07 00:59:12 -080098 jnz .Lscnd
99 lhi %r1,0x800 # otherwise report 2GB
100.Lscnd:
101 lhi %r3,0x800 # limit reported memory size to 2GB
102 cr %r1,%r3
103 jl .Lno2gb
104 lr %r1,%r3
105.Lno2gb:
106 xr %r3,%r3 # same logic
Heiko Carstensb1b70302006-06-29 14:58:17 +0200107 ic %r3,.Lscpa1-.Lsccb(%r4)
Heiko Carstens0ad775d2005-11-07 00:59:12 -0800108 chi %r3,0x00
109 jne .Lcompmem
Heiko Carstensb1b70302006-06-29 14:58:17 +0200110 l %r3,.Lscpa2-.Lsccb(%r4)
Heiko Carstens0ad775d2005-11-07 00:59:12 -0800111.Lcompmem:
112 mr %r2,%r1 # mem in MB on 128-bit
113 l %r1,.Lonemb-.LPG1(%r13)
114 mr %r2,%r1 # mem size in bytes in %r3
115 b .Lfchunk-.LPG1(%r13)
116
117 .align 4
Heiko Carstens0ad775d2005-11-07 00:59:12 -0800118.Lpmask:
119 .byte 0
120.align 8
121.Lpcext:.long 0x00080000,0x80000000
122.Lcr:
123 .long 0x00 # place holder for cr0
124.Lwaitsclp:
125 .long 0x010a0000,0x80000000 + .Lsclph
126.Lrcp:
127 .int 0x00120001 # Read SCP forced code
128.Lrcp2:
129 .int 0x00020001 # Read SCP code
130.Lonemb:
131 .int 0x100000
132.Lfchunk:
133
134#
135# find memory chunks.
136#
137 lr %r9,%r3 # end of mem
138 mvc __LC_PGM_NEW_PSW(8),.Lpcmem-.LPG1(%r13)
139 la %r1,1 # test in increments of 128KB
140 sll %r1,17
141 l %r3,.Lmchunk-.LPG1(%r13) # get pointer to memory_chunk array
142 slr %r4,%r4 # set start of chunk to zero
143 slr %r5,%r5 # set end of chunk to zero
144 slr %r6,%r6 # set access code to zero
145 la %r10, MEMORY_CHUNKS # number of chunks
146.Lloop:
147 tprot 0(%r5),0 # test protection of first byte
148 ipm %r7
149 srl %r7,28
150 clr %r6,%r7 # compare cc with last access code
151 be .Lsame-.LPG1(%r13)
152 b .Lchkmem-.LPG1(%r13)
153.Lsame:
154 ar %r5,%r1 # add 128KB to end of chunk
155 bno .Lloop-.LPG1(%r13) # r1 < 0x80000000 -> loop
156.Lchkmem: # > 2GB or tprot got a program check
157 clr %r4,%r5 # chunk size > 0?
158 be .Lchkloop-.LPG1(%r13)
159 st %r4,0(%r3) # store start address of chunk
160 lr %r0,%r5
161 slr %r0,%r4
162 st %r0,4(%r3) # store size of chunk
163 st %r6,8(%r3) # store type of chunk
164 la %r3,12(%r3)
165 l %r4,.Lmemsize-.LPG1(%r13) # address of variable memory_size
166 st %r5,0(%r4) # store last end to memory size
167 ahi %r10,-1 # update chunk number
168.Lchkloop:
169 lr %r6,%r7 # set access code to last cc
170 # we got an exception or we're starting a new
171 # chunk , we must check if we should
172 # still try to find valid memory (if we detected
173 # the amount of available storage), and if we
174 # have chunks left
175 xr %r0,%r0
176 clr %r0,%r9 # did we detect memory?
177 je .Ldonemem # if not, leave
178 chi %r10,0 # do we have chunks left?
179 je .Ldonemem
180 alr %r5,%r1 # add 128KB to end of chunk
181 lr %r4,%r5 # potential new chunk
182 clr %r5,%r9 # should we go on?
183 jl .Lloop
184.Ldonemem:
185 l %r12,.Lmflags-.LPG1(%r13) # get address of machine_flags
186#
187# find out if we are running under VM
188#
189 stidp __LC_CPUID # store cpuid
190 tm __LC_CPUID,0xff # running under VM ?
191 bno .Lnovm-.LPG1(%r13)
192 oi 3(%r12),1 # set VM flag
193.Lnovm:
194 lh %r0,__LC_CPUID+4 # get cpu version
195 chi %r0,0x7490 # running on a P/390 ?
196 bne .Lnop390-.LPG1(%r13)
197 oi 3(%r12),4 # set P/390 flag
198.Lnop390:
199
200#
201# find out if we have an IEEE fpu
202#
203 mvc __LC_PGM_NEW_PSW(8),.Lpcfpu-.LPG1(%r13)
204 efpc %r0,0 # test IEEE extract fpc instruction
205 oi 3(%r12),2 # set IEEE fpu flag
206.Lchkfpu:
207
208#
209# find out if we have the CSP instruction
210#
211 mvc __LC_PGM_NEW_PSW(8),.Lpccsp-.LPG1(%r13)
212 la %r0,0
213 lr %r1,%r0
214 la %r2,4
215 csp %r0,%r2 # Test CSP instruction
216 oi 3(%r12),8 # set CSP flag
217.Lchkcsp:
218
219#
220# find out if we have the MVPG instruction
221#
222 mvc __LC_PGM_NEW_PSW(8),.Lpcmvpg-.LPG1(%r13)
223 sr %r0,%r0
224 la %r1,0
225 la %r2,0
226 mvpg %r1,%r2 # Test CSP instruction
227 oi 3(%r12),16 # set MVPG flag
228.Lchkmvpg:
229
230#
231# find out if we have the IDTE instruction
232#
233 mvc __LC_PGM_NEW_PSW(8),.Lpcidte-.LPG1(%r13)
234 .long 0xb2b10000 # store facility list
235 tm 0xc8,0x08 # check bit for clearing-by-ASCE
236 bno .Lchkidte-.LPG1(%r13)
237 lhi %r1,2094
238 lhi %r2,0
239 .long 0xb98e2001
240 oi 3(%r12),0x80 # set IDTE flag
241.Lchkidte:
242
243 lpsw .Lentry-.LPG1(13) # jump to _stext in primary-space,
244 # virtual and never return ...
245 .align 8
246.Lentry:.long 0x00080000,0x80000000 + _stext
247.Lctl: .long 0x04b50002 # cr0: various things
248 .long 0 # cr1: primary space segment table
249 .long .Lduct # cr2: dispatchable unit control table
250 .long 0 # cr3: instruction authorization
251 .long 0 # cr4: instruction authorization
252 .long 0xffffffff # cr5: primary-aste origin
253 .long 0 # cr6: I/O interrupts
254 .long 0 # cr7: secondary space segment table
255 .long 0 # cr8: access registers translation
256 .long 0 # cr9: tracing off
257 .long 0 # cr10: tracing off
258 .long 0 # cr11: tracing off
259 .long 0 # cr12: tracing off
260 .long 0 # cr13: home space segment table
261 .long 0xc0000000 # cr14: machine check handling off
262 .long 0 # cr15: linkage stack operations
Heiko Carstensb1b70302006-06-29 14:58:17 +0200263.Lduct: .long 0,0,0,0,0,0,0,0
264 .long 0,0,0,0,0,0,0,0
Heiko Carstens0ad775d2005-11-07 00:59:12 -0800265.Lpcmem:.long 0x00080000,0x80000000 + .Lchkmem
266.Lpcfpu:.long 0x00080000,0x80000000 + .Lchkfpu
267.Lpccsp:.long 0x00080000,0x80000000 + .Lchkcsp
268.Lpcmvpg:.long 0x00080000,0x80000000 + .Lchkmvpg
269.Lpcidte:.long 0x00080000,0x80000000 + .Lchkidte
270.Lmemsize:.long memory_size
271.Lmchunk:.long memory_chunk
272.Lmflags:.long machine_flags
273.Lbss_bgn: .long __bss_start
274.Lbss_end: .long _end
Heiko Carstensb1b70302006-06-29 14:58:17 +0200275.Lparmaddr: .long PARMAREA
276.Lsccbaddr: .long .Lsccb
Heiko Carstensdc8f5d22006-07-18 13:44:57 +0200277 .org 0x12000
Michael Holzheuff6b8ea2006-09-20 15:58:49 +0200278.globl s390_readinfo_sccb
279s390_readinfo_sccb:
Heiko Carstens0ad775d2005-11-07 00:59:12 -0800280.Lsccb:
281 .hword 0x1000 # length, one page
282 .byte 0x00,0x00,0x00
283 .byte 0x80 # variable response bit set
284.Lsccbr:
285 .hword 0x00 # response code
286.Lscpincr1:
287 .hword 0x00
288.Lscpa1:
289 .byte 0x00
290 .fill 89,1,0
291.Lscpa2:
292 .int 0x00
293.Lscpincr2:
294 .quad 0x00
295 .fill 3984,1,0
Heiko Carstensdc8f5d22006-07-18 13:44:57 +0200296 .org 0x13000
Heiko Carstens0ad775d2005-11-07 00:59:12 -0800297
298#ifdef CONFIG_SHARED_KERNEL
299 .org 0x100000
300#endif
301
302#
Heiko Carstensb1b70302006-06-29 14:58:17 +0200303# startup-code, running in absolute addressing mode
Heiko Carstens0ad775d2005-11-07 00:59:12 -0800304#
305 .globl _stext
306_stext: basr %r13,0 # get base
307.LPG3:
308#
309# Setup stack
310#
311 l %r15,.Linittu-.LPG3(%r13)
312 mvc __LC_CURRENT(4),__TI_task(%r15)
313 ahi %r15,1<<(PAGE_SHIFT+THREAD_ORDER) # init_task_union+THREAD_SIZE
314 st %r15,__LC_KERNEL_STACK # set end of kernel stack
315 ahi %r15,-96
316 xc __SF_BACKCHAIN(4,%r15),__SF_BACKCHAIN(%r15) # clear backchain
317
318# check control registers
319 stctl %c0,%c15,0(%r15)
320 oi 2(%r15),0x40 # enable sigp emergency signal
321 oi 0(%r15),0x10 # switch on low address protection
322 lctl %c0,%c15,0(%r15)
323
324#
325 lam 0,15,.Laregs-.LPG3(%r13) # load access regs needed by uaccess
326 l %r14,.Lstart-.LPG3(%r13)
327 basr %r14,%r14 # call start_kernel
328#
329# We returned from start_kernel ?!? PANIK
330#
331 basr %r13,0
332 lpsw .Ldw-.(%r13) # load disabled wait psw
333#
334 .align 8
335.Ldw: .long 0x000a0000,0x00000000
336.Linittu:.long init_thread_union
337.Lstart:.long start_kernel
338.Laregs:.long 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0