xref: /original-bsd/sys/kern/subr_xxx.c (revision 0fc6f013)
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.8 (Berkeley) 03/09/86
7  */
8 
9 #include "../machine/pte.h"
10 
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"
23 
24 /*
25  * Routine placed in illegal entries in the bdevsw and cdevsw tables.
26  */
27 nodev()
28 {
29 
30 	return (ENODEV);
31 }
32 
33 /*
34  * Null routine; placed in insignificant entries
35  * in the bdevsw and cdevsw tables.
36  */
37 nulldev()
38 {
39 
40 	return (0);
41 }
42 
43 #ifdef notdef
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 
56 unsigned
57 min(a, b)
58 	u_int a, b;
59 {
60 
61 	return (a < b ? a : b);
62 }
63 
64 unsigned
65 max(a, b)
66 	u_int a, b;
67 {
68 
69 	return (a > b ? a : b);
70 }
71 #endif notdef
72 
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 }
107 
108 #ifdef GPROF
109 /*
110  * Stub routine in case it is ever possible to free space.
111  */
112 cfreemem(cp, size)
113 	caddr_t cp;
114 	int size;
115 {
116 	printf("freeing %x, size %d\n", cp, size);
117 }
118 #endif
119 
120 #ifndef vax
121 ffs(mask)
122 	register long mask;
123 {
124 	register int i;
125 
126 	for(i = 1; i < NSIG; i++) {
127 		if (mask & 1)
128 			return (i);
129 		mask >>= 1;
130 	}
131 	return (0);
132 }
133 
134 bcmp(s1, s2, len)
135 	register char *s1, *s2;
136 	register int len;
137 {
138 
139 	while (len--)
140 		if (*s1++ != *s2++)
141 			return (1);
142 	return (0);
143 }
144 
145 strlen(s1)
146 	register char *s1;
147 {
148 	register int len;
149 
150 	for (len = 0; *s1++ != '\0'; len++)
151 		/* void */;
152 	return (len);
153 }
154 #endif
155