11541Srgrimes/*-
21541Srgrimes * Copyright (c) 1992, 1993
31541Srgrimes *	The Regents of the University of California.  All rights reserved.
41541Srgrimes *
51541Srgrimes * Redistribution and use in source and binary forms, with or without
61541Srgrimes * modification, are permitted provided that the following conditions
71541Srgrimes * are met:
81541Srgrimes * 1. Redistributions of source code must retain the above copyright
91541Srgrimes *    notice, this list of conditions and the following disclaimer.
101541Srgrimes * 2. Redistributions in binary form must reproduce the above copyright
111541Srgrimes *    notice, this list of conditions and the following disclaimer in the
121541Srgrimes *    documentation and/or other materials provided with the distribution.
131541Srgrimes * 4. Neither the name of the University nor the names of its contributors
141541Srgrimes *    may be used to endorse or promote products derived from this software
151541Srgrimes *    without specific prior written permission.
161541Srgrimes *
171541Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
181541Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
191541Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
201541Srgrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
211541Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
221541Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
231541Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
241541Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
251541Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
261541Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
271541Srgrimes * SUCH DAMAGE.
281541Srgrimes *
291541Srgrimes *	@(#)vm_extern.h	8.2 (Berkeley) 1/12/94
3050477Speter * $FreeBSD: releng/11.0/sys/vm/vm_extern.h 294344 2016-01-19 21:37:51Z jhb $
311541Srgrimes */
321541Srgrimes
335283Sbde#ifndef _VM_EXTERN_H_
345283Sbde#define	_VM_EXTERN_H_
352177Spaul
36255732Sneelstruct pmap;
371541Srgrimesstruct proc;
381541Srgrimesstruct vmspace;
391541Srgrimesstruct vnode;
40254025Sjeffstruct vmem;
411541Srgrimes
4255206Speter#ifdef _KERNEL
43283998Sjhbstruct cdev;
44283998Sjhbstruct cdevsw;
457090Sbde
46254025Sjeff/* These operate on kernel virtual addresses only. */
47254025Sjeffvm_offset_t kva_alloc(vm_size_t);
48254025Sjeffvoid kva_free(vm_offset_t, vm_size_t);
49254025Sjeff
50254025Sjeff/* These operate on pageable virtual addresses. */
51254025Sjeffvm_offset_t kmap_alloc_wait(vm_map_t, vm_size_t);
52254025Sjeffvoid kmap_free_wakeup(vm_map_t, vm_offset_t, vm_size_t);
53254025Sjeff
54254025Sjeff/* These operate on virtual addresses backed by memory. */
55254025Sjeffvm_offset_t kmem_alloc_attr(struct vmem *, vm_size_t size, int flags,
56206409Salc    vm_paddr_t low, vm_paddr_t high, vm_memattr_t memattr);
57254025Sjeffvm_offset_t kmem_alloc_contig(struct vmem *, vm_size_t size, int flags,
58226928Salc    vm_paddr_t low, vm_paddr_t high, u_long alignment, vm_paddr_t boundary,
59226891Salc    vm_memattr_t memattr);
60254025Sjeffvm_offset_t kmem_malloc(struct vmem *, vm_size_t size, int flags);
61254025Sjeffvoid kmem_free(struct vmem *, vm_offset_t, vm_size_t);
62254025Sjeff
63254025Sjeff/* This provides memory for previously allocated address space. */
64254025Sjeffint kmem_back(vm_object_t, vm_offset_t, vm_size_t, int);
65254025Sjeffvoid kmem_unback(vm_object_t, vm_offset_t, vm_size_t);
66254025Sjeff
67254025Sjeff/* Bootstrapping. */
68178933Salcvm_map_t kmem_suballoc(vm_map_t, vm_offset_t *, vm_offset_t *, vm_size_t,
69178933Salc    boolean_t);
70254025Sjeffvoid kmem_init(vm_offset_t, vm_offset_t);
71254025Sjeffvoid kmem_init_zero_region(void);
72254025Sjeffvoid kmeminit(void);
73254025Sjeff
7492727Salfredvoid swapout_procs(int);
75254025Sjeffint kernacc(void *, int, int);
76109630Salfredint useracc(void *, int, int);
7792727Salfredint vm_fault(vm_map_t, vm_offset_t, vm_prot_t, int);
78195329Skibvoid vm_fault_copy_entry(vm_map_t, vm_map_t, vm_map_entry_t, vm_map_entry_t,
79195329Skib    vm_ooffset_t *);
80223889Skibint vm_fault_disable_pagefaults(void);
81223889Skibvoid vm_fault_enable_pagefaults(int save);
82253953Sattilioint vm_fault_hold(vm_map_t map, vm_offset_t vaddr, vm_prot_t fault_type,
83216604Salc    int fault_flags, vm_page_t *m_hold);
84216699Salcint vm_fault_quick_hold_pages(vm_map_t map, vm_offset_t addr, vm_size_t len,
85216699Salc    vm_prot_t prot, vm_page_t *ma, int max_count);
86283998Sjhbint vm_forkproc(struct thread *, struct proc *, struct thread *,
87283998Sjhb    struct vmspace *, int);
8892727Salfredvoid vm_waitproc(struct proc *);
89283998Sjhbint vm_mmap(vm_map_t, vm_offset_t *, vm_size_t, vm_prot_t, vm_prot_t, int,
90283998Sjhb    objtype_t, void *, vm_ooffset_t);
91283998Sjhbint vm_mmap_object(vm_map_t, vm_offset_t *, vm_size_t, vm_prot_t,
92283998Sjhb    vm_prot_t, int, vm_object_t, vm_ooffset_t, boolean_t, struct thread *);
93223914Skibint vm_mmap_to_errno(int rv);
94283998Sjhbint vm_mmap_cdev(struct thread *, vm_size_t, vm_prot_t, vm_prot_t *,
95283998Sjhb    int *, struct cdev *, struct cdevsw *, vm_ooffset_t *, vm_object_t *);
96283998Sjhbint vm_mmap_vnode(struct thread *, vm_size_t, vm_prot_t, vm_prot_t *, int *,
97283998Sjhb    struct vnode *, vm_ooffset_t *, vm_object_t *, boolean_t *);
9892727Salfredvoid vm_set_page_size(void);
99198341Smarcelvoid vm_sync_icache(vm_map_t, vm_offset_t, vm_size_t);
100255732Sneeltypedef int (*pmap_pinit_t)(struct pmap *pmap);
101255732Sneelstruct vmspace *vmspace_alloc(vm_offset_t, vm_offset_t, pmap_pinit_t);
102194766Skibstruct vmspace *vmspace_fork(struct vmspace *, vm_ooffset_t *);
103173361Skibint vmspace_exec(struct proc *, vm_offset_t, vm_offset_t);
104173361Skibint vmspace_unshare(struct proc *);
105159054Steggevoid vmspace_exit(struct thread *);
106159054Steggestruct vmspace *vmspace_acquire_ref(struct proc *);
10792727Salfredvoid vmspace_free(struct vmspace *);
10892727Salfredvoid vmspace_exitfree(struct proc *);
109294344Sjhbvoid vmspace_switch_aio(struct vmspace *);
11092727Salfredvoid vnode_pager_setsize(struct vnode *, vm_ooffset_t);
111127007Struckmanint vslock(void *, size_t);
112127007Struckmanvoid vsunlock(void *, size_t);
113153485Salcstruct sf_buf *vm_imgact_map_page(vm_object_t object, vm_ooffset_t offset);
114253953Sattiliovoid vm_imgact_unmap_page(struct sf_buf *sf);
115116355Salcvoid vm_thread_dispose(struct thread *td);
116173361Skibint vm_thread_new(struct thread *td, int pages);
117251523Sglebiusint vm_mlock(struct proc *, struct ucred *, const void *, size_t);
11855206Speter#endif				/* _KERNEL */
1195455Sdg#endif				/* !_VM_EXTERN_H_ */
120