Switching to xe::mutex.
This commit is contained in:
@@ -69,9 +69,7 @@ uint32_t get_page_count(uint32_t value, uint32_t page_size) {
|
||||
|
||||
static Memory* active_memory_ = nullptr;
|
||||
|
||||
void CrashDump() {
|
||||
active_memory_->DumpMap();
|
||||
}
|
||||
void CrashDump() { active_memory_->DumpMap(); }
|
||||
|
||||
Memory::Memory()
|
||||
: virtual_membase_(nullptr),
|
||||
@@ -491,7 +489,7 @@ void BaseHeap::Dispose() {
|
||||
}
|
||||
|
||||
void BaseHeap::DumpMap() {
|
||||
std::lock_guard<std::recursive_mutex> lock(heap_mutex_);
|
||||
std::lock_guard<xe::recursive_mutex> lock(heap_mutex_);
|
||||
XELOGE("------------------------------------------------------------------");
|
||||
XELOGE("Heap: %.8X-%.8X", heap_base_, heap_base_ + heap_size_);
|
||||
XELOGE("------------------------------------------------------------------");
|
||||
@@ -565,7 +563,7 @@ bool BaseHeap::AllocFixed(uint32_t base_address, uint32_t size,
|
||||
return false;
|
||||
}
|
||||
|
||||
std::lock_guard<std::recursive_mutex> lock(heap_mutex_);
|
||||
std::lock_guard<xe::recursive_mutex> lock(heap_mutex_);
|
||||
|
||||
// - If we are reserving the entire range requested must not be already
|
||||
// reserved.
|
||||
@@ -643,7 +641,7 @@ bool BaseHeap::AllocRange(uint32_t low_address, uint32_t high_address,
|
||||
high_page_number =
|
||||
std::min(uint32_t(page_table_.size()) - 1, high_page_number);
|
||||
|
||||
std::lock_guard<std::recursive_mutex> lock(heap_mutex_);
|
||||
std::lock_guard<xe::recursive_mutex> lock(heap_mutex_);
|
||||
|
||||
// Find a free page range.
|
||||
// The base page must match the requested alignment, so we first scan for
|
||||
@@ -765,7 +763,7 @@ bool BaseHeap::Decommit(uint32_t address, uint32_t size) {
|
||||
std::min(uint32_t(page_table_.size()) - 1, start_page_number);
|
||||
end_page_number = std::min(uint32_t(page_table_.size()) - 1, end_page_number);
|
||||
|
||||
std::lock_guard<std::recursive_mutex> lock(heap_mutex_);
|
||||
std::lock_guard<xe::recursive_mutex> lock(heap_mutex_);
|
||||
|
||||
// Release from host.
|
||||
// TODO(benvanik): find a way to actually decommit memory;
|
||||
@@ -789,7 +787,7 @@ bool BaseHeap::Decommit(uint32_t address, uint32_t size) {
|
||||
}
|
||||
|
||||
bool BaseHeap::Release(uint32_t base_address, uint32_t* out_region_size) {
|
||||
std::lock_guard<std::recursive_mutex> lock(heap_mutex_);
|
||||
std::lock_guard<xe::recursive_mutex> lock(heap_mutex_);
|
||||
|
||||
// Given address must be a region base address.
|
||||
uint32_t base_page_number = (base_address - heap_base_) / page_size_;
|
||||
@@ -844,7 +842,7 @@ bool BaseHeap::Protect(uint32_t address, uint32_t size, uint32_t protect) {
|
||||
std::min(uint32_t(page_table_.size()) - 1, start_page_number);
|
||||
end_page_number = std::min(uint32_t(page_table_.size()) - 1, end_page_number);
|
||||
|
||||
std::lock_guard<std::recursive_mutex> lock(heap_mutex_);
|
||||
std::lock_guard<xe::recursive_mutex> lock(heap_mutex_);
|
||||
|
||||
// Ensure all pages are in the same reserved region and all are committed.
|
||||
uint32_t first_base_address = UINT_MAX;
|
||||
@@ -897,7 +895,7 @@ bool BaseHeap::QueryRegionInfo(uint32_t base_address,
|
||||
return false;
|
||||
}
|
||||
|
||||
std::lock_guard<std::recursive_mutex> lock(heap_mutex_);
|
||||
std::lock_guard<xe::recursive_mutex> lock(heap_mutex_);
|
||||
|
||||
auto start_page_entry = page_table_[start_page_number];
|
||||
out_info->base_address = base_address;
|
||||
@@ -948,7 +946,7 @@ bool BaseHeap::QuerySize(uint32_t address, uint32_t* out_size) {
|
||||
*out_size = 0;
|
||||
return false;
|
||||
}
|
||||
std::lock_guard<std::recursive_mutex> lock(heap_mutex_);
|
||||
std::lock_guard<xe::recursive_mutex> lock(heap_mutex_);
|
||||
auto page_entry = page_table_[page_number];
|
||||
*out_size = page_entry.region_page_count * page_size_;
|
||||
return true;
|
||||
@@ -961,7 +959,7 @@ bool BaseHeap::QueryProtect(uint32_t address, uint32_t* out_protect) {
|
||||
*out_protect = 0;
|
||||
return false;
|
||||
}
|
||||
std::lock_guard<std::recursive_mutex> lock(heap_mutex_);
|
||||
std::lock_guard<xe::recursive_mutex> lock(heap_mutex_);
|
||||
auto page_entry = page_table_[page_number];
|
||||
*out_protect = page_entry.current_protect;
|
||||
return true;
|
||||
@@ -1009,7 +1007,7 @@ bool PhysicalHeap::Alloc(uint32_t size, uint32_t alignment,
|
||||
size = xe::round_up(size, page_size_);
|
||||
alignment = xe::round_up(alignment, page_size_);
|
||||
|
||||
std::lock_guard<std::recursive_mutex> lock(heap_mutex_);
|
||||
std::lock_guard<xe::recursive_mutex> lock(heap_mutex_);
|
||||
|
||||
// Allocate from parent heap (gets our physical address in 0-512mb).
|
||||
uint32_t parent_low_address = GetPhysicalAddress(heap_base_);
|
||||
@@ -1047,7 +1045,7 @@ bool PhysicalHeap::AllocFixed(uint32_t base_address, uint32_t size,
|
||||
size = xe::round_up(size, page_size_);
|
||||
alignment = xe::round_up(alignment, page_size_);
|
||||
|
||||
std::lock_guard<std::recursive_mutex> lock(heap_mutex_);
|
||||
std::lock_guard<xe::recursive_mutex> lock(heap_mutex_);
|
||||
|
||||
// Allocate from parent heap (gets our physical address in 0-512mb).
|
||||
// NOTE: this can potentially overwrite heap contents if there are already
|
||||
@@ -1088,7 +1086,7 @@ bool PhysicalHeap::AllocRange(uint32_t low_address, uint32_t high_address,
|
||||
size = xe::round_up(size, page_size_);
|
||||
alignment = xe::round_up(alignment, page_size_);
|
||||
|
||||
std::lock_guard<std::recursive_mutex> lock(heap_mutex_);
|
||||
std::lock_guard<xe::recursive_mutex> lock(heap_mutex_);
|
||||
|
||||
// Allocate from parent heap (gets our physical address in 0-512mb).
|
||||
low_address = std::max(heap_base_, low_address);
|
||||
@@ -1122,7 +1120,7 @@ bool PhysicalHeap::AllocRange(uint32_t low_address, uint32_t high_address,
|
||||
}
|
||||
|
||||
bool PhysicalHeap::Decommit(uint32_t address, uint32_t size) {
|
||||
std::lock_guard<std::recursive_mutex> lock(heap_mutex_);
|
||||
std::lock_guard<xe::recursive_mutex> lock(heap_mutex_);
|
||||
uint32_t parent_address = GetPhysicalAddress(address);
|
||||
if (!parent_heap_->Decommit(parent_address, size)) {
|
||||
XELOGE("PhysicalHeap::Decommit failed due to parent heap failure");
|
||||
@@ -1132,7 +1130,7 @@ bool PhysicalHeap::Decommit(uint32_t address, uint32_t size) {
|
||||
}
|
||||
|
||||
bool PhysicalHeap::Release(uint32_t base_address, uint32_t* out_region_size) {
|
||||
std::lock_guard<std::recursive_mutex> lock(heap_mutex_);
|
||||
std::lock_guard<xe::recursive_mutex> lock(heap_mutex_);
|
||||
uint32_t parent_base_address = GetPhysicalAddress(base_address);
|
||||
if (!parent_heap_->Release(parent_base_address, out_region_size)) {
|
||||
XELOGE("PhysicalHeap::Release failed due to parent heap failure");
|
||||
@@ -1142,7 +1140,7 @@ bool PhysicalHeap::Release(uint32_t base_address, uint32_t* out_region_size) {
|
||||
}
|
||||
|
||||
bool PhysicalHeap::Protect(uint32_t address, uint32_t size, uint32_t protect) {
|
||||
std::lock_guard<std::recursive_mutex> lock(heap_mutex_);
|
||||
std::lock_guard<xe::recursive_mutex> lock(heap_mutex_);
|
||||
uint32_t parent_address = GetPhysicalAddress(address);
|
||||
bool parent_result = parent_heap_->Protect(parent_address, size, protect);
|
||||
if (!parent_result) {
|
||||
|
||||
Reference in New Issue
Block a user