/* Virtual Memory Pagers. Copyright 1999-2002 Johan Rydberg, jrydberg@rtmk.org. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef __vm_pager_h #define __vm_pager_h 1 #include "tm.h" #include #include struct vm_page; struct vm_object; /* External pager; ??? per-object pager Each object have an assigned pager, either the default or one specifed when creating the object. The object also holds a cookie for the pager, which identifies the object to the pager. The fault handler requests pages for the pager through the functions defined below. The pageout daemon flushes pages through the functions below. Each object that have an assigned pager should inherit this structure. COOKIE is free for whatever usage by pager. */ struct vm_pager { /* Request a page from VM object COOKIE, controled by PAGER. OFFSET is postion in object. DESIRED_ACCESS is the access that we want for the page. Page is returned in *PAGEP. If *PAGEP is NULL, and the fn does not return an error, we allocate a new page. */ kern_return_t (*page_request) (struct vm_pager *pager, void *cookie, vm_offset_t offset, vm_prot_t desired_access, struct vm_page **pagep); #define PAGER_PAGE_REQUEST(OBJECT, OFFSET, ACCESS, PAGEP) \ (*(OBJECT)->pager_object->page_request) \ ((OBJECT)->pager_object, (OBJECT)->pager_cookie, OFFSET, ACCESS, PAGEP) /* Flush PAGE into backingstore controled by COOKIN in PAGER. */ kern_return_t (*page_flush) (struct vm_pager *pager, void *cookie, vm_offset_t offset, struct vm_page *page); /* Cookie for this object - pager may assign whatever value. */ void *cookie; }; /* Pagers that the kernel provides. */ extern struct vm_pager pager_default; extern struct vm_pager pager_host; /* Initialize host pager on OBJECT. PHYS_ADDR is the physical address that the object should map into memory. */ extern kern_return_t host_pager_init_object (struct vm_object *object, vm_offset_t phys_addr); #endif /* vm-pager.h */