1: /* 2: * Copyright (c) 1982, 1986 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: * @(#)sys_machdep.c 7.1 (Berkeley) 6/5/86 7: */ 8: 9: #include "param.h" 10: #include "systm.h" 11: #include "dir.h" 12: #include "user.h" 13: #include "ioctl.h" 14: #include "file.h" 15: #include "proc.h" 16: #include "uio.h" 17: #include "kernel.h" 18: #include "mtio.h" 19: #include "buf.h" 20: #include "trace.h" 21: 22: #include "dkio.h" 23: #include "pte.h" 24: #include "../vaxuba/ubareg.h" 25: #include "../vaxuba/ubavar.h" 26: 27: resuba() 28: { 29: 30: if (suser()) 31: if (u.u_arg[0] < numuba) 32: ubareset(u.u_arg[0]); 33: } 34: 35: #ifdef TRACE 36: int nvualarm; 37: 38: vtrace() 39: { 40: register struct a { 41: int request; 42: int value; 43: } *uap; 44: int vdoualarm(); 45: 46: uap = (struct a *)u.u_ap; 47: switch (uap->request) { 48: 49: case VTR_DISABLE: /* disable a trace point */ 50: case VTR_ENABLE: /* enable a trace point */ 51: if (uap->value < 0 || uap->value >= TR_NFLAGS) 52: u.u_error = EINVAL; 53: else { 54: u.u_r.r_val1 = traceflags[uap->value]; 55: traceflags[uap->value] = uap->request; 56: } 57: break; 58: 59: case VTR_VALUE: /* return a trace point setting */ 60: if (uap->value < 0 || uap->value >= TR_NFLAGS) 61: u.u_error = EINVAL; 62: else 63: u.u_r.r_val1 = traceflags[uap->value]; 64: break; 65: 66: case VTR_UALARM: /* set a real-time ualarm, less than 1 min */ 67: if (uap->value <= 0 || uap->value > 60 * hz || 68: nvualarm > 5) 69: u.u_error = EINVAL; 70: else { 71: nvualarm++; 72: timeout(vdoualarm, (caddr_t)u.u_procp->p_pid, 73: uap->value); 74: } 75: break; 76: 77: case VTR_STAMP: 78: trace(TR_STAMP, uap->value, u.u_procp->p_pid); 79: break; 80: } 81: } 82: 83: vdoualarm(arg) 84: int arg; 85: { 86: register struct proc *p; 87: 88: p = pfind(arg); 89: if (p) 90: psignal(p, 16); 91: nvualarm--; 92: } 93: #endif 94: 95: #ifdef COMPAT 96: /* 97: * Note: these tables are sorted by 98: * ioctl "code" (in ascending order). 99: */ 100: int dctls[] = { DKIOCHDR, 0 }; 101: int fctls[] = { FIOCLEX, FIONCLEX, FIOASYNC, FIONBIO, FIONREAD, 0 }; 102: int mctls[] = { MTIOCTOP, MTIOCGET, 0 }; 103: int tctls[] = { 104: TIOCGETD, TIOCSETD, TIOCHPCL, TIOCMODG, TIOCMODS, 105: TIOCGETP, TIOCSETP, TIOCSETN, TIOCEXCL, TIOCNXCL, 106: TIOCFLUSH,TIOCSETC, TIOCGETC, TIOCREMOTE,TIOCMGET, 107: TIOCMBIC, TIOCMBIS, TIOCMSET, TIOCSTART,TIOCSTOP, 108: TIOCPKT, TIOCNOTTY,TIOCSTI, TIOCOUTQ, TIOCGLTC, 109: TIOCSLTC, TIOCSPGRP,TIOCGPGRP,TIOCCDTR, TIOCSDTR, 110: TIOCCBRK, TIOCSBRK, TIOCLGET, TIOCLSET, TIOCLBIC, 111: TIOCLBIS, 0 112: }; 113: 114: /* 115: * Map an old style ioctl command to new. 116: */ 117: mapioctl(cmd) 118: int cmd; 119: { 120: register int *map, c; 121: 122: switch ((cmd >> 8) & 0xff) { 123: 124: case 'd': 125: map = dctls; 126: break; 127: 128: case 'f': 129: map = fctls; 130: break; 131: 132: case 'm': 133: map = mctls; 134: break; 135: 136: case 't': 137: map = tctls; 138: break; 139: 140: default: 141: return (0); 142: } 143: while ((c = *map) && (c&0xff) < (cmd&0xff)) 144: map++; 145: if (c && (c&0xff) == (cmd&0xff)) 146: return (c); 147: return (0); 148: } 149: #endif