param.c revision 1.66 1 1.66 pooka /* $NetBSD: param.c,v 1.66 2015/08/24 22:50:33 pooka Exp $ */
2 1.11 cgd
3 1.7 cgd /*
4 1.7 cgd * Copyright (c) 1980, 1986, 1989 Regents of the University of California.
5 1.7 cgd * All rights reserved.
6 1.7 cgd * (c) UNIX System Laboratories, Inc.
7 1.7 cgd * All or some portions of this file are derived from material licensed
8 1.7 cgd * to the University of California by American Telephone and Telegraph
9 1.7 cgd * Co. or Unix System Laboratories, Inc. and are reproduced herein with
10 1.7 cgd * the permission of UNIX System Laboratories, Inc.
11 1.7 cgd *
12 1.7 cgd * Redistribution and use in source and binary forms, with or without
13 1.7 cgd * modification, are permitted provided that the following conditions
14 1.7 cgd * are met:
15 1.7 cgd * 1. Redistributions of source code must retain the above copyright
16 1.7 cgd * notice, this list of conditions and the following disclaimer.
17 1.7 cgd * 2. Redistributions in binary form must reproduce the above copyright
18 1.7 cgd * notice, this list of conditions and the following disclaimer in the
19 1.7 cgd * documentation and/or other materials provided with the distribution.
20 1.41 agc * 3. Neither the name of the University nor the names of its contributors
21 1.7 cgd * may be used to endorse or promote products derived from this software
22 1.7 cgd * without specific prior written permission.
23 1.7 cgd *
24 1.7 cgd * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 1.7 cgd * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 1.7 cgd * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 1.7 cgd * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 1.7 cgd * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 1.7 cgd * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 1.7 cgd * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 1.7 cgd * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 1.7 cgd * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 1.7 cgd * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 1.7 cgd * SUCH DAMAGE.
35 1.7 cgd *
36 1.10 cgd * @(#)param.c 7.20 (Berkeley) 6/27/91
37 1.7 cgd */
38 1.39 lukem
39 1.39 lukem #include <sys/cdefs.h>
40 1.66 pooka __KERNEL_RCSID(0, "$NetBSD: param.c,v 1.66 2015/08/24 22:50:33 pooka Exp $");
41 1.22 enami
42 1.66 pooka #ifdef _KERNEL_OPT
43 1.46 yamt #include "opt_hz.h"
44 1.22 enami #include "opt_rtc_offset.h"
45 1.24 tron #include "opt_sysv.h"
46 1.36 jdolecek #include "opt_sysvparam.h"
47 1.54 ad #include "opt_multiprocessor.h"
48 1.66 pooka #endif
49 1.7 cgd
50 1.7 cgd #include <sys/param.h>
51 1.7 cgd #include <sys/systm.h>
52 1.7 cgd #include <sys/socket.h>
53 1.26 simonb #include <sys/socketvar.h>
54 1.7 cgd #include <sys/proc.h>
55 1.7 cgd #include <sys/vnode.h>
56 1.7 cgd #include <sys/file.h>
57 1.7 cgd #include <sys/callout.h>
58 1.7 cgd #include <sys/mbuf.h>
59 1.9 mycroft #include <ufs/ufs/quota.h>
60 1.7 cgd #include <sys/kernel.h>
61 1.7 cgd #include <sys/utsname.h>
62 1.59 ad #include <sys/ksem.h>
63 1.64 christos #include <sys/lwp.h>
64 1.7 cgd #ifdef SYSVSHM
65 1.7 cgd #include <machine/vmparam.h>
66 1.7 cgd #include <sys/shm.h>
67 1.7 cgd #endif
68 1.7 cgd #ifdef SYSVSEM
69 1.7 cgd #include <sys/sem.h>
70 1.7 cgd #endif
71 1.7 cgd #ifdef SYSVMSG
72 1.7 cgd #include <sys/msg.h>
73 1.7 cgd #endif
74 1.40 atatat
75 1.58 gmcgarry /*
76 1.58 gmcgarry * PCC cannot handle the 80KB string literal.
77 1.58 gmcgarry */
78 1.58 gmcgarry #if !defined(__PCC__)
79 1.40 atatat #define CONFIG_FILE
80 1.40 atatat #include "config_file.h"
81 1.58 gmcgarry #endif
82 1.7 cgd
83 1.7 cgd /*
84 1.7 cgd * System parameter formulae.
85 1.7 cgd *
86 1.7 cgd * This file is copied into each directory where we compile
87 1.7 cgd * the kernel; it should be modified there to suit local taste
88 1.7 cgd * if necessary.
89 1.7 cgd *
90 1.19 perry * Compiled with -DHZ=xx -DRTC_OFFSET=x -DMAXUSERS=xx
91 1.7 cgd */
92 1.7 cgd
93 1.19 perry #ifdef TIMEZONE
94 1.19 perry #error TIMEZONE is an obsolete kernel option.
95 1.16 mrg #endif
96 1.33 thorpej
97 1.19 perry #ifdef DST
98 1.19 perry #error DST is an obsolete kernel option.
99 1.19 perry #endif
100 1.33 thorpej
101 1.19 perry #ifndef RTC_OFFSET
102 1.19 perry #define RTC_OFFSET 0
103 1.16 mrg #endif
104 1.33 thorpej
105 1.7 cgd #ifndef HZ
106 1.7 cgd #define HZ 100
107 1.7 cgd #endif
108 1.33 thorpej
109 1.33 thorpej #ifndef MAXFILES
110 1.33 thorpej #define MAXFILES (3 * (NPROC + MAXUSERS) + 80)
111 1.33 thorpej #endif
112 1.33 thorpej
113 1.57 ad #ifndef MAXEXEC
114 1.57 ad #define MAXEXEC 16
115 1.57 ad #endif
116 1.57 ad
117 1.7 cgd int hz = HZ;
118 1.7 cgd int tick = 1000000 / HZ;
119 1.47 yamt /* can adjust 240ms in 60s */
120 1.47 yamt int tickadj = (240000 / (60 * HZ)) ? (240000 / (60 * HZ)) : 1;
121 1.19 perry int rtc_offset = RTC_OFFSET;
122 1.7 cgd int maxproc = NPROC;
123 1.64 christos int maxlwp = MAXLWP;
124 1.9 mycroft int desiredvnodes = NVNODE;
125 1.53 ad u_int maxfiles = MAXFILES;
126 1.7 cgd int fscale = FSCALE; /* kernel uses `FSCALE', user uses `fscale' */
127 1.57 ad int maxexec = MAXEXEC; /* max number of concurrent exec() calls */
128 1.55 ad
129 1.54 ad #ifdef MULTIPROCESSOR
130 1.54 ad u_int maxcpus = MAXCPUS;
131 1.55 ad size_t coherency_unit = COHERENCY_UNIT;
132 1.54 ad #else
133 1.54 ad u_int maxcpus = 1;
134 1.56 ad size_t coherency_unit = ALIGNBYTES + 1;
135 1.54 ad #endif
136 1.29 thorpej
137 1.29 thorpej /*
138 1.29 thorpej * Various mbuf-related parameters. These can also be changed at run-time
139 1.29 thorpej * with sysctl.
140 1.29 thorpej */
141 1.63 joerg int nmbclusters = 0;
142 1.29 thorpej
143 1.29 thorpej #ifndef MBLOWAT
144 1.29 thorpej #define MBLOWAT 16
145 1.29 thorpej #endif
146 1.29 thorpej int mblowat = MBLOWAT;
147 1.29 thorpej
148 1.29 thorpej #ifndef MCLLOWAT
149 1.29 thorpej #define MCLLOWAT 8
150 1.29 thorpej #endif
151 1.29 thorpej int mcllowat = MCLLOWAT;
152 1.7 cgd
153 1.65 pgoyette #if XXX_PRG
154 1.7 cgd /*
155 1.7 cgd * Values in support of System V compatible shared memory. XXX
156 1.7 cgd */
157 1.7 cgd #ifdef SYSVSHM
158 1.60 joerg #if !defined(SHMMAX) && defined(SHMMAXPGS)
159 1.45 martin #define SHMMAX SHMMAXPGS /* shminit() performs a `*= PAGE_SIZE' */
160 1.60 joerg #elif !defined(SHMMAX)
161 1.60 joerg #define SHMMAX 0
162 1.38 mrg #endif
163 1.38 mrg #ifndef SHMMIN
164 1.7 cgd #define SHMMIN 1
165 1.38 mrg #endif
166 1.38 mrg #ifndef SHMMNI
167 1.43 drochner #define SHMMNI 128 /* <64k, see IPCID_TO_IX in ipc.h */
168 1.38 mrg #endif
169 1.38 mrg #ifndef SHMSEG
170 1.37 mycroft #define SHMSEG 128
171 1.38 mrg #endif
172 1.7 cgd
173 1.7 cgd struct shminfo shminfo = {
174 1.7 cgd SHMMAX,
175 1.7 cgd SHMMIN,
176 1.7 cgd SHMMNI,
177 1.7 cgd SHMSEG,
178 1.60 joerg 0
179 1.7 cgd };
180 1.7 cgd #endif
181 1.7 cgd
182 1.7 cgd /*
183 1.7 cgd * Values in support of System V compatible semaphores.
184 1.7 cgd */
185 1.7 cgd #ifdef SYSVSEM
186 1.14 mycroft struct seminfo seminfo = {
187 1.14 mycroft SEMMAP, /* # of entries in semaphore map */
188 1.14 mycroft SEMMNI, /* # of semaphore identifiers */
189 1.14 mycroft SEMMNS, /* # of semaphores in system */
190 1.14 mycroft SEMMNU, /* # of undo structures in system */
191 1.14 mycroft SEMMSL, /* max # of semaphores per id */
192 1.14 mycroft SEMOPM, /* max # of operations per semop call */
193 1.14 mycroft SEMUME, /* max # of undo entries per process */
194 1.14 mycroft SEMUSZ, /* size in bytes of undo structure */
195 1.14 mycroft SEMVMX, /* semaphore maximum value */
196 1.14 mycroft SEMAEM /* adjust on exit max value */
197 1.7 cgd };
198 1.7 cgd #endif
199 1.7 cgd
200 1.7 cgd /*
201 1.7 cgd * Values in support of System V compatible messages.
202 1.7 cgd */
203 1.7 cgd #ifdef SYSVMSG
204 1.14 mycroft struct msginfo msginfo = {
205 1.14 mycroft MSGMAX, /* max chars in a message */
206 1.14 mycroft MSGMNI, /* # of message queue identifiers */
207 1.14 mycroft MSGMNB, /* max chars in a queue */
208 1.14 mycroft MSGTQL, /* max messages in system */
209 1.14 mycroft MSGSSZ, /* size of a message segment */
210 1.14 mycroft /* (must be small power of 2 greater than 4) */
211 1.14 mycroft MSGSEG /* number of message segments */
212 1.7 cgd };
213 1.7 cgd #endif
214 1.65 pgoyette #endif /* XXX_PRG */
215 1.7 cgd
216 1.7 cgd /*
217 1.21 jonathan * Actual network mbuf sizes (read-only), for netstat.
218 1.21 jonathan */
219 1.28 simonb const int msize = MSIZE;
220 1.28 simonb const int mclbytes = MCLBYTES;
221 1.59 ad
222 1.59 ad /*
223 1.59 ad * Values in support of POSIX semaphores.
224 1.59 ad */
225 1.59 ad int ksem_max = KSEM_MAX;
226