141474Smckusick /* 241474Smckusick * Copyright (c) 1988 University of Utah. 341474Smckusick * Copyright (c) 1982, 1986, 1990 The Regents of the University of California. 441474Smckusick * All rights reserved. 541474Smckusick * 641474Smckusick * This code is derived from software contributed to Berkeley by 741474Smckusick * the Systems Programming Group of the University of Utah Computer 841474Smckusick * Science Department. 941474Smckusick * 1041474Smckusick * %sccs.include.redist.c% 1141474Smckusick * 1241474Smckusick * from: Utah $Hdr: machparam.h 1.11 89/08/14$ 1341474Smckusick * 14*45755Smckusick * @(#)param.h 7.2 (Berkeley) 12/05/90 1541474Smckusick */ 1641474Smckusick 1741474Smckusick /* 1841474Smckusick * Machine dependent constants for HP9000 series 300. 1941474Smckusick */ 2041474Smckusick #define MACHINE "hp300" 2141474Smckusick 2241474Smckusick #ifndef BYTE_ORDER 2341474Smckusick #include <machine/endian.h> 2441474Smckusick #endif 2541474Smckusick 2641474Smckusick #include <machine/machlimits.h> 2741474Smckusick 2841474Smckusick #define NBPG 4096 /* bytes/page */ 2941474Smckusick #define PGOFSET (NBPG-1) /* byte offset into page */ 3041474Smckusick #define PGSHIFT 12 /* LOG2(NBPG) */ 3141474Smckusick #define NPTEPG (NBPG/(sizeof (struct pte))) 3241474Smckusick 3341474Smckusick #define NBSEG (1024*NBPG) /* bytes/segment */ 3441474Smckusick #define SEGOFSET (NBSEG-1) /* byte offset into segment */ 3541474Smckusick #define SEGSHIFT 22 /* LOG2(NBSEG) */ 3641474Smckusick 3741474Smckusick #define KERNBASE 0x00000000 /* start of kernel virtual */ 3841474Smckusick #define BTOPKERNBASE ((u_long)KERNBASE >> PGSHIFT) 3941474Smckusick 4041474Smckusick #define DEV_BSIZE 512 4141474Smckusick #define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */ 4241474Smckusick #define BLKDEV_IOSIZE 2048 4341474Smckusick #define MAXPHYS (64 * 1024) /* max raw I/O transfer size */ 4441474Smckusick 4541474Smckusick #define CLSIZE 1 4641474Smckusick #define CLSIZELOG2 0 4741474Smckusick 4841474Smckusick #define SSIZE 1 /* initial stack size/NBPG */ 4941474Smckusick #define SINCR 1 /* increment of stack/NBPG */ 5041474Smckusick 5141474Smckusick #define UPAGES 3 /* pages of u-area */ 5241474Smckusick 5341474Smckusick /* 5441474Smckusick * Constants related to network buffer management. 5541474Smckusick * MCLBYTES must be no larger than CLBYTES (the software page size), and, 5641474Smckusick * on machines that exchange pages of input or output buffers with mbuf 5741474Smckusick * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple 5841474Smckusick * of the hardware page size. 5941474Smckusick */ 6041474Smckusick #define MSIZE 128 /* size of an mbuf */ 6141474Smckusick #define MCLBYTES 1024 6241474Smckusick #define MCLSHIFT 10 6341474Smckusick #define MCLOFSET (MCLBYTES - 1) 6441474Smckusick #ifndef NMBCLUSTERS 6541474Smckusick #ifdef GATEWAY 6641474Smckusick #define NMBCLUSTERS 512 /* map size, max cluster allocation */ 6741474Smckusick #else 6841474Smckusick #define NMBCLUSTERS 256 /* map size, max cluster allocation */ 6941474Smckusick #endif 7041474Smckusick #endif 7141474Smckusick 7241474Smckusick /* 7341474Smckusick * Size of kernel malloc arena in CLBYTES-sized logical pages 7441474Smckusick */ 7541474Smckusick #ifndef NKMEMCLUSTERS 7641474Smckusick #define NKMEMCLUSTERS (512*1024/CLBYTES) 7741474Smckusick #endif 7841474Smckusick 7941474Smckusick /* 8041474Smckusick * Some macros for units conversion 8141474Smckusick */ 8241474Smckusick /* Core clicks (4096 bytes) to segments and vice versa */ 8341474Smckusick #define ctos(x) (x) 8441474Smckusick #define stoc(x) (x) 8541474Smckusick 8641474Smckusick /* Core clicks (4096 bytes) to disk blocks */ 8741474Smckusick #define ctod(x) ((x)<<(PGSHIFT-DEV_BSHIFT)) 8841474Smckusick #define dtoc(x) ((x)>>(PGSHIFT-DEV_BSHIFT)) 8941474Smckusick #define dtob(x) ((x)<<DEV_BSHIFT) 9041474Smckusick 9141474Smckusick /* clicks to bytes */ 9241474Smckusick #define ctob(x) ((x)<<PGSHIFT) 9341474Smckusick 9441474Smckusick /* bytes to clicks */ 9541474Smckusick #define btoc(x) (((unsigned)(x)+(NBPG-1))>>PGSHIFT) 9641474Smckusick 9741474Smckusick #define btodb(bytes) /* calculates (bytes / DEV_BSIZE) */ \ 9841474Smckusick ((unsigned)(bytes) >> DEV_BSHIFT) 9941474Smckusick #define dbtob(db) /* calculates (db * DEV_BSIZE) */ \ 10041474Smckusick ((unsigned)(db) << DEV_BSHIFT) 10141474Smckusick 10241474Smckusick /* 10341474Smckusick * Map a ``block device block'' to a file system block. 10441474Smckusick * This should be device dependent, and will be if we 10541474Smckusick * add an entry to cdevsw/bdevsw for that purpose. 10641474Smckusick * For now though just use DEV_BSIZE. 10741474Smckusick */ 10841474Smckusick #define bdbtofsb(bn) ((bn) / (BLKDEV_IOSIZE/DEV_BSIZE)) 10941474Smckusick 11041474Smckusick /* 111*45755Smckusick * Mach derived conversion macros 112*45755Smckusick */ 113*45755Smckusick #define hp300_round_seg(x) ((((unsigned)(x)) + NBSEG - 1) & ~(NBSEG-1)) 114*45755Smckusick #define hp300_trunc_seg(x) ((unsigned)(x) & ~(NBSEG-1)) 115*45755Smckusick #define hp300_round_page(x) ((((unsigned)(x)) + NBPG - 1) & ~(NBPG-1)) 116*45755Smckusick #define hp300_trunc_page(x) ((unsigned)(x) & ~(NBPG-1)) 117*45755Smckusick #define hp300_btos(x) ((unsigned)(x) >> SEGSHIFT) 118*45755Smckusick #define hp300_stob(x) ((unsigned)(x) << SEGSHIFT) 119*45755Smckusick #define hp300_btop(x) ((unsigned)(x) >> PGSHIFT) 120*45755Smckusick #define hp300_ptob(x) ((unsigned)(x) << PGSHIFT) 121*45755Smckusick 122*45755Smckusick /* 12341474Smckusick * Macros to decode processor status word. 12441474Smckusick */ 12541474Smckusick #define USERMODE(ps) (((ps) & PSL_S) == 0) 12641474Smckusick #define BASEPRI(ps) (((ps) & PSL_IPL7) == 0) 12741474Smckusick 12841474Smckusick #ifdef KERNEL 12941474Smckusick #ifndef LOCORE 13041474Smckusick int cpuspeed; 13141474Smckusick #define DELAY(n) { register int N = cpuspeed * (n); while (--N > 0); } 13241474Smckusick #endif 13341474Smckusick 13441474Smckusick #else KERNEL 13541474Smckusick #define DELAY(n) { register int N = (n); while (--N > 0); } 13641474Smckusick #endif KERNEL 13741474Smckusick 13841474Smckusick #ifdef HPUXCOMPAT 13941474Smckusick /* 14041474Smckusick * Constants/macros for HPUX multiple mapping of user address space. 14141474Smckusick * Pages in the first 256Mb are mapped in at every 256Mb segment. 14241474Smckusick */ 14341474Smckusick #define HPMMMASK 0xF0000000 14441474Smckusick #define ISHPMMADDR(v) \ 14541474Smckusick ((u.u_pcb.pcb_flags&PCB_HPUXMMAP) && ((unsigned)(v)&HPMMMASK) != HPMMMASK) 14641474Smckusick #define HPMMBASEADDR(v) ((unsigned)(v) & ~HPMMMASK) 14741474Smckusick #endif 148