153974Sfujita /* 253974Sfujita * Copyright (c) 1988 University of Utah. 353974Sfujita * Copyright (c) 1992 OMRON Corporation. 4*63194Sbostic * Copyright (c) 1982, 1986, 1990, 1992, 1993 5*63194Sbostic * The Regents of the University of California. All rights reserved. 653974Sfujita * 753974Sfujita * This code is derived from software contributed to Berkeley by 853974Sfujita * the Systems Programming Group of the University of Utah Computer 953974Sfujita * Science Department. 1053974Sfujita * 1153974Sfujita * %sccs.include.redist.c% 1253974Sfujita * 1353974Sfujita * from: Utah $Hdr: machparam.h 1.11 89/08/14$ 1457395Sakito * from: hp300/include/param.h 7.13 (Berkeley) 12/27/92 1553974Sfujita * 16*63194Sbostic * @(#)param.h 8.1 (Berkeley) 06/10/93 1753974Sfujita */ 1853974Sfujita 1953974Sfujita /* 2053974Sfujita * Machine dependent constants for LUNA taken from: 2153974Sfujita * Param.h for HP9000 series 300. 2253974Sfujita */ 2353974Sfujita #define MACHINE "luna68k" 2453974Sfujita 2553974Sfujita /* 2653974Sfujita * Round p (pointer or byte index) up to a correctly-aligned value 2753974Sfujita * for all data types (int, long, ...). The result is u_int and 2853974Sfujita * must be cast to any desired pointer type. 2953974Sfujita */ 3053974Sfujita #define ALIGNBYTES 3 3153974Sfujita #define ALIGN(p) (((u_int)(p) + ALIGNBYTES) &~ ALIGNBYTES) 3253974Sfujita 3353974Sfujita #define NBPG 4096 /* bytes/page */ 3453974Sfujita #define PGOFSET (NBPG-1) /* byte offset into page */ 3553974Sfujita #define PGSHIFT 12 /* LOG2(NBPG) */ 3653974Sfujita #define NPTEPG (NBPG/(sizeof (struct pte))) 3753974Sfujita 3853974Sfujita #define NBSEG 0x400000 /* bytes/segment */ 3953974Sfujita #define SEGOFSET (NBSEG-1) /* byte offset into segment */ 4053974Sfujita #define SEGSHIFT 22 /* LOG2(NBSEG) */ 4153974Sfujita 4253974Sfujita #define KERNBASE 0x00000000 /* start of kernel virtual */ 4353974Sfujita #define BTOPKERNBASE ((u_long)KERNBASE >> PGSHIFT) 4453974Sfujita 4553974Sfujita #define DEV_BSIZE 512 4653974Sfujita #define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */ 4753974Sfujita #define BLKDEV_IOSIZE 2048 4853974Sfujita #define MAXPHYS (64 * 1024) /* max raw I/O transfer size */ 4953974Sfujita 5053974Sfujita #define CLSIZE 1 5153974Sfujita #define CLSIZELOG2 0 5253974Sfujita 5353974Sfujita /* NOTE: SSIZE, SINCR and UPAGES must be multiples of CLSIZE */ 5453974Sfujita #define SSIZE 1 /* initial stack size/NBPG */ 5553974Sfujita #define SINCR 1 /* increment of stack/NBPG */ 5653974Sfujita 5757395Sakito #define UPAGES 2 /* pages of u-area */ 5853974Sfujita 5953974Sfujita /* 6053974Sfujita * Constants related to network buffer management. 6153974Sfujita * MCLBYTES must be no larger than CLBYTES (the software page size), and, 6253974Sfujita * on machines that exchange pages of input or output buffers with mbuf 6353974Sfujita * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple 6453974Sfujita * of the hardware page size. 6553974Sfujita */ 6653974Sfujita #define MSIZE 128 /* size of an mbuf */ 6757395Sakito #define MCLBYTES 2048 /* large enough for ether MTU */ 6857395Sakito #define MCLSHIFT 11 6953974Sfujita #define MCLOFSET (MCLBYTES - 1) 7053974Sfujita #ifndef NMBCLUSTERS 7153974Sfujita #ifdef GATEWAY 7253974Sfujita #define NMBCLUSTERS 512 /* map size, max cluster allocation */ 7353974Sfujita #else 7453974Sfujita #define NMBCLUSTERS 256 /* map size, max cluster allocation */ 7553974Sfujita #endif 7653974Sfujita #endif 7753974Sfujita 7853974Sfujita /* 7953974Sfujita * Size of kernel malloc arena in CLBYTES-sized logical pages 8053974Sfujita */ 8153974Sfujita #ifndef NKMEMCLUSTERS 8253974Sfujita #define NKMEMCLUSTERS (2048*1024/CLBYTES) 8353974Sfujita #endif 8453974Sfujita 8553974Sfujita /* pages ("clicks") (4096 bytes) to disk blocks */ 8653974Sfujita #define ctod(x) ((x)<<(PGSHIFT-DEV_BSHIFT)) 8753974Sfujita #define dtoc(x) ((x)>>(PGSHIFT-DEV_BSHIFT)) 8853974Sfujita #define dtob(x) ((x)<<DEV_BSHIFT) 8953974Sfujita 9053974Sfujita /* pages to bytes */ 9153974Sfujita #define ctob(x) ((x)<<PGSHIFT) 9253974Sfujita 9353974Sfujita /* bytes to pages */ 9453974Sfujita #define btoc(x) (((unsigned)(x)+(NBPG-1))>>PGSHIFT) 9553974Sfujita 9653974Sfujita #define btodb(bytes) /* calculates (bytes / DEV_BSIZE) */ \ 9753974Sfujita ((unsigned)(bytes) >> DEV_BSHIFT) 9853974Sfujita #define dbtob(db) /* calculates (db * DEV_BSIZE) */ \ 9953974Sfujita ((unsigned)(db) << DEV_BSHIFT) 10053974Sfujita 10153974Sfujita /* 10253974Sfujita * Map a ``block device block'' to a file system block. 10353974Sfujita * This should be device dependent, and should use the bsize 10453974Sfujita * field from the disk label. 10553974Sfujita * For now though just use DEV_BSIZE. 10653974Sfujita */ 10753974Sfujita #define bdbtofsb(bn) ((bn) / (BLKDEV_IOSIZE/DEV_BSIZE)) 10853974Sfujita 10953974Sfujita /* 11053974Sfujita * Mach derived conversion macros 11153974Sfujita */ 11253974Sfujita #define luna_round_page(x) ((((unsigned)(x)) + NBPG - 1) & ~(NBPG-1)) 11353974Sfujita #define luna_trunc_page(x) ((unsigned)(x) & ~(NBPG-1)) 11453974Sfujita #define luna_btop(x) ((unsigned)(x) >> PGSHIFT) 11553974Sfujita #define luna_ptob(x) ((unsigned)(x) << PGSHIFT) 11653974Sfujita 11753974Sfujita /* 11853974Sfujita * spl functions; all but spl0 are done in-line 11953974Sfujita */ 12053974Sfujita #include <machine/psl.h> 12153974Sfujita 12253974Sfujita #define _spl(s) \ 12353974Sfujita ({ \ 12453974Sfujita register int _spl_r; \ 12553974Sfujita \ 12653974Sfujita asm __volatile ("clrl %0; movew sr,%0; movew %1,sr" : \ 12753974Sfujita "&=d" (_spl_r) : "di" (s)); \ 12853974Sfujita _spl_r; \ 12953974Sfujita }) 13053974Sfujita 13153974Sfujita /* spl0 requires checking for software interrupts */ 13253974Sfujita #define spl1() _spl(PSL_S|PSL_IPL1) 13353974Sfujita #define spl2() _spl(PSL_S|PSL_IPL2) 13453974Sfujita #define spl3() _spl(PSL_S|PSL_IPL3) 13553974Sfujita #define spl4() _spl(PSL_S|PSL_IPL4) 13653974Sfujita #define spl5() _spl(PSL_S|PSL_IPL5) 13753974Sfujita #define spl6() _spl(PSL_S|PSL_IPL6) 13853974Sfujita #define spl7() _spl(PSL_S|PSL_IPL7) 13953974Sfujita 14055583Sfujita #define splsoftclock() spl1() 14155583Sfujita #define splnet() spl1() 14255583Sfujita #define splbio() spl5() 14355583Sfujita #define splimp() spl5() 14455583Sfujita #define spltty() spl6() 14555583Sfujita #define splclock() spl5() 14655583Sfujita #define splstatclock() spl5() 14755583Sfujita #define splvm() spl6() 14855583Sfujita #define splhigh() spl7() 14955583Sfujita #define splsched() spl7() 15053974Sfujita 15153974Sfujita /* watch out for side effects */ 15253974Sfujita #define splx(s) (s & PSL_IPL ? _spl(s) : spl0()) 15353974Sfujita 15453974Sfujita #ifdef KERNEL 15553974Sfujita #ifndef LOCORE 15653974Sfujita int cpuspeed; 15753974Sfujita #define DELAY(n) { register int N = cpuspeed * (n); while (--N > 0); } 15853974Sfujita #endif 15953974Sfujita 16053974Sfujita #else 16153974Sfujita #define DELAY(n) { register int N = (n); while (--N > 0); } 16253974Sfujita #endif 163