Commit | Line | Data |
---|---|---|
da7c5cc6 KM |
1 | /* |
2 | * Copyright (c) 1982 Regents of the University of California. | |
3 | * All rights reserved. The Berkeley software License Agreement | |
4 | * specifies the terms and conditions for redistribution. | |
5 | * | |
6 | * @(#)subr_xxx.c 6.6 (Berkeley) %G% | |
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 | ||
23cf588f | 43 | #ifndef vax |
ae9e2121 BJ |
44 | imin(a, b) |
45 | { | |
46 | ||
47 | return (a < b ? a : b); | |
48 | } | |
49 | ||
50 | imax(a, b) | |
51 | { | |
52 | ||
53 | return (a > b ? a : b); | |
54 | } | |
55 | ||
6459ebe0 KM |
56 | unsigned |
57 | min(a, b) | |
b32450f4 | 58 | u_int a, b; |
6459ebe0 KM |
59 | { |
60 | ||
61 | return (a < b ? a : b); | |
62 | } | |
63 | ||
64 | unsigned | |
65 | max(a, b) | |
b32450f4 | 66 | u_int a, b; |
6459ebe0 KM |
67 | { |
68 | ||
69 | return (a > b ? a : b); | |
70 | } | |
23cf588f | 71 | #endif not vax |
b32450f4 | 72 | |
cb99a88a BJ |
73 | extern cabase, calimit; |
74 | extern struct pte camap[]; | |
75 | ||
76 | caddr_t cacur = (caddr_t)&cabase; | |
77 | caddr_t camax = (caddr_t)&cabase; | |
78 | int cax = 0; | |
79 | /* | |
80 | * This is a kernel-mode storage allocator. | |
81 | * It is very primitive, currently, in that | |
82 | * there is no way to give space back. | |
83 | * It serves, for the time being, the needs of | |
84 | * auto-configuration code and the like which | |
85 | * need to allocate some stuff at boot time. | |
86 | */ | |
87 | caddr_t | |
88 | calloc(size) | |
89 | int size; | |
90 | { | |
91 | register caddr_t res; | |
92 | register int i; | |
93 | ||
94 | if (cacur+size >= (caddr_t)&calimit) | |
95 | panic("calloc"); | |
96 | while (cacur+size > camax) { | |
97 | (void) vmemall(&camap[cax], CLSIZE, &proc[0], CSYS); | |
98 | vmaccess(&camap[cax], camax, CLSIZE); | |
99 | for (i = 0; i < CLSIZE; i++) | |
100 | clearseg(camap[cax++].pg_pfnum); | |
101 | camax += NBPG * CLSIZE; | |
102 | } | |
103 | res = cacur; | |
104 | cacur += size; | |
105 | return (res); | |
106 | } | |
febd1daa | 107 | |
44a388b8 KM |
108 | /* |
109 | * Stub routine in case it is ever possible to free space. | |
110 | */ | |
111 | cfreemem(cp, size) | |
112 | caddr_t cp; | |
113 | int size; | |
114 | { | |
115 | printf("freeing %x, size %d\n", cp, size); | |
116 | } | |
117 | ||
cb99a88a BJ |
118 | #ifndef vax |
119 | ffs(mask) | |
120 | register long mask; | |
121 | { | |
122 | register int i; | |
123 | ||
88a7a62a | 124 | for(i = 1; i < NSIG; i++) { |
cb99a88a BJ |
125 | if (mask & 1) |
126 | return (i); | |
127 | mask >>= 1; | |
128 | } | |
129 | return (0); | |
130 | } | |
febd1daa | 131 | |
febd1daa BJ |
132 | bcmp(s1, s2, len) |
133 | register char *s1, *s2; | |
134 | register int len; | |
135 | { | |
136 | ||
f49dd739 | 137 | while (len--) |
febd1daa BJ |
138 | if (*s1++ != *s2++) |
139 | return (1); | |
140 | return (0); | |
141 | } | |
142 | ||
143 | strlen(s1) | |
144 | register char *s1; | |
145 | { | |
146 | register int len; | |
147 | ||
148 | for (len = 0; *s1++ != '\0'; len++) | |
149 | /* void */; | |
150 | return (len); | |
151 | } | |
152 | #endif |