Extended the interface of the fetch handler to general direct memory access handler.
Now the handler receives 'rw' (BX_READ, BX_WRTE, BX_EXECUTE) access type as parameter. If returning a pointer to <addr> - itr is assumed that whole 4K page containing the <addr> could be accessed using the same pointer with offset. You can return a pointer for READ/WRITE only and disallow execute, this is handled properly in the CPU code.
This commit is contained in:
parent
84214f7119
commit
f57b14d338
@ -45,8 +45,9 @@ class BX_CPU_C;
|
||||
#define BIOS_MAP_LAST128K(addr) (((addr) | 0xfff00000) & BIOS_MASK)
|
||||
|
||||
typedef bx_bool (*memory_handler_t)(bx_phy_address addr, unsigned len, void *data, void *param);
|
||||
// return a pointer to 4K region containing <addr> or NULL if direct fetch is not allowed
|
||||
typedef Bit8u* (*memory_fetch_handler_t)(bx_phy_address addr, void *param);
|
||||
// return a pointer to 4K region containing <addr> or NULL if direct access is not allowed
|
||||
// same format as getHostMemAddr method
|
||||
typedef Bit8u* (*memory_direct_access_handler_t)(bx_phy_address addr, unsigned rw, void *param);
|
||||
|
||||
struct memory_handler_struct {
|
||||
struct memory_handler_struct *next;
|
||||
@ -55,7 +56,7 @@ struct memory_handler_struct {
|
||||
bx_phy_address end;
|
||||
memory_handler_t read_handler;
|
||||
memory_handler_t write_handler;
|
||||
memory_fetch_handler_t fetch_handler;
|
||||
memory_direct_access_handler_t da_handler;
|
||||
};
|
||||
|
||||
#define SMRAM_CODE 1
|
||||
@ -103,7 +104,7 @@ public:
|
||||
#endif
|
||||
BX_MEM_SMF Bit8u* getHostMemAddr(BX_CPU_C *cpu, bx_phy_address addr, unsigned rw);
|
||||
BX_MEM_SMF bx_bool registerMemoryHandlers(void *param, memory_handler_t read_handler,
|
||||
memory_handler_t write_handler, memory_fetch_handler_t fetch_handler,
|
||||
memory_handler_t write_handler, memory_direct_access_handler_t da_handler,
|
||||
bx_phy_address begin_addr, bx_phy_address end_addr);
|
||||
BX_MEM_SMF BX_CPP_INLINE bx_bool registerMemoryHandlers(void *param, memory_handler_t read_handler,
|
||||
memory_handler_t write_handler,
|
||||
|
@ -597,8 +597,8 @@ Bit8u *BX_MEM_C::getHostMemAddr(BX_CPU_C *cpu, bx_phy_address addr, unsigned rw)
|
||||
while (memory_handler) {
|
||||
if (memory_handler->begin <= a20addr &&
|
||||
memory_handler->end >= a20addr) {
|
||||
if (rw == BX_EXECUTE && memory_handler->fetch_handler)
|
||||
return memory_handler->fetch_handler(a20addr, memory_handler->param);
|
||||
if (memory_handler->da_handler)
|
||||
return memory_handler->da_handler(a20addr, rw, memory_handler->param);
|
||||
else
|
||||
return(NULL); // Vetoed! memory handler for i/o apic, vram, mmio and PCI PnP
|
||||
}
|
||||
@ -692,7 +692,7 @@ Bit8u *BX_MEM_C::getHostMemAddr(BX_CPU_C *cpu, bx_phy_address addr, unsigned rw)
|
||||
*/
|
||||
bx_bool
|
||||
BX_MEM_C::registerMemoryHandlers(void *param, memory_handler_t read_handler,
|
||||
memory_handler_t write_handler, memory_fetch_handler_t fetch_handler,
|
||||
memory_handler_t write_handler, memory_direct_access_handler_t da_handler,
|
||||
bx_phy_address begin_addr, bx_phy_address end_addr)
|
||||
{
|
||||
if (end_addr < begin_addr)
|
||||
@ -706,7 +706,7 @@ BX_MEM_C::registerMemoryHandlers(void *param, memory_handler_t read_handler,
|
||||
BX_MEM_THIS memory_handlers[page_idx] = memory_handler;
|
||||
memory_handler->read_handler = read_handler;
|
||||
memory_handler->write_handler = write_handler;
|
||||
memory_handler->fetch_handler = fetch_handler;
|
||||
memory_handler->da_handler = da_handler;
|
||||
memory_handler->param = param;
|
||||
memory_handler->begin = begin_addr;
|
||||
memory_handler->end = end_addr;
|
||||
|
Loading…
Reference in New Issue
Block a user