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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [gdb/] [nlm/] [i386.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
#include <dfs.h>
2
#include <stdio.h>
3
#include <string.h>
4
#include <stdlib.h>
5
#include <ctype.h>
6
#include <time.h>
7
#include <conio.h>
8
#include <advanced.h>
9
#include <debugapi.h>
10
#include <process.h>
11
#include <errno.h>
12
#include "i386.h"
13
 
14
extern char *mem2hex (void *mem, char *buf, int count, int may_fault);
15
extern char *hex2mem (char *buf, void *mem, int count, int may_fault);
16
extern int computeSignal (int exceptionVector);
17
 
18
void
19
flush_i_cache (void)
20
{
21
}
22
 
23
/* Get the registers out of the frame information.  */
24
 
25
void
26
frame_to_registers (struct StackFrame *frame, char *regs)
27
{
28
  /* Copy EAX -> EDI */
29
  mem2hex (&frame->ExceptionEAX, &regs[0 * 4 * 2], 4 * 8, 0);
30
 
31
  /* Copy EIP & PS */
32
  mem2hex (&frame->ExceptionPC, &regs[8 * 4 * 2], 4 * 2, 0);
33
 
34
  /* Copy CS, SS, DS */
35
  mem2hex (&frame->ExceptionCS, &regs[10 * 4 * 2], 4 * 3, 0);
36
 
37
  /* Copy ES */
38
  mem2hex (&frame->ExceptionES, &regs[13 * 4 * 2], 4 * 1, 0);
39
 
40
  /* Copy FS & GS */
41
  mem2hex (&frame->ExceptionFS, &regs[14 * 4 * 2], 4 * 2, 0);
42
}
43
 
44
/* Put the registers back into the frame information.  */
45
 
46
void
47
registers_to_frame (char *regs, struct StackFrame *frame)
48
{
49
  /* Copy EAX -> EDI */
50
  hex2mem (&regs[0 * 4 * 2], &frame->ExceptionEAX, 4 * 8, 0);
51
 
52
  /* Copy EIP & PS */
53
  hex2mem (&regs[8 * 4 * 2], &frame->ExceptionPC, 4 * 2, 0);
54
 
55
  /* Copy CS, SS, DS */
56
  hex2mem (&regs[10 * 4 * 2], &frame->ExceptionCS, 4 * 3, 0);
57
 
58
  /* Copy ES */
59
  hex2mem (&regs[13 * 4 * 2], &frame->ExceptionES, 4 * 1, 0);
60
 
61
  /* Copy FS & GS */
62
  hex2mem (&regs[14 * 4 * 2], &frame->ExceptionFS, 4 * 2, 0);
63
}
64
 
65
void
66
set_step_traps (struct StackFrame *frame)
67
{
68
  frame->ExceptionSystemFlags |= 0x100;
69
}
70
 
71
void
72
clear_step_traps (struct StackFrame *frame)
73
{
74
  frame->ExceptionSystemFlags &= ~0x100;
75
}
76
 
77
void
78
do_status (char *ptr, struct StackFrame *frame)
79
{
80
  int sigval;
81
 
82
  sigval = computeSignal (frame->ExceptionNumber);
83
 
84
  sprintf (ptr, "T%02x", sigval);
85
  ptr += 3;
86
 
87
  sprintf (ptr, "%02x:", PC_REGNUM);
88
  ptr = mem2hex (&frame->ExceptionPC, ptr + 3, 4, 0);
89
  *ptr++ = ';';
90
 
91
  sprintf (ptr, "%02x:", SP_REGNUM);
92
  ptr = mem2hex (&frame->ExceptionESP, ptr + 3, 4, 0);
93
  *ptr++ = ';';
94
 
95
  sprintf (ptr, "%02x:", FP_REGNUM);
96
  ptr = mem2hex (&frame->ExceptionEBP, ptr + 3, 4, 0);
97
  *ptr++ = ';';
98
 
99
  *ptr = '\000';
100
}

powered by: WebSVN 2.1.0

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