Prex Home / Browse Source - Prex Version: 0.9.0

root/include/sys/param.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


   1 /*-
   2  * Copyright (c) 1982, 1986, 1989, 1993
   3  *      The Regents of the University of California.  All rights reserved.
   4  * (c) UNIX System Laboratories, Inc.
   5  * All or some portions of this file are derived from material licensed
   6  * to the University of California by American Telephone and Telegraph
   7  * Co. or Unix System Laboratories, Inc. and are reproduced herein with
   8  * the permission of UNIX System Laboratories, Inc.
   9  *
  10  * Redistribution and use in source and binary forms, with or without
  11  * modification, are permitted provided that the following conditions
  12  * are met:
  13  * 1. Redistributions of source code must retain the above copyright
  14  *    notice, this list of conditions and the following disclaimer.
  15  * 2. Redistributions in binary form must reproduce the above copyright
  16  *    notice, this list of conditions and the following disclaimer in the
  17  *    documentation and/or other materials provided with the distribution.
  18  * 3. Neither the name of the University nor the names of its contributors
  19  *    may be used to endorse or promote products derived from this software
  20  *    without specific prior written permission.
  21  *
  22  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  23  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  24  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  25  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  26  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  27  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  28  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  29  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  31  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  32  * SUCH DAMAGE.
  33  *
  34  *      @(#)param.h     8.3 (Berkeley) 4/4/95
  35  */
  36 
  37 #ifndef _SYS_PARAM_H_
  38 #define _SYS_PARAM_H_
  39 
  40 #include <conf/config.h>
  41 
  42 #ifndef LOCORE
  43 #include <sys/types.h>
  44 #endif
  45 
  46 /*
  47  * Machine-independent constants (some used in following include files).
  48  * Redefined constants are from POSIX 1003.1 limits file.
  49  */
  50 #include <sys/syslimits.h>
  51 
  52 #define NCARGS          ARG_MAX         /* max bytes for an exec function */
  53 #define NGROUPS         NGROUPS_MAX     /* max number groups */
  54 #define NOFILE          OPEN_MAX        /* max open files per process */
  55 #define NOGROUP         65535           /* marker for empty group set member */
  56 #define MAXHOSTNAMELEN  32              /* max hostname size */
  57 
  58 #define MAXTASKS        256             /* max number of tasks in system */
  59 #define MAXTHREADS      128             /* max number of threads per task */
  60 #define MAXOBJECTS      32              /* max number of objects per task */
  61 #define MAXSYNCS        512             /* max number of synch objects per task */
  62 #define MAXMEM          (4*1024*1024)   /* max core per task - first # is Mb */
  63 
  64 /* The following name length include a null-terminate character */
  65 #define MAXTASKNAME     12              /* max task name */
  66 #define MAXDEVNAME      12              /* max device name */
  67 #define MAXOBJNAME      16              /* max object name */
  68 #define MAXEVTNAME      12              /* max event name */
  69 
  70 #define HZ              CONFIG_HZ       /* ticks per second */
  71 #define MAXIRQS         32              /* max number of irq line */
  72 #define PASSWORD_LEN    4               /* fixed length, not counting NULL */
  73 
  74 /*
  75  * Priorities.
  76  * Probably should not be altered too much.
  77  */
  78 #define PRI_TIMER       15      /* priority for timer thread */
  79 #define PRI_IST         16      /* top priority for interrupt threads */
  80 #define PRI_DPC         33      /* priority for Deferred Procedure Call */
  81 #define PRI_IDLE        255     /* priority for idle thread */
  82 #define PRI_REALTIME    127     /* default priority for real-time thread */
  83 #define PRI_DEFAULT     200     /* default user priority */
  84 
  85 #define MAXPRI          0
  86 #define MINPRI          255
  87 #define NPRI            (MINPRI + 1)    /* number of thread priority */
  88 
  89 /* Server priorities */
  90 #define PRI_PROC        124     /* process server */
  91 #define PRI_EXEC        125     /* exec server */
  92 #define PRI_FS          126     /* file system server */
  93 #define PRI_POW         100     /* power server */
  94 
  95 #ifndef NULL
  96 #if !defined(__cplusplus)
  97 #define NULL    ((void *)0)
  98 #else
  99 #define NULL    0
 100 #endif
 101 #endif
 102 
 103 /* More types and definitions used throughout the kernel. */
 104 #ifdef KERNEL
 105 #include <sys/cdefs.h>
 106 #endif
 107 
 108 #ifndef KERNEL
 109 /* Signals. */
 110 #include <sys/signal.h>
 111 #endif
 112 
 113 #include <machine/limits.h>
 114 #include <machine/memory.h>
 115 
 116 #define KSTACKSZ        768             /* kernel stack size */
 117 
 118 #define USRSTACK        (0 + PAGE_SIZE) /* base address of user stack */
 119 #define DFLSTKSZ        4096            /* default size of user stack */
 120 
 121 #ifdef CONFIG_MMU
 122 #define user_area(a)    ((vaddr_t)(a) <  (vaddr_t)USERLIMIT)
 123 #else
 124 #define user_area(a)    1
 125 #endif
 126 
 127 /* Address translation between physical address and kernel viritul address */
 128 #define ptokv(pa)       (void *)((paddr_t)(pa) + KERNBASE)
 129 #define kvtop(va)       ((paddr_t)(va) - KERNBASE)
 130 
 131 /*
 132  * Round p (pointer or byte index) up to a correctly-aligned value for all
 133  * data types (int, long, ...).   The result is u_long and must be cast to
 134  * any desired pointer type.
 135  */
 136 #define _ALIGNBYTES     (sizeof(int) - 1)
 137 #define ALIGN(p)        (((unsigned)(p) + _ALIGNBYTES) &~ _ALIGNBYTES)
 138 
 139 /*
 140  * Memory page
 141  */
 142 #define PAGE_MASK       (PAGE_SIZE-1)
 143 #define trunc_page(x)   ((x) & ~PAGE_MASK)
 144 #define round_page(x)   (((x) + PAGE_MASK) & ~PAGE_MASK)
 145 
 146 /*
 147  * MAXPATHLEN defines the longest permissable path length after expanding
 148  * symbolic links. It is used to allocate a temporary buffer from the buffer
 149  * pool in which to do the name expansion, hence should be a power of two,
 150  * and must be less than or equal to MAXBSIZE.  MAXSYMLINKS defines the
 151  * maximum number of symbolic links that may be expanded in a path name.
 152  * It should be set high enough to allow all legitimate uses, but halt
 153  * infinite loops reasonably quickly.
 154  */
 155 #define MAXPATHLEN      PATH_MAX
 156 #define MAXSYMLINKS     8
 157 
 158 /* Bit map related macros. */
 159 #define setbit(a,i)     ((a)[(i)/NBBY] |= 1<<((i)%NBBY))
 160 #define clrbit(a,i)     ((a)[(i)/NBBY] &= ~(1<<((i)%NBBY)))
 161 #define isset(a,i)      ((a)[(i)/NBBY] & (1<<((i)%NBBY)))
 162 #define isclr(a,i)      (((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
 163 
 164 /* Macros for counting and rounding. */
 165 #ifndef howmany
 166 #define howmany(x, y)   (((x)+((y)-1))/(y))
 167 #endif
 168 #define roundup(x, y)   ((((x)+((y)-1))/(y))*(y))
 169 #define rounddown(x,y)  (((x)/(y))*(y))
 170 #define powerof2(x)     ((((x)-1)&(x))==0)
 171 
 172 /* Macros for min/max. */
 173 #define MIN(a,b) (((a)<(b))?(a):(b))
 174 #define MAX(a,b) (((a)>(b))?(a):(b))
 175 
 176 #define BSIZE   512             /* size of secondary block (bytes) */
 177 
 178 /*
 179  * Macro to convert milliseconds and tick.
 180  */
 181 #define mstohz(ms)      (((ms) + 0UL) * HZ / 1000)
 182 
 183 #define hztoms(tick)    ((tick) >= 0x20000 ? \
 184                          (((tick) + 0u) / HZ) * 1000u : \
 185                          (((tick) + 0u) * 1000u) / HZ)
 186 
 187 #endif /* !_SYS_PARAM_H_ */

/* [<][>][^][v][top][bottom][index][help] */