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