octeon-wdt-nmi.S 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (C) 2007-2017 Cavium, Inc.
  4. */
  5. #include <asm/asm.h>
  6. #include <asm/regdef.h>
  7. #define CVMSEG_BASE -32768
  8. #define CVMSEG_SIZE 6912
  9. #define SAVE_REG(r) sd $r, CVMSEG_BASE + CVMSEG_SIZE - ((32 - r) * 8)($0)
  10. NESTED(octeon_wdt_nmi_stage2, 0, sp)
  11. .set push
  12. .set noreorder
  13. .set noat
  14. /* Clear Dcache so cvmseg works right. */
  15. cache 1,0($0)
  16. /* Use K0 to do a read/modify/write of CVMMEMCTL */
  17. dmfc0 k0, $11, 7
  18. /* Clear out the size of CVMSEG */
  19. dins k0, $0, 0, 6
  20. /* Set CVMSEG to its largest value */
  21. ori k0, k0, 0x1c0 | 54
  22. /* Store the CVMMEMCTL value */
  23. dmtc0 k0, $11, 7
  24. /*
  25. * Restore K0 from the debug scratch register, it was saved in
  26. * the boot-vector code.
  27. */
  28. dmfc0 k0, $31
  29. /*
  30. * Save all registers to the top CVMSEG. This shouldn't
  31. * corrupt any state used by the kernel. Also all registers
  32. * should have the value right before the NMI.
  33. */
  34. SAVE_REG(0)
  35. SAVE_REG(1)
  36. SAVE_REG(2)
  37. SAVE_REG(3)
  38. SAVE_REG(4)
  39. SAVE_REG(5)
  40. SAVE_REG(6)
  41. SAVE_REG(7)
  42. SAVE_REG(8)
  43. SAVE_REG(9)
  44. SAVE_REG(10)
  45. SAVE_REG(11)
  46. SAVE_REG(12)
  47. SAVE_REG(13)
  48. SAVE_REG(14)
  49. SAVE_REG(15)
  50. SAVE_REG(16)
  51. SAVE_REG(17)
  52. SAVE_REG(18)
  53. SAVE_REG(19)
  54. SAVE_REG(20)
  55. SAVE_REG(21)
  56. SAVE_REG(22)
  57. SAVE_REG(23)
  58. SAVE_REG(24)
  59. SAVE_REG(25)
  60. SAVE_REG(26)
  61. SAVE_REG(27)
  62. SAVE_REG(28)
  63. SAVE_REG(29)
  64. SAVE_REG(30)
  65. SAVE_REG(31)
  66. /* Write zero to all CVMSEG locations per Core-15169 */
  67. dli a0, CVMSEG_SIZE - (33 * 8)
  68. 1: sd zero, CVMSEG_BASE(a0)
  69. daddiu a0, a0, -8
  70. bgez a0, 1b
  71. nop
  72. /* Set the stack to begin right below the registers */
  73. dli sp, CVMSEG_BASE + CVMSEG_SIZE - (32 * 8)
  74. /* Load the address of the third stage handler */
  75. dla $25, octeon_wdt_nmi_stage3
  76. /* Call the third stage handler */
  77. jal $25
  78. /* a0 is the address of the saved registers */
  79. move a0, sp
  80. /* Loop forvever if we get here. */
  81. 2: b 2b
  82. nop
  83. .set pop
  84. END(octeon_wdt_nmi_stage2)