aboutsummaryrefslogtreecommitdiff
path: root/sys/i386/ibcs2/ibcs2_isc.c
blob: 344fc9d22b0f443b6f14575d2676c7489d9e0b98 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
/*-
 * Copyright (c) 1994 Søren Schmidt
 * Copyright (c) 1994 Sean Eric Fagan
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer
 *    in this position and unchanged.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. The name of the author may not be used to endorse or promote products
 *    derived from this software withough specific prior written permission
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 *	$Id: ibcs2_isc.c,v 1.2 1995/02/03 21:31:32 bde Exp $
 */

#include <i386/ibcs2/ibcs2.h>
#include <sys/param.h>
#include <sys/proc.h>
#include <sys/sysent.h>
#include <sys/errno.h>
#include <sys/ioctl.h>
#include <sys/signal.h>
#include <sys/syslimits.h>
#include <sys/timeb.h>
#include <sys/unistd.h>
#include <sys/utsname.h>
#include <machine/cpu.h>
#include <machine/psl.h>
#include <machine/reg.h>

int
ibcs2_cisc(struct proc *p, void *args, int *retval)
{
	struct trapframe *tf = (struct trapframe *)p->p_md.md_regs;
	
	switch ((tf->tf_eax & 0xffffff00) >> 8) {

	case 0x00:
		printf("IBCS2: 'cisc #0' what is this ??\n");
		return 0;

	case 0x02:
		if (ibcs2_trace & IBCS2_TRACE_ISC)
			printf("IBCS2: 'cisc rename'\n");
	      	return rename(p, args, retval);

	case 0x03:
		if (ibcs2_trace & IBCS2_TRACE_ISC)
			printf("IBCS2: 'cisc sigaction'\n");
	      	return ibcs2_sigaction(p, args, retval);

	case 0x04:
		if (ibcs2_trace & IBCS2_TRACE_ISC)
			printf("IBCS2: 'cisc sigprocmask'\n");
	      	return ibcs2_sigprocmask(p, args, retval);

	case 0x05:
		if (ibcs2_trace & IBCS2_TRACE_ISC)
			printf("IBCS2: 'cisc sigpending'\n");
	      	return ibcs2_sigpending(p, args, retval);

	case 0x06:
		if (ibcs2_trace & IBCS2_TRACE_ISC)
			printf("IBCS2: 'cisc getgroups'\n");
	      	return getgroups(p, args, retval);

	case 0x07:
		if (ibcs2_trace & IBCS2_TRACE_ISC)
			printf("IBCS2: 'cisc setgroups'\n");
	      	return setgroups(p, args, retval);

	case 0x08:	/* pathconf */
	case 0x09:	/* fpathconf */
		if (ibcs2_trace & IBCS2_TRACE_ISC) 
			printf("IBCS2: 'cisc (f)pathconf'"); 
	      	return ibcs2_pathconf(p, args, retval);

	case 0x10: {	/* sysconf */
	    	struct ibcs2_sysconf_args {
	      		int num;
	    	} *sysconf_args = args;

		if (ibcs2_trace & IBCS2_TRACE_ISC) 
			printf("IBCS2: 'cisc sysconf'"); 
		switch (sysconf_args->num) {
		case 0: 	/* _SC_ARG_MAX */
			*retval = (ARG_MAX);
			break;
		case 1:		/* _SC_CHILD_MAX */
			*retval = (CHILD_MAX); 
			break;
		case 2:		/* _SC_CLK_TCK */
			*retval = (_BSD_CLK_TCK_);
			break;
		case 3:		/* _SC_NGROUPS_MAX */
			*retval = (NGROUPS_MAX);
			break;
		case 4:		/* _SC_OPEN_MAX */
			*retval = (OPEN_MAX);
			break;
		case 5:		/* _SC_JOB_CONTROL */
#ifdef _POSIX_JOB_CONTROL
			*retval = (1);
#else
			*retval = (-1);
#endif
			break;
		case 6:		/* _SC_SAVED_IDS */
#ifdef _POSIX_SAVED_IDS
			*retval = (1);
#else
			*retval = (-1);
#endif
			break;
		case 7:		/* _SC_VERSION */
			*retval = (_POSIX_VERSION);
			break;
		default:
			*retval = -1;
	      		return EINVAL;
		}
	      	return 0;
	}

	case 0x0b:
		if (ibcs2_trace & IBCS2_TRACE_ISC)
			printf("IBCS2: 'cisc waitpid'\n");
	      	return ibcs2_wait(p, args, retval);

	case 0x0c:
		if (ibcs2_trace & IBCS2_TRACE_ISC)
			printf("IBCS2: 'cisc setsid'\n");
	      	return setsid(p, args, retval);

	case 0x0d:
		if (ibcs2_trace & IBCS2_TRACE_ISC)
			printf("IBCS2: 'cisc setpgid'\n");
	      	return setpgid(p, args, retval);

	case 0x11:
		if (ibcs2_trace & IBCS2_TRACE_ISC)
			printf("IBCS2: 'cisc sigsuspend'\n");
	      	return ibcs2_sigsuspend(p, args, retval);

	case 0x12:
		if (ibcs2_trace & IBCS2_TRACE_ISC)
			printf("IBCS2: 'cisc symlink'\n");
	      	return symlink(p, args, retval);

	case 0x13:
		if (ibcs2_trace & IBCS2_TRACE_ISC)
			printf("IBCS2: 'cisc readlink'\n");
	      	return readlink(p, args, retval);

	/* Here needs more work to be done */
	case 0x01:
		printf("IBCS2: 'cisc setostype'");
		break;
	case 0x0e:
		printf("IBCS2: 'cisc adduser'");
		break;
	case 0x0f:
		printf("IBCS2: 'cisc setuser'");
		break;
	case 0x14:
		printf("IBCS2: 'cisc getmajor'");
		break;
	default:
		printf("IBCS2: 'cisc' function %d(0x%x)", 
			tf->tf_eax>>8, tf->tf_eax>>8);
		break;
	}
	printf(" not implemented yet\n");
	return EINVAL;
}