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  *	OMRON:$Id: sys_machdep.c,v 1.2 92/06/14 06:22:55 moti Exp $
9  *
10  * from: hp300/hp300/sys_machdep.c	7.8 (Berkeley) 6/5/92
11  *
12  *	@(#)sys_machdep.c	7.1 (Berkeley) 06/15/92
13  */
14 
15 #include "sys/param.h"
16 #include "sys/systm.h"
17 #include "sys/ioctl.h"
18 #include "sys/file.h"
19 #include "sys/time.h"
20 #include "sys/proc.h"
21 #include "sys/uio.h"
22 #include "sys/kernel.h"
23 #include "sys/mtio.h"
24 #include "sys/buf.h"
25 #include "sys/trace.h"
26 #include "vm/vm.h"
27 
28 #ifdef TRACE
29 int	nvualarm;
30 
31 vtrace(p, uap, retval)
32 	struct proc *p;
33 	register struct args {
34 		int	request;
35 		int	value;
36 	} *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 "../include/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