mirror of
https://github.com/genodelabs/genode.git
synced 2025-01-18 18:56:29 +00:00
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:
parent
51f99106bd
commit
7ee4b75156
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user