aboutsummaryrefslogtreecommitdiffstats
path: root/arch/s390/kernel/head.S
diff options
context:
space:
mode:
authorHeiko Carstens <heiko.carstens@de.ibm.com>2005-11-07 03:59:12 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2005-11-07 10:53:34 -0500
commit0ad775dbba12de3b7d25f586efe81ad995ca75a7 (patch)
tree4fb33dc988fde1c8fc9088b40c62002fa4793aa2 /arch/s390/kernel/head.S
parenta5da866fe0272db6b664d4c790ad98320bf2feb6 (diff)
[PATCH] s390: merge common parts of head.S and head64.S
Merge common parts of head.S and head64.S into head.S and move architecture specific parts to head31.S and head64.S respectively. Saves us ~500 lines of duplicated assembly code. Acked-by: Martin Schwidefsky <schwidefsky@de.ibm.com> Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch/s390/kernel/head.S')
-rw-r--r--arch/s390/kernel/head.S382
1 files changed, 34 insertions, 348 deletions
diff --git a/arch/s390/kernel/head.S b/arch/s390/kernel/head.S
index 4ca029332114..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,303 +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 0x010a0000,0x80000000 + .Lsclph
576.Lrcp:
577 .int 0x00120001 # Read SCP forced code
578.Lrcp2:
579 .int 0x00020001 # Read SCP code
580.Lonemb:
581 .int 0x100000
582.Lfchunk:
583
584#
585# find memory chunks.
586#
587 lr %r9,%r3 # end of mem
588 mvc __LC_PGM_NEW_PSW(8),.Lpcmem-.LPG1(%r13)
589 la %r1,1 # test in increments of 128KB
590 sll %r1,17
591 l %r3,.Lmchunk-.LPG1(%r13) # get pointer to memory_chunk array
592 slr %r4,%r4 # set start of chunk to zero
593 slr %r5,%r5 # set end of chunk to zero
594 slr %r6,%r6 # set access code to zero
595 la %r10, MEMORY_CHUNKS # number of chunks
596.Lloop:
597 tprot 0(%r5),0 # test protection of first byte
598 ipm %r7
599 srl %r7,28
600 clr %r6,%r7 # compare cc with last access code
601 be .Lsame-.LPG1(%r13)
602 b .Lchkmem-.LPG1(%r13)
603.Lsame:
604 ar %r5,%r1 # add 128KB to end of chunk
605 bno .Lloop-.LPG1(%r13) # r1 < 0x80000000 -> loop
606.Lchkmem: # > 2GB or tprot got a program check
607 clr %r4,%r5 # chunk size > 0?
608 be .Lchkloop-.LPG1(%r13)
609 st %r4,0(%r3) # store start address of chunk
610 lr %r0,%r5
611 slr %r0,%r4
612 st %r0,4(%r3) # store size of chunk
613 st %r6,8(%r3) # store type of chunk
614 la %r3,12(%r3)
615 l %r4,.Lmemsize-.LPG1(%r13) # address of variable memory_size
616 st %r5,0(%r4) # store last end to memory size
617 ahi %r10,-1 # update chunk number
618.Lchkloop:
619 lr %r6,%r7 # set access code to last cc
620 # we got an exception or we're starting a new
621 # chunk , we must check if we should
622 # still try to find valid memory (if we detected
623 # the amount of available storage), and if we
624 # have chunks left
625 xr %r0,%r0
626 clr %r0,%r9 # did we detect memory?
627 je .Ldonemem # if not, leave
628 chi %r10,0 # do we have chunks left?
629 je .Ldonemem
630 alr %r5,%r1 # add 128KB to end of chunk
631 lr %r4,%r5 # potential new chunk
632 clr %r5,%r9 # should we go on?
633 jl .Lloop
634.Ldonemem:
635 l %r12,.Lmflags-.LPG1(%r13) # get address of machine_flags
636#
637# find out if we are running under VM
638#
639 stidp __LC_CPUID # store cpuid
640 tm __LC_CPUID,0xff # running under VM ?
641 bno .Lnovm-.LPG1(%r13)
642 oi 3(%r12),1 # set VM flag
643.Lnovm:
644 lh %r0,__LC_CPUID+4 # get cpu version
645 chi %r0,0x7490 # running on a P/390 ?
646 bne .Lnop390-.LPG1(%r13)
647 oi 3(%r12),4 # set P/390 flag
648.Lnop390:
649
650#
651# find out if we have an IEEE fpu
652#
653 mvc __LC_PGM_NEW_PSW(8),.Lpcfpu-.LPG1(%r13)
654 efpc %r0,0 # test IEEE extract fpc instruction
655 oi 3(%r12),2 # set IEEE fpu flag
656.Lchkfpu:
657
658#
659# find out if we have the CSP instruction
660#
661 mvc __LC_PGM_NEW_PSW(8),.Lpccsp-.LPG1(%r13)
662 la %r0,0
663 lr %r1,%r0
664 la %r2,4
665 csp %r0,%r2 # Test CSP instruction
666 oi 3(%r12),8 # set CSP flag
667.Lchkcsp:
668
669#
670# find out if we have the MVPG instruction
671#
672 mvc __LC_PGM_NEW_PSW(8),.Lpcmvpg-.LPG1(%r13)
673 sr %r0,%r0
674 la %r1,0
675 la %r2,0
676 mvpg %r1,%r2 # Test CSP instruction
677 oi 3(%r12),16 # set MVPG flag
678.Lchkmvpg:
679
680#
681# find out if we have the IDTE instruction
682#
683 mvc __LC_PGM_NEW_PSW(8),.Lpcidte-.LPG1(%r13)
684 .long 0xb2b10000 # store facility list
685 tm 0xc8,0x08 # check bit for clearing-by-ASCE
686 bno .Lchkidte-.LPG1(%r13)
687 lhi %r1,2094
688 lhi %r2,0
689 .long 0xb98e2001
690 oi 3(%r12),0x80 # set IDTE flag
691.Lchkidte:
692
693 lpsw .Lentry-.LPG1(13) # jump to _stext in primary-space,
694 # virtual and never return ...
695 .align 8
696.Lentry:.long 0x00080000,0x80000000 + _stext
697.Lctl: .long 0x04b50002 # cr0: various things
698 .long 0 # cr1: primary space segment table
699 .long .Lduct # cr2: dispatchable unit control table
700 .long 0 # cr3: instruction authorization
701 .long 0 # cr4: instruction authorization
702 .long 0xffffffff # cr5: primary-aste origin
703 .long 0 # cr6: I/O interrupts
704 .long 0 # cr7: secondary space segment table
705 .long 0 # cr8: access registers translation
706 .long 0 # cr9: tracing off
707 .long 0 # cr10: tracing off
708 .long 0 # cr11: tracing off
709 .long 0 # cr12: tracing off
710 .long 0 # cr13: home space segment table
711 .long 0xc0000000 # cr14: machine check handling off
712 .long 0 # cr15: linkage stack operations
713.Lpcmem:.long 0x00080000,0x80000000 + .Lchkmem
714.Lpcfpu:.long 0x00080000,0x80000000 + .Lchkfpu
715.Lpccsp:.long 0x00080000,0x80000000 + .Lchkcsp
716.Lpcmvpg:.long 0x00080000,0x80000000 + .Lchkmvpg
717.Lpcidte:.long 0x00080000,0x80000000 + .Lchkidte
718.Lmemsize:.long memory_size
719.Lmchunk:.long memory_chunk
720.Lmflags:.long machine_flags
721.Lbss_bgn: .long __bss_start
722.Lbss_end: .long _end
723
724 .org PARMAREA-64
725.Lduct: .long 0,0,0,0,0,0,0,0
726 .long 0,0,0,0,0,0,0,0
727
728#
729# params at 10400 (setup.h)
730#
731 .org PARMAREA
732 .global _pstart
733_pstart:
734 .long 0,0 # IPL_DEVICE
735 .long 0,RAMDISK_ORIGIN # INITRD_START
736 .long 0,RAMDISK_SIZE # INITRD_SIZE
737
738 .org COMMAND_LINE
739 .byte "root=/dev/ram0 ro"
740 .byte 0
741 .org 0x11000
742.Lsccb:
743 .hword 0x1000 # length, one page
744 .byte 0x00,0x00,0x00
745 .byte 0x80 # variable response bit set
746.Lsccbr:
747 .hword 0x00 # response code
748.Lscpincr1:
749 .hword 0x00
750.Lscpa1:
751 .byte 0x00
752 .fill 89,1,0
753.Lscpa2:
754 .int 0x00
755.Lscpincr2:
756 .quad 0x00
757 .fill 3984,1,0
758 .org 0x12000
759 .global _pend
760_pend:
761
762.Lget_ipl_device: 484.Lget_ipl_device:
763 basr %r12,0 485 basr %r12,0
764.LPG2: l %r1,0xb8 # get sid 486.LGID: l %r1,0xb8 # get sid
765 sll %r1,15 # test if subchannel is enabled 487 sll %r1,15 # test if subchannel is enabled
766 srl %r1,31 488 srl %r1,31
767 ltr %r1,%r1 489 ltr %r1,%r1
768 bz 0(%r14) # subchannel disabled 490 bz 0(%r14) # subchannel disabled
769 l %r1,0xb8 491 l %r1,0xb8
770 la %r5,.Lipl_schib-.LPG2(%r12) 492 la %r5,.Lipl_schib-.LGID(%r12)
771 stsch 0(%r5) # get schib of subchannel 493 stsch 0(%r5) # get schib of subchannel
772 bnz 0(%r14) # schib not available 494 bnz 0(%r14) # schib not available
773 tm 5(%r5),0x01 # devno valid? 495 tm 5(%r5),0x01 # devno valid?
774 bno 0(%r14) 496 bno 0(%r14)
775 la %r6,ipl_parameter_flags-.LPG2(%r12) 497 la %r6,ipl_parameter_flags-.LGID(%r12)
776 oi 3(%r6),0x01 # set flag 498 oi 3(%r6),0x01 # set flag
777 la %r2,ipl_devno-.LPG2(%r12) 499 la %r2,ipl_devno-.LGID(%r12)
778 mvc 0(2,%r2),6(%r5) # store devno 500 mvc 0(2,%r2),6(%r5) # store devno
779 tm 4(%r5),0x80 # qdio capable device? 501 tm 4(%r5),0x80 # qdio capable device?
780 bno 0(%r14) 502 bno 0(%r14)
@@ -815,46 +537,10 @@ ipl_parameter_flags:
815 .globl ipl_devno 537 .globl ipl_devno
816ipl_devno: 538ipl_devno:
817 .word 0 539 .word 0
540.endm
818 541
819#ifdef CONFIG_SHARED_KERNEL 542#ifdef CONFIG_ARCH_S390X
820 .org 0x100000 543#include "head64.S"
544#else
545#include "head31.S"
821#endif 546#endif
822
823#
824# startup-code, running in virtual mode
825#
826 .globl _stext
827_stext: basr %r13,0 # get base
828.LPG3:
829#
830# Setup stack
831#
832 l %r15,.Linittu-.LPG3(%r13)
833 mvc __LC_CURRENT(4),__TI_task(%r15)
834 ahi %r15,1<<(PAGE_SHIFT+THREAD_ORDER) # init_task_union + THREAD_SIZE
835 st %r15,__LC_KERNEL_STACK # set end of kernel stack
836 ahi %r15,-96
837 xc __SF_BACKCHAIN(4,%r15),__SF_BACKCHAIN(%r15) # clear backchain
838
839# check control registers
840 stctl %c0,%c15,0(%r15)
841 oi 2(%r15),0x40 # enable sigp emergency signal
842 oi 0(%r15),0x10 # switch on low address protection
843 lctl %c0,%c15,0(%r15)
844
845#
846 lam 0,15,.Laregs-.LPG3(%r13) # load access regs needed by uaccess
847 l %r14,.Lstart-.LPG3(%r13)
848 basr %r14,%r14 # call start_kernel
849#
850# We returned from start_kernel ?!? PANIK
851#
852 basr %r13,0
853 lpsw .Ldw-.(%r13) # load disabled wait psw
854#
855 .align 8
856.Ldw: .long 0x000a0000,0x00000000
857.Linittu: .long init_thread_union
858.Lstart: .long start_kernel
859.Laregs: .long 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
860