Home | History | Annotate | Line # | Download | only in include
vmparam.h revision 1.1
      1 /* $NetBSD: vmparam.h,v 1.1 2014/08/10 05:47:38 matt 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 /*
     38  * AARCH64 supports 3 page sizes: 4KB, 16KB, 64KB.  Each page table can
     39  * even have its own page size.
     40  */
     41 
     42 #ifdef AARCH64_PAGE_SHIFT
     43 #if (1 << AARCH64_PAGE_SHIFT) & ~0x141000
     44 #error AARCH64_PAGE_SHIFT contains an unsupported value.
     45 #endif
     46 #define PAGE_SHIFT	AARCH64_PAGE_SHIFT
     47 #else
     48 #define PAGE_SHIFT	12
     49 #endif
     50 #define PAGE_SIZE	(1 << PAGE_SHIFT)
     51 #define PAGE_MASK	(PAGE_SIZE - 1)
     52 
     53 #if PAGE_SHIFT <= 14
     54 #define USPACE		16384
     55 #else
     56 #define USPACE		65536
     57 #endif
     58 #define	UPAGES		(USPACE >> PAGE_SHIFT)
     59 
     60 /*
     61  * USRSTACK is the top (end) of the user stack.  The user VA space is a
     62  * 48-bit address space starting at 0.  Place the stack at its top end.
     63  */
     64 #define USRSTACK	((vaddr_t) 0x0000ffffffff0000)
     65 #define USRSTACK32	((vaddr_t) 0x7ffff000)
     66 
     67 #ifndef MAXTSIZ
     68 #define	MAXTSIZ		(1L << 30)	/* max text size (1GB) */
     69 #endif
     70 
     71 #ifndef MAXTSIZ32
     72 #define	MAXTSIZ32	(1L << 26)	/* 32bit max text size (64MB) */
     73 #endif
     74 
     75 #ifndef MAXDSIZ
     76 #define	MAXDSIZ		(1L << 36)	/* max data size (64GB) */
     77 #endif
     78 
     79 #ifndef MAXSSIZ
     80 #define	MAXSSIZ		(1L << 26)	/* max stack size (64MB) */
     81 #endif
     82 
     83 #ifndef DFLDSIZ
     84 #define	DFLDSIZ		(1L << 32)	/* default data size (4GB) */
     85 #endif
     86 
     87 #ifndef DFLDSIZ32
     88 #define	DFLDSIZ32	(1L << 27)	/* 32bit default data size (128MB) */
     89 #endif
     90 
     91 #ifndef DFLSSIZ
     92 #define	DFLSSIZ		(1L << 23)	/* default stack size (8MB) */
     93 #endif
     94 
     95 #ifndef DFLSSIZ32
     96 #define	DFLSSIZ32	(1L << 21)	/* 32bit default stack size (2MB) */
     97 #endif
     98 
     99 #define	VM_MIN_ADDRESS		((vaddr_t) 0x0)
    100 #define	VM_MAXUSER_ADDRESS	((vaddr_t) (1L << 48) - PAGE_SIZE)
    101 #define	VM_MAX_ADDRESS		VM_MAXUSER_ADDRESS
    102 
    103 #define VM_MAXUSER_ADDRESS32	((vaddr_t) 0x7ffff000)
    104 
    105 /*
    106  * Give ourselves 64GB of mappable kernel space.  That leaves the rest
    107  * to be user for directly mapped (block addressable) addresses.
    108  */
    109 #define VM_MIN_KERNEL_ADDRESS	((vaddr_t) 0xffffffc000000000L)
    110 #define VM_MAX_KERNEL_ADDRESS	((vaddr_t) 0xffffffffffff0000L)
    111 
    112 /* virtual sizes (bytes) for various kernel submaps */
    113 #define USRIOSIZE		(PAGE_SIZE / 8)
    114 #define VM_PHYS_SIZE		(USRIOSIZE * PAGE_SIZE)
    115 
    116 /*
    117  * Since we have the address space, we map all of physical memory (RAM)
    118  * using block page table entries.
    119  */
    120 #define AARCH64_KSEG_MASK	((vaddr_t) 0xffff000000000000L)
    121 #define AARCH64_KSEG_START	AARCH64_KSEG_MASK
    122 #define	AARCH64_KMEMORY_BASE	AARCH64_KSEG_MASK
    123 #define AARCH64_KVA_P(va)	(((vaddr_t) (va) & AARCH64_KSEG_MASK) != 0)
    124 #define AARCH64_PA_TO_KVA(pa)	((vaddr_t) ((pa) | AARCH64_KSEG_START))
    125 #define AARCH64_KVA_TO_PA(va)	((paddr_t) ((pa) & ~AARCH64_KSEG_MASK))
    126 
    127 /* */
    128 #define VM_PHYSSEG_MAX		16              /* XXX */
    129 #define VM_PHYSSEG_STRAT	VM_PSTRAT_BSEARCH
    130 
    131 #define VM_NFREELIST		2
    132 #define	VM_FREELIST_DEFAULT	0
    133 #define VM_FREELIST_FIRST4GB	1
    134 
    135 #elif defined(__arm__)
    136 
    137 #include <arm/vmparam.h>
    138 
    139 #endif /* __aarch64__/__arm__ */
    140 
    141 #endif /* _AARCH64_VMPARAM_H_ */
    142