kernel: Various 64-bit fixes in memory/process/thread

This commit is contained in:
bunnei 2017-12-29 13:27:58 -05:00
parent 1d01ffccb8
commit ebd4b1422d
5 changed files with 14 additions and 14 deletions

View file

@ -13,9 +13,9 @@ namespace Kernel {
class VMManager; class VMManager;
struct MemoryRegionInfo { struct MemoryRegionInfo {
u32 base; // Not an address, but offset from start of FCRAM u64 base; // Not an address, but offset from start of FCRAM
u32 size; u64 size;
u32 used; u64 used;
std::shared_ptr<std::vector<u8>> linear_heap_memory; std::shared_ptr<std::vector<u8>> linear_heap_memory;
}; };

View file

@ -167,7 +167,7 @@ VAddr Process::GetLinearHeapLimit() const {
return GetLinearHeapBase() + memory_region->size; return GetLinearHeapBase() + memory_region->size;
} }
ResultVal<VAddr> Process::HeapAllocate(VAddr target, u32 size, VMAPermission perms) { ResultVal<VAddr> Process::HeapAllocate(VAddr target, u64 size, VMAPermission perms) {
if (target < Memory::HEAP_VADDR || target + size > Memory::HEAP_VADDR_END || if (target < Memory::HEAP_VADDR || target + size > Memory::HEAP_VADDR_END ||
target + size < target) { target + size < target) {
return ERR_INVALID_ADDRESS; return ERR_INVALID_ADDRESS;

View file

@ -19,7 +19,7 @@ namespace Kernel {
struct AddressMapping { struct AddressMapping {
// Address and size must be page-aligned // Address and size must be page-aligned
VAddr address; VAddr address;
u32 size; u64 size;
bool read_only; bool read_only;
bool unk_flag; bool unk_flag;
}; };
@ -154,7 +154,7 @@ public:
// The left/right bounds of the address space covered by heap_memory. // The left/right bounds of the address space covered by heap_memory.
VAddr heap_start = 0, heap_end = 0; VAddr heap_start = 0, heap_end = 0;
u32 heap_used = 0, linear_heap_used = 0, misc_memory_used = 0; u64 heap_used = 0, linear_heap_used = 0, misc_memory_used = 0;
MemoryRegionInfo* memory_region = nullptr; MemoryRegionInfo* memory_region = nullptr;
@ -171,7 +171,7 @@ public:
VAddr GetLinearHeapBase() const; VAddr GetLinearHeapBase() const;
VAddr GetLinearHeapLimit() const; VAddr GetLinearHeapLimit() const;
ResultVal<VAddr> HeapAllocate(VAddr target, u32 size, VMAPermission perms); ResultVal<VAddr> HeapAllocate(VAddr target, u64 size, VMAPermission perms);
ResultCode HeapFree(VAddr target, u32 size); ResultCode HeapFree(VAddr target, u32 size);
ResultVal<VAddr> LinearAllocate(VAddr target, u32 size, VMAPermission perms); ResultVal<VAddr> LinearAllocate(VAddr target, u32 size, VMAPermission perms);

View file

@ -103,8 +103,8 @@ void Thread::Stop() {
ReleaseThreadMutexes(this); ReleaseThreadMutexes(this);
// Mark the TLS slot in the thread's page as free. // Mark the TLS slot in the thread's page as free.
u32 tls_page = (tls_address - Memory::TLS_AREA_VADDR) / Memory::PAGE_SIZE; u64 tls_page = (tls_address - Memory::TLS_AREA_VADDR) / Memory::PAGE_SIZE;
u32 tls_slot = u64 tls_slot =
((tls_address - Memory::TLS_AREA_VADDR) % Memory::PAGE_SIZE) / Memory::TLS_ENTRY_SIZE; ((tls_address - Memory::TLS_AREA_VADDR) % Memory::PAGE_SIZE) / Memory::TLS_ENTRY_SIZE;
Kernel::g_current_process->tls_slots[tls_page].reset(tls_slot); Kernel::g_current_process->tls_slots[tls_page].reset(tls_slot);
} }
@ -184,7 +184,7 @@ static void SwitchContext(Thread* new_thread) {
} }
Core::CPU().LoadContext(new_thread->context); Core::CPU().LoadContext(new_thread->context);
Core::CPU().SetCP15Register(CP15_THREAD_URO, new_thread->GetTLSAddress()); Core::CPU().SetTlsAddress(new_thread->GetTLSAddress());
} else { } else {
current_thread = nullptr; current_thread = nullptr;
// Note: We do not reset the current process and current page table when idling because // Note: We do not reset the current process and current page table when idling because
@ -369,7 +369,7 @@ static void ResetThreadContext(ARM_Interface::ThreadContext& context, VAddr stac
} }
ResultVal<SharedPtr<Thread>> Thread::Create(std::string name, VAddr entry_point, u32 priority, ResultVal<SharedPtr<Thread>> Thread::Create(std::string name, VAddr entry_point, u32 priority,
u32 arg, s32 processor_id, VAddr stack_top, u64 arg, s32 processor_id, VAddr stack_top,
SharedPtr<Process> owner_process) { SharedPtr<Process> owner_process) {
// Check if priority is in ranged. Lowest priority -> highest priority id. // Check if priority is in ranged. Lowest priority -> highest priority id.
if (priority > THREADPRIO_LOWEST) { if (priority > THREADPRIO_LOWEST) {
@ -493,7 +493,7 @@ void Thread::BoostPriority(u32 priority) {
current_priority = priority; current_priority = priority;
} }
SharedPtr<Thread> SetupMainThread(u32 entry_point, u32 priority, SharedPtr<Process> owner_process) { SharedPtr<Thread> SetupMainThread(VAddr entry_point, u32 priority, SharedPtr<Process> owner_process) {
// Setup page table so we can write to memory // Setup page table so we can write to memory
SetCurrentPageTable(&Kernel::g_current_process->vm_manager.page_table); SetCurrentPageTable(&Kernel::g_current_process->vm_manager.page_table);

View file

@ -65,7 +65,7 @@ public:
* @return A shared pointer to the newly created thread * @return A shared pointer to the newly created thread
*/ */
static ResultVal<SharedPtr<Thread>> Create(std::string name, VAddr entry_point, u32 priority, static ResultVal<SharedPtr<Thread>> Create(std::string name, VAddr entry_point, u32 priority,
u32 arg, s32 processor_id, VAddr stack_top, u64 arg, s32 processor_id, VAddr stack_top,
SharedPtr<Process> owner_process); SharedPtr<Process> owner_process);
std::string GetName() const override { std::string GetName() const override {
@ -234,7 +234,7 @@ private:
* @param owner_process The parent process for the main thread * @param owner_process The parent process for the main thread
* @return A shared pointer to the main thread * @return A shared pointer to the main thread
*/ */
SharedPtr<Thread> SetupMainThread(u32 entry_point, u32 priority, SharedPtr<Process> owner_process); SharedPtr<Thread> SetupMainThread(VAddr entry_point, u32 priority, SharedPtr<Process> owner_process);
/** /**
* Returns whether there are any threads that are ready to run. * Returns whether there are any threads that are ready to run.