pgtable.c 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * arch/xtensa/mm/pgtable.c
  3. *
  4. * This file is subject to the terms and conditions of the GNU General Public
  5. * License. See the file "COPYING" in the main directory of this archive
  6. * for more details.
  7. *
  8. * Copyright (C) 2001 - 2005 Tensilica Inc.
  9. *
  10. * Chris Zankel <chris@zankel.net>
  11. */
  12. #if (DCACHE_SIZE > PAGE_SIZE)
  13. pte_t* pte_alloc_one_kernel(struct mm_struct *mm, unsigned long address)
  14. {
  15. pte_t *pte = NULL, *p;
  16. int color = ADDR_COLOR(address);
  17. int i;
  18. p = (pte_t*) __get_free_pages(GFP_KERNEL|__GFP_REPEAT, COLOR_ORDER);
  19. if (likely(p)) {
  20. split_page(virt_to_page(p), COLOR_ORDER);
  21. for (i = 0; i < COLOR_SIZE; i++) {
  22. if (ADDR_COLOR(p) == color)
  23. pte = p;
  24. else
  25. free_page(p);
  26. p += PTRS_PER_PTE;
  27. }
  28. clear_page(pte);
  29. }
  30. return pte;
  31. }
  32. #ifdef PROFILING
  33. int mask;
  34. int hit;
  35. int flush;
  36. #endif
  37. struct page* pte_alloc_one(struct mm_struct *mm, unsigned long address)
  38. {
  39. struct page *page = NULL, *p;
  40. int color = ADDR_COLOR(address);
  41. p = alloc_pages(GFP_KERNEL | __GFP_REPEAT, PTE_ORDER);
  42. if (likely(p)) {
  43. split_page(p, COLOR_ORDER);
  44. for (i = 0; i < PAGE_ORDER; i++) {
  45. if (PADDR_COLOR(page_address(p)) == color)
  46. page = p;
  47. else
  48. __free_page(p);
  49. p++;
  50. }
  51. clear_highpage(page);
  52. }
  53. return page;
  54. }
  55. #endif