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