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