2 * arch/s390/kernel/head31.S
4 * Copyright (C) IBM Corp. 2005,2006
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>
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
19 startup:basr %r13,0 # get base
20 .LPG0: l %r13,0f-.LPG0(%r13)
22 0: .long startup_continue
25 # params at 10400 (setup.h)
28 .long 0,0 # IPL_DEVICE
29 .long 0,RAMDISK_ORIGIN # INITRD_START
30 .long 0,RAMDISK_SIZE # INITRD_SIZE
33 .byte "root=/dev/ram0 ro"
39 basr %r13,0 # get base
41 lctl %c0,%c15,.Lctl-.LPG1(%r13) # load control registers
42 l %r12,.Lparmaddr-.LPG1(%r13) # pointer to parameter area
43 # move IPL device to lowcore
44 mvc __LC_IPLDEV(4),IPL_DEVICE-PARMAREA(%r12)
49 l %r2,.Lbss_bgn-.LPG1(%r13) # start of bss
50 l %r3,.Lbss_end-.LPG1(%r13) # end of bss
51 sr %r3,%r2 # length of bss
53 sr %r5,%r5 # set src,length and pad to zero
55 mvcle %r2,%r4,0 # clear mem
56 jo .-4 # branch back, if not finish
58 l %r2,.Lrcp-.LPG1(%r13) # Read SCP forced command word
60 stosm .Lpmask-.LPG1(%r13),0x01 # authorize ext interrupts
62 stctl %r0, %r0,.Lcr-.LPG1(%r13) # get cr0
63 la %r1,0x200 # set bit 22
64 o %r1,.Lcr-.LPG1(%r13) # or old cr0 with r1
65 st %r1,.Lcr-.LPG1(%r13)
66 lctl %r0, %r0,.Lcr-.LPG1(%r13) # load modified cr0
68 mvc __LC_EXT_NEW_PSW(8),.Lpcext-.LPG1(%r13) # set postcall psw
69 la %r1, .Lsclph-.LPG1(%r13)
70 a %r1,__LC_EXT_NEW_PSW+4 # set handler
71 st %r1,__LC_EXT_NEW_PSW+4
73 l %r4,.Lsccbaddr-.LPG1(%r13) # %r4 is our index for sccb stuff
75 .insn rre,0xb2200000,%r2,%r1 # service call
77 srl %r1,28 # get cc code
80 be .Lfchunk-.LPG1(%r13) # leave
82 be .Lservicecall-.LPG1(%r13)
83 lpsw .Lwaitsclp-.LPG1(%r13)
85 lh %r1,.Lsccbr-.Lsccb(%r4)
86 chi %r1,0x10 # 0x0010 is the sucess code
87 je .Lprocsccb # let's process the sccb
89 bne .Lfchunk-.LPG1(%r13) # unhandled error code
90 c %r2, .Lrcp-.LPG1(%r13) # Did we try Read SCP forced
91 bne .Lfchunk-.LPG1(%r13) # if no, give up
92 l %r2, .Lrcp2-.LPG1(%r13) # try with Read SCP
93 b .Lservicecall-.LPG1(%r13)
96 icm %r1,3,.Lscpincr1-.Lsccb(%r4) # use this one if != 0
98 lhi %r1,0x800 # otherwise report 2GB
100 lhi %r3,0x800 # limit reported memory size to 2GB
105 xr %r3,%r3 # same logic
106 ic %r3,.Lscpa1-.Lsccb(%r4)
109 l %r3,.Lscpa2-.Lsccb(%r4)
111 mr %r2,%r1 # mem in MB on 128-bit
112 l %r1,.Lonemb-.LPG1(%r13)
113 mr %r2,%r1 # mem size in bytes in %r3
114 b .Lfchunk-.LPG1(%r13)
120 .Lpcext:.long 0x00080000,0x80000000
122 .long 0x00 # place holder for cr0
124 .long 0x010a0000,0x80000000 + .Lsclph
126 .int 0x00120001 # Read SCP forced code
128 .int 0x00020001 # Read SCP code
134 # find memory chunks.
136 lr %r9,%r3 # end of mem
137 mvc __LC_PGM_NEW_PSW(8),.Lpcmem-.LPG1(%r13)
138 la %r1,1 # test in increments of 128KB
140 l %r3,.Lmchunk-.LPG1(%r13) # get pointer to memory_chunk array
141 slr %r4,%r4 # set start of chunk to zero
142 slr %r5,%r5 # set end of chunk to zero
143 slr %r6,%r6 # set access code to zero
144 la %r10, MEMORY_CHUNKS # number of chunks
146 tprot 0(%r5),0 # test protection of first byte
149 clr %r6,%r7 # compare cc with last access code
150 be .Lsame-.LPG1(%r13)
151 b .Lchkmem-.LPG1(%r13)
153 ar %r5,%r1 # add 128KB to end of chunk
154 bno .Lloop-.LPG1(%r13) # r1 < 0x80000000 -> loop
155 .Lchkmem: # > 2GB or tprot got a program check
156 clr %r4,%r5 # chunk size > 0?
157 be .Lchkloop-.LPG1(%r13)
158 st %r4,0(%r3) # store start address of chunk
161 st %r0,4(%r3) # store size of chunk
162 st %r6,8(%r3) # store type of chunk
164 l %r4,.Lmemsize-.LPG1(%r13) # address of variable memory_size
165 st %r5,0(%r4) # store last end to memory size
166 ahi %r10,-1 # update chunk number
168 lr %r6,%r7 # set access code to last cc
169 # we got an exception or we're starting a new
170 # chunk , we must check if we should
171 # still try to find valid memory (if we detected
172 # the amount of available storage), and if we
175 clr %r0,%r9 # did we detect memory?
176 je .Ldonemem # if not, leave
177 chi %r10,0 # do we have chunks left?
179 alr %r5,%r1 # add 128KB to end of chunk
180 lr %r4,%r5 # potential new chunk
181 clr %r5,%r9 # should we go on?
184 l %r12,.Lmflags-.LPG1(%r13) # get address of machine_flags
186 # find out if we are running under VM
188 stidp __LC_CPUID # store cpuid
189 tm __LC_CPUID,0xff # running under VM ?
190 bno .Lnovm-.LPG1(%r13)
191 oi 3(%r12),1 # set VM flag
193 lh %r0,__LC_CPUID+4 # get cpu version
194 chi %r0,0x7490 # running on a P/390 ?
195 bne .Lnop390-.LPG1(%r13)
196 oi 3(%r12),4 # set P/390 flag
200 # find out if we have an IEEE fpu
202 mvc __LC_PGM_NEW_PSW(8),.Lpcfpu-.LPG1(%r13)
203 efpc %r0,0 # test IEEE extract fpc instruction
204 oi 3(%r12),2 # set IEEE fpu flag
208 # find out if we have the CSP instruction
210 mvc __LC_PGM_NEW_PSW(8),.Lpccsp-.LPG1(%r13)
214 csp %r0,%r2 # Test CSP instruction
215 oi 3(%r12),8 # set CSP flag
219 # find out if we have the MVPG instruction
221 mvc __LC_PGM_NEW_PSW(8),.Lpcmvpg-.LPG1(%r13)
225 mvpg %r1,%r2 # Test CSP instruction
226 oi 3(%r12),16 # set MVPG flag
230 # find out if we have the IDTE instruction
232 mvc __LC_PGM_NEW_PSW(8),.Lpcidte-.LPG1(%r13)
233 .long 0xb2b10000 # store facility list
234 tm 0xc8,0x08 # check bit for clearing-by-ASCE
235 bno .Lchkidte-.LPG1(%r13)
239 oi 3(%r12),0x80 # set IDTE flag
242 lpsw .Lentry-.LPG1(13) # jump to _stext in primary-space,
243 # virtual and never return ...
245 .Lentry:.long 0x00080000,0x80000000 + _stext
246 .Lctl: .long 0x04b50002 # cr0: various things
247 .long 0 # cr1: primary space segment table
248 .long .Lduct # cr2: dispatchable unit control table
249 .long 0 # cr3: instruction authorization
250 .long 0 # cr4: instruction authorization
251 .long 0xffffffff # cr5: primary-aste origin
252 .long 0 # cr6: I/O interrupts
253 .long 0 # cr7: secondary space segment table
254 .long 0 # cr8: access registers translation
255 .long 0 # cr9: tracing off
256 .long 0 # cr10: tracing off
257 .long 0 # cr11: tracing off
258 .long 0 # cr12: tracing off
259 .long 0 # cr13: home space segment table
260 .long 0xc0000000 # cr14: machine check handling off
261 .long 0 # cr15: linkage stack operations
262 .Lduct: .long 0,0,0,0,0,0,0,0
263 .long 0,0,0,0,0,0,0,0
264 .Lpcmem:.long 0x00080000,0x80000000 + .Lchkmem
265 .Lpcfpu:.long 0x00080000,0x80000000 + .Lchkfpu
266 .Lpccsp:.long 0x00080000,0x80000000 + .Lchkcsp
267 .Lpcmvpg:.long 0x00080000,0x80000000 + .Lchkmvpg
268 .Lpcidte:.long 0x00080000,0x80000000 + .Lchkidte
269 .Lmemsize:.long memory_size
270 .Lmchunk:.long memory_chunk
271 .Lmflags:.long machine_flags
272 .Lbss_bgn: .long __bss_start
273 .Lbss_end: .long _end
274 .Lparmaddr: .long PARMAREA
275 .Lsccbaddr: .long .Lsccb
278 .hword 0x1000 # length, one page
280 .byte 0x80 # variable response bit set
282 .hword 0x00 # response code
295 #ifdef CONFIG_SHARED_KERNEL
300 # startup-code, running in absolute addressing mode
303 _stext: basr %r13,0 # get base
308 l %r15,.Linittu-.LPG3(%r13)
309 mvc __LC_CURRENT(4),__TI_task(%r15)
310 ahi %r15,1<<(PAGE_SHIFT+THREAD_ORDER) # init_task_union+THREAD_SIZE
311 st %r15,__LC_KERNEL_STACK # set end of kernel stack
313 xc __SF_BACKCHAIN(4,%r15),__SF_BACKCHAIN(%r15) # clear backchain
315 # check control registers
316 stctl %c0,%c15,0(%r15)
317 oi 2(%r15),0x40 # enable sigp emergency signal
318 oi 0(%r15),0x10 # switch on low address protection
319 lctl %c0,%c15,0(%r15)
322 lam 0,15,.Laregs-.LPG3(%r13) # load access regs needed by uaccess
323 l %r14,.Lstart-.LPG3(%r13)
324 basr %r14,%r14 # call start_kernel
326 # We returned from start_kernel ?!? PANIK
329 lpsw .Ldw-.(%r13) # load disabled wait psw
332 .Ldw: .long 0x000a0000,0x00000000
333 .Linittu:.long init_thread_union
334 .Lstart:.long start_kernel
335 .Laregs:.long 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0