mirror of
				https://github.com/PabloMK7/citra.git
				synced 2025-10-30 05:10:03 +00:00 
			
		
		
		
	Kernel: change owner_process in Thread/SharedMemory to raw pointer
Otherwise circular ownership would form in Process->handle_table->thread->owner_process
This commit is contained in:
		
							parent
							
								
									8d32843d68
								
							
						
					
					
						commit
						e5c5d1ecce
					
				
					 6 changed files with 11 additions and 12 deletions
				
			
		|  | @ -102,7 +102,7 @@ public: | ||||||
|      */ |      */ | ||||||
|     ResultVal<SharedPtr<Thread>> CreateThread(std::string name, VAddr entry_point, u32 priority, |     ResultVal<SharedPtr<Thread>> CreateThread(std::string name, VAddr entry_point, u32 priority, | ||||||
|                                               u32 arg, s32 processor_id, VAddr stack_top, |                                               u32 arg, s32 processor_id, VAddr stack_top, | ||||||
|                                               SharedPtr<Process> owner_process); |                                               Process* owner_process); | ||||||
| 
 | 
 | ||||||
|     /**
 |     /**
 | ||||||
|      * Creates a semaphore. |      * Creates a semaphore. | ||||||
|  | @ -156,7 +156,7 @@ public: | ||||||
|      * linear heap. |      * linear heap. | ||||||
|      * @param name Optional object name, used for debugging purposes. |      * @param name Optional object name, used for debugging purposes. | ||||||
|      */ |      */ | ||||||
|     SharedPtr<SharedMemory> CreateSharedMemory(SharedPtr<Process> owner_process, u32 size, |     SharedPtr<SharedMemory> CreateSharedMemory(Process* owner_process, u32 size, | ||||||
|                                                MemoryPermission permissions, |                                                MemoryPermission permissions, | ||||||
|                                                MemoryPermission other_permissions, |                                                MemoryPermission other_permissions, | ||||||
|                                                VAddr address = 0, |                                                VAddr address = 0, | ||||||
|  |  | ||||||
|  | @ -14,7 +14,7 @@ namespace Kernel { | ||||||
| SharedMemory::SharedMemory(KernelSystem& kernel) : Object(kernel) {} | SharedMemory::SharedMemory(KernelSystem& kernel) : Object(kernel) {} | ||||||
| SharedMemory::~SharedMemory() {} | SharedMemory::~SharedMemory() {} | ||||||
| 
 | 
 | ||||||
| SharedPtr<SharedMemory> KernelSystem::CreateSharedMemory(SharedPtr<Process> owner_process, u32 size, | SharedPtr<SharedMemory> KernelSystem::CreateSharedMemory(Process* owner_process, u32 size, | ||||||
|                                                          MemoryPermission permissions, |                                                          MemoryPermission permissions, | ||||||
|                                                          MemoryPermission other_permissions, |                                                          MemoryPermission other_permissions, | ||||||
|                                                          VAddr address, MemoryRegion region, |                                                          VAddr address, MemoryRegion region, | ||||||
|  |  | ||||||
|  | @ -58,7 +58,7 @@ public: | ||||||
|     u8* GetPointer(u32 offset = 0); |     u8* GetPointer(u32 offset = 0); | ||||||
| 
 | 
 | ||||||
|     /// Process that created this shared memory block.
 |     /// Process that created this shared memory block.
 | ||||||
|     SharedPtr<Process> owner_process; |     Process* owner_process; | ||||||
|     /// Address of shared memory block in the owner process if specified.
 |     /// Address of shared memory block in the owner process if specified.
 | ||||||
|     VAddr base_address; |     VAddr base_address; | ||||||
|     /// Physical address of the shared memory block in the linear heap if no address was specified
 |     /// Physical address of the shared memory block in the linear heap if no address was specified
 | ||||||
|  |  | ||||||
|  | @ -785,9 +785,9 @@ static ResultCode CreateThread(Handle* out_handle, u32 priority, u32 entry_point | ||||||
|         break; |         break; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     CASCADE_RESULT(SharedPtr<Thread> thread, |     CASCADE_RESULT(SharedPtr<Thread> thread, Core::System::GetInstance().Kernel().CreateThread( | ||||||
|                    Core::System::GetInstance().Kernel().CreateThread( |                                                  name, entry_point, priority, arg, processor_id, | ||||||
|                        name, entry_point, priority, arg, processor_id, stack_top, current_process)); |                                                  stack_top, current_process.get())); | ||||||
| 
 | 
 | ||||||
|     thread->context->SetFpscr(FPSCR_DEFAULT_NAN | FPSCR_FLUSH_TO_ZERO | |     thread->context->SetFpscr(FPSCR_DEFAULT_NAN | FPSCR_FLUSH_TO_ZERO | | ||||||
|                               FPSCR_ROUND_TOZERO); // 0x03C00000
 |                               FPSCR_ROUND_TOZERO); // 0x03C00000
 | ||||||
|  | @ -1157,7 +1157,7 @@ static ResultCode CreateMemoryBlock(Handle* out_handle, u32 addr, u32 size, u32 | ||||||
|         region = current_process->flags.memory_region; |         region = current_process->flags.memory_region; | ||||||
| 
 | 
 | ||||||
|     shared_memory = Core::System::GetInstance().Kernel().CreateSharedMemory( |     shared_memory = Core::System::GetInstance().Kernel().CreateSharedMemory( | ||||||
|         current_process, size, static_cast<MemoryPermission>(my_permission), |         current_process.get(), size, static_cast<MemoryPermission>(my_permission), | ||||||
|         static_cast<MemoryPermission>(other_permission), addr, region); |         static_cast<MemoryPermission>(other_permission), addr, region); | ||||||
|     CASCADE_RESULT(*out_handle, current_process->handle_table.Create(std::move(shared_memory))); |     CASCADE_RESULT(*out_handle, current_process->handle_table.Create(std::move(shared_memory))); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -320,8 +320,7 @@ static void ResetThreadContext(const std::unique_ptr<ARM_Interface::ThreadContex | ||||||
| 
 | 
 | ||||||
| ResultVal<SharedPtr<Thread>> KernelSystem::CreateThread(std::string name, VAddr entry_point, | ResultVal<SharedPtr<Thread>> KernelSystem::CreateThread(std::string name, VAddr entry_point, | ||||||
|                                                         u32 priority, u32 arg, s32 processor_id, |                                                         u32 priority, u32 arg, s32 processor_id, | ||||||
|                                                         VAddr stack_top, |                                                         VAddr stack_top, 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 > ThreadPrioLowest) { |     if (priority > ThreadPrioLowest) { | ||||||
|         LOG_ERROR(Kernel_SVC, "Invalid thread priority: {}", priority); |         LOG_ERROR(Kernel_SVC, "Invalid thread priority: {}", priority); | ||||||
|  | @ -447,7 +446,7 @@ SharedPtr<Thread> SetupMainThread(KernelSystem& kernel, u32 entry_point, u32 pri | ||||||
|     // Initialize new "main" thread
 |     // Initialize new "main" thread
 | ||||||
|     auto thread_res = |     auto thread_res = | ||||||
|         kernel.CreateThread("main", entry_point, priority, 0, owner_process->ideal_processor, |         kernel.CreateThread("main", entry_point, priority, 0, owner_process->ideal_processor, | ||||||
|                             Memory::HEAP_VADDR_END, owner_process); |                             Memory::HEAP_VADDR_END, owner_process.get()); | ||||||
| 
 | 
 | ||||||
|     SharedPtr<Thread> thread = std::move(thread_res).Unwrap(); |     SharedPtr<Thread> thread = std::move(thread_res).Unwrap(); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -189,7 +189,7 @@ public: | ||||||
|     /// Mutexes that this thread is currently waiting for.
 |     /// Mutexes that this thread is currently waiting for.
 | ||||||
|     boost::container::flat_set<SharedPtr<Mutex>> pending_mutexes; |     boost::container::flat_set<SharedPtr<Mutex>> pending_mutexes; | ||||||
| 
 | 
 | ||||||
|     SharedPtr<Process> owner_process; ///< Process that owns this thread
 |     Process* owner_process; ///< Process that owns this thread
 | ||||||
| 
 | 
 | ||||||
|     /// Objects that the thread is waiting on, in the same order as they were
 |     /// Objects that the thread is waiting on, in the same order as they were
 | ||||||
|     // passed to WaitSynchronization1/N.
 |     // passed to WaitSynchronization1/N.
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue