cache-page.c 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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 <linux/module.h>
  15. #include <asm/pgalloc.h>
  16. /*****************************************************************************/
  17. /*
  18. * DCF takes a virtual address and the page may not currently have one
  19. * - temporarily hijack a kmap_atomic() slot and attach the page to it
  20. */
  21. void flush_dcache_page(struct page *page)
  22. {
  23. unsigned long dampr2;
  24. void *vaddr;
  25. dampr2 = __get_DAMPR(2);
  26. vaddr = kmap_atomic_primary(page);
  27. frv_dcache_writeback((unsigned long) vaddr, (unsigned long) vaddr + PAGE_SIZE);
  28. kunmap_atomic_primary(vaddr);
  29. if (dampr2) {
  30. __set_DAMPR(2, dampr2);
  31. __set_IAMPR(2, dampr2);
  32. }
  33. } /* end flush_dcache_page() */
  34. EXPORT_SYMBOL(flush_dcache_page);
  35. /*****************************************************************************/
  36. /*
  37. * ICI takes a virtual address and the page may not currently have one
  38. * - so we temporarily attach the page to a bit of virtual space so that is can be flushed
  39. */
  40. void flush_icache_user_range(struct vm_area_struct *vma, struct page *page,
  41. unsigned long start, unsigned long len)
  42. {
  43. unsigned long dampr2;
  44. void *vaddr;
  45. dampr2 = __get_DAMPR(2);
  46. vaddr = kmap_atomic_primary(page);
  47. start = (start & ~PAGE_MASK) | (unsigned long) vaddr;
  48. frv_cache_wback_inv(start, start + len);
  49. kunmap_atomic_primary(vaddr);
  50. if (dampr2) {
  51. __set_DAMPR(2, dampr2);
  52. __set_IAMPR(2, dampr2);
  53. }
  54. } /* end flush_icache_user_range() */
  55. EXPORT_SYMBOL(flush_icache_user_range);