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