param.h revision 1.8 1 /* $NetBSD: param.h,v 1.8 2008/01/08 13:15:02 yamt Exp $ */
2
3 #ifdef _KERNEL
4 #include <machine/cpu.h>
5 #endif
6
7 #define _MACHINE amd64
8 #define MACHINE "amd64"
9 #define _MACHINE_ARCH x86_64
10 #define MACHINE_ARCH "x86_64"
11 #define MID_MACHINE MID_X86_64
12
13 /*
14 * Round p (pointer or byte index) up to a correctly-aligned value
15 * for all data types (int, long, ...). The result is u_int and
16 * must be cast to any desired pointer type.
17 *
18 * ALIGNED_POINTER is a boolean macro that checks whether an address
19 * is valid to fetch data elements of type t from on this architecture.
20 * This does not reflect the optimal alignment, just the possibility
21 * (within reasonable limits).
22 *
23 */
24 #define ALIGNBYTES (sizeof(long) - 1)
25 #define ALIGN(p) (((u_long)(p) + ALIGNBYTES) &~ALIGNBYTES)
26 #define ALIGNED_POINTER(p,t) 1
27
28 #define ALIGNBYTES32 (sizeof(int) - 1)
29 #define ALIGN32(p) (((u_long)(p) + ALIGNBYTES32) &~ALIGNBYTES32)
30
31 #define PGSHIFT 12 /* LOG2(NBPG) */
32 #define NBPG (1 << PGSHIFT) /* bytes/page */
33 #define PGOFSET (NBPG-1) /* byte offset into page */
34 #define NPTEPG (NBPG/(sizeof (pt_entry_t)))
35
36 /*
37 * XXXfvdl change this (after bootstrap) to take # of bits from
38 * config info into account.
39 */
40 #define KERNBASE 0xffffffff80000000 /* start of kernel virtual space */
41 #define KERNTEXTOFF 0xffffffff80100000 /* start of kernel text */
42 #define BTOPKERNBASE ((u_long)KERNBASE >> PGSHIFT)
43
44 #define KERNTEXTOFF_HI 0xffffffff
45 #define KERNTEXTOFF_LO 0x80100000
46
47 #define KERNBASE_HI 0xffffffff
48 #define KERNBASE_LO 0x80000000
49
50 #define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */
51 #define DEV_BSIZE (1 << DEV_BSHIFT)
52 #define BLKDEV_IOSIZE 2048
53 #ifndef MAXPHYS
54 #define MAXPHYS (64 * 1024) /* max raw I/O transfer size */
55 #endif
56
57 #define SSIZE 1 /* initial stack size/NBPG */
58 #define SINCR 1 /* increment of stack/NBPG */
59 #define UPAGES 3 /* pages of u-area */
60 #define USPACE (UPAGES * NBPG) /* total size of u-area */
61 #define INTRSTACKSIZE 4096
62
63 #ifndef MSGBUFSIZE
64 #define MSGBUFSIZE 8*NBPG /* default message buffer size */
65 #endif
66
67 /*
68 * Constants related to network buffer management.
69 * MCLBYTES must be no larger than NBPG (the software page size), and,
70 * on machines that exchange pages of input or output buffers with mbuf
71 * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple
72 * of the hardware page size.
73 */
74 #define MSIZE 512 /* size of an mbuf */
75
76 #ifndef MCLSHIFT
77 #define MCLSHIFT 11 /* convert bytes to m_buf clusters */
78 /* 2K cluster can hold Ether frame */
79 #endif /* MCLSHIFT */
80
81 #define MCLBYTES (1 << MCLSHIFT) /* size of a m_buf cluster */
82
83 #ifndef NMBCLUSTERS
84 #if defined(_KERNEL_OPT)
85 #include "opt_gateway.h"
86 #endif
87
88 #ifdef GATEWAY
89 #define NMBCLUSTERS 4096 /* map size, max cluster allocation */
90 #else
91 #define NMBCLUSTERS 2048 /* map size, max cluster allocation */
92 #endif
93 #endif
94
95 #ifndef NFS_RSIZE
96 #define NFS_RSIZE 32768
97 #endif
98 #ifndef NFS_WSIZE
99 #define NFS_WSIZE 32768
100 #endif
101
102 /*
103 * Minimum and maximum sizes of the kernel malloc arena in PAGE_SIZE-sized
104 * logical pages.
105 */
106 #define NKMEMPAGES_MIN_DEFAULT ((8 * 1024 * 1024) >> PAGE_SHIFT)
107 #define NKMEMPAGES_MAX_DEFAULT ((1 *1024 * 1024 * 1024) >> PAGE_SHIFT)
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 #define round_pdr(x) x86_round_pdr(x)
128
129 #define mstohz(ms) ((ms + 0UL) * hz / 1000)
130