Home | History | Annotate | Line # | Download | only in include
vmparam.h revision 1.3
      1 /* $NetBSD: vmparam.h,v 1.3 2018/04/01 04:35:03 ryo Exp $ */
      2 
      3 /*-
      4  * Copyright (c) 2014 The NetBSD Foundation, Inc.
      5  * All rights reserved.
      6  *
      7  * This code is derived from software contributed to The NetBSD Foundation
      8  * by Matt Thomas of 3am Software Foundry.
      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  *
     19  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     20  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     23  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29  * POSSIBILITY OF SUCH DAMAGE.
     30  */
     31 
     32 #ifndef _AARCH64_VMPARAM_H_
     33 #define _AARCH64_VMPARAM_H_
     34 
     35 #ifdef __aarch64__
     36 
     37 #define	__USE_TOPDOWN_VM
     38 
     39 /*
     40  * AARCH64 supports 3 page sizes: 4KB, 16KB, 64KB.  Each page table can
     41  * even have its own page size.
     42  */
     43 
     44 #ifdef AARCH64_PAGE_SHIFT
     45 #if (1 << AARCH64_PAGE_SHIFT) & ~0x141000
     46 #error AARCH64_PAGE_SHIFT contains an unsupported value.
     47 #endif
     48 #define PAGE_SHIFT	AARCH64_PAGE_SHIFT
     49 #else
     50 #define PAGE_SHIFT	12
     51 #endif
     52 #define PAGE_SIZE	(1 << PAGE_SHIFT)
     53 #define PAGE_MASK	(PAGE_SIZE - 1)
     54 
     55 #if PAGE_SHIFT <= 14
     56 #define USPACE		32768
     57 #else
     58 #define USPACE		65536
     59 #endif
     60 #define	UPAGES		(USPACE >> PAGE_SHIFT)
     61 
     62 /*
     63  * USRSTACK is the top (end) of the user stack.  The user VA space is a
     64  * 48-bit address space starting at 0.  Place the stack at its top end.
     65  */
     66 #define USRSTACK	VM_MAXUSER_ADDRESS
     67 
     68 #ifndef MAXTSIZ
     69 #define	MAXTSIZ		(1L << 30)	/* max text size (1GB) */
     70 #endif
     71 
     72 #ifndef MAXDSIZ
     73 #define	MAXDSIZ		(1L << 36)	/* max data size (64GB) */
     74 #endif
     75 
     76 #ifndef MAXSSIZ
     77 #define	MAXSSIZ		(1L << 26)	/* max stack size (64MB) */
     78 #endif
     79 
     80 #ifndef DFLDSIZ
     81 #define	DFLDSIZ		(1L << 32)	/* default data size (4GB) */
     82 #endif
     83 
     84 #ifndef DFLSSIZ
     85 #define	DFLSSIZ		(1L << 23)	/* default stack size (8MB) */
     86 #endif
     87 
     88 #define USRSTACK32	VM_MAXUSER_ADDRESS32
     89 
     90 #ifndef MAXTSIZ32
     91 #define	MAXTSIZ32	(1L << 26)	/* 32bit max text size (64MB) */
     92 #endif
     93 
     94 #ifndef	MAXDSIZ32
     95 #define	MAXDSIZ32	(1536*1024*1024)	/* max data size */
     96 #endif
     97 
     98 #ifndef	MAXSSIZ32
     99 #define	MAXSSIZ32	(64*1024*1024)		/* max stack size */
    100 #endif
    101 
    102 #ifndef DFLDSIZ32
    103 #define	DFLDSIZ32	(1L << 27)	/* 32bit default data size (128MB) */
    104 #endif
    105 
    106 #ifndef DFLSSIZ32
    107 #define	DFLSSIZ32	(1L << 21)	/* 32bit default stack size (2MB) */
    108 #endif
    109 
    110 #define	VM_MIN_ADDRESS		((vaddr_t) 0x0)
    111 #define	VM_MAXUSER_ADDRESS	((vaddr_t) (1L << 48) - PAGE_SIZE)
    112 #define	VM_MAX_ADDRESS		VM_MAXUSER_ADDRESS
    113 
    114 #define VM_MAXUSER_ADDRESS32	((vaddr_t) 0x7ffff000)
    115 
    116 /*
    117  * Give ourselves 64GB of mappable kernel space.  That leaves the rest
    118  * to be user for directly mapped (block addressable) addresses.
    119  */
    120 #define VM_MIN_KERNEL_ADDRESS	((vaddr_t) 0xffffffc000000000L)
    121 #define VM_MAX_KERNEL_ADDRESS	((vaddr_t) 0xffffffffffe00000L)
    122 
    123 /*
    124  * last 254MB of kernel vm area (0xfffffffff0000000-0xffffffffffe00000)
    125  * may be used for devmap. address must be aligned 2MB (L2_SIZE)
    126  * see also aarch64/pmap.c:pmap_devmap_*
    127  */
    128 #define VM_KERNEL_IO_ADDRESS	0xfffffffff0000000L
    129 
    130 /* virtual sizes (bytes) for various kernel submaps */
    131 #define USRIOSIZE		(PAGE_SIZE / 8)
    132 #define VM_PHYS_SIZE		(USRIOSIZE * PAGE_SIZE)
    133 
    134 /*
    135  * Since we have the address space, we map all of physical memory (RAM)
    136  * using block page table entries.
    137  */
    138 #define AARCH64_KSEG_MASK	((vaddr_t) 0xffff000000000000L)
    139 #define AARCH64_KSEG_SIZE	(1UL << 39)	/* 512GB */
    140 #define AARCH64_KSEG_START	AARCH64_KSEG_MASK
    141 #define AARCH64_KSEG_END	(AARCH64_KSEG_START + AARCH64_KSEG_SIZE)
    142 #define AARCH64_KMEMORY_BASE	AARCH64_KSEG_MASK
    143 #define AARCH64_KVA_P(va)	(((vaddr_t) (va) & AARCH64_KSEG_MASK) != 0)
    144 #define AARCH64_PA_TO_KVA(pa)	((vaddr_t) ((pa) | AARCH64_KSEG_START))
    145 #define AARCH64_KVA_TO_PA(va)	((paddr_t) ((va) & ~AARCH64_KSEG_MASK))
    146 
    147 /* */
    148 #define VM_PHYSSEG_MAX		16              /* XXX */
    149 #define VM_PHYSSEG_STRAT	VM_PSTRAT_BSEARCH
    150 
    151 #define VM_NFREELIST		3
    152 #define VM_FREELIST_DEFAULT	0
    153 #define VM_FREELIST_FIRST4GB	1
    154 #define VM_FREELIST_HIGHMEM	2
    155 
    156 #elif defined(__arm__)
    157 
    158 #include <arm/vmparam.h>
    159 
    160 #endif /* __aarch64__/__arm__ */
    161 
    162 #endif /* _AARCH64_VMPARAM_H_ */
    163