cache_flush.S 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. * GRUB -- GRand Unified Bootloader
  3. * Copyright (C) 2013 Free Software Foundation, Inc.
  4. *
  5. * GRUB is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * GRUB is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #include <grub/symbol.h>
  19. .file "cache_flush.S"
  20. .text
  21. /*
  22. * Simple cache maintenance functions
  23. */
  24. // x0 - *beg (inclusive)
  25. // x1 - *end (exclusive)
  26. // x2 - line size
  27. FUNCTION(grub_arch_clean_dcache_range)
  28. // Clean data cache for range to point-of-unification
  29. 1: cmp x0, x1
  30. b.ge 2f
  31. dc cvau, x0 // Clean Virtual Address to PoU
  32. add x0, x0, x2 // Next line
  33. b 1b
  34. 2: dsb ish
  35. isb
  36. ret
  37. // x0 - *beg (inclusive)
  38. // x1 - *end (exclusive)
  39. // x2 - line size
  40. FUNCTION(grub_arch_invalidate_icache_range)
  41. // Invalidate instruction cache for range to point-of-unification
  42. 1: cmp x0, x1
  43. b.ge 2f
  44. ic ivau, x0 // Invalidate Virtual Address to PoU
  45. add x0, x0, x2 // Next line
  46. b 1b
  47. // Branch predictor invalidation not needed on AArch64
  48. 2: dsb ish
  49. isb
  50. ret