home *** CD-ROM | disk | FTP | other *** search
/ Jason Aller Floppy Collection / 202.img / SCO386N2.TD0 / usr / include / sys / param.h < prev    next >
Encoding:
C/C++ Source or Header  |  1988-05-18  |  9.8 KB  |  333 lines

  1. /*
  2.  *    @(#) param.h 2.3 88/05/18 
  3.  *
  4.  *    Copyright (C) The Santa Cruz Operation, 1984, 1985, 1986, 1987, 1988.
  5.  *    Copyright (C) Microsoft Corporation, 1984, 1985, 1986, 1987, 1988.
  6.  *    This Module contains Proprietary Information of
  7.  *    The Santa Cruz Operation, Microsoft Corporation
  8.  *    and AT&T, and should be treated as Confidential.
  9.  */
  10.  
  11. /*
  12.  * THIS FILE CONTAINS CODE WHICH IS SPECIFIC TO THE
  13.  * INTEL 80286 CPU AND MAY REQUIRE MODIFICATION
  14.  * WHEN ADAPTING XENIX TO NEW HARDWARE.
  15.  */
  16.  
  17. /*
  18.  * Adjustable parameters
  19.  */
  20. #ifdef M_I8086
  21. #define    HZ    20        /* Ticks/second of the clock */
  22. #define    SSIZE    1024        /* initial stack size (bytes) */
  23. #define KSSIZE    1024        /* size of per process kernel stack */
  24. #endif
  25.  
  26. #ifdef M_I286
  27. #define    HZ    50        /* Ticks/second of the clock */
  28. #define    SSIZE    4096        /* initial stack size (bytes) */
  29. #define KSSIZE    1024        /* size of per process kernel stack */
  30. #define OFFUSRPG 0        /* address of U page (for fpsup.s) */
  31. #endif
  32.  
  33. #ifdef M_I386
  34. #define    HZ    50        /* Ticks/second of the clock */
  35. #define    SSIZE    4096        /* initial stack size (bytes) */
  36. #define KSSIZE    2048        /* size of per process kernel stack */
  37.  
  38. #define    USIZE    (u.u_procp->p_usize)        
  39.                 /* size of user block (pages) */
  40. #define    MAXUSIZE    17    /* maximum size of user block (*4k bytes) */
  41.                  /* min size of user block (*4k bytes) */
  42. #define MINUSIZE btoc(sizeof(struct user))
  43.  
  44. #define KERNTBASE    40    /* page directory index for kernel text -
  45.                    this is then moved to KERNBASE + KERNTBASE */
  46.  
  47. #define KERNTADDR    (ctob((KERNTBASE)*NEPT)) 
  48.                 /* kernel text base linear address */
  49.  
  50. #define KERNBASE    950    /* page directory index where kernel resides */
  51. #define KERNADDR    (ctob((KERNBASE)*NEPT)) /* kernel base linear address */
  52.  
  53. #define SPTOFFS        24    /* page directory offset of 
  54.                    sptmap from base of kernel */
  55. #define SPTADDR        (ctob((SPTOFFS)*NEPT)) /* kernel data address of 
  56.                            sptmapped address space */
  57. #define SPTBASE        (KERNBASE+SPTOFFS) /* page directory index for 
  58.                     sptmapped address space */
  59. #define TEXTBASE    600    /* page directory index for first text pt */
  60. #define DATABASE    0    /* page directory index for first data pt */
  61. #define SHMBASE        400    /* page directory index for first shdata pt */
  62. #define PHYSBASE    500    /* pdi for physmem mapped into user space */
  63. #define SHLBBASE    640    /* pdi for shared library text */
  64. #define WEITBASE    1023    /* pdi for mem-mapped weitek coprocessor */
  65.  
  66.  
  67.  
  68. #define TXTPDENT    10    /* number of text page directory entries */
  69. #define DATAPDENT    100    /* number of data page directory entries */
  70. #define SHMPDENT    25    /* number of shared data page dir entries */
  71. #define PHYSPDENT    1    /* number of physmem page dir entries */
  72. #define SHLBPDENT    128    /* " for shared libraries, these are sparse */ 
  73. #define WEITDENT    1    /* " for weitek coprocessor */ 
  74.  
  75. #define WEITEK_START    0xFFC00000
  76. #define WEITEK_END    0xFFC08000
  77.  
  78. #define TAU    (HZ/4)        /* working set scanning period */
  79.                 /* 64K/PGSIZE = num 4K pages per 286 seg */
  80. #define N386PAGEPS (0x10000/PGSIZE)
  81. #endif
  82.  
  83. #define    SINCR    1024        /* increment of stack (bytes) (not used)*/
  84. #define    NOFILE    60        /* max open files per process */
  85. #define    CDLIMIT    (1L<<21)    /* default max write address */
  86. #define    CANBSIZ    256        /* max size of typewriter line */
  87. #define    MSGBUFS    128        /* Characters saved from error messages */
  88. #define    NCARGS    5120        /* # characters in exec arglist */
  89. #define    MAXTTYS    16        /* Max # open ttys */
  90. #define    NIOSTAT    50        /* max number of bufs to keep stats for */
  91. #define    MAXPID    30000        /* max process id */
  92. #define    MAXUID    60000        /* max user id */
  93. #define    MAXLINK    1000        /* max links */
  94. #define BSSIZE        256    /* bytes in bootstring buffer */
  95. #define    NCARGS    5120        /* # characters in exec arglist */
  96. #define MINBUF    40        /* minimum # of buffers */
  97. #define NSEG    2        /* max seg/user (see user.h) 8086 only */
  98.  
  99. /*
  100.  * These are temp to implement statfs without FSS.
  101.  * This should be replaced by var nfstyp in an FSS kernel.
  102.  */
  103.  
  104. #define NFSTYP  1    /* Refers to fstypsw entries, not block size */
  105.  
  106. #define Fs1b    1    /* 512 byte blocks */
  107. #define Fs2b    2    /* 1024 byte blocks */
  108. #define S5FSTYP Fs2b
  109.  
  110. /*
  111.  * priorities
  112.  * probably should not be
  113.  * altered too much
  114.  */
  115.  
  116. #define    PSWP    0
  117. #define    PINOD    10
  118. #define    PRIBIO    20
  119. #define    PZERO    25
  120. #define    NZERO    20
  121. #define PCATCH  0400
  122. #define PMASK    0177    
  123. #define    PPIPE    26
  124. #define    PWAIT    30
  125. #define    PSLEP    40
  126. #define    PUSER    50
  127. #define    PIDLE    127
  128.  
  129. /*
  130.  * fundamental constants of the implementation--
  131.  * cannot be changed easily
  132.  */
  133.  
  134. #define    NBPW    sizeof(int)    /* number of bytes in an integer */
  135.     /*
  136.      *      *** WARNING ***
  137.      * Some io devices may have a problem 
  138.      * if BSIZE is greater than MMPGSZ    
  139.      * If BSIZE changes, so must NSBFILL, BSHIFT,
  140.      * NSHIFT, LINOPB
  141.          */
  142. #define    BSIZE    1024        /* size of secondary block (bytes) */
  143. #define    BSHIFT    10        /* LOG2(BSIZE) */
  144. #define    BMASK    (BSIZE - 1)    /* BSIZE-1 */
  145. #define    BSLOP    0        /* must be 0 for current copyio implemtation*/
  146. #define    NINDIR    (BSIZE/sizeof(daddr_t))
  147. #define    NSHIFT    8        /* LOG2(NINDIR) */
  148. #define    NMASK    (NINDIR - 1)    /* NINDIR-1 */
  149. #define    INOPB    (BSIZE/sizeof(struct dinode))    /* # inodes per block */
  150. #define    LINOPB    4        /* LOG2(INOPB) */
  151. #define    INOSHIFT    4        /* LOG2(INOPB) */
  152. #ifndef NULL            /* bs for util including param and stdio */
  153. #define    NULL    ((char *)0)
  154. #endif
  155. #define    NODEV    (dev_t)(-1)
  156. #define    ROOTINO    ((ino_t)2)    /* i number of all roots */
  157. #define    SUPERB    ((daddr_t)1)    /* block number of the super block */
  158. #define    DIRSIZ    14        /* max characters per directory */
  159. #define    NICINOD    100        /* number of superblock inodes */
  160. #define    NICFREE    100        /* number of superblock free blocks */
  161. #define    NSBFILL    371        /* aligns s_magic, .. at end of super block */
  162.  
  163. #ifdef M_I386
  164. #define    NCPS    1        /* Number of clicks per segment */
  165. #define    NBPC    4096        /* Number of bytes per click */
  166. #define    NDPC    4        /* number of blocks per click */
  167. #define    BPCSHIFT    12    /* LOG2(NBPC) if exact */
  168. #endif
  169.  
  170. #define    FsBSIZE(dev)    BSIZE
  171. #define    FsBSHIFT(dev)    BSHIFT
  172. #define    FsNINDIR(dev)    NINDIR
  173. #define    FsBMASK(dev)    BMASK
  174. #define    FsBOFF(dev, x)    ((x)&BMASK)
  175. #define    FsBNO(dev, x)    (x>>BSHIFT)
  176. #define    FsINOPB(dev)    INOPB
  177. #define    FsLTOP(dev, b)    (b)
  178. #define    FsPTOL(dev, b)    (b)
  179. #define    FsNMASK(dev)    NMASK
  180. #define    FsNSHIFT(dev)    NSHIFT
  181. #define    FsITOD(dev, x)    itod(x)
  182. #define    FsITOO(dev, x)    itoo(x)
  183. #define    FsINOS(dev, x)  ((x&~07)+1)
  184.  
  185. /*
  186.  * MMU parameters.
  187.  */
  188.  
  189. #ifdef M_I8086
  190. #define    PAGESIZE 16        /* size of memory allocation unit */
  191. #define    MMPGSZ    PAGESIZE
  192. #define    PAGEMASK (PAGESIZE - 1)    /* PAGESIZE - 1 */
  193. #define    LPGSIZE    4        /* log 2 of pagesize */
  194. #define LMMPGSZ LPGSIZE
  195. #define MMPGMASK PAGEMASK
  196. #define NPAGEPS        0x1000        /* 64k/MMPGSZ = number of pages/seg */
  197. #define MAXPAGES      0xA000
  198. #define MAXPAGE      MAXPAGES
  199. #define UPGSIZE    sizeof(struct user)
  200. #define USIZE    btoms(UPGSIZE)
  201. #define    STACKSTART(ss)    (USRSTACK - mstob(ss))
  202. #endif
  203.  
  204. #ifdef M_I286
  205. #define    MMPGSZ    512        /* bytes/page in the MMU */
  206. #define    LMMPGSZ    9        /* log2(MMPGSZ) */
  207. #define NPAGEPS    128        /* 64k/MMPGSZ = number of pages per segment */
  208. #define MAXPAGES  32768L
  209. #define USIZE     (u.u_procp->p_usize)
  210. #endif
  211.  
  212. #ifndef M_I386
  213. #ifndef M_I8086            
  214. #ifndef M_I286
  215. ERROR ****)))))        /* error if none defined */
  216. #endif
  217. #endif
  218. #endif
  219.  
  220. #ifdef M_I8086        /* error if any two defined */
  221. #ifdef M_I286
  222. ERROR ****)))))        
  223. #endif
  224. #ifdef M_I386
  225. ERROR ****)))))    
  226. #endif
  227. #endif
  228.  
  229. #ifdef M_I286
  230. #ifdef M_I386
  231. ERROR ****)))))    
  232. #endif
  233. #endif
  234.  
  235.  
  236. /* true if bp is not mapped out */
  237. #ifdef M_I386
  238. #define issabuf(bp)    (1)
  239. #else
  240. #define issabuf(bp)    (bp->b_paddr <= ktop(sabuf[v.v_sabuf]))
  241. #endif
  242.  
  243. #ifdef M_I8086
  244. #define ptok(x) ((caddr_t)x)
  245. #define ktop(x) ((paddr_t)(unsigned)x)
  246. #define copypsize(rpp,rip)    rpp->p_size = rip->p_size;
  247. #define USRSTACK    u.u_topstk
  248. #define    URSBC        14        /* User stk Reg Save area Byte Cnt */
  249. #endif
  250.  
  251. #ifdef M_I286
  252. #define ptok(x) ((caddr_t)((unsigned) x - (unsigned) kmemstart))
  253. #define ktop(x) ((paddr_t)(unsigned) x + kmemstart)
  254. #define copypsize(rpp,rip)    rpp->p_usize = rip->p_usize; \
  255.                 rpp->p_lsize = rip->p_lsize
  256. #define USRSTACK    u.u_stkbot
  257. #define    URSBC        0        /* User stk Reg Save area Byte Cnt */
  258. #endif
  259.  
  260. #ifdef M_I386
  261. #define    ktop(addr)    ((paddr_t)addr)
  262. #define    ptok(addr)    ((caddr_t)addr)
  263. #define copypsize(rpp,rip)    rpp->p_usize = rip->p_usize;    
  264. #endif
  265.  
  266. #define lobyte(X)    (((unsigned char *)&X)[0])
  267. #define hibyte(X)    (((unsigned char *)&X)[1])
  268. #define    loword(X)    (((ushort *)&X)[0])
  269. #define    hiword(X)    (((ushort *)&X)[1])
  270.  
  271.  
  272. /*
  273.  * Machine-dependent bits and macros
  274.  */
  275.  
  276. #ifndef M_I386
  277. #define CLKONLY(ps)     (((ps)&PS_PRIMASK)==0)
  278. #define USERMODE(ps)    ((ps)&PS_USER)
  279. #define PTRSIZE(f)    ((f)? sizeof(char far *) : sizeof(caddr_t))
  280.  
  281. /*
  282.  * 286/8086 simulated "state" definitions.
  283.  */
  284.  
  285. #define    PS_USER        0x01        /* "user" mode */
  286. #define    PS_SYS        0xFE        /* for mch.a86, turns off user mode */
  287. #define    PS_PRIMASK    0xFF00        /* previous priority */
  288. #define SHWDSZ          (2+6) /* space on user stack for shell word */
  289. #endif
  290.  
  291.  
  292. #ifdef M_I386
  293. #define SPL0MASK        0x00            
  294. #define    USERMODE(cs)    ((cs & DPL_USER) == DPL_USER)
  295. #define    CLKONLY(mask)    ((mask) == 0)
  296. #define    USRSTACK    u.u_stkbot
  297. #define    USRSTACK286    ((caddr_t)FTOOFF(u.u_stkbot))
  298. #define    URSBC        0        /* User stk Reg Save area Byte Cnt */
  299. #define PTRSIZE(f)    ((f)? sizeof(caddr_t) : sizeof(short))
  300. #define SHWDSZ          (nbpw+6) /* space on user stack for shell word */
  301. #endif
  302.  
  303. #define NBPW286        2        /* sizeof an int on a 80286 */
  304.  
  305.  
  306. /* Conditional compilation */
  307.  
  308. #define    PAGEMMU            /* mmu is divided in pages */
  309.  
  310. #ifdef M_I386
  311.  
  312. /*#define    SHORTINT    /* sizeof(int)==sizeof(short) */
  313. /*#define    BYTESWAP    /* byte ordering is opposite that of pdp11
  314. /*#define       OLDFORK        /* return to parent by bumping pc by 2 */
  315. /*#define       FIXEDSTACK      /* stack cannot grow */
  316. /*#define       BUFMAPOUT       /* buffers are mapped out */
  317. /*#define     LARGECODE       /* kernel supports multisegment code */
  318. /*#define     UNOTMAPPED    /* upage copied in on context switch */
  319.  
  320. #else
  321.  
  322. #define        SHORTINT           /* sizeof(int)==sizeof(short) */
  323. #define        BUFMAPOUT       /* buffers are mapped out */
  324. #define     UNOTMAPPED    /* upage copied in on context switch */
  325. #ifdef M_I286
  326. #define        FIXEDSTACK         /* stack cannot grow */
  327. #endif
  328. #ifdef M_I8086
  329. #define LARGECODE        /* kernel supports multisegment code */
  330. #endif
  331.  
  332. #endif
  333.