mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-06-02 15:49:48 -04:00
fs: revise NcaFileSystemDriver for latest semantics
This commit is contained in:
parent
ccf29a1302
commit
52296fc2dd
37 changed files with 1612 additions and 1026 deletions
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
* Copyright (c) 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::fssystem {
|
||||
|
||||
class IAsynchronousAccessSplitter {
|
||||
public:
|
||||
static IAsynchronousAccessSplitter *GetDefaultAsynchronousAccessSplitter();
|
||||
public:
|
||||
constexpr IAsynchronousAccessSplitter() = default;
|
||||
constexpr virtual ~IAsynchronousAccessSplitter() { /* ... */ }
|
||||
public:
|
||||
Result QueryNextOffset(s64 *out, s64 start_offset, s64 end_offset, s64 access_size, s64 alignment_size);
|
||||
public:
|
||||
virtual Result QueryAppropriateOffset(s64 *out, s64 offset, s64 access_size, s64 alignment_size) = 0;
|
||||
virtual Result QueryInvocationCount(s64 *out, s64 start_offset, s64 end_offset, s64 access_size, s64 alignment_size);
|
||||
};
|
||||
|
||||
class DefaultAsynchronousAccessSplitter final : public IAsynchronousAccessSplitter {
|
||||
public:
|
||||
constexpr DefaultAsynchronousAccessSplitter() = default;
|
||||
public:
|
||||
virtual Result QueryAppropriateOffset(s64 *out, s64 offset, s64 access_size, s64 alignment_size) override {
|
||||
/* Align the access. */
|
||||
*out = util::AlignDown(offset + access_size, alignment_size);
|
||||
return ResultSuccess();
|
||||
}
|
||||
|
||||
virtual Result QueryInvocationCount(s64 *out, s64 start_offset, s64 end_offset, s64 access_size, s64 alignment_size) override {
|
||||
/* Determine aligned access count. */
|
||||
*out = util::DivideUp(end_offset - util::AlignDown(start_offset, alignment_size), access_size);
|
||||
return ResultSuccess();
|
||||
}
|
||||
};
|
||||
|
||||
inline IAsynchronousAccessSplitter *IAsynchronousAccessSplitter::GetDefaultAsynchronousAccessSplitter() {
|
||||
static constinit DefaultAsynchronousAccessSplitter s_default_access_splitter;
|
||||
return std::addressof(s_default_access_splitter);
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue