فهرست منبع

kernel/process_capability: Handle program capability flags

Lioncash 7 سال پیش
والد
کامیت
010bc677f3
3فایلهای تغییر یافته به همراه29 افزوده شده و 2 حذف شده
  1. 1 0
      src/core/hle/kernel/errors.h
  2. 8 1
      src/core/hle/kernel/process_capability.cpp
  3. 20 1
      src/core/hle/kernel/process_capability.h

+ 1 - 0
src/core/hle/kernel/errors.h

@@ -31,6 +31,7 @@ constexpr ResultCode ERR_NOT_FOUND{ErrorModule::Kernel, 121};
 constexpr ResultCode ERR_ALREADY_REGISTERED{ErrorModule::Kernel, 122};
 constexpr ResultCode ERR_ALREADY_REGISTERED{ErrorModule::Kernel, 122};
 constexpr ResultCode ERR_SESSION_CLOSED_BY_REMOTE{ErrorModule::Kernel, 123};
 constexpr ResultCode ERR_SESSION_CLOSED_BY_REMOTE{ErrorModule::Kernel, 123};
 constexpr ResultCode ERR_INVALID_STATE{ErrorModule::Kernel, 125};
 constexpr ResultCode ERR_INVALID_STATE{ErrorModule::Kernel, 125};
+constexpr ResultCode ERR_RESERVED_VALUE{ErrorModule::Kernel, 126};
 constexpr ResultCode ERR_RESOURCE_LIMIT_EXCEEDED{ErrorModule::Kernel, 132};
 constexpr ResultCode ERR_RESOURCE_LIMIT_EXCEEDED{ErrorModule::Kernel, 132};
 
 
 } // namespace Kernel
 } // namespace Kernel

+ 8 - 1
src/core/hle/kernel/process_capability.cpp

@@ -200,6 +200,8 @@ void ProcessCapabilities::Clear() {
     handle_table_size = 0;
     handle_table_size = 0;
     kernel_version = 0;
     kernel_version = 0;
 
 
+    program_type = ProgramType::SysModule;
+
     is_debuggable = false;
     is_debuggable = false;
     can_force_debug = false;
     can_force_debug = false;
 }
 }
@@ -303,7 +305,12 @@ ResultCode ProcessCapabilities::HandleInterruptFlags(u32 flags) {
 }
 }
 
 
 ResultCode ProcessCapabilities::HandleProgramTypeFlags(u32 flags) {
 ResultCode ProcessCapabilities::HandleProgramTypeFlags(u32 flags) {
-    // TODO: Implement
+    const u32 reserved = flags >> 17;
+    if (reserved != 0) {
+        return ERR_RESERVED_VALUE;
+    }
+
+    program_type = static_cast<ProgramType>((flags >> 14) & 0b111);
     return RESULT_SUCCESS;
     return RESULT_SUCCESS;
 }
 }
 
 

+ 20 - 1
src/core/hle/kernel/process_capability.h

@@ -14,6 +14,14 @@ namespace Kernel {
 
 
 class VMManager;
 class VMManager;
 
 
+/// The possible types of programs that may be indicated
+/// by the program type capability descriptor.
+enum class ProgramType {
+    SysModule,
+    Application,
+    Applet,
+};
+
 /// Handles kernel capability descriptors that are provided by
 /// Handles kernel capability descriptors that are provided by
 /// application metadata. These descriptors provide information
 /// application metadata. These descriptors provide information
 /// that alters certain parameters for kernel process instance
 /// that alters certain parameters for kernel process instance
@@ -137,6 +145,16 @@ public:
         return svc_capabilities;
         return svc_capabilities;
     }
     }
 
 
+    /// Gets the valid interrupt bits.
+    const InterruptCapabilities& GetInterruptCapabilities() const {
+        return interrupt_capabilities;
+    }
+
+    /// Gets the program type for this process.
+    ProgramType GetProgramType() const {
+        return program_type;
+    }
+
 private:
 private:
     /// Attempts to parse a given sequence of capability descriptors.
     /// Attempts to parse a given sequence of capability descriptors.
     ///
     ///
@@ -215,7 +233,8 @@ private:
 
 
     u32 handle_table_size = 0;
     u32 handle_table_size = 0;
     u32 kernel_version = 0;
     u32 kernel_version = 0;
-    u32 program_type = 0;
+
+    ProgramType program_type = ProgramType::SysModule;
 
 
     bool is_debuggable = false;
     bool is_debuggable = false;
     bool can_force_debug = false;
     bool can_force_debug = false;