mips_excpt_gcc.S 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /*
  2. * File : mips_excpt_asm.S
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2008 - 2012, RT-Thread Development Team
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along
  17. * with this program; if not, write to the Free Software Foundation, Inc.,
  18. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  19. *
  20. * Change Logs:
  21. * Date Author Notes
  22. * 2016年9月7日 Urey the first version
  23. */
  24. #ifndef __ASSEMBLY__
  25. # define __ASSEMBLY__
  26. #endif
  27. #include "../common/mips.h"
  28. #define _EXC_STKSIZE 20*1024
  29. ;/*********************************************************************************************************
  30. ; PTE BASE 相关定义
  31. ;*********************************************************************************************************/
  32. #define PTE_BASE_OFFSET 23
  33. #define PTE_BASE_SIZE 9
  34. #define MIPS32_BADVPN2_SHIFT 2
  35. .section ".text", "ax"
  36. .set noreorder
  37. LEAF(mips_tlb_refill_handlerx)
  38. .set push
  39. .set noat
  40. .set noreorder
  41. .set volatile
  42. ;/*
  43. ; * K1 = CP0_CTXT
  44. ; * K0 = K1
  45. ; */
  46. mfc0 k1 , CP0_CONTEXT ;/* K1 等于 Context 寄存器 */
  47. ehb
  48. move k0 , k1 ;/* K0 等于 Context 寄存器 */
  49. ;/*
  50. ; * K1 <<= PTE_BASE_SIZE
  51. ; * K1 >>= PTE_BASE_SIZE
  52. ; * K1 >>= 4
  53. ; * K1 >>= MIPS32_BADVPN2_SHIFT
  54. ; * K1 <<= 3
  55. ; */
  56. sll k1 , PTE_BASE_SIZE
  57. srl k1 , (PTE_BASE_SIZE + 4 + MIPS32_BADVPN2_SHIFT) ;/* K1 为 BAD VPN2 */
  58. sll k1 , (4 - 1)
  59. ;/*
  60. ; * K0 >>= PTE_BASE_OFFSET
  61. ; * K0 <<= PTE_BASE_OFFSET
  62. ; */
  63. srl k0 , PTE_BASE_OFFSET
  64. sll k0 , PTE_BASE_OFFSET ;/* K0 为 PTE BASE */
  65. ;/*
  66. ; * K1 = K1 | K0
  67. ; */
  68. or k1 , k1 , k0 ;/* 合成 */
  69. ;/*
  70. ; * K0 = *K1
  71. ; * K1 = *(K1 + 4)
  72. ; */
  73. lw k0 , 0(k1)
  74. lw k1 , 4(k1)
  75. ;/*
  76. ; * CP0_TLBLO0 = K0
  77. ; * CP0_TLBLO1 = K1
  78. ; */
  79. mtc0 k0 , CP0_ENTRYLO0 ;/* EntryLo0 */
  80. mtc0 k1 , CP0_ENTRYLO1 ;/* EntryLo1 */
  81. ehb
  82. tlbwr ;/* TLB 随机替换 */
  83. eret ;/* 异常返回 */
  84. .set pop
  85. END(mips_tlb_refill_handlerx)