tlb-mmu1.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /*
  2. * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 as
  6. * published by the Free Software Foundation.
  7. */
  8. #ifndef __ASM_TLB_MMU_V1_H__
  9. #define __ASM_TLB_MMU_V1_H__
  10. #include <asm/mmu.h>
  11. #if defined(__ASSEMBLY__) && (CONFIG_ARC_MMU_VER == 1)
  12. .macro TLB_WRITE_HEURISTICS
  13. #define JH_HACK1
  14. #undef JH_HACK2
  15. #undef JH_HACK3
  16. #ifdef JH_HACK3
  17. ; Calculate set index for 2-way MMU
  18. ; -avoiding use of GetIndex from MMU
  19. ; and its unpleasant LFSR pseudo-random sequence
  20. ;
  21. ; r1 = TLBPD0 from TLB_RELOAD above
  22. ;
  23. ; -- jh_ex_way_set not cleared on startup
  24. ; didn't want to change setup.c
  25. ; hence extra instruction to clean
  26. ;
  27. ; -- should be in cache since in same line
  28. ; as r0/r1 saves above
  29. ;
  30. ld r0,[jh_ex_way_sel] ; victim pointer
  31. and r0,r0,1 ; clean
  32. xor.f r0,r0,1 ; flip
  33. st r0,[jh_ex_way_sel] ; store back
  34. asr r0,r1,12 ; get set # <<1, note bit 12=R=0
  35. or.nz r0,r0,1 ; set way bit
  36. and r0,r0,0xff ; clean
  37. sr r0,[ARC_REG_TLBINDEX]
  38. #endif
  39. #ifdef JH_HACK2
  40. ; JH hack #2
  41. ; Faster than hack #1 in non-thrash case, but hard-coded for 2-way MMU
  42. ; Slower in thrash case (where it matters) because more code is executed
  43. ; Inefficient due to two-register paradigm of this miss handler
  44. ;
  45. /* r1 = data TLBPD0 at this point */
  46. lr r0,[eret] /* instruction address */
  47. xor r0,r0,r1 /* compare set # */
  48. and.f r0,r0,0x000fe000 /* 2-way MMU mask */
  49. bne 88f /* not in same set - no need to probe */
  50. lr r0,[eret] /* instruction address */
  51. and r0,r0,PAGE_MASK /* VPN of instruction address */
  52. ; lr r1,[ARC_REG_TLBPD0] /* Data VPN+ASID - already in r1 from TLB_RELOAD*/
  53. and r1,r1,0xff /* Data ASID */
  54. or r0,r0,r1 /* Instruction address + Data ASID */
  55. lr r1,[ARC_REG_TLBPD0] /* save TLBPD0 containing data TLB*/
  56. sr r0,[ARC_REG_TLBPD0] /* write instruction address to TLBPD0 */
  57. sr TLBProbe, [ARC_REG_TLBCOMMAND] /* Look for instruction */
  58. lr r0,[ARC_REG_TLBINDEX] /* r0 = index where instruction is, if at all */
  59. sr r1,[ARC_REG_TLBPD0] /* restore TLBPD0 */
  60. xor r0,r0,1 /* flip bottom bit of data index */
  61. b.d 89f
  62. sr r0,[ARC_REG_TLBINDEX] /* and put it back */
  63. 88:
  64. sr TLBGetIndex, [ARC_REG_TLBCOMMAND]
  65. 89:
  66. #endif
  67. #ifdef JH_HACK1
  68. ;
  69. ; Always checks whether instruction will be kicked out by dtlb miss
  70. ;
  71. mov_s r3, r1 ; save PD0 prepared by TLB_RELOAD in r3
  72. lr r0,[eret] /* instruction address */
  73. and r0,r0,PAGE_MASK /* VPN of instruction address */
  74. bmsk r1,r3,7 /* Data ASID, bits 7-0 */
  75. or_s r0,r0,r1 /* Instruction address + Data ASID */
  76. sr r0,[ARC_REG_TLBPD0] /* write instruction address to TLBPD0 */
  77. sr TLBProbe, [ARC_REG_TLBCOMMAND] /* Look for instruction */
  78. lr r0,[ARC_REG_TLBINDEX] /* r0 = index where instruction is, if at all */
  79. sr r3,[ARC_REG_TLBPD0] /* restore TLBPD0 */
  80. sr TLBGetIndex, [ARC_REG_TLBCOMMAND]
  81. lr r1,[ARC_REG_TLBINDEX] /* r1 = index where MMU wants to put data */
  82. cmp r0,r1 /* if no match on indices, go around */
  83. xor.eq r1,r1,1 /* flip bottom bit of data index */
  84. sr r1,[ARC_REG_TLBINDEX] /* and put it back */
  85. #endif
  86. .endm
  87. #endif
  88. #endif