Merge branch 'akpm'
[linux-2.6/next.git] / arch / s390 / kernel / head_kdump.S
blob9d5ed9eacb5d659645568b2d6417b3ad85fa7889
1 /*
2  * S390 kdump lowlevel functions (new kernel)
3  *
4  * Copyright IBM Corp. 2011
5  * Author(s): Michael Holzheu <holzheu@linux.vnet.ibm.com>
6  */
8 #define DATAMOVER_ADDR  0x4000
9 #define COPY_PAGE_ADDR  0x6000
11 #ifdef CONFIG_CRASH_DUMP
14 # kdump entry (new kernel - not yet relocated)
16 # Note: This code has to be position independent
19 .align 2
20 .Lep_startup_kdump:
21         basr    %r13,0
22 .Lbase:
23         larl    %r2,.Lbase_addr                 # Check, if we have been
24         lg      %r2,0(%r2)                      # already relocated:
25         clgr    %r2,%r13                        #
26         jne     .Lrelocate                      # No : Start data mover
27         lghi    %r2,0                           # Yes: Start kdump kernel
28         brasl   %r14,startup_kdump_relocated
30 .Lrelocate:
31         larl    %r4,startup
32         lg      %r2,0x418(%r4)                  # Get kdump base
33         lg      %r3,0x420(%r4)                  # Get kdump size
35         larl    %r10,.Lcopy_start               # Source of data mover
36         lghi    %r8,DATAMOVER_ADDR              # Target of data mover
37         mvc     0(256,%r8),0(%r10)              # Copy data mover code
39         agr     %r8,%r2                         # Copy data mover to
40         mvc     0(256,%r8),0(%r10)              # reserved mem
42         lghi    %r14,DATAMOVER_ADDR             # Jump to copied data mover
43         basr    %r14,%r14
44 .Lbase_addr:
45         .quad   .Lbase
48 # kdump data mover code (runs at address DATAMOVER_ADDR)
50 # r2: kdump base address
51 # r3: kdump size
53 .Lcopy_start:
54         basr    %r13,0                          # Base
56         lgr     %r11,%r2                        # Save kdump base address
57         lgr     %r12,%r2
58         agr     %r12,%r3                        # Compute kdump end address
60         lghi    %r5,0
61         lghi    %r10,COPY_PAGE_ADDR             # Load copy page address
63         mvc     0(256,%r10),0(%r5)              # Copy old kernel to tmp
64         mvc     0(256,%r5),0(%r11)              # Copy new kernel to old
65         mvc     0(256,%r11),0(%r10)             # Copy tmp to new
66         aghi    %r11,256
67         aghi    %r5,256
68         clgr    %r11,%r12
69         jl      1b
71         lg      %r14,.Lstartup_kdump-0b(%r13)
72         basr    %r14,%r14                       # Start relocated kernel
73 .Lstartup_kdump:
74         .long   0x00000000,0x00000000 + startup_kdump_relocated
75 .Lcopy_end:
78 # Startup of kdump (relocated new kernel)
80 .align 2
81 startup_kdump_relocated:
82         basr    %r13,0
84         mvc     0(8,%r0),.Lrestart_psw-0b(%r13) # Setup restart PSW
85         mvc     464(16,%r0),.Lpgm_psw-0b(%r13)  # Setup pgm check PSW
86         lhi     %r1,1                           # Start new kernel
87         diag    %r1,%r1,0x308                   # with diag 308
89 .Lno_diag308:                                   # No diag 308
90         sam31                                   # Switch to 31 bit addr mode
91         sr      %r1,%r1                         # Erase register r1
92         sr      %r2,%r2                         # Erase register r2
93         sigp    %r1,%r2,0x12                    # Switch to 31 bit arch mode
94         lpsw    0                               # Start new kernel...
95 .align  8
96 .Lrestart_psw:
97         .long   0x00080000,0x80000000 + startup
98 .Lpgm_psw:
99         .quad   0x0000000180000000,0x0000000000000000 + .Lno_diag308
100 #else
101 .align 2
102 .Lep_startup_kdump:
103 #ifdef CONFIG_64BIT
104         larl    %r13,startup_kdump_crash
105         lpswe   0(%r13)
106 .align 8
107 startup_kdump_crash:
108         .quad   0x0002000080000000,0x0000000000000000 + startup_kdump_crash
109 #else
110         basr    %r13,0
111 0:      lpsw    startup_kdump_crash-0b(%r13)
112 .align 8
113 startup_kdump_crash:
114         .long   0x000a0000,0x00000000 + startup_kdump_crash
115 #endif /* CONFIG_64BIT */
116 #endif /* CONFIG_CRASH_DUMP */