Some reorganization of sysarch() interface:

1. Move definitions of struct i386_*_args to the header file sysarch.h,
   since they are part of the sysarch API. struct i386_get_ldt_args and
   i386_set_ldt_args were identical, therefore make them into one
   struct i386_ldt_args. Libc should use these definitions as well.
2. Return a more sensible EOPNOTSUPP for unknown operations.

Reviewed by:	marcel
This commit is contained in:
Luoqi Chen 1999-09-02 20:59:50 +00:00
parent 4f2571dd77
commit 7a2bb3b800
6 changed files with 55 additions and 67 deletions

View File

@ -108,7 +108,7 @@ sysarch(p, uap)
error = vm86_sysarch(p, uap->parms);
break;
default:
error = EINVAL;
error = EOPNOTSUPP;
break;
}
return (error);
@ -163,12 +163,6 @@ i386_extend_pcb(struct proc *p)
return 0;
}
struct i386_ioperm_args {
u_int start;
u_int length;
int enable;
};
static int
i386_set_ioperm(p, args)
struct proc *p;
@ -265,12 +259,6 @@ set_user_ldt(struct pcb *pcb)
currentldt = GSEL(GUSERLDT_SEL, SEL_KPL);
}
struct i386_get_ldt_args {
int start;
union descriptor *desc;
int num;
};
static int
i386_get_ldt(p, args)
struct proc *p;
@ -281,15 +269,14 @@ i386_get_ldt(p, args)
int nldt, num;
union descriptor *lp;
int s;
struct i386_get_ldt_args ua;
struct i386_get_ldt_args *uap = &ua;
struct i386_ldt_args ua, *uap = &ua;
if ((error = copyin(args, uap, sizeof(struct i386_get_ldt_args))) < 0)
if ((error = copyin(args, uap, sizeof(struct i386_ldt_args))) < 0)
return(error);
#ifdef DEBUG
printf("i386_get_ldt: start=%d num=%d descs=%p\n",
uap->start, uap->num, (void *)uap->desc);
uap->start, uap->num, (void *)uap->descs);
#endif
/* verify range of LDTs exist */
@ -312,7 +299,7 @@ i386_get_ldt(p, args)
return(EINVAL);
}
error = copyout(lp, uap->desc, num * sizeof(union descriptor));
error = copyout(lp, uap->descs, num * sizeof(union descriptor));
if (!error)
p->p_retval[0] = num;
@ -320,12 +307,6 @@ i386_get_ldt(p, args)
return(error);
}
struct i386_set_ldt_args {
int start;
union descriptor *desc;
int num;
};
static int
i386_set_ldt(p, args)
struct proc *p;
@ -335,16 +316,14 @@ i386_set_ldt(p, args)
int largest_ld;
struct pcb *pcb = &p->p_addr->u_pcb;
int s;
struct i386_set_ldt_args ua, *uap;
struct i386_ldt_args ua, *uap = &ua;
if ((error = copyin(args, &ua, sizeof(struct i386_set_ldt_args))) < 0)
if ((error = copyin(args, uap, sizeof(struct i386_ldt_args))) < 0)
return(error);
uap = &ua;
#ifdef DEBUG
printf("i386_set_ldt: start=%d num=%d descs=%p\n",
uap->start, uap->num, (void *)uap->desc);
uap->start, uap->num, (void *)uap->descs);
#endif
/* verify range of descriptors to modify */
@ -381,7 +360,7 @@ i386_set_ldt(p, args)
/* Check descriptors for access violations */
for (i = 0, n = uap->start; i < uap->num; i++, n++) {
union descriptor desc, *dp;
dp = &uap->desc[i];
dp = &uap->descs[i];
error = copyin(dp, &desc, sizeof(union descriptor));
if (error)
return(error);
@ -446,7 +425,7 @@ i386_set_ldt(p, args)
s = splhigh();
/* Fill in range */
error = copyin(uap->desc,
error = copyin(uap->descs,
&((union descriptor *)(pcb->pcb_ldt))[uap->start],
uap->num * sizeof(union descriptor));
if (!error)

View File

@ -47,6 +47,23 @@
/* xxxxx */
#define I386_VM86 6
struct i386_ldt_args {
int start;
union descriptor *descs;
int num;
};
struct i386_ioperm_args {
unsigned int start;
unsigned int length;
int enable;
};
struct i386_vm86_args {
int sub_op; /* sub-operation to perform */
char *sub_args; /* args */
};
#ifndef KERNEL
#include <sys/cdefs.h>

View File

@ -108,7 +108,7 @@ sysarch(p, uap)
error = vm86_sysarch(p, uap->parms);
break;
default:
error = EINVAL;
error = EOPNOTSUPP;
break;
}
return (error);
@ -163,12 +163,6 @@ i386_extend_pcb(struct proc *p)
return 0;
}
struct i386_ioperm_args {
u_int start;
u_int length;
int enable;
};
static int
i386_set_ioperm(p, args)
struct proc *p;
@ -265,12 +259,6 @@ set_user_ldt(struct pcb *pcb)
currentldt = GSEL(GUSERLDT_SEL, SEL_KPL);
}
struct i386_get_ldt_args {
int start;
union descriptor *desc;
int num;
};
static int
i386_get_ldt(p, args)
struct proc *p;
@ -281,15 +269,14 @@ i386_get_ldt(p, args)
int nldt, num;
union descriptor *lp;
int s;
struct i386_get_ldt_args ua;
struct i386_get_ldt_args *uap = &ua;
struct i386_ldt_args ua, *uap = &ua;
if ((error = copyin(args, uap, sizeof(struct i386_get_ldt_args))) < 0)
if ((error = copyin(args, uap, sizeof(struct i386_ldt_args))) < 0)
return(error);
#ifdef DEBUG
printf("i386_get_ldt: start=%d num=%d descs=%p\n",
uap->start, uap->num, (void *)uap->desc);
uap->start, uap->num, (void *)uap->descs);
#endif
/* verify range of LDTs exist */
@ -312,7 +299,7 @@ i386_get_ldt(p, args)
return(EINVAL);
}
error = copyout(lp, uap->desc, num * sizeof(union descriptor));
error = copyout(lp, uap->descs, num * sizeof(union descriptor));
if (!error)
p->p_retval[0] = num;
@ -320,12 +307,6 @@ i386_get_ldt(p, args)
return(error);
}
struct i386_set_ldt_args {
int start;
union descriptor *desc;
int num;
};
static int
i386_set_ldt(p, args)
struct proc *p;
@ -335,16 +316,14 @@ i386_set_ldt(p, args)
int largest_ld;
struct pcb *pcb = &p->p_addr->u_pcb;
int s;
struct i386_set_ldt_args ua, *uap;
struct i386_ldt_args ua, *uap = &ua;
if ((error = copyin(args, &ua, sizeof(struct i386_set_ldt_args))) < 0)
if ((error = copyin(args, uap, sizeof(struct i386_ldt_args))) < 0)
return(error);
uap = &ua;
#ifdef DEBUG
printf("i386_set_ldt: start=%d num=%d descs=%p\n",
uap->start, uap->num, (void *)uap->desc);
uap->start, uap->num, (void *)uap->descs);
#endif
/* verify range of descriptors to modify */
@ -381,7 +360,7 @@ i386_set_ldt(p, args)
/* Check descriptors for access violations */
for (i = 0, n = uap->start; i < uap->num; i++, n++) {
union descriptor desc, *dp;
dp = &uap->desc[i];
dp = &uap->descs[i];
error = copyin(dp, &desc, sizeof(union descriptor));
if (error)
return(error);
@ -446,7 +425,7 @@ i386_set_ldt(p, args)
s = splhigh();
/* Fill in range */
error = copyin(uap->desc,
error = copyin(uap->descs,
&((union descriptor *)(pcb->pcb_ldt))[uap->start],
uap->num * sizeof(union descriptor));
if (!error)

View File

@ -46,6 +46,7 @@
#include <machine/pcb_ext.h> /* pcb.h included via sys/user.h */
#include <machine/psl.h>
#include <machine/specialreg.h>
#include <machine/sysarch.h>
extern int i386_extend_pcb __P((struct proc *));
extern int vm86pa;

View File

@ -47,6 +47,23 @@
/* xxxxx */
#define I386_VM86 6
struct i386_ldt_args {
int start;
union descriptor *descs;
int num;
};
struct i386_ioperm_args {
unsigned int start;
unsigned int length;
int enable;
};
struct i386_vm86_args {
int sub_op; /* sub-operation to perform */
char *sub_args; /* args */
};
#ifndef KERNEL
#include <sys/cdefs.h>

View File

@ -124,11 +124,6 @@ struct vm86_kernel {
caddr_t vm86_sproc; /* address of sproc */
};
struct i386_vm86_args {
int sub_op; /* sub-operation to perform */
char *sub_args; /* args */
};
#define VM86_INIT 1
#define VM86_SET_VME 2
#define VM86_GET_VME 3