riched32: Skeleton of richedit 1.0 test plus WM_SETTEXT test.
[wine] / server / context_i386.c
1 /*
2  * i386 register context support
3  *
4  * Copyright (C) 1999 Alexandre Julliard
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19  */
20
21 #include "config.h"
22
23 #ifdef __i386__
24
25 #include <assert.h>
26 #include <errno.h>
27 #include <stdarg.h>
28 #include <unistd.h>
29
30 #include "windef.h"
31
32 #include "file.h"
33 #include "thread.h"
34 #include "request.h"
35
36 /* copy a context structure according to the flags */
37 void copy_context( CONTEXT *to, const CONTEXT *from, unsigned int flags )
38 {
39     flags &= ~CONTEXT_i386;  /* get rid of CPU id */
40     if (flags & CONTEXT_CONTROL)
41     {
42         to->Ebp    = from->Ebp;
43         to->Eip    = from->Eip;
44         to->Esp    = from->Esp;
45         to->SegCs  = from->SegCs;
46         to->SegSs  = from->SegSs;
47         to->EFlags = from->EFlags;
48     }
49     if (flags & CONTEXT_INTEGER)
50     {
51         to->Eax = from->Eax;
52         to->Ebx = from->Ebx;
53         to->Ecx = from->Ecx;
54         to->Edx = from->Edx;
55         to->Esi = from->Esi;
56         to->Edi = from->Edi;
57     }
58     if (flags & CONTEXT_SEGMENTS)
59     {
60         to->SegDs = from->SegDs;
61         to->SegEs = from->SegEs;
62         to->SegFs = from->SegFs;
63         to->SegGs = from->SegGs;
64     }
65     if (flags & CONTEXT_FLOATING_POINT)
66     {
67         to->FloatSave = from->FloatSave;
68     }
69     if (flags & CONTEXT_DEBUG_REGISTERS)
70     {
71         to->Dr0 = from->Dr0;
72         to->Dr1 = from->Dr1;
73         to->Dr2 = from->Dr2;
74         to->Dr3 = from->Dr3;
75         to->Dr6 = from->Dr6;
76         to->Dr7 = from->Dr7;
77     }
78     to->ContextFlags |= flags;
79 }
80
81 /* retrieve the current instruction pointer of a context */
82 void *get_context_ip( const CONTEXT *context )
83 {
84     return (void *)context->Eip;
85 }
86
87 /* return the context flag that contains the CPU id */
88 unsigned int get_context_cpu_flag(void)
89 {
90     return CONTEXT_i386;
91 }
92
93 /* return only the context flags that correspond to system regs */
94 /* (system regs are the ones we can't access on the client side) */
95 unsigned int get_context_system_regs( unsigned int flags )
96 {
97     return flags & (CONTEXT_DEBUG_REGISTERS & ~CONTEXT_i386);
98 }
99
100 #endif  /* __i386__ */