relocate_kernel64.S 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. * arch/s390/kernel/relocate_kernel64.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. *
  20. * 0xf000 is a page_mask
  21. */
  22. .text
  23. .globl relocate_kernel
  24. relocate_kernel:
  25. basr %r13,0 #base address
  26. .base:
  27. spx zero64-.base(%r13) #absolute addressing mode
  28. stnsm sys_msk-.base(%r13),0xf8 #disable DAT and IRQ (external)
  29. .top:
  30. lghi %r7,4096 #load PAGE_SIZE in r7
  31. lghi %r9,4096 #load PAGE_SIZE in r9
  32. lg %r5,0(%r2) #read another word for indirection page
  33. aghi %r2,8 #increment pointer
  34. tml %r5,0x1 #is it a destination page?
  35. je .indir_check #NO, goto "indir_check"
  36. lgr %r6,%r5 #r6 = r5
  37. nill %r6,0xf000 #mask it out and...
  38. j .top #...next iteration
  39. .indir_check:
  40. tml %r5,0x2 #is it a indirection page?
  41. je .done_test #NO, goto "done_test"
  42. nill %r5,0xf000 #YES, mask out,
  43. lgr %r2,%r5 #move it into the right register,
  44. j .top #and read next...
  45. .done_test:
  46. tml %r5,0x4 #is it the done indicator?
  47. je .source_test #NO! Well, then it should be the source indicator...
  48. j .done #ok, lets finish it here...
  49. .source_test:
  50. tml %r5,0x8 #it should be a source indicator...
  51. je .top #NO, ignore it...
  52. lgr %r8,%r5 #r8 = r5
  53. nill %r8,0xf000 #masking
  54. 0: mvcle %r6,%r8,0x0 #copy PAGE_SIZE bytes from r8 to r6 - pad with 0
  55. jo 0b
  56. j .top
  57. .done:
  58. sgr %r0,%r0 #clear register r0
  59. la %r4,load_psw-.base(%r13) #load psw-address into the register
  60. o %r3,4(%r4) #or load address into psw
  61. st %r3,4(%r4)
  62. mvc 0(8,%r0),0(%r4) #copy psw to absolute address 0
  63. sam31 #31 bit mode
  64. sr %r1,%r1 #erase register r1
  65. sr %r2,%r2 #erase register 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