1 /* $OpenBSD: param.h,v 1.12 2001/07/06 02:07:41 provos Exp $ */ 2 3 /* 4 * Copyright (c) 1988-1994, The University of Utah and 5 * the Computer Systems Laboratory at the University of Utah (CSL). 6 * All rights reserved. 7 * 8 * Permission to use, copy, modify and distribute this software is hereby 9 * granted provided that (1) source code retains these copyright, permission, 10 * and disclaimer notices, and (2) redistributions including binaries 11 * reproduce the notices in supporting documentation, and (3) all advertising 12 * materials mentioning features or use of this software display the following 13 * acknowledgement: ``This product includes software developed by the 14 * Computer Systems Laboratory at the University of Utah.'' 15 * 16 * THE UNIVERSITY OF UTAH AND CSL ALLOW FREE USE OF THIS SOFTWARE IN ITS "AS 17 * IS" CONDITION. THE UNIVERSITY OF UTAH AND CSL DISCLAIM ANY LIABILITY OF 18 * ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. 19 * 20 * CSL requests users of this software to return to csl-dist@cs.utah.edu any 21 * improvements that they make and grant CSL redistribution rights. 22 * 23 * Utah $Hdr: param.h 1.18 94/12/16$ 24 */ 25 26 #include <machine/cpu.h> 27 #include <machine/intr.h> 28 29 /* 30 * Machine dependent constants for PA-RISC. 31 */ 32 33 #define _MACHINE hppa 34 #define MACHINE "hppa" 35 #define _MACHINE_ARCH hppa 36 #define MACHINE_ARCH "hppa" 37 #define MID_MACHINE MID_HPUX800 38 39 /* 40 * Round p (pointer or byte index) up to a correctly-aligned value for all 41 * data types (int, long, ...). The result is u_int and must be cast to 42 * any desired pointer type. 43 */ 44 #define ALIGNBYTES 7 45 #define ALIGN(p) (((u_long)(p) + ALIGNBYTES) &~ ALIGNBYTES) 46 #define ALIGNED_POINTER(p,t) ((((u_long)(p)) & (sizeof(t) - 1)) == 0) 47 48 #define PAGE_SIZE 4096 49 #define PAGE_MASK (PAGE_SIZE-1) 50 #define PAGE_SHIFT 12 51 52 #define NBPG 4096 /* bytes/page */ 53 #define PGOFSET (NBPG-1) /* byte offset into page */ 54 #define PGSHIFT 12 /* LOG2(NBPG) */ 55 56 #define SEGSHIFT (PGSHIFT + (PGSHIFT-PTESHIFT)) /* LOG2(NBSEG) */ 57 #define NBSEG (1 << SEGSHIFT) /* bytes/segment (quadrant) */ 58 #define SEGOFSET (NBSEG-1) /* byte offset into segment */ 59 60 #define KERNBASE 0x00000000 /* start of kernel virtual */ 61 #define BTOPKERNBASE ((u_long)KERNBASE >> PGSHIFT) 62 63 #define DEV_BSIZE 512 64 #define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */ 65 #define BLKDEV_IOSIZE 2048 66 #define MAXPHYS (64 * 1024) /* max raw I/O transfer size */ 67 68 #define MACHINE_STACK_GROWS_UP 1 /* stack grows to higher addresses */ 69 70 #define SSIZE (1) /* initial stack size/NBPG */ 71 #define SINCR (1) /* increment of stack/NBPG */ 72 73 #define UADDR 0x7ffe6000 /* u-area lives here */ 74 #define USHIFT (3) /* log2(UPAGES) */ 75 #define UPAGES (1<<USHIFT) /* pages of u-area */ 76 #define USPACE (UPAGES * NBPG) /* pages for user struct and kstack */ 77 78 #ifndef MSGBUFSIZE 79 #define MSGBUFSIZE 2*NBPG /* default message buffer size */ 80 #endif 81 82 /* 83 * Constants related to network buffer management. 84 * MCLBYTES must be no larger than the software page size, and, 85 * on machines that exchange pages of input or output buffers with mbuf 86 * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple 87 * of the hardware page size. 88 */ 89 #define MSIZE 256 /* size of an mbuf */ 90 #define MCLSHIFT 11 91 #define MCLBYTES (1 << MCLSHIFT) /* large enough for ether MTU */ 92 #define MCLOFSET (MCLBYTES - 1) 93 #ifndef NMBCLUSTERS 94 #define NMBCLUSTERS (2048) /* cl map size: 1MB */ 95 #endif 96 97 /* 98 * Size of kernel malloc arena in logical pages 99 */ 100 #ifndef NKMEMCLUSTERS 101 #define NKMEMCLUSTERS (16 * 1024 * 1024 / PAGE_SIZE) 102 #endif 103 104 /* pages ("clicks") (4096 bytes) to disk blocks */ 105 #define ctod(x) ((x)<<(PGSHIFT-DEV_BSHIFT)) 106 #define dtoc(x) ((x)>>(PGSHIFT-DEV_BSHIFT)) 107 108 /* pages to bytes */ 109 #define ctob(x) ((x)<<PGSHIFT) 110 #define btoc(x) (((unsigned)(x)+(NBPG-1))>>PGSHIFT) 111 112 #define btodb(bytes) ((unsigned)(bytes) >> DEV_BSHIFT) 113 #define dbtob(db) ((unsigned)(db) << DEV_BSHIFT) 114 115 /* 116 * Map a ``block device block'' to a file system block. 117 * This should be device dependent, and should use the bsize 118 * field from the disk label. 119 * For now though just use DEV_BSIZE. 120 */ 121 #define bdbtofsb(bn) ((bn) / (BLKDEV_IOSIZE/DEV_BSIZE)) 122 123 /* 124 * Mach derived conversion macros 125 */ 126 #define hppa_round_page(x) ((((unsigned long)(x)) + NBPG - 1) & ~(NBPG-1)) 127 #define hppa_trunc_page(x) ((unsigned long)(x) & ~(NBPG-1)) 128 129 #define btop(x) ((unsigned long)(x) >> PGSHIFT) 130 #define ptob(x) ((unsigned long)(x) << PGSHIFT) 131 132 #ifdef _KERNEL 133 #ifdef COMPAT_HPUX 134 /* 135 * Constants/macros for HPUX multiple mapping of user address space. 136 * Pages in the first 256Mb are mapped in at every 256Mb segment. 137 */ 138 #define HPMMMASK 0xF0000000 139 #define ISHPMMADDR(v) 0 /* XXX ...jef */ 140 #define HPMMBASEADDR(v) ((unsigned)(v) & ~HPMMMASK) 141 #endif 142 143 #endif 144