uvm_pager.h 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. /* $OpenBSD: uvm_pager.h,v 1.29 2014/07/11 16:35:40 jsg Exp $ */
  2. /* $NetBSD: uvm_pager.h,v 1.20 2000/11/27 08:40:05 chs Exp $ */
  3. /*
  4. * Copyright (c) 1997 Charles D. Cranor and Washington University.
  5. * All rights reserved.
  6. *
  7. * Redistribution and use in source and binary forms, with or without
  8. * modification, are permitted provided that the following conditions
  9. * are met:
  10. * 1. Redistributions of source code must retain the above copyright
  11. * notice, this list of conditions and the following disclaimer.
  12. * 2. Redistributions in binary form must reproduce the above copyright
  13. * notice, this list of conditions and the following disclaimer in the
  14. * documentation and/or other materials provided with the distribution.
  15. *
  16. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  17. * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  18. * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  19. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  20. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  21. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  22. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  23. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  25. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. *
  27. * from: Id: uvm_pager.h,v 1.1.2.14 1998/01/13 19:00:50 chuck Exp
  28. */
  29. /*
  30. * Copyright (c) 1990 University of Utah.
  31. * Copyright (c) 1991, 1993
  32. * The Regents of the University of California. All rights reserved.
  33. *
  34. * This code is derived from software contributed to Berkeley by
  35. * the Systems Programming Group of the University of Utah Computer
  36. * Science Department.
  37. *
  38. * Redistribution and use in source and binary forms, with or without
  39. * modification, are permitted provided that the following conditions
  40. * are met:
  41. * 1. Redistributions of source code must retain the above copyright
  42. * notice, this list of conditions and the following disclaimer.
  43. * 2. Redistributions in binary form must reproduce the above copyright
  44. * notice, this list of conditions and the following disclaimer in the
  45. * documentation and/or other materials provided with the distribution.
  46. * 3. Neither the name of the University nor the names of its contributors
  47. * may be used to endorse or promote products derived from this software
  48. * without specific prior written permission.
  49. *
  50. * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  51. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  52. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  53. * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  54. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  55. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  56. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  57. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  58. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  59. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  60. * SUCH DAMAGE.
  61. *
  62. * @(#)vm_pager.h 8.5 (Berkeley) 7/7/94
  63. */
  64. #ifndef _UVM_UVM_PAGER_H_
  65. #define _UVM_UVM_PAGER_H_
  66. #ifdef _KERNEL
  67. struct uvm_pagerops {
  68. /* init pager */
  69. void (*pgo_init)(void);
  70. /* add reference to obj */
  71. void (*pgo_reference)(struct uvm_object *);
  72. /* drop reference to obj */
  73. void (*pgo_detach)(struct uvm_object *);
  74. /* special nonstd fault fn */
  75. int (*pgo_fault)(struct uvm_faultinfo *, vaddr_t,
  76. vm_page_t *, int, int, vm_fault_t,
  77. vm_prot_t, int);
  78. /* flush pages out of obj */
  79. boolean_t (*pgo_flush)(struct uvm_object *, voff_t,
  80. voff_t, int);
  81. /* get/read page */
  82. int (*pgo_get)(struct uvm_object *, voff_t,
  83. vm_page_t *, int *, int, vm_prot_t, int, int);
  84. /* put/write page */
  85. int (*pgo_put)(struct uvm_object *, vm_page_t *,
  86. int, boolean_t);
  87. /* return range of cluster */
  88. void (*pgo_cluster)(struct uvm_object *, voff_t,
  89. voff_t *, voff_t *);
  90. /* make "put" cluster */
  91. struct vm_page ** (*pgo_mk_pcluster)(struct uvm_object *,
  92. struct vm_page **, int *, struct vm_page *,
  93. int, voff_t, voff_t);
  94. };
  95. /* pager flags [mostly for flush] */
  96. #define PGO_CLEANIT 0x001 /* write dirty pages to backing store */
  97. #define PGO_SYNCIO 0x002 /* if PGO_CLEANIT: use sync I/O? */
  98. #define PGO_DEACTIVATE 0x004 /* deactivate flushed pages */
  99. #define PGO_FREE 0x008 /* free flushed pages */
  100. /* if PGO_FREE is not set then the pages stay where they are. */
  101. #define PGO_ALLPAGES 0x010 /* flush whole object/get all pages */
  102. #define PGO_DOACTCLUST 0x020 /* flag to mk_pcluster to include active */
  103. #define PGO_LOCKED 0x040 /* fault data structures are locked [get] */
  104. #define PGO_PDFREECLUST 0x080 /* daemon's free cluster flag [uvm_pager_put] */
  105. #define PGO_REALLOCSWAP 0x100 /* reallocate swap area [pager_dropcluster] */
  106. /* page we are not interested in getting */
  107. #define PGO_DONTCARE ((struct vm_page *) -1L) /* [get only] */
  108. /*
  109. * prototypes
  110. */
  111. void uvm_pager_dropcluster(struct uvm_object *, struct vm_page *,
  112. struct vm_page **, int *, int);
  113. void uvm_pager_init(void);
  114. int uvm_pager_put(struct uvm_object *, struct vm_page *,
  115. struct vm_page ***, int *, int, voff_t, voff_t);
  116. vaddr_t uvm_pagermapin(struct vm_page **, int, int);
  117. void uvm_pagermapout(vaddr_t, int);
  118. struct vm_page **uvm_mk_pcluster(struct uvm_object *, struct vm_page **,
  119. int *, struct vm_page *, int, voff_t, voff_t);
  120. /* Flags to uvm_pagermapin() */
  121. #define UVMPAGER_MAPIN_WAITOK 0x01 /* it's okay to wait */
  122. #define UVMPAGER_MAPIN_READ 0x02 /* host <- device */
  123. #define UVMPAGER_MAPIN_WRITE 0x00 /* device -> host (pseudo flag) */
  124. /*
  125. * get/put return values
  126. * OK operation was successful
  127. * BAD specified data was out of the accepted range
  128. * FAIL specified data was in range, but doesn't exist
  129. * PEND operations was initiated but not completed
  130. * ERROR error while accessing data that is in range and exists
  131. * AGAIN temporary resource shortage prevented operation from happening
  132. * UNLOCK unlock the map and try again
  133. * REFAULT [uvm_fault internal use only!] unable to relock data structures,
  134. * thus the mapping needs to be reverified before we can procede
  135. */
  136. #define VM_PAGER_OK 0
  137. #define VM_PAGER_BAD 1
  138. #define VM_PAGER_FAIL 2
  139. #define VM_PAGER_PEND 3
  140. #define VM_PAGER_ERROR 4
  141. #define VM_PAGER_AGAIN 5
  142. #define VM_PAGER_UNLOCK 6
  143. #define VM_PAGER_REFAULT 7
  144. /*
  145. * XXX
  146. * this is needed until the device strategy interface
  147. * is changed to do physically-addressed i/o.
  148. */
  149. #ifndef PAGER_MAP_SIZE
  150. #define PAGER_MAP_SIZE (16 * 1024 * 1024)
  151. #endif
  152. #endif /* _KERNEL */
  153. #endif /* _UVM_UVM_PAGER_H_ */