summaryrefslogtreecommitdiffstats
path: root/src/core/hle/kernel/k_device_address_space.h
diff options
context:
space:
mode:
authorLiam <byteslice@airmail.cc>2023-01-29 21:03:29 +0100
committerLiam <byteslice@airmail.cc>2023-02-01 23:18:21 +0100
commit7d1c3a3f59d4dd55c012bdd46d4ec092d141e814 (patch)
tree20dd32b3568c1c88081b6c81fba3765ff0d03362 /src/core/hle/kernel/k_device_address_space.h
parentMerge pull request #9696 from german77/please_forgive_me_for_this_sin (diff)
downloadyuzu-7d1c3a3f59d4dd55c012bdd46d4ec092d141e814.tar
yuzu-7d1c3a3f59d4dd55c012bdd46d4ec092d141e814.tar.gz
yuzu-7d1c3a3f59d4dd55c012bdd46d4ec092d141e814.tar.bz2
yuzu-7d1c3a3f59d4dd55c012bdd46d4ec092d141e814.tar.lz
yuzu-7d1c3a3f59d4dd55c012bdd46d4ec092d141e814.tar.xz
yuzu-7d1c3a3f59d4dd55c012bdd46d4ec092d141e814.tar.zst
yuzu-7d1c3a3f59d4dd55c012bdd46d4ec092d141e814.zip
Diffstat (limited to 'src/core/hle/kernel/k_device_address_space.h')
-rw-r--r--src/core/hle/kernel/k_device_address_space.h60
1 files changed, 60 insertions, 0 deletions
diff --git a/src/core/hle/kernel/k_device_address_space.h b/src/core/hle/kernel/k_device_address_space.h
new file mode 100644
index 000000000..4709df995
--- /dev/null
+++ b/src/core/hle/kernel/k_device_address_space.h
@@ -0,0 +1,60 @@
+// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#pragma once
+
+#include <string>
+
+#include "common/common_types.h"
+#include "core/hle/kernel/k_page_table.h"
+#include "core/hle/kernel/slab_helpers.h"
+#include "core/hle/result.h"
+
+namespace Kernel {
+
+class KDeviceAddressSpace final
+ : public KAutoObjectWithSlabHeapAndContainer<KDeviceAddressSpace, KAutoObjectWithList> {
+ KERNEL_AUTOOBJECT_TRAITS(KDeviceAddressSpace, KAutoObject);
+
+public:
+ explicit KDeviceAddressSpace(KernelCore& kernel);
+ ~KDeviceAddressSpace();
+
+ Result Initialize(u64 address, u64 size);
+ void Finalize();
+
+ bool IsInitialized() const {
+ return m_is_initialized;
+ }
+ static void PostDestroy(uintptr_t arg) {}
+
+ Result Attach(Svc::DeviceName device_name);
+ Result Detach(Svc::DeviceName device_name);
+
+ Result MapByForce(KPageTable* page_table, VAddr process_address, size_t size,
+ u64 device_address, u32 option) {
+ R_RETURN(this->Map(page_table, process_address, size, device_address, option, false));
+ }
+
+ Result MapAligned(KPageTable* page_table, VAddr process_address, size_t size,
+ u64 device_address, u32 option) {
+ R_RETURN(this->Map(page_table, process_address, size, device_address, option, true));
+ }
+
+ Result Unmap(KPageTable* page_table, VAddr process_address, size_t size, u64 device_address);
+
+ static void Initialize();
+
+private:
+ Result Map(KPageTable* page_table, VAddr process_address, size_t size, u64 device_address,
+ u32 option, bool is_aligned);
+
+private:
+ KLightLock m_lock;
+ // KDevicePageTable m_table;
+ u64 m_space_address{};
+ u64 m_space_size{};
+ bool m_is_initialized{};
+};
+
+} // namespace Kernel