~ubuntu-branches/ubuntu/saucy/bochs/saucy-proposed

« back to all changes in this revision

Viewing changes to memory/memory.cc

  • Committer: Bazaar Package Importer
  • Author(s): David Futcher
  • Date: 2009-04-30 07:46:11 UTC
  • mfrom: (1.1.11 upstream) (4.1.7 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090430074611-6dih80a5mk2uvxhk
Tags: 2.3.7+20090416-1ubuntu1
* Merge from debian unstable (LP: #370427), remaining changes:
  - debian/patches/12_no-ssp.patch: Build bios with -fno-stack-protector
  - Add Replaces/Conflicts for bochsbios-qemu (<< 2.3.6-2)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/////////////////////////////////////////////////////////////////////////
2
 
// $Id: memory.cc,v 1.69 2008/05/31 20:59:38 sshwarts Exp $
 
2
// $Id: memory.cc,v 1.76 2009/03/13 18:48:08 sshwarts Exp $
3
3
/////////////////////////////////////////////////////////////////////////
4
4
//
5
5
//  Copyright (C) 2001  MandrakeSoft S.A.
22
22
//
23
23
//  You should have received a copy of the GNU Lesser General Public
24
24
//  License along with this library; if not, write to the Free Software
25
 
//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 
25
//  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
26
26
//
27
27
/////////////////////////////////////////////////////////////////////////
28
28
 
61
61
 
62
62
  if (cpu != NULL) {
63
63
#if BX_SUPPORT_IODEBUG
64
 
    bx_iodebug_c::mem_write(cpu, a20addr, len, data);
 
64
    bx_devices.pluginIODebug->mem_write(cpu, a20addr, len, data);
65
65
#endif
66
66
 
67
67
    BX_INSTR_PHY_WRITE(cpu->which_cpu(), a20addr, len);
68
68
 
69
 
#if BX_SUPPORT_APIC
70
 
    bx_generic_apic_c *local_apic = &cpu->local_apic;
71
 
    if (local_apic->is_selected(a20addr, len)) {
72
 
      local_apic->write(a20addr, (Bit32u *)data, len);
73
 
      return;
74
 
    }
75
 
#endif
76
 
 
77
69
    if ((a20addr & 0xfffe0000) == 0x000a0000 && (BX_MEM_THIS smram_available))
78
70
    {
79
71
      // SMRAM memory space
97
89
 
98
90
  // all memory access feets in single 4K page
99
91
  if (a20addr < BX_MEM_THIS len) {
100
 
#if BX_SUPPORT_ICACHE
101
92
    pageWriteStampTable.decWriteStamp(a20addr);
102
 
#endif
103
93
    // all of data is within limits of physical memory
104
94
    if ((a20addr & 0xfff80000) != 0x00080000 || (a20addr <= 0x0009ffff))
105
95
    {
106
96
      if (len == 8) {
107
97
        WriteHostQWordToLittleEndian(BX_MEM_THIS get_vector(a20addr), *(Bit64u*)data);
108
 
        BX_DBG_DIRTY_PAGE(a20addr >> 12);
109
98
        return;
110
99
      }
111
100
      if (len == 4) {
112
101
        WriteHostDWordToLittleEndian(BX_MEM_THIS get_vector(a20addr), *(Bit32u*)data);
113
 
        BX_DBG_DIRTY_PAGE(a20addr >> 12);
114
102
        return;
115
103
      }
116
104
      if (len == 2) {
117
105
        WriteHostWordToLittleEndian(BX_MEM_THIS get_vector(a20addr), *(Bit16u*)data);
118
 
        BX_DBG_DIRTY_PAGE(a20addr >> 12);
119
106
        return;
120
107
      }
121
108
      if (len == 1) {
122
109
        * (BX_MEM_THIS get_vector(a20addr)) = * (Bit8u *) data;
123
 
        BX_DBG_DIRTY_PAGE(a20addr >> 12);
124
110
        return;
125
111
      }
126
112
      // len == other, just fall thru to special cases handling
137
123
      while(1) {
138
124
        // addr *not* in range 000A0000 .. 000FFFFF
139
125
        *(BX_MEM_THIS get_vector(a20addr)) = *data_ptr;
140
 
        BX_DBG_DIRTY_PAGE(a20addr >> 12);
141
126
        if (len == 1) return;
142
127
        len--;
143
128
        a20addr++;
158
143
        // devices are not allowed to access SMMRAM under VGA memory
159
144
        if (cpu) {
160
145
          *(BX_MEM_THIS get_vector(a20addr)) = *data_ptr;
161
 
          BX_DBG_DIRTY_PAGE(a20addr >> 12);
162
146
        }
163
147
        goto inc_one;
164
148
      }
175
159
          case 0x1:   // Writes to ShadowRAM
176
160
            BX_DEBUG(("Writing to ShadowRAM: address 0x" FMT_PHY_ADDRX ", data %02x", a20addr, *data_ptr));
177
161
            *(BX_MEM_THIS get_vector(a20addr)) = *data_ptr;
178
 
            BX_DBG_DIRTY_PAGE(a20addr >> 12);
179
162
            break;
180
163
 
181
164
          case 0x0:   // Writes to ROM, Inhibit
217
200
 
218
201
  if (cpu != NULL) {
219
202
#if BX_SUPPORT_IODEBUG
220
 
    bx_iodebug_c::mem_read(cpu, a20addr, len, data);
 
203
    bx_devices.pluginIODebug->mem_read(cpu, a20addr, len, data);
221
204
#endif
222
205
 
223
206
    BX_INSTR_PHY_READ(cpu->which_cpu(), a20addr, len);
224
207
 
225
 
#if BX_SUPPORT_APIC
226
 
    bx_generic_apic_c *local_apic = &cpu->local_apic;
227
 
    if (local_apic->is_selected (a20addr, len)) {
228
 
      local_apic->read(a20addr, data, len);
229
 
      return;
230
 
    }
231
 
#endif
232
 
 
233
208
    if ((a20addr & 0xfffe0000) == 0x000a0000 && (BX_MEM_THIS smram_available))
234
209
    {
235
210
      // SMRAM memory space
360
335
#endif
361
336
 
362
337
    for (unsigned i = 0; i < len; i++) {
 
338
#if BX_PHY_ADDRESS_LONG
 
339
      if (a20addr >= BX_CONST64(0xFFFFFFFF))
 
340
        *data_ptr = 0xff;
 
341
      else
 
342
#endif      
363
343
      if (a20addr >= (bx_phy_address)~BIOS_MASK)
364
344
        *data_ptr = BX_MEM_THIS rom[a20addr & BIOS_MASK];
365
345
      else