mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2024-12-18 08:22:04 +00:00
pf2: add drv::Initialize(Volume *)
This commit is contained in:
parent
ceef76c428
commit
102e1e0e74
7 changed files with 163 additions and 3 deletions
|
@ -25,5 +25,6 @@
|
|||
#include <vapours/prfile2/prfile2_system.hpp>
|
||||
#include <vapours/prfile2/pdm/prfile2_pdm_api.hpp>
|
||||
#include <vapours/prfile2/pdm/prfile2_pdm_disk_management.hpp>
|
||||
#include <vapours/prfile2/pdm/prfile2_pdm_upper_layer_api.hpp>
|
||||
#include <vapours/prfile2/prfile2_fatfs.hpp>
|
||||
#include <vapours/prfile2/prfile2_volume.hpp>
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* 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/prfile2/pdm/prfile2_pdm_types.hpp>
|
||||
#include <vapours/prfile2/pdm/prfile2_pdm_common.hpp>
|
||||
#include <vapours/prfile2/pdm/prfile2_pdm_disk_management.hpp>
|
||||
|
||||
namespace ams::prfile2::pdm {
|
||||
|
||||
namespace part {
|
||||
|
||||
pdm::Error CheckDataEraseRequest(HandleType part_handle, bool *out);
|
||||
|
||||
}
|
||||
|
||||
}
|
29
libraries/libvapours/include/vapours/prfile2/prfile2_drv.hpp
Normal file
29
libraries/libvapours/include/vapours/prfile2/prfile2_drv.hpp
Normal file
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* 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/prfile2/prfile2_common.hpp>
|
||||
|
||||
namespace ams::prfile2 {
|
||||
|
||||
struct Volume;
|
||||
|
||||
}
|
||||
|
||||
namespace ams::prfile2::drv {
|
||||
|
||||
pf::Error Initialize(Volume *volume);
|
||||
|
||||
}
|
|
@ -17,6 +17,7 @@
|
|||
#include <vapours/prfile2/prfile2_common.hpp>
|
||||
#include <vapours/prfile2/prfile2_cache.hpp>
|
||||
#include <vapours/prfile2/prfile2_critical_section.hpp>
|
||||
#include <vapours/prfile2/prfile2_drv.hpp>
|
||||
#include <vapours/prfile2/prfile2_entry.hpp>
|
||||
#include <vapours/prfile2/prfile2_fat.hpp>
|
||||
|
||||
|
@ -193,8 +194,14 @@ namespace ams::prfile2 {
|
|||
constexpr bool IsMounted() const { return this->GetFlagsBit<1>(); }
|
||||
constexpr void SetMounted(bool en) { this->SetFlagsBit<1>(en); }
|
||||
|
||||
constexpr bool IsDiskInserted() const { return this->GetFlagsBit<2>(); }
|
||||
constexpr void SetDiskInserted(bool en) { this->SetFlagsBit<2>(en); }
|
||||
constexpr bool IsFormatAfterMountRequested() const { return this->GetFlagsBit<4>(); }
|
||||
constexpr void SetFormatAfterMountRequested(bool en) { this->SetFlagsBit<4>(en); }
|
||||
|
||||
constexpr bool IsNoFormattingByFatFsLayer() const { return this->GetFlagsBit<5>(); }
|
||||
constexpr void SetNoFormattingByFatFsLayer(bool en) { this->SetFlagsBit<5>(en); }
|
||||
|
||||
constexpr bool IsDataEraseRequested() const { return this->GetFlagsBit<6>(); }
|
||||
constexpr void SetDataEraseRequested(bool en) { this->SetFlagsBit<6>(en); }
|
||||
|
||||
constexpr bool IsFlag12() const { return this->GetFlagsBit<12>(); }
|
||||
constexpr void SetFlag12(bool en) { this->SetFlagsBit<12>(en); }
|
||||
|
|
|
@ -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/>.
|
||||
*/
|
||||
#if defined(ATMOSPHERE_IS_STRATOSPHERE)
|
||||
#include <stratosphere.hpp>
|
||||
#elif defined(ATMOSPHERE_IS_MESOSPHERE)
|
||||
#include <mesosphere.hpp>
|
||||
#elif defined(ATMOSPHERE_IS_EXOSPHERE)
|
||||
#include <exosphere.hpp>
|
||||
#else
|
||||
#include <vapours.hpp>
|
||||
#endif
|
||||
#include "prfile2_pdm_disk_set.hpp"
|
||||
|
||||
namespace ams::prfile2::pdm::part {
|
||||
|
||||
pdm::Error CheckDataEraseRequest(HandleType part_handle, bool *out) {
|
||||
/* Check parameters. */
|
||||
Partition *part = GetPartition(part_handle);
|
||||
if (out == nullptr || part == nullptr) {
|
||||
return pdm::Error_InvalidParameter;
|
||||
}
|
||||
|
||||
/* Get the disk. */
|
||||
Disk *disk = GetDisk(part->disk_handle);
|
||||
if (disk == nullptr) {
|
||||
return pdm::Error_InvalidParameter;
|
||||
}
|
||||
|
||||
/* Check for data erase function. */
|
||||
*out = disk->erase_callback != nullptr;
|
||||
return pdm::Error_Ok;
|
||||
}
|
||||
|
||||
}
|
45
libraries/libvapours/source/prfile2/prfile2_drv.cpp
Normal file
45
libraries/libvapours/source/prfile2/prfile2_drv.cpp
Normal file
|
@ -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/>.
|
||||
*/
|
||||
#if defined(ATMOSPHERE_IS_STRATOSPHERE)
|
||||
#include <stratosphere.hpp>
|
||||
#elif defined(ATMOSPHERE_IS_MESOSPHERE)
|
||||
#include <mesosphere.hpp>
|
||||
#elif defined(ATMOSPHERE_IS_EXOSPHERE)
|
||||
#include <exosphere.hpp>
|
||||
#else
|
||||
#include <vapours.hpp>
|
||||
#endif
|
||||
|
||||
namespace ams::prfile2::drv {
|
||||
|
||||
pf::Error Initialize(Volume *volume) {
|
||||
/* Check the volume. */
|
||||
if (volume == nullptr) {
|
||||
return pf::Error_InvalidParameter;
|
||||
}
|
||||
|
||||
/* Check the data erase request. */
|
||||
bool data_erase;
|
||||
if (auto pdm_err = pdm::part::CheckDataEraseRequest(volume->partition_handle, std::addressof(data_erase)); pdm_err != pdm::Error_Ok) {
|
||||
return pf::Error_Generic;
|
||||
}
|
||||
|
||||
/* Set the data erase request flag. */
|
||||
volume->SetDataEraseRequested(data_erase);
|
||||
return pf::Error_Ok;
|
||||
}
|
||||
|
||||
}
|
|
@ -273,7 +273,9 @@ namespace ams::prfile2::vol {
|
|||
vol->tail_entry.tracker_bits = vol->tail_entry.tracker_buf;
|
||||
|
||||
/* Initialize driver for volume. */
|
||||
/* TODO: drv::Initialize(vol); + error checking */
|
||||
if (auto err = drv::Initialize(vol); err != pf::Error_Ok) {
|
||||
return SetLastErrorAndReturn(err);
|
||||
}
|
||||
|
||||
/* Setup the cache. */
|
||||
/* TODO: cache::SetCache(vol, drive_table->cache->pages, drive_table->cache->buffers, drive_table->cache->num_fat_pages, drive_table->cache->num_data_pages); */
|
||||
|
|
Loading…
Reference in a new issue