misc.S 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * Copyright (C) Paul Mackerras 1997.
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * as published by the Free Software Foundation; either version
  7. * 2 of the License, or (at your option) any later version.
  8. */
  9. .text
  10. /*
  11. * Use the BAT2 & 3 registers to map the 1st 16MB of RAM to
  12. * the address given as the 1st argument.
  13. */
  14. .globl setup_bats
  15. setup_bats:
  16. mfpvr 5
  17. rlwinm 5,5,16,16,31 /* r3 = 1 for 601, 4 for 604 */
  18. cmpwi 0,5,1
  19. li 0,0
  20. bne 4f
  21. mtibatl 3,0 /* invalidate BAT first */
  22. ori 3,3,4 /* set up BAT registers for 601 */
  23. li 4,0x7f
  24. mtibatu 2,3
  25. mtibatl 2,4
  26. oris 3,3,0x80
  27. oris 4,4,0x80
  28. mtibatu 3,3
  29. mtibatl 3,4
  30. b 5f
  31. 4: mtdbatu 3,0 /* invalidate BATs first */
  32. mtibatu 3,0
  33. ori 3,3,0xff /* set up BAT registers for 604 */
  34. li 4,2
  35. mtdbatl 2,4
  36. mtdbatu 2,3
  37. mtibatl 2,4
  38. mtibatu 2,3
  39. oris 3,3,0x80
  40. oris 4,4,0x80
  41. mtdbatl 3,4
  42. mtdbatu 3,3
  43. mtibatl 3,4
  44. mtibatu 3,3
  45. 5: sync
  46. isync
  47. blr
  48. /*
  49. * Flush the dcache and invalidate the icache for a range of addresses.
  50. *
  51. * flush_cache(addr, len)
  52. */
  53. .global flush_cache
  54. flush_cache:
  55. addi 4,4,0x1f /* len = (len + 0x1f) / 0x20 */
  56. rlwinm. 4,4,27,5,31
  57. mtctr 4
  58. beqlr
  59. 1: dcbf 0,3
  60. icbi 0,3
  61. addi 3,3,0x20
  62. bdnz 1b
  63. sync
  64. isync
  65. blr