1 /* $NetBSD: param.h,v 1.6 2007/10/18 15:28:34 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 5 /* pages of u-area */ 60 #define USPACE (UPAGES * NBPG) /* total size of u-area */ 61 62 #ifndef MSGBUFSIZE 63 #define MSGBUFSIZE 8*NBPG /* default message buffer size */ 64 #endif 65 66 /* 67 * Constants related to network buffer management. 68 * MCLBYTES must be no larger than NBPG (the software page size), and, 69 * on machines that exchange pages of input or output buffers with mbuf 70 * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple 71 * of the hardware page size. 72 */ 73 #define MSIZE 512 /* size of an mbuf */ 74 75 #ifndef MCLSHIFT 76 #define MCLSHIFT 11 /* convert bytes to m_buf clusters */ 77 /* 2K cluster can hold Ether frame */ 78 #endif /* MCLSHIFT */ 79 80 #define MCLBYTES (1 << MCLSHIFT) /* size of a m_buf cluster */ 81 82 #ifndef NMBCLUSTERS 83 #if defined(_KERNEL_OPT) 84 #include "opt_gateway.h" 85 #endif 86 87 #ifdef GATEWAY 88 #define NMBCLUSTERS 4096 /* map size, max cluster allocation */ 89 #else 90 #define NMBCLUSTERS 2048 /* map size, max cluster allocation */ 91 #endif 92 #endif 93 94 #ifndef NFS_RSIZE 95 #define NFS_RSIZE 32768 96 #endif 97 #ifndef NFS_WSIZE 98 #define NFS_WSIZE 32768 99 #endif 100 101 /* 102 * Minimum and maximum sizes of the kernel malloc arena in PAGE_SIZE-sized 103 * logical pages. 104 */ 105 #define NKMEMPAGES_MIN_DEFAULT ((8 * 1024 * 1024) >> PAGE_SHIFT) 106 #define NKMEMPAGES_MAX_DEFAULT ((1 *1024 * 1024 * 1024) >> PAGE_SHIFT) 107 108 /* 109 * XXXfvdl the PD* stuff is different from i386. 110 */ 111 /* 112 * Mach derived conversion macros 113 */ 114 #define x86_round_pdr(x) \ 115 ((((unsigned long)(x)) + (NBPD_L2 - 1)) & ~(NBPD_L2 - 1)) 116 #define x86_trunc_pdr(x) ((unsigned long)(x) & ~(NBPD_L2 - 1)) 117 #define x86_btod(x) ((unsigned long)(x) >> L2_SHIFT) 118 #define x86_dtob(x) ((unsigned long)(x) << L2_SHIFT) 119 #define x86_round_page(x) ((((unsigned long)(x)) + PGOFSET) & ~PGOFSET) 120 #define x86_trunc_page(x) ((unsigned long)(x) & ~PGOFSET) 121 #define x86_btop(x) ((unsigned long)(x) >> PGSHIFT) 122 #define x86_ptob(x) ((unsigned long)(x) << PGSHIFT) 123 124 #define btop(x) x86_btop(x) 125 #define ptob(x) x86_ptob(x) 126 #define round_pdr(x) x86_round_pdr(x) 127 128 #define mstohz(ms) ((ms + 0UL) * hz / 1000) 129