Home | History | Annotate | Line # | Download | only in include
vmparam.h revision 1.2.2.3
      1  1.2.2.2       tls /* $NetBSD: vmparam.h,v 1.2.2.3 2017/12/03 11:35:44 jdolecek Exp $ */
      2  1.2.2.2       tls 
      3  1.2.2.2       tls /*-
      4  1.2.2.2       tls  * Copyright (c) 2014 The NetBSD Foundation, Inc.
      5  1.2.2.2       tls  * All rights reserved.
      6  1.2.2.2       tls  *
      7  1.2.2.2       tls  * This code is derived from software contributed to The NetBSD Foundation
      8  1.2.2.2       tls  * by Matt Thomas of 3am Software Foundry.
      9  1.2.2.2       tls  *
     10  1.2.2.2       tls  * Redistribution and use in source and binary forms, with or without
     11  1.2.2.2       tls  * modification, are permitted provided that the following conditions
     12  1.2.2.2       tls  * are met:
     13  1.2.2.2       tls  * 1. Redistributions of source code must retain the above copyright
     14  1.2.2.2       tls  *    notice, this list of conditions and the following disclaimer.
     15  1.2.2.2       tls  * 2. Redistributions in binary form must reproduce the above copyright
     16  1.2.2.2       tls  *    notice, this list of conditions and the following disclaimer in the
     17  1.2.2.2       tls  *    documentation and/or other materials provided with the distribution.
     18  1.2.2.2       tls  *
     19  1.2.2.2       tls  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     20  1.2.2.2       tls  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21  1.2.2.2       tls  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22  1.2.2.2       tls  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     23  1.2.2.2       tls  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24  1.2.2.2       tls  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25  1.2.2.2       tls  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26  1.2.2.2       tls  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27  1.2.2.2       tls  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28  1.2.2.2       tls  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29  1.2.2.2       tls  * POSSIBILITY OF SUCH DAMAGE.
     30  1.2.2.2       tls  */
     31  1.2.2.2       tls 
     32  1.2.2.2       tls #ifndef _AARCH64_VMPARAM_H_
     33  1.2.2.2       tls #define _AARCH64_VMPARAM_H_
     34  1.2.2.2       tls 
     35  1.2.2.2       tls #ifdef __aarch64__
     36  1.2.2.2       tls 
     37  1.2.2.2       tls /*
     38  1.2.2.2       tls  * AARCH64 supports 3 page sizes: 4KB, 16KB, 64KB.  Each page table can
     39  1.2.2.2       tls  * even have its own page size.
     40  1.2.2.2       tls  */
     41  1.2.2.2       tls 
     42  1.2.2.2       tls #ifdef AARCH64_PAGE_SHIFT
     43  1.2.2.2       tls #if (1 << AARCH64_PAGE_SHIFT) & ~0x141000
     44  1.2.2.2       tls #error AARCH64_PAGE_SHIFT contains an unsupported value.
     45  1.2.2.2       tls #endif
     46  1.2.2.2       tls #define PAGE_SHIFT	AARCH64_PAGE_SHIFT
     47  1.2.2.2       tls #else
     48  1.2.2.2       tls #define PAGE_SHIFT	12
     49  1.2.2.2       tls #endif
     50  1.2.2.2       tls #define PAGE_SIZE	(1 << PAGE_SHIFT)
     51  1.2.2.2       tls #define PAGE_MASK	(PAGE_SIZE - 1)
     52  1.2.2.2       tls 
     53  1.2.2.2       tls #if PAGE_SHIFT <= 14
     54  1.2.2.2       tls #define USPACE		16384
     55  1.2.2.2       tls #else
     56  1.2.2.2       tls #define USPACE		65536
     57  1.2.2.2       tls #endif
     58  1.2.2.2       tls #define	UPAGES		(USPACE >> PAGE_SHIFT)
     59  1.2.2.2       tls 
     60  1.2.2.2       tls /*
     61  1.2.2.2       tls  * USRSTACK is the top (end) of the user stack.  The user VA space is a
     62  1.2.2.2       tls  * 48-bit address space starting at 0.  Place the stack at its top end.
     63  1.2.2.2       tls  */
     64  1.2.2.2       tls #define USRSTACK	((vaddr_t) 0x0000ffffffff0000)
     65  1.2.2.2       tls #define USRSTACK32	((vaddr_t) 0x7ffff000)
     66  1.2.2.2       tls 
     67  1.2.2.2       tls #ifndef MAXTSIZ
     68  1.2.2.2       tls #define	MAXTSIZ		(1L << 30)	/* max text size (1GB) */
     69  1.2.2.2       tls #endif
     70  1.2.2.2       tls 
     71  1.2.2.2       tls #ifndef MAXTSIZ32
     72  1.2.2.2       tls #define	MAXTSIZ32	(1L << 26)	/* 32bit max text size (64MB) */
     73  1.2.2.2       tls #endif
     74  1.2.2.2       tls 
     75  1.2.2.2       tls #ifndef MAXDSIZ
     76  1.2.2.2       tls #define	MAXDSIZ		(1L << 36)	/* max data size (64GB) */
     77  1.2.2.2       tls #endif
     78  1.2.2.2       tls 
     79  1.2.2.2       tls #ifndef MAXSSIZ
     80  1.2.2.2       tls #define	MAXSSIZ		(1L << 26)	/* max stack size (64MB) */
     81  1.2.2.2       tls #endif
     82  1.2.2.2       tls 
     83  1.2.2.2       tls #ifndef DFLDSIZ
     84  1.2.2.2       tls #define	DFLDSIZ		(1L << 32)	/* default data size (4GB) */
     85  1.2.2.2       tls #endif
     86  1.2.2.2       tls 
     87  1.2.2.2       tls #ifndef DFLDSIZ32
     88  1.2.2.2       tls #define	DFLDSIZ32	(1L << 27)	/* 32bit default data size (128MB) */
     89  1.2.2.2       tls #endif
     90  1.2.2.2       tls 
     91  1.2.2.2       tls #ifndef DFLSSIZ
     92  1.2.2.2       tls #define	DFLSSIZ		(1L << 23)	/* default stack size (8MB) */
     93  1.2.2.2       tls #endif
     94  1.2.2.2       tls 
     95  1.2.2.2       tls #ifndef DFLSSIZ32
     96  1.2.2.2       tls #define	DFLSSIZ32	(1L << 21)	/* 32bit default stack size (2MB) */
     97  1.2.2.2       tls #endif
     98  1.2.2.2       tls 
     99  1.2.2.2       tls #define	VM_MIN_ADDRESS		((vaddr_t) 0x0)
    100  1.2.2.2       tls #define	VM_MAXUSER_ADDRESS	((vaddr_t) (1L << 48) - PAGE_SIZE)
    101  1.2.2.2       tls #define	VM_MAX_ADDRESS		VM_MAXUSER_ADDRESS
    102  1.2.2.2       tls 
    103  1.2.2.2       tls #define VM_MAXUSER_ADDRESS32	((vaddr_t) 0x7ffff000)
    104  1.2.2.2       tls 
    105  1.2.2.2       tls /*
    106  1.2.2.2       tls  * Give ourselves 64GB of mappable kernel space.  That leaves the rest
    107  1.2.2.2       tls  * to be user for directly mapped (block addressable) addresses.
    108  1.2.2.2       tls  */
    109  1.2.2.2       tls #define VM_MIN_KERNEL_ADDRESS	((vaddr_t) 0xffffffc000000000L)
    110  1.2.2.2       tls #define VM_MAX_KERNEL_ADDRESS	((vaddr_t) 0xffffffffffff0000L)
    111  1.2.2.2       tls 
    112  1.2.2.2       tls /* virtual sizes (bytes) for various kernel submaps */
    113  1.2.2.2       tls #define USRIOSIZE		(PAGE_SIZE / 8)
    114  1.2.2.2       tls #define VM_PHYS_SIZE		(USRIOSIZE * PAGE_SIZE)
    115  1.2.2.2       tls 
    116  1.2.2.2       tls /*
    117  1.2.2.2       tls  * Since we have the address space, we map all of physical memory (RAM)
    118  1.2.2.2       tls  * using block page table entries.
    119  1.2.2.2       tls  */
    120  1.2.2.2       tls #define AARCH64_KSEG_MASK	((vaddr_t) 0xffff000000000000L)
    121  1.2.2.2       tls #define AARCH64_KSEG_START	AARCH64_KSEG_MASK
    122  1.2.2.2       tls #define	AARCH64_KMEMORY_BASE	AARCH64_KSEG_MASK
    123  1.2.2.2       tls #define AARCH64_KVA_P(va)	(((vaddr_t) (va) & AARCH64_KSEG_MASK) != 0)
    124  1.2.2.2       tls #define AARCH64_PA_TO_KVA(pa)	((vaddr_t) ((pa) | AARCH64_KSEG_START))
    125  1.2.2.2       tls #define AARCH64_KVA_TO_PA(va)	((paddr_t) ((pa) & ~AARCH64_KSEG_MASK))
    126  1.2.2.2       tls 
    127  1.2.2.2       tls /* */
    128  1.2.2.2       tls #define VM_PHYSSEG_MAX		16              /* XXX */
    129  1.2.2.2       tls #define VM_PHYSSEG_STRAT	VM_PSTRAT_BSEARCH
    130  1.2.2.2       tls 
    131  1.2.2.2       tls #define VM_NFREELIST		2
    132  1.2.2.2       tls #define	VM_FREELIST_DEFAULT	0
    133  1.2.2.2       tls #define VM_FREELIST_FIRST4GB	1
    134  1.2.2.2       tls 
    135  1.2.2.2       tls #elif defined(__arm__)
    136  1.2.2.2       tls 
    137  1.2.2.3  jdolecek // These exist for building the RUMP libraries with MKCOMPAT
    138  1.2.2.3  jdolecek 
    139  1.2.2.3  jdolecek #define KERNEL_BASE		0x80000000
    140  1.2.2.3  jdolecek #define PGSHIFT			12
    141  1.2.2.3  jdolecek #define	NBPG			(1 << PGSHIFT)
    142  1.2.2.3  jdolecek #define VM_PHYSSEG_MAX		1
    143  1.2.2.3  jdolecek #define VM_NFREELIST		1
    144  1.2.2.3  jdolecek #define	VM_FREELIST_DEFAULT	0
    145  1.2.2.3  jdolecek 
    146  1.2.2.2       tls #include <arm/vmparam.h>
    147  1.2.2.2       tls 
    148  1.2.2.2       tls #endif /* __aarch64__/__arm__ */
    149  1.2.2.2       tls 
    150  1.2.2.2       tls #endif /* _AARCH64_VMPARAM_H_ */
    151