cache.c 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. /* init.c - initialize an ia64-based EFI system */
  2. /*
  3. * GRUB -- GRand Unified Bootloader
  4. * Copyright (C) 2008 Free Software Foundation, Inc.
  5. *
  6. * GRUB 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 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * GRUB 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
  17. * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #include <grub/types.h>
  20. #include <grub/cache.h>
  21. void
  22. grub_arch_sync_caches (void *address, grub_size_t len)
  23. {
  24. /* Cache line length is at least 32. */
  25. len += (grub_uint64_t)address & 0x1f;
  26. grub_uint64_t a = (grub_uint64_t)address & ~0x1f;
  27. /* Flush data. */
  28. for (len = (len + 31) & ~0x1f; len > 0; len -= 0x20, a += 0x20)
  29. asm volatile ("fc.i %0" : : "r" (a));
  30. /* Sync and serialize. Maybe extra. */
  31. asm volatile (";; sync.i;; srlz.i;;");
  32. }