home *** CD-ROM | disk | FTP | other *** search
/ H4CK3R 4 / hacker04 / 04_HACK04.ISO / darwin / darwinx86.iso / usr / include / i386 / param.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-09-30  |  5.9 KB  |  164 lines

  1. /*
  2.  * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
  3.  *
  4.  * @APPLE_LICENSE_HEADER_START@
  5.  * 
  6.  * The contents of this file constitute Original Code as defined in and
  7.  * are subject to the Apple Public Source License Version 1.1 (the
  8.  * "License").  You may not use this file except in compliance with the
  9.  * License.  Please obtain a copy of the License at
  10.  * http://www.apple.com/publicsource and read it before using this file.
  11.  * 
  12.  * This Original Code and all software distributed under the License are
  13.  * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  14.  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  15.  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
  16.  * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
  17.  * License for the specific language governing rights and limitations
  18.  * under the License.
  19.  * 
  20.  * @APPLE_LICENSE_HEADER_END@
  21.  */
  22. /*-
  23.  * Copyright (c) 1990, 1993
  24.  *    The Regents of the University of California.  All rights reserved.
  25.  * (c) UNIX System Laboratories, Inc.
  26.  * All or some portions of this file are derived from material licensed
  27.  * to the University of California by American Telephone and Telegraph
  28.  * Co. or Unix System Laboratories, Inc. and are reproduced herein with
  29.  * the permission of UNIX System Laboratories, Inc.
  30.  *
  31.  * Redistribution and use in source and binary forms, with or without
  32.  * modification, are permitted provided that the following conditions
  33.  * are met:
  34.  * 1. Redistributions of source code must retain the above copyright
  35.  *    notice, this list of conditions and the following disclaimer.
  36.  * 2. Redistributions in binary form must reproduce the above copyright
  37.  *    notice, this list of conditions and the following disclaimer in the
  38.  *    documentation and/or other materials provided with the distribution.
  39.  * 3. All advertising materials mentioning features or use of this software
  40.  *    must display the following acknowledgement:
  41.  *    This product includes software developed by the University of
  42.  *    California, Berkeley and its contributors.
  43.  * 4. Neither the name of the University nor the names of its contributors
  44.  *    may be used to endorse or promote products derived from this software
  45.  *    without specific prior written permission.
  46.  *
  47.  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  48.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  49.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  50.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  51.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  52.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  53.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  54.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  55.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  56.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  57.  * SUCH DAMAGE.
  58.  *
  59.  *    @(#)param.h    8.1 (Berkeley) 4/4/95
  60.  */
  61.  
  62. /*
  63.  * Machine dependent constants for Intel 386.
  64.  */
  65.  
  66. #ifndef _I386_PARAM_H_
  67. #define _I386_PARAM_H_
  68.  
  69. /*
  70.  * Round p (pointer or byte index) up to a correctly-aligned value for all
  71.  * data types (int, long, ...).   The result is u_int and must be cast to
  72.  * any desired pointer type.
  73.  */
  74. #define    ALIGNBYTES    3
  75. #define    ALIGN(p)    (((u_int)(p) + ALIGNBYTES) &~ ALIGNBYTES)
  76.  
  77. #define    NBPG        4096        /* bytes/page */
  78. #define    PGOFSET        (NBPG-1)    /* byte offset into page */
  79. #define    PGSHIFT        12        /* LOG2(NBPG) */
  80.  
  81. #define    DEV_BSIZE    512
  82. #define    DEV_BSHIFT    9        /* log2(DEV_BSIZE) */
  83. #define BLKDEV_IOSIZE    2048
  84. #define    MAXPHYS        (64 * 1024)    /* max raw I/O transfer size */
  85.  
  86. #define    STACK_GROWS_UP    0        /* stack grows to lower addresses */
  87.  
  88. #define    CLSIZE        1
  89. #define    CLSIZELOG2    0
  90.  
  91. /*
  92.  * Constants related to network buffer management.
  93.  * MCLBYTES must be no larger than CLBYTES (the software page size), and,
  94.  * on machines that exchange pages of input or output buffers with mbuf
  95.  * clusters (MAPPED_MBUFS), MCLBYTES must also be an integral multiple
  96.  * of the hardware page size.
  97.  */
  98. #define    MSIZE        256        /* size of an mbuf */
  99. #define    MCLBYTES    2048        /* large enough for ether MTU */
  100. #define    MCLSHIFT    11
  101. #define    MCLOFSET    (MCLBYTES - 1)
  102. #ifndef NMBCLUSTERS
  103. #ifdef GATEWAY
  104. #define    NMBCLUSTERS    ((1024 * 1024) / MCLBYTES)    /* cl map size: 1MB */
  105. #else
  106. #define    NMBCLUSTERS    ((1024 * 512) / MCLBYTES)    /* cl map size: 0.5MB */
  107. #endif
  108. #endif
  109.  
  110. /*
  111.  * Some macros for units conversion
  112.  */
  113. /* Core clicks (NeXT_page_size bytes) to segments and vice versa */
  114. #define    ctos(x)    (x)
  115. #define    stoc(x)    (x)
  116.  
  117. /* Core clicks (4096 bytes) to disk blocks */
  118. #define    ctod(x)    ((x)<<(PGSHIFT-DEV_BSHIFT))
  119. #define    dtoc(x)    ((x)>>(PGSHIFT-DEV_BSHIFT))
  120. #define    dtob(x)    ((x)<<DEV_BSHIFT)
  121.  
  122. /* clicks to bytes */
  123. #define    ctob(x)    ((x)<<PGSHIFT)
  124.  
  125. /* bytes to clicks */
  126. #define    btoc(x)    (((unsigned)(x)+(NBPG-1))>>PGSHIFT)
  127.  
  128. #ifdef __APPLE__
  129. #define  btodb(bytes, devBlockSize)         \
  130.         ((unsigned)(bytes) / devBlockSize)
  131. #define  dbtob(db, devBlockSize)            \
  132.         ((unsigned)(db) * devBlockSize)
  133. #else
  134. #define    btodb(bytes)             /* calculates (bytes / DEV_BSIZE) */ \
  135.     ((unsigned)(bytes) >> DEV_BSHIFT)
  136. #define    dbtob(db)            /* calculates (db * DEV_BSIZE) */ \
  137.     ((unsigned)(db) << DEV_BSHIFT)
  138. #endif
  139.  
  140. /*
  141.  * Map a ``block device block'' to a file system block.
  142.  * This should be device dependent, and will be if we
  143.  * add an entry to cdevsw/bdevsw for that purpose.
  144.  * For now though just use DEV_BSIZE.
  145.  */
  146. #define    bdbtofsb(bn)    ((bn) / (BLKDEV_IOSIZE/DEV_BSIZE))
  147.  
  148. /*
  149.  * Macros to decode (and encode) processor status word.
  150.  */
  151. #define STATUS_WORD(rpl, ipl)    (((ipl) << 8) | (rpl))
  152. #define    USERMODE(x)        (((x) & 3) == 3)
  153. #define    BASEPRI(x)        (((x) & (255 << 8)) == 0)
  154.  
  155.  
  156. #if    defined(KERNEL) || defined(STANDALONE)
  157. #define    DELAY(n) delay(n)
  158.  
  159. #else    /* defined(KERNEL) || defined(STANDALONE) */
  160. #define    DELAY(n)    { register int N = (n); while (--N > 0); }
  161. #endif    /* defined(KERNEL) || defined(STANDALONE) */
  162.  
  163. #endif /* _I386_PARAM_H_ */
  164.