mmu.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /**************************************************************************
  2. * Copyright (c) 2007-2011, Intel Corporation.
  3. * All Rights Reserved.
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms and conditions of the GNU General Public License,
  7. * version 2, as published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12. * more details.
  13. **************************************************************************/
  14. #ifndef __MMU_H
  15. #define __MMU_H
  16. struct psb_mmu_driver {
  17. /* protects driver- and pd structures. Always take in read mode
  18. * before taking the page table spinlock.
  19. */
  20. struct rw_semaphore sem;
  21. /* protects page tables, directory tables and pt tables.
  22. * and pt structures.
  23. */
  24. spinlock_t lock;
  25. atomic_t needs_tlbflush;
  26. atomic_t *msvdx_mmu_invaldc;
  27. struct psb_mmu_pd *default_pd;
  28. uint32_t bif_ctrl;
  29. int has_clflush;
  30. int clflush_add;
  31. unsigned long clflush_mask;
  32. struct drm_device *dev;
  33. };
  34. struct psb_mmu_pd;
  35. struct psb_mmu_pt {
  36. struct psb_mmu_pd *pd;
  37. uint32_t index;
  38. uint32_t count;
  39. struct page *p;
  40. uint32_t *v;
  41. };
  42. struct psb_mmu_pd {
  43. struct psb_mmu_driver *driver;
  44. int hw_context;
  45. struct psb_mmu_pt **tables;
  46. struct page *p;
  47. struct page *dummy_pt;
  48. struct page *dummy_page;
  49. uint32_t pd_mask;
  50. uint32_t invalid_pde;
  51. uint32_t invalid_pte;
  52. };
  53. extern struct psb_mmu_driver *psb_mmu_driver_init(struct drm_device *dev,
  54. int trap_pagefaults,
  55. int invalid_type,
  56. atomic_t *msvdx_mmu_invaldc);
  57. extern void psb_mmu_driver_takedown(struct psb_mmu_driver *driver);
  58. extern struct psb_mmu_pd *psb_mmu_get_default_pd(struct psb_mmu_driver
  59. *driver);
  60. extern struct psb_mmu_pd *psb_mmu_alloc_pd(struct psb_mmu_driver *driver,
  61. int trap_pagefaults,
  62. int invalid_type);
  63. extern void psb_mmu_free_pagedir(struct psb_mmu_pd *pd);
  64. extern void psb_mmu_flush(struct psb_mmu_driver *driver);
  65. extern void psb_mmu_remove_pfn_sequence(struct psb_mmu_pd *pd,
  66. unsigned long address,
  67. uint32_t num_pages);
  68. extern int psb_mmu_insert_pfn_sequence(struct psb_mmu_pd *pd,
  69. uint32_t start_pfn,
  70. unsigned long address,
  71. uint32_t num_pages, int type);
  72. extern int psb_mmu_virtual_to_pfn(struct psb_mmu_pd *pd, uint32_t virtual,
  73. unsigned long *pfn);
  74. extern void psb_mmu_set_pd_context(struct psb_mmu_pd *pd, int hw_context);
  75. extern int psb_mmu_insert_pages(struct psb_mmu_pd *pd, struct page **pages,
  76. unsigned long address, uint32_t num_pages,
  77. uint32_t desired_tile_stride,
  78. uint32_t hw_tile_stride, int type);
  79. extern void psb_mmu_remove_pages(struct psb_mmu_pd *pd,
  80. unsigned long address, uint32_t num_pages,
  81. uint32_t desired_tile_stride,
  82. uint32_t hw_tile_stride);
  83. #endif