1 /* $NetBSD: param.h,v 1.30 2019/03/16 11:50:48 rin Exp $ */ 2 3 #ifdef __x86_64__ 4 5 #ifndef XENPV 6 /* Must be defined before cpu.h */ 7 #define MAXCPUS 256 8 #endif 9 10 #ifdef _KERNEL 11 #include <machine/cpu.h> 12 #if defined(_KERNEL_OPT) 13 #include "opt_kasan.h" 14 #include "opt_kleak.h" 15 #endif 16 #endif 17 18 #define _MACHINE amd64 19 #define MACHINE "amd64" 20 #define _MACHINE_ARCH x86_64 21 #define MACHINE_ARCH "x86_64" 22 #define MID_MACHINE MID_X86_64 23 24 #define ALIGNED_POINTER(p,t) 1 25 26 /* 27 * Align stack as required by AMD64 System V ABI. This is because 28 * (1) we want to bypass libc/csu in LLDB, and 29 * (2) rtld in glibc >= 2.23 for Linux/x86_64 requires it. 30 */ 31 #define STACK_ALIGNBYTES (16 - 1) 32 33 #define ALIGNBYTES32 (sizeof(int) - 1) 34 #define ALIGN32(p) (((u_long)(p) + ALIGNBYTES32) &~ALIGNBYTES32) 35 36 #define PGSHIFT 12 /* LOG2(NBPG) */ 37 #define NBPG (1 << PGSHIFT) /* bytes/page */ 38 #define PGOFSET (NBPG-1) /* byte offset into page */ 39 #define NPTEPG (NBPG/(sizeof (pt_entry_t))) 40 41 #define MAXIOMEM 0xffffffffffff 42 43 /* 44 * Maximum physical memory supported by the implementation. 45 */ 46 #define MAXPHYSMEM 0x100000000000ULL /* 16TB */ 47 48 /* 49 * XXXfvdl change this (after bootstrap) to take # of bits from 50 * config info into account. 51 */ 52 #define KERNBASE 0xffffffff80000000 /* start of kernel virtual space */ 53 #define KERNTEXTOFF 0xffffffff80200000 /* start of kernel text */ 54 #define BTOPKERNBASE ((u_long)KERNBASE >> PGSHIFT) 55 56 #define KERNTEXTOFF_HI 0xffffffff 57 #define KERNTEXTOFF_LO 0x80200000 58 59 #define KERNBASE_HI 0xffffffff 60 #define KERNBASE_LO 0x80000000 61 62 #define SSIZE 1 /* initial stack size/NBPG */ 63 #define SINCR 1 /* increment of stack/NBPG */ 64 65 #if defined(KASAN) || defined(KLEAK) 66 #define UPAGES 8 67 #elif defined(DIAGNOSTIC) 68 #define UPAGES 5 /* pages of u-area (1 for redzone) */ 69 #else 70 #define UPAGES 4 /* pages of u-area */ 71 #endif 72 #define USPACE (UPAGES * NBPG) /* total size of u-area */ 73 74 #ifndef MSGBUFSIZE 75 #define MSGBUFSIZE (16*NBPG) /* default message buffer size */ 76 #endif 77 78 /* 79 * Constants related to network buffer management. 80 * MCLBYTES must be no larger than NBPG (the software page size), and, 81 * on machines that exchange pages of input or output buffers with mbuf 82 * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple 83 * of the hardware page size. 84 */ 85 #define MSIZE 512 /* size of an mbuf */ 86 87 #ifndef MCLSHIFT 88 #define MCLSHIFT 11 /* convert bytes to m_buf clusters */ 89 /* 2K cluster can hold Ether frame */ 90 #endif /* MCLSHIFT */ 91 92 #define MCLBYTES (1 << MCLSHIFT) /* size of a m_buf cluster */ 93 94 #ifndef NFS_RSIZE 95 #define NFS_RSIZE 32768 96 #endif 97 #ifndef NFS_WSIZE 98 #define NFS_WSIZE 32768 99 #endif 100 101 /* 102 * Minimum size of the kernel kmem_arena in PAGE_SIZE-sized 103 * logical pages. 104 * No enforced maximum on amd64. 105 */ 106 #define NKMEMPAGES_MIN_DEFAULT ((8 * 1024 * 1024) >> PAGE_SHIFT) 107 #define NKMEMPAGES_MAX_UNLIMITED 1 108 109 /* 110 * XXXfvdl the PD* stuff is different from i386. 111 */ 112 /* 113 * Mach derived conversion macros 114 */ 115 #define x86_round_pdr(x) \ 116 ((((unsigned long)(x)) + (NBPD_L2 - 1)) & ~(NBPD_L2 - 1)) 117 #define x86_trunc_pdr(x) ((unsigned long)(x) & ~(NBPD_L2 - 1)) 118 #define x86_btod(x) ((unsigned long)(x) >> L2_SHIFT) 119 #define x86_dtob(x) ((unsigned long)(x) << L2_SHIFT) 120 #define x86_round_page(x) ((((unsigned long)(x)) + PGOFSET) & ~PGOFSET) 121 #define x86_trunc_page(x) ((unsigned long)(x) & ~PGOFSET) 122 #define x86_btop(x) ((unsigned long)(x) >> PGSHIFT) 123 #define x86_ptob(x) ((unsigned long)(x) << PGSHIFT) 124 125 #define btop(x) x86_btop(x) 126 #define ptob(x) x86_ptob(x) 127 128 #define mstohz(ms) ((ms + 0UL) * hz / 1000) 129 130 #else /* __x86_64__ */ 131 132 #include <i386/param.h> 133 134 #endif /* __x86_64__ */ 135