From 68e29b56b6f34a21609ad36c65433b3809987ea6 Mon Sep 17 00:00:00 2001 From: fincs Date: Mon, 10 Aug 2020 21:54:13 +0200 Subject: [PATCH] kern: add stubbed KDevicePageTable implementation for systems without iommu --- .../generic/kern_k_device_page_table.hpp | 47 +++++++++++++++++++ .../kern_select_device_page_table.hpp | 7 ++- .../svc/board/generic/svc_device_name.hpp | 26 ++++++++++ .../vapours/svc/svc_select_device_name.hpp | 5 +- 4 files changed, 83 insertions(+), 2 deletions(-) create mode 100644 libraries/libmesosphere/include/mesosphere/board/generic/kern_k_device_page_table.hpp create mode 100644 libraries/libvapours/include/vapours/svc/board/generic/svc_device_name.hpp diff --git a/libraries/libmesosphere/include/mesosphere/board/generic/kern_k_device_page_table.hpp b/libraries/libmesosphere/include/mesosphere/board/generic/kern_k_device_page_table.hpp new file mode 100644 index 000000000..e87148680 --- /dev/null +++ b/libraries/libmesosphere/include/mesosphere/board/generic/kern_k_device_page_table.hpp @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2018-2020 Atmosphère-NX + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#pragma once +#include +#include +#include +#include + +namespace ams::kern::board::generic { + + using KDeviceVirtualAddress = u64; + + class KDevicePageTable { + public: + constexpr KDevicePageTable() { /* ... */ } + + Result ALWAYS_INLINE Initialize(u64 space_address, u64 space_size) { return ams::kern::svc::ResultNotImplemented(); } + void ALWAYS_INLINE Finalize() { /* ... */ } + + Result ALWAYS_INLINE Attach(ams::svc::DeviceName device_name, u64 space_address, u64 space_size) { return ams::kern::svc::ResultNotImplemented(); } + Result ALWAYS_INLINE Detach(ams::svc::DeviceName device_name) { return ams::kern::svc::ResultNotImplemented(); } + + Result ALWAYS_INLINE Map(size_t *out_mapped_size, const KPageGroup &pg, KDeviceVirtualAddress device_address, ams::svc::MemoryPermission device_perm, bool refresh_mappings) { return ams::kern::svc::ResultNotImplemented(); } + Result ALWAYS_INLINE Unmap(const KPageGroup &pg, KDeviceVirtualAddress device_address) { return ams::kern::svc::ResultNotImplemented(); } + public: + static ALWAYS_INLINE void Initialize() { /* ... */ } + + static ALWAYS_INLINE void Lock() { /* ... */ } + static ALWAYS_INLINE void Unlock() { /* ... */ } + static ALWAYS_INLINE void Sleep() { /* ... */ } + static ALWAYS_INLINE void Wakeup() { /* ... */ } + }; + +} \ No newline at end of file diff --git a/libraries/libmesosphere/include/mesosphere/kern_select_device_page_table.hpp b/libraries/libmesosphere/include/mesosphere/kern_select_device_page_table.hpp index 51e4db302..6557c991e 100644 --- a/libraries/libmesosphere/include/mesosphere/kern_select_device_page_table.hpp +++ b/libraries/libmesosphere/include/mesosphere/kern_select_device_page_table.hpp @@ -24,5 +24,10 @@ } #else - #error "Unknown board for KDevicePageTable" + #include + + namespace ams::kern { + using ams::kern::board::generic::KDevicePageTable; + } + #endif diff --git a/libraries/libvapours/include/vapours/svc/board/generic/svc_device_name.hpp b/libraries/libvapours/include/vapours/svc/board/generic/svc_device_name.hpp new file mode 100644 index 000000000..4de1ba2bd --- /dev/null +++ b/libraries/libvapours/include/vapours/svc/board/generic/svc_device_name.hpp @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2018-2020 Atmosphère-NX + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#pragma once +#include + +namespace ams::svc::board::generic { + + enum DeviceName { + /* If there is no smmu, there are no device names. */ + DeviceName_Count = 0, + }; + +} diff --git a/libraries/libvapours/include/vapours/svc/svc_select_device_name.hpp b/libraries/libvapours/include/vapours/svc/svc_select_device_name.hpp index 5435c6b93..5db94155c 100644 --- a/libraries/libvapours/include/vapours/svc/svc_select_device_name.hpp +++ b/libraries/libvapours/include/vapours/svc/svc_select_device_name.hpp @@ -26,6 +26,9 @@ #else - #error "Unknown board for svc::DeviceName" + #include + namespace ams::svc { + using namespace ams::svc::board::generic; + } #endif