cache-page.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /* cache-page.c: whole-page cache wrangling functions for MMU linux
  2. *
  3. * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved.
  4. * Written by David Howells (dhowells@redhat.com)
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * as published by the Free Software Foundation; either version
  9. * 2 of the License, or (at your option) any later version.
  10. */
  11. #include <linux/sched.h>
  12. #include <linux/mm.h>
  13. #include <linux/highmem.h>
  14. #include <asm/pgalloc.h>
  15. /*****************************************************************************/
  16. /*
  17. * DCF takes a virtual address and the page may not currently have one
  18. * - temporarily hijack a kmap_atomic() slot and attach the page to it
  19. */
  20. void flush_dcache_page(struct page *page)
  21. {
  22. unsigned long dampr2;
  23. void *vaddr;
  24. dampr2 = __get_DAMPR(2);
  25. vaddr = kmap_atomic(page, __KM_CACHE);
  26. frv_dcache_writeback((unsigned long) vaddr, (unsigned long) vaddr + PAGE_SIZE);
  27. kunmap_atomic(vaddr, __KM_CACHE);
  28. if (dampr2) {
  29. __set_DAMPR(2, dampr2);
  30. __set_IAMPR(2, dampr2);
  31. }
  32. } /* end flush_dcache_page() */
  33. /*****************************************************************************/
  34. /*
  35. * ICI takes a virtual address and the page may not currently have one
  36. * - so we temporarily attach the page to a bit of virtual space so that is can be flushed
  37. */
  38. void flush_icache_user_range(struct vm_area_struct *vma, struct page *page,
  39. unsigned long start, unsigned long len)
  40. {
  41. unsigned long dampr2;
  42. void *vaddr;
  43. dampr2 = __get_DAMPR(2);
  44. vaddr = kmap_atomic(page, __KM_CACHE);
  45. start = (start & ~PAGE_MASK) | (unsigned long) vaddr;
  46. frv_cache_wback_inv(start, start + len);
  47. kunmap_atomic(vaddr, __KM_CACHE);
  48. if (dampr2) {
  49. __set_DAMPR(2, dampr2);
  50. __set_IAMPR(2, dampr2);
  51. }
  52. } /* end flush_icache_user_range() */