aboutsummaryrefslogtreecommitdiffstats
path: root/arch/s390/kernel/head.S
diff options
context:
space:
mode:
authorPaul Mackerras <paulus@samba.org>2005-11-07 19:14:20 -0500
committerPaul Mackerras <paulus@samba.org>2005-11-07 19:14:20 -0500
commit24bfb00123e82a2e70bd115277d922438813515b (patch)
tree27328b8a5718e16d64e2d101f4b7ddcad5930aed /arch/s390/kernel/head.S
parentc6135234550ed89a6fd0e8cb229633967e41d649 (diff)
parent3f00d3e8fb963968a922d821a9a53b503b687e81 (diff)
Merge ../linux-2.6
Diffstat (limited to 'arch/s390/kernel/head.S')
-rw-r--r--arch/s390/kernel/head.S383
1 files changed, 34 insertions, 349 deletions
diff --git a/arch/s390/kernel/head.S b/arch/s390/kernel/head.S
index 039354d72348..d31a97c89f68 100644
--- a/arch/s390/kernel/head.S
+++ b/arch/s390/kernel/head.S
@@ -1,11 +1,12 @@
1/* 1/*
2 * arch/s390/kernel/head.S 2 * arch/s390/kernel/head.S
3 * 3 *
4 * S390 version 4 * (C) Copyright IBM Corp. 1999, 2005
5 * Copyright (C) 1999,2000 IBM Deutschland Entwicklung GmbH, IBM Corporation 5 *
6 * Author(s): Hartmut Penner (hp@de.ibm.com), 6 * Author(s): Hartmut Penner <hp@de.ibm.com>
7 * Martin Schwidefsky (schwidefsky@de.ibm.com), 7 * Martin Schwidefsky <schwidefsky@de.ibm.com>
8 * Rob van der Heij (rvdhei@iae.nl) 8 * Rob van der Heij <rvdhei@iae.nl>
9 * Heiko Carstens <heiko.carstens@de.ibm.com>
9 * 10 *
10 * There are 5 different IPL methods 11 * There are 5 different IPL methods
11 * 1) load the image directly into ram at address 0 and do an PSW restart 12 * 1) load the image directly into ram at address 0 and do an PSW restart
@@ -19,12 +20,7 @@
19 * 5) direct call of start by the SALIPL loader 20 * 5) direct call of start by the SALIPL loader
20 * We use the cpuid to distinguish between VM and native ipl 21 * We use the cpuid to distinguish between VM and native ipl
21 * params for kernel are pushed to 0x10400 (see setup.h) 22 * params for kernel are pushed to 0x10400 (see setup.h)
22 23 *
23 Changes:
24 Okt 25 2000 <rvdheij@iae.nl>
25 added code to skip HDR and EOF to allow SL tape IPL (5 retries)
26 changed first CCW from rewind to backspace block
27
28 */ 24 */
29 25
30#include <linux/config.h> 26#include <linux/config.h>
@@ -34,6 +30,12 @@
34#include <asm/thread_info.h> 30#include <asm/thread_info.h>
35#include <asm/page.h> 31#include <asm/page.h>
36 32
33#ifdef CONFIG_ARCH_S390X
34#define ARCH_OFFSET 4
35#else
36#define ARCH_OFFSET 0
37#endif
38
37#ifndef CONFIG_IPL 39#ifndef CONFIG_IPL
38 .org 0 40 .org 0
39 .long 0x00080000,0x80000000+startup # Just a restart PSW 41 .long 0x00080000,0x80000000+startup # Just a restart PSW
@@ -201,7 +203,7 @@
201 ssch 0(%r3) # load chunk of 1600 bytes 203 ssch 0(%r3) # load chunk of 1600 bytes
202 bnz .Llderr 204 bnz .Llderr
203.Lwait4irq: 205.Lwait4irq:
204 mvc __LC_IO_NEW_PSW(8),.Lnewpsw # set up IO interrupt psw 206 mvc 0x78(8),.Lnewpsw # set up IO interrupt psw
205 lpsw .Lwaitpsw 207 lpsw .Lwaitpsw
206.Lioint: 208.Lioint:
207 c %r1,0xb8 # compare subchannel number 209 c %r1,0xb8 # compare subchannel number
@@ -265,13 +267,13 @@ iplstart:
265 la %r2,IPL_BS # load start address 267 la %r2,IPL_BS # load start address
266 bas %r14,.Lloader # load rest of ipl image 268 bas %r14,.Lloader # load rest of ipl image
267 l %r12,.Lparm # pointer to parameter area 269 l %r12,.Lparm # pointer to parameter area
268 st %r1,IPL_DEVICE-PARMAREA(%r12) # store ipl device number 270 st %r1,IPL_DEVICE+ARCH_OFFSET-PARMAREA(%r12) # save ipl device number
269 271
270# 272#
271# load parameter file from ipl device 273# load parameter file from ipl device
272# 274#
273.Lagain1: 275.Lagain1:
274 l %r2,INITRD_START-PARMAREA(%r12) # use ramdisk location as temp 276 l %r2,INITRD_START+ARCH_OFFSET-PARMAREA(%r12) # ramdisk loc. is temp
275 bas %r14,.Lloader # load parameter file 277 bas %r14,.Lloader # load parameter file
276 ltr %r2,%r2 # got anything ? 278 ltr %r2,%r2 # got anything ?
277 bz .Lnopf 279 bz .Lnopf
@@ -279,7 +281,7 @@ iplstart:
279 bnh .Lnotrunc 281 bnh .Lnotrunc
280 la %r2,895 282 la %r2,895
281.Lnotrunc: 283.Lnotrunc:
282 l %r4,INITRD_START-PARMAREA(%r12) 284 l %r4,INITRD_START+ARCH_OFFSET-PARMAREA(%r12)
283 clc 0(3,%r4),.L_hdr # if it is HDRx 285 clc 0(3,%r4),.L_hdr # if it is HDRx
284 bz .Lagain1 # skip dataset header 286 bz .Lagain1 # skip dataset header
285 clc 0(3,%r4),.L_eof # if it is EOFx 287 clc 0(3,%r4),.L_eof # if it is EOFx
@@ -322,14 +324,14 @@ iplstart:
322# load ramdisk from ipl device 324# load ramdisk from ipl device
323# 325#
324.Lagain2: 326.Lagain2:
325 l %r2,INITRD_START-PARMAREA(%r12) # load adr. of ramdisk 327 l %r2,INITRD_START+ARCH_OFFSET-PARMAREA(%r12) # addr of ramdisk
326 bas %r14,.Lloader # load ramdisk 328 bas %r14,.Lloader # load ramdisk
327 st %r2,INITRD_SIZE-PARMAREA(%r12) # store size of ramdisk 329 st %r2,INITRD_SIZE+ARCH_OFFSET-PARMAREA(%r12) # store size of ramdisk
328 ltr %r2,%r2 330 ltr %r2,%r2
329 bnz .Lrdcont 331 bnz .Lrdcont
330 st %r2,INITRD_START-PARMAREA(%r12) # no ramdisk found, null it 332 st %r2,INITRD_START+ARCH_OFFSET-PARMAREA(%r12) # no ramdisk found
331.Lrdcont: 333.Lrdcont:
332 l %r2,INITRD_START-PARMAREA(%r12) 334 l %r2,INITRD_START+ARCH_OFFSET-PARMAREA(%r12)
333 335
334 clc 0(3,%r2),.L_hdr # skip HDRx and EOFx 336 clc 0(3,%r2),.L_hdr # skip HDRx and EOFx
335 bz .Lagain2 337 bz .Lagain2
@@ -432,10 +434,10 @@ start:
432 la %r3,1(%r3) 434 la %r3,1(%r3)
433.done: 435.done:
434 l %r1,.memsize 436 l %r1,.memsize
435 st %r3,0(%r1) 437 st %r3,ARCH_OFFSET(%r1)
436 slr %r0,%r0 438 slr %r0,%r0
437 st %r0,INITRD_SIZE-PARMAREA(%r11) 439 st %r0,INITRD_SIZE+ARCH_OFFSET-PARMAREA(%r11)
438 st %r0,INITRD_START-PARMAREA(%r11) 440 st %r0,INITRD_START+ARCH_OFFSET-PARMAREA(%r11)
439 j startup # continue with startup 441 j startup # continue with startup
440.tbl: .long _ebcasc # translate table 442.tbl: .long _ebcasc # translate table
441.cmd: .long COMMAND_LINE # address of command line buffer 443.cmd: .long COMMAND_LINE # address of command line buffer
@@ -478,304 +480,23 @@ start:
478 .byte 0xf0,0xf1,0xf2,0xf3,0xf4,0xf5,0xf6,0xf7 480 .byte 0xf0,0xf1,0xf2,0xf3,0xf4,0xf5,0xf6,0xf7
479 .byte 0xf8,0xf9,0xfa,0xfb,0xfc,0xfd,0xfe,0xff 481 .byte 0xf8,0xf9,0xfa,0xfb,0xfc,0xfd,0xfe,0xff
480 482
481# 483.macro GET_IPL_DEVICE
482# startup-code at 0x10000, running in real mode
483# this is called either by the ipl loader or directly by PSW restart
484# or linload or SALIPL
485#
486 .org 0x10000
487startup:basr %r13,0 # get base
488.LPG1: l %r1, .Lget_ipl_device_addr-.LPG1(%r13)
489 basr %r14, %r1
490 lctl %c0,%c15,.Lctl-.LPG1(%r13) # load control registers
491 la %r12,_pstart-.LPG1(%r13) # pointer to parameter area
492 # move IPL device to lowcore
493 mvc __LC_IPLDEV(4),IPL_DEVICE-PARMAREA(%r12)
494
495#
496# clear bss memory
497#
498 l %r2,.Lbss_bgn-.LPG1(%r13) # start of bss
499 l %r3,.Lbss_end-.LPG1(%r13) # end of bss
500 sr %r3,%r2 # length of bss
501 sr %r4,%r4 #
502 sr %r5,%r5 # set src,length and pad to zero
503 sr %r0,%r0 #
504 mvcle %r2,%r4,0 # clear mem
505 jo .-4 # branch back, if not finish
506
507 l %r2,.Lrcp-.LPG1(%r13) # Read SCP forced command word
508.Lservicecall:
509 stosm .Lpmask-.LPG1(%r13),0x01 # authorize ext interrupts
510
511 stctl %r0, %r0,.Lcr-.LPG1(%r13) # get cr0
512 la %r1,0x200 # set bit 22
513 o %r1,.Lcr-.LPG1(%r13) # or old cr0 with r1
514 st %r1,.Lcr-.LPG1(%r13)
515 lctl %r0, %r0,.Lcr-.LPG1(%r13) # load modified cr0
516
517 mvc __LC_EXT_NEW_PSW(8),.Lpcext-.LPG1(%r13) # set postcall psw
518 la %r1, .Lsclph-.LPG1(%r13)
519 a %r1,__LC_EXT_NEW_PSW+4 # set handler
520 st %r1,__LC_EXT_NEW_PSW+4
521
522 la %r4,_pstart-.LPG1(%r13) # %r4 is our index for sccb stuff
523 la %r1, .Lsccb-PARMAREA(%r4) # our sccb
524 .insn rre,0xb2200000,%r2,%r1 # service call
525 ipm %r1
526 srl %r1,28 # get cc code
527 xr %r3, %r3
528 chi %r1,3
529 be .Lfchunk-.LPG1(%r13) # leave
530 chi %r1,2
531 be .Lservicecall-.LPG1(%r13)
532 lpsw .Lwaitsclp-.LPG1(%r13)
533.Lsclph:
534 lh %r1,.Lsccbr-PARMAREA(%r4)
535 chi %r1,0x10 # 0x0010 is the sucess code
536 je .Lprocsccb # let's process the sccb
537 chi %r1,0x1f0
538 bne .Lfchunk-.LPG1(%r13) # unhandled error code
539 c %r2, .Lrcp-.LPG1(%r13) # Did we try Read SCP forced
540 bne .Lfchunk-.LPG1(%r13) # if no, give up
541 l %r2, .Lrcp2-.LPG1(%r13) # try with Read SCP
542 b .Lservicecall-.LPG1(%r13)
543.Lprocsccb:
544 lhi %r1,0
545 icm %r1,3,.Lscpincr1-PARMAREA(%r4) # use this one if != 0
546 jnz .Lscnd
547 lhi %r1,0x800 # otherwise report 2GB
548.Lscnd:
549 lhi %r3,0x800 # limit reported memory size to 2GB
550 cr %r1,%r3
551 jl .Lno2gb
552 lr %r1,%r3
553.Lno2gb:
554 xr %r3,%r3 # same logic
555 ic %r3,.Lscpa1-PARMAREA(%r4)
556 chi %r3,0x00
557 jne .Lcompmem
558 l %r3,.Lscpa2-PARMAREA(%r13)
559.Lcompmem:
560 mr %r2,%r1 # mem in MB on 128-bit
561 l %r1,.Lonemb-.LPG1(%r13)
562 mr %r2,%r1 # mem size in bytes in %r3
563 b .Lfchunk-.LPG1(%r13)
564
565 .align 4
566.Lget_ipl_device_addr:
567 .long .Lget_ipl_device
568.Lpmask:
569 .byte 0
570.align 8
571.Lpcext:.long 0x00080000,0x80000000
572.Lcr:
573 .long 0x00 # place holder for cr0
574.Lwaitsclp:
575 .long 0x020A0000
576 .long .Lsclph
577.Lrcp:
578 .int 0x00120001 # Read SCP forced code
579.Lrcp2:
580 .int 0x00020001 # Read SCP code
581.Lonemb:
582 .int 0x100000
583.Lfchunk:
584
585#
586# find memory chunks.
587#
588 lr %r9,%r3 # end of mem
589 mvc __LC_PGM_NEW_PSW(8),.Lpcmem-.LPG1(%r13)
590 la %r1,1 # test in increments of 128KB
591 sll %r1,17
592 l %r3,.Lmchunk-.LPG1(%r13) # get pointer to memory_chunk array
593 slr %r4,%r4 # set start of chunk to zero
594 slr %r5,%r5 # set end of chunk to zero
595 slr %r6,%r6 # set access code to zero
596 la %r10, MEMORY_CHUNKS # number of chunks
597.Lloop:
598 tprot 0(%r5),0 # test protection of first byte
599 ipm %r7
600 srl %r7,28
601 clr %r6,%r7 # compare cc with last access code
602 be .Lsame-.LPG1(%r13)
603 b .Lchkmem-.LPG1(%r13)
604.Lsame:
605 ar %r5,%r1 # add 128KB to end of chunk
606 bno .Lloop-.LPG1(%r13) # r1 < 0x80000000 -> loop
607.Lchkmem: # > 2GB or tprot got a program check
608 clr %r4,%r5 # chunk size > 0?
609 be .Lchkloop-.LPG1(%r13)
610 st %r4,0(%r3) # store start address of chunk
611 lr %r0,%r5
612 slr %r0,%r4
613 st %r0,4(%r3) # store size of chunk
614 st %r6,8(%r3) # store type of chunk
615 la %r3,12(%r3)
616 l %r4,.Lmemsize-.LPG1(%r13) # address of variable memory_size
617 st %r5,0(%r4) # store last end to memory size
618 ahi %r10,-1 # update chunk number
619.Lchkloop:
620 lr %r6,%r7 # set access code to last cc
621 # we got an exception or we're starting a new
622 # chunk , we must check if we should
623 # still try to find valid memory (if we detected
624 # the amount of available storage), and if we
625 # have chunks left
626 xr %r0,%r0
627 clr %r0,%r9 # did we detect memory?
628 je .Ldonemem # if not, leave
629 chi %r10,0 # do we have chunks left?
630 je .Ldonemem
631 alr %r5,%r1 # add 128KB to end of chunk
632 lr %r4,%r5 # potential new chunk
633 clr %r5,%r9 # should we go on?
634 jl .Lloop
635.Ldonemem:
636 l %r12,.Lmflags-.LPG1(%r13) # get address of machine_flags
637#
638# find out if we are running under VM
639#
640 stidp __LC_CPUID # store cpuid
641 tm __LC_CPUID,0xff # running under VM ?
642 bno .Lnovm-.LPG1(%r13)
643 oi 3(%r12),1 # set VM flag
644.Lnovm:
645 lh %r0,__LC_CPUID+4 # get cpu version
646 chi %r0,0x7490 # running on a P/390 ?
647 bne .Lnop390-.LPG1(%r13)
648 oi 3(%r12),4 # set P/390 flag
649.Lnop390:
650
651#
652# find out if we have an IEEE fpu
653#
654 mvc __LC_PGM_NEW_PSW(8),.Lpcfpu-.LPG1(%r13)
655 efpc %r0,0 # test IEEE extract fpc instruction
656 oi 3(%r12),2 # set IEEE fpu flag
657.Lchkfpu:
658
659#
660# find out if we have the CSP instruction
661#
662 mvc __LC_PGM_NEW_PSW(8),.Lpccsp-.LPG1(%r13)
663 la %r0,0
664 lr %r1,%r0
665 la %r2,4
666 csp %r0,%r2 # Test CSP instruction
667 oi 3(%r12),8 # set CSP flag
668.Lchkcsp:
669
670#
671# find out if we have the MVPG instruction
672#
673 mvc __LC_PGM_NEW_PSW(8),.Lpcmvpg-.LPG1(%r13)
674 sr %r0,%r0
675 la %r1,0
676 la %r2,0
677 mvpg %r1,%r2 # Test CSP instruction
678 oi 3(%r12),16 # set MVPG flag
679.Lchkmvpg:
680
681#
682# find out if we have the IDTE instruction
683#
684 mvc __LC_PGM_NEW_PSW(8),.Lpcidte-.LPG1(%r13)
685 .long 0xb2b10000 # store facility list
686 tm 0xc8,0x08 # check bit for clearing-by-ASCE
687 bno .Lchkidte-.LPG1(%r13)
688 lhi %r1,2094
689 lhi %r2,0
690 .long 0xb98e2001
691 oi 3(%r12),0x80 # set IDTE flag
692.Lchkidte:
693
694 lpsw .Lentry-.LPG1(13) # jump to _stext in primary-space,
695 # virtual and never return ...
696 .align 8
697.Lentry:.long 0x00080000,0x80000000 + _stext
698.Lctl: .long 0x04b50002 # cr0: various things
699 .long 0 # cr1: primary space segment table
700 .long .Lduct # cr2: dispatchable unit control table
701 .long 0 # cr3: instruction authorization
702 .long 0 # cr4: instruction authorization
703 .long 0xffffffff # cr5: primary-aste origin
704 .long 0 # cr6: I/O interrupts
705 .long 0 # cr7: secondary space segment table
706 .long 0 # cr8: access registers translation
707 .long 0 # cr9: tracing off
708 .long 0 # cr10: tracing off
709 .long 0 # cr11: tracing off
710 .long 0 # cr12: tracing off
711 .long 0 # cr13: home space segment table
712 .long 0xc0000000 # cr14: machine check handling off
713 .long 0 # cr15: linkage stack operations
714.Lpcmem:.long 0x00080000,0x80000000 + .Lchkmem
715.Lpcfpu:.long 0x00080000,0x80000000 + .Lchkfpu
716.Lpccsp:.long 0x00080000,0x80000000 + .Lchkcsp
717.Lpcmvpg:.long 0x00080000,0x80000000 + .Lchkmvpg
718.Lpcidte:.long 0x00080000,0x80000000 + .Lchkidte
719.Lmemsize:.long memory_size
720.Lmchunk:.long memory_chunk
721.Lmflags:.long machine_flags
722.Lbss_bgn: .long __bss_start
723.Lbss_end: .long _end
724
725 .org PARMAREA-64
726.Lduct: .long 0,0,0,0,0,0,0,0
727 .long 0,0,0,0,0,0,0,0
728
729#
730# params at 10400 (setup.h)
731#
732 .org PARMAREA
733 .global _pstart
734_pstart:
735 .long 0,0 # IPL_DEVICE
736 .long 0,RAMDISK_ORIGIN # INITRD_START
737 .long 0,RAMDISK_SIZE # INITRD_SIZE
738
739 .org COMMAND_LINE
740 .byte "root=/dev/ram0 ro"
741 .byte 0
742 .org 0x11000
743.Lsccb:
744 .hword 0x1000 # length, one page
745 .byte 0x00,0x00,0x00
746 .byte 0x80 # variable response bit set
747.Lsccbr:
748 .hword 0x00 # response code
749.Lscpincr1:
750 .hword 0x00
751.Lscpa1:
752 .byte 0x00
753 .fill 89,1,0
754.Lscpa2:
755 .int 0x00
756.Lscpincr2:
757 .quad 0x00
758 .fill 3984,1,0
759 .org 0x12000
760 .global _pend
761_pend:
762
763.Lget_ipl_device: 484.Lget_ipl_device:
764 basr %r12,0 485 basr %r12,0
765.LPG2: l %r1,0xb8 # get sid 486.LGID: l %r1,0xb8 # get sid
766 sll %r1,15 # test if subchannel is enabled 487 sll %r1,15 # test if subchannel is enabled
767 srl %r1,31 488 srl %r1,31
768 ltr %r1,%r1 489 ltr %r1,%r1
769 bz 0(%r14) # subchannel disabled 490 bz 0(%r14) # subchannel disabled
770 l %r1,0xb8 491 l %r1,0xb8
771 la %r5,.Lipl_schib-.LPG2(%r12) 492 la %r5,.Lipl_schib-.LGID(%r12)
772 stsch 0(%r5) # get schib of subchannel 493 stsch 0(%r5) # get schib of subchannel
773 bnz 0(%r14) # schib not available 494 bnz 0(%r14) # schib not available
774 tm 5(%r5),0x01 # devno valid? 495 tm 5(%r5),0x01 # devno valid?
775 bno 0(%r14) 496 bno 0(%r14)
776 la %r6,ipl_parameter_flags-.LPG2(%r12) 497 la %r6,ipl_parameter_flags-.LGID(%r12)
777 oi 3(%r6),0x01 # set flag 498 oi 3(%r6),0x01 # set flag
778 la %r2,ipl_devno-.LPG2(%r12) 499 la %r2,ipl_devno-.LGID(%r12)
779 mvc 0(2,%r2),6(%r5) # store devno 500 mvc 0(2,%r2),6(%r5) # store devno
780 tm 4(%r5),0x80 # qdio capable device? 501 tm 4(%r5),0x80 # qdio capable device?
781 bno 0(%r14) 502 bno 0(%r14)
@@ -816,46 +537,10 @@ ipl_parameter_flags:
816 .globl ipl_devno 537 .globl ipl_devno
817ipl_devno: 538ipl_devno:
818 .word 0 539 .word 0
540.endm
819 541
820#ifdef CONFIG_SHARED_KERNEL 542#ifdef CONFIG_ARCH_S390X
821 .org 0x100000 543#include "head64.S"
544#else
545#include "head31.S"
822#endif 546#endif
823
824#
825# startup-code, running in virtual mode
826#
827 .globl _stext
828_stext: basr %r13,0 # get base
829.LPG3:
830#
831# Setup stack
832#
833 l %r15,.Linittu-.LPG3(%r13)
834 mvc __LC_CURRENT(4),__TI_task(%r15)
835 ahi %r15,1<<(PAGE_SHIFT+THREAD_ORDER) # init_task_union + THREAD_SIZE
836 st %r15,__LC_KERNEL_STACK # set end of kernel stack
837 ahi %r15,-96
838 xc __SF_BACKCHAIN(4,%r15),__SF_BACKCHAIN(%r15) # clear backchain
839
840# check control registers
841 stctl %c0,%c15,0(%r15)
842 oi 2(%r15),0x40 # enable sigp emergency signal
843 oi 0(%r15),0x10 # switch on low address protection
844 lctl %c0,%c15,0(%r15)
845
846#
847 lam 0,15,.Laregs-.LPG3(%r13) # load access regs needed by uaccess
848 l %r14,.Lstart-.LPG3(%r13)
849 basr %r14,%r14 # call start_kernel
850#
851# We returned from start_kernel ?!? PANIK
852#
853 basr %r13,0
854 lpsw .Ldw-.(%r13) # load disabled wait psw
855#
856 .align 8
857.Ldw: .long 0x000a0000,0x00000000
858.Linittu: .long init_thread_union
859.Lstart: .long start_kernel
860.Laregs: .long 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
861