OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [hal/] [i386/] [arch/] [current/] [include/] [i386_stub.h] - Blame information for rev 786

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
#ifndef CYGONCE_HAL_I386_STUB_H
2
#define CYGONCE_HAL_I386_STUB_H
3
//==========================================================================
4
//
5
//      i386_stub.h
6
//
7
//      i386/PC GDB stub support
8
//
9
//==========================================================================
10
// ####ECOSGPLCOPYRIGHTBEGIN####                                            
11
// -------------------------------------------                              
12
// This file is part of eCos, the Embedded Configurable Operating System.   
13
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
14
//
15
// eCos is free software; you can redistribute it and/or modify it under    
16
// the terms of the GNU General Public License as published by the Free     
17
// Software Foundation; either version 2 or (at your option) any later      
18
// version.                                                                 
19
//
20
// eCos is distributed in the hope that it will be useful, but WITHOUT      
21
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or    
22
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License    
23
// for more details.                                                        
24
//
25
// You should have received a copy of the GNU General Public License        
26
// along with eCos; if not, write to the Free Software Foundation, Inc.,    
27
// 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.            
28
//
29
// As a special exception, if other files instantiate templates or use      
30
// macros or inline functions from this file, or you compile this file      
31
// and link it with other works to produce a work based on this file,       
32
// this file does not by itself cause the resulting work to be covered by   
33
// the GNU General Public License. However the source code for this file    
34
// must still be made available in accordance with section (3) of the GNU   
35
// General Public License v2.                                               
36
//
37
// This exception does not invalidate any other reasons why a work based    
38
// on this file might be covered by the GNU General Public License.         
39
// -------------------------------------------                              
40
// ####ECOSGPLCOPYRIGHTEND####                                              
41
//==========================================================================
42
//#####DESCRIPTIONBEGIN####
43
//
44
// Author(s):    pjo
45
// Contributors: pjo, nickg
46
// Date:         1999-10-15
47
// Purpose:      i386/PC GDB stub support
48
// Description:  Definitions for the GDB stubs. Most of this comes from
49
//               the original libstub code.
50
//              
51
// Usage:
52
//               #include <cyg/hal/plf_intr.h>
53
//               ...
54
//
55
//####DESCRIPTIONEND####
56
//
57
//==========================================================================
58
 
59
 
60
#ifndef CYGHWR_HAL_I386_FPU
61
#define NUMREGS     16
62
#else
63
#ifdef CYGHWR_HAL_I386_PENTIUM_SSE
64
#define NUMREGS     41
65
#else
66
#define NUMREGS     32
67
#endif
68
#endif
69
 
70
// Size of a given register.
71
#define REGSIZE(X)  (((X) >= REG_FST0  && (X) <= REG_FST7) ? 10 :              \
72
                    (((X) >= REG_MMX0  && (X) <= REG_MMX7) ? 10 :              \
73
                    (((X) == REG_GDT || (X) == REG_IDT) ? 6 :                  \
74
                    (((X) == REG_MSR || (X) == REG_LDT || (X) == REG_TR) ? 8 : \
75
                    (((X) >= REG_XMM0  && (X) <= REG_XMM7) ? 16 : 4)))))
76
 
77
enum regnames
78
{
79
    // General regs (0 - 15)
80
    EAX, ECX, EDX, EBX, ESP, EBP, ESI, EDI,
81
    PC /* also known as eip */,
82
    PS /* also known as eflags */,
83
    CS, SS, DS, ES, FS, GS,
84
 
85
    // FPU regs. (16 - 31)
86
    REG_FST0, REG_FST1, REG_FST2, REG_FST3,
87
    REG_FST4, REG_FST5, REG_FST6, REG_FST7,
88
    REG_FCTRL, REG_FSTAT, REG_FTAG,
89
    REG_FISEG, REG_FIOFF,
90
    REG_FOSEG, REG_FOOFF,
91
    REG_FOP,
92
 
93
    // SSE regs (32 - 40)
94
    REG_XMM0, REG_XMM1, REG_XMM2, REG_XMM3,
95
    REG_XMM4, REG_XMM5, REG_XMM6, REG_XMM7,
96
    REG_MXCSR,
97
 
98
    // Registers below this point are _not_ part of the g/G packet
99
    // so they play no part in defining NUMREGS. GDB accesses these
100
    // individually with p/P packets.
101
 
102
    // MMX regs (41 - 48)
103
    // These are here as placeholders for register numbering purposes.
104
    // GDB never asks for these directly as their values are stored
105
    // in FSTn registers.
106
    REG_MMX0, REG_MMX1, REG_MMX2, REG_MMX3,
107
    REG_MMX4, REG_MMX5, REG_MMX6, REG_MMX7,
108
 
109
    // Misc pentium regs (49 - 56)
110
    REG_CR0, REG_CR2, REG_CR3, REG_CR4,
111
    REG_GDT, REG_IDT, REG_LDT, REG_TR,
112
 
113
    // Pseudo reg used by gdb to access other regs (57)
114
    REG_MSR
115
};
116
 
