1 1.17 thorpej /* $NetBSD: mips_param.h,v 1.17 2000/02/11 19:25:16 thorpej Exp $ */ 2 1.16 simonb 3 1.16 simonb #include <machine/cpu.h> 4 1.5 jonathan 5 1.5 jonathan /* 6 1.5 jonathan * On mips, UPAGES is fixed by sys/arch/mips/mips/locore code 7 1.5 jonathan * to be the number of per-process-wired kernel-stack pages/PTES. 8 1.5 jonathan */ 9 1.5 jonathan 10 1.6 jonathan #define SSIZE 1 /* initial stack size/NBPG */ 11 1.6 jonathan #define SINCR 1 /* increment of stack/NBPG */ 12 1.6 jonathan 13 1.5 jonathan #define UPAGES 2 /* pages of u-area */ 14 1.5 jonathan #define USPACE (UPAGES*NBPG) /* size of u-area in bytes */ 15 1.5 jonathan 16 1.7 leo #ifndef MSGBUFSIZE 17 1.7 leo #define MSGBUFSIZE NBPG /* default message buffer size */ 18 1.7 leo #endif 19 1.1 jonathan 20 1.1 jonathan /* 21 1.1 jonathan * Round p (pointer or byte index) up to a correctly-aligned value for all 22 1.1 jonathan * data types (int, long, ...). The result is u_int and must be cast to 23 1.1 jonathan * any desired pointer type. 24 1.10 jonathan * 25 1.10 jonathan * ALIGNED_POINTER is a boolean macro that checks whether an address 26 1.10 jonathan * is valid to fetch data elements of type t from on this architecture. 27 1.10 jonathan * This does not reflect the optimal alignment, just the possibility 28 1.13 simonb * (within reasonable limits). 29 1.10 jonathan * 30 1.1 jonathan */ 31 1.1 jonathan #define ALIGNBYTES 7 32 1.10 jonathan #define ALIGN(p) (((u_int)(p) + ALIGNBYTES) & ~ALIGNBYTES) 33 1.2 jonathan #define ALIGNED_POINTER(p,t) ((((u_long)(p)) & (sizeof(t)-1)) == 0) 34 1.1 jonathan 35 1.14 shin #ifdef MIPS_16K_PAGE /* enable kernel support for 16k pages */ 36 1.14 shin #define NBPG (1024*16) /* bytes/page */ 37 1.14 shin #define PGOFSET (NBPG-1) /* byte offset into page */ 38 1.14 shin #define PGSHIFT 14 /* LOG2(NBPG) */ 39 1.14 shin #else 40 1.1 jonathan #define NBPG 4096 /* bytes/page */ 41 1.1 jonathan #define PGOFSET (NBPG-1) /* byte offset into page */ 42 1.1 jonathan #define PGSHIFT 12 /* LOG2(NBPG) */ 43 1.14 shin #endif 44 1.1 jonathan #define NPTEPG (NBPG/4) 45 1.1 jonathan 46 1.1 jonathan #define NBSEG 0x400000 /* bytes/segment */ 47 1.1 jonathan #define SEGOFSET (NBSEG-1) /* byte offset into segment */ 48 1.1 jonathan #define SEGSHIFT 22 /* LOG2(NBSEG) */ 49 1.1 jonathan 50 1.1 jonathan /* 51 1.17 thorpej * Minimum and maximum sizes of the kernel malloc arena in PAGE_SIZE-sized 52 1.17 thorpej * logical pages. 53 1.13 simonb */ 54 1.17 thorpej #define NKMEMPAGES_MIN_DEFAULT ((8 * 1024 * 1024) >> PAGE_SHIFT) 55 1.17 thorpej #define NKMEMPAGES_MAX_DEFAULT ((128 * 1024 * 1024) >> PAGE_SHIFT) 56 1.1 jonathan 57 1.1 jonathan /* pages ("clicks") (4096 bytes) to disk blocks */ 58 1.1 jonathan #define ctod(x) ((x) << (PGSHIFT - DEV_BSHIFT)) 59 1.1 jonathan #define dtoc(x) ((x) >> (PGSHIFT - DEV_BSHIFT)) 60 1.1 jonathan 61 1.1 jonathan /* pages to bytes */ 62 1.1 jonathan #define ctob(x) ((x) << PGSHIFT) 63 1.1 jonathan #define btoc(x) (((x) + PGOFSET) >> PGSHIFT) 64 1.1 jonathan 65 1.1 jonathan /* bytes to disk blocks */ 66 1.1 jonathan #define btodb(x) ((x) >> DEV_BSHIFT) 67 1.1 jonathan #define dbtob(x) ((x) << DEV_BSHIFT) 68 1.1 jonathan 69 1.1 jonathan /* 70 1.1 jonathan * Map a ``block device block'' to a file system block. 71 1.1 jonathan * This should be device dependent, and should use the bsize 72 1.1 jonathan * field from the disk label. 73 1.1 jonathan * For now though just use DEV_BSIZE. 74 1.1 jonathan */ 75 1.1 jonathan #define bdbtofsb(bn) ((bn) / (BLKDEV_IOSIZE/DEV_BSIZE)) 76 1.1 jonathan 77 1.1 jonathan /* 78 1.1 jonathan * Mach derived conversion macros 79 1.1 jonathan */ 80 1.1 jonathan #define mips_round_page(x) ((((unsigned)(x)) + NBPG - 1) & ~(NBPG-1)) 81 1.1 jonathan #define mips_trunc_page(x) ((unsigned)(x) & ~(NBPG-1)) 82 1.1 jonathan #define mips_btop(x) ((unsigned)(x) >> PGSHIFT) 83 1.1 jonathan #define mips_ptob(x) ((unsigned)(x) << PGSHIFT) 84