Advertisement
Guest User

OCINDEX Enable

a guest
Feb 27th, 2023
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.65 KB | None | 0 0
  1. !sh4WriteCCN also flushes and invalidates cache
  2. !I don't think sh4WriteCCN handles flushing/invalidation correctly when
  3. !OCRAM is enabled, but OCINDEX is better in every way, so there's never
  4. !a reason to use OCRAM.
  5. !
  6. !sh4WriteCCN(unsigned int new_ccn);
  7. !sh4EnableOCIndex(void);
  8. !sh4DisableOCIndex(void);
  9.  
  10. .globl _sh4DisableOCIndex
  11. .globl _sh4EnableOCIndex
  12. .globl _sh4WriteCCN
  13.  
  14. .set .LCCN_OIX, 0x80
  15. .set .LDATA_CACHELINE_CNT, 512
  16. .set .LCACHELINE_SIZE, 32
  17.  
  18. _sh4DisableOCIndex:
  19. !Get existing CCN and clear OIX bit, then call sh4WriteCCN
  20. mov.l .LCCN, r5
  21. mov.l @r5, r0
  22. or #.LCCN_OIX, r0 !Set OIX bit...
  23. bra 1f
  24. xor #.LCCN_OIX, r0 !...then reverse the OIX bit to clear it
  25.  
  26. _sh4EnableOCIndex:
  27. !Get existing CCN and set OIX bit, then call sh4WriteCCN
  28. mov.l .LCCN, r5
  29. mov.l @r5, r0
  30. or #.LCCN_OIX, r0
  31. 1:
  32. mov r0, r4
  33. !Fallthough to sh4WriteCCN
  34.  
  35. _sh4WriteCCN:
  36. mov.l .LCCN, r5
  37.  
  38. !Block IRQs
  39. mov.l .LBlockBit, r0
  40. stc sr, r7
  41. or r7, r0
  42. ldc r0, sr
  43.  
  44. !Flush and invalidate data cache
  45. mov.l .LOCTags, r0
  46. mov #.LDATA_CACHELINE_CNT>>8, r1
  47. shll8 r1
  48. mov #0, r2
  49. 1:
  50. mov.l r2, @r0
  51. dt r1
  52. add #.LCACHELINE_SIZE, r0
  53. bf 1b
  54.  
  55. !Jump to uncached P1 area before writing CCN
  56. mova 1f, r0
  57. mov #0xa0, r1
  58. shll16 r1
  59. shll8 r1
  60. or r1, r0
  61. jmp @r0
  62. nop
  63.  
  64. .align 2
  65. 1:
  66. !Write to CCN
  67. mov.l r4, @r5
  68.  
  69. !Can't touch cache for a while after writing CCN
  70. nop
  71. nop
  72. nop
  73. nop
  74. nop
  75. nop
  76. nop
  77. nop
  78.  
  79. !Restore SR (unblock IRQs)
  80. ldc r7, sr
  81. rts
  82. nop
  83.  
  84. .align 2
  85. .LCCN:
  86. .long 0xFF00001C
  87. .LBlockBit:
  88. .long 0x10000000
  89. .LOCTags:
  90. .long 0xF4000000
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement