ipldump.S
上传用户:lgb322
上传日期:2013-02-24
资源大小:30529k
文件大小:5k
源码类别:

嵌入式Linux

开发平台:

Unix_Linux

  1. /*
  2.  *  arch/s390/boot/ipldump.S
  3.  *
  4.  *  S390 version
  5.  *    Copyright (C) 2000 IBM Deutschland Entwicklung GmbH, IBM Corporation
  6.  *    Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com),
  7.  *
  8.  *  Tape dump ipl record. Put it on a tape and ipl from it and it will
  9.  *  write a dump of the real storage after the ipl record on that tape.
  10.  */
  11. #include <asm/setup.h>
  12. #include <asm/lowcore.h>
  13. #define IPL_BS 1024
  14.         .org   0
  15.         .long  0x00080000,0x80000000+_start    # The first 24 bytes are loaded
  16.         .long  0x07000000,0x60000001           # by ipl to addresses 0-23.
  17.         .long  0x02000000,0x20000000+IPL_BS    # (a PSW and two CCWs).
  18.         .long  0x00000000,0x00000000
  19.         .long  0x00000000,0x00000000           # svc old psw
  20.         .long  0x00000000,0x00000000           # program check old psw
  21.         .long  0x00000000,0x00000000           # machine check old psw
  22.         .long  0x00000000,0x00000000           # io old psw
  23.         .long  0x00000000,0x00000000
  24.         .long  0x00000000,0x00000000
  25.         .long  0x00000000,0x00000000
  26.         .long  0x000a0000,0x00000058           # external new psw
  27.         .long  0x000a0000,0x00000060           # svc new psw
  28.         .long  0x000a0000,0x00000068           # program check new psw
  29.         .long  0x000a0000,0x00000070           # machine check new psw
  30.         .long  0x00080000,0x80000000+.Lioint   # io new psw
  31.         .org   0x100
  32.         .globl _start
  33. _start:
  34. l     %r1,0xb8                         # load ipl subchannel number
  35. #
  36. # find out memory size
  37. #
  38.         mvc   104(8),.Lpcmem0          # setup program check handler
  39.         slr   %r3,%r3
  40.         lhi   %r2,1
  41.         sll   %r2,20
  42. .Lloop0:
  43.         l     %r0,0(%r3)                 # test page
  44.         ar    %r3,%r2                    # add 1M
  45.         jnm   .Lloop0                    # r1 < 0x80000000 -> loop
  46. .Lchkmem0:
  47.         n     %r3,.L4malign0             # align to multiples of 4M
  48.         st    %r3,.Lmemsize              # store memory size
  49. .Lmemok:
  50. #
  51. # first write a tape mark
  52. #
  53.         bras  %r14,.Ltapemark
  54. #
  55. # write real storage to tape
  56. #
  57.   slr   %r2,%r2                          # start at address 0
  58.         bras  %r14,.Lwriter                    # load ramdisk
  59. #
  60. # write another tape mark
  61. #
  62.         bras  %r14,.Ltapemark
  63. #
  64. # everything written, stop processor
  65. #
  66.         lpsw  .Lstopped
  67. #
  68. # subroutine for writing to tape
  69. # Paramters:
  70. #  R1 = device number
  71. #  R2 = start address
  72. #  R3 = length
  73. .Lwriter:
  74.         st    %r14,.Lldret
  75.         la    %r12,.Lorbread                   # r12 = address of orb 
  76. la    %r5,.Lirb                        # r5 = address of irb
  77.         st    %r2,.Lccwwrite+4                 # initialize CCW data addresses
  78.         lctl  %c6,%c6,.Lcr6               
  79.         slr   %r2,%r2
  80. .Lldlp:
  81.         lhi   %r6,3                            # 3 retries
  82. .Lssch:
  83.         ssch  0(%r12)                          # write chunk of IPL_BS bytes
  84.         jnz   .Llderr
  85. .Lw4end:
  86.         bras  %r14,.Lwait4io
  87.         tm    8(%r5),0x82                      # do we have a problem ?
  88.         jnz   .Lrecov
  89.         l     %r0,.Lccwwrite+4                 # update CCW data addresses
  90.         ahi   %r0,IPL_BS
  91.         st    %r0,.Lccwwrite+4
  92.         clr   %r0,%r3                          # enough ?
  93.         jl    .Lldlp
  94. .Ldone:
  95.         l     %r14,.Lldret
  96.         br    %r14                             # r2 contains the total size
  97. .Lrecov:
  98.         bras  %r14,.Lsense                     # do the sensing
  99.         brct  %r6,.Lssch                       # dec. retry count & branch
  100.         j     .Llderr
  101. .Ltapemark:
  102.         st    %r14,.Lldret
  103.         la    %r12,.Lorbmark                   # r12 = address of orb
  104.         la    %r5,.Lirb                        # r5 = address of irb
  105.         lctl  %c6,%c6,.Lcr6
  106.         ssch  0(%r12)                          # write a tape mark
  107.         jnz   .Llderr
  108.         bras  %r14,.Lwait4io
  109.         l     %r14,.Lldret
  110.         br    %r14
  111. #
  112. # Sense subroutine
  113. #
  114. .Lsense:
  115.         st    %r14,.Lsnsret
  116.         la    %r7,.Lorbsense              
  117.         ssch  0(%r7)                           # start sense command
  118.         jnz   .Llderr
  119.         bras  %r14,.Lwait4io
  120.         l     %r14,.Lsnsret
  121.         tm    8(%r5),0x82                      # do we have a problem ?
  122.         jnz   .Llderr
  123.         br    %r14
  124. #
  125. # Wait for interrupt subroutine
  126. #
  127. .Lwait4io:
  128.         lpsw  .Lwaitpsw                 
  129. .Lioint:
  130.         c     %r1,0xb8                         # compare subchannel number
  131.         jne   .Lwait4io
  132.         tsch  0(%r5)
  133.         slr   %r0,%r0
  134.         tm    8(%r5),0x82                      # do we have a problem ?
  135.         jnz   .Lwtexit
  136.         tm    8(%r5),0x04                      # got device end ?
  137.         jz    .Lwait4io
  138. .Lwtexit:
  139.         br    %r14
  140. .Llderr:
  141.         lpsw  .Lcrash              
  142.         .align 8
  143. .Lorbread:
  144. .long  0x00000000,0x0080ff00,.Lccwwrite
  145.         .align 8
  146. .Lorbsense:
  147.         .long  0x00000000,0x0080ff00,.Lccwsense
  148.         .align 8
  149. .Lorbmark:
  150.         .long  0x00000000,0x0080ff00,.Lccwmark
  151.         .align 8
  152. .Lccwwrite:
  153.         .long  0x01200000+IPL_BS,0x00000000
  154. .Lccwsense:
  155.         .long  0x04200001,0x00000000
  156. .Lccwmark:
  157.         .long  0x1f200001,0x00000000
  158. .Lwaitpsw:
  159. .long  0x020a0000,0x80000000+.Lioint
  160. .Lirb: .long  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  161. .Lcr6:  .long  0xff000000
  162.         .align 8
  163. .Lcrash:.long  0x000a0000,0x00000000
  164. .Lstopped: .long 0x000a0000,0x00001234
  165. .Lpcmem0:.long  0x00080000,0x80000000 + .Lchkmem0
  166. .L4malign0:.long 0xffc00000
  167. .Lmemsize:.long 0
  168. .Lldret:.long  0
  169. .Lsnsret: .long 0
  170.          .org IPL_BS