Commit | Line | Data |
---|---|---|
da7c5cc6 | 1 | /* |
0880b18e | 2 | * Copyright (c) 1982, 1986 Regents of the University of California. |
da7c5cc6 KM |
3 | * All rights reserved. The Berkeley software License Agreement |
4 | * specifies the terms and conditions for redistribution. | |
5 | * | |
9d61b7ff | 6 | * @(#)subr_xxx.c 7.3 (Berkeley) %G% |
da7c5cc6 | 7 | */ |
961945a8 SL |
8 | |
9 | #include "../machine/pte.h" | |
ae9e2121 | 10 | |
94368568 JB |
11 | #include "param.h" |
12 | #include "systm.h" | |
13 | #include "conf.h" | |
14 | #include "inode.h" | |
15 | #include "dir.h" | |
16 | #include "user.h" | |
17 | #include "buf.h" | |
18 | #include "proc.h" | |
19 | #include "fs.h" | |
20 | #include "vm.h" | |
21 | #include "cmap.h" | |
22 | #include "uio.h" | |
ae9e2121 | 23 | |
ae9e2121 | 24 | /* |
50a84b40 | 25 | * Routine placed in illegal entries in the bdevsw and cdevsw tables. |
ae9e2121 BJ |
26 | */ |
27 | nodev() | |
28 | { | |
29 | ||
50a84b40 | 30 | return (ENODEV); |
ae9e2121 BJ |
31 | } |
32 | ||
33 | /* | |
34 | * Null routine; placed in insignificant entries | |
35 | * in the bdevsw and cdevsw tables. | |
36 | */ | |
37 | nulldev() | |
38 | { | |
39 | ||
50a84b40 | 40 | return (0); |
ae9e2121 BJ |
41 | } |
42 | ||
fb1db32c MK |
43 | /* |
44 | * Definitions of various trivial functions; | |
45 | * usually expanded inline rather than being defined here. | |
46 | */ | |
47 | #if !defined(vax) && !defined(tahoe) | |
ae9e2121 BJ |
48 | imin(a, b) |
49 | { | |
50 | ||
51 | return (a < b ? a : b); | |
52 | } | |
53 | ||
54 | imax(a, b) | |
55 | { | |
56 | ||
57 | return (a > b ? a : b); | |
58 | } | |
59 | ||
6459ebe0 KM |
60 | unsigned |
61 | min(a, b) | |
b32450f4 | 62 | u_int a, b; |
6459ebe0 KM |
63 | { |
64 | ||
65 | return (a < b ? a : b); | |
66 | } | |
67 | ||
68 | unsigned | |
69 | max(a, b) | |
b32450f4 | 70 | u_int a, b; |
6459ebe0 KM |
71 | { |
72 | ||
73 | return (a > b ? a : b); | |
74 | } | |
fb1db32c | 75 | #endif |
b32450f4 | 76 | |
cb99a88a BJ |
77 | extern cabase, calimit; |
78 | extern struct pte camap[]; | |
79 | ||
80 | caddr_t cacur = (caddr_t)&cabase; | |
81 | caddr_t camax = (caddr_t)&cabase; | |
82 | int cax = 0; | |
83 | /* | |
84 | * This is a kernel-mode storage allocator. | |
85 | * It is very primitive, currently, in that | |
86 | * there is no way to give space back. | |
87 | * It serves, for the time being, the needs of | |
88 | * auto-configuration code and the like which | |
89 | * need to allocate some stuff at boot time. | |
90 | */ | |
91 | caddr_t | |
92 | calloc(size) | |
93 | int size; | |
94 | { | |
95 | register caddr_t res; | |
96 | register int i; | |
97 | ||
98 | if (cacur+size >= (caddr_t)&calimit) | |
99 | panic("calloc"); | |
100 | while (cacur+size > camax) { | |
101 | (void) vmemall(&camap[cax], CLSIZE, &proc[0], CSYS); | |
102 | vmaccess(&camap[cax], camax, CLSIZE); | |
103 | for (i = 0; i < CLSIZE; i++) | |
104 | clearseg(camap[cax++].pg_pfnum); | |
105 | camax += NBPG * CLSIZE; | |
106 | } | |
107 | res = cacur; | |
108 | cacur += size; | |
109 | return (res); | |
110 | } | |
febd1daa | 111 | |
ba533a98 | 112 | #ifdef GPROF |
44a388b8 KM |
113 | /* |
114 | * Stub routine in case it is ever possible to free space. | |
115 | */ | |
116 | cfreemem(cp, size) | |
117 | caddr_t cp; | |
118 | int size; | |
119 | { | |
120 | printf("freeing %x, size %d\n", cp, size); | |
121 | } | |
8011f5df | 122 | #endif |
44a388b8 | 123 | |
fb1db32c | 124 | #if !defined(vax) && !defined(tahoe) |
cb99a88a BJ |
125 | ffs(mask) |
126 | register long mask; | |
127 | { | |
128 | register int i; | |
129 | ||
88a7a62a | 130 | for(i = 1; i < NSIG; i++) { |
cb99a88a BJ |
131 | if (mask & 1) |
132 | return (i); | |
133 | mask >>= 1; | |
134 | } | |
135 | return (0); | |
136 | } | |
fb1db32c | 137 | #endif |
febd1daa | 138 | |
fb1db32c | 139 | #if !defined(vax) |
febd1daa BJ |
140 | bcmp(s1, s2, len) |
141 | register char *s1, *s2; | |
9d61b7ff | 142 | register unsigned len; |
febd1daa BJ |
143 | { |
144 | ||
f49dd739 | 145 | while (len--) |
febd1daa BJ |
146 | if (*s1++ != *s2++) |
147 | return (1); | |
148 | return (0); | |
149 | } | |
150 | ||
151 | strlen(s1) | |
152 | register char *s1; | |
153 | { | |
154 | register int len; | |
155 | ||
156 | for (len = 0; *s1++ != '\0'; len++) | |
157 | /* void */; | |
158 | return (len); | |
159 | } | |
160 | #endif |