MMIOHandler::InvalidateRange
This commit is contained in:
parent
8784de0162
commit
529227e4e6
|
@ -156,8 +156,29 @@ void MMIOHandler::CancelWriteWatch(uintptr_t watch_handle) {
|
|||
delete entry;
|
||||
}
|
||||
|
||||
bool MMIOHandler::CheckWriteWatch(X64Context* thread_context,
|
||||
uint64_t fault_address) {
|
||||
void MMIOHandler::InvalidateRange(uint32_t physical_address, size_t length) {
|
||||
auto lock = global_critical_region_.Acquire();
|
||||
|
||||
for (auto it = write_watches_.begin(); it != write_watches_.end();) {
|
||||
auto entry = *it;
|
||||
if ((entry->address <= physical_address &&
|
||||
entry->address + entry->length > physical_address) ||
|
||||
(entry->address >= physical_address &&
|
||||
entry->address < physical_address + length)) {
|
||||
// This watch lies within the range. End it.
|
||||
ClearWriteWatch(entry);
|
||||
entry->callback(entry->callback_context, entry->callback_data,
|
||||
entry->address);
|
||||
|
||||
it = write_watches_.erase(it);
|
||||
continue;
|
||||
}
|
||||
|
||||
++it;
|
||||
}
|
||||
}
|
||||
|
||||
bool MMIOHandler::CheckWriteWatch(uint64_t fault_address) {
|
||||
uint32_t physical_address = uint32_t(fault_address);
|
||||
if (physical_address > 0x1FFFFFFF) {
|
||||
physical_address &= 0x1FFFFFFF;
|
||||
|
@ -395,7 +416,7 @@ bool MMIOHandler::ExceptionCallback(Exception* ex) {
|
|||
if (!range) {
|
||||
// Access is not found within any range, so fail and let the caller handle
|
||||
// it (likely by aborting).
|
||||
return CheckWriteWatch(ex->thread_context(), ex->fault_address());
|
||||
return CheckWriteWatch(ex->fault_address());
|
||||
}
|
||||
|
||||
auto rip = ex->pc();
|
||||
|
|
|
@ -63,6 +63,7 @@ class MMIOHandler {
|
|||
WriteWatchCallback callback,
|
||||
void* callback_context, void* callback_data);
|
||||
void CancelWriteWatch(uintptr_t watch_handle);
|
||||
void InvalidateRange(uint32_t physical_address, size_t length);
|
||||
|
||||
protected:
|
||||
struct WriteWatchEntry {
|
||||
|
@ -83,7 +84,7 @@ class MMIOHandler {
|
|||
bool ExceptionCallback(Exception* ex);
|
||||
|
||||
void ClearWriteWatch(WriteWatchEntry* entry);
|
||||
bool CheckWriteWatch(X64Context* thread_context, uint64_t fault_address);
|
||||
bool CheckWriteWatch(uint64_t fault_address);
|
||||
|
||||
uint8_t* virtual_membase_;
|
||||
uint8_t* physical_membase_;
|
||||
|
|
Loading…
Reference in New Issue