1 /* $NetBSD: param.h,v 1.27 2018/12/02 21:00:13 maxv Exp $ */ 2 3 #ifdef __x86_64__ 4 5 #ifndef XEN 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 #define ALIGNBYTES32 (sizeof(int) - 1) 27 #define ALIGN32(p) (((u_long)(p) + ALIGNBYTES32) &~ALIGNBYTES32) 28 29 #define PGSHIFT 12 /* LOG2(NBPG) */ 30 #define NBPG (1 << PGSHIFT) /* bytes/page */ 31 #define PGOFSET (NBPG-1) /* byte offset into page */ 32 #define NPTEPG (NBPG/(sizeof (pt_entry_t))) 33 34 #define MAXIOMEM 0xffffffffffff 35 36 /* 37 * Maximum physical memory supported by the implementation. 38 */ 39 #define MAXPHYSMEM 0x100000000000ULL /* 16TB */ 40 41 /* 42 * XXXfvdl change this (after bootstrap) to take # of bits from 43 * config info into account. 44 */ 45 #define KERNBASE 0xffffffff80000000 /* start of kernel virtual space */ 46 #define KERNTEXTOFF 0xffffffff80200000 /* start of kernel text */ 47 #define BTOPKERNBASE ((u_long)KERNBASE >> PGSHIFT) 48 49 #define KERNTEXTOFF_HI 0xffffffff 50 #define KERNTEXTOFF_LO 0x80200000 51 52 #define KERNBASE_HI 0xffffffff 53 #define KERNBASE_LO 0x80000000 54 55 #define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */ 56 #define DEV_BSIZE (1 << DEV_BSHIFT) 57 #define BLKDEV_IOSIZE 2048 58 #ifndef MAXPHYS 59 #define MAXPHYS (64 * 1024) /* max raw I/O transfer size */ 60 #endif 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