mirror of
https://github.com/Atmosphere-NX/Atmosphere
synced 2024-11-25 02:50:18 +00:00
htc: add htcfs server/service object skeletons
This commit is contained in:
parent
9fbbb9fadb
commit
870b45f208
17 changed files with 682 additions and 5 deletions
|
@ -15,3 +15,4 @@
|
|||
*/
|
||||
#pragma once
|
||||
|
||||
#include <stratosphere/htcfs/htcfs_hipc_server.hpp>
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#pragma once
|
||||
#include <vapours.hpp>
|
||||
|
||||
namespace ams::htclow {
|
||||
|
||||
class HtclowManager;
|
||||
|
||||
}
|
||||
|
||||
namespace ams::htcfs {
|
||||
|
||||
void Initialize(htclow::HtclowManager *htclow_manager);
|
||||
|
||||
void RegisterHipcServer();
|
||||
void LoopHipcServer();
|
||||
|
||||
}
|
|
@ -37,3 +37,22 @@
|
|||
AMS_SF_METHOD_INFO(C, H, 13, Result, GetDiskFreeSpaceExW, (sf::Out<s64> out_free, sf::Out<s64> out_total, sf::Out<s64> out_total_free, const tma::Path &path), (out_free, out_total, out_total_free, path))
|
||||
|
||||
AMS_SF_DEFINE_INTERFACE(ams::tma, IFileManager, AMS_TMA_I_FILE_MANAGER_INTERFACE_INFO)
|
||||
|
||||
/* Prior to system version 6.0.0, case sensitivity was not parameterized. */
|
||||
#define AMS_TMA_I_DEPRECATED_FILE_MANAGER_INTERFACE_INFO(C, H) \
|
||||
AMS_SF_METHOD_INFO(C, H, 0, Result, OpenFile, (sf::Out<sf::SharedPointer<tma::IFileAccessor>> out, const tma::Path &path), (out, path)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 1, Result, FileExists, (sf::Out<bool> out, const tma::Path &path), (out, path)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 2, Result, DeleteFile, (const tma::Path &path), (path)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 3, Result, RenameFile, (const tma::Path &old_path, const tma::Path &new_path), (old_path, new_path)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 4, Result, GetIOType, (sf::Out<s32> out, const tma::Path &path), (out, path)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 5, Result, OpenDirectory, (sf::Out<sf::SharedPointer<tma::IDirectoryAccessor>> out, const tma::Path &path), (out, path)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 6, Result, DirectoryExists, (sf::Out<bool> out, const tma::Path &path), (out, path)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 7, Result, CreateDirectory, (const tma::Path &path), (path)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 8, Result, DeleteDirectory, (const tma::Path &path), (path)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 9, Result, RenameDirectory, (const tma::Path &old_path, const tma::Path &new_path), (old_path, new_path)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 10, Result, CreateFile, (const tma::Path &path, s64 size), (path, size)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 11, Result, GetFileTimeStamp, (sf::Out<u64> out_create, sf::Out<u64> out_access, sf::Out<u64> out_modify, const tma::Path &path), (out_create, out_access, out_modify, path)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 12, Result, GetCaseSensitivePath, (const tma::Path &path, const sf::OutBuffer &out), (path, out)) \
|
||||
AMS_SF_METHOD_INFO(C, H, 13, Result, GetDiskFreeSpaceExW, (sf::Out<s64> out_free, sf::Out<s64> out_total, sf::Out<s64> out_total_free, const tma::Path &path), (out_free, out_total, out_total_free, path))
|
||||
|
||||
AMS_SF_DEFINE_INTERFACE(ams::tma, IDeprecatedFileManager, AMS_TMA_I_DEPRECATED_FILE_MANAGER_INTERFACE_INFO)
|
||||
|
|
103
libraries/libstratosphere/source/htcfs/htcfs_cache_manager.hpp
Normal file
103
libraries/libstratosphere/source/htcfs/htcfs_cache_manager.hpp
Normal file
|
@ -0,0 +1,103 @@
|
|||
/*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#pragma once
|
||||
#include <stratosphere.hpp>
|
||||
|
||||
namespace ams::htcfs {
|
||||
|
||||
class CacheManager {
|
||||
private:
|
||||
os::SdkMutex m_mutex;
|
||||
void *m_cache;
|
||||
size_t m_cache_size;
|
||||
s64 m_cached_file_size;
|
||||
size_t m_cached_data_size;
|
||||
s32 m_cached_handle;
|
||||
bool m_has_cached_handle;
|
||||
public:
|
||||
CacheManager(void *cache, size_t cache_size) : m_mutex(), m_cache(cache), m_cache_size(cache_size), m_cached_file_size(), m_cached_data_size(), m_cached_handle(), m_has_cached_handle() { /* ... */ }
|
||||
public:
|
||||
bool GetFileSize(s64 *out, s32 handle) {
|
||||
/* Lock ourselves. */
|
||||
std::scoped_lock lk(m_mutex);
|
||||
|
||||
/* Get the cached size, if we match. */
|
||||
if (m_has_cached_handle && m_cached_handle == handle) {
|
||||
*out = m_cached_file_size;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void Invalidate() {
|
||||
/* Lock ourselves. */
|
||||
std::scoped_lock lk(m_mutex);
|
||||
|
||||
/* Note that we have no handle. */
|
||||
m_has_cached_handle = false;
|
||||
}
|
||||
|
||||
void Record(s64 file_size, const void *data, s32 handle, size_t data_size) {
|
||||
/* Lock ourselves. */
|
||||
std::scoped_lock lk(m_mutex);
|
||||
|
||||
/* Set our cached file size. */
|
||||
m_cached_file_size = file_size;
|
||||
|
||||
/* Set our cached data size. */
|
||||
m_cached_data_size = std::min(m_cache_size, data_size);
|
||||
|
||||
/* Copy the data. */
|
||||
std::memcpy(m_cache, data, m_cached_data_size);
|
||||
|
||||
/* Set our cache handle. */
|
||||
m_cached_handle = handle;
|
||||
|
||||
/* Note that we have cached data. */
|
||||
m_has_cached_handle = true;
|
||||
}
|
||||
|
||||
bool ReadFile(size_t *out, void *dst, s32 handle, size_t offset, size_t size) {
|
||||
/* Lock ourselves. */
|
||||
std::scoped_lock lk(m_mutex);
|
||||
|
||||
/* Check that we have a cached file. */
|
||||
if (!m_has_cached_handle) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Check the file is our cached one. */
|
||||
if (handle != m_cached_handle) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Check that we can read data. */
|
||||
if (offset + size > m_cached_data_size) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Copy the cached data. */
|
||||
std::memcpy(dst, static_cast<const u8 *>(m_cache) + offset, size);
|
||||
|
||||
/* Set the output read size. */
|
||||
*out = size;
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
47
libraries/libstratosphere/source/htcfs/htcfs_client.cpp
Normal file
47
libraries/libstratosphere/source/htcfs/htcfs_client.cpp
Normal file
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include <stratosphere.hpp>
|
||||
#include "htcfs_client.hpp"
|
||||
|
||||
namespace ams::htcfs {
|
||||
|
||||
namespace {
|
||||
|
||||
constinit TYPED_STORAGE(Client) g_client_storage;
|
||||
constinit bool g_initialized;
|
||||
|
||||
}
|
||||
|
||||
void InitializeClient(htclow::HtclowManager *manager) {
|
||||
AMS_ASSERT(!g_initialized);
|
||||
|
||||
std::construct_at(GetPointer(g_client_storage), manager);
|
||||
}
|
||||
|
||||
void FinalizeClient() {
|
||||
AMS_ASSERT(g_initialized);
|
||||
|
||||
std::destroy_at(GetPointer(g_client_storage));
|
||||
}
|
||||
|
||||
Client &GetClient() {
|
||||
AMS_ASSERT(g_initialized);
|
||||
|
||||
return GetReference(g_client_storage);
|
||||
}
|
||||
|
||||
|
||||
}
|
34
libraries/libstratosphere/source/htcfs/htcfs_client.hpp
Normal file
34
libraries/libstratosphere/source/htcfs/htcfs_client.hpp
Normal file
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#pragma once
|
||||
#include <stratosphere.hpp>
|
||||
#include "htcfs_client_impl.hpp"
|
||||
|
||||
namespace ams::htcfs {
|
||||
|
||||
class Client {
|
||||
private:
|
||||
ClientImpl m_impl;
|
||||
public:
|
||||
Client(htclow::HtclowManager *manager);
|
||||
};
|
||||
|
||||
void InitializeClient(htclow::HtclowManager *manager);
|
||||
void FinalizeClient();
|
||||
|
||||
Client &GetClient();
|
||||
|
||||
}
|
53
libraries/libstratosphere/source/htcfs/htcfs_client_impl.hpp
Normal file
53
libraries/libstratosphere/source/htcfs/htcfs_client_impl.hpp
Normal file
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#pragma once
|
||||
#include <stratosphere.hpp>
|
||||
#include "../htclow/htclow_manager.hpp"
|
||||
#include "../htclow/htclow_channel.hpp"
|
||||
#include "htcfs_cache_manager.hpp"
|
||||
#include "htcfs_header_factory.hpp"
|
||||
|
||||
namespace ams::htcfs {
|
||||
|
||||
class ClientImpl {
|
||||
private:
|
||||
u8 m_receive_buffer[0x1C040];
|
||||
u8 m_send_buffer[0x1C040];
|
||||
u8 m_packet_buffer[0xE020];
|
||||
htclow::HtclowManager *m_htclow_manager;
|
||||
CacheManager m_cache_manager;
|
||||
HeaderFactory m_header_factory;
|
||||
os::SdkMutex m_mutex;
|
||||
htclow::Module m_module;
|
||||
htclow::Channel m_channel;
|
||||
htclow::Channel m_data_channel;
|
||||
bool m_connected;
|
||||
os::ThreadType m_monitor_thread;
|
||||
os::Event m_event;
|
||||
public:
|
||||
ClientImpl(htclow::HtclowManager *manager);
|
||||
|
||||
~ClientImpl() {
|
||||
this->Cancel();
|
||||
this->Wait();
|
||||
}
|
||||
public:
|
||||
void Start();
|
||||
void Cancel();
|
||||
void Wait();
|
||||
};
|
||||
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include <stratosphere.hpp>
|
||||
#include "htcfs_directory_service_object.hpp"
|
||||
|
||||
namespace ams::htcfs {
|
||||
|
||||
DirectoryServiceObject::DirectoryServiceObject(s32 handle) : m_handle(handle) { /* ... */ }
|
||||
|
||||
DirectoryServiceObject::~DirectoryServiceObject() {
|
||||
/* TODO */
|
||||
AMS_ABORT("htcfs::GetClient().CloseDirectory(m_handle);");
|
||||
}
|
||||
|
||||
Result DirectoryServiceObject::GetEntryCount(ams::sf::Out<s64> out) {
|
||||
AMS_ABORT("DirectoryServiceObject::GetEntryCount");
|
||||
}
|
||||
|
||||
Result DirectoryServiceObject::Read(ams::sf::Out<s64> out, const ams::sf::OutMapAliasArray<fs::DirectoryEntry> &out_entries) {
|
||||
AMS_ABORT("DirectoryServiceObject::Read");
|
||||
}
|
||||
|
||||
Result DirectoryServiceObject::SetPriorityForDirectory(s32 priority) {
|
||||
AMS_ABORT("DirectoryServiceObject::SetPriorityForDirectory");
|
||||
}
|
||||
|
||||
Result DirectoryServiceObject::GetPriorityForDirectory(ams::sf::Out<s32> out) {
|
||||
AMS_ABORT("DirectoryServiceObject::GetPriorityForDirectory");
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#pragma once
|
||||
#include <stratosphere.hpp>
|
||||
|
||||
namespace ams::htcfs {
|
||||
|
||||
class DirectoryServiceObject {
|
||||
private:
|
||||
s32 m_handle;
|
||||
public:
|
||||
explicit DirectoryServiceObject(s32 handle);
|
||||
~DirectoryServiceObject();
|
||||
public:
|
||||
Result GetEntryCount(ams::sf::Out<s64> out);
|
||||
Result Read(ams::sf::Out<s64> out, const ams::sf::OutMapAliasArray<fs::DirectoryEntry> &out_entries);
|
||||
Result SetPriorityForDirectory(s32 priority);
|
||||
Result GetPriorityForDirectory(ams::sf::Out<s32> out);
|
||||
};
|
||||
static_assert(tma::IsIDirectoryAccessor<DirectoryServiceObject>);
|
||||
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include <stratosphere.hpp>
|
||||
#include "htcfs_file_service_object.hpp"
|
||||
|
||||
namespace ams::htcfs {
|
||||
|
||||
FileServiceObject::FileServiceObject(s32 handle) : m_handle(handle) { /* ... */ }
|
||||
|
||||
FileServiceObject::~FileServiceObject() {
|
||||
/* TODO */
|
||||
AMS_ABORT("htcfs::GetClient().CloseFile(m_handle);");
|
||||
}
|
||||
|
||||
Result FileServiceObject::ReadFile(ams::sf::Out<s64> out, s64 offset, const ams::sf::OutNonSecureBuffer &buffer, ams::fs::ReadOption option) {
|
||||
AMS_ABORT("FileServiceObject::ReadFile");
|
||||
}
|
||||
|
||||
Result FileServiceObject::WriteFile(s64 offset, const ams::sf::InNonSecureBuffer &buffer, ams::fs::WriteOption option) {
|
||||
AMS_ABORT("FileServiceObject::WriteFile");
|
||||
}
|
||||
|
||||
Result FileServiceObject::GetFileSize(ams::sf::Out<s64> out) {
|
||||
AMS_ABORT("FileServiceObject::GetFileSize");
|
||||
}
|
||||
|
||||
Result FileServiceObject::SetFileSize(s64 size) {
|
||||
AMS_ABORT("FileServiceObject::SetFileSize");
|
||||
}
|
||||
|
||||
Result FileServiceObject::FlushFile() {
|
||||
AMS_ABORT("FileServiceObject::FlushFile");
|
||||
}
|
||||
|
||||
Result FileServiceObject::SetPriorityForFile(s32 priority) {
|
||||
AMS_ABORT("FileServiceObject::SetPriorityForFile");
|
||||
}
|
||||
|
||||
Result FileServiceObject::GetPriorityForFile(ams::sf::Out<s32> out) {
|
||||
AMS_ABORT("FileServiceObject::GetPriorityForFile");
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#pragma once
|
||||
#include <stratosphere.hpp>
|
||||
|
||||
namespace ams::htcfs {
|
||||
|
||||
class FileServiceObject {
|
||||
private:
|
||||
s32 m_handle;
|
||||
public:
|
||||
explicit FileServiceObject(s32 handle);
|
||||
~FileServiceObject();
|
||||
public:
|
||||
Result ReadFile(ams::sf::Out<s64> out, s64 offset, const ams::sf::OutNonSecureBuffer &buffer, ams::fs::ReadOption option);
|
||||
Result WriteFile(s64 offset, const ams::sf::InNonSecureBuffer &buffer, ams::fs::WriteOption option);
|
||||
Result GetFileSize(ams::sf::Out<s64> out);
|
||||
Result SetFileSize(s64 size);
|
||||
Result FlushFile();
|
||||
Result SetPriorityForFile(s32 priority);
|
||||
Result GetPriorityForFile(ams::sf::Out<s32> out);
|
||||
};
|
||||
static_assert(tma::IsIFileAccessor<FileServiceObject>);
|
||||
|
||||
}
|
|
@ -0,0 +1,77 @@
|
|||
/*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include <stratosphere.hpp>
|
||||
#include "htcfs_file_system_service_object.hpp"
|
||||
|
||||
namespace ams::htcfs {
|
||||
|
||||
Result FileSystemServiceObject::OpenFile(sf::Out<sf::SharedPointer<tma::IFileAccessor>> out, const tma::Path &path, bool case_sensitive) {
|
||||
AMS_ABORT("FileSystemServiceObject::OpenFile");
|
||||
}
|
||||
|
||||
Result FileSystemServiceObject::FileExists(sf::Out<bool> out, const tma::Path &path, bool case_sensitive) {
|
||||
AMS_ABORT("FileSystemServiceObject::FileExists");
|
||||
}
|
||||
|
||||
Result FileSystemServiceObject::DeleteFile(const tma::Path &path, bool case_sensitive) {
|
||||
AMS_ABORT("FileSystemServiceObject::DeleteFile");
|
||||
}
|
||||
|
||||
Result FileSystemServiceObject::RenameFile(const tma::Path &old_path, const tma::Path &new_path, bool case_sensitive) {
|
||||
AMS_ABORT("FileSystemServiceObject::RenameFile");
|
||||
}
|
||||
|
||||
Result FileSystemServiceObject::GetIOType(sf::Out<s32> out, const tma::Path &path, bool case_sensitive) {
|
||||
AMS_ABORT("FileSystemServiceObject::GetIOType");
|
||||
}
|
||||
|
||||
Result FileSystemServiceObject::OpenDirectory(sf::Out<sf::SharedPointer<tma::IDirectoryAccessor>> out, const tma::Path &path, bool case_sensitive) {
|
||||
AMS_ABORT("FileSystemServiceObject::OpenDirectory");
|
||||
}
|
||||
|
||||
Result FileSystemServiceObject::DirectoryExists(sf::Out<bool> out, const tma::Path &path, bool case_sensitive) {
|
||||
AMS_ABORT("FileSystemServiceObject::DirectoryExists");
|
||||
}
|
||||
|
||||
Result FileSystemServiceObject::CreateDirectory(const tma::Path &path, bool case_sensitive) {
|
||||
AMS_ABORT("FileSystemServiceObject::CreateDirectory");
|
||||
}
|
||||
|
||||
Result FileSystemServiceObject::DeleteDirectory(const tma::Path &path, bool case_sensitive) {
|
||||
AMS_ABORT("FileSystemServiceObject::DeleteDirectory");
|
||||
}
|
||||
|
||||
Result FileSystemServiceObject::RenameDirectory(const tma::Path &old_path, const tma::Path &new_path, bool case_sensitive) {
|
||||
AMS_ABORT("FileSystemServiceObject::RenameDirectory");
|
||||
}
|
||||
|
||||
Result FileSystemServiceObject::CreateFile(const tma::Path &path, s64 size, bool case_sensitive) {
|
||||
AMS_ABORT("FileSystemServiceObject::CreateFile");
|
||||
}
|
||||
|
||||
Result FileSystemServiceObject::GetFileTimeStamp(sf::Out<u64> out_create, sf::Out<u64> out_access, sf::Out<u64> out_modify, const tma::Path &path, bool case_sensitive) {
|
||||
AMS_ABORT("FileSystemServiceObject::GetFileTimeStamp");
|
||||
}
|
||||
|
||||
Result FileSystemServiceObject::GetCaseSensitivePath(const tma::Path &path, const sf::OutBuffer &out) {
|
||||
AMS_ABORT("FileSystemServiceObject::GetCaseSensitivePath");
|
||||
}
|
||||
|
||||
Result FileSystemServiceObject::GetDiskFreeSpaceExW(sf::Out<s64> out_free, sf::Out<s64> out_total, sf::Out<s64> out_total_free, const tma::Path &path) {
|
||||
AMS_ABORT("FileSystemServiceObject::GetDiskFreeSpaceExW");
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#pragma once
|
||||
#include <stratosphere.hpp>
|
||||
|
||||
namespace ams::htcfs {
|
||||
|
||||
constexpr inline bool DefaultCaseSensitivityForDeprecatedFileSystemServiceObject = false;
|
||||
|
||||
class FileSystemServiceObject {
|
||||
public:
|
||||
Result OpenFile(sf::Out<sf::SharedPointer<tma::IFileAccessor>> out, const tma::Path &path, bool case_sensitive = DefaultCaseSensitivityForDeprecatedFileSystemServiceObject);
|
||||
Result FileExists(sf::Out<bool> out, const tma::Path &path, bool case_sensitive = DefaultCaseSensitivityForDeprecatedFileSystemServiceObject);
|
||||
Result DeleteFile(const tma::Path &path, bool case_sensitive = DefaultCaseSensitivityForDeprecatedFileSystemServiceObject);
|
||||
Result RenameFile(const tma::Path &old_path, const tma::Path &new_path, bool case_sensitive = DefaultCaseSensitivityForDeprecatedFileSystemServiceObject);
|
||||
Result GetIOType(sf::Out<s32> out, const tma::Path &path, bool case_sensitive = DefaultCaseSensitivityForDeprecatedFileSystemServiceObject);
|
||||
Result OpenDirectory(sf::Out<sf::SharedPointer<tma::IDirectoryAccessor>> out, const tma::Path &path, bool case_sensitive = DefaultCaseSensitivityForDeprecatedFileSystemServiceObject);
|
||||
Result DirectoryExists(sf::Out<bool> out, const tma::Path &path, bool case_sensitive = DefaultCaseSensitivityForDeprecatedFileSystemServiceObject);
|
||||
Result CreateDirectory(const tma::Path &path, bool case_sensitive = DefaultCaseSensitivityForDeprecatedFileSystemServiceObject);
|
||||
Result DeleteDirectory(const tma::Path &path, bool case_sensitive = DefaultCaseSensitivityForDeprecatedFileSystemServiceObject);
|
||||
Result RenameDirectory(const tma::Path &old_path, const tma::Path &new_path, bool case_sensitive = DefaultCaseSensitivityForDeprecatedFileSystemServiceObject);
|
||||
Result CreateFile(const tma::Path &path, s64 size, bool case_sensitive = DefaultCaseSensitivityForDeprecatedFileSystemServiceObject);
|
||||
Result GetFileTimeStamp(sf::Out<u64> out_create, sf::Out<u64> out_access, sf::Out<u64> out_modify, const tma::Path &path, bool case_sensitive = DefaultCaseSensitivityForDeprecatedFileSystemServiceObject);
|
||||
Result GetCaseSensitivePath(const tma::Path &path, const sf::OutBuffer &out);
|
||||
Result GetDiskFreeSpaceExW(sf::Out<s64> out_free, sf::Out<s64> out_total, sf::Out<s64> out_total_free, const tma::Path &path);
|
||||
};
|
||||
static_assert(tma::IsIFileManager<FileSystemServiceObject>);
|
||||
static_assert(tma::IsIDeprecatedFileManager<FileSystemServiceObject>);
|
||||
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#pragma once
|
||||
#include <stratosphere.hpp>
|
||||
|
||||
namespace ams::htcfs {
|
||||
|
||||
class HeaderFactory {
|
||||
private:
|
||||
s16 m_version;
|
||||
public:
|
||||
HeaderFactory() : m_version() { /* ... */ }
|
||||
public:
|
||||
/* ... */
|
||||
};
|
||||
|
||||
}
|
64
libraries/libstratosphere/source/htcfs/htcfs_hipc_server.cpp
Normal file
64
libraries/libstratosphere/source/htcfs/htcfs_hipc_server.cpp
Normal file
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include <stratosphere.hpp>
|
||||
#include "htcfs_client.hpp"
|
||||
#include "htcfs_file_system_service_object.hpp"
|
||||
|
||||
namespace ams::htcfs {
|
||||
|
||||
namespace {
|
||||
|
||||
static constexpr inline size_t NumServers = 1;
|
||||
static constexpr inline size_t MaxSessions = 30;
|
||||
static constexpr inline sm::ServiceName ServiceName = sm::ServiceName::Encode("htcfs");
|
||||
|
||||
struct ServerOptions {
|
||||
static constexpr size_t PointerBufferSize = 0x1000;
|
||||
static constexpr size_t MaxDomains = 0x10;
|
||||
static constexpr size_t MaxDomainObjects = 0x100;
|
||||
};
|
||||
|
||||
using ServerManager = sf::hipc::ServerManager<NumServers, ServerOptions, MaxSessions>;
|
||||
|
||||
/* Service object. */
|
||||
ServerManager g_server_manager;
|
||||
|
||||
/* Service object. */
|
||||
constinit sf::UnmanagedServiceObject<tma::IFileManager, FileSystemServiceObject> g_htcfs_service_object;
|
||||
constinit sf::UnmanagedServiceObject<tma::IDeprecatedFileManager, FileSystemServiceObject> g_htcfs_deprecated_service_object;
|
||||
|
||||
}
|
||||
|
||||
void Initialize(htclow::HtclowManager *htclow_manager) {
|
||||
/* Initialize the htcfs client library. */
|
||||
htcfs::InitializeClient(htclow_manager);
|
||||
}
|
||||
|
||||
void RegisterHipcServer() {
|
||||
/* Register the service. */
|
||||
if (hos::GetVersion() >= hos::Version_6_0_0) {
|
||||
R_ABORT_UNLESS(g_server_manager.RegisterObjectForServer(g_htcfs_service_object.GetShared(), ServiceName, MaxSessions));
|
||||
} else {
|
||||
R_ABORT_UNLESS(g_server_manager.RegisterObjectForServer(g_htcfs_deprecated_service_object.GetShared(), ServiceName, MaxSessions));
|
||||
}
|
||||
}
|
||||
|
||||
void LoopHipcServer() {
|
||||
/* Loop, servicing services. */
|
||||
g_server_manager.LoopProcess();
|
||||
}
|
||||
|
||||
}
|
|
@ -51,12 +51,12 @@ namespace ams::htcs::server {
|
|||
}
|
||||
|
||||
Result ManagerServiceObject::RegisterProcessId(const sf::ClientProcessId &client_pid) {
|
||||
/* NOTE: Nintend does nothing here. */
|
||||
/* NOTE: Nintendo does nothing here. */
|
||||
return ResultSuccess();
|
||||
}
|
||||
|
||||
Result ManagerServiceObject::MonitorManager(const sf::ClientProcessId &client_pid) {
|
||||
/* NOTE: Nintend does nothing here. */
|
||||
/* NOTE: Nintendo does nothing here. */
|
||||
return ResultSuccess();
|
||||
}
|
||||
|
||||
|
|
|
@ -210,7 +210,7 @@ namespace ams::htc {
|
|||
}
|
||||
|
||||
void HtcfsIpcThreadFunction(void *arg) {
|
||||
//htcfs::LoopHipcServer();
|
||||
htcfs::LoopHipcServer();
|
||||
}
|
||||
|
||||
void HtcsIpcThreadFunction(void *arg) {
|
||||
|
@ -254,8 +254,8 @@ int main(int argc, char **argv)
|
|||
os::SetThreadNamePointer(std::addressof(htc_ipc_thread), AMS_GET_SYSTEM_THREAD_NAME(htc, HtcIpc));
|
||||
|
||||
/* Initialize the htcfs server. */
|
||||
//htcfs::Initialize();
|
||||
//htcfs::RegisterHipcServer();
|
||||
htcfs::Initialize(htclow_manager);
|
||||
htcfs::RegisterHipcServer();
|
||||
|
||||
/* Create the htcfs ipc thread. */
|
||||
os::ThreadType htcfs_ipc_thread;
|
||||
|
|
Loading…
Reference in a new issue