xref: /netbsd-src/sys/arch/amd64/include/param.h (revision 23c8222edbfb0f0932d88a8351d3a0cf817dfb9e)
1 /*	$NetBSD: param.h,v 1.1 2003/04/26 18:39:45 fvdl Exp $	*/
2 
3 #ifdef _KERNEL
4 #ifdef _LOCORE
5 #include <machine/psl.h>
6 #else
7 #include <machine/cpu.h>
8 #endif
9 #endif
10 
11 #define	_MACHINE	amd64
12 #define	MACHINE		"amd64"
13 #define	_MACHINE_ARCH	x86_64
14 #define	MACHINE_ARCH	"x86_64"
15 #define MID_MACHINE	MID_X86_64
16 
17 /*
18  * Round p (pointer or byte index) up to a correctly-aligned value
19  * for all data types (int, long, ...).   The result is u_int and
20  * must be cast to any desired pointer type.
21  *
22  * ALIGNED_POINTER is a boolean macro that checks whether an address
23  * is valid to fetch data elements of type t from on this architecture.
24  * This does not reflect the optimal alignment, just the possibility
25  * (within reasonable limits).
26  *
27  */
28 #define ALIGNBYTES		(sizeof(long) - 1)
29 #define ALIGN(p)		(((u_long)(p) + ALIGNBYTES) &~ALIGNBYTES)
30 #define ALIGNED_POINTER(p,t)	1
31 
32 #define ALIGNBYTES32		(sizeof(int) - 1)
33 #define ALIGN32(p)		(((u_long)(p) + ALIGNBYTES32) &~ALIGNBYTES32)
34 
35 #define	PGSHIFT		12		/* LOG2(NBPG) */
36 #define	NBPG		(1 << PGSHIFT)	/* bytes/page */
37 #define	PGOFSET		(NBPG-1)	/* byte offset into page */
38 #define	NPTEPG		(NBPG/(sizeof (pt_entry_t)))
39 
40 /*
41  * XXXfvdl change this (after bootstrap) to take # of bits from
42  * config info into account.
43  */
44 #define	KERNBASE	0xffffffff80000000 /* start of kernel virtual space */
45 #define	KERNTEXTOFF	0xffffffff80100000 /* start of kernel text */
46 #define	BTOPKERNBASE	((u_long)KERNBASE >> PGSHIFT)
47 
48 #define KERNTEXTOFF_HI	0xffffffff
49 #define KERNTEXTOFF_LO	0x80100000
50 
51 #define KERNBASE_HI	0xffffffff
52 #define KERNBASE_LO	0x80000000
53 
54 #define	DEV_BSHIFT	9		/* log2(DEV_BSIZE) */
55 #define	DEV_BSIZE	(1 << DEV_BSHIFT)
56 #define	BLKDEV_IOSIZE	2048
57 #ifndef	MAXPHYS
58 #define	MAXPHYS		(64 * 1024)	/* max raw I/O transfer size */
59 #endif
60 
61 #define	SSIZE		1		/* initial stack size/NBPG */
62 #define	SINCR		1		/* increment of stack/NBPG */
63 #define	UPAGES		5		/* pages of u-area */
64 #define	USPACE		(UPAGES * NBPG)	/* total size of u-area */
65 
66 #ifndef MSGBUFSIZE
67 #define MSGBUFSIZE	4*NBPG		/* default message buffer size */
68 #endif
69 
70 /*
71  * Constants related to network buffer management.
72  * MCLBYTES must be no larger than NBPG (the software page size), and,
73  * on machines that exchange pages of input or output buffers with mbuf
74  * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple
75  * of the hardware page size.
76  */
77 #define	MSIZE		512		/* size of an mbuf */
78 
79 #ifndef MCLSHIFT
80 #define	MCLSHIFT	11		/* convert bytes to m_buf clusters */
81 					/* 2K cluster can hold Ether frame */
82 #endif	/* MCLSHIFT */
83 
84 #define	MCLBYTES	(1 << MCLSHIFT)	/* size of a m_buf cluster */
85 
86 #ifndef NMBCLUSTERS
87 #if defined(_KERNEL_OPT)
88 #include "opt_gateway.h"
89 #endif
90 
91 #ifdef GATEWAY
92 #define	NMBCLUSTERS	4096		/* map size, max cluster allocation */
93 #else
94 #define	NMBCLUSTERS	2048		/* map size, max cluster allocation */
95 #endif
96 #endif
97 
98 #ifndef NFS_RSIZE
99 #define NFS_RSIZE       32768
100 #endif
101 #ifndef NFS_WSIZE
102 #define NFS_WSIZE       32768
103 #endif
104 
105 /*
106  * Minimum and maximum sizes of the kernel malloc arena in PAGE_SIZE-sized
107  * logical pages.
108  */
109 #define	NKMEMPAGES_MIN_DEFAULT	((8 * 1024 * 1024) >> PAGE_SHIFT)
110 #define	NKMEMPAGES_MAX_DEFAULT	((128 * 1024 * 1024) >> PAGE_SHIFT)
111 
112 /* pages ("clicks") to disk blocks */
113 #define	ctod(x)		((x) << (PGSHIFT - DEV_BSHIFT))
114 #define	dtoc(x)		((x) >> (PGSHIFT - DEV_BSHIFT))
115 
116 /* bytes to pages */
117 #define	ctob(x)		((x) << PGSHIFT)
118 #define	btoc(x)		(((x) + PGOFSET) >> PGSHIFT)
119 
120 /* bytes to disk blocks */
121 #define	dbtob(x)	((x) << DEV_BSHIFT)
122 #define	btodb(x)	((x) >> DEV_BSHIFT)
123 
124 /*
125  * Map a ``block device block'' to a file system block.
126  * This should be device dependent, and should use the bsize
127  * field from the disk label.
128  * For now though just use DEV_BSIZE.
129  */
130 #define	bdbtofsb(bn)	((bn) / (BLKDEV_IOSIZE / DEV_BSIZE))
131 
132 /*
133  * XXXfvdl the PD* stuff is different from i386.
134  */
135 /*
136  * Mach derived conversion macros
137  */
138 #define	x86_round_pdr(x) \
139 	((((unsigned long)(x)) + (NBPD_L2 - 1)) & ~(NBPD_L2 - 1))
140 #define	x86_trunc_pdr(x)	((unsigned long)(x) & ~(NBPD_L2 - 1))
141 #define	x86_btod(x)		((unsigned long)(x) >> L2_SHIFT)
142 #define	x86_dtob(x)		((unsigned long)(x) << L2_SHIFT)
143 #define	x86_round_page(x)	((((unsigned long)(x)) + PGOFSET) & ~PGOFSET)
144 #define	x86_trunc_page(x)	((unsigned long)(x) & ~PGOFSET)
145 #define	x86_btop(x)		((unsigned long)(x) >> PGSHIFT)
146 #define	x86_ptob(x)		((unsigned long)(x) << PGSHIFT)
147 
148 #define btop(x)				x86_btop(x)
149 #define ptob(x)				x86_ptob(x)
150 #define round_pdr(x)			x86_round_pdr(x)
151 
152 #define mstohz(ms) ((ms + 0UL) * hz / 1000)
153