Skip to content

Commit

Permalink
ready to enlarge supported BIOS ROM to 2M
Browse files Browse the repository at this point in the history
  • Loading branch information
sshwarts committed May 18, 2010
1 parent 45e4470 commit 2734983
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
6 changes: 3 additions & 3 deletions memory/memory.cc
@@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: memory.cc,v 1.83 2010/05/18 07:44:37 sshwarts Exp $
// $Id: memory.cc,v 1.84 2010/05/18 08:54:01 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001-2009 The Bochs Project
Expand Down Expand Up @@ -291,7 +291,7 @@ void BX_MEM_C::readPhysicalPage(BX_CPU_C *cpu, bx_phy_address addr, unsigned len
case 0x0: // Read from ROM
if ((a20addr & 0xfffe0000) == 0x000e0000) {
// last 128K of BIOS ROM mapped to 0xE0000-0xFFFFF
*data_ptr = BX_MEM_THIS rom[a20addr & BIOS_MASK];
*data_ptr = BX_MEM_THIS rom[BIOS_MAP_LAST128K(a20addr)];
}
else {
*data_ptr = BX_MEM_THIS rom[(a20addr & EXROM_MASK) + BIOSROMSZ];
Expand All @@ -312,7 +312,7 @@ void BX_MEM_C::readPhysicalPage(BX_CPU_C *cpu, bx_phy_address addr, unsigned len
}
else if ((a20addr & 0xfffe0000) == 0x000e0000) {
// last 128K of BIOS ROM mapped to 0xE0000-0xFFFFF
*data_ptr = BX_MEM_THIS rom[a20addr & BIOS_MASK];
*data_ptr = BX_MEM_THIS rom[BIOS_MAP_LAST128K(a20addr)];
}
else {
*data_ptr = BX_MEM_THIS rom[(a20addr & EXROM_MASK) + BIOSROMSZ];
Expand Down
7 changes: 5 additions & 2 deletions memory/memory.h
@@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: memory.h,v 1.69 2010/05/17 19:42:30 sshwarts Exp $
// $Id: memory.h,v 1.70 2010/05/18 08:54:01 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001-2009 The Bochs Project
Expand Down Expand Up @@ -36,11 +36,14 @@

class BX_CPU_C;

#define BIOSROMSZ ((Bit32u)(1 << 19)) // 512KB BIOS ROM @0xfff80000, must be a power of 2
// 512K BIOS ROM @0xfff80000
#define BIOSROMSZ ((Bit32u)(1 << 19)) // 2M BIOS ROM @0xffe00000, must be a power of 2
#define EXROMSIZE (0x20000) // ROMs 0xc0000-0xdffff (area 0xe0000-0xfffff=bios mapped)
#define BIOS_MASK (BIOSROMSZ-1)
#define EXROM_MASK (EXROMSIZE-1)

#define BIOS_MAP_LAST128K(addr) ((addr) & BIOS_MASK)

typedef bx_bool (*memory_handler_t)(bx_phy_address addr, unsigned len, void *data, void *param);

struct memory_handler_struct {
Expand Down
12 changes: 6 additions & 6 deletions memory/misc_mem.cc
@@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: misc_mem.cc,v 1.146 2010/05/18 07:44:37 sshwarts Exp $
// $Id: misc_mem.cc,v 1.147 2010/05/18 08:54:01 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001-2009 The Bochs Project
Expand Down Expand Up @@ -73,7 +73,7 @@ void BX_MEM_C::init_memory(Bit64u guest, Bit64u host)
{
unsigned idx;

BX_DEBUG(("Init $Id: misc_mem.cc,v 1.146 2010/05/18 07:44:37 sshwarts Exp $"));
BX_DEBUG(("Init $Id: misc_mem.cc,v 1.147 2010/05/18 08:54:01 sshwarts Exp $"));

// accept only memory size which is multiply of 1M
BX_ASSERT((host & 0xfffff) == 0);
Expand Down Expand Up @@ -431,7 +431,7 @@ bx_bool BX_MEM_C::dbg_fetch_mem(BX_CPU_C *cpu, bx_phy_address addr, unsigned len
case 0x0: // Read from ROM
if ((addr & 0xfffe0000) == 0x000e0000) {
// last 128K of BIOS ROM mapped to 0xE0000-0xFFFFF
*buf = BX_MEM_THIS rom[addr & BIOS_MASK];
*buf = BX_MEM_THIS rom[BIOS_MAP_LAST128K(addr)];
}
else {
*buf = BX_MEM_THIS rom[(addr & EXROM_MASK) + BIOSROMSZ];
Expand All @@ -453,7 +453,7 @@ bx_bool BX_MEM_C::dbg_fetch_mem(BX_CPU_C *cpu, bx_phy_address addr, unsigned len
// must be in C0000 - FFFFF range
else if ((addr & 0xfffe0000) == 0x000e0000) {
// last 128K of BIOS ROM mapped to 0xE0000-0xFFFFF
*buf = BX_MEM_THIS rom[addr & BIOS_MASK];
*buf = BX_MEM_THIS rom[BIOS_MAP_LAST128K(addr)];
}
else {
*buf = BX_MEM_THIS rom[(addr & EXROM_MASK) + BIOSROMSZ];
Expand Down Expand Up @@ -612,7 +612,7 @@ Bit8u *BX_MEM_C::getHostMemAddr(BX_CPU_C *cpu, bx_phy_address addr, unsigned rw)
case 0x0: // Read from ROM
if ((a20addr & 0xfffe0000) == 0x000e0000) {
// last 128K of BIOS ROM mapped to 0xE0000-0xFFFFF
return (Bit8u *) &BX_MEM_THIS rom[a20addr & BIOS_MASK];
return (Bit8u *) &BX_MEM_THIS rom[BIOS_MAP_LAST128K(a20addr)];
}
else {
return (Bit8u *) &BX_MEM_THIS rom[(a20addr & EXROM_MASK) + BIOSROMSZ];
Expand All @@ -634,7 +634,7 @@ Bit8u *BX_MEM_C::getHostMemAddr(BX_CPU_C *cpu, bx_phy_address addr, unsigned rw)
// must be in C0000 - FFFFF range
else if ((a20addr & 0xfffe0000) == 0x000e0000) {
// last 128K of BIOS ROM mapped to 0xE0000-0xFFFFF
return (Bit8u *) &BX_MEM_THIS rom[a20addr & BIOS_MASK];
return (Bit8u *) &BX_MEM_THIS rom[BIOS_MAP_LAST128K(a20addr)];
}
else {
return((Bit8u *) &BX_MEM_THIS rom[(a20addr & EXROM_MASK) + BIOSROMSZ]);
Expand Down

0 comments on commit 2734983

Please sign in to comment.