NetBSD/sys/vm/pmap.h

183 lines
6.2 KiB
C

/*
* Copyright (c) 1991 Regents of the University of California.
* All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* The Mach Operating System project at Carnegie-Mellon University.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from: @(#)pmap.h 7.4 (Berkeley) 5/7/91
* $Id: pmap.h,v 1.6 1994/04/15 07:04:43 cgd Exp $
*
*
* Copyright (c) 1987, 1990 Carnegie-Mellon University.
* All rights reserved.
*
* Author: Avadis Tevanian, Jr.
*
* Permission to use, copy, modify and distribute this software and
* its documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
*
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
* FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
*
* Carnegie Mellon requests users of this software to return to
*
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
*
* any improvements or extensions that they make and grant Carnegie the
* rights to redistribute these changes.
*/
/*
* Machine address mapping definitions -- machine-independent
* section. [For machine-dependent section, see "machine/pmap.h".]
*/
#ifndef _PMAP_VM_
#define _PMAP_VM_
/*
* Each machine dependent implementation is expected to
* keep certain statistics. They may do this anyway they
* so choose, but are expected to return the statistics
* in the following structure.
*/
struct pmap_statistics {
long resident_count; /* # of pages mapped (total)*/
long wired_count; /* # of pages wired */
};
typedef struct pmap_statistics *pmap_statistics_t;
#include <machine/pmap.h>
#ifdef KERNEL
/*
* Currently this option is used on the i386 to be able to handle the
* memory from 0-640k and 1M+.
*/
#ifdef MACHINE_NONCONTIG
/*
* Routines used for initialization.
* There is traditionally also a pmap_bootstrap,
* used very early by machine-dependent code,
* but it is not part of the interface.
*/
extern vm_offset_t pmap_steal_memory(); /* During VM initialization,
* steal a chunk of memory.
*/
extern unsigned int pmap_free_pages(); /* During VM initialization,
* report remaining unused
* physical pages.
*/
extern void pmap_startup(); /* During VM initialization,
* use remaining physical pages
* to allocate page frames.
*/
extern void pmap_init(); /* Initialization,
* after kernel runs
* in virtual memory.
*/
/*
* Currently the following isn't really an option. So don't define it.
*/
#undef MACHINE_PAGES
#ifndef MACHINE_PAGES
/*
* If machine/pmap.h defines MACHINE_PAGES, it must implement
* the above functions. The pmap modules has complete control.
* Otherwise, it must implement
* pmap_free_pages
* pmap_virtual_space
* pmap_next_page
* pmap_init
* and vm/vm_page.c implements pmap_steal_memory and pmap_startup
* using pmap_free_pages, pmap_next_page, pmap_virtual_space,
* and pmap_enter. pmap_free_pages may over-estimate the number
* of unused physical pages, and pmap_next_page may return FALSE
* to indicate that there are no more unused pages to return.
* However, for best performance pmap_free_pages should be accurate.
*/
extern boolean_t pmap_next_page(); /* During VM initialization,
* return the next unused
* physical page.
*/
extern void pmap_virtual_space(); /* During VM initialization,
* report virtual space
* available for the kernel.
*/
#endif /* MACHINE_PAGES */
#endif /* MACHINE_NONCONTIG */
#ifdef MACHINE_NONCONTIG
void pmap_init __P((void));
#else
void pmap_init __P((vm_offset_t s, vm_offset_t e));
#endif
void pmap_pinit __P((struct pmap *pmap));
void pmap_release __P((struct pmap *pmap));
vm_offset_t pmap_map();
pmap_t pmap_create();
void pmap_destroy();
void pmap_reference();
void pmap_remove();
void pmap_page_protect();
void pmap_protect();
void pmap_enter();
vm_offset_t pmap_extract();
void pmap_update();
void pmap_collect();
void pmap_activate();
void pmap_deactivate();
void pmap_copy();
void pmap_statistics();
void pmap_clear_reference();
boolean_t pmap_is_referenced();
#ifndef pmap_kernel
pmap_t pmap_kernel();
#endif
void pmap_redzone();
boolean_t pmap_access();
extern pmap_t kernel_pmap;
#endif
#endif /* _PMAP_VM_ */