117
typedef enum regnames regnames_t ;
118
typedef unsigned long target_register_t ;
119
 
120
typedef struct
121
{
122
    target_register_t eax;
123
    target_register_t ecx;
124
    target_register_t edx;
125
    target_register_t ebx;
126
    target_register_t esp;
127
    target_register_t ebp;
128
    target_register_t esi;
129
    target_register_t edi;
130
    target_register_t pc;
131
    target_register_t ps;
132
    target_register_t cs;
133
    target_register_t ss;
134
    target_register_t ds;
135
    target_register_t es;
136
    target_register_t fs;
137
    target_register_t gs;
138
#ifdef CYGHWR_HAL_I386_FPU
139
    target_register_t fcw;
140
    target_register_t fsw;
141
    target_register_t ftw;
142
    target_register_t ipoff;
143
    target_register_t cssel;
144
    target_register_t dataoff;
145
    target_register_t opsel;
146
    unsigned char     st0[10];
147
    unsigned char     st1[10];
148
    unsigned char     st2[10];
149
    unsigned char     st3[10];
150
    unsigned char     st4[10];
151
    unsigned char     st5[10];
152
    unsigned char     st6[10];
153
    unsigned char     st7[10];
154
#endif
155
#ifdef CYGHWR_HAL_I386_PENTIUM_SSE
156
    unsigned char     xmm0[16];
157
    unsigned char     xmm1[16];
158
    unsigned char     xmm2[16];
159
    unsigned char     xmm3[16];
160
    unsigned char     xmm4[16];
161
    unsigned char     xmm5[16];
162
    unsigned char     xmm6[16];
163
    unsigned char     xmm7[16];
164
    target_register_t mxcsr;
165
#endif
166
#ifdef CYGHWR_HAL_I386_PENTIUM_GDB_REGS
167
    target_register_t cr0;
168
    target_register_t cr2;
169
    target_register_t cr3;
170
    target_register_t cr4;
171
 
172
    unsigned char     gdtr[6];
173
    unsigned char     idtr[6];
174
    target_register_t ldt;
175
    target_register_t tr;
176
#endif
177
} GDB_SavedRegisters;
178
 
179
#define HAL_STUB_REGISTERS_SIZE \
180
 ((sizeof(GDB_SavedRegisters) + sizeof(target_register_t) - 1) / sizeof(target_register_t))
181
 
182
#define PS_C                    0x00000001
183
#define PS_Z                    0x00000040
184
#define PS_V                    0x00000080
185
#define PS_T                    0x00000100
186
 
187
#define SP                      (ESP)
188
#define EIP                     (PC)
189
 
190
// We have to rewind the PC only in case of a breakpoint
191
// set by a user interrupt (ie: a Ctrl-C)
192
 
193
// There should be another way to do it
194
 
195
#ifdef CYGDBG_HAL_DEBUG_GDB_BREAK_SUPPORT
196
#define HAL_STUB_PLATFORM_STUBS_FIXUP()                         \
197
    CYG_MACRO_START                                             \
198
    if (break_buffer.targetAddr==get_register(PC)-1)            \
199
        put_register(PC, get_register(PC) - 1);                 \
200
    CYG_MACRO_END
201
#endif //CYGDBG_HAL_DEBUG_GDB_BREAK_SUPPORT
202
 
203
// I386 stub has special needs for register handling, so special
204
// put_register and get_register are provided.
205
#define CYGARC_STUB_REGISTER_ACCESS_DEFINED 1
206
 
207
// The x86 has float (and other) registers that are larger than it can
208
// hold in a target_register_t.
209
#define TARGET_HAS_LARGE_REGISTERS
210
 
211
#ifdef CYGHWR_HAL_I386_PENTIUM_GDB_REGS
212
// Handle arch-specific query packets.
213
extern int cyg_hal_stub_process_query (char *p, char *b, int n);
214
#define CYG_HAL_STUB_PROCESS_QUERY(__pkt__, __buf__, __bufsz__) \
215
  cyg_hal_stub_process_query ((__pkt__), (__buf__), (__bufsz__))
216
 
217
// These masks are used to protect the user from writing to reserved bits
218
// of the control registers.
219
#define REG_CR4_MASK    0x000007FF
220
#define REG_CR3_MASK    0xFFFFF018
221
#define REG_CR2_MASK    0xFFFFFFFF
222
#define REG_CR0_MASK    0xE005003F
223
#endif
224
 
225
/* Find out what our last trap was. */
226
extern int __get_trap_number(void) ;
227
 
228
/* Given a trap number, compute the signal code for it. */
229
extern int __computeSignal(unsigned int trap_number) ;
230
 
231
/* Enable single stepping after the next user resume instruction. */
232
extern void __single_step(void) ;
233
extern void __clear_single_step(void) ;
234
 
235
extern void __install_breakpoints(void) ;
236
extern void __clear_breakpoints(void) ;
237
 
238
 
239
//---------------------------------------------------------------------------
240
#endif /* CYGONCE_HAL_I386_STUB_H */
241
// End of i386_stub.h

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.