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

Subversion Repositories ao486

[/] [ao486/] [trunk/] [bochs486/] [cpu/] [soft_int.cc] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 alfik
/////////////////////////////////////////////////////////////////////////
2
// $Id: soft_int.cc 11529 2012-11-02 07:46:50Z sshwarts $
3
/////////////////////////////////////////////////////////////////////////
4
//
5
//  Copyright (C) 2001-2012  The Bochs Project
6
//
7
//  This library is free software; you can redistribute it and/or
8
//  modify it under the terms of the GNU Lesser General Public
9
//  License as published by the Free Software Foundation; either
10
//  version 2 of the License, or (at your option) any later version.
11
//
12
//  This library is distributed in the hope that it will be useful,
13
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
//  Lesser General Public License for more details.
16
//
17
//  You should have received a copy of the GNU Lesser General Public
18
//  License along with this library; if not, write to the Free Software
19
//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA B 02110-1301 USA
20
/////////////////////////////////////////////////////////////////////////
21
 
22
#define NEED_CPU_REG_SHORTCUTS 1
23
#include "bochs.h"
24
#include "cpu.h"
25
#define LOG_THIS BX_CPU_THIS_PTR
26
 
27
BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::BOUND_GwMa(bxInstruction_c *i)
28
{
29
  Bit16s op1_16 = BX_READ_16BIT_REG(i->dst());
30
 
31
  Bit32u eaddr = (Bit32u) BX_CPU_CALL_METHODR(i->ResolveModrm, (i));
32
 
33
  Bit16s bound_min = (Bit16s) read_virtual_word_32(i->seg(), eaddr);
34
  Bit16s bound_max = (Bit16s) read_virtual_word_32(i->seg(), (eaddr+2) & i->asize_mask());
35
 
36
  if (op1_16 < bound_min || op1_16 > bound_max) {
37
    BX_INFO(("BOUND_GdMa: fails bounds test"));
38
    exception(BX_BR_EXCEPTION, 0);
39
  }
40
 
41
  BX_NEXT_INSTR(i);
42
}
43
 
44
BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::BOUND_GdMa(bxInstruction_c *i)
45
{
46
  Bit32s op1_32 = BX_READ_32BIT_REG(i->dst());
47
 
48
  Bit32u eaddr = (Bit32u) BX_CPU_CALL_METHODR(i->ResolveModrm, (i));
49
 
50
  Bit32s bound_min = (Bit32s) read_virtual_dword_32(i->seg(), eaddr);
51
  Bit32s bound_max = (Bit32s) read_virtual_dword_32(i->seg(), (eaddr+4) & i->asize_mask());
52
 
53
  if (op1_32 < bound_min || op1_32 > bound_max) {
54
    BX_INFO(("BOUND_GdMa: fails bounds test"));
55
    exception(BX_BR_EXCEPTION, 0);
56
  }
57
 
58
  BX_NEXT_INSTR(i);
59
}
60
 
61
// This is an undocumented instrucion (opcode 0xf1) which
62
// is useful for an ICE system
63
BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::INT1(bxInstruction_c *i)
64
{
65
#if BX_SUPPORT_VMX
66
  VMexit_Event(BX_PRIVILEGED_SOFTWARE_INTERRUPT, 1, 0, 0);
67
#endif
68
 
69
#if BX_SUPPORT_SVM
70
  if (BX_CPU_THIS_PTR in_svm_guest) {
71
    if (SVM_INTERCEPT(SVM_INTERCEPT1_ICEBP)) Svm_Vmexit(SVM_VMEXIT_ICEBP);
72
  }
73
#endif
74
 
75
#if BX_DEBUGGER
76
  BX_CPU_THIS_PTR show_flag |= Flag_softint;
77
#endif
78
 
79
  BX_CPU_THIS_PTR EXT = 1;
80
 
81
  // interrupt is not RSP safe
82
  interrupt(1, BX_PRIVILEGED_SOFTWARE_INTERRUPT, 0, 0);
83
 
84
  BX_INSTR_FAR_BRANCH(BX_CPU_ID, BX_INSTR_IS_INT,
85
                      BX_CPU_THIS_PTR sregs[BX_SEG_REG_CS].selector.value,
86
                      EIP);
87
 
88
  BX_NEXT_TRACE(i);
89
}
90
 
