141474Smckusick /* 241474Smckusick * Copyright (c) 1988 University of Utah. 363160Sbostic * Copyright (c) 1982, 1986, 1990, 1993 463160Sbostic * The Regents of the University of California. 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 * 1257319Shibler * from: Utah $Hdr: machparam.h 1.16 92/12/20$ 1341474Smckusick * 14*68631Smckusick * @(#)param.h 8.2 (Berkeley) 03/29/95 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 */ 2753672Sbostic #define ALIGNBYTES 3 2853672Sbostic #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 3553928Shibler #define NBSEG 0x400000 /* 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 5457319Shibler #define UPAGES 2 /* 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 */ 6457319Shibler #define MCLBYTES 2048 /* large enough for ether MTU */ 6557319Shibler #define MCLSHIFT 11 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 9357319Shibler #define LABELSECTOR (1024/DEV_BSIZE) 9457319Shibler #define LABELOFFSET 0 9557319Shibler 9641474Smckusick #define btodb(bytes) /* calculates (bytes / DEV_BSIZE) */ \ 97*68631Smckusick ((bytes) >> DEV_BSHIFT) 9841474Smckusick #define dbtob(db) /* calculates (db * DEV_BSIZE) */ \ 99*68631Smckusick ((db) << DEV_BSHIFT) 10041474Smckusick 10141474Smckusick /* 10241474Smckusick * Map a ``block device block'' to a file system block. 10349136Skarels * This should be device dependent, and should use the bsize 10449136Skarels * field from the disk label. 10541474Smckusick * For now though just use DEV_BSIZE. 10641474Smckusick */ 10741474Smckusick #define bdbtofsb(bn) ((bn) / (BLKDEV_IOSIZE/DEV_BSIZE)) 10841474Smckusick 10941474Smckusick /* 11045755Smckusick * Mach derived conversion macros 11145755Smckusick */ 11245755Smckusick #define hp300_round_page(x) ((((unsigned)(x)) + NBPG - 1) & ~(NBPG-1)) 11345755Smckusick #define hp300_trunc_page(x) ((unsigned)(x) & ~(NBPG-1)) 11445755Smckusick #define hp300_btop(x) ((unsigned)(x) >> PGSHIFT) 11545755Smckusick #define hp300_ptob(x) ((unsigned)(x) << PGSHIFT) 11645755Smckusick 11745755Smckusick /* 11849136Skarels * spl functions; all but spl0 are done in-line 11941474Smckusick */ 12049136Skarels #include <machine/psl.h> 12141474Smckusick 12249136Skarels #define _spl(s) \ 12349136Skarels ({ \ 12449136Skarels register int _spl_r; \ 12549136Skarels \ 12649136Skarels asm __volatile ("clrl %0; movew sr,%0; movew %1,sr" : \ 12749136Skarels "&=d" (_spl_r) : "di" (s)); \ 12849136Skarels _spl_r; \ 12949136Skarels }) 13049136Skarels 13149136Skarels /* spl0 requires checking for software interrupts */ 13249136Skarels #define spl1() _spl(PSL_S|PSL_IPL1) 13349136Skarels #define spl2() _spl(PSL_S|PSL_IPL2) 13449136Skarels #define spl3() _spl(PSL_S|PSL_IPL3) 13549136Skarels #define spl4() _spl(PSL_S|PSL_IPL4) 13649136Skarels #define spl5() _spl(PSL_S|PSL_IPL5) 13749136Skarels #define spl6() _spl(PSL_S|PSL_IPL6) 13849136Skarels #define spl7() _spl(PSL_S|PSL_IPL7) 13949136Skarels 14054794Smckusick #define splsoftclock() spl1() 14154794Smckusick #define splnet() spl1() 14254794Smckusick #define splbio() spl5() 14354794Smckusick #define splimp() spl5() 14454794Smckusick #define spltty() spl5() 14554794Smckusick #define splclock() spl6() 14654794Smckusick #define splstatclock() spl6() 14754794Smckusick #define splvm() spl6() 14854794Smckusick #define splhigh() spl7() 14954794Smckusick #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 15950030Sbostic #else 16041474Smckusick #define DELAY(n) { register int N = (n); while (--N > 0); } 16150030Sbostic #endif 16241474Smckusick 16341474Smckusick #ifdef HPUXCOMPAT 16441474Smckusick /* 16541474Smckusick * Constants/macros for HPUX multiple mapping of user address space. 16641474Smckusick * Pages in the first 256Mb are mapped in at every 256Mb segment. 16741474Smckusick */ 16841474Smckusick #define HPMMMASK 0xF0000000 16953928Shibler #define ISHPMMADDR(v) \ 17057319Shibler ((curproc->p_md.md_flags & MDP_HPUXMMAP) && \ 17157319Shibler ((unsigned)(v) & HPMMMASK) && \ 17253928Shibler ((unsigned)(v) & HPMMMASK) != HPMMMASK) 17353928Shibler #define HPMMBASEADDR(v) \ 17453928Shibler ((unsigned)(v) & ~HPMMMASK) 17541474Smckusick #endif 176