Thu Mar 3 07:31:24 2022 UTC ()
Welcome to NetBSD 9.99.94!

- usbnet(9) overhaul.
- USB host controller interface API and ABI simplifications.
- usbdi(9) additions -- usbd_suspend_pipe, usbd_resume_pipe.
- video(9) change -- video_attach_mi takes explicit cookie argument.
- driver(9) addition -- device_set_private, in preparation for opaque
  struct device.

While here, fix typo noted by pgoyette@ -- `privilege', not
`priviledge'.


(riastradh)
diff -r1.706 -r1.707 src/sys/sys/param.h

cvs diff -r1.706 -r1.707 src/sys/sys/param.h (switch to unified diff)

--- src/sys/sys/param.h 2021/12/21 18:59:22 1.706
+++ src/sys/sys/param.h 2022/03/03 07:31:24 1.707
@@ -1,566 +1,566 @@ @@ -1,566 +1,566 @@
1/* $NetBSD: param.h,v 1.706 2021/12/21 18:59:22 thorpej Exp $ */ 1/* $NetBSD: param.h,v 1.707 2022/03/03 07:31:24 riastradh Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1982, 1986, 1989, 1993 4 * Copyright (c) 1982, 1986, 1989, 1993
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * (c) UNIX System Laboratories, Inc. 6 * (c) UNIX System Laboratories, Inc.
7 * All or some portions of this file are derived from material licensed 7 * All or some portions of this file are derived from material licensed
8 * to the University of California by American Telephone and Telegraph 8 * to the University of California by American Telephone and Telegraph
9 * Co. or Unix System Laboratories, Inc. and are reproduced herein with 9 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
10 * the permission of UNIX System Laboratories, Inc. 10 * the permission of UNIX System Laboratories, Inc.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions 13 * modification, are permitted provided that the following conditions
14 * are met: 14 * are met:
15 * 1. Redistributions of source code must retain the above copyright 15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer. 16 * notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright 17 * 2. Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the 18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution. 19 * documentation and/or other materials provided with the distribution.
20 * 3. Neither the name of the University nor the names of its contributors 20 * 3. Neither the name of the University nor the names of its contributors
21 * may be used to endorse or promote products derived from this software 21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission. 22 * without specific prior written permission.
23 * 23 *
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE. 34 * SUCH DAMAGE.
35 * 35 *
36 * @(#)param.h 8.3 (Berkeley) 4/4/95 36 * @(#)param.h 8.3 (Berkeley) 4/4/95
37 */ 37 */
38 38
39#ifndef _SYS_PARAM_H_ 39#ifndef _SYS_PARAM_H_
40#define _SYS_PARAM_H_ 40#define _SYS_PARAM_H_
41 41
42#ifdef _KERNEL_OPT 42#ifdef _KERNEL_OPT
43#include "opt_param.h" 43#include "opt_param.h"
44#endif 44#endif
45 45
46/* 46/*
47 * Historic BSD #defines -- probably will remain untouched for all time. 47 * Historic BSD #defines -- probably will remain untouched for all time.
48 */ 48 */
49#define BSD 199506 /* System version (year & month). */ 49#define BSD 199506 /* System version (year & month). */
50#define BSD4_3 1 50#define BSD4_3 1
51#define BSD4_4 1 51#define BSD4_4 1
52 52
53/* 53/*
54 * #define __NetBSD_Version__ MMmmrrpp00 54 * #define __NetBSD_Version__ MMmmrrpp00
55 * 55 *
56 * M = major version 56 * M = major version
57 * m = minor version; a minor number of 99 indicates current. 57 * m = minor version; a minor number of 99 indicates current.
58 * r = 0 (*) 58 * r = 0 (*)
59 * p = patchlevel 59 * p = patchlevel
60 * 60 *
61 * When new releases are made, src/gnu/usr.bin/groff/tmac/mdoc.local 61 * When new releases are made, src/gnu/usr.bin/groff/tmac/mdoc.local
62 * needs to be updated and the changes sent back to the groff maintainers. 62 * needs to be updated and the changes sent back to the groff maintainers.
63 * 63 *
64 * (*) Up to 2.0I "release" used to be "",A-Z,Z[A-Z] but numeric 64 * (*) Up to 2.0I "release" used to be "",A-Z,Z[A-Z] but numeric
65 * e.g. NetBSD-1.2D = 102040000 ('D' == 4) 65 * e.g. NetBSD-1.2D = 102040000 ('D' == 4)
66 * NetBSD-2.0H (200080000) was changed on 20041001 to: 66 * NetBSD-2.0H (200080000) was changed on 20041001 to:
67 * 2.99.9 (299000900) 67 * 2.99.9 (299000900)
68 */ 68 */
69 69
70#define __NetBSD_Version__ 999009300 /* NetBSD 9.99.93 */ 70#define __NetBSD_Version__ 999009400 /* NetBSD 9.99.94 */
71 71
72#define __NetBSD_Prereq__(M,m,p) (((((M) * 100000000) + \ 72#define __NetBSD_Prereq__(M,m,p) (((((M) * 100000000) + \
73 (m) * 1000000) + (p) * 100) <= __NetBSD_Version__) 73 (m) * 1000000) + (p) * 100) <= __NetBSD_Version__)
74 74
75/* 75/*
76 * Historical NetBSD #define 76 * Historical NetBSD #define
77 * 77 *
78 * NetBSD 1.4 was the last release for which this value was incremented. 78 * NetBSD 1.4 was the last release for which this value was incremented.
79 * The value is now permanently fixed at 199905. It will never be 79 * The value is now permanently fixed at 199905. It will never be
80 * changed again. 80 * changed again.
81 * 81 *
82 * New code must use __NetBSD_Version__ instead, and should not even 82 * New code must use __NetBSD_Version__ instead, and should not even
83 * count on NetBSD being defined. 83 * count on NetBSD being defined.
84 * 84 *
85 */ 85 */
86 86
87#define NetBSD 199905 /* NetBSD version (year & month). */ 87#define NetBSD 199905 /* NetBSD version (year & month). */
88 88
89/* 89/*
90 * These macros determine if we are running in protected mode or not. 90 * These macros determine if we are running in protected mode or not.
91 * _HARDKERNEL: code uses kernel namespace and runs in hw priviledged mode 91 * _HARDKERNEL: code uses kernel namespace and runs in hw privileged mode
92 * _SOFTKERNEL: code uses kernel namespace but runs without hw priviledges 92 * _SOFTKERNEL: code uses kernel namespace but runs without hw privileges
93 */ 93 */
94#if defined(_KERNEL) && !defined(_RUMPKERNEL) 94#if defined(_KERNEL) && !defined(_RUMPKERNEL)
95#define _HARDKERNEL 95#define _HARDKERNEL
96#endif 96#endif
97#if defined(_KERNEL) && defined(_RUMPKERNEL) 97#if defined(_KERNEL) && defined(_RUMPKERNEL)
98#define _SOFTKERNEL 98#define _SOFTKERNEL
99#endif 99#endif
100 100
101#include <sys/null.h> 101#include <sys/null.h>
102 102
103#ifndef __ASSEMBLER__ 103#ifndef __ASSEMBLER__
104#include <sys/inttypes.h> 104#include <sys/inttypes.h>
105#include <sys/types.h> 105#include <sys/types.h>
106 106
107/* 107/*
108 * Machine-independent constants (some used in following include files). 108 * Machine-independent constants (some used in following include files).
109 * Redefined constants are from POSIX 1003.1 limits file. 109 * Redefined constants are from POSIX 1003.1 limits file.
110 * 110 *
111 * MAXCOMLEN should be >= sizeof(ac_comm) (see <acct.h>) 111 * MAXCOMLEN should be >= sizeof(ac_comm) (see <acct.h>)
112 * MAXHOSTNAMELEN should be >= (_POSIX_HOST_NAME_MAX + 1) (see <limits.h>) 112 * MAXHOSTNAMELEN should be >= (_POSIX_HOST_NAME_MAX + 1) (see <limits.h>)
113 * MAXLOGNAME should be >= UT_NAMESIZE (see <utmp.h>) 113 * MAXLOGNAME should be >= UT_NAMESIZE (see <utmp.h>)
114 */ 114 */
115#include <sys/syslimits.h> 115#include <sys/syslimits.h>
116 116
117#define MAXCOMLEN 16 /* max command name remembered */ 117#define MAXCOMLEN 16 /* max command name remembered */
118#define MAXINTERP PATH_MAX /* max interpreter file name length */ 118#define MAXINTERP PATH_MAX /* max interpreter file name length */
119/* DEPRECATED: use LOGIN_NAME_MAX instead. */ 119/* DEPRECATED: use LOGIN_NAME_MAX instead. */
120#define MAXLOGNAME (LOGIN_NAME_MAX - 1) /* max login name length */ 120#define MAXLOGNAME (LOGIN_NAME_MAX - 1) /* max login name length */
121#define NCARGS ARG_MAX /* max bytes for an exec function */ 121#define NCARGS ARG_MAX /* max bytes for an exec function */
122#define NGROUPS NGROUPS_MAX /* max number groups */ 122#define NGROUPS NGROUPS_MAX /* max number groups */
123#define NOGROUP 65535 /* marker for empty group set member */ 123#define NOGROUP 65535 /* marker for empty group set member */
124#define MAXHOSTNAMELEN 256 /* max hostname size */ 124#define MAXHOSTNAMELEN 256 /* max hostname size */
125 125
126#ifndef NOFILE 126#ifndef NOFILE
127#define NOFILE OPEN_MAX /* max open files per process */ 127#define NOFILE OPEN_MAX /* max open files per process */
128#endif 128#endif
129#ifndef MAXUPRC /* max simultaneous processes */ 129#ifndef MAXUPRC /* max simultaneous processes */
130#define MAXUPRC CHILD_MAX /* POSIX 1003.1-compliant default */ 130#define MAXUPRC CHILD_MAX /* POSIX 1003.1-compliant default */
131#else 131#else
132#if (MAXUPRC - 0) < CHILD_MAX 132#if (MAXUPRC - 0) < CHILD_MAX
133#error MAXUPRC less than CHILD_MAX. See options(4) for details. 133#error MAXUPRC less than CHILD_MAX. See options(4) for details.
134#endif /* (MAXUPRC - 0) < CHILD_MAX */ 134#endif /* (MAXUPRC - 0) < CHILD_MAX */
135#endif /* !defined(MAXUPRC) */ 135#endif /* !defined(MAXUPRC) */
136 136
137/* Macros for min/max. */ 137/* Macros for min/max. */
138#define MIN(a,b) ((/*CONSTCOND*/(a)<(b))?(a):(b)) 138#define MIN(a,b) ((/*CONSTCOND*/(a)<(b))?(a):(b))
139#define MAX(a,b) ((/*CONSTCOND*/(a)>(b))?(a):(b)) 139#define MAX(a,b) ((/*CONSTCOND*/(a)>(b))?(a):(b))
140 140
141/* Machine type dependent parameters. */ 141/* Machine type dependent parameters. */
142#include <machine/param.h> 142#include <machine/param.h>
143#include <machine/limits.h> 143#include <machine/limits.h>
144 144
145/* 145/*
146 * Coherency unit: assumed cache line size. See also MIN_LWP_ALIGNMENT. 146 * Coherency unit: assumed cache line size. See also MIN_LWP_ALIGNMENT.
147 * The MD code depends on the current values of these constants. Don't 147 * The MD code depends on the current values of these constants. Don't
148 * change them without coordinating. 148 * change them without coordinating.
149 */ 149 */
150#ifndef COHERENCY_UNIT 150#ifndef COHERENCY_UNIT
151#define COHERENCY_UNIT 64 151#define COHERENCY_UNIT 64
152#endif 152#endif
153#ifndef CACHE_LINE_SIZE 153#ifndef CACHE_LINE_SIZE
154#define CACHE_LINE_SIZE 64 154#define CACHE_LINE_SIZE 64
155#endif 155#endif
156 156
157/* More types and definitions used throughout the kernel. */ 157/* More types and definitions used throughout the kernel. */
158#ifdef _KERNEL 158#ifdef _KERNEL
159#include <sys/cdefs.h> 159#include <sys/cdefs.h>
160#include <sys/errno.h> 160#include <sys/errno.h>
161#include <sys/time.h> 161#include <sys/time.h>
162#include <sys/resource.h> 162#include <sys/resource.h>
163#include <sys/ucred.h> 163#include <sys/ucred.h>
164#include <sys/uio.h> 164#include <sys/uio.h>
165#include <uvm/uvm_param.h> 165#include <uvm/uvm_param.h>
166#ifndef NPROC 166#ifndef NPROC
167#define NPROC (20 + 16 * MAXUSERS) 167#define NPROC (20 + 16 * MAXUSERS)
168#endif 168#endif
169#ifndef MAXFILES 169#ifndef MAXFILES
170#define MAXFILES (3 * (NPROC + MAXUSERS) + 80) 170#define MAXFILES (3 * (NPROC + MAXUSERS) + 80)
171#define MAXFILES_IMPLICIT 171#define MAXFILES_IMPLICIT
172#endif 172#endif
173#ifndef NTEXT 173#ifndef NTEXT
174#define NTEXT (80 + NPROC / 8) /* actually the object cache */ 174#define NTEXT (80 + NPROC / 8) /* actually the object cache */
175#endif 175#endif
176#ifndef NVNODE 176#ifndef NVNODE
177#define NVNODE (NPROC + NTEXT + 100) 177#define NVNODE (NPROC + NTEXT + 100)
178#define NVNODE_IMPLICIT 178#define NVNODE_IMPLICIT
179#endif 179#endif
180#ifndef VNODE_KMEM_MAXPCT 180#ifndef VNODE_KMEM_MAXPCT
181#define VNODE_KMEM_MAXPCT 60 181#define VNODE_KMEM_MAXPCT 60
182#endif 182#endif
183#ifndef BUFCACHE_VA_MAXPCT 183#ifndef BUFCACHE_VA_MAXPCT
184#define BUFCACHE_VA_MAXPCT 20 184#define BUFCACHE_VA_MAXPCT 20
185#endif 185#endif
186#define VNODE_COST 2048 /* assumed space in bytes */ 186#define VNODE_COST 2048 /* assumed space in bytes */
187#endif /* _KERNEL */ 187#endif /* _KERNEL */
188 188
189/* Signals. */ 189/* Signals. */
190#include <sys/signal.h> 190#include <sys/signal.h>
191 191
192#define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */ 192#define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */
193#define DEV_BSIZE (1 << DEV_BSHIFT) /* 512 */ 193#define DEV_BSIZE (1 << DEV_BSHIFT) /* 512 */
194 194
195#ifndef BLKDEV_IOSIZE 195#ifndef BLKDEV_IOSIZE
196#define BLKDEV_IOSIZE 2048 196#define BLKDEV_IOSIZE 2048
197#endif 197#endif
198 198
199#ifndef MAXPHYS 199#ifndef MAXPHYS
200#define MAXPHYS (64 * 1024) /* max raw I/O transfer size */ 200#define MAXPHYS (64 * 1024) /* max raw I/O transfer size */
201#endif 201#endif
202 202
203/* pages ("clicks") to disk blocks */ 203/* pages ("clicks") to disk blocks */
204#define ctod(x) ((x) << (PGSHIFT - DEV_BSHIFT)) 204#define ctod(x) ((x) << (PGSHIFT - DEV_BSHIFT))
205#define dtoc(x) ((x) >> (PGSHIFT - DEV_BSHIFT)) 205#define dtoc(x) ((x) >> (PGSHIFT - DEV_BSHIFT))
206 206
207/* bytes to pages */ 207/* bytes to pages */
208#define ctob(x) ((x) << PGSHIFT) 208#define ctob(x) ((x) << PGSHIFT)
209#define btoc(x) (((x) + PGOFSET) >> PGSHIFT) 209#define btoc(x) (((x) + PGOFSET) >> PGSHIFT)
210 210
211/* bytes to disk blocks */ 211/* bytes to disk blocks */
212#define dbtob(x) ((x) << DEV_BSHIFT) 212#define dbtob(x) ((x) << DEV_BSHIFT)
213#define btodb(x) ((x) >> DEV_BSHIFT) 213#define btodb(x) ((x) >> DEV_BSHIFT)
214 214
215#ifndef MAXCPUS 215#ifndef MAXCPUS
216#define MAXCPUS 32 216#define MAXCPUS 32
217#endif 217#endif
218#ifndef MAX_LWP_PER_PROC 218#ifndef MAX_LWP_PER_PROC
219#define MAX_LWP_PER_PROC 8000 219#define MAX_LWP_PER_PROC 8000
220#endif 220#endif
221 221
222/* 222/*
223 * Stack macros. On most architectures, the stack grows down, 223 * Stack macros. On most architectures, the stack grows down,
224 * towards lower addresses; it is the rare architecture where 224 * towards lower addresses; it is the rare architecture where
225 * it grows up, towards higher addresses. 225 * it grows up, towards higher addresses.
226 * 226 *
227 * STACK_GROW and STACK_SHRINK adjust a stack pointer by some 227 * STACK_GROW and STACK_SHRINK adjust a stack pointer by some
228 * size, no questions asked. STACK_ALIGN aligns a stack pointer. 228 * size, no questions asked. STACK_ALIGN aligns a stack pointer.
229 * 229 *
230 * STACK_ALLOC returns a pointer to allocated stack space of 230 * STACK_ALLOC returns a pointer to allocated stack space of
231 * some size; given such a pointer and a size, STACK_MAX gives 231 * some size; given such a pointer and a size, STACK_MAX gives
232 * the maximum (in the "maxsaddr" sense) stack address of the 232 * the maximum (in the "maxsaddr" sense) stack address of the
233 * allocated memory. 233 * allocated memory.
234 */ 234 */
235#if defined(_KERNEL) || defined(__EXPOSE_STACK) 235#if defined(_KERNEL) || defined(__EXPOSE_STACK)
236 236
237#ifndef STACK_ALIGNBYTES 237#ifndef STACK_ALIGNBYTES
238#define STACK_ALIGNBYTES __ALIGNBYTES 238#define STACK_ALIGNBYTES __ALIGNBYTES
239#endif 239#endif
240 240
241#ifdef __MACHINE_STACK_GROWS_UP 241#ifdef __MACHINE_STACK_GROWS_UP
242#define STACK_GROW(sp, _size) (((char *)(void *)(sp)) + (_size)) 242#define STACK_GROW(sp, _size) (((char *)(void *)(sp)) + (_size))
243#define STACK_SHRINK(sp, _size) (((char *)(void *)(sp)) - (_size)) 243#define STACK_SHRINK(sp, _size) (((char *)(void *)(sp)) - (_size))
244#define STACK_ALIGN(sp, bytes) \ 244#define STACK_ALIGN(sp, bytes) \
245 ((char *)((((unsigned long)(sp)) + (bytes)) & ~(bytes))) 245 ((char *)((((unsigned long)(sp)) + (bytes)) & ~(bytes)))
246#define STACK_ALLOC(sp, _size) ((char *)(void *)(sp)) 246#define STACK_ALLOC(sp, _size) ((char *)(void *)(sp))
247#define STACK_MAX(p, _size) (((char *)(void *)(p)) + (_size)) 247#define STACK_MAX(p, _size) (((char *)(void *)(p)) + (_size))
248#else 248#else
249#define STACK_GROW(sp, _size) (((char *)(void *)(sp)) - (_size)) 249#define STACK_GROW(sp, _size) (((char *)(void *)(sp)) - (_size))
250#define STACK_SHRINK(sp, _size) (((char *)(void *)(sp)) + (_size)) 250#define STACK_SHRINK(sp, _size) (((char *)(void *)(sp)) + (_size))
251#define STACK_ALIGN(sp, bytes) \ 251#define STACK_ALIGN(sp, bytes) \
252 ((char *)(((unsigned long)(sp)) & ~(bytes))) 252 ((char *)(((unsigned long)(sp)) & ~(bytes)))
253#define STACK_ALLOC(sp, _size) (((char *)(void *)(sp)) - (_size)) 253#define STACK_ALLOC(sp, _size) (((char *)(void *)(sp)) - (_size))
254#define STACK_MAX(p, _size) ((char *)(void *)(p)) 254#define STACK_MAX(p, _size) ((char *)(void *)(p))
255#endif 255#endif
256#define STACK_LEN_ALIGN(len, bytes) (((len) + (bytes)) & ~(bytes)) 256#define STACK_LEN_ALIGN(len, bytes) (((len) + (bytes)) & ~(bytes))
257 257
258#endif /* defined(_KERNEL) || defined(__EXPOSE_STACK) */ 258#endif /* defined(_KERNEL) || defined(__EXPOSE_STACK) */
259 259
260/* 260/*
261 * Round p (pointer or byte index) up to a correctly-aligned value for all 261 * Round p (pointer or byte index) up to a correctly-aligned value for all
262 * data types (int, long, ...). The result is u_int and must be cast to 262 * data types (int, long, ...). The result is u_int and must be cast to
263 * any desired pointer type. 263 * any desired pointer type.
264 * 264 *
265 * ALIGNED_POINTER is a boolean macro that checks whether an address 265 * ALIGNED_POINTER is a boolean macro that checks whether an address
266 * is valid to fetch data elements of type t from on this architecture 266 * is valid to fetch data elements of type t from on this architecture
267 * using ALIGNED_POINTER_LOAD. This does not reflect the optimal 267 * using ALIGNED_POINTER_LOAD. This does not reflect the optimal
268 * alignment, just the possibility (within reasonable limits). 268 * alignment, just the possibility (within reasonable limits).
269 * 269 *
270 * uint32_t x; 270 * uint32_t x;
271 * unsigned char *p = ...; 271 * unsigned char *p = ...;
272 * 272 *
273 * if (ALIGNED_POINTER(p, uint32_t)) { 273 * if (ALIGNED_POINTER(p, uint32_t)) {
274 * uint32_t t; 274 * uint32_t t;
275 * ALIGNED_POINTER_LOAD(&t, p, uint32_t); 275 * ALIGNED_POINTER_LOAD(&t, p, uint32_t);
276 * x = t; 276 * x = t;
277 * } else { 277 * } else {
278 * uint32_t t; 278 * uint32_t t;
279 * memcpy(&t, p, sizeof(t)); 279 * memcpy(&t, p, sizeof(t));
280 * x = t; 280 * x = t;
281 * } 281 * }
282 * 282 *
283 */ 283 */
284#define ALIGNBYTES __ALIGNBYTES 284#define ALIGNBYTES __ALIGNBYTES
285#ifndef ALIGN 285#ifndef ALIGN
286#define ALIGN(p) (((uintptr_t)(p) + ALIGNBYTES) & ~ALIGNBYTES) 286#define ALIGN(p) (((uintptr_t)(p) + ALIGNBYTES) & ~ALIGNBYTES)
287#endif 287#endif
288#ifndef ALIGNED_POINTER 288#ifndef ALIGNED_POINTER
289#define ALIGNED_POINTER(p,t) ((((uintptr_t)(p)) & (__alignof(t) - 1)) == 0) 289#define ALIGNED_POINTER(p,t) ((((uintptr_t)(p)) & (__alignof(t) - 1)) == 0)
290#endif 290#endif
291#ifndef ALIGNED_POINTER_LOAD 291#ifndef ALIGNED_POINTER_LOAD
292#define ALIGNED_POINTER_LOAD(q,p,t) (*(q) = *((const t *)(p))) 292#define ALIGNED_POINTER_LOAD(q,p,t) (*(q) = *((const t *)(p)))
293#endif 293#endif
294 294
295/* 295/*
296 * Return if pointer p is accessible for type t. For primitive types 296 * Return if pointer p is accessible for type t. For primitive types
297 * this means that the pointer itself can be dereferenced; for structures 297 * this means that the pointer itself can be dereferenced; for structures
298 * and unions this means that any field can be dereferenced. On CPUs 298 * and unions this means that any field can be dereferenced. On CPUs
299 * that allow unaligned pointer access, we always return that the pointer 299 * that allow unaligned pointer access, we always return that the pointer
300 * is accessible to prevent unnecessary copies, although this might not be 300 * is accessible to prevent unnecessary copies, although this might not be
301 * necessarily faster. 301 * necessarily faster.
302 */ 302 */
303#ifdef __NO_STRICT_ALIGNMENT 303#ifdef __NO_STRICT_ALIGNMENT
304#define ACCESSIBLE_POINTER(p, t) 1 304#define ACCESSIBLE_POINTER(p, t) 1
305#else 305#else
306#define ACCESSIBLE_POINTER(p, t) ALIGNED_POINTER(p, t) 306#define ACCESSIBLE_POINTER(p, t) ALIGNED_POINTER(p, t)
307#endif 307#endif
308 308
309/* 309/*
310 * Historic priority levels. These are meaningless and remain only 310 * Historic priority levels. These are meaningless and remain only
311 * for source compatibility. Do not use in new code. 311 * for source compatibility. Do not use in new code.
312 */ 312 */
313#define PSWP 0 313#define PSWP 0
314#define PVM 4 314#define PVM 4
315#define PINOD 8 315#define PINOD 8
316#define PRIBIO 16 316#define PRIBIO 16
317#define PVFS 20 317#define PVFS 20
318#define PZERO 22 318#define PZERO 22
319#define PSOCK 24 319#define PSOCK 24
320#define PWAIT 32 320#define PWAIT 32
321#define PLOCK 36 321#define PLOCK 36
322#define PPAUSE 40 322#define PPAUSE 40
323#define PUSER 50 323#define PUSER 50
324#define MAXPRI 127 324#define MAXPRI 127
325 325
326#define PCATCH 0x100 /* OR'd with pri for tsleep to check signals */ 326#define PCATCH 0x100 /* OR'd with pri for tsleep to check signals */
327#define PNORELOCK 0x200 /* OR'd with pri for tsleep to not relock */ 327#define PNORELOCK 0x200 /* OR'd with pri for tsleep to not relock */
328 328
329/* 329/*
330 * New priority levels. 330 * New priority levels.
331 */ 331 */
332#define PRI_COUNT 224 332#define PRI_COUNT 224
333#define PRI_NONE (-1) 333#define PRI_NONE (-1)
334 334
335#define PRI_KERNEL_RT 192 335#define PRI_KERNEL_RT 192
336#define NPRI_KERNEL_RT 32 336#define NPRI_KERNEL_RT 32
337#define MAXPRI_KERNEL_RT (PRI_KERNEL_RT + NPRI_KERNEL_RT - 1) 337#define MAXPRI_KERNEL_RT (PRI_KERNEL_RT + NPRI_KERNEL_RT - 1)
338 338
339#define PRI_USER_RT 128 339#define PRI_USER_RT 128
340#define NPRI_USER_RT 64 340#define NPRI_USER_RT 64
341#define MAXPRI_USER_RT (PRI_USER_RT + NPRI_USER_RT - 1) 341#define MAXPRI_USER_RT (PRI_USER_RT + NPRI_USER_RT - 1)
342 342
343#define PRI_KTHREAD 96 343#define PRI_KTHREAD 96
344#define NPRI_KTHREAD 32 344#define NPRI_KTHREAD 32
345#define MAXPRI_KTHREAD (PRI_KTHREAD + NPRI_KTHREAD - 1) 345#define MAXPRI_KTHREAD (PRI_KTHREAD + NPRI_KTHREAD - 1)
346 346
347#define PRI_KERNEL 64 347#define PRI_KERNEL 64
348#define NPRI_KERNEL 32 348#define NPRI_KERNEL 32
349#define MAXPRI_KERNEL (PRI_KERNEL + NPRI_KERNEL - 1) 349#define MAXPRI_KERNEL (PRI_KERNEL + NPRI_KERNEL - 1)
350 350
351#define PRI_USER 0 351#define PRI_USER 0
352#define NPRI_USER 64 352#define NPRI_USER 64
353#define MAXPRI_USER (PRI_USER + NPRI_USER - 1) 353#define MAXPRI_USER (PRI_USER + NPRI_USER - 1)
354 354
355/* Priority range used by POSIX real-time features */ 355/* Priority range used by POSIX real-time features */
356#define SCHED_PRI_MIN 0 356#define SCHED_PRI_MIN 0
357#define SCHED_PRI_MAX 63 357#define SCHED_PRI_MAX 63
358 358
359/* 359/*
360 * Kernel thread priorities. 360 * Kernel thread priorities.
361 */ 361 */
362#define PRI_SOFTSERIAL MAXPRI_KERNEL_RT 362#define PRI_SOFTSERIAL MAXPRI_KERNEL_RT
363#define PRI_SOFTNET (MAXPRI_KERNEL_RT - schedppq * 1) 363#define PRI_SOFTNET (MAXPRI_KERNEL_RT - schedppq * 1)
364#define PRI_SOFTBIO (MAXPRI_KERNEL_RT - schedppq * 2) 364#define PRI_SOFTBIO (MAXPRI_KERNEL_RT - schedppq * 2)
365#define PRI_SOFTCLOCK (MAXPRI_KERNEL_RT - schedppq * 3) 365#define PRI_SOFTCLOCK (MAXPRI_KERNEL_RT - schedppq * 3)
366 366
367#define PRI_XCALL MAXPRI_KTHREAD 367#define PRI_XCALL MAXPRI_KTHREAD
368#define PRI_PGDAEMON (MAXPRI_KTHREAD - schedppq * 1) 368#define PRI_PGDAEMON (MAXPRI_KTHREAD - schedppq * 1)
369#define PRI_VM (MAXPRI_KTHREAD - schedppq * 2) 369#define PRI_VM (MAXPRI_KTHREAD - schedppq * 2)
370#define PRI_IOFLUSH (MAXPRI_KTHREAD - schedppq * 3) 370#define PRI_IOFLUSH (MAXPRI_KTHREAD - schedppq * 3)
371#define PRI_BIO (MAXPRI_KTHREAD - schedppq * 4) 371#define PRI_BIO (MAXPRI_KTHREAD - schedppq * 4)
372 372
373#define PRI_IDLE PRI_USER 373#define PRI_IDLE PRI_USER
374 374
375/* 375/*
376 * Miscellaneous. 376 * Miscellaneous.
377 */ 377 */
378#define NBPW sizeof(int) /* number of bytes per word (integer) */ 378#define NBPW sizeof(int) /* number of bytes per word (integer) */
379 379
380#define CMASK 022 /* default file mask: S_IWGRP|S_IWOTH */ 380#define CMASK 022 /* default file mask: S_IWGRP|S_IWOTH */
381#define NODEV (dev_t)(-1) /* non-existent device */ 381#define NODEV (dev_t)(-1) /* non-existent device */
382 382
383/* 383/*
384 * File system parameters and macros. 384 * File system parameters and macros.
385 * 385 *
386 * The file system is made out of blocks of at most MAXBSIZE units, with 386 * The file system is made out of blocks of at most MAXBSIZE units, with
387 * smaller units (fragments) only in the last direct block. MAXBSIZE 387 * smaller units (fragments) only in the last direct block. MAXBSIZE
388 * primarily determines the size of buffers in the buffer pool. It may be 388 * primarily determines the size of buffers in the buffer pool. It may be
389 * made larger without any effect on existing file systems; however making 389 * made larger without any effect on existing file systems; however making
390 * it smaller may make some file systems unmountable. 390 * it smaller may make some file systems unmountable.
391 */ 391 */
392#ifndef MAXBSIZE /* XXX */ 392#ifndef MAXBSIZE /* XXX */
393#define MAXBSIZE MAXPHYS 393#define MAXBSIZE MAXPHYS
394#endif 394#endif
395#define MAXFRAG 8 395#define MAXFRAG 8
396 396
397/* 397/*
398 * MAXPATHLEN defines the longest permissible path length after expanding 398 * MAXPATHLEN defines the longest permissible path length after expanding
399 * symbolic links. It is used to allocate a temporary buffer from the buffer 399 * symbolic links. It is used to allocate a temporary buffer from the buffer
400 * pool in which to do the name expansion, hence should be a power of two, 400 * pool in which to do the name expansion, hence should be a power of two,
401 * and must be less than or equal to MAXBSIZE. MAXSYMLINKS defines the 401 * and must be less than or equal to MAXBSIZE. MAXSYMLINKS defines the
402 * maximum number of symbolic links that may be expanded in a path name. 402 * maximum number of symbolic links that may be expanded in a path name.
403 * It should be set high enough to allow all legitimate uses, but halt 403 * It should be set high enough to allow all legitimate uses, but halt
404 * infinite loops reasonably quickly. 404 * infinite loops reasonably quickly.
405 * 405 *
406 * MAXSYMLINKS should be >= _POSIX_SYMLOOP_MAX (see <limits.h>) 406 * MAXSYMLINKS should be >= _POSIX_SYMLOOP_MAX (see <limits.h>)
407 */ 407 */
408#define MAXPATHLEN PATH_MAX 408#define MAXPATHLEN PATH_MAX
409#define MAXSYMLINKS 32 409#define MAXSYMLINKS 32
410 410
411/* 411/*
412 * This is the maximum individual filename component length enforced by 412 * This is the maximum individual filename component length enforced by
413 * namei. Filesystems cannot exceed this limit. The upper bound for that 413 * namei. Filesystems cannot exceed this limit. The upper bound for that
414 * limit is NAME_MAX. We don't bump it for now, for compatibility with 414 * limit is NAME_MAX. We don't bump it for now, for compatibility with
415 * old binaries during the time where MAXNAMLEN was 511 and NAME_MAX was 415 * old binaries during the time where MAXNAMLEN was 511 and NAME_MAX was
416 * 255 416 * 255
417 */ 417 */
418#define KERNEL_NAME_MAX 255 418#define KERNEL_NAME_MAX 255
419 419
420/* Bit map related macros. */ 420/* Bit map related macros. */
421#define setbit(a,i) ((a)[(i)/NBBY] |= 1<<((i)%NBBY)) 421#define setbit(a,i) ((a)[(i)/NBBY] |= 1<<((i)%NBBY))
422#define clrbit(a,i) ((a)[(i)/NBBY] &= ~(1<<((i)%NBBY))) 422#define clrbit(a,i) ((a)[(i)/NBBY] &= ~(1<<((i)%NBBY)))
423#define isset(a,i) ((a)[(i)/NBBY] & (1<<((i)%NBBY))) 423#define isset(a,i) ((a)[(i)/NBBY] & (1<<((i)%NBBY)))
424#define isclr(a,i) (((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0) 424#define isclr(a,i) (((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
425 425
426/* Macros for counting and rounding. */ 426/* Macros for counting and rounding. */
427#ifndef howmany 427#ifndef howmany
428#define howmany(x, y) (((x)+((y)-1))/(y)) 428#define howmany(x, y) (((x)+((y)-1))/(y))
429#endif 429#endif
430#define roundup(x, y) ((((x)+((y)-1))/(y))*(y)) 430#define roundup(x, y) ((((x)+((y)-1))/(y))*(y))
431#define rounddown(x,y) (((x)/(y))*(y)) 431#define rounddown(x,y) (((x)/(y))*(y))
432 432
433/* 433/*
434 * Rounding to powers of two. The naive definitions of roundup2 and 434 * Rounding to powers of two. The naive definitions of roundup2 and
435 * rounddown2, 435 * rounddown2,
436 * 436 *
437 * #define roundup2(x,m) (((x) + ((m) - 1)) & ~((m) - 1)) 437 * #define roundup2(x,m) (((x) + ((m) - 1)) & ~((m) - 1))
438 * #define rounddown2(x,m) ((x) & ~((m) - 1)), 438 * #define rounddown2(x,m) ((x) & ~((m) - 1)),
439 * 439 *
440 * exhibit a quirk of integer arithmetic in C because the complement 440 * exhibit a quirk of integer arithmetic in C because the complement
441 * happens in the type of m, not in the type of x. So if unsigned int 441 * happens in the type of m, not in the type of x. So if unsigned int
442 * is 32-bit, and m is an unsigned int while x is a uint64_t, then 442 * is 32-bit, and m is an unsigned int while x is a uint64_t, then
443 * roundup2 and rounddown2 would have the unintended effect of clearing 443 * roundup2 and rounddown2 would have the unintended effect of clearing
444 * the upper 32 bits of the result(!). These definitions avoid the 444 * the upper 32 bits of the result(!). These definitions avoid the
445 * pitfalls of C arithmetic depending on the types of x and m, and 445 * pitfalls of C arithmetic depending on the types of x and m, and
446 * additionally avoid multiply evaluating their arguments. 446 * additionally avoid multiply evaluating their arguments.
447 */ 447 */
448#define roundup2(x,m) ((((x) - 1) | ((m) - 1)) + 1) 448#define roundup2(x,m) ((((x) - 1) | ((m) - 1)) + 1)
449#define rounddown2(x,m) ((x) & ~((__typeof__(x))((m) - 1))) 449#define rounddown2(x,m) ((x) & ~((__typeof__(x))((m) - 1)))
450 450
451#define powerof2(x) ((((x)-1)&(x))==0) 451#define powerof2(x) ((((x)-1)&(x))==0)
452 452
453/* 453/*
454 * Constants for setting the parameters of the kernel memory allocator. 454 * Constants for setting the parameters of the kernel memory allocator.
455 * 455 *
456 * 2 ** MINBUCKET is the smallest unit of memory that will be 456 * 2 ** MINBUCKET is the smallest unit of memory that will be
457 * allocated. It must be at least large enough to hold a pointer. 457 * allocated. It must be at least large enough to hold a pointer.
458 * 458 *
459 * Units of memory less or equal to MAXALLOCSAVE will permanently 459 * Units of memory less or equal to MAXALLOCSAVE will permanently
460 * allocate physical memory; requests for these size pieces of 460 * allocate physical memory; requests for these size pieces of
461 * memory are quite fast. Allocations greater than MAXALLOCSAVE must 461 * memory are quite fast. Allocations greater than MAXALLOCSAVE must
462 * always allocate and free physical memory; requests for these 462 * always allocate and free physical memory; requests for these
463 * size allocations should be done infrequently as they will be slow. 463 * size allocations should be done infrequently as they will be slow.
464 * 464 *
465 * Constraints: NBPG <= MAXALLOCSAVE <= 2 ** (MINBUCKET + 14), and 465 * Constraints: NBPG <= MAXALLOCSAVE <= 2 ** (MINBUCKET + 14), and
466 * MAXALLOCSAVE must be a power of two. 466 * MAXALLOCSAVE must be a power of two.
467 */ 467 */
468#ifdef _LP64 468#ifdef _LP64
469#define MINBUCKET 5 /* 5 => min allocation of 32 bytes */ 469#define MINBUCKET 5 /* 5 => min allocation of 32 bytes */
470#else 470#else
471#define MINBUCKET 4 /* 4 => min allocation of 16 bytes */ 471#define MINBUCKET 4 /* 4 => min allocation of 16 bytes */
472#endif 472#endif
473#define MAXALLOCSAVE (2 * NBPG) 473#define MAXALLOCSAVE (2 * NBPG)
474 474
475/* 475/*
476 * Scale factor for scaled integers used to count %cpu time and load avgs. 476 * Scale factor for scaled integers used to count %cpu time and load avgs.
477 * 477 *
478 * The number of CPU `tick's that map to a unique `%age' can be expressed 478 * The number of CPU `tick's that map to a unique `%age' can be expressed
479 * by the formula (1 / (2 ^ (FSHIFT - 11))). The maximum load average that 479 * by the formula (1 / (2 ^ (FSHIFT - 11))). The maximum load average that
480 * can be calculated (assuming 32 bits) can be closely approximated using 480 * can be calculated (assuming 32 bits) can be closely approximated using
481 * the formula (2 ^ (2 * (16 - FSHIFT))) for (FSHIFT < 15). 481 * the formula (2 ^ (2 * (16 - FSHIFT))) for (FSHIFT < 15).
482 * 482 *
483 * For the scheduler to maintain a 1:1 mapping of CPU `tick' to `%age', 483 * For the scheduler to maintain a 1:1 mapping of CPU `tick' to `%age',
484 * FSHIFT must be at least 11; this gives us a maximum load avg of ~1024. 484 * FSHIFT must be at least 11; this gives us a maximum load avg of ~1024.
485 */ 485 */
486#define FSHIFT 11 /* bits to right of fixed binary point */ 486#define FSHIFT 11 /* bits to right of fixed binary point */
487#define FSCALE (1<<FSHIFT) 487#define FSCALE (1<<FSHIFT)
488 488
489/* 489/*
490 * The time for a process to be blocked before being very swappable. 490 * The time for a process to be blocked before being very swappable.
491 * This is a number of seconds which the system takes as being a non-trivial 491 * This is a number of seconds which the system takes as being a non-trivial
492 * amount of real time. You probably shouldn't change this; 492 * amount of real time. You probably shouldn't change this;
493 * it is used in subtle ways (fractions and multiples of it are, that is, like 493 * it is used in subtle ways (fractions and multiples of it are, that is, like
494 * half of a ``long time'', almost a long time, etc.) 494 * half of a ``long time'', almost a long time, etc.)
495 * It is related to human patience and other factors which don't really 495 * It is related to human patience and other factors which don't really
496 * change over time. 496 * change over time.
497 */ 497 */
498#define MAXSLP 20 498#define MAXSLP 20
499 499
500/* 500/*
501 * Defaults for Unified Buffer Cache parameters. 501 * Defaults for Unified Buffer Cache parameters.
502 * These may be overridden in <machine/param.h>. 502 * These may be overridden in <machine/param.h>.
503 */ 503 */
504 504
505#ifndef UBC_WINSHIFT 505#ifndef UBC_WINSHIFT
506#define UBC_WINSHIFT 13 506#define UBC_WINSHIFT 13
507#endif 507#endif
508#ifndef UBC_NWINS 508#ifndef UBC_NWINS
509#define UBC_NWINS 1024 509#define UBC_NWINS 1024
510#endif 510#endif
511 511
512#ifdef _KERNEL 512#ifdef _KERNEL
513extern int hz; 513extern int hz;
514/* 514/*
515 * macro to convert from milliseconds to hz without integer overflow 515 * macro to convert from milliseconds to hz without integer overflow
516 * The 32 bit version uses only 32bit arithmetic; 0x20000 is safe for hz < 20000 516 * The 32 bit version uses only 32bit arithmetic; 0x20000 is safe for hz < 20000
517 * the 64 bit version does the computation directly. 517 * the 64 bit version does the computation directly.
518 */ 518 */
519#ifndef mstohz 519#ifndef mstohz
520# ifdef _LP64 520# ifdef _LP64
521# define mstohz(ms) ((unsigned int)((ms + 0ul) * hz / 1000ul)) 521# define mstohz(ms) ((unsigned int)((ms + 0ul) * hz / 1000ul))
522# else 522# else
523static __inline unsigned int 523static __inline unsigned int
524mstohz(unsigned int ms) 524mstohz(unsigned int ms)
525{ 525{
526 return __predict_false(ms >= 0x20000u) ? 526 return __predict_false(ms >= 0x20000u) ?
527 (ms / 1000u) * hz : (ms * hz) / 1000u; 527 (ms / 1000u) * hz : (ms * hz) / 1000u;
528} 528}
529# endif 529# endif
530#endif 530#endif
531 531
532#ifndef hztoms 532#ifndef hztoms
533# ifdef _LP64 533# ifdef _LP64
534# define hztoms(t) ((unsigned int)(((t) + 0ul) * 1000ul / hz)) 534# define hztoms(t) ((unsigned int)(((t) + 0ul) * 1000ul / hz))
535# else 535# else
536static __inline unsigned int 536static __inline unsigned int
537hztoms(unsigned int t) 537hztoms(unsigned int t)
538{ 538{
539 return __predict_false(t >= 0x20000u) ? 539 return __predict_false(t >= 0x20000u) ?
540 (t / hz) * 1000u : (t * 1000u) / hz; 540 (t / hz) * 1000u : (t * 1000u) / hz;
541} 541}
542# endif 542# endif
543#endif 543#endif
544 544
545#define hz2bintime(t) (ms2bintime(hztoms(t))) 545#define hz2bintime(t) (ms2bintime(hztoms(t)))
546 546
547extern const int schedppq; 547extern const int schedppq;
548extern size_t coherency_unit; 548extern size_t coherency_unit;
549 549
550#endif /* _KERNEL */ 550#endif /* _KERNEL */
551 551
552/* 552/*
553 * Minimum alignment of "struct lwp" needed by the architecture. This 553 * Minimum alignment of "struct lwp" needed by the architecture. This
554 * counts when packing a lock byte into a word alongside a pointer to an 554 * counts when packing a lock byte into a word alongside a pointer to an
555 * LWP. We need a minimum of 32, but go with the cache line size. 555 * LWP. We need a minimum of 32, but go with the cache line size.
556 */ 556 */
557#ifndef MIN_LWP_ALIGNMENT 557#ifndef MIN_LWP_ALIGNMENT
558# if COHERENCY_UNIT > 32 558# if COHERENCY_UNIT > 32
559# define MIN_LWP_ALIGNMENT COHERENCY_UNIT 559# define MIN_LWP_ALIGNMENT COHERENCY_UNIT
560# else 560# else
561# define MIN_LWP_ALIGNMENT 32 561# define MIN_LWP_ALIGNMENT 32
562# endif 562# endif
563#endif 563#endif
564#endif /* !__ASSEMBLER__ */ 564#endif /* !__ASSEMBLER__ */
565 565
566#endif /* !_SYS_PARAM_H_ */ 566#endif /* !_SYS_PARAM_H_ */