From 17db4f92a12aafffaa956b8ccb10568cbf3a2505 Mon Sep 17 00:00:00 2001 From: alc Date: Wed, 24 Jul 2002 19:47:56 +0000 Subject: o Merge vm_fault_wire() and vm_fault_user_wire() by adding a new parameter, user_wire. --- sys/vm/vm_fault.c | 57 ++++++++----------------------------------------------- 1 file changed, 8 insertions(+), 49 deletions(-) (limited to 'sys/vm/vm_fault.c') diff --git a/sys/vm/vm_fault.c b/sys/vm/vm_fault.c index 93804c7..d8f1d60 100644 --- a/sys/vm/vm_fault.c +++ b/sys/vm/vm_fault.c @@ -919,69 +919,29 @@ readrest: * Wire down a range of virtual addresses in a map. */ int -vm_fault_wire(map, start, end) - vm_map_t map; - vm_offset_t start, end; -{ - - vm_offset_t va; - pmap_t pmap; - int rv; - - pmap = vm_map_pmap(map); - - /* - * Inform the physical mapping system that the range of addresses may - * not fault, so that page tables and such can be locked down as well. - */ - pmap_pageable(pmap, start, end, FALSE); - - /* - * We simulate a fault to get the page and enter it in the physical - * map. - */ - for (va = start; va < end; va += PAGE_SIZE) { - rv = vm_fault(map, va, VM_PROT_READ|VM_PROT_WRITE, - VM_FAULT_CHANGE_WIRING); - if (rv) { - if (va != start) - vm_fault_unwire(map, start, va); - return (rv); - } - } - return (KERN_SUCCESS); -} - -/* - * vm_fault_user_wire: - * - * Wire down a range of virtual addresses in a map. This - * is for user mode though, so we only ask for read access - * on currently read only sections. - */ -int -vm_fault_user_wire(map, start, end) +vm_fault_wire(map, start, end, user_wire) vm_map_t map; vm_offset_t start, end; + boolean_t user_wire; { vm_offset_t va; - pmap_t pmap; int rv; - pmap = vm_map_pmap(map); - /* * Inform the physical mapping system that the range of addresses may * not fault, so that page tables and such can be locked down as well. */ - pmap_pageable(pmap, start, end, FALSE); + pmap_pageable(map->pmap, start, end, FALSE); /* * We simulate a fault to get the page and enter it in the physical - * map. + * map. For user wiring, we only ask for read access on currently + * read-only sections. */ for (va = start; va < end; va += PAGE_SIZE) { - rv = vm_fault(map, va, VM_PROT_READ, VM_FAULT_USER_WIRE); + rv = vm_fault(map, va, + user_wire ? VM_PROT_READ : VM_PROT_READ | VM_PROT_WRITE, + user_wire ? VM_FAULT_USER_WIRE : VM_FAULT_CHANGE_WIRING); if (rv) { if (va != start) vm_fault_unwire(map, start, va); @@ -991,7 +951,6 @@ vm_fault_user_wire(map, start, end) return (KERN_SUCCESS); } - /* * vm_fault_unwire: * -- cgit v1.1