| 1 | /*	$OpenBSD: uvm_km.h,v 1.15 2017/05/11 00:42:05 dlg Exp $	*/ |
| 2 | /*	$NetBSD: uvm_km.h,v 1.9 1999/06/21 17:25:11 thorpej Exp $	*/ |
| 3 | |
| 4 | /* |
| 5 | * Copyright (c) 1997 Charles D. Cranor and Washington University. |
| 6 | * All rights reserved. |
| 7 | * |
| 8 | * Redistribution and use in source and binary forms, with or without |
| 9 | * modification, are permitted provided that the following conditions |
| 10 | * are met: |
| 11 | * 1. Redistributions of source code must retain the above copyright |
| 12 | * notice, this list of conditions and the following disclaimer. |
| 13 | * 2. Redistributions in binary form must reproduce the above copyright |
| 14 | * notice, this list of conditions and the following disclaimer in the |
| 15 | * documentation and/or other materials provided with the distribution. |
| 16 | * |
| 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
| 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
| 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
| 20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
| 22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | * |
| 28 | * from: Id: uvm_km.h,v 1.1.2.2 1997/12/30 12:03:15 mrg Exp |
| 29 | */ |
| 30 | |
| 31 | #ifndef _UVM_UVM_KM_H_ |
| 32 | #define _UVM_UVM_KM_H_ |
| 33 | |
| 34 | /* |
| 35 | * uvm_km.h |
| 36 | */ |
| 37 | |
| 38 | #ifdef _KERNEL |
| 39 | |
| 40 | #include <sys/mutex.h> |
| 41 | |
| 42 | /* |
| 43 | * prototypes |
| 44 | */ |
| 45 | |
| 46 | void uvm_km_init(vaddr_t, vaddr_t, vaddr_t); |
| 47 | void uvm_km_page_init(void); |
| 48 | void uvm_km_page_lateinit(void); |
| 49 | void uvm_km_pgremove(struct uvm_object *, vaddr_t, vaddr_t); |
| 50 | void uvm_km_pgremove_intrsafe(vaddr_t, vaddr_t); |
| 51 | |
| 52 | #if !defined(__HAVE_PMAP_DIRECT) |
| 53 | |
| 54 | #define UVM_KM_PAGES_LOWAT_MAX	(2048) |
| 55 | #define UVM_KM_PAGES_HIWAT_MAX	(4 * UVM_KM_PAGES_LOWAT_MAX) |
| 56 | |
| 57 | struct uvm_km_free_page { |
| 58 | 	struct uvm_km_free_page *next; |
| 59 | }; |
| 60 | struct uvm_km_pages { |
| 61 | 	struct	mutex mtx; |
| 62 | |
| 63 | 	/* Low and high water mark for addresses. */ |
| 64 | 	int	lowat; |
| 65 | 	int	hiwat; |
| 66 | |
| 67 | 	/* Kernel address pool. */ |
| 68 | 	int	free; |
| 69 | 	vaddr_t	page[UVM_KM_PAGES_HIWAT_MAX]; |
| 70 | |
| 71 | 	struct uvm_km_free_page *freelist; |
| 72 | 	int freelistlen; |
| 73 | |
| 74 | 	struct	proc *km_proc; |
| 75 | }; |
| 76 | |
| 77 | extern struct uvm_km_pages uvm_km_pages; |
| 78 | #endif	/* _HAVE_PMAP_DIRECT */ |
| 79 | |
| 80 | #endif /* _KERNEL */ |
| 81 | |
| 82 | #endif /* _UVM_UVM_KM_H_ */ |