Always allocate system heap from top of heap
This commit is contained in:
parent
dde8adc140
commit
3d96dfa359
|
@ -535,8 +535,7 @@ const std::filesystem::path Emulator::GetNewDiscPath(
|
||||||
{"All Files (*.*)", "*.*"},
|
{"All Files (*.*)", "*.*"},
|
||||||
});
|
});
|
||||||
|
|
||||||
if (file_picker->Show(
|
if (file_picker->Show()) {
|
||||||
kernel_state()->emulator()->display_window()->native_handle())) {
|
|
||||||
auto selected_files = file_picker->selected_files();
|
auto selected_files = file_picker->selected_files();
|
||||||
if (!selected_files.empty()) {
|
if (!selected_files.empty()) {
|
||||||
path = selected_files[0];
|
path = selected_files[0];
|
||||||
|
|
|
@ -443,8 +443,8 @@ typedef struct {
|
||||||
} X_SWAPDISC_ERROR_MESSAGE;
|
} X_SWAPDISC_ERROR_MESSAGE;
|
||||||
static_assert_size(X_SWAPDISC_ERROR_MESSAGE, 12);
|
static_assert_size(X_SWAPDISC_ERROR_MESSAGE, 12);
|
||||||
|
|
||||||
dword_result_t XamSwapDisc(dword_t disc_number,
|
dword_result_t XamSwapDisc_entry(
|
||||||
pointer_t<X_KEVENT> completion_handle,
|
dword_t disc_number, pointer_t<X_KEVENT> completion_handle,
|
||||||
pointer_t<X_SWAPDISC_ERROR_MESSAGE> error_message) {
|
pointer_t<X_SWAPDISC_ERROR_MESSAGE> error_message) {
|
||||||
|
|
||||||
xex2_opt_execution_info* info = nullptr;
|
xex2_opt_execution_info* info = nullptr;
|
||||||
|
|
|
@ -555,7 +555,7 @@ uint32_t Memory::SystemHeapAlloc(uint32_t size, uint32_t alignment,
|
||||||
uint32_t address;
|
uint32_t address;
|
||||||
if (!heap->AllocSystemHeap(
|
if (!heap->AllocSystemHeap(
|
||||||
size, alignment, kMemoryAllocationReserve | kMemoryAllocationCommit,
|
size, alignment, kMemoryAllocationReserve | kMemoryAllocationCommit,
|
||||||
kMemoryProtectRead | kMemoryProtectWrite, false, &address)) {
|
kMemoryProtectRead | kMemoryProtectWrite, true, &address)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
Zero(address, size);
|
Zero(address, size);
|
||||||
|
@ -823,10 +823,14 @@ bool BaseHeap::Alloc(uint32_t size, uint32_t alignment,
|
||||||
*out_address = 0;
|
*out_address = 0;
|
||||||
size = xe::round_up(size, page_size_);
|
size = xe::round_up(size, page_size_);
|
||||||
alignment = xe::round_up(alignment, page_size_);
|
alignment = xe::round_up(alignment, page_size_);
|
||||||
|
uint32_t heap_virtual_guest_offset = 0;
|
||||||
|
if (heap_type_ == HeapType::kGuestVirtual) {
|
||||||
|
heap_virtual_guest_offset = 0x10000000;
|
||||||
|
}
|
||||||
|
|
||||||
uint32_t low_address = heap_base_;
|
uint32_t low_address = heap_base_;
|
||||||
uint32_t high_address =
|
uint32_t high_address =
|
||||||
heap_base_ + (heap_size_ - 1) -
|
heap_base_ + (heap_size_ - 1) - heap_virtual_guest_offset;
|
||||||
(heap_type_ == HeapType::kGuestVirtual ? 0x10000000 : 0);
|
|
||||||
return AllocRange(low_address, high_address, size, alignment, allocation_type,
|
return AllocRange(low_address, high_address, size, alignment, allocation_type,
|
||||||
protect, top_down, out_address);
|
protect, top_down, out_address);
|
||||||
}
|
}
|
||||||
|
@ -1523,6 +1527,12 @@ bool PhysicalHeap::AllocRange(uint32_t low_address, uint32_t high_address,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool PhysicalHeap::AllocSystemHeap(uint32_t size, uint32_t alignment,
|
||||||
|
uint32_t allocation_type, uint32_t protect,
|
||||||
|
bool top_down, uint32_t* out_address) {
|
||||||
|
return Alloc(size, alignment, allocation_type, protect, top_down, out_address);
|
||||||
|
}
|
||||||
|
|
||||||
bool PhysicalHeap::Decommit(uint32_t address, uint32_t size) {
|
bool PhysicalHeap::Decommit(uint32_t address, uint32_t size) {
|
||||||
auto global_lock = global_critical_region_.Acquire();
|
auto global_lock = global_critical_region_.Acquire();
|
||||||
|
|
||||||
|
|
|
@ -165,6 +165,9 @@ class BaseHeap {
|
||||||
uint32_t allocation_type, uint32_t protect,
|
uint32_t allocation_type, uint32_t protect,
|
||||||
bool top_down, uint32_t* out_address);
|
bool top_down, uint32_t* out_address);
|
||||||
|
|
||||||
|
virtual bool AllocSystemHeap(uint32_t size, uint32_t alignment,
|
||||||
|
uint32_t allocation_type, uint32_t protect,
|
||||||
|
bool top_down, uint32_t* out_address);
|
||||||
// Decommits pages in the given range.
|
// Decommits pages in the given range.
|
||||||
// Partial overlapping pages will also be decommitted.
|
// Partial overlapping pages will also be decommitted.
|
||||||
virtual bool Decommit(uint32_t address, uint32_t size);
|
virtual bool Decommit(uint32_t address, uint32_t size);
|
||||||
|
@ -255,6 +258,9 @@ class PhysicalHeap : public BaseHeap {
|
||||||
uint32_t alignment, uint32_t allocation_type,
|
uint32_t alignment, uint32_t allocation_type,
|
||||||
uint32_t protect, bool top_down,
|
uint32_t protect, bool top_down,
|
||||||
uint32_t* out_address) override;
|
uint32_t* out_address) override;
|
||||||
|
bool AllocSystemHeap(uint32_t size, uint32_t alignment,
|
||||||
|
uint32_t allocation_type, uint32_t protect,
|
||||||
|
bool top_down, uint32_t* out_address) override;
|
||||||
bool Decommit(uint32_t address, uint32_t size) override;
|
bool Decommit(uint32_t address, uint32_t size) override;
|
||||||
bool Release(uint32_t base_address,
|
bool Release(uint32_t base_address,
|
||||||
uint32_t* out_region_size = nullptr) override;
|
uint32_t* out_region_size = nullptr) override;
|
||||||
|
|
Loading…
Reference in New Issue