1: /* 2: * Copyright (c) 1986 Regents of the University of California. 3: * All rights reserved. The Berkeley software License Agreement 4: * specifies the terms and conditions for redistribution. 5: * 6: * @(#)machparam.h 1.4 (2.11BSD GTE) 1998/9/15 7: */ 8: 9: /* 10: * Machine dependent constants for PDP. 11: */ 12: #ifndef ENDIAN 13: /* 14: * Definitions for byte order, 15: * according to byte significance from low address to high. 16: */ 17: #define LITTLE 1234 /* least-significant byte first (vax) */ 18: #define BIG 4321 /* most-significant byte first */ 19: #define PDP 3412 /* LSB first in word, MSW first in long (pdp) */ 20: #define ENDIAN PDP /* byte order on pdp */ 21: 22: /* 23: * Macros for network/external number representation conversion. 24: */ 25: #if ENDIAN == BIG && !defined(lint) 26: #define ntohl(x) (x) 27: #define ntohs(x) (x) 28: #define htonl(x) (x) 29: #define htons(x) (x) 30: #else 31: #include <sys/types.h> 32: u_short ntohs(), htons(); 33: u_long ntohl(), htonl(); 34: #endif 35: 36: #define CHAR_BIT NBBY 37: #define CHAR_MAX 0x7f 38: #define CHAR_MIN 0x80 39: #define CLK_TCK 60 /* for times() */ 40: #define INT_MAX 0x7fff 41: #define INT_MIN 0x8000 42: #define LONG_MAX 0x7fffffff 43: #define LONG_MIN 0x80000000 44: #define SCHAR_MAX 0x7f 45: #define SCHAR_MIN 0x80 46: #define SHRT_MAX 0x7fff 47: #define SHRT_MIN 0x8000 48: #define UCHAR_MAX 0xff 49: #define UINT_MAX ((unsigned int)0xffff) 50: #define ULONG_MAX 0x7fffffff 51: #define USHRT_MAX ((unsigned short)0xffff) 52: 53: #define NBPG 512 /* bytes/page */ 54: #define PGOFSET (NBPG-1) /* byte offset into page */ 55: #define PGSHIFT 9 /* LOG2(NBPG) */ 56: 57: #define DEV_BSIZE 1024 58: #define DEV_BSHIFT 10 /* log2(DEV_BSIZE) */ 59: #define DEV_BMASK 0x3ffL /* DEV_BSIZE - 1 */ 60: 61: #define CLSIZE 2 62: #define CLSIZELOG2 1 63: 64: #define SSIZE 20 /* initial stack size (*64 bytes) */ 65: #define SINCR 20 /* increment of stack (*64 bytes) */ 66: 67: /* machine dependent stuff for core files */ 68: #define TXTRNDSIZ 8192L 69: #define stacktop(siz) (0x10000L) 70: #define stackbas(siz) (0x10000L-(siz)) 71: 72: /* 73: * User area: a user structure, followed by a stack for the networking code 74: * (running in supervisor space on the PDP-11), followed by the kernel 75: * stack. The numbers for NET_SSIZE and KERN_SSIZE are determined 76: * empirically. 77: * 78: * Note that the SBASE and STOP constants are only used by the assembly code, 79: * but are defined here to localize information about the user area's 80: * layout (see pdp/genassym.c). Note also that a networking stack is always 81: * allocated even for non-networking systems. This prevents problems with 82: * applications having to be recompiled for networking versus non-networking 83: * systems. 84: */ 85: #define NET_SSIZE 16 /* size of the network stack (*64) */ 86: #define KERN_SSIZE 32 /* size of the kernel stack (*64) */ 87: #define USIZE (btoc(sizeof(struct user)) + NET_SSIZE + KERN_SSIZE) 88: 89: #define NET_SBASE ctob(btoc(sizeof(struct user))) 90: #define NET_STOP (NET_SBASE + ctob(NET_SSIZE)) 91: #define KERN_SBASE NET_STOP 92: #define KERN_STOP (KERN_SBASE + ctob(KERN_SSIZE)) 93: 94: /* 95: * Some macros for units conversion 96: */ 97: /* Core clicks (64 bytes) to segments and vice versa */ 98: #define ctos(x) (((x)+127)/128) 99: #define stoc(x) ((x)*128) 100: 101: /* Core clicks (64 bytes) to disk blocks */ 102: #define ctod(x) (((x)+7)>>3) 103: 104: /* clicks to bytes */ 105: #define ctob(x) ((x)<<6) 106: 107: /* bytes to clicks */ 108: #define btoc(x) ((((unsigned)(x)+63)>>6)) 109: 110: /* these should be fixed to use unsigned longs, if we ever get them. */ 111: #define btodb(bytes) /* calculates (bytes / DEV_BSIZE) */ \ 112: ((long)(bytes) >> DEV_BSHIFT) 113: #define dbtob(db) /* calculates (db * DEV_BSIZE) */ \ 114: ((long)(db) << DEV_BSHIFT) 115: 116: /* clicks to KB */ 117: #define ctok(x) (((x)>>4)&07777) 118: 119: /* 120: * Macros to decode processor status word. 121: */ 122: #define SUPVMODE(ps) (((ps) & PSL_CURMOD) == PSL_CURSUP) 123: #define USERMODE(ps) (((ps) & PSL_USERSET) == PSL_USERSET) 124: #define BASEPRI(ps) (((ps) & PSL_IPL) == 0) 125: 126: #define DELAY(n) { long N = ((long)(n))<<1; while (--N > 0); } 127: 128: /* 129: * Treat ps as byte, to allow restoring value from mfps/movb. 130: * (see splfix.*.sed) 131: */ 132: #define PS_LOBYTE ((char *)0177776) 133: #define splx(ops) (*PS_LOBYTE = ((char)(ops))) 134: 135: /* 136: * high int of a long 137: * low int of a long 138: */ 139: #define hiint(long) (((int *)&(long))[0]) 140: #define loint(long) (((int *)&(long))[1]) 141: 142: /* 143: * SUPERADD is used to distinguish a supervisor-mode address from a 144: * kernel mode address to insure uniqueness over both address spaces. 145: */ 146: #define SUPERADD(add) ((int)(add)|01) 147: #define KERNELADD(add) ((int)(add)&~01) 148: #define ISSUPERADD(add) ((int)(add)&01) 149: 150: #endif ENDIAN