diff options
author | bunnei <bunneidev@gmail.com> | 2023-02-03 04:00:23 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-03 04:00:23 +0100 |
commit | af20e25081f97d55b451606c87922e2b49f0d363 (patch) | |
tree | 8b305ea03e2f577782ac35f9b0a2edf719c1734d /src/core/hle/kernel/k_device_address_space.h | |
parent | Merge pull request #9708 from ameerj/gl-context-flush (diff) | |
parent | kernel: add KDeviceAddressSpace (diff) | |
download | yuzu-af20e25081f97d55b451606c87922e2b49f0d363.tar yuzu-af20e25081f97d55b451606c87922e2b49f0d363.tar.gz yuzu-af20e25081f97d55b451606c87922e2b49f0d363.tar.bz2 yuzu-af20e25081f97d55b451606c87922e2b49f0d363.tar.lz yuzu-af20e25081f97d55b451606c87922e2b49f0d363.tar.xz yuzu-af20e25081f97d55b451606c87922e2b49f0d363.tar.zst yuzu-af20e25081f97d55b451606c87922e2b49f0d363.zip |
Diffstat (limited to 'src/core/hle/kernel/k_device_address_space.h')
-rw-r--r-- | src/core/hle/kernel/k_device_address_space.h | 60 |
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 |