Fix vesa_drv on native hardware

When vesa_drv tries to access values lying across region boundaries, the
second region may be not mapped.

Fixes #524
This commit is contained in:
Alexander Boettcher 2012-11-27 12:38:38 +01:00 committed by Norman Feske
parent 51f99106bd
commit 7ee4b75156
1 changed files with 14 additions and 3 deletions

View File

@ -321,22 +321,33 @@ static int map_code_area(void)
template <typename T>
static T X86API read(X86emu::u32 addr)
{
T ret = *X86emu::virt_addr<T>(addr);
/*
* Access the last byte of the T value, before actually reading the value.
*
* If the value of the address is crossing the current region boundary,
* the region behind the boundary will be allocated. Both regions will be
* merged and can be attached to a different virtual address then when
* only accessing the first bytes of the value.
*/
T * ret = X86emu::virt_addr<T>(addr + sizeof(T) - 1);
ret = X86emu::virt_addr<T>(addr);
if (verbose_mem) {
unsigned v = ret;
unsigned v = *ret;
PLOG(" io_mem: read [%p,%p) val 0x%ux",
reinterpret_cast<void*>(addr),
reinterpret_cast<void*>(addr + sizeof(T)), v);
}
return ret;
return *ret;
}
template <typename T>
static void X86API write(X86emu::u32 addr, T val)
{
/* see description of 'read' function */
X86emu::virt_addr<T>(addr + sizeof(T) - 1);
*X86emu::virt_addr<T>(addr) = val;
if (verbose_mem) {