1 /* 2 * Copyright (c) 1992 OMRON Corporation. 3 * Copyright (c) 1982, 1986 Regents of the University of California. 4 * All rights reserved. 5 * 6 * %sccs.include.redist.c% 7 * 8 * from: hp300/hp300/sys_machdep.c 7.11 (Berkeley) 12/27/92 9 * 10 * @(#)sys_machdep.c 7.3 (Berkeley) 01/03/93 11 */ 12 13 #include <sys/param.h> 14 #include <sys/systm.h> 15 #include <sys/ioctl.h> 16 #include <sys/file.h> 17 #include <sys/time.h> 18 #include <sys/proc.h> 19 #include <sys/uio.h> 20 #include <sys/kernel.h> 21 #include <sys/mtio.h> 22 #include <sys/buf.h> 23 #include <sys/trace.h> 24 25 #include <vm/vm.h> 26 27 #ifdef TRACE 28 int nvualarm; 29 30 struct vtrace_args { 31 int request; 32 int value; 33 }; 34 vtrace(p, uap, retval) 35 struct proc *p; 36 register struct vtrace_args *uap; 37 int *retval; 38 { 39 int vdoualarm(); 40 41 switch (uap->request) { 42 43 case VTR_DISABLE: /* disable a trace point */ 44 case VTR_ENABLE: /* enable a trace point */ 45 if (uap->value < 0 || uap->value >= TR_NFLAGS) 46 return (EINVAL); 47 *retval = traceflags[uap->value]; 48 traceflags[uap->value] = uap->request; 49 break; 50 51 case VTR_VALUE: /* return a trace point setting */ 52 if (uap->value < 0 || uap->value >= TR_NFLAGS) 53 return (EINVAL); 54 *retval = traceflags[uap->value]; 55 break; 56 57 case VTR_UALARM: /* set a real-time ualarm, less than 1 min */ 58 if (uap->value <= 0 || uap->value > 60 * hz || nvualarm > 5) 59 return (EINVAL); 60 nvualarm++; 61 timeout(vdoualarm, (caddr_t)p->p_pid, uap->value); 62 break; 63 64 case VTR_STAMP: 65 trace(TR_STAMP, uap->value, p->p_pid); 66 break; 67 } 68 return (0); 69 } 70 71 vdoualarm(arg) 72 int arg; 73 { 74 register struct proc *p; 75 76 p = pfind(arg); 77 if (p) 78 psignal(p, 16); 79 nvualarm--; 80 } 81 #endif 82 83 #include <machine/cpu.h> 84 85 /* XXX should be in an include file somewhere */ 86 #define CC_PURGE 1 87 #define CC_FLUSH 2 88 #define CC_IPURGE 4 89 #define CC_EXTPURGE 0x80000000 90 /* XXX end should be */ 91 92 /* 93 * Note that what we do here for a 68040 is different than HP-UX. 94 * 95 * In 'pux they either act on a line (len == 16), a page (len == NBPG) 96 * or the whole cache (len == anything else). 97 * 98 * In BSD we attempt to be more optimal when acting on "odd" sizes. 99 * For lengths up to 1024 we do all affected lines, up to 2*NBPG we 100 * do pages, above that we do the entire cache. 101 */ 102 /*ARGSUSED1*/ 103 cachectl(req, addr, len) 104 int req; 105 caddr_t addr; 106 int len; 107 { 108 int error = 0; 109 110 switch (req) { 111 case CC_EXTPURGE|CC_PURGE: 112 case CC_EXTPURGE|CC_FLUSH: 113 case CC_PURGE: 114 case CC_FLUSH: 115 break; 116 case CC_EXTPURGE|CC_IPURGE: 117 case CC_IPURGE: 118 ICIA(); 119 break; 120 default: 121 error = EINVAL; 122 break; 123 } 124 return(error); 125 } 126