From 7a2bb3b800667397d41ad7324c4d8f2911fb8ebb Mon Sep 17 00:00:00 2001 From: Luoqi Chen Date: Thu, 2 Sep 1999 20:59:50 +0000 Subject: [PATCH] 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 --- sys/amd64/amd64/sys_machdep.c | 41 +++++++++-------------------------- sys/amd64/include/sysarch.h | 17 +++++++++++++++ sys/i386/i386/sys_machdep.c | 41 +++++++++-------------------------- sys/i386/i386/vm86.c | 1 + sys/i386/include/sysarch.h | 17 +++++++++++++++ sys/i386/include/vm86.h | 5 ----- 6 files changed, 55 insertions(+), 67 deletions(-) diff --git a/sys/amd64/amd64/sys_machdep.c b/sys/amd64/amd64/sys_machdep.c index 0f5930ca7a0..54f63ca0f7d 100644 --- a/sys/amd64/amd64/sys_machdep.c +++ b/sys/amd64/amd64/sys_machdep.c @@ -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) diff --git a/sys/amd64/include/sysarch.h b/sys/amd64/include/sysarch.h index 009c7810259..5ea3ee6e887 100644 --- a/sys/amd64/include/sysarch.h +++ b/sys/amd64/include/sysarch.h @@ -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 diff --git a/sys/i386/i386/sys_machdep.c b/sys/i386/i386/sys_machdep.c index 0f5930ca7a0..54f63ca0f7d 100644 --- a/sys/i386/i386/sys_machdep.c +++ b/sys/i386/i386/sys_machdep.c @@ -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) diff --git a/sys/i386/i386/vm86.c b/sys/i386/i386/vm86.c index b50b6f18d57..c041d3b8e07 100644 --- a/sys/i386/i386/vm86.c +++ b/sys/i386/i386/vm86.c @@ -46,6 +46,7 @@ #include /* pcb.h included via sys/user.h */ #include #include +#include extern int i386_extend_pcb __P((struct proc *)); extern int vm86pa; diff --git a/sys/i386/include/sysarch.h b/sys/i386/include/sysarch.h index 009c7810259..5ea3ee6e887 100644 --- a/sys/i386/include/sysarch.h +++ b/sys/i386/include/sysarch.h @@ -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 diff --git a/sys/i386/include/vm86.h b/sys/i386/include/vm86.h index 1231bb20a77..60c56154a6e 100644 --- a/sys/i386/include/vm86.h +++ b/sys/i386/include/vm86.h @@ -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