Home | History | Annotate | Line # | Download | only in include
vmparam.h revision 1.10
      1 /*	$NetBSD: vmparam.h,v 1.10 2017/04/08 18:05:36 scole Exp $	*/
      2 
      3 /*-
      4  * Copyright (c) 1990 The Regents of the University of California.
      5  * All rights reserved.
      6  *
      7  * This code is derived from software contributed to Berkeley by
      8  * William Jolitz.
      9  *
     10  * Redistribution and use in source and binary forms, with or without
     11  * modification, are permitted provided that the following conditions
     12  * are met:
     13  * 1. Redistributions of source code must retain the above copyright
     14  *    notice, this list of conditions and the following disclaimer.
     15  * 2. Redistributions in binary form must reproduce the above copyright
     16  *    notice, this list of conditions and the following disclaimer in the
     17  *    documentation and/or other materials provided with the distribution.
     18  * 3. Neither the name of the University nor the names of its contributors
     19  *    may be used to endorse or promote products derived from this software
     20  *    without specific prior written permission.
     21  *
     22  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     23  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     24  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     25  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     26  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     27  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     28  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     29  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     31  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     32  * SUCH DAMAGE.
     33  *
     34  *	@(#)vmparam.h	5.9 (Berkeley) 5/12/91
     35  */
     36 
     37 #ifndef _VMPARAM_H_
     38 #define _VMPARAM_H_
     39 
     40 #define	USRSTACK	VM_MAX_ADDRESS /* XXX: Revisit vm address space. */
     41 
     42 /*
     43  * Virtual memory related constants, all in bytes
     44  */
     45 #ifndef MAXTSIZ
     46 #define	MAXTSIZ		(1<<30)			/* max text size (1G) */
     47 #endif
     48 #ifndef DFLDSIZ
     49 #define	DFLDSIZ		(1<<27)			/* initial data size (128M) */
     50 #endif
     51 #ifndef MAXDSIZ
     52 #define	MAXDSIZ		(1<<30)			/* max data size (1G) */
     53 #endif
     54 #ifndef	DFLSSIZ
     55 #define	DFLSSIZ		(1<<21)			/* initial stack size (2M) */
     56 #endif
     57 #ifndef	MAXSSIZ
     58 #define	MAXSSIZ		(1<<28)			/* max stack size (256M) */
     59 #endif
     60 #ifndef SGROWSIZ
     61 #define SGROWSIZ	(128UL*1024)		/* amount to grow stack */
     62 #endif
     63 
     64 #define	IA64_VM_MINKERN_REGION	4
     65 
     66 /*
     67  * PTEs for mapping user space into the kernel for phyio operations.
     68  * 64 pte's are enough to cover 8 disks * MAXBSIZE.
     69  */
     70 #ifndef USRIOSIZE
     71 #define USRIOSIZE	64
     72 #endif
     73 
     74 /*
     75  * Manipulating region bits of an address.
     76  */
     77 #define IA64_RR_BASE(n)         (((uint64_t) (n)) << 61)
     78 #define IA64_RR_MASK(x)         ((x) & ((1L << 61) - 1))
     79 
     80 #define IA64_PHYS_TO_RR6(x)     ((x) | IA64_RR_BASE(6))
     81 #define IA64_PHYS_TO_RR7(x)     ((x) | IA64_RR_BASE(7))
     82 
     83 /*
     84  * The Itanium architecture defines that all implementations support at
     85  * least 51 virtual address bits (i.e. IMPL_VA_MSB=50). The unimplemented
     86  * bits are sign-extended from VA{IMPL_VA_MSB}. As such, there's a gap in
     87  * the virtual address range, which extends at most from 0x0004000000000000
     88  * to 0x1ffbffffffffffff. We define the top half of a region in terms of
     89  * this worst-case gap.
     90  */
     91 #define IA64_REGION_GAP_START   0x0004000000000000
     92 #define IA64_REGION_GAP_EXTEND  0x1ffc000000000000
     93 
     94 /*
     95  * Parameters for Pre-Boot Virtual Memory (PBVM).
     96  * The kernel, its modules and metadata are loaded in the PBVM by the loader.
     97  * The PBVM consists of pages for which the mapping is maintained in a page
     98  * table. The page table is at least 1 EFI page large (i.e. 4KB), but can be
     99  * larger to accommodate more PBVM. The maximum page table size is 1MB. With
    100  * 8 bytes per page table entry, this means that the PBVM has at least 512
    101  * pages and at most 128K pages.
    102  * The GNU toolchain (in particular GNU ld) does not support an alignment
    103  * larger than 64K. This means that we cannot guarantee page alignment for
    104  * a page size that's larger than 64K. We do want to have text and data in
    105  * different pages, which means that the maximum usable page size is 64KB.
    106  * Consequently:
    107  * The maximum total PBVM size is 8GB -- enough for a DVD image. A page table
    108  * of a single EFI page (4KB) allows for 32MB of PBVM.
    109  *
    110  * The kernel is given the PA and size of the page table that provides the
    111  * mapping of the PBVM. The page table itself is assumed to be mapped at a
    112  * known virtual address and using a single translation wired into the CPU.
    113  * As such, the page table is assumed to be a power of 2 and naturally aligned.
    114  * The kernel also assumes that a good portion of the kernel text is mapped
    115  * and wired into the CPU, but does not assume that the mapping covers the
    116  * whole of PBVM.
    117  */
    118 #define IA64_PBVM_RR            IA64_VM_MINKERN_REGION
    119 #define IA64_PBVM_BASE          \
    120                 (IA64_RR_BASE(IA64_PBVM_RR) + IA64_REGION_GAP_EXTEND)
    121 
    122 #define IA64_PBVM_PGTBL_MAXSZ   1048576
    123 #define IA64_PBVM_PGTBL         \
    124                 (IA64_RR_BASE(IA64_PBVM_RR + 1) - IA64_PBVM_PGTBL_MAXSZ)
    125 
    126 #define IA64_PBVM_PAGE_SHIFT    16      /* 64KB */
    127 #define IA64_PBVM_PAGE_SIZE     (1 << IA64_PBVM_PAGE_SHIFT)
    128 #define IA64_PBVM_PAGE_MASK     (IA64_PBVM_PAGE_SIZE - 1)
    129 
    130 #define	IA64_ID_PAGE_SHIFT	28		/* 256M */
    131 #define	IA64_ID_PAGE_SIZE	(1 << IA64_ID_PAGE_SHIFT)
    132 #define	IA64_ID_PAGE_MASK	(IA64_ID_PAGE_SIZE-1)
    133 
    134 /* XXX freebsd uses
    135 #define IA64_BACKINGSTORE       (USRSTACK - (2 * MAXSSIZ) - PAGE_SIZE)
    136 */
    137 #define	IA64_BACKINGSTORE	IA64_RR_BASE(4)
    138 
    139 #define	PAGE_SHIFT	14		/* 16K pages by default. */
    140 #define	PAGE_SIZE	(1 << PAGE_SHIFT)
    141 #define	PAGE_MASK	(PAGE_SIZE - 1)
    142 
    143 /* user/kernel map constants */
    144 #define VM_MIN_ADDRESS		((vaddr_t)0)
    145 #define	VM_MAX_ADDRESS		((vaddr_t) IA64_RR_BASE(5))
    146 #define	VM_GATEWAY_SIZE		PAGE_SIZE
    147 #define	VM_MAXUSER_ADDRESS	(VM_MAX_ADDRESS + VM_GATEWAY_SIZE)
    148 #define	VM_MIN_KERNEL_ADDRESS	VM_MAXUSER_ADDRESS
    149 #define VM_INIT_KERNEL_ADDRESS  IA64_RR_BASE(IA64_VM_MINKERN_REGION + 1)
    150 #define VM_MAX_KERNEL_ADDRESS	((vaddr_t) (IA64_RR_BASE(6) - 1))
    151 
    152 #define VM_PHYSSEG_MAX		16		/* XXX: */
    153 #define VM_PHYSSEG_STRAT	VM_PSTRAT_BSEARCH
    154 
    155 #define	VM_NFREELIST		1 /* XXX: */
    156 #define	VM_FREELIST_DEFAULT	0 /* XXX: */
    157 
    158 /* virtual sizes (bytes) for various kernel submaps */
    159 #define VM_PHYS_SIZE		(USRIOSIZE*PAGE_SIZE)
    160 
    161 #endif /* _VMPARAM_H_ */
    162