summaryrefslogtreecommitdiffstats
path: root/src/core/hle/service/nvdrv/devices/nvmap.h
diff options
context:
space:
mode:
authorSubv <subv2112@gmail.com>2018-01-09 16:41:13 +0100
committerbunnei <bunneidev@gmail.com>2018-01-11 05:28:40 +0100
commit1ca800cceecd3f37ad874e12fd657f6145ae13c7 (patch)
treed5c935b854585739970c9a7c2a6b9981e31fdeca /src/core/hle/service/nvdrv/devices/nvmap.h
parentVI: Use a Pulse event instead of OneShot for the vblank events. (diff)
downloadyuzu-1ca800cceecd3f37ad874e12fd657f6145ae13c7.tar
yuzu-1ca800cceecd3f37ad874e12fd657f6145ae13c7.tar.gz
yuzu-1ca800cceecd3f37ad874e12fd657f6145ae13c7.tar.bz2
yuzu-1ca800cceecd3f37ad874e12fd657f6145ae13c7.tar.lz
yuzu-1ca800cceecd3f37ad874e12fd657f6145ae13c7.tar.xz
yuzu-1ca800cceecd3f37ad874e12fd657f6145ae13c7.tar.zst
yuzu-1ca800cceecd3f37ad874e12fd657f6145ae13c7.zip
Diffstat (limited to '')
-rw-r--r--src/core/hle/service/nvdrv/devices/nvmap.h108
1 files changed, 108 insertions, 0 deletions
diff --git a/src/core/hle/service/nvdrv/devices/nvmap.h b/src/core/hle/service/nvdrv/devices/nvmap.h
new file mode 100644
index 000000000..e8b08f3fb
--- /dev/null
+++ b/src/core/hle/service/nvdrv/devices/nvmap.h
@@ -0,0 +1,108 @@
+// Copyright 2018 Citra Emulator Project
+// Licensed under GPLv2 or any later version
+// Refer to the license.txt file included.
+
+#pragma once
+
+#include <memory>
+#include <unordered_map>
+#include <vector>
+#include "common/common_funcs.h"
+#include "common/common_types.h"
+#include "common/swap.h"
+#include "core/hle/service/nvdrv/devices/nvdevice.h"
+
+namespace Service {
+namespace NVDRV {
+namespace Devices {
+
+class nvmap final : public nvdevice {
+public:
+ nvmap() = default;
+ ~nvmap() override = default;
+
+ /// Returns the allocated address of an nvmap object given its handle.
+ VAddr GetObjectAddress(u32 handle) const;
+
+ u32 ioctl(u32 command, const std::vector<u8>& input, std::vector<u8>& output) override;
+
+private:
+ // Represents an nvmap object.
+ struct Object {
+ enum class Status { Created, Allocated };
+ u32 id;
+ u32 size;
+ u32 flags;
+ u32 align;
+ u8 kind;
+ VAddr addr;
+ Status status;
+ };
+
+ /// Id to use for the next handle that is created.
+ u32 next_handle = 1;
+
+ // Id to use for the next object that is created.
+ u32 next_id = 1;
+
+ /// Mapping of currently allocated handles to the objects they represent.
+ std::unordered_map<u32, std::shared_ptr<Object>> handles;
+
+ enum IoctlCommands {
+ IocCreateCommand = 0xC0080101,
+ IocFromIdCommand = 0xC0080103,
+ IocAllocCommand = 0xC0200104,
+ IocParamCommand = 0xC00C0109,
+ IocGetIdCommand = 0xC008010E
+ };
+
+ struct IocCreateParams {
+ // Input
+ u32_le size;
+ // Output
+ u32_le handle;
+ };
+
+ struct IocAllocParams {
+ // Input
+ u32_le handle;
+ u32_le heap_mask;
+ u32_le flags;
+ u32_le align;
+ u8 kind;
+ INSERT_PADDING_BYTES(7);
+ u64_le addr;
+ };
+
+ struct IocGetIdParams {
+ // Output
+ u32_le id;
+ // Input
+ u32_le handle;
+ };
+
+ struct IocFromIdParams {
+ // Input
+ u32_le id;
+ // Output
+ u32_le handle;
+ };
+
+ struct IocParamParams {
+ // Input
+ u32_le handle;
+ u32_le type;
+ // Output
+ u32_le value;
+ };
+
+ u32 IocCreate(const std::vector<u8>& input, std::vector<u8>& output);
+ u32 IocAlloc(const std::vector<u8>& input, std::vector<u8>& output);
+ u32 IocGetId(const std::vector<u8>& input, std::vector<u8>& output);
+ u32 IocFromId(const std::vector<u8>& input, std::vector<u8>& output);
+ u32 IocParam(const std::vector<u8>& input, std::vector<u8>& output);
+};
+
+} // namespace Devices
+} // namespace NVDRV
+} // namespace Service