91
BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::INT3(bxInstruction_c *i)
92
{
93
  // INT 3 is not IOPL sensitive
94
 
95
#if BX_SUPPORT_VMX
96
  VMexit_Event(BX_SOFTWARE_EXCEPTION, 3, 0, 0);
97
#endif
98
 
99
#if BX_SUPPORT_SVM
100
  SvmInterceptException(BX_SOFTWARE_EXCEPTION, 3, 0, 0);
101
#endif
102
 
103
#if BX_DEBUGGER
104
  BX_CPU_THIS_PTR show_flag |= Flag_softint;
105
#endif
106
 
107
  // interrupt is not RSP safe
108
  interrupt(3, BX_SOFTWARE_EXCEPTION, 0, 0);
109
 
110
  BX_INSTR_FAR_BRANCH(BX_CPU_ID, BX_INSTR_IS_INT,
111
                      BX_CPU_THIS_PTR sregs[BX_SEG_REG_CS].selector.value,
112
                      EIP);
113
 
114
  BX_NEXT_TRACE(i);
115
}
116
 
117
 
118
BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::INT_Ib(bxInstruction_c *i)
119
{
120
  Bit8u vector = i->Ib();
121
 
122
#if BX_SUPPORT_VMX
123
  VMexit_Event(BX_SOFTWARE_INTERRUPT, vector, 0, 0);
124
#endif
125
 
126
#if BX_SUPPORT_SVM
127
  if (BX_CPU_THIS_PTR in_svm_guest) {
128
    if (SVM_INTERCEPT(SVM_INTERCEPT0_SOFTINT))
129
      Svm_Vmexit(SVM_VMEXIT_SOFTWARE_INTERRUPT, BX_SUPPORT_SVM_EXTENSION(BX_CPUID_SVM_DECODE_ASSIST) ? vector : 0);
130
  }
131
#endif
132
 
133
#ifdef SHOW_EXIT_STATUS
134
  if ((vector == 0x21) && (AH == 0x4c)) {
135
    BX_INFO(("INT 21/4C called AL=0x%02x, BX=0x%04x", (unsigned) AL, (unsigned) BX));
136
  }
137
#endif
138
 
139
#if BX_DEBUGGER
140
  BX_CPU_THIS_PTR show_flag |= Flag_softint;
141
#endif
142
 
143
  interrupt(vector, BX_SOFTWARE_INTERRUPT, 0, 0);
144
 
145
  BX_INSTR_FAR_BRANCH(BX_CPU_ID, BX_INSTR_IS_INT,
146
                      BX_CPU_THIS_PTR sregs[BX_SEG_REG_CS].selector.value,
147
                      EIP);
148
 
149
  BX_NEXT_TRACE(i);
150
}
151
 
152
BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::INTO(bxInstruction_c *i)
153
{
154
  if (get_OF()) {
155
 
156
#if BX_SUPPORT_VMX
157
    VMexit_Event(BX_SOFTWARE_EXCEPTION, 4, 0, 0);
158
#endif
159
 
160
#if BX_SUPPORT_SVM
161
    SvmInterceptException(BX_SOFTWARE_EXCEPTION, 4, 0, 0);
162
#endif
163
 
164
#if BX_DEBUGGER
165
    BX_CPU_THIS_PTR show_flag |= Flag_softint;
166
#endif
167
 
168
    // interrupt is not RSP safe
169
    interrupt(4, BX_SOFTWARE_EXCEPTION, 0, 0);
170
 
171
    BX_INSTR_FAR_BRANCH(BX_CPU_ID, BX_INSTR_IS_INT,
172
                        BX_CPU_THIS_PTR sregs[BX_SEG_REG_CS].selector.value,
173
                        EIP);
174
  }
175
 
176
  BX_NEXT_TRACE(i);
177
}

powered by: WebSVN 2.1.0

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