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*53672Sbostic * @(#)param.h 7.10 (Berkeley) 05/26/92 1541474Smckusick */ 1641474Smckusick 1741474Smckusick /* 1841474Smckusick * Machine dependent constants for HP9000 series 300. 1941474Smckusick */ 2041474Smckusick #define MACHINE "hp300" 2141474Smckusick 2250140Ssklower /* 2352588Sbostic * Round p (pointer or byte index) up to a correctly-aligned value for all 2452588Sbostic * data types (int, long, ...). The result is u_int and must be cast to 2552588Sbostic * any desired pointer type. 2650140Ssklower */ 27*53672Sbostic #define ALIGNBYTES 3 28*53672Sbostic #define ALIGN(p) (((u_int)(p) + ALIGNBYTES) &~ ALIGNBYTES) 2950140Ssklower 3041474Smckusick #define NBPG 4096 /* bytes/page */ 3141474Smckusick #define PGOFSET (NBPG-1) /* byte offset into page */ 3241474Smckusick #define PGSHIFT 12 /* LOG2(NBPG) */ 3341474Smckusick #define NPTEPG (NBPG/(sizeof (struct pte))) 3441474Smckusick 3541474Smckusick #define NBSEG (1024*NBPG) /* bytes/segment */ 3641474Smckusick #define SEGOFSET (NBSEG-1) /* byte offset into segment */ 3741474Smckusick #define SEGSHIFT 22 /* LOG2(NBSEG) */ 3841474Smckusick 3941474Smckusick #define KERNBASE 0x00000000 /* start of kernel virtual */ 4041474Smckusick #define BTOPKERNBASE ((u_long)KERNBASE >> PGSHIFT) 4141474Smckusick 4241474Smckusick #define DEV_BSIZE 512 4341474Smckusick #define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */ 4441474Smckusick #define BLKDEV_IOSIZE 2048 4541474Smckusick #define MAXPHYS (64 * 1024) /* max raw I/O transfer size */ 4641474Smckusick 4741474Smckusick #define CLSIZE 1 4841474Smckusick #define CLSIZELOG2 0 4941474Smckusick 5049136Skarels /* NOTE: SSIZE, SINCR and UPAGES must be multiples of CLSIZE */ 5141474Smckusick #define SSIZE 1 /* initial stack size/NBPG */ 5241474Smckusick #define SINCR 1 /* increment of stack/NBPG */ 5341474Smckusick 5441474Smckusick #define UPAGES 3 /* pages of u-area */ 5541474Smckusick 5641474Smckusick /* 5741474Smckusick * Constants related to network buffer management. 5841474Smckusick * MCLBYTES must be no larger than CLBYTES (the software page size), and, 5941474Smckusick * on machines that exchange pages of input or output buffers with mbuf 6041474Smckusick * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple 6141474Smckusick * of the hardware page size. 6241474Smckusick */ 6341474Smckusick #define MSIZE 128 /* size of an mbuf */ 6441474Smckusick #define MCLBYTES 1024 6541474Smckusick #define MCLSHIFT 10 6641474Smckusick #define MCLOFSET (MCLBYTES - 1) 6741474Smckusick #ifndef NMBCLUSTERS 6841474Smckusick #ifdef GATEWAY 6941474Smckusick #define NMBCLUSTERS 512 /* map size, max cluster allocation */ 7041474Smckusick #else 7141474Smckusick #define NMBCLUSTERS 256 /* map size, max cluster allocation */ 7241474Smckusick #endif 7341474Smckusick #endif 7441474Smckusick 7541474Smckusick /* 7641474Smckusick * Size of kernel malloc arena in CLBYTES-sized logical pages 7741474Smckusick */ 7841474Smckusick #ifndef NKMEMCLUSTERS 7950266Skarels #define NKMEMCLUSTERS (2048*1024/CLBYTES) 8041474Smckusick #endif 8141474Smckusick 8249427Skarels /* pages ("clicks") (4096 bytes) to disk blocks */ 8341474Smckusick #define ctod(x) ((x)<<(PGSHIFT-DEV_BSHIFT)) 8441474Smckusick #define dtoc(x) ((x)>>(PGSHIFT-DEV_BSHIFT)) 8541474Smckusick #define dtob(x) ((x)<<DEV_BSHIFT) 8641474Smckusick 8749427Skarels /* pages to bytes */ 8841474Smckusick #define ctob(x) ((x)<<PGSHIFT) 8941474Smckusick 9049427Skarels /* bytes to pages */ 9141474Smckusick #define btoc(x) (((unsigned)(x)+(NBPG-1))>>PGSHIFT) 9241474Smckusick 9341474Smckusick #define btodb(bytes) /* calculates (bytes / DEV_BSIZE) */ \ 9441474Smckusick ((unsigned)(bytes) >> DEV_BSHIFT) 9541474Smckusick #define dbtob(db) /* calculates (db * DEV_BSIZE) */ \ 9641474Smckusick ((unsigned)(db) << DEV_BSHIFT) 9741474Smckusick 9841474Smckusick /* 9941474Smckusick * Map a ``block device block'' to a file system block. 10049136Skarels * This should be device dependent, and should use the bsize 10149136Skarels * field from the disk label. 10241474Smckusick * For now though just use DEV_BSIZE. 10341474Smckusick */ 10441474Smckusick #define bdbtofsb(bn) ((bn) / (BLKDEV_IOSIZE/DEV_BSIZE)) 10541474Smckusick 10641474Smckusick /* 10745755Smckusick * Mach derived conversion macros 10845755Smckusick */ 10945755Smckusick #define hp300_round_seg(x) ((((unsigned)(x)) + NBSEG - 1) & ~(NBSEG-1)) 11045755Smckusick #define hp300_trunc_seg(x) ((unsigned)(x) & ~(NBSEG-1)) 11145755Smckusick #define hp300_round_page(x) ((((unsigned)(x)) + NBPG - 1) & ~(NBPG-1)) 11245755Smckusick #define hp300_trunc_page(x) ((unsigned)(x) & ~(NBPG-1)) 11345755Smckusick #define hp300_btos(x) ((unsigned)(x) >> SEGSHIFT) 11445755Smckusick #define hp300_stob(x) ((unsigned)(x) << SEGSHIFT) 11545755Smckusick #define hp300_btop(x) ((unsigned)(x) >> PGSHIFT) 11645755Smckusick #define hp300_ptob(x) ((unsigned)(x) << PGSHIFT) 11745755Smckusick 11845755Smckusick /* 11949136Skarels * spl functions; all but spl0 are done in-line 12041474Smckusick */ 12149136Skarels #include <machine/psl.h> 12241474Smckusick 12349136Skarels #define _spl(s) \ 12449136Skarels ({ \ 12549136Skarels register int _spl_r; \ 12649136Skarels \ 12749136Skarels asm __volatile ("clrl %0; movew sr,%0; movew %1,sr" : \ 12849136Skarels "&=d" (_spl_r) : "di" (s)); \ 12949136Skarels _spl_r; \ 13049136Skarels }) 13149136Skarels 13249136Skarels /* spl0 requires checking for software interrupts */ 13349136Skarels #define spl1() _spl(PSL_S|PSL_IPL1) 13449136Skarels #define spl2() _spl(PSL_S|PSL_IPL2) 13549136Skarels #define spl3() _spl(PSL_S|PSL_IPL3) 13649136Skarels #define spl4() _spl(PSL_S|PSL_IPL4) 13749136Skarels #define spl5() _spl(PSL_S|PSL_IPL5) 13849136Skarels #define spl6() _spl(PSL_S|PSL_IPL6) 13949136Skarels #define spl7() _spl(PSL_S|PSL_IPL7) 14049136Skarels 14149136Skarels #define splsoftclock() spl1() 14249136Skarels #define splnet() spl1() 14349136Skarels #define splbio() spl5() 14449136Skarels #define splimp() spl5() 14549136Skarels #define spltty() spl5() 14649136Skarels #define splclock() spl6() 14749136Skarels #define splvm() spl6() 14849136Skarels #define splhigh() spl7() 14949136Skarels #define splsched() spl7() 15049136Skarels 15149136Skarels /* watch out for side effects */ 15249136Skarels #define splx(s) (s & PSL_IPL ? _spl(s) : spl0()) 15349136Skarels 15441474Smckusick #ifdef KERNEL 15541474Smckusick #ifndef LOCORE 15641474Smckusick int cpuspeed; 15741474Smckusick #define DELAY(n) { register int N = cpuspeed * (n); while (--N > 0); } 15841474Smckusick #endif 15941474Smckusick 16050030Sbostic #else 16141474Smckusick #define DELAY(n) { register int N = (n); while (--N > 0); } 16250030Sbostic #endif 16341474Smckusick 16441474Smckusick #ifdef HPUXCOMPAT 16541474Smckusick /* 16641474Smckusick * Constants/macros for HPUX multiple mapping of user address space. 16741474Smckusick * Pages in the first 256Mb are mapped in at every 256Mb segment. 16841474Smckusick */ 16941474Smckusick #define HPMMMASK 0xF0000000 17041474Smckusick #define ISHPMMADDR(v) \ 17149136Skarels ((curproc->p_addr->u_pcb.pcb_flags&PCB_HPUXMMAP) && ((unsigned)(v)&HPMMMASK) != HPMMMASK) 17241474Smckusick #define HPMMBASEADDR(v) ((unsigned)(v) & ~HPMMMASK) 17341474Smckusick #endif 174