1 /* 2 * Copyright (c) 1990 University of Utah. 3 * Copyright (c) 1991 The Regents of the University of California. 4 * All rights reserved. 5 * 6 * This code is derived from software contributed to Berkeley by 7 * the Systems Programming Group of the University of Utah Computer 8 * Science Department. 9 * 10 * %sccs.include.redist.c% 11 * 12 * @(#)vm_pager.h 7.1 (Berkeley) 12/05/90 13 */ 14 15 /* 16 * Pager routine interface definition. 17 * For BSD we use a cleaner version of the internal pager interface. 18 */ 19 20 #ifndef _VM_PAGER_ 21 #define _VM_PAGER_ 22 23 #ifdef KERNEL 24 #include "types.h" 25 #include "queue.h" 26 #else 27 #include <sys/types.h> 28 #include <sys/queue.h> 29 #endif 30 31 struct pager_struct { 32 queue_head_t pg_list; /* links for list management */ 33 caddr_t pg_handle; /* external handle (vp, dev, fp) */ 34 int pg_type; /* type of pager */ 35 struct pagerops *pg_ops; /* pager operations */ 36 caddr_t pg_data; /* private pager data */ 37 }; 38 typedef struct pager_struct *vm_pager_t; 39 40 #define vm_pager_null ((vm_pager_t) 0) /* XXX MACH compat */ 41 #define VM_PAGER_NULL ((vm_pager_t) 0) 42 43 /* pager types */ 44 #define PG_DFLT -1 45 #define PG_SWAP 0 46 #define PG_VNODE 1 47 #define PG_DEVICE 2 48 49 struct pagerops { 50 void (*pgo_init)(); /* initialize pager */ 51 vm_pager_t (*pgo_alloc)(); /* allocate pager */ 52 void (*pgo_dealloc)(); /* disassociate */ 53 int (*pgo_getpage)(); /* get (read) page */ 54 int (*pgo_putpage)(); /* put (write) page */ 55 boolean_t (*pgo_haspage)(); /* does pager have page? */ 56 }; 57 #define PAGER_OPS_NULL ((struct pagerops *)0) 58 59 /* 60 * get/put return values 61 * OK operation was successful 62 * BAD specified data was out of the accepted range 63 * FAIL specified data was in range, but doesn't exist 64 * PEND operations was initiated but not completed 65 */ 66 #define VM_PAGER_OK 0 67 #define VM_PAGER_BAD 1 68 #define VM_PAGER_FAIL 2 69 #define VM_PAGER_PEND 3 70 71 #define VM_PAGER_ALLOC(h, s, p) (*(pg)->pg_ops->pgo_alloc)(h, s, p) 72 #define VM_PAGER_DEALLOC(pg) (*(pg)->pg_ops->pgo_dealloc)(pg) 73 #define VM_PAGER_GET(pg, m, s) (*(pg)->pg_ops->pgo_getpage)(pg, m, s) 74 #define VM_PAGER_PUT(pg, m, s) (*(pg)->pg_ops->pgo_putpage)(pg, m, s) 75 #define VM_PAGER_HASPAGE(pg, o) (*(pg)->pg_ops->pgo_haspage)(pg, o) 76 77 #ifdef KERNEL 78 vm_pager_t vm_pager_allocate(); 79 void vm_pager_deallocate(); 80 int vm_pager_get(); 81 int vm_pager_put(); 82 boolean_t vm_pager_has_page(); 83 84 vm_offset_t vm_pager_map_page(); 85 void vm_pager_unmap_page(); 86 vm_pager_t vm_pager_lookup(); 87 void vm_pager_sync(); 88 89 extern struct pagerops *dfltpagerops; 90 #endif 91 92 #endif /* _VM_PAGER_ */ 93