1 /** @file
2     Machine dependent constants for the Intel64 Architecture(X64).
3 
4     Copyright (c) 2010-2012, Intel Corporation. All rights reserved.<BR>
5     This program and the accompanying materials are licensed and made available under
6     the terms and conditions of the BSD License that accompanies this distribution.
7     The full text of the license may be found at
8     http://opensource.org/licenses/bsd-license.
9 
10     THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11     WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12 
13  *  $NetBSD: param.h,v 1.3 2006/08/28 13:43:35 yamt Exp
14 **/
15 #ifndef _X64_PARAM_H_
16 #define _X64_PARAM_H_
17 
18 #define _MACHINE      amd64
19 #define MACHINE       "amd64"
20 #define _MACHINE_ARCH x86_64
21 #define MACHINE_ARCH  "x86_64"
22 #define MID_MACHINE   MID_X86_64
23 
24 /*
25  * Round p (pointer or byte index) up to a correctly-aligned value
26  * for all data types (int, long, ...).   The result is u_int and
27  * must be cast to any desired pointer type.
28  *
29  * ALIGNED_POINTER is a boolean macro that checks whether an address
30  * is valid to fetch data elements of type t from on this architecture.
31  * This does not reflect the optimal alignment, just the possibility
32  * (within reasonable limits).
33  *
34  */
35 #define ALIGNBYTES            (sizeof(INT64) - 1)
36 #define ALIGN(p)              (((UINT64)(p) + ALIGNBYTES) &~ALIGNBYTES)
37 #define ALIGNED_POINTER(p,t)  1
38 
39 #define ALIGNBYTES32          (sizeof(INT32) - 1)
40 #define ALIGN32(p)            (((UINT64)(p) + ALIGNBYTES32) &~ALIGNBYTES32)
41 
42 #define PGSHIFT       12    /* LOG2(NBPG) */
43 #define NBPG          (1 << PGSHIFT)  /* bytes/page */
44 #define PGOFSET       (NBPG-1)  /* byte offset into page */
45 #define NPTEPG        (NBPG/(sizeof (pt_entry_t)))
46 
47 #define DEV_BSHIFT    9   /* log2(DEV_BSIZE) */
48 #define DEV_BSIZE     (1 << DEV_BSHIFT)
49 #define BLKDEV_IOSIZE 2048
50 #ifndef MAXPHYS
51   #define MAXPHYS     (64 * 1024) /* max raw I/O transfer size */
52 #endif
53 
54 #define SSIZE         1                 /* initial stack size/NBPG */
55 #define SINCR         1                 /* increment of stack/NBPG */
56 #define UPAGES        5                 /* pages of u-area */
57 #define USPACE        (UPAGES * NBPG)   /* total size of u-area */
58 
59 #ifndef MSGBUFSIZE
60   #define MSGBUFSIZE  4*NBPG          /* default message buffer size */
61 #endif
62 
63 /*
64  * Constants related to network buffer management.
65  * MCLBYTES must be no larger than NBPG (the software page size), and,
66  * on machines that exchange pages of input or output buffers with mbuf
67  * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple
68  * of the hardware page size.
69  */
70 #define MSIZE         512   /* size of an mbuf */
71 
72 #ifndef MCLSHIFT
73   #define MCLSHIFT    11    /* convert bytes to m_buf clusters */
74             /* 2K cluster can hold Ether frame */
75 #endif  /* MCLSHIFT */
76 
77 #define MCLBYTES      (1 << MCLSHIFT) /* size of a m_buf cluster */
78 
79 #ifndef NMBCLUSTERS
80   #ifdef GATEWAY
81     #define NMBCLUSTERS 4096    /* map size, max cluster allocation */
82   #else
83     #define NMBCLUSTERS 2048    /* map size, max cluster allocation */
84   #endif
85 #endif
86 
87 #ifndef NFS_RSIZE
88   #define NFS_RSIZE     32768
89 #endif
90 #ifndef NFS_WSIZE
91   #define NFS_WSIZE     32768
92 #endif
93 
94 #define x86_round_page(x) ((((EFI_ULONG_T)(x)) + PGOFSET) & ~PGOFSET)
95 #define x86_trunc_page(x)   ((EFI_ULONG_T)(x) & ~PGOFSET)
96 #define x86_btop(x)         ((EFI_ULONG_T)(x) >> PGSHIFT)
97 #define x86_ptob(x)         ((EFI_ULONG_T)(x) << PGSHIFT)
98 
99 #define btop(x)           x86_btop(x)
100 #define ptob(x)           x86_ptob(x)
101 #define round_pdr(x)      x86_round_pdr(x)
102 
103 #define mstohz(ms) ((ms + 0UL) * hz / 1000)
104 
105 #endif  /* _X64_PARAM_H_ */
106