aboutsummaryrefslogtreecommitdiff
path: root/src/core/hle/kernel/process.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/hle/kernel/process.h')
-rw-r--r--src/core/hle/kernel/process.h76
1 files changed, 50 insertions, 26 deletions
diff --git a/src/core/hle/kernel/process.h b/src/core/hle/kernel/process.h
index 590e0c73d..8d2616c79 100644
--- a/src/core/hle/kernel/process.h
+++ b/src/core/hle/kernel/process.h
@@ -13,6 +13,7 @@
#include <boost/container/static_vector.hpp>
#include "common/bit_field.h"
#include "common/common_types.h"
+#include "core/hle/kernel/handle_table.h"
#include "core/hle/kernel/object.h"
#include "core/hle/kernel/thread.h"
#include "core/hle/kernel/vm_manager.h"
@@ -24,6 +25,7 @@ class ProgramMetadata;
namespace Kernel {
class KernelCore;
+class ResourceLimit;
struct AddressMapping {
// Address and size must be page-aligned
@@ -57,30 +59,33 @@ union ProcessFlags {
BitField<12, 1, u16> loaded_high; ///< Application loaded high (not at 0x00100000).
};
-enum class ProcessStatus { Created, Running, Exited };
-
-class ResourceLimit;
+/**
+ * Indicates the status of a Process instance.
+ *
+ * @note These match the values as used by kernel,
+ * so new entries should only be added if RE
+ * shows that a new value has been introduced.
+ */
+enum class ProcessStatus {
+ Created,
+ CreatedWithDebuggerAttached,
+ Running,
+ WaitingForDebuggerToAttach,
+ DebuggerAttached,
+ Exiting,
+ Exited,
+ DebugBreak,
+};
-struct CodeSet final : public Object {
+struct CodeSet final {
struct Segment {
std::size_t offset = 0;
VAddr addr = 0;
u32 size = 0;
};
- static SharedPtr<CodeSet> Create(KernelCore& kernel, std::string name);
-
- std::string GetTypeName() const override {
- return "CodeSet";
- }
- std::string GetName() const override {
- return name;
- }
-
- static const HandleType HANDLE_TYPE = HandleType::CodeSet;
- HandleType GetHandleType() const override {
- return HANDLE_TYPE;
- }
+ explicit CodeSet();
+ ~CodeSet();
Segment& CodeSegment() {
return segments[0];
@@ -109,14 +114,7 @@ struct CodeSet final : public Object {
std::shared_ptr<std::vector<u8>> memory;
std::array<Segment, 3> segments;
- VAddr entrypoint;
-
- /// Name of the process
- std::string name;
-
-private:
- explicit CodeSet(KernelCore& kernel);
- ~CodeSet() override;
+ VAddr entrypoint = 0;
};
class Process final : public Object {
@@ -145,6 +143,16 @@ public:
return vm_manager;
}
+ /// Gets a reference to the process' handle table.
+ HandleTable& GetHandleTable() {
+ return handle_table;
+ }
+
+ /// Gets a const reference to the process' handle table.
+ const HandleTable& GetHandleTable() const {
+ return handle_table;
+ }
+
/// Gets the current status of the process
ProcessStatus GetStatus() const {
return status;
@@ -194,6 +202,16 @@ public:
return is_64bit_process;
}
+ /// Gets the total running time of the process instance in ticks.
+ u64 GetCPUTimeTicks() const {
+ return total_process_running_time_ticks;
+ }
+
+ /// Updates the total running time, adding the given ticks to it.
+ void UpdateCPUTimeTicks(u64 ticks) {
+ total_process_running_time_ticks += ticks;
+ }
+
/**
* Loads process-specifics configuration info with metadata provided
* by an executable.
@@ -219,7 +237,7 @@ public:
*/
void PrepareForTermination();
- void LoadModule(SharedPtr<CodeSet> module_, VAddr base_addr);
+ void LoadModule(CodeSet module_, VAddr base_addr);
///////////////////////////////////////////////////////////////////////////////////////////////
// Memory Management
@@ -297,6 +315,12 @@ private:
/// specified by metadata provided to the process during loading.
bool is_64bit_process = true;
+ /// Total running time for the process in ticks.
+ u64 total_process_running_time_ticks = 0;
+
+ /// Per-process handle table for storing created object handles in.
+ HandleTable handle_table;
+
std::string name;
};