summaryrefslogtreecommitdiffstats
path: root/src/core/hle/kernel/code_set.h
diff options
context:
space:
mode:
authorLioncash <mathew1800@gmail.com>2019-03-20 17:40:09 +0100
committerLioncash <mathew1800@gmail.com>2019-03-20 18:07:04 +0100
commit1b6bd9d6dff81666d15e193c9589ddb2eb7cbb93 (patch)
tree3e133530a2ba4fe509c084d579bdd186b6525169 /src/core/hle/kernel/code_set.h
parentMerge pull request #2264 from lioncash/linker (diff)
downloadyuzu-1b6bd9d6dff81666d15e193c9589ddb2eb7cbb93.tar
yuzu-1b6bd9d6dff81666d15e193c9589ddb2eb7cbb93.tar.gz
yuzu-1b6bd9d6dff81666d15e193c9589ddb2eb7cbb93.tar.bz2
yuzu-1b6bd9d6dff81666d15e193c9589ddb2eb7cbb93.tar.lz
yuzu-1b6bd9d6dff81666d15e193c9589ddb2eb7cbb93.tar.xz
yuzu-1b6bd9d6dff81666d15e193c9589ddb2eb7cbb93.tar.zst
yuzu-1b6bd9d6dff81666d15e193c9589ddb2eb7cbb93.zip
Diffstat (limited to 'src/core/hle/kernel/code_set.h')
-rw-r--r--src/core/hle/kernel/code_set.h90
1 files changed, 90 insertions, 0 deletions
diff --git a/src/core/hle/kernel/code_set.h b/src/core/hle/kernel/code_set.h
new file mode 100644
index 000000000..834fd23d2
--- /dev/null
+++ b/src/core/hle/kernel/code_set.h
@@ -0,0 +1,90 @@
+// Copyright 2019 yuzu emulator team
+// Licensed under GPLv2 or any later version
+// Refer to the license.txt file included.
+
+#pragma once
+
+#include <cstddef>
+#include <memory>
+#include <vector>
+
+#include "common/common_types.h"
+
+namespace Kernel {
+
+/**
+ * Represents executable data that may be loaded into a kernel process.
+ *
+ * A code set consists of three basic segments:
+ * - A code (AKA text) segment,
+ * - A read-only data segment (rodata)
+ * - A data segment
+ *
+ * The code segment is the portion of the object file that contains
+ * executable instructions.
+ *
+ * The read-only data segment in the portion of the object file that
+ * contains (as one would expect) read-only data, such as fixed constant
+ * values and data structures.
+ *
+ * The data segment is similar to the read-only data segment -- it contains
+ * variables and data structures that have predefined values, however,
+ * entities within this segment can be modified.
+ */
+struct CodeSet final {
+ /// A single segment within a code set.
+ struct Segment final {
+ /// The byte offset that this segment is located at.
+ std::size_t offset = 0;
+
+ /// The address to map this segment to.
+ VAddr addr = 0;
+
+ /// The size of this segment in bytes.
+ u32 size = 0;
+ };
+
+ explicit CodeSet();
+ ~CodeSet();
+
+ CodeSet(const CodeSet&) = delete;
+ CodeSet& operator=(const CodeSet&) = delete;
+
+ CodeSet(CodeSet&&) = default;
+ CodeSet& operator=(CodeSet&&) = default;
+
+ Segment& CodeSegment() {
+ return segments[0];
+ }
+
+ const Segment& CodeSegment() const {
+ return segments[0];
+ }
+
+ Segment& RODataSegment() {
+ return segments[1];
+ }
+
+ const Segment& RODataSegment() const {
+ return segments[1];
+ }
+
+ Segment& DataSegment() {
+ return segments[2];
+ }
+
+ const Segment& DataSegment() const {
+ return segments[2];
+ }
+
+ /// The overall data that backs this code set.
+ std::shared_ptr<std::vector<u8>> memory;
+
+ /// The segments that comprise this code set.
+ std::array<Segment, 3> segments;
+
+ /// The entry point address for this code set.
+ VAddr entrypoint = 0;
+};
+
+} // namespace Kernel