/* Host (physical memory) pager. 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. */ #include #include "tm.h" #include "vm-page.h" #include "vm-pager.h" #include "vm-object.h" #include "ipc-port.h" /* Someone is requesting page at OFFSET in object COOKIE, from our PAGER. since we are providing physical memory, COOKIE is the physical address. */ static kern_return_t host_page_request (struct vm_pager *pager, void *cookie, vm_offset_t offset, vm_prot_t desired_access, struct vm_page **pagep) { vm_offset_t pa = ((vm_offset_t) cookie) + offset; /* We allocate a fictitious page and assign (PA + OFFSET) to it. */ *pagep = vm_page_fictitious_allocate (); if (! *pagep) return KERN_RESOURCE_SHORTAGE; vm_page_assign (*pagep, pa); return KERN_SUCCESS; } /* Initialize host pager on OBJECT. PHYS_ADDR is the physical address that the object should map into memory. */ kern_return_t host_pager_init_object (struct vm_object *object, vm_offset_t phys_addr) { object->pager_cookie = (void *) phys_addr; object->pager_object = & pager_host; object->object_port = ipc_port_create_kernel (); ipc_port_set_kobject (object->object_port, IPC_KOBJECT_TYPE_MEMORY_OBJECT, object); return KERN_SUCCESS; } /* Pager structure for the host pager. */ struct vm_pager pager_host = { host_page_request, 0 };