- VBE LFB memory now registered using DEV_register_memory_handlers (static LFB

memory handling in memory.cc removed)
- type of memory handlers changed to bx_bool
- misc_mem.cc: fixed a warning
This commit is contained in:
Volker Ruppert 2004-06-06 17:01:19 +00:00
parent 0e76f1e21e
commit 36d7f60c21
5 changed files with 61 additions and 66 deletions

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: vga.cc,v 1.102 2004-05-04 20:41:52 vruppert Exp $
// $Id: vga.cc,v 1.103 2004-06-06 17:01:12 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2002 MandrakeSoft S.A.
@ -307,6 +307,9 @@ bx_vga_c::init(void)
DEV_register_iowrite_handler(this, vbe_write_handler, addr, "vga video", 7);
}
#endif
DEV_register_memory_handlers(vbe_mem_read_handler, theVga, vbe_mem_write_handler,
theVga, VBE_DISPI_LFB_PHYSICAL_ADDRESS,
VBE_DISPI_LFB_PHYSICAL_ADDRESS + VBE_DISPI_TOTAL_VIDEO_MEMORY_BYTES - 1);
BX_VGA_THIS s.vbe_cur_dispi=VBE_DISPI_ID0;
BX_VGA_THIS s.vbe_xres=640;
BX_VGA_THIS s.vbe_yres=480;
@ -2538,6 +2541,29 @@ bx_vga_c::redraw_area(unsigned x0, unsigned y0, unsigned width,
#if BX_SUPPORT_VBE
bx_bool
bx_vga_c::vbe_mem_read_handler(unsigned long addr, unsigned long len,
void *data, void *param)
{
Bit8u *data_ptr;
#ifdef BX_LITTLE_ENDIAN
data_ptr = (Bit8u *) data;
#else // BX_BIG_ENDIAN
data_ptr = (Bit8u *) data + (len - 1);
#endif
for (unsigned i = 0; i < len; i++) {
*data_ptr = vbe_mem_read(addr);
addr++;
#ifdef BX_LITTLE_ENDIAN
data_ptr++;
#else // BX_BIG_ENDIAN
data_ptr--;
#endif
}
return 1;
}
Bit8u BX_CPP_AttrRegparmN(1)
bx_vga_c::vbe_mem_read(Bit32u addr)
{
@ -2561,6 +2587,29 @@ bx_vga_c::vbe_mem_read(Bit32u addr)
return (BX_VGA_THIS s.vbe_memory[offset]);
}
bx_bool
bx_vga_c::vbe_mem_write_handler(unsigned long addr, unsigned long len,
void *data, void *param)
{
Bit8u *data_ptr;
#ifdef BX_LITTLE_ENDIAN
data_ptr = (Bit8u *) data;
#else // BX_BIG_ENDIAN
data_ptr = (Bit8u *) data + (len - 1);
#endif
for (unsigned i = 0; i < len; i++) {
vbe_mem_write(addr, *data_ptr);
addr++;
#ifdef BX_LITTLE_ENDIAN
data_ptr++;
#else // BX_BIG_ENDIAN
data_ptr--;
#endif
}
return 1;
}
void BX_CPP_AttrRegparmN(2)
bx_vga_c::vbe_mem_write(Bit32u addr, Bit8u value)
{

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: vga.h,v 1.38 2004-05-04 20:41:53 vruppert Exp $
// $Id: vga.h,v 1.39 2004-06-06 17:01:18 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2002 MandrakeSoft S.A.
@ -118,6 +118,9 @@ public:
virtual void trigger_timer(void *this_ptr);
#if BX_SUPPORT_VBE
BX_VGA_SMF bx_bool vbe_mem_read_handler(unsigned long addr, unsigned long len, void *data, void *param);
BX_VGA_SMF bx_bool vbe_mem_write_handler(unsigned long addr, unsigned long len, void *data, void *param);
BX_VGA_SMF Bit8u vbe_mem_read(Bit32u addr) BX_CPP_AttrRegparmN(1);
BX_VGA_SMF void vbe_mem_write(Bit32u addr, Bit8u value) BX_CPP_AttrRegparmN(2);
#endif

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: memory.cc,v 1.28 2004-01-15 02:08:35 danielg4 Exp $
// $Id: memory.cc,v 1.29 2004-06-06 17:01:19 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -181,35 +181,6 @@ inc_one:
#endif
#if BX_SUPPORT_VBE
// Check VBE LFB support
if ((a20addr >= VBE_DISPI_LFB_PHYSICAL_ADDRESS) &&
(a20addr < (VBE_DISPI_LFB_PHYSICAL_ADDRESS + VBE_DISPI_TOTAL_VIDEO_MEMORY_BYTES)))
{
for (i = 0; i < len; i++) {
//if (a20addr < BX_MEM_THIS len) {
//vector[a20addr] = *data_ptr;
//BX_DBG_DIRTY_PAGE(a20addr >> 12);
DEV_vga_mem_write(a20addr, *data_ptr);
// }
// otherwise ignore byte, since it overruns memory
addr++;
a20addr = (addr);
#ifdef BX_LITTLE_ENDIAN
data_ptr++;
#else // BX_BIG_ENDIAN
data_ptr--;
#endif
}
return;
}
#endif
#if BX_SUPPORT_APIC
bx_generic_apic_c *local_apic = &cpu->local_apic;
bx_generic_apic_c *ioapic = bx_devices.ioapic;
@ -373,34 +344,6 @@ inc_one:
data_ptr = (Bit8u *) data + (len - 1);
#endif
#if BX_SUPPORT_VBE
// Check VBE LFB support
if ((a20addr >= VBE_DISPI_LFB_PHYSICAL_ADDRESS) &&
(a20addr < (VBE_DISPI_LFB_PHYSICAL_ADDRESS + VBE_DISPI_TOTAL_VIDEO_MEMORY_BYTES)))
{
for (i = 0; i < len; i++) {
//if (a20addr < BX_MEM_THIS len) {
//vector[a20addr] = *data_ptr;
//BX_DBG_DIRTY_PAGE(a20addr >> 12);
*data_ptr = DEV_vga_mem_read(a20addr);
// }
// otherwise ignore byte, since it overruns memory
addr++;
a20addr = (addr);
#ifdef BX_LITTLE_ENDIAN
data_ptr++;
#else // BX_BIG_ENDIAN
data_ptr--;
#endif
}
return;
}
#endif
#if BX_SUPPORT_APIC
bx_generic_apic_c *local_apic = &cpu->local_apic;

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: memory.h,v 1.17 2004-01-15 02:08:37 danielg4 Exp $
// $Id: memory.h,v 1.18 2004-06-06 17:01:19 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -42,7 +42,7 @@
// alignment of memory vector, must be a power of 2
#define BX_MEM_VECTOR_ALIGN 4096
typedef bool (*memory_handler_t)(unsigned long addr, unsigned long len, void *data, void *param);
typedef bx_bool (*memory_handler_t)(unsigned long addr, unsigned long len, void *data, void *param);
struct memory_handler_struct {
struct memory_handler_struct *next;

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: misc_mem.cc,v 1.42 2004-01-15 02:08:37 danielg4 Exp $
// $Id: misc_mem.cc,v 1.43 2004-06-06 17:01:19 vruppert Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2002 MandrakeSoft S.A.
@ -135,7 +135,7 @@ BX_MEM_C::~BX_MEM_C(void)
void
BX_MEM_C::init_memory(int memsize)
{
BX_DEBUG(("Init $Id: misc_mem.cc,v 1.42 2004-01-15 02:08:37 danielg4 Exp $"));
BX_DEBUG(("Init $Id: misc_mem.cc,v 1.43 2004-06-06 17:01:19 vruppert Exp $"));
// you can pass 0 if memory has been allocated already through
// the constructor, or the desired size of memory if it hasn't
// BX_INFO(("%.2fMB", (float)(BX_MEM_THIS megabytes) ));
@ -424,7 +424,7 @@ BX_MEM_C::registerMemoryHandlers(memory_handler_t read_handler, void *read_param
return false;
if (!write_handler)
return false;
for (int page_idx = begin_addr >> 20; page_idx <= end_addr >> 20; page_idx++) {
for (unsigned page_idx = begin_addr >> 20; page_idx <= end_addr >> 20; page_idx++) {
struct memory_handler_struct *memory_handler = new struct memory_handler_struct;
memory_handler->next = memory_handlers[page_idx];
memory_handlers[page_idx] = memory_handler;
@ -444,7 +444,7 @@ BX_MEM_C::unregisterMemoryHandlers(memory_handler_t read_handler, memory_handler
unsigned long begin_addr, unsigned long end_addr)
{
bx_bool ret = true;
for (int page_idx = begin_addr >> 20; page_idx <= end_addr >> 20; page_idx++) {
for (unsigned page_idx = begin_addr >> 20; page_idx <= end_addr >> 20; page_idx++) {
struct memory_handler_struct *memory_handler = memory_handlers[page_idx];
struct memory_handler_struct *prev = NULL;
while (memory_handler &&