From cf9d6c6f526fffb2bf414ff774c5d0281a73ecf4 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sat, 29 Sep 2018 18:47:00 -0400 Subject: kernel/process: Make data member variables private Makes the public interface consistent in terms of how accesses are done on a process object. It also makes it slightly nicer to reason about the logic of the process class, as we don't want to expose everything to external code. --- src/core/hle/kernel/process.h | 97 +++++++++++++++++++++++++++++++------------ 1 file changed, 71 insertions(+), 26 deletions(-) (limited to 'src/core/hle/kernel/process.h') diff --git a/src/core/hle/kernel/process.h b/src/core/hle/kernel/process.h index adb03c228..2dfb88fa9 100644 --- a/src/core/hle/kernel/process.h +++ b/src/core/hle/kernel/process.h @@ -135,6 +135,16 @@ public: return HANDLE_TYPE; } + /// Gets a reference to the process' memory manager. + Kernel::VMManager& VMManager() { + return vm_manager; + } + + /// Gets a const reference to the process' memory manager. + const Kernel::VMManager& VMManager() const { + return vm_manager; + } + /// Gets the current status of the process ProcessStatus GetStatus() const { return status; @@ -145,6 +155,40 @@ public: return process_id; } + /// Gets the title ID corresponding to this process. + u64 GetTitleID() const { + return program_id; + } + + /// Gets the resource limit descriptor for this process + ResourceLimit& GetResourceLimit() { + return *resource_limit; + } + + /// Gets the resource limit descriptor for this process + const ResourceLimit& GetResourceLimit() const { + return *resource_limit; + } + + /// Gets the default CPU ID for this process + u8 GetDefaultProcessorID() const { + return ideal_processor; + } + + /// Gets the bitmask of allowed CPUs that this process' threads can run on. + u32 GetAllowedProcessorMask() const { + return allowed_processor_mask; + } + + /// Gets the bitmask of allowed thread priorities. + u32 GetAllowedThreadPriorityMask() const { + return allowed_thread_priority_mask; + } + + u32 IsVirtualMemoryEnabled() const { + return is_virtual_address_memory_enabled; + } + /** * Loads process-specifics configuration info with metadata provided * by an executable. @@ -153,30 +197,6 @@ public: */ void LoadFromMetadata(const FileSys::ProgramMetadata& metadata); - /// Title ID corresponding to the process - u64 program_id; - - /// Resource limit descriptor for this process - SharedPtr resource_limit; - - /// The process may only call SVCs which have the corresponding bit set. - std::bitset<0x80> svc_access_mask; - /// Maximum size of the handle table for the process. - unsigned int handle_table_size = 0x200; - /// Special memory ranges mapped into this processes address space. This is used to give - /// processes access to specific I/O regions and device memory. - boost::container::static_vector address_mappings; - ProcessFlags flags; - /// Kernel compatibility version for this process - u16 kernel_version = 0; - /// The default CPU for this process, threads are scheduled on this cpu by default. - u8 ideal_processor = 0; - /// Bitmask of allowed CPUs that this process' threads can run on. TODO(Subv): Actually parse - /// this value from the process header. - u32 allowed_processor_mask = THREADPROCESSORID_DEFAULT_MASK; - u32 allowed_thread_priority_mask = 0xFFFFFFFF; - u32 is_virtual_address_memory_enabled = 0; - /** * Parses a list of kernel capability descriptors (as found in the ExHeader) and applies them * to this process. @@ -212,18 +232,43 @@ public: ResultCode UnmapMemory(VAddr dst_addr, VAddr src_addr, u64 size); - VMManager vm_manager; - private: explicit Process(KernelCore& kernel); ~Process() override; + /// Memory manager for this process. + Kernel::VMManager vm_manager; + /// Current status of the process ProcessStatus status; /// The ID of this process u32 process_id = 0; + /// Title ID corresponding to the process + u64 program_id; + + /// Resource limit descriptor for this process + SharedPtr resource_limit; + + /// The process may only call SVCs which have the corresponding bit set. + std::bitset<0x80> svc_access_mask; + /// Maximum size of the handle table for the process. + u32 handle_table_size = 0x200; + /// Special memory ranges mapped into this processes address space. This is used to give + /// processes access to specific I/O regions and device memory. + boost::container::static_vector address_mappings; + ProcessFlags flags; + /// Kernel compatibility version for this process + u16 kernel_version = 0; + /// The default CPU for this process, threads are scheduled on this cpu by default. + u8 ideal_processor = 0; + /// Bitmask of allowed CPUs that this process' threads can run on. TODO(Subv): Actually parse + /// this value from the process header. + u32 allowed_processor_mask = THREADPROCESSORID_DEFAULT_MASK; + u32 allowed_thread_priority_mask = 0xFFFFFFFF; + u32 is_virtual_address_memory_enabled = 0; + // Memory used to back the allocations in the regular heap. A single vector is used to cover // the entire virtual address space extents that bound the allocations, including any holes. // This makes deallocation and reallocation of holes fast and keeps process memory contiguous -- cgit v1.2.3