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