1 /* subr_xxx.c 6.5 84/08/29 */ 2 3 #include "../machine/pte.h" 4 5 #include "param.h" 6 #include "systm.h" 7 #include "conf.h" 8 #include "inode.h" 9 #include "dir.h" 10 #include "user.h" 11 #include "buf.h" 12 #include "proc.h" 13 #include "fs.h" 14 #include "vm.h" 15 #include "cmap.h" 16 #include "uio.h" 17 18 /* 19 * Routine placed in illegal entries in the bdevsw and cdevsw tables. 20 */ 21 nodev() 22 { 23 24 return (ENODEV); 25 } 26 27 /* 28 * Null routine; placed in insignificant entries 29 * in the bdevsw and cdevsw tables. 30 */ 31 nulldev() 32 { 33 34 return (0); 35 } 36 37 #ifndef vax 38 imin(a, b) 39 { 40 41 return (a < b ? a : b); 42 } 43 44 imax(a, b) 45 { 46 47 return (a > b ? a : b); 48 } 49 50 unsigned 51 min(a, b) 52 u_int a, b; 53 { 54 55 return (a < b ? a : b); 56 } 57 58 unsigned 59 max(a, b) 60 u_int a, b; 61 { 62 63 return (a > b ? a : b); 64 } 65 #endif not vax 66 67 extern cabase, calimit; 68 extern struct pte camap[]; 69 70 caddr_t cacur = (caddr_t)&cabase; 71 caddr_t camax = (caddr_t)&cabase; 72 int cax = 0; 73 /* 74 * This is a kernel-mode storage allocator. 75 * It is very primitive, currently, in that 76 * there is no way to give space back. 77 * It serves, for the time being, the needs of 78 * auto-configuration code and the like which 79 * need to allocate some stuff at boot time. 80 */ 81 caddr_t 82 calloc(size) 83 int size; 84 { 85 register caddr_t res; 86 register int i; 87 88 if (cacur+size >= (caddr_t)&calimit) 89 panic("calloc"); 90 while (cacur+size > camax) { 91 (void) vmemall(&camap[cax], CLSIZE, &proc[0], CSYS); 92 vmaccess(&camap[cax], camax, CLSIZE); 93 for (i = 0; i < CLSIZE; i++) 94 clearseg(camap[cax++].pg_pfnum); 95 camax += NBPG * CLSIZE; 96 } 97 res = cacur; 98 cacur += size; 99 return (res); 100 } 101 102 /* 103 * Stub routine in case it is ever possible to free space. 104 */ 105 cfreemem(cp, size) 106 caddr_t cp; 107 int size; 108 { 109 printf("freeing %x, size %d\n", cp, size); 110 } 111 112 #ifndef vax 113 ffs(mask) 114 register long mask; 115 { 116 register int i; 117 118 for(i = 1; i < NSIG; i++) { 119 if (mask & 1) 120 return (i); 121 mask >>= 1; 122 } 123 return (0); 124 } 125 126 bcmp(s1, s2, len) 127 register char *s1, *s2; 128 register int len; 129 { 130 131 while (len--) 132 if (*s1++ != *s2++) 133 return (1); 134 return (0); 135 } 136 137 strlen(s1) 138 register char *s1; 139 { 140 register int len; 141 142 for (len = 0; *s1++ != '\0'; len++) 143 /* void */; 144 return (len); 145 } 146 #endif 147