relocate_kernel.S 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright IBM Corp. 2005
  4. *
  5. * Author(s): Rolf Adelsberger,
  6. * Heiko Carstens <heiko.carstens@de.ibm.com>
  7. *
  8. */
  9. #include <linux/linkage.h>
  10. #include <asm/page.h>
  11. #include <asm/sigp.h>
  12. /*
  13. * moves the new kernel to its destination...
  14. * %r2 = pointer to first kimage_entry_t
  15. * %r3 = start address - where to jump to after the job is done...
  16. *
  17. * %r5 will be used as temp. storage
  18. * %r6 holds the destination address
  19. * %r7 = PAGE_SIZE
  20. * %r8 holds the source address
  21. * %r9 = PAGE_SIZE
  22. *
  23. * 0xf000 is a page_mask
  24. */
  25. .text
  26. ENTRY(relocate_kernel)
  27. basr %r13,0 # base address
  28. .base:
  29. lghi %r7,PAGE_SIZE # load PAGE_SIZE in r7
  30. lghi %r9,PAGE_SIZE # load PAGE_SIZE in r9
  31. lg %r5,0(%r2) # read another word for indirection page
  32. aghi %r2,8 # increment pointer
  33. tml %r5,0x1 # is it a destination page?
  34. je .indir_check # NO, goto "indir_check"
  35. lgr %r6,%r5 # r6 = r5
  36. nill %r6,0xf000 # mask it out and...
  37. j .base # ...next iteration
  38. .indir_check:
  39. tml %r5,0x2 # is it a indirection page?
  40. je .done_test # NO, goto "done_test"
  41. nill %r5,0xf000 # YES, mask out,
  42. lgr %r2,%r5 # move it into the right register,
  43. j .base # and read next...
  44. .done_test:
  45. tml %r5,0x4 # is it the done indicator?
  46. je .source_test # NO! Well, then it should be the source indicator...
  47. j .done # ok, lets finish it here...
  48. .source_test:
  49. tml %r5,0x8 # it should be a source indicator...
  50. je .base # NO, ignore it...
  51. lgr %r8,%r5 # r8 = r5
  52. nill %r8,0xf000 # masking
  53. 0: mvcle %r6,%r8,0x0 # copy PAGE_SIZE bytes from r8 to r6 - pad with 0
  54. jo 0b
  55. j .base
  56. .done:
  57. sgr %r0,%r0 # clear register r0
  58. la %r4,load_psw-.base(%r13) # load psw-address into the register
  59. o %r3,4(%r4) # or load address into psw
  60. st %r3,4(%r4)
  61. mvc 0(8,%r0),0(%r4) # copy psw to absolute address 0
  62. diag %r0,%r0,0x308
  63. .align 8
  64. load_psw:
  65. .long 0x00080000,0x80000000
  66. relocate_kernel_end:
  67. .align 8
  68. .globl relocate_kernel_len
  69. relocate_kernel_len:
  70. .quad relocate_kernel_end - relocate_kernel