x86: clean up arch/x86/ia32/fpu32.c
White space and coding style clenaup. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Ingo Molnar <mingo@elte.hu>
This commit is contained in:
parent
7b11fb5156
commit
d94448b1fd
1 changed files with 67 additions and 67 deletions
|
@ -24,73 +24,73 @@ static inline unsigned short twd_i387_to_fxsr(unsigned short twd)
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define FPREG_ADDR(f, n) ((void *)&(f)->st_space + (n) * 16);
|
||||||
|
#define FP_EXP_TAG_VALID 0
|
||||||
|
#define FP_EXP_TAG_ZERO 1
|
||||||
|
#define FP_EXP_TAG_SPECIAL 2
|
||||||
|
#define FP_EXP_TAG_EMPTY 3
|
||||||
|
|
||||||
static inline unsigned long twd_fxsr_to_i387(struct i387_fxsave_struct *fxsave)
|
static inline unsigned long twd_fxsr_to_i387(struct i387_fxsave_struct *fxsave)
|
||||||
{
|
{
|
||||||
struct _fpxreg *st = NULL;
|
struct _fpxreg *st;
|
||||||
unsigned long tos = (fxsave->swd >> 11) & 7;
|
unsigned long tos = (fxsave->swd >> 11) & 7;
|
||||||
unsigned long twd = (unsigned long) fxsave->twd;
|
unsigned long twd = (unsigned long) fxsave->twd;
|
||||||
unsigned long tag;
|
unsigned long tag;
|
||||||
unsigned long ret = 0xffff0000;
|
unsigned long ret = 0xffff0000;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
#define FPREG_ADDR(f, n) ((void *)&(f)->st_space + (n) * 16);
|
for (i = 0; i < 8; i++, twd >>= 1) {
|
||||||
|
|
||||||
for (i = 0 ; i < 8 ; i++) {
|
|
||||||
if (twd & 0x1) {
|
if (twd & 0x1) {
|
||||||
st = FPREG_ADDR(fxsave, (i - tos) & 7);
|
st = FPREG_ADDR(fxsave, (i - tos) & 7);
|
||||||
|
|
||||||
switch (st->exponent & 0x7fff) {
|
switch (st->exponent & 0x7fff) {
|
||||||
case 0x7fff:
|
case 0x7fff:
|
||||||
tag = 2; /* Special */
|
tag = FP_EXP_TAG_SPECIAL;
|
||||||
break;
|
break;
|
||||||
case 0x0000:
|
case 0x0000:
|
||||||
if (!st->significand[0] &&
|
if (!st->significand[0] &&
|
||||||
!st->significand[1] &&
|
!st->significand[1] &&
|
||||||
!st->significand[2] &&
|
!st->significand[2] &&
|
||||||
!st->significand[3] ) {
|
!st->significand[3])
|
||||||
tag = 1; /* Zero */
|
tag = FP_EXP_TAG_ZERO;
|
||||||
} else {
|
else
|
||||||
tag = 2; /* Special */
|
tag = FP_EXP_TAG_SPECIAL;
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (st->significand[3] & 0x8000) {
|
if (st->significand[3] & 0x8000)
|
||||||
tag = 0; /* Valid */
|
tag = FP_EXP_TAG_VALID;
|
||||||
} else {
|
else
|
||||||
tag = 2; /* Special */
|
tag = FP_EXP_TAG_SPECIAL;
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
tag = 3; /* Empty */
|
tag = FP_EXP_TAG_EMPTY;
|
||||||
}
|
}
|
||||||
ret |= (tag << (2 * i));
|
ret |= tag << (2 * i);
|
||||||
twd = twd >> 1;
|
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define G(num, val) err |= __get_user(val, num + (u32 __user *)buf)
|
||||||
|
|
||||||
static inline int convert_fxsr_from_user(struct i387_fxsave_struct *fxsave,
|
static inline int convert_fxsr_from_user(struct i387_fxsave_struct *fxsave,
|
||||||
struct _fpstate_ia32 __user *buf)
|
struct _fpstate_ia32 __user *buf)
|
||||||
{
|
{
|
||||||
struct _fpxreg *to;
|
struct _fpxreg *to;
|
||||||
struct _fpreg __user *from;
|
struct _fpreg __user *from;
|
||||||
int i;
|
int i, err = 0;
|
||||||
u32 v;
|
u32 v;
|
||||||
int err = 0;
|
|
||||||
|
|
||||||
#define G(num,val) err |= __get_user(val, num + (u32 __user *)buf)
|
|
||||||
G(0, fxsave->cwd);
|
G(0, fxsave->cwd);
|
||||||
G(1, fxsave->swd);
|
G(1, fxsave->swd);
|
||||||
G(2, fxsave->twd);
|
G(2, fxsave->twd);
|
||||||
fxsave->twd = twd_i387_to_fxsr(fxsave->twd);
|
fxsave->twd = twd_i387_to_fxsr(fxsave->twd);
|
||||||
G(3, fxsave->rip);
|
G(3, fxsave->rip);
|
||||||
G(4, v);
|
G(4, v);
|
||||||
fxsave->fop = v>>16; /* cs ignored */
|
/* cs ignored */
|
||||||
|
fxsave->fop = v>>16;
|
||||||
G(5, fxsave->rdp);
|
G(5, fxsave->rdp);
|
||||||
/* 6: ds ignored */
|
/* 6: ds ignored */
|
||||||
#undef G
|
|
||||||
if (err)
|
if (err)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
@ -103,6 +103,7 @@ static inline int convert_fxsr_from_user(struct i387_fxsave_struct *fxsave,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define P(num, val) err |= __put_user(val, num + (u32 __user *)buf)
|
||||||
|
|
||||||
static inline int convert_fxsr_to_user(struct _fpstate_ia32 __user *buf,
|
static inline int convert_fxsr_to_user(struct _fpstate_ia32 __user *buf,
|
||||||
struct i387_fxsave_struct *fxsave,
|
struct i387_fxsave_struct *fxsave,
|
||||||
|
@ -111,21 +112,22 @@ static inline int convert_fxsr_to_user(struct _fpstate_ia32 __user *buf,
|
||||||
{
|
{
|
||||||
struct _fpreg __user *to;
|
struct _fpreg __user *to;
|
||||||
struct _fpxreg *from;
|
struct _fpxreg *from;
|
||||||
int i;
|
int i, err = 0;
|
||||||
u16 cs, ds;
|
u16 cs, ds;
|
||||||
int err = 0;
|
|
||||||
|
|
||||||
if (tsk == current) {
|
if (tsk == current) {
|
||||||
/* should be actually ds/cs at fpu exception time,
|
/*
|
||||||
but that information is not available in 64bit mode. */
|
* should be actually ds/cs at fpu exception time, but
|
||||||
|
* that information is not available in 64bit mode.
|
||||||
|
*/
|
||||||
asm("movw %%ds,%0 " : "=r" (ds));
|
asm("movw %%ds,%0 " : "=r" (ds));
|
||||||
asm("movw %%cs,%0 " : "=r" (cs));
|
asm("movw %%cs,%0 " : "=r" (cs));
|
||||||
} else { /* ptrace. task has stopped. */
|
} else {
|
||||||
|
/* ptrace. task has stopped. */
|
||||||
ds = tsk->thread.ds;
|
ds = tsk->thread.ds;
|
||||||
cs = regs->cs;
|
cs = regs->cs;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define P(num,val) err |= __put_user(val, num + (u32 __user *)buf)
|
|
||||||
P(0, (u32)fxsave->cwd | 0xffff0000);
|
P(0, (u32)fxsave->cwd | 0xffff0000);
|
||||||
P(1, (u32)fxsave->swd | 0xffff0000);
|
P(1, (u32)fxsave->swd | 0xffff0000);
|
||||||
P(2, twd_fxsr_to_i387(fxsave));
|
P(2, twd_fxsr_to_i387(fxsave));
|
||||||
|
@ -133,7 +135,6 @@ static inline int convert_fxsr_to_user(struct _fpstate_ia32 __user *buf,
|
||||||
P(4, cs | ((u32)fxsave->fop) << 16);
|
P(4, cs | ((u32)fxsave->fop) << 16);
|
||||||
P(5, fxsave->rdp);
|
P(5, fxsave->rdp);
|
||||||
P(6, 0xffff0000 | ds);
|
P(6, 0xffff0000 | ds);
|
||||||
#undef P
|
|
||||||
|
|
||||||
if (err)
|
if (err)
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -147,7 +148,8 @@ static inline int convert_fxsr_to_user(struct _fpstate_ia32 __user *buf,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int restore_i387_ia32(struct task_struct *tsk, struct _fpstate_ia32 __user *buf, int fsave)
|
int restore_i387_ia32(struct task_struct *tsk,
|
||||||
|
struct _fpstate_ia32 __user *buf, int fsave)
|
||||||
{
|
{
|
||||||
clear_fpu(tsk);
|
clear_fpu(tsk);
|
||||||
if (!fsave) {
|
if (!fsave) {
|
||||||
|
@ -161,10 +163,8 @@ int restore_i387_ia32(struct task_struct *tsk, struct _fpstate_ia32 __user *buf,
|
||||||
return convert_fxsr_from_user(&tsk->thread.i387.fxsave, buf);
|
return convert_fxsr_from_user(&tsk->thread.i387.fxsave, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
int save_i387_ia32(struct task_struct *tsk,
|
int save_i387_ia32(struct task_struct *tsk, struct _fpstate_ia32 __user *buf,
|
||||||
struct _fpstate_ia32 __user *buf,
|
struct pt_regs *regs, int fsave)
|
||||||
struct pt_regs *regs,
|
|
||||||
int fsave)
|
|
||||||
{
|
{
|
||||||
int err = 0;
|
int err = 0;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue