relocate_kernel.S 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * arch/s390/kernel/relocate_kernel.S
  3. *
  4. * (C) Copyright IBM Corp. 2005
  5. *
  6. * Author(s): Rolf Adelsberger <adelsberger@de.ibm.com>
  7. *
  8. */
  9. /*
  10. * moves the new kernel to its destination...
  11. * %r2 = pointer to first kimage_entry_t
  12. * %r3 = start address - where to jump to after the job is done...
  13. *
  14. * %r5 will be used as temp. storage
  15. * %r6 holds the destination address
  16. * %r7 = PAGE_SIZE
  17. * %r8 holds the source address
  18. * %r9 = PAGE_SIZE
  19. * %r10 is a page mask
  20. */
  21. .text
  22. .globl relocate_kernel
  23. relocate_kernel:
  24. basr %r13,0 #base address
  25. .base:
  26. spx zero64-.base(%r13) #absolute addressing mode
  27. stnsm sys_msk-.base(%r13),0xf8 #disable DAT and IRQ (external)
  28. lhi %r10,-1 #preparing the mask
  29. sll %r10,12 #shift it such that it becomes 0xf000
  30. .top:
  31. lhi %r7,4096 #load PAGE_SIZE in r7
  32. lhi %r9,4096 #load PAGE_SIZE in r9
  33. l %r5,0(%r2) #read another word for indirection page
  34. ahi %r2,4 #increment pointer
  35. tml %r5,0x1 #is it a destination page?
  36. je .indir_check #NO, goto "indir_check"
  37. lr %r6,%r5 #r6 = r5
  38. nr %r6,%r10 #mask it out and...
  39. j .top #...next iteration
  40. .indir_check:
  41. tml %r5,0x2 #is it a indirection page?
  42. je .done_test #NO, goto "done_test"
  43. nr %r5,%r10 #YES, mask out,
  44. lr %r2,%r5 #move it into the right register,
  45. j .top #and read next...
  46. .done_test:
  47. tml %r5,0x4 #is it the done indicator?
  48. je .source_test #NO! Well, then it should be the source indicator...
  49. j .done #ok, lets finish it here...
  50. .source_test:
  51. tml %r5,0x8 #it should be a source indicator...
  52. je .top #NO, ignore it...
  53. lr %r8,%r5 #r8 = r5
  54. nr %r8,%r10 #masking
  55. 0: mvcle %r6,%r8,0x0 #copy PAGE_SIZE bytes from r8 to r6 - pad with 0
  56. jo 0b
  57. j .top
  58. .done:
  59. sr %r0,%r0 #clear register r0
  60. la %r4,load_psw-.base(%r13) #load psw-address into the register
  61. o %r3,4(%r4) #or load address into psw
  62. st %r3,4(%r4)
  63. mvc 0(8,%r0),0(%r4) #copy psw to absolute address 0
  64. sr %r1,%r1 #clear %r1
  65. sr %r2,%r2 #clear %r2
  66. sigp %r1,%r2,0x12 #set cpuid to zero
  67. lpsw 0 #hopefully start new kernel...
  68. .align 8
  69. zero64:
  70. .quad 0
  71. load_psw:
  72. .long 0x00080000,0x80000000
  73. sys_msk:
  74. .quad 0
  75. relocate_kernel_end:
  76. .globl relocate_kernel_len
  77. relocate_kernel_len:
  78. .quad relocate_kernel_end - relocate_kernel