id
int64 0
755k
| file_name
stringlengths 3
109
| file_path
stringlengths 13
185
| content
stringlengths 31
9.38M
| size
int64 31
9.38M
| language
stringclasses 1
value | extension
stringclasses 11
values | total_lines
int64 1
340k
| avg_line_length
float64 2.18
149k
| max_line_length
int64 7
2.22M
| alphanum_fraction
float64 0
1
| repo_name
stringlengths 6
65
| repo_stars
int64 100
47.3k
| repo_forks
int64 0
12k
| repo_open_issues
int64 0
3.4k
| repo_license
stringclasses 9
values | repo_extraction_date
stringclasses 92
values | exact_duplicates_redpajama
bool 2
classes | near_duplicates_redpajama
bool 2
classes | exact_duplicates_githubcode
bool 2
classes | exact_duplicates_stackv2
bool 1
class | exact_duplicates_stackv1
bool 2
classes | near_duplicates_githubcode
bool 2
classes | near_duplicates_stackv1
bool 2
classes | near_duplicates_stackv2
bool 1
class |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
7,433
|
sprofile.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/sprofile.hpp
|
/*
* 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 <stratosphere/sprofile/sprofile_types.hpp>
#include <stratosphere/sprofile/srv/sprofile_srv_api.hpp>
| 758
|
C++
|
.h
| 18
| 40.333333
| 76
| 0.768919
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,434
|
htcs.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/htcs.hpp
|
/*
* 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 <stratosphere/htcs/htcs_types.hpp>
#include <stratosphere/htcs/htcs_api.hpp>
#include <stratosphere/htcs/htcs_socket.hpp>
#include <stratosphere/htcs/impl/htcs_manager_holder.hpp>
#include <stratosphere/htcs/impl/htcs_channel_ids.hpp>
#include <stratosphere/htcs/server/htcs_hipc_server.hpp>
| 950
|
C++
|
.h
| 22
| 41.5
| 76
| 0.776699
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,435
|
gpio.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/gpio.hpp
|
/*
* 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 <stratosphere/gpio/gpio_types.hpp>
#include <stratosphere/gpio/sf/gpio_sf_i_pad_session.hpp>
#include <stratosphere/gpio/sf/gpio_sf_i_manager.hpp>
#include <stratosphere/gpio/gpio_api.hpp>
#include <stratosphere/gpio/gpio_pad_api.hpp>
#include <stratosphere/gpio/driver/gpio_select_driver_api.hpp>
#include <stratosphere/gpio/driver/gpio_pad_accessor.hpp>
#include <stratosphere/gpio/driver/impl/gpio_pad_session_impl.hpp>
#include <stratosphere/gpio/server/gpio_server_api.hpp>
| 1,137
|
C++
|
.h
| 25
| 43.88
| 76
| 0.780378
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,436
|
rapidjson.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/rapidjson.hpp
|
/*
* 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>
#include <stratosphere/ams/ams_environment.hpp>
#define RAPIDJSON_NAMESPACE ams::rapidjson
#define RAPIDJSON_ASSERT(x) AMS_ABORT_UNLESS(x)
#define RAPIDJSON_MALLOC(size) ams::MallocForRapidJson(size)
#define RAPIDJSON_REALLOC(ptr, size) ams::ReallocForRapidJson(ptr, size)
#define RAPIDJSON_FREE(ptr) ams::FreeForRapidJson(ptr)
#include <stratosphere/rapidjson/rapidjson.h>
#include <stratosphere/rapidjson/encodings.h>
#include <stratosphere/rapidjson/reader.h>
| 1,170
|
C++
|
.h
| 26
| 43.346154
| 76
| 0.763365
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,437
|
diag.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/diag.hpp
|
/*
* 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 <stratosphere/diag/diag_log_types.hpp>
#include <stratosphere/diag/diag_log_observer.hpp>
#include <stratosphere/diag/impl/diag_impl_log.hpp>
#include <stratosphere/diag/diag_log.hpp>
#include <stratosphere/diag/diag_sdk_log.hpp>
#include <stratosphere/diag/diag_abort_observer.hpp>
#include <stratosphere/diag/diag_assertion_failure_handler.hpp>
#include <stratosphere/diag/impl/diag_utf8_util.hpp>
#include <stratosphere/diag/diag_backtrace.hpp>
#include <stratosphere/diag/diag_symbol.hpp>
| 1,153
|
C++
|
.h
| 26
| 42.692308
| 76
| 0.783808
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,438
|
settings.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/settings.hpp
|
/*
* 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 <stratosphere/settings/settings_types.hpp>
#include <stratosphere/settings/settings_fwdbg_types.hpp>
#include <stratosphere/settings/settings_fwdbg_api.hpp>
#include <stratosphere/settings/factory/settings_serial_number.hpp>
#include <stratosphere/settings/factory/settings_configuration_id.hpp>
#include <stratosphere/settings/factory/settings_device_certificate.hpp>
#include <stratosphere/settings/system/settings_error_report.hpp>
#include <stratosphere/settings/system/settings_firmware_version.hpp>
#include <stratosphere/settings/system/settings_platform_region.hpp>
#include <stratosphere/settings/system/settings_product_model.hpp>
#include <stratosphere/settings/system/settings_region.hpp>
#include <stratosphere/settings/system/settings_serial_number.hpp>
| 1,427
|
C++
|
.h
| 28
| 49.392857
| 76
| 0.80816
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,439
|
hos.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/hos.hpp
|
/*
* 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 <stratosphere/hos/hos_types.hpp>
#include <stratosphere/hos/hos_version_api.hpp>
#include <stratosphere/hos/hos_stratosphere_api.hpp>
| 793
|
C++
|
.h
| 19
| 39.894737
| 76
| 0.768135
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,440
|
fssrv.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/fssrv.hpp
|
/*
* 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 <stratosphere/fssrv/sf/fssrv_sf_path.hpp>
#include <stratosphere/fssrv/sf/fssrv_sf_ifile.hpp>
#include <stratosphere/fssrv/sf/fssrv_sf_i_event_notifier.hpp>
#include <stratosphere/fssrv/impl/fssrv_impl_program_index_map_info_manager.hpp>
#include <stratosphere/fssrv/impl/fssrv_access_control.hpp>
#include <stratosphere/fssrv/fssrv_nca_crypto_configuration.hpp>
#include <stratosphere/fssrv/fssrv_memory_resource_from_standard_allocator.hpp>
#include <stratosphere/fssrv/fssrv_memory_resource_from_exp_heap.hpp>
#include <stratosphere/fssrv/fssrv_i_file_system_creator.hpp>
#include <stratosphere/fssrv/fscreator/fssrv_partition_file_system_creator.hpp>
#include <stratosphere/fssrv/fscreator/fssrv_rom_file_system_creator.hpp>
#include <stratosphere/fssrv/fscreator/fssrv_storage_on_nca_creator.hpp>
#include <stratosphere/fssrv/fscreator/fssrv_local_file_system_creator.hpp>
#include <stratosphere/fssrv/fscreator/fssrv_subdirectory_file_system_creator.hpp>
#include <stratosphere/fssrv/fscreator/fssrv_storage_on_nca_creator.hpp>
#include <stratosphere/fssrv/fssrv_file_system_proxy_server_session_resource_manager.hpp>
#include <stratosphere/fssrv/impl/fssrv_file_system_proxy_service_object.hpp>
#include <stratosphere/fssrv/fssrv_file_system_proxy_api.hpp>
#include <stratosphere/fssrv/fssrv_program_registry_impl.hpp>
#include <stratosphere/fssrv/fssrv_program_registry_service.hpp>
#include <stratosphere/fssrv/fssrv_nca_file_system_service_impl.hpp>
#include <stratosphere/fssrv/impl/fssrv_external_key_manager.hpp>
| 2,184
|
C++
|
.h
| 38
| 56.078947
| 89
| 0.810256
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,441
|
sm.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/sm.hpp
|
/*
* 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 <stratosphere/sm/sm_types.hpp>
#include <stratosphere/sm/sm_api.hpp>
#include <stratosphere/sm/sm_mitm_api.hpp>
#include <stratosphere/sm/sm_manager_api.hpp>
#include <stratosphere/sm/impl/sm_user_interface.hpp>
#include <stratosphere/sm/impl/sm_manager_interface.hpp>
| 930
|
C++
|
.h
| 22
| 40.454545
| 76
| 0.771018
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,442
|
htc.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/htc.hpp
|
/*
* 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 <stratosphere/htc/server/htc_htcmisc_hipc_server.hpp>
#include <stratosphere/htc/server/htc_htcmisc_channel_ids.hpp>
#include <stratosphere/htc/tenv/htc_tenv_types.hpp>
#include <stratosphere/htc/tenv/htc_tenv.hpp>
#include <stratosphere/htc/tenv/htc_tenv_service_manager.hpp>
| 936
|
C++
|
.h
| 21
| 42.809524
| 76
| 0.775465
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,443
|
time.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/time.hpp
|
/*
* 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 <stratosphere/time/time_common.hpp>
#include <stratosphere/time/time_api.hpp>
#include <stratosphere/time/time_posix_time.hpp>
#include <stratosphere/time/time_calendar_time.hpp>
#include <stratosphere/time/time_timezone_api.hpp>
#include <stratosphere/time/time_steady_clock_time_point.hpp>
#include <stratosphere/time/time_standard_steady_clock.hpp>
#include <stratosphere/time/time_standard_user_system_clock.hpp>
#include <stratosphere/time/time_standard_network_system_clock.hpp>
#include <stratosphere/time/impl/util/time_impl_util_api.hpp>
| 1,206
|
C++
|
.h
| 26
| 44.769231
| 76
| 0.786927
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,444
|
powctl.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/powctl.hpp
|
/*
* 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 <stratosphere/powctl/powctl_types.hpp>
#include <stratosphere/powctl/powctl_select_devices.hpp>
#include <stratosphere/powctl/powctl_session_api.hpp>
#include <stratosphere/powctl/powctl_battery_api.hpp>
#include <stratosphere/powctl/powctl_charger_api.hpp>
#include <stratosphere/powctl/impl/powctl_battery_charge_percentage.hpp>
#include <stratosphere/powctl/driver/powctl_driver_api.hpp>
#include <stratosphere/powctl/driver/impl/powctl_select_charger_parameters.hpp>
#include <stratosphere/powctl/driver/impl/powctl_charge_arbiter.hpp>
| 1,198
|
C++
|
.h
| 25
| 46.32
| 79
| 0.794369
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,445
|
regulator.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/regulator.hpp
|
/*
* 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 <stratosphere/regulator/regulator_types.hpp>
#include <stratosphere/regulator/regulator_api.hpp>
#include <stratosphere/regulator/regulator_session_api.hpp>
| 816
|
C++
|
.h
| 19
| 41.105263
| 76
| 0.776101
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,446
|
dd.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/dd.hpp
|
/*
* 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 <stratosphere/dd/dd_types.hpp>
#include <stratosphere/dd/dd_device_address_space.hpp>
#include <stratosphere/dd/dd_io_mappings.hpp>
#include <stratosphere/dd/dd_process_handle.hpp>
| 840
|
C++
|
.h
| 20
| 40.2
| 76
| 0.768949
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,447
|
socket.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/socket.hpp
|
/*
* 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
#if !defined(ATMOSPHERE_OS_WINDOWS)
#include <sys/socket.h>
#include <netdb.h>
#include <netinet/in.h>
#endif
#include <stratosphere/socket/socket_types.hpp>
#include <stratosphere/socket/socket_options.hpp>
#include <stratosphere/socket/socket_errno.hpp>
#include <stratosphere/socket/socket_constants.hpp>
#include <stratosphere/socket/socket_config.hpp>
#include <stratosphere/socket/socket_system_config.hpp>
#include <stratosphere/socket/socket_api.hpp>
| 1,109
|
C++
|
.h
| 28
| 38.035714
| 76
| 0.782206
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,448
|
err.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/err.hpp
|
/*
* 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 <stratosphere/err/err_types.hpp>
#include <stratosphere/err/err_error_context.hpp>
#include <stratosphere/err/err_system_api.hpp>
| 789
|
C++
|
.h
| 19
| 39.684211
| 76
| 0.766927
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,449
|
htcfs.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/htcfs.hpp
|
/*
* 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 <stratosphere/htcfs/htcfs_hipc_server.hpp>
| 701
|
C++
|
.h
| 17
| 39.352941
| 76
| 0.762811
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,450
|
psc.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/psc.hpp
|
/*
* 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 <stratosphere/psc/psc_types.hpp>
#include <stratosphere/psc/psc_pm_module_id.hpp>
#include <stratosphere/psc/sf/psc_sf_i_pm_module.hpp>
#include <stratosphere/psc/sf/psc_sf_i_pm_service.hpp>
#include <stratosphere/psc/psc_pm_module.hpp>
| 896
|
C++
|
.h
| 21
| 40.904762
| 76
| 0.766323
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,451
|
fs.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/fs.hpp
|
/*
* 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 <stratosphere/fs/fs_common.hpp>
#include <stratosphere/fs/impl/fs_result_utils.hpp>
#include <stratosphere/fs/fs_context.hpp>
#include <stratosphere/fs/fs_result_config.hpp>
#include <stratosphere/fs/fs_storage_type.hpp>
#include <stratosphere/fs/fs_priority.hpp>
#include <stratosphere/fs/impl/fs_priority_utils.hpp>
#include <stratosphere/fs/fs_access_log.hpp>
#include <stratosphere/fs/fsa/fs_ifile.hpp>
#include <stratosphere/fs/fsa/fs_idirectory.hpp>
#include <stratosphere/fs/fsa/fs_ifilesystem.hpp>
#include <stratosphere/fs/impl/fs_filesystem_proxy_type.hpp>
#include <stratosphere/fs/fsa/fs_registrar.hpp>
#include <stratosphere/fs/fs_remote_filesystem.hpp>
#include <stratosphere/fs/fs_read_only_filesystem.hpp>
#include <stratosphere/fs/fs_istorage.hpp>
#include <stratosphere/fs/fs_i_event_notifier.hpp>
#include <stratosphere/fs/fs_substorage.hpp>
#include <stratosphere/fs/fs_memory_storage.hpp>
#include <stratosphere/fs/fs_remote_storage.hpp>
#include <stratosphere/fs/common/fs_file_storage.hpp>
#include <stratosphere/fs/fs_query_range.hpp>
#include <stratosphere/fs/fs_speed_emulation.hpp>
#include <stratosphere/fs/impl/fs_common_mount_name.hpp>
#include <stratosphere/fs/fs_mount.hpp>
#include <stratosphere/fs/fs_path_utility.hpp>
#include <stratosphere/fs/fs_path.hpp>
#include <stratosphere/fs/common/fs_directory_path_parser.hpp>
#include <stratosphere/fs/fs_filesystem_utils.hpp>
#include <stratosphere/fs/fs_romfs_filesystem.hpp>
#include <stratosphere/fs/impl/fs_data.hpp>
#include <stratosphere/fs/fs_application.hpp>
#include <stratosphere/fs/fs_bis.hpp>
#include <stratosphere/fs/fs_code.hpp>
#include <stratosphere/fs/fs_content.hpp>
#include <stratosphere/fs/fs_content_storage.hpp>
#include <stratosphere/fs/fs_error_info.hpp>
#include <stratosphere/fs/fs_game_card.hpp>
#include <stratosphere/fs/fs_host.hpp>
#include <stratosphere/fs/fs_image_directory.hpp>
#include <stratosphere/fs/fs_mmc.hpp>
#include <stratosphere/fs/fs_save_data_types.hpp>
#include <stratosphere/fs/fs_save_data_management.hpp>
#include <stratosphere/fs/fs_save_data_transaction.hpp>
#include <stratosphere/fs/fs_device_save_data.hpp>
#include <stratosphere/fs/fs_system_save_data.hpp>
#include <stratosphere/fs/fs_sd_card.hpp>
#include <stratosphere/fs/fs_signed_system_partition.hpp>
#include <stratosphere/fs/fs_system_data.hpp>
#include <stratosphere/fs/fs_program_index_map_info.hpp>
#include <stratosphere/fs/fs_program_id.hpp>
#include <stratosphere/fs/impl/fs_access_log_impl.hpp>
#include <stratosphere/fs/impl/fs_hash_generator_factory_selector.hpp>
#include <stratosphere/fs/impl/fs_storage_service_object_adapter.hpp>
#include <stratosphere/fs/fs_api.hpp>
| 3,335
|
C++
|
.h
| 71
| 45.760563
| 76
| 0.797426
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,452
|
vi.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/vi.hpp
|
/*
* 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 <stratosphere/vi/vi_layer_stack.hpp>
| 696
|
C++
|
.h
| 17
| 39
| 76
| 0.760709
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,453
|
util.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/util.hpp
|
/*
* 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 <stratosphere/util/util_uuid_api.hpp>
#include <stratosphere/util/util_compression.hpp>
#include <stratosphere/util/util_ini.hpp>
#include <stratosphere/util/util_singleton_traits.hpp>
#include <stratosphere/util/util_lock_free_atomic_type.hpp>
| 903
|
C++
|
.h
| 21
| 41.285714
| 76
| 0.775255
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,454
|
spl_types.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/spl/spl_types.hpp
|
/*
* 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::spl {
namespace smc {
enum class FunctionId : u32 {
SetConfig = 0xC3000401,
GetConfig = 0xC3000002,
GetResult = 0xC3000003,
GetResultData = 0xC3000404,
ModularExponentiate = 0xC3000E05,
GenerateRandomBytes = 0xC3000006,
GenerateAesKek = 0xC3000007,
LoadAesKey = 0xC3000008,
ComputeAes = 0xC3000009,
GenerateSpecificAesKey = 0xC300000A,
ComputeCmac = 0xC300040B,
ReencryptDeviceUniqueData = 0xC300D60C,
DecryptDeviceUniqueData = 0xC300100D,
ModularExponentiateWithStorageKey = 0xC300060F,
PrepareEsDeviceUniqueKey = 0xC3000610,
LoadPreparedAesKey = 0xC3000011,
PrepareCommonEsTitleKey = 0xC3000012,
/* Deprecated functions. */
LoadEsDeviceKey = 0xC300100C,
DecryptAndStoreGcKey = 0xC300100E,
/* Atmosphere functions. */
AtmosphereIramCopy = 0xF0000201,
AtmosphereReadWriteRegister = 0xF0000002,
AtmosphereGetEmummcConfig = 0xF0000404,
};
enum class Result {
Success = 0,
NotSupported = 1,
InvalidArgument = 2,
InProgress = 3,
NoAsyncOperation = 4,
InvalidAsyncOperation = 5,
NotPermitted = 6,
NotInitialized = 7,
};
constexpr inline ::ams::Result ConvertResult(Result smc_result) {
/* smc::Result::Success becomes ResultSuccess() directly. */
R_SUCCEED_IF(smc_result == smc::Result::Success);
/* Convert to the list of known SecureMonitorErrors. */
const auto converted = R_MAKE_NAMESPACE_RESULT(::ams::spl, static_cast<u32>(smc_result));
R_UNLESS(spl::ResultSecureMonitorError::Includes(converted), spl::ResultUnexpectedSecureMonitorResult());
/* Return the error. */
R_RETURN(converted);
}
enum class CipherMode {
CbcEncrypt = 0,
CbcDecrypt = 1,
Ctr = 2,
};
enum class DeviceUniqueDataMode {
DecryptDeviceUniqueData = 0,
DecryptAndStoreGcKey = 1,
DecryptAndStoreEsDeviceKey = 2,
DecryptAndStoreSslKey = 3,
DecryptAndStoreDrmDeviceCertKey = 4,
};
enum class ModularExponentiateWithStorageKeyMode {
Gc = 0,
Ssl = 1,
DrmDeviceCert = 2,
};
enum class EsDeviceUniqueKeyType {
TitleKey = 0,
ArchiveKey = 1,
Unknown2 = 2,
};
struct AsyncOperationKey {
u64 value;
};
}
constexpr inline size_t AesKeySize = crypto::AesEncryptor128::KeySize;
constexpr inline size_t AesBlockSize = crypto::AesEncryptor128::BlockSize;
enum class HardwareType {
Icosa = 0,
Copper = 1,
Hoag = 2,
Iowa = 3,
Calcio = 4,
Aula = 5,
};
enum SocType {
SocType_Erista = 0,
SocType_Mariko = 1,
};
enum HardwareState {
HardwareState_Development = 0,
HardwareState_Production = 1,
};
enum MemoryArrangement {
MemoryArrangement_Standard = 0,
MemoryArrangement_StandardForAppletDev = 1,
MemoryArrangement_StandardForSystemDev = 2,
MemoryArrangement_Expanded = 3,
MemoryArrangement_ExpandedForAppletDev = 4,
/* Note: MemoryArrangement_Dynamic is not official. */
/* Atmosphere uses it to maintain compatibility with firmwares prior to 6.0.0, */
/* which removed the explicit retrieval of memory arrangement from PM. */
MemoryArrangement_Dynamic = 5,
MemoryArrangement_Count,
};
enum RetailInteractiveDisplayState {
RetailInteractiveDisplayState_Disabled = 0,
RetailInteractiveDisplayState_Enabled = 1,
};
struct BootReasonValue {
union {
struct {
u8 power_intr;
u8 rtc_intr;
u8 nv_erc;
u8 boot_reason;
};
u32 value;
};
};
static_assert(sizeof(BootReasonValue) == sizeof(u32), "BootReasonValue definition!");
enum BootReason {
BootReason_Unknown = 0,
BootReason_AcOk = 1,
BootReason_OnKey = 2,
BootReason_RtcAlarm1 = 3,
BootReason_RtcAlarm2 = 4,
};
#pragma pack(push, 1)
struct AesKey {
union {
u8 data[AesKeySize];
u64 data64[AesKeySize / sizeof(u64)];
};
};
static_assert(alignof(AesKey) == alignof(u8), "AesKey definition!");
struct IvCtr {
union {
u8 data[AesKeySize];
u64 data64[AesKeySize / sizeof(u64)];
};
};
static_assert(alignof(IvCtr) == alignof(u8), "IvCtr definition!");
struct Cmac {
union {
u8 data[AesKeySize];
u64 data64[AesKeySize / sizeof(u64)];
};
};
static_assert(alignof(Cmac) == alignof(u8), "Cmac definition!");
struct AccessKey {
union {
u8 data[AesKeySize];
u64 data64[AesKeySize / sizeof(u64)];
};
};
static_assert(alignof(AccessKey) == alignof(u8), "AccessKey definition!");
struct KeySource {
union {
u8 data[AesKeySize];
u64 data64[AesKeySize / sizeof(u64)];
};
};
static_assert(alignof(AccessKey) == alignof(u8), "KeySource definition!");
#pragma pack(pop)
enum class ConfigItem : u32 {
/* Standard config items. */
DisableProgramVerification = 1,
DramId = 2,
SecurityEngineInterruptNumber = 3,
FuseVersion = 4,
HardwareType = 5,
HardwareState = 6,
IsRecoveryBoot = 7,
DeviceId = 8,
BootReason = 9,
MemoryMode = 10,
IsDevelopmentFunctionEnabled = 11,
KernelConfiguration = 12,
IsChargerHiZModeEnabled = 13,
RetailInteractiveDisplayState = 14,
RegulatorType = 15,
DeviceUniqueKeyGeneration = 16,
Package2Hash = 17,
/* Extension config items for exosphere. */
ExosphereApiVersion = 65000,
ExosphereNeedsReboot = 65001,
ExosphereNeedsShutdown = 65002,
ExosphereGitCommitHash = 65003,
ExosphereHasRcmBugPatch = 65004,
ExosphereBlankProdInfo = 65005,
ExosphereAllowCalWrites = 65006,
ExosphereEmummcType = 65007,
ExospherePayloadAddress = 65008,
ExosphereLogConfiguration = 65009,
ExosphereForceEnableUsb30 = 65010,
ExosphereSupportedHosVersion = 65011,
ExosphereApproximateApiVersion = 65012, /* NOTE: Internal use only. */
};
}
#if defined(ATMOSPHERE_OS_HORIZON)
/* Extensions to libnx spl config item enum. */
constexpr inline SplConfigItem SplConfigItem_ExosphereApiVersion = static_cast<SplConfigItem>(65000);
constexpr inline SplConfigItem SplConfigItem_ExosphereNeedsReboot = static_cast<SplConfigItem>(65001);
constexpr inline SplConfigItem SplConfigItem_ExosphereNeedsShutdown = static_cast<SplConfigItem>(65002);
constexpr inline SplConfigItem SplConfigItem_ExosphereGitCommitHash = static_cast<SplConfigItem>(65003);
constexpr inline SplConfigItem SplConfigItem_ExosphereHasRcmBugPatch = static_cast<SplConfigItem>(65004);
constexpr inline SplConfigItem SplConfigItem_ExosphereBlankProdInfo = static_cast<SplConfigItem>(65005);
constexpr inline SplConfigItem SplConfigItem_ExosphereAllowCalWrites = static_cast<SplConfigItem>(65006);
constexpr inline SplConfigItem SplConfigItem_ExosphereEmummcType = static_cast<SplConfigItem>(65007);
constexpr inline SplConfigItem SplConfigItem_ExospherePayloadAddress = static_cast<SplConfigItem>(65008);
constexpr inline SplConfigItem SplConfigItem_ExosphereLogConfiguration = static_cast<SplConfigItem>(65009);
constexpr inline SplConfigItem SplConfigItem_ExosphereForceEnableUsb30 = static_cast<SplConfigItem>(65010);
#endif
| 9,639
|
C++
|
.h
| 229
| 33.379913
| 117
| 0.587583
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,455
|
spl_api.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/spl/spl_api.hpp
|
/*
* 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 <stratosphere/spl/spl_types.hpp>
namespace ams::spl {
void Initialize();
void InitializeForCrypto();
void InitializeForSsl();
void InitializeForEs();
void InitializeForFs();
void InitializeForManu();
void Finalize();
Result AllocateAesKeySlot(s32 *out_slot);
Result DeallocateAesKeySlot(s32 slot);
Result GenerateAesKek(AccessKey *access_key, const void *key_source, size_t key_source_size, s32 generation, u32 option);
Result LoadAesKey(s32 slot, const AccessKey &access_key, const void *key_source, size_t key_source_size);
Result GenerateAesKey(void *dst, size_t dst_size, const AccessKey &access_key, const void *key_source, size_t key_source_size);
Result GenerateSpecificAesKey(void *dst, size_t dst_size, const void *key_source, size_t key_source_size, s32 generation, u32 option);
Result ComputeCtr(void *dst, size_t dst_size, s32 slot, const void *src, size_t src_size, const void *iv, size_t iv_size);
Result DecryptAesKey(void *dst, size_t dst_size, const void *src, size_t src_size, s32 generation, u32 option);
Result GetConfig(u64 *out, ConfigItem item);
Result SetConfig(ConfigItem item, u64 v);
bool IsDevelopment();
MemoryArrangement GetMemoryArrangement();
inline bool GetConfigBool(ConfigItem item) {
u64 v;
R_ABORT_UNLESS(::ams::spl::GetConfig(std::addressof(v), item));
return v != 0;
}
inline HardwareType GetHardwareType() {
u64 v;
R_ABORT_UNLESS(::ams::spl::GetConfig(std::addressof(v), ::ams::spl::ConfigItem::HardwareType));
return static_cast<HardwareType>(v);
}
inline HardwareState GetHardwareState() {
u64 v;
R_ABORT_UNLESS(::ams::spl::GetConfig(std::addressof(v), ::ams::spl::ConfigItem::HardwareState));
return static_cast<HardwareState>(v);
}
inline RetailInteractiveDisplayState GetRetailInteractiveDisplayState() {
u64 v;
R_ABORT_UNLESS(::ams::spl::GetConfig(std::addressof(v), ::ams::spl::ConfigItem::RetailInteractiveDisplayState));
return static_cast<RetailInteractiveDisplayState>(v);
}
inline u64 GetDeviceIdLow() {
u64 v;
R_ABORT_UNLESS(::ams::spl::GetConfig(std::addressof(v), ::ams::spl::ConfigItem::DeviceId));
return v;
}
inline bool IsRecoveryBoot() {
return ::ams::spl::GetConfigBool(::ams::spl::ConfigItem::IsRecoveryBoot);
}
inline bool IsDevelopmentFunctionEnabled() {
return ::ams::spl::GetConfigBool(::ams::spl::ConfigItem::IsDevelopmentFunctionEnabled);
}
inline bool IsDisabledProgramVerification() {
return ::ams::spl::GetConfigBool(::ams::spl::ConfigItem::DisableProgramVerification);
}
inline bool IsUsb30ForceEnabled() {
return ::ams::spl::GetConfigBool(::ams::spl::ConfigItem::ExosphereForceEnableUsb30);
}
Result SetBootReason(BootReasonValue boot_reason);
Result GetBootReason(BootReasonValue *out);
inline BootReasonValue GetBootReason() {
BootReasonValue br;
R_ABORT_UNLESS(::ams::spl::GetBootReason(std::addressof(br)));
return br;
}
SocType GetSocType();
Result GetPackage2Hash(void *dst, size_t dst_size);
Result GenerateRandomBytes(void *out, size_t buffer_size);
Result LoadPreparedAesKey(s32 slot, const AccessKey &access_key);
Result PrepareCommonEsTitleKey(AccessKey *out, const void *key_source, const size_t key_source_size, int generation);
}
| 4,157
|
C++
|
.h
| 87
| 42.218391
| 138
| 0.713368
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,456
|
spl_device_unique_data_interface.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/spl/impl/spl_device_unique_data_interface.hpp
|
/*
* 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>
#include <stratosphere/sf.hpp>
#include <stratosphere/spl/spl_types.hpp>
#include <stratosphere/spl/impl/spl_crypto_interface.hpp>
#define AMS_SPL_I_DEVICE_UNIQUE_DATA_INTERFACE_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 13, Result, DecryptDeviceUniqueDataDeprecated, (const sf::OutPointerBuffer &dst, const sf::InPointerBuffer &src, spl::AccessKey access_key, spl::KeySource key_source, u32 option), (dst, src, access_key, key_source, option), hos::Version_Min, hos::Version_4_1_0) \
AMS_SF_METHOD_INFO(C, H, 13, Result, DecryptDeviceUniqueData, (const sf::OutPointerBuffer &dst, const sf::InPointerBuffer &src, spl::AccessKey access_key, spl::KeySource key_source), (dst, src, access_key, key_source), hos::Version_5_0_0)
AMS_SF_DEFINE_INTERFACE_WITH_BASE(ams::spl::impl, IDeviceUniqueDataInterface, ::ams::spl::impl::ICryptoInterface, AMS_SPL_I_DEVICE_UNIQUE_DATA_INTERFACE_INTERFACE_INFO, 0xADAD1D0A)
| 1,849
|
C++
|
.h
| 24
| 75
| 294
| 0.654226
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,457
|
spl_general_interface.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/spl/impl/spl_general_interface.hpp
|
/*
* 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>
#include <stratosphere/sf.hpp>
#include <stratosphere/spl/spl_types.hpp>
#define AMS_SPL_I_GENERAL_INTERFACE_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, GetConfig, (sf::Out<u64> out, u32 which), (out, which)) \
AMS_SF_METHOD_INFO(C, H, 1, Result, ModularExponentiate, (const sf::OutPointerBuffer &out, const sf::InPointerBuffer &base, const sf::InPointerBuffer &exp, const sf::InPointerBuffer &mod), (out, base, exp, mod)) \
AMS_SF_METHOD_INFO(C, H, 5, Result, SetConfig, (u32 which, u64 value), (which, value)) \
AMS_SF_METHOD_INFO(C, H, 7, Result, GenerateRandomBytes, (const sf::OutPointerBuffer &out), (out)) \
AMS_SF_METHOD_INFO(C, H, 11, Result, IsDevelopment, (sf::Out<bool> is_dev), (is_dev)) \
AMS_SF_METHOD_INFO(C, H, 24, Result, SetBootReason, (spl::BootReasonValue boot_reason), (boot_reason), hos::Version_3_0_0) \
AMS_SF_METHOD_INFO(C, H, 25, Result, GetBootReason, (sf::Out<spl::BootReasonValue> out), (out), hos::Version_3_0_0)
AMS_SF_DEFINE_INTERFACE(ams::spl::impl, IGeneralInterface, AMS_SPL_I_GENERAL_INTERFACE_INTERFACE_INFO, 0x127DDBD0)
| 2,772
|
C++
|
.h
| 28
| 96.392857
| 238
| 0.46151
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,458
|
spl_manu_interface.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/spl/impl/spl_manu_interface.hpp
|
/*
* 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>
#include <stratosphere/sf.hpp>
#include <stratosphere/spl/spl_types.hpp>
#include <stratosphere/spl/impl/spl_device_unique_data_interface.hpp>
#define AMS_SPL_I_MANU_INTERFACE_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 30, Result, ReencryptDeviceUniqueData, (const sf::OutPointerBuffer &out, const sf::InPointerBuffer &src, spl::AccessKey access_key_dec, spl::KeySource source_dec, spl::AccessKey access_key_enc, spl::KeySource source_enc, u32 option), (out, src, access_key_dec, source_dec, access_key_enc, source_enc, option))
AMS_SF_DEFINE_INTERFACE_WITH_BASE(ams::spl::impl, IManuInterface, ::ams::spl::impl::IDeviceUniqueDataInterface, AMS_SPL_I_MANU_INTERFACE_INTERFACE_INFO, 0xF5643734)
| 1,377
|
C++
|
.h
| 23
| 57.956522
| 338
| 0.766839
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,459
|
spl_api_impl.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/spl/impl/spl_api_impl.hpp
|
/*
* 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 <stratosphere/spl/spl_types.hpp>
namespace ams::spl::impl {
constexpr inline s32 AesKeySlotMin = 16;
constexpr inline s32 AesKeySlotCount = 9;
constexpr inline s32 AesKeySlotMax = AesKeySlotMin + AesKeySlotCount - 1;
/* Initialization. */
void Initialize();
/* General. */
Result GetConfig(u64 *out, spl::ConfigItem key);
Result ModularExponentiate(void *out, size_t out_size, const void *base, size_t base_size, const void *exp, size_t exp_size, const void *mod, size_t mod_size);
Result SetConfig(spl::ConfigItem key, u64 value);
Result GenerateRandomBytes(void *out, size_t size);
Result IsDevelopment(bool *out);
Result SetBootReason(BootReasonValue boot_reason);
Result GetBootReason(BootReasonValue *out);
ALWAYS_INLINE bool GetConfigBool(spl::ConfigItem key) {
u64 v;
R_ABORT_UNLESS(::ams::spl::impl::GetConfig(std::addressof(v), key));
return v != 0;
}
/* Crypto. */
Result GenerateAesKek(AccessKey *out_access_key, const KeySource &key_source, u32 generation, u32 option);
Result LoadAesKey(s32 keyslot, const AccessKey &access_key, const KeySource &key_source);
Result GenerateAesKey(AesKey *out_key, const AccessKey &access_key, const KeySource &key_source);
Result DecryptAesKey(AesKey *out_key, const KeySource &key_source, u32 generation, u32 option);
Result ComputeCtr(void *dst, size_t dst_size, s32 keyslot, const void *src, size_t src_size, const IvCtr &iv_ctr);
Result ComputeCmac(Cmac *out_cmac, s32 keyslot, const void *data, size_t size);
Result AllocateAesKeySlot(s32 *out_keyslot);
Result DeallocateAesKeySlot(s32 keyslot);
Result TestAesKeySlot(s32 *out_index, bool *out_virtual, s32 keyslot);
os::SystemEvent *GetAesKeySlotAvailableEvent();
/* RSA. */
Result DecryptDeviceUniqueData(void *dst, size_t dst_size, const void *src, size_t src_size, const AccessKey &access_key, const KeySource &key_source, u32 option);
/* SSL */
Result DecryptAndStoreSslClientCertKey(const void *src, size_t src_size, const AccessKey &access_key, const KeySource &key_source);
Result ModularExponentiateWithSslClientCertKey(void *out, size_t out_size, const void *base, size_t base_size, const void *mod, size_t mod_size);
/* ES */
Result LoadEsDeviceKey(const void *src, size_t src_size, const AccessKey &access_key, const KeySource &key_source, u32 option);
Result PrepareEsTitleKey(AccessKey *out_access_key, const void *base, size_t base_size, const void *mod, size_t mod_size, const void *label_digest, size_t label_digest_size, u32 generation);
Result PrepareCommonEsTitleKey(AccessKey *out_access_key, const KeySource &key_source, u32 generation);
Result DecryptAndStoreDrmDeviceCertKey(const void *src, size_t src_size, const AccessKey &access_key, const KeySource &key_source);
Result ModularExponentiateWithDrmDeviceCertKey(void *out, size_t out_size, const void *base, size_t base_size, const void *mod, size_t mod_size);
Result PrepareEsArchiveKey(AccessKey *out_access_key, const void *base, size_t base_size, const void *mod, size_t mod_size, const void *label_digest, size_t label_digest_size, u32 generation);
Result LoadPreparedAesKey(s32 keyslot, const AccessKey &access_key);
Result PrepareEsUnknown2Key(AccessKey *out_access_key, const void *base, size_t base_size, const void *mod, size_t mod_size, const void *label_digest, size_t label_digest_size, u32 generation);
/* FS */
Result DecryptAndStoreGcKey(const void *src, size_t src_size, const AccessKey &access_key, const KeySource &key_source, u32 option);
Result DecryptGcMessage(u32 *out_size, void *dst, size_t dst_size, const void *base, size_t base_size, const void *mod, size_t mod_size, const void *label_digest, size_t label_digest_size);
Result GenerateSpecificAesKey(AesKey *out_key, const KeySource &key_source, u32 generation, u32 which);
Result LoadPreparedAesKey(s32 keyslot, const AccessKey &access_key);
Result GetPackage2Hash(void *dst, const size_t size);
/* Manu. */
Result ReencryptDeviceUniqueData(void *dst, size_t dst_size, const void *src, size_t src_size, const AccessKey &access_key_dec, const KeySource &source_dec, const AccessKey &access_key_enc, const KeySource &source_enc, u32 option);
}
| 4,993
|
C++
|
.h
| 70
| 66.828571
| 235
| 0.743888
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,460
|
spl_deprecated_general_interface.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/spl/impl/spl_deprecated_general_interface.hpp
|
/*
* 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>
#include <stratosphere/sf.hpp>
#include <stratosphere/spl/spl_types.hpp>
#define AMS_SPL_I_DEPRECATED_GENERAL_INTERFACE_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, GetConfig, (sf::Out<u64> out, u32 which), (out, which)) \
AMS_SF_METHOD_INFO(C, H, 1, Result, ModularExponentiate, (const sf::OutPointerBuffer &out, const sf::InPointerBuffer &base, const sf::InPointerBuffer &exp, const sf::InPointerBuffer &mod), (out, base, exp, mod)) \
AMS_SF_METHOD_INFO(C, H, 2, Result, GenerateAesKek, (sf::Out<spl::AccessKey> out_access_key, spl::KeySource key_source, u32 generation, u32 option), (out_access_key, key_source, generation, option)) \
AMS_SF_METHOD_INFO(C, H, 3, Result, LoadAesKey, (s32 keyslot, spl::AccessKey access_key, spl::KeySource key_source), (keyslot, access_key, key_source)) \
AMS_SF_METHOD_INFO(C, H, 4, Result, GenerateAesKey, (sf::Out<spl::AesKey> out_key, spl::AccessKey access_key, spl::KeySource key_source), (out_key, access_key, key_source)) \
AMS_SF_METHOD_INFO(C, H, 5, Result, SetConfig, (u32 which, u64 value), (which, value)) \
AMS_SF_METHOD_INFO(C, H, 7, Result, GenerateRandomBytes, (const sf::OutPointerBuffer &out), (out)) \
AMS_SF_METHOD_INFO(C, H, 9, Result, DecryptAndStoreGcKey, (const sf::InPointerBuffer &src, spl::AccessKey access_key, spl::KeySource key_source, u32 option), (src, access_key, key_source, option)) \
AMS_SF_METHOD_INFO(C, H, 10, Result, DecryptGcMessage, (sf::Out<u32> out_size, const sf::OutPointerBuffer &out, const sf::InPointerBuffer &base, const sf::InPointerBuffer &mod, const sf::InPointerBuffer &label_digest), (out_size, out, base, mod, label_digest)) \
AMS_SF_METHOD_INFO(C, H, 11, Result, IsDevelopment, (sf::Out<bool> is_dev), (is_dev)) \
AMS_SF_METHOD_INFO(C, H, 12, Result, GenerateSpecificAesKey, (sf::Out<spl::AesKey> out_key, spl::KeySource key_source, u32 generation, u32 which), (out_key, key_source, generation, which)) \
AMS_SF_METHOD_INFO(C, H, 13, Result, DecryptDeviceUniqueData, (const sf::OutPointerBuffer &dst, const sf::InPointerBuffer &src, spl::AccessKey access_key, spl::KeySource key_source, u32 option), (dst, src, access_key, key_source, option)) \
AMS_SF_METHOD_INFO(C, H, 14, Result, DecryptAesKey, (sf::Out<spl::AesKey> out_key, spl::KeySource key_source, u32 generation, u32 option), (out_key, key_source, generation, option)) \
AMS_SF_METHOD_INFO(C, H, 15, Result, ComputeCtrDeprecated, (const sf::OutBuffer &out_buf, s32 keyslot, const sf::InBuffer &in_buf, spl::IvCtr iv_ctr), (out_buf, keyslot, in_buf, iv_ctr), hos::Version_1_0_0, hos::Version_1_0_0) \
AMS_SF_METHOD_INFO(C, H, 15, Result, ComputeCtr, (const sf::OutNonSecureBuffer &out_buf, s32 keyslot, const sf::InNonSecureBuffer &in_buf, spl::IvCtr iv_ctr), (out_buf, keyslot, in_buf, iv_ctr), hos::Version_2_0_0) \
AMS_SF_METHOD_INFO(C, H, 16, Result, ComputeCmac, (sf::Out<spl::Cmac> out_cmac, s32 keyslot, const sf::InPointerBuffer &in_buf), (out_cmac, keyslot, in_buf)) \
AMS_SF_METHOD_INFO(C, H, 17, Result, LoadEsDeviceKey, (const sf::InPointerBuffer &src, spl::AccessKey access_key, spl::KeySource key_source, u32 option), (src, access_key, key_source, option)) \
AMS_SF_METHOD_INFO(C, H, 18, Result, PrepareEsTitleKeyDeprecated, (sf::Out<spl::AccessKey> out_access_key, const sf::InPointerBuffer &base, const sf::InPointerBuffer &mod, const sf::InPointerBuffer &label_digest), (out_access_key, base, mod, label_digest), hos::Version_1_0_0, hos::Version_2_3_0) \
AMS_SF_METHOD_INFO(C, H, 18, Result, PrepareEsTitleKey, (sf::Out<spl::AccessKey> out_access_key, const sf::InPointerBuffer &base, const sf::InPointerBuffer &mod, const sf::InPointerBuffer &label_digest, u32 generation), (out_access_key, base, mod, label_digest, generation), hos::Version_3_0_0) \
AMS_SF_METHOD_INFO(C, H, 19, Result, LoadPreparedAesKey, (s32 keyslot, spl::AccessKey access_key), (keyslot, access_key)) \
AMS_SF_METHOD_INFO(C, H, 20, Result, PrepareCommonEsTitleKeyDeprecated, (sf::Out<spl::AccessKey> out_access_key, spl::KeySource key_source), (out_access_key, key_source), hos::Version_2_0_0, hos::Version_2_3_0) \
AMS_SF_METHOD_INFO(C, H, 20, Result, PrepareCommonEsTitleKey, (sf::Out<spl::AccessKey> out_access_key, spl::KeySource key_source, u32 generation), (out_access_key, key_source, generation), hos::Version_3_0_0) \
AMS_SF_METHOD_INFO(C, H, 21, Result, AllocateAesKeySlot, (sf::Out<s32> out_keyslot), (out_keyslot)) \
AMS_SF_METHOD_INFO(C, H, 22, Result, DeallocateAesKeySlot, (s32 keyslot), (keyslot)) \
AMS_SF_METHOD_INFO(C, H, 23, Result, GetAesKeySlotAvailableEvent, (sf::OutCopyHandle out_hnd), (out_hnd)) \
AMS_SF_METHOD_INFO(C, H, 24, Result, SetBootReason, (spl::BootReasonValue boot_reason), (boot_reason), hos::Version_3_0_0) \
AMS_SF_METHOD_INFO(C, H, 25, Result, GetBootReason, (sf::Out<spl::BootReasonValue> out), (out), hos::Version_3_0_0)
AMS_SF_DEFINE_INTERFACE(ams::spl::impl, IDeprecatedGeneralInterface, AMS_SPL_I_DEPRECATED_GENERAL_INTERFACE_INTERFACE_INFO, 0x127DDBD0)
| 10,297
|
C++
|
.h
| 48
| 210.916667
| 336
| 0.39918
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,461
|
spl_ssl_interface.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/spl/impl/spl_ssl_interface.hpp
|
/*
* 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>
#include <stratosphere/sf.hpp>
#include <stratosphere/spl/spl_types.hpp>
#include <stratosphere/spl/impl/spl_device_unique_data_interface.hpp>
#define AMS_SPL_I_SSL_INTERFACE_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 26, Result, DecryptAndStoreSslClientCertKey, (const sf::InPointerBuffer &src, spl::AccessKey access_key, spl::KeySource key_source), (src, access_key, key_source), hos::Version_5_0_0) \
AMS_SF_METHOD_INFO(C, H, 27, Result, ModularExponentiateWithSslClientCertKey, (const sf::OutPointerBuffer &out, const sf::InPointerBuffer &base, const sf::InPointerBuffer &mod), (out, base, mod), hos::Version_5_0_0)
AMS_SF_DEFINE_INTERFACE_WITH_BASE(ams::spl::impl, ISslInterface, ::ams::spl::impl::IDeviceUniqueDataInterface, AMS_SPL_I_SSL_INTERFACE_INTERFACE_INFO, 0x0E1D71B7)
| 1,683
|
C++
|
.h
| 24
| 68.083333
| 234
| 0.664251
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,462
|
spl_fs_interface.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/spl/impl/spl_fs_interface.hpp
|
/*
* 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>
#include <stratosphere/sf.hpp>
#include <stratosphere/spl/spl_types.hpp>
#include <stratosphere/spl/impl/spl_crypto_interface.hpp>
#define AMS_SPL_I_FS_INTERFACE_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 9, Result, DecryptAndStoreGcKeyDeprecated, (const sf::InPointerBuffer &src, spl::AccessKey access_key, spl::KeySource key_source, u32 option), (src, access_key, key_source, option), hos::Version_Min, hos::Version_4_1_0) \
AMS_SF_METHOD_INFO(C, H, 9, Result, DecryptAndStoreGcKey, (const sf::InPointerBuffer &src, spl::AccessKey access_key, spl::KeySource key_source), (src, access_key, key_source), hos::Version_5_0_0) \
AMS_SF_METHOD_INFO(C, H, 10, Result, DecryptGcMessage, (sf::Out<u32> out_size, const sf::OutPointerBuffer &out, const sf::InPointerBuffer &base, const sf::InPointerBuffer &mod, const sf::InPointerBuffer &label_digest), (out_size, out, base, mod, label_digest)) \
AMS_SF_METHOD_INFO(C, H, 12, Result, GenerateSpecificAesKey, (sf::Out<spl::AesKey> out_key, spl::KeySource key_source, u32 generation, u32 which), (out_key, key_source, generation, which)) \
AMS_SF_METHOD_INFO(C, H, 19, Result, LoadPreparedAesKey, (s32 keyslot, spl::AccessKey access_key), (keyslot, access_key)) \
AMS_SF_METHOD_INFO(C, H, 31, Result, GetPackage2Hash, (const sf::OutPointerBuffer &dst), (dst), hos::Version_5_0_0)
AMS_SF_DEFINE_INTERFACE_WITH_BASE(ams::spl::impl, IFsInterface, ::ams::spl::impl::ICryptoInterface, AMS_SPL_I_FS_INTERFACE_INTERFACE_INFO, 0x682B3803)
| 3,146
|
C++
|
.h
| 28
| 109.892857
| 320
| 0.510112
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,463
|
spl_es_interface.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/spl/impl/spl_es_interface.hpp
|
/*
* 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>
#include <stratosphere/sf.hpp>
#include <stratosphere/spl/spl_types.hpp>
#include <stratosphere/spl/impl/spl_device_unique_data_interface.hpp>
#define AMS_SPL_I_ES_INTERFACE_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 17, Result, LoadEsDeviceKeyDeprecated, (const sf::InPointerBuffer &src, spl::AccessKey access_key, spl::KeySource key_source, u32 option), (src, access_key, key_source, option), hos::Version_Min, hos::Version_4_1_0) \
AMS_SF_METHOD_INFO(C, H, 17, Result, LoadEsDeviceKey, (const sf::InPointerBuffer &src, spl::AccessKey access_key, spl::KeySource key_source), (src, access_key, key_source), hos::Version_5_0_0) \
AMS_SF_METHOD_INFO(C, H, 18, Result, PrepareEsTitleKey, (sf::Out<spl::AccessKey> out_access_key, const sf::InPointerBuffer &base, const sf::InPointerBuffer &mod, const sf::InPointerBuffer &label_digest, u32 generation), (out_access_key, base, mod, label_digest, generation)) \
AMS_SF_METHOD_INFO(C, H, 20, Result, PrepareCommonEsTitleKey, (sf::Out<spl::AccessKey> out_access_key, spl::KeySource key_source, u32 generation), (out_access_key, key_source, generation), hos::Version_2_0_0) \
AMS_SF_METHOD_INFO(C, H, 28, Result, DecryptAndStoreDrmDeviceCertKey, (const sf::InPointerBuffer &src, spl::AccessKey access_key, spl::KeySource key_source), (src, access_key, key_source), hos::Version_5_0_0) \
AMS_SF_METHOD_INFO(C, H, 29, Result, ModularExponentiateWithDrmDeviceCertKey, (const sf::OutPointerBuffer &out, const sf::InPointerBuffer &base, const sf::InPointerBuffer &mod), (out, base, mod), hos::Version_5_0_0) \
AMS_SF_METHOD_INFO(C, H, 31, Result, PrepareEsArchiveKey, (sf::Out<spl::AccessKey> out_access_key, const sf::InPointerBuffer &base, const sf::InPointerBuffer &mod, const sf::InPointerBuffer &label_digest, u32 generation), (out_access_key, base, mod, label_digest, generation), hos::Version_6_0_0) \
AMS_SF_METHOD_INFO(C, H, 32, Result, LoadPreparedAesKey, (s32 keyslot, spl::AccessKey access_key), (keyslot, access_key), hos::Version_6_0_0) \
AMS_SF_METHOD_INFO(C, H, 33, Result, PrepareEsUnknown2Key, (sf::Out<spl::AccessKey> out_access_key, const sf::InPointerBuffer &base, const sf::InPointerBuffer &mod, const sf::InPointerBuffer &label_digest, u32 generation), (out_access_key, base, mod, label_digest, generation), hos::Version_18_0_0)
AMS_SF_DEFINE_INTERFACE_WITH_BASE(ams::spl::impl, IEsInterface, ::ams::spl::impl::IDeviceUniqueDataInterface, AMS_SPL_I_ES_INTERFACE_INTERFACE_INFO, 0x346D5001)
| 4,387
|
C++
|
.h
| 31
| 138.806452
| 342
| 0.535493
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,464
|
spl_random_interface.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/spl/impl/spl_random_interface.hpp
|
/*
* 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>
#include <stratosphere/sf.hpp>
#include <stratosphere/spl/spl_types.hpp>
#define AMS_SPL_I_RANDOM_INTERFACE_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, GenerateRandomBytes, (const sf::OutBuffer &out), (out))
AMS_SF_DEFINE_INTERFACE(ams::spl::impl, IRandomInterface, AMS_SPL_I_RANDOM_INTERFACE_INTERFACE_INFO, 0xBDE33ED4)
| 1,013
|
C++
|
.h
| 22
| 44.136364
| 112
| 0.760364
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,465
|
spl_crypto_interface.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/spl/impl/spl_crypto_interface.hpp
|
/*
* 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>
#include <stratosphere/sf.hpp>
#include <stratosphere/spl/spl_types.hpp>
#include <stratosphere/spl/impl/spl_general_interface.hpp>
#define AMS_SPL_I_CRYPTO_INTERFACE_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 2, Result, GenerateAesKek, (sf::Out<spl::AccessKey> out_access_key, spl::KeySource key_source, u32 generation, u32 option), (out_access_key, key_source, generation, option)) \
AMS_SF_METHOD_INFO(C, H, 3, Result, LoadAesKey, (s32 keyslot, spl::AccessKey access_key, spl::KeySource key_source), (keyslot, access_key, key_source)) \
AMS_SF_METHOD_INFO(C, H, 4, Result, GenerateAesKey, (sf::Out<spl::AesKey> out_key, spl::AccessKey access_key, spl::KeySource key_source), (out_key, access_key, key_source)) \
AMS_SF_METHOD_INFO(C, H, 14, Result, DecryptAesKey, (sf::Out<spl::AesKey> out_key, spl::KeySource key_source, u32 generation, u32 option), (out_key, key_source, generation, option)) \
AMS_SF_METHOD_INFO(C, H, 15, Result, ComputeCtr, (const sf::OutNonSecureBuffer &out_buf, s32 keyslot, const sf::InNonSecureBuffer &in_buf, spl::IvCtr iv_ctr), (out_buf, keyslot, in_buf, iv_ctr)) \
AMS_SF_METHOD_INFO(C, H, 16, Result, ComputeCmac, (sf::Out<spl::Cmac> out_cmac, s32 keyslot, const sf::InPointerBuffer &in_buf), (out_cmac, keyslot, in_buf)) \
AMS_SF_METHOD_INFO(C, H, 21, Result, AllocateAesKeySlot, (sf::Out<s32> out_keyslot), (out_keyslot)) \
AMS_SF_METHOD_INFO(C, H, 22, Result, DeallocateAesKeySlot, (s32 keyslot), (keyslot)) \
AMS_SF_METHOD_INFO(C, H, 23, Result, GetAesKeySlotAvailableEvent, (sf::OutCopyHandle out_hnd), (out_hnd))
AMS_SF_DEFINE_INTERFACE_WITH_BASE(ams::spl::impl, ICryptoInterface, ::ams::spl::impl::IGeneralInterface, AMS_SPL_I_CRYPTO_INTERFACE_INTERFACE_INFO, 0xEF3598D9)
| 3,245
|
C++
|
.h
| 31
| 101.967742
| 231
| 0.544379
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,466
|
spl_secure_monitor_api.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/spl/smc/spl_secure_monitor_api.hpp
|
/*
* 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 <stratosphere/spl/spl_types.hpp>
namespace ams::spl::smc {
/* Helpers for converting arguments. */
constexpr ALWAYS_INLINE u32 GetComputeAesMode(CipherMode mode, u32 keyslot) {
return static_cast<u32>((static_cast<u32>(mode) << 4) | (keyslot & 7));
}
constexpr ALWAYS_INLINE u32 GetPrepareEsDeviceUniqueKeyOption(EsDeviceUniqueKeyType type, u32 generation) {
return static_cast<u32>((static_cast<u32>(type) << 6) | (generation & 0x3F));
}
/* Functions. */
Result SetConfig(AsyncOperationKey *out_op, spl::ConfigItem key, const u64 *value, size_t num_qwords, const void *sign);
Result GetConfig(u64 *out, size_t num_qwords, spl::ConfigItem key);
Result GetResult(Result *out, AsyncOperationKey op);
Result GetResultData(Result *out, void *out_buf, size_t out_buf_size, AsyncOperationKey op);
Result ModularExponentiate(AsyncOperationKey *out_op, const void *base, const void *exp, size_t exp_size, const void *mod);
Result GenerateRandomBytes(void *out, size_t size);
Result GenerateAesKek(AccessKey *out, const KeySource &source, u32 generation, u32 option);
Result LoadAesKey(u32 keyslot, const AccessKey &access_key, const KeySource &source);
Result ComputeAes(AsyncOperationKey *out_op, u64 dst_addr, u32 mode, const IvCtr &iv_ctr, u64 src_addr, size_t size);
Result GenerateSpecificAesKey(AesKey *out_key, const KeySource &source, u32 generation, u32 which);
Result ComputeCmac(Cmac *out_mac, u32 keyslot, const void *data, size_t size);
Result ReencryptDeviceUniqueData(void *data, size_t size, const AccessKey &access_key_dec, const KeySource &source_dec, const AccessKey &access_key_enc, const KeySource &source_enc, u32 option);
Result DecryptDeviceUniqueData(void *data, size_t size, const AccessKey &access_key, const KeySource &source, DeviceUniqueDataMode mode);
Result ModularExponentiateWithStorageKey(AsyncOperationKey *out_op, const void *base, const void *mod, ModularExponentiateWithStorageKeyMode mode);
Result PrepareEsDeviceUniqueKey(AsyncOperationKey *out_op, const void *base, const void *mod, const void *label_digest, size_t label_digest_size, u32 option);
Result LoadPreparedAesKey(u32 keyslot, const AccessKey &access_key);
Result PrepareCommonEsTitleKey(AccessKey *out, const KeySource &source, u32 generation);
/* Deprecated functions. */
Result LoadEsDeviceKey(const void *data, size_t size, const AccessKey &access_key, const KeySource &source, u32 option);
Result DecryptDeviceUniqueData(size_t *out_size, void *data, size_t size, const AccessKey &access_key, const KeySource &source, u32 option);
Result DecryptAndStoreGcKey(const void *data, size_t size, const AccessKey &access_key, const KeySource &source, u32 option);
/* Atmosphere functions. */
Result AtmosphereCopyToIram(uintptr_t iram_dst, const void *dram_src, size_t size);
Result AtmosphereCopyFromIram(void *dram_dst, uintptr_t iram_src, size_t size);
Result AtmosphereReadWriteRegister(uint64_t address, uint32_t mask, uint32_t value, uint32_t *out_value);
Result AtmosphereGetEmummcConfig(void *out_config, void *out_paths, u32 storage_id);
/* Helpers. */
ALWAYS_INLINE Result SetConfig(spl::ConfigItem key, const u64 *value, size_t num_qwords) {
AsyncOperationKey dummy_op;
return SetConfig(std::addressof(dummy_op), key, value, num_qwords, nullptr);
}
ALWAYS_INLINE Result SetConfig(spl::ConfigItem key, const u64 value) {
return SetConfig(key, std::addressof(value), 1);
}
#if !defined(ATMOSPHERE_OS_HORIZON)
void PresetInternalKey(const AesKey *key, u32 generation, bool device);
#endif
}
| 4,359
|
C++
|
.h
| 64
| 63.59375
| 198
| 0.749533
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,467
|
htclow_module_types.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/htclow/htclow_module_types.hpp
|
/*
* 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>
#include <stratosphere/htclow/htclow_module_types.hpp>
namespace ams::htclow {
enum class ModuleId : u8 {
Unknown = 0,
Htcfs = 1,
Htcmisc = 3,
Htcs = 4,
};
struct ModuleType {
bool _is_initialized;
ModuleId _id;
};
constexpr void InitializeModule(ModuleType *out, ModuleId id) {
*out = {
._is_initialized = true,
._id = id,
};
}
constexpr void FinalizeModule(ModuleType *out) {
*out = {
._is_initialized = false,
._id = ModuleId::Unknown,
};
}
class Module final {
private:
ModuleType m_impl;
public:
constexpr explicit Module(ModuleId id) : m_impl() {
InitializeModule(std::addressof(m_impl), id);
}
constexpr ~Module() {
FinalizeModule(std::addressof(m_impl));
}
ModuleType *GetBase() { return std::addressof(m_impl); }
const ModuleType *GetBase() const { return std::addressof(m_impl); }
};
}
| 1,807
|
C++
|
.h
| 55
| 25.945455
| 80
| 0.605974
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,468
|
htclow_types.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/htclow/htclow_types.hpp
|
/*
* 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::htclow {
namespace impl {
enum class DriverType {
Unknown = 0,
Debug = 1,
Socket = 2,
Usb = 3,
HostBridge = 4,
PlainChannel = 5,
};
}
constexpr inline s16 ProtocolVersion = 5;
enum ReceiveOption {
ReceiveOption_NonBlocking = 0,
ReceiveOption_ReceiveAnyData = 1,
ReceiveOption_ReceiveAllData = 2,
};
}
| 1,158
|
C++
|
.h
| 35
| 27.714286
| 76
| 0.651434
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,469
|
htclow_channel_types.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/htclow/htclow_channel_types.hpp
|
/*
* 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>
#include <stratosphere/htclow/htclow_module_types.hpp>
namespace ams::htclow {
using ChannelId = u16;
struct ChannelType {
bool _is_initialized;
ModuleId _module_id;
ChannelId _channel_id;
};
enum ChannelState {
ChannelState_Connectable = 0,
ChannelState_Unconnectable = 1,
ChannelState_Connected = 2,
ChannelState_Disconnected = 3,
};
struct ChannelConfig {
bool flow_control_enabled;
bool handshake_enabled;
u64 initial_counter_max_data;
size_t max_packet_size;
};
constexpr bool IsStateTransitionAllowed(ChannelState from, ChannelState to) {
switch (from) {
case ChannelState_Connectable:
return to == ChannelState_Unconnectable ||
to == ChannelState_Connected ||
to == ChannelState_Disconnected;
case ChannelState_Unconnectable:
return to == ChannelState_Connectable ||
to == ChannelState_Disconnected;
case ChannelState_Connected:
return to == ChannelState_Disconnected;
case ChannelState_Disconnected:
return to == ChannelState_Disconnected;
AMS_UNREACHABLE_DEFAULT_CASE();
}
}
}
| 2,004
|
C++
|
.h
| 54
| 29.555556
| 81
| 0.655687
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,470
|
htclow_manager_holder.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/htclow/htclow_manager_holder.hpp
|
/*
* 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>
#include <stratosphere/htclow/htclow_types.hpp>
namespace ams::htclow {
class HtclowManager;
namespace HtclowManagerHolder {
void AddReference();
void Release();
HtclowManager *GetHtclowManager();
void SetDefaultDriver(htclow::impl::DriverType driver_type);
}
}
| 985
|
C++
|
.h
| 27
| 33.037037
| 76
| 0.742105
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,471
|
htclow_internal_types.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/htclow/impl/htclow_internal_types.hpp
|
/*
* 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>
#include <stratosphere/htclow/htclow_channel_types.hpp>
namespace ams::htclow::impl {
struct ChannelInternalType {
ChannelId channel_id;
s8 reserved;
ModuleId module_id;
};
static_assert(sizeof(ChannelInternalType) == 4);
constexpr ALWAYS_INLINE ChannelInternalType ConvertChannelType(ChannelType channel) {
return {
.channel_id = channel._channel_id,
.reserved = 0,
.module_id = channel._module_id,
};
}
constexpr ALWAYS_INLINE bool operator==(const ChannelInternalType &lhs, const ChannelInternalType &rhs) {
return lhs.module_id == rhs.module_id && lhs.reserved == rhs.reserved && lhs.channel_id == rhs.channel_id;
}
constexpr ALWAYS_INLINE bool operator!=(const ChannelInternalType &lhs, const ChannelInternalType &rhs) {
return !(lhs == rhs);
}
constexpr ALWAYS_INLINE bool operator<(const ChannelInternalType &lhs, const ChannelInternalType &rhs) {
return std::tie(lhs.module_id, lhs.reserved, lhs.channel_id) < std::tie(rhs.module_id, rhs.reserved, rhs.channel_id);
}
constexpr ALWAYS_INLINE bool operator>(const ChannelInternalType &lhs, const ChannelInternalType &rhs) {
return rhs < lhs;
}
constexpr ALWAYS_INLINE bool operator<=(const ChannelInternalType &lhs, const ChannelInternalType &rhs) {
return !(lhs > rhs);
}
constexpr ALWAYS_INLINE bool operator>=(const ChannelInternalType &lhs, const ChannelInternalType &rhs) {
return !(lhs < rhs);
}
}
| 2,236
|
C++
|
.h
| 51
| 38.607843
| 125
| 0.708046
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,472
|
util_lock_free_atomic_type.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/util/util_lock_free_atomic_type.hpp
|
/*
* 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>
#include <stratosphere/os/os_memory_fence_api.hpp>
namespace ams::util {
template<typename T>
struct LockFreeAtomicType {
volatile u32 _counter;
T _value[2];
};
template<typename T>
void StoreToLockFreeAtomicType(LockFreeAtomicType<T> *p, const T &value) {
/* Get the current counter. */
auto counter = p->_counter;
/* Increment the counter. */
++counter;
/* Store the updated value. */
p->_value[counter % 2] = value;
/* Fence memory. */
os::FenceMemoryStoreStore();
/* Set the updated counter. */
p->_counter = counter;
}
template<typename T>
T LoadFromLockFreeAtomicType(const LockFreeAtomicType<T> *p) {
while (true) {
/* Get the counter. */
auto counter = p->_counter;
/* Get the value. */
auto value = p->_value[counter % 2];
/* Fence memory. */
os::FenceMemoryLoadLoad();
/* Check that the counter matches. */
if (counter == p->_counter) {
return value;
}
}
}
}
| 1,824
|
C++
|
.h
| 53
| 27.792453
| 78
| 0.624218
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,473
|
util_uuid_api.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/util/util_uuid_api.hpp
|
/*
* 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::util {
/* Nintendo provides UUID generation following RFC 4122. */
/* By default, UUIDs are generated as version 4 (random). */
Uuid GenerateUuid();
Uuid GenerateUuidVersion5(const void *sha1_hash);
}
| 908
|
C++
|
.h
| 23
| 37
| 76
| 0.745743
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,474
|
util_singleton_traits.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/util/util_singleton_traits.hpp
|
/*
* 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>
#include <stratosphere/os/os_sdk_mutex.hpp>
#define AMS_SINGLETON_TRAITS(_CLASSNAME_) \
private: \
NON_COPYABLE(_CLASSNAME_); \
NON_MOVEABLE(_CLASSNAME_); \
private: \
_CLASSNAME_ (); \
public: \
static _CLASSNAME_ &GetInstance() { \
AMS_FUNCTION_LOCAL_STATIC(_CLASSNAME_, s_singleton_instance); \
\
return s_singleton_instance; \
}
#define AMS_CONSTINIT_SINGLETON_TRAITS(_CLASSNAME_) \
private: \
NON_COPYABLE(_CLASSNAME_); \
NON_MOVEABLE(_CLASSNAME_); \
private: \
constexpr _CLASSNAME_ () = default; \
public: \
static _CLASSNAME_ &GetInstance() { \
/* Declare singleton instance variables. */ \
AMS_FUNCTION_LOCAL_STATIC_CONSTINIT(_CLASSNAME_, s_singleton_instance); \
return s_singleton_instance; \
}
| 2,520
|
C++
|
.h
| 42
| 52.928571
| 85
| 0.403636
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,475
|
util_compression.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/util/util_compression.hpp
|
/*
* 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::util {
/* Compression utilities. */
int CompressLZ4(void *dst, size_t dst_size, const void *src, size_t src_size);
/* Decompression utilities. */
int DecompressLZ4(void *dst, size_t dst_size, const void *src, size_t src_size);
}
| 935
|
C++
|
.h
| 23
| 38.173913
| 84
| 0.737885
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,476
|
util_ini.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/util/util_ini.hpp
|
/*
* 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>
#include <stratosphere/fs/fs_file.hpp>
namespace ams::fs::fsa {
class IFile;
}
namespace ams::util::ini {
/* Ini handler type. */
using Handler = int (*)(void *user_ctx, const char *section, const char *name, const char *value);
/* Utilities for dealing with INI file configuration. */
int ParseString(const char *ini_str, void *user_ctx, Handler h);
int ParseFile(fs::FileHandle file, void *user_ctx, Handler h);
int ParseFile(fs::fsa::IFile *file, void *user_ctx, Handler h);
}
| 1,186
|
C++
|
.h
| 29
| 38.206897
| 102
| 0.728696
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,477
|
psc_pm_module.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/psc/psc_pm_module.hpp
|
/*
* 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>
#if defined(ATMOSPHERE_OS_HORIZON)
#include <stratosphere/psc/psc_pm_module.os.horizon.hpp>
#else
#include <stratosphere/psc/psc_pm_module.os.generic.hpp>
#endif
| 843
|
C++
|
.h
| 22
| 36.227273
| 76
| 0.760684
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,478
|
psc_pm_module_id.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/psc/psc_pm_module_id.hpp
|
/*
* 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::psc {
enum PmModuleId : u32 {
PmModuleId_Reserved0 = 0,
PmModuleId_Usb = 4,
PmModuleId_Ethernet = 5,
PmModuleId_Fgm = 6,
PmModuleId_PcvClock = 7,
PmModuleId_PcvVoltage = 8,
PmModuleId_Gpio = 9,
PmModuleId_Pinmux = 10,
PmModuleId_Uart = 11,
PmModuleId_I2c = 12,
PmModuleId_I2cPcv = 13,
PmModuleId_Spi = 14,
PmModuleId_Pwm = 15,
PmModuleId_Psm = 16,
PmModuleId_Tc = 17,
PmModuleId_Omm = 18,
PmModuleId_Pcie = 19,
PmModuleId_Lbl = 20,
PmModuleId_Display = 21,
PmModuleId_Hid = 24,
PmModuleId_WlanSockets = 25,
PmModuleId_Fs = 27,
PmModuleId_Audio = 28,
PmModuleId_TmaHostIo = 30,
PmModuleId_Bluetooth = 31,
PmModuleId_Bpc = 32,
PmModuleId_Fan = 33,
PmModuleId_Pcm = 34,
PmModuleId_Nfc = 35,
PmModuleId_Apm = 36,
PmModuleId_Btm = 37,
PmModuleId_Nifm = 38,
PmModuleId_GpioLow = 39,
PmModuleId_Npns = 40,
PmModuleId_Lm = 41,
PmModuleId_Bcat = 42,
PmModuleId_Time = 43,
PmModuleId_Pctl = 44,
PmModuleId_Erpt = 45,
PmModuleId_Eupld = 46,
PmModuleId_Friends = 47,
PmModuleId_Bgtc = 48,
PmModuleId_Account = 49,
PmModuleId_Sasbus = 50,
PmModuleId_Ntc = 51,
PmModuleId_Idle = 52,
PmModuleId_Tcap = 53,
PmModuleId_PsmLow = 54,
PmModuleId_Ndd = 55,
PmModuleId_Olsc = 56,
PmModuleId_Ns = 61,
PmModuleId_Nvservices = 101,
PmModuleId_Spsm = 127,
};
}
| 2,802
|
C++
|
.h
| 74
| 30.689189
| 76
| 0.518955
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,479
|
psc_pm_module.os.generic.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/psc/psc_pm_module.os.generic.hpp
|
/*
* 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>
#include <stratosphere/psc/psc_types.hpp>
#include <stratosphere/psc/psc_pm_module_id.hpp>
#include <stratosphere/psc/sf/psc_sf_i_pm_module.hpp>
namespace ams::psc {
class PmModule {
NON_COPYABLE(PmModule);
NON_MOVEABLE(PmModule);
private:
os::SystemEvent m_system_event;
bool m_initialized;
PmModuleId m_module_id;
uintptr_t m_reserved;
PmState m_state;
PmFlagSet m_flags;
public:
PmModule() : m_initialized(false), m_module_id(PmModuleId_Reserved0), m_reserved(0), m_state(PmState_FullAwake), m_flags() { /* ... */ }
~PmModule() {
if (m_initialized) {
R_ABORT_UNLESS(this->Finalize());
}
}
Result Initialize(const PmModuleId mid, const PmModuleId *dependencies, u32 dependency_count, os::EventClearMode clear_mode) {
/* TODO: Should we do in-process dependency resolution? */
AMS_UNUSED(dependencies, dependency_count);
/* Check that we're not already initialized. */
R_UNLESS(!m_initialized, psc::ResultAlreadyInitialized());
/* Create our event. */
R_ABORT_UNLESS(os::CreateSystemEvent(m_system_event.GetBase(), clear_mode, false));
/* Set our state. */
m_module_id = mid;
m_initialized = true;
R_SUCCEED();
}
Result Finalize() {
/* Check that we're initialized. */
R_UNLESS(m_initialized, psc::ResultNotInitialized());
/* Destroy our system event. */
os::DestroySystemEvent(m_system_event.GetBase());
/* Mark not initialized. */
m_initialized = false;
R_SUCCEED();
}
constexpr PmModuleId GetId() const { return m_module_id; }
Result GetRequest(PmState *out_state, PmFlagSet *out_flags) {
/* Check that we're initialized. */
R_UNLESS(m_initialized, psc::ResultNotInitialized());
/* Set output. */
*out_state = m_state;
*out_flags = m_flags;
R_SUCCEED();
}
Result Acknowledge(PmState state, Result res) {
/* Check that we're initialized. */
R_UNLESS(m_initialized, psc::ResultNotInitialized());
/* Check the transition was successful. */
R_ABORT_UNLESS(res);
AMS_UNUSED(state);
R_SUCCEED();
}
os::SystemEvent *GetEventPointer() {
return std::addressof(m_system_event);
}
};
}
| 3,482
|
C++
|
.h
| 81
| 31.54321
| 148
| 0.571724
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,480
|
psc_pm_module.os.horizon.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/psc/psc_pm_module.os.horizon.hpp
|
/*
* 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>
#include <stratosphere/psc/psc_types.hpp>
#include <stratosphere/psc/psc_pm_module_id.hpp>
#include <stratosphere/psc/sf/psc_sf_i_pm_module.hpp>
namespace ams::psc {
class PmModule {
NON_COPYABLE(PmModule);
NON_MOVEABLE(PmModule);
private:
ams::sf::SharedPointer<psc::sf::IPmModule> m_intf;
os::SystemEvent m_system_event;
bool m_initialized;
PmModuleId m_module_id;
uintptr_t m_reserved;
public:
PmModule();
~PmModule();
Result Initialize(const PmModuleId mid, const PmModuleId *dependencies, u32 dependency_count, os::EventClearMode clear_mode);
Result Finalize();
constexpr PmModuleId GetId() const { return m_module_id; }
Result GetRequest(PmState *out_state, PmFlagSet *out_flags);
Result Acknowledge(PmState state, Result res);
os::SystemEvent *GetEventPointer();
};
}
| 1,649
|
C++
|
.h
| 41
| 33.926829
| 137
| 0.682698
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,481
|
psc_types.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/psc/psc_types.hpp
|
/*
* 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::psc {
enum PmState {
PmState_FullAwake = 0,
PmState_MinimumAwake = 1,
PmState_SleepReady = 2,
PmState_EssentialServicesSleepReady = 3,
PmState_EssentialServicesAwake = 4,
PmState_ShutdownReady = 5,
PmState_Unknown = 6,
};
constexpr inline u32 MaximumDependencyLevels = 20;
struct PmFlag {
};
using PmFlagSet = util::BitFlagSet<BITSIZEOF(u32), PmFlag>;
}
| 1,218
|
C++
|
.h
| 32
| 33.875
| 76
| 0.66129
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,482
|
psc_sf_i_pm_module.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/psc/sf/psc_sf_i_pm_module.hpp
|
/*
* 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>
#include <stratosphere/psc/psc_types.hpp>
#include <stratosphere/psc/psc_pm_module_id.hpp>
#define AMS_PSC_I_PM_MODULE_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, Initialize, (ams::sf::OutCopyHandle out, psc::PmModuleId module_id, const ams::sf::InBuffer &child_list), (out, module_id, child_list)) \
AMS_SF_METHOD_INFO(C, H, 1, Result, GetRequest, (ams::sf::Out<psc::PmState> out_state, ams::sf::Out<psc::PmFlagSet> out_flags), (out_state, out_flags)) \
AMS_SF_METHOD_INFO(C, H, 2, Result, Acknowledge, (), ()) \
AMS_SF_METHOD_INFO(C, H, 3, Result, Finalize, (), ()) \
AMS_SF_METHOD_INFO(C, H, 4, Result, AcknowledgeEx, (psc::PmState state), (state), hos::Version_5_1_0)
AMS_SF_DEFINE_INTERFACE(ams::psc::sf, IPmModule, AMS_PSC_I_PM_MODULE_INTERFACE_INFO, 0x4275F38F)
| 2,066
|
C++
|
.h
| 26
| 77.038462
| 200
| 0.511537
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,483
|
psc_sf_i_pm_service.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/psc/sf/psc_sf_i_pm_service.hpp
|
/*
* 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>
#include <stratosphere/psc/sf/psc_sf_i_pm_module.hpp>
#define AMS_PSC_I_PM_SERVICE_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, Initialize, (ams::sf::Out<ams::sf::SharedPointer<psc::sf::IPmModule>> out), (out))
AMS_SF_DEFINE_INTERFACE(ams::psc::sf, IPmService, AMS_PSC_I_PM_SERVICE_INTERFACE_INFO, 0xEABE6F26)
| 1,067
|
C++
|
.h
| 21
| 48.809524
| 122
| 0.700863
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,484
|
htc_htcmisc_channel_ids.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/htc/server/htc_htcmisc_channel_ids.hpp
|
/*
* 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>
#include <stratosphere/htclow/htclow_channel_types.hpp>
namespace ams::htc::server {
constexpr inline htclow::ChannelId HtcmiscClientChannelId = 1;
constexpr inline htclow::ChannelId HtcmiscServerChannelId = 2;
}
| 895
|
C++
|
.h
| 22
| 38.545455
| 76
| 0.768966
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,485
|
htc_htcmisc_hipc_server.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/htc/server/htc_htcmisc_hipc_server.hpp
|
/*
* 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::htclow {
class HtclowManager;
}
namespace ams::htc::server {
void InitializeHtcmiscServer(htclow::HtclowManager *htclow_manager);
void FinalizeHtcmiscServer();
void LoopHtcmiscServer();
void RequestStopHtcmiscServer();
class HtcmiscImpl;
HtcmiscImpl *GetHtcmiscImpl();
}
| 992
|
C++
|
.h
| 28
| 32.678571
| 76
| 0.759666
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,486
|
htc_tenv_service_manager.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/htc/tenv/htc_tenv_service_manager.hpp
|
/*
* 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>
#include <stratosphere/sm/sm_types.hpp>
#include <stratosphere/htc/tenv/htc_tenv_i_service_manager.hpp>
namespace ams::htc::tenv {
constexpr inline sm::ServiceName ServiceName = sm::ServiceName::Encode("htc:tenv");
class ServiceManager {
public:
Result GetServiceInterface(sf::Out<sf::SharedPointer<htc::tenv::IService>> out, const sf::ClientProcessId &process_id);
};
static_assert(htc::tenv::IsIServiceManager<ServiceManager>);
}
| 1,143
|
C++
|
.h
| 27
| 39.333333
| 131
| 0.747302
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,487
|
htc_tenv.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/htc/tenv/htc_tenv.hpp
|
/*
* 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::htc::tenv {
void Initialize(AllocateFunction allocate, DeallocateFunction deallocate);
Result RegisterDefinitionFilePath(os::ProcessId process_id, const char *path, size_t size);
void UnregisterDefinitionFilePath(os::ProcessId process_id);
}
| 943
|
C++
|
.h
| 22
| 40.545455
| 95
| 0.770153
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,488
|
htc_tenv_i_service.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/htc/tenv/htc_tenv_i_service.hpp
|
/*
* 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>
#include <stratosphere/sf.hpp>
#include <stratosphere/htc/tenv/htc_tenv_types.hpp>
#define AMS_HTC_TENV_I_SERVICE_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, GetVariable, (sf::Out<s64> out_size, const sf::OutBuffer &out_buffer, const htc::tenv::VariableName &name), (out_size, out_buffer, name)) \
AMS_SF_METHOD_INFO(C, H, 1, Result, GetVariableLength, (sf::Out<s64> out_size,const htc::tenv::VariableName &name), (out_size, name)) \
AMS_SF_METHOD_INFO(C, H, 2, Result, WaitUntilVariableAvailable, (s64 timeout_ms), (timeout_ms))
AMS_SF_DEFINE_INTERFACE(ams::htc::tenv, IService, AMS_HTC_TENV_I_SERVICE_INTERFACE_INFO, 0x041F65C5)
| 1,619
|
C++
|
.h
| 24
| 65.291667
| 194
| 0.607659
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,489
|
htc_tenv_i_service_manager.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/htc/tenv/htc_tenv_i_service_manager.hpp
|
/*
* 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>
#include <stratosphere/sf.hpp>
#include <stratosphere/os/os_common_types.hpp>
#include <stratosphere/htc/tenv/htc_tenv_i_service.hpp>
#define AMS_HTC_TENV_I_SERVICE_MANAGER_INTERFACE_INFO(C, H) \
AMS_SF_METHOD_INFO(C, H, 0, Result, GetServiceInterface, (sf::Out<sf::SharedPointer<htc::tenv::IService>> out, const sf::ClientProcessId &process_id), (out, process_id))
AMS_SF_DEFINE_INTERFACE(ams::htc::tenv, IServiceManager, AMS_HTC_TENV_I_SERVICE_MANAGER_INTERFACE_INFO, 0x38649D88)
| 1,159
|
C++
|
.h
| 23
| 48.521739
| 173
| 0.761905
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,490
|
htc_tenv_types.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/htc/tenv/htc_tenv_types.hpp
|
/*
* 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::htc::tenv {
struct VariableName {
char str[0x40];
};
constexpr inline auto PathLengthMax = 0x300;
struct alignas(4) Path {
char str[PathLengthMax];
};
}
| 880
|
C++
|
.h
| 26
| 30.730769
| 76
| 0.729093
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,491
|
fssystem_bitmap_utils.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_bitmap_utils.hpp
|
/*
* 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 {
/* ACCURATE_TO_VERSION: 13.4.0.0 */
constexpr inline s32 CountLeadingZeros(u32 val) {
return util::CountLeadingZeros(val);
}
constexpr inline s32 CountLeadingOnes(u32 val) {
return CountLeadingZeros(~val);
}
inline u32 ReadU32(const u8 *buf, size_t index) {
u32 val;
std::memcpy(std::addressof(val), buf + index, sizeof(u32));
return val;
}
inline void WriteU32(u8 *buf, size_t index, u32 val) {
std::memcpy(buf + index, std::addressof(val), sizeof(u32));
}
constexpr inline bool IsPowerOfTwo(s32 val) {
return util::IsPowerOfTwo(val);
}
constexpr inline u32 ILog2(u32 val) {
AMS_ASSERT(val > 0);
return (BITSIZEOF(u32) - 1 - util::CountLeadingZeros<u32>(val));
}
constexpr inline u32 CeilingPowerOfTwo(u32 val) {
if (val == 0) {
return 1;
}
return util::CeilingPowerOfTwo<u32>(val);
}
}
| 1,651
|
C++
|
.h
| 47
| 30.297872
| 76
| 0.680477
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,492
|
fssystem_compression_configuration.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_compression_configuration.hpp
|
/*
* 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>
#include <stratosphere/fssystem/fssystem_nca_file_system_driver.hpp>
namespace ams::fssystem {
const ::ams::fssystem::NcaCompressionConfiguration *GetNcaCompressionConfiguration();
}
| 861
|
C++
|
.h
| 21
| 39
| 89
| 0.771804
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,493
|
fssystem_aes_xts_storage_external.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_aes_xts_storage_external.hpp
|
/*
* 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>
#include <stratosphere/fs/fs_istorage.hpp>
#include <stratosphere/fs/impl/fs_newable.hpp>
#include <stratosphere/fssystem/fssystem_nca_file_system_driver.hpp>
namespace ams::fssystem {
/* ACCURATE_TO_VERSION: 14.3.0.0 */
template<fs::PointerToStorage BasePointer>
class AesXtsStorageExternal : public ::ams::fs::IStorage, public ::ams::fs::impl::Newable {
NON_COPYABLE(AesXtsStorageExternal);
NON_MOVEABLE(AesXtsStorageExternal);
public:
static constexpr size_t AesBlockSize = crypto::Aes128XtsEncryptor::BlockSize;
static constexpr size_t KeySize = crypto::Aes128XtsEncryptor::KeySize;
static constexpr size_t IvSize = crypto::Aes128XtsEncryptor::IvSize;
private:
BasePointer m_base_storage;
char m_key[2][KeySize];
char m_iv[IvSize];
const size_t m_block_size;
CryptAesXtsFunction m_encrypt_function;
CryptAesXtsFunction m_decrypt_function;
public:
AesXtsStorageExternal(BasePointer bs, const void *key1, const void *key2, size_t key_size, const void *iv, size_t iv_size, size_t block_size, CryptAesXtsFunction ef, CryptAesXtsFunction df);
virtual Result Read(s64 offset, void *buffer, size_t size) override;
virtual Result OperateRange(void *dst, size_t dst_size, fs::OperationId op_id, s64 offset, s64 size, const void *src, size_t src_size) override;
virtual Result GetSize(s64 *out) override;
virtual Result Flush() override;
virtual Result Write(s64 offset, const void *buffer, size_t size) override;
virtual Result SetSize(s64 size) override;
};
using AesXtsStorageExternalByPointer = AesXtsStorageExternal<fs::IStorage *>;
using AesXtsStorageExternalBySharedPointer = AesXtsStorageExternal<std::shared_ptr<fs::IStorage>>;
}
| 2,582
|
C++
|
.h
| 49
| 46.081633
| 202
| 0.70807
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,494
|
fssystem_bucket_tree_utils.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_bucket_tree_utils.hpp
|
/*
* 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 <stratosphere/fssystem/fssystem_bucket_tree.hpp>
namespace ams::fssystem::impl {
/* ACCURATE_TO_VERSION: Unknown */
class SafeValue {
public:
static ALWAYS_INLINE s64 GetInt64(const void *ptr) {
s64 value;
std::memcpy(std::addressof(value), ptr, sizeof(s64));
return value;
}
static ALWAYS_INLINE s64 GetInt64(const s64 *ptr) {
return GetInt64(static_cast<const void *>(ptr));
}
static ALWAYS_INLINE s64 GetInt64(const s64 &v) {
return GetInt64(std::addressof(v));
}
static ALWAYS_INLINE void SetInt64(void *dst, const void *src) {
std::memcpy(dst, src, sizeof(s64));
}
static ALWAYS_INLINE void SetInt64(void *dst, const s64 *src) {
return SetInt64(dst, static_cast<const void *>(src));
}
static ALWAYS_INLINE void SetInt64(void *dst, const s64 &v) {
return SetInt64(dst, std::addressof(v));
}
};
/* ACCURATE_TO_VERSION: Unknown */
template<typename IteratorType>
struct BucketTreeNode {
using Header = BucketTree::NodeHeader;
Header header;
s32 GetCount() const { return this->header.count; }
void *GetArray() { return std::addressof(this->header) + 1; }
template<typename T> T *GetArray() { return reinterpret_cast<T *>(this->GetArray()); }
const void *GetArray() const { return std::addressof(this->header) + 1; }
template<typename T> const T *GetArray() const { return reinterpret_cast<const T *>(this->GetArray()); }
s64 GetBeginOffset() const { return *this->GetArray<s64>(); }
s64 GetEndOffset() const { return this->header.offset; }
IteratorType GetBegin() { return IteratorType(this->GetArray<s64>()); }
IteratorType GetEnd() { return IteratorType(this->GetArray<s64>()) + this->header.count; }
IteratorType GetBegin() const { return IteratorType(this->GetArray<s64>()); }
IteratorType GetEnd() const { return IteratorType(this->GetArray<s64>()) + this->header.count; }
IteratorType GetBegin(size_t entry_size) { return IteratorType(this->GetArray(), entry_size); }
IteratorType GetEnd(size_t entry_size) { return IteratorType(this->GetArray(), entry_size) + this->header.count; }
IteratorType GetBegin(size_t entry_size) const { return IteratorType(this->GetArray(), entry_size); }
IteratorType GetEnd(size_t entry_size) const { return IteratorType(this->GetArray(), entry_size) + this->header.count; }
};
constexpr inline s64 GetBucketTreeEntryOffset(s64 entry_set_offset, size_t entry_size, s32 entry_index) {
return entry_set_offset + sizeof(BucketTree::NodeHeader) + entry_index * static_cast<s64>(entry_size);
}
constexpr inline s64 GetBucketTreeEntryOffset(s32 entry_set_index, size_t node_size, size_t entry_size, s32 entry_index) {
return GetBucketTreeEntryOffset(entry_set_index * static_cast<s64>(node_size), entry_size, entry_index);
}
}
| 3,810
|
C++
|
.h
| 70
| 46.185714
| 128
| 0.659414
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,495
|
fssystem_partition_file_system_meta.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_partition_file_system_meta.hpp
|
/*
* 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 <stratosphere/fs/fs_common.hpp>
#include <stratosphere/fs/impl/fs_newable.hpp>
namespace ams::fssystem {
/* ACCURATE_TO_VERSION: Unknown */
namespace impl {
struct PartitionFileSystemFormat {
#pragma pack(push, 1)
struct PartitionEntry {
u64 offset;
u64 size;
u32 name_offset;
u32 reserved;
};
static_assert(util::is_pod<PartitionEntry>::value);
#pragma pack(pop)
static constexpr const char VersionSignature[] = { 'P', 'F', 'S', '0' };
static constexpr size_t EntryNameLengthMax = ::ams::fs::EntryNameLengthMax;
static constexpr size_t FileDataAlignmentSize = 0x20;
using ResultSignatureVerificationFailed = fs::ResultPartitionSignatureVerificationFailed;
};
struct Sha256PartitionFileSystemFormat {
static constexpr size_t HashSize = ::ams::crypto::Sha256Generator::HashSize;
#pragma pack(push, 1)
struct PartitionEntry {
u64 offset;
u64 size;
u32 name_offset;
u32 hash_target_size;
u64 hash_target_offset;
char hash[HashSize];
};
static_assert(util::is_pod<PartitionEntry>::value);
#pragma pack(pop)
static constexpr const char VersionSignature[] = { 'H', 'F', 'S', '0' };
static constexpr size_t EntryNameLengthMax = ::ams::fs::EntryNameLengthMax;
static constexpr size_t FileDataAlignmentSize = 0x200;
using ResultSignatureVerificationFailed = fs::ResultSha256PartitionSignatureVerificationFailed;
};
}
template<typename Format>
class PartitionFileSystemMetaCore : public fs::impl::Newable {
public:
static constexpr size_t EntryNameLengthMax = Format::EntryNameLengthMax;
static constexpr size_t FileDataAlignmentSize = Format::FileDataAlignmentSize;
/* Forward declare header. */
struct PartitionFileSystemHeader;
using PartitionEntry = typename Format::PartitionEntry;
protected:
bool m_initialized;
PartitionFileSystemHeader *m_header;
PartitionEntry *m_entries;
char *m_name_table;
size_t m_meta_data_size;
MemoryResource *m_allocator;
char *m_buffer;
public:
PartitionFileSystemMetaCore() : m_initialized(false), m_allocator(nullptr), m_buffer(nullptr) { /* ... */ }
~PartitionFileSystemMetaCore();
Result Initialize(fs::IStorage *storage, MemoryResource *allocator);
Result Initialize(fs::IStorage *storage, void *header, size_t header_size);
const PartitionEntry *GetEntry(s32 index) const;
s32 GetEntryCount() const;
s32 GetEntryIndex(const char *name) const;
const char *GetEntryName(s32 index) const;
size_t GetHeaderSize() const;
size_t GetMetaDataSize() const;
public:
static Result QueryMetaDataSize(size_t *out_size, fs::IStorage *storage);
protected:
void DeallocateBuffer();
};
using PartitionFileSystemMeta = PartitionFileSystemMetaCore<impl::PartitionFileSystemFormat>;
class Sha256PartitionFileSystemMeta : public PartitionFileSystemMetaCore<impl::Sha256PartitionFileSystemFormat> {
public:
using PartitionFileSystemMetaCore<impl::Sha256PartitionFileSystemFormat>::Initialize;
Result Initialize(fs::IStorage *base_storage, MemoryResource *allocator, const void *hash, size_t hash_size, util::optional<u8> suffix = util::nullopt);
};
}
| 4,457
|
C++
|
.h
| 94
| 37.361702
| 164
| 0.652234
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,496
|
fssystem_local_file_system.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_local_file_system.hpp
|
/*
* 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>
#include <stratosphere/fs/fsa/fs_ifilesystem.hpp>
#include <stratosphere/fs/fs_memory_management.hpp>
#include <stratosphere/fs/fs_path.hpp>
namespace ams::fssystem {
/* TODO: Put this in its own header? */
enum PathCaseSensitiveMode {
PathCaseSensitiveMode_CaseInsensitive = 0,
PathCaseSensitiveMode_CaseSensitive = 1,
};
/* ACCURATE_TO_VERSION: 13.4.0.0 */
class LocalFileSystem : public fs::fsa::IFileSystem, public fs::impl::Newable {
NON_COPYABLE(LocalFileSystem);
NON_MOVEABLE(LocalFileSystem);
private:
#if defined(ATMOSPHERE_OS_WINDOWS)
using NativeCharacterType = wchar_t;
#else
using NativeCharacterType = char;
#endif
using NativePathBuffer = std::unique_ptr<NativeCharacterType[], ::ams::fs::impl::Deleter>;
private:
fs::Path m_root_path;
fssystem::PathCaseSensitiveMode m_case_sensitive_mode;
NativePathBuffer m_native_path_buffer;
int m_native_path_length;
bool m_use_posix_time;
public:
LocalFileSystem(bool posix_time = true) : m_root_path(), m_native_path_buffer(), m_native_path_length(0), m_use_posix_time(posix_time) {
/* ... */
}
Result Initialize(const fs::Path &root_path, fssystem::PathCaseSensitiveMode case_sensitive_mode);
Result GetCaseSensitivePath(int *out_size, char *dst, size_t dst_size, const char *path, const char *work_path);
private:
Result CheckPathCaseSensitively(const NativeCharacterType *path, const NativeCharacterType *root_path, NativeCharacterType *cs_buf, size_t cs_size, bool check_case_sensitivity);
Result ResolveFullPath(NativePathBuffer *out, const fs::Path &path, int max_len, int min_len, bool check_case_sensitivity);
public:
virtual Result DoCreateFile(const fs::Path &path, s64 size, int flags) override;
virtual Result DoDeleteFile(const fs::Path &path) override;
virtual Result DoCreateDirectory(const fs::Path &path) override;
virtual Result DoDeleteDirectory(const fs::Path &path) override;
virtual Result DoDeleteDirectoryRecursively(const fs::Path &path) override;
virtual Result DoRenameFile(const fs::Path &old_path, const fs::Path &new_path) override;
virtual Result DoRenameDirectory(const fs::Path &old_path, const fs::Path &new_path) override;
virtual Result DoGetEntryType(fs::DirectoryEntryType *out, const fs::Path &path) override;
virtual Result DoOpenFile(std::unique_ptr<fs::fsa::IFile> *out_file, const fs::Path &path, fs::OpenMode mode) override;
virtual Result DoOpenDirectory(std::unique_ptr<fs::fsa::IDirectory> *out_dir, const fs::Path &path, fs::OpenDirectoryMode mode) override;
virtual Result DoCommit() override;
virtual Result DoGetFreeSpaceSize(s64 *out, const fs::Path &path) override;
virtual Result DoGetTotalSpaceSize(s64 *out, const fs::Path &path) override;
virtual Result DoCleanDirectoryRecursively(const fs::Path &path) override;
virtual Result DoGetFileTimeStampRaw(fs::FileTimeStampRaw *out, const fs::Path &path) override;
virtual Result DoQueryEntry(char *dst, size_t dst_size, const char *src, size_t src_size, fs::fsa::QueryId query, const fs::Path &path) override;
/* These aren't accessible as commands. */
virtual Result DoCommitProvisionally(s64 counter) override;
virtual Result DoRollback() override;
public:
Result DoGetDiskFreeSpace(s64 *out_free, s64 *out_total, s64 *out_total_free, const fs::Path &path);
Result DeleteDirectoryRecursivelyInternal(const NativeCharacterType *path, bool delete_top);
};
}
| 4,574
|
C++
|
.h
| 77
| 50.636364
| 189
| 0.688349
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,497
|
fssystem_pooled_buffer.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_pooled_buffer.hpp
|
/*
* 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>
#include <stratosphere/fs/impl/fs_newable.hpp>
namespace ams::fssystem {
/* ACCURATE_TO_VERSION: Unknown */
constexpr inline size_t BufferPoolAlignment = 4_KB;
constexpr inline size_t BufferPoolWorkSize = 320;
class PooledBuffer {
NON_COPYABLE(PooledBuffer);
private:
char *m_buffer;
size_t m_size;
private:
static size_t GetAllocatableSizeMaxCore(bool large);
public:
static size_t GetAllocatableSizeMax() { return GetAllocatableSizeMaxCore(false); }
static size_t GetAllocatableParticularlyLargeSizeMax() { return GetAllocatableSizeMaxCore(true); }
private:
void Swap(PooledBuffer &rhs) {
std::swap(m_buffer, rhs.m_buffer);
std::swap(m_size, rhs.m_size);
}
public:
/* Constructor/Destructor. */
constexpr PooledBuffer() : m_buffer(), m_size() { /* ... */ }
PooledBuffer(size_t ideal_size, size_t required_size) : m_buffer(), m_size() {
this->Allocate(ideal_size, required_size);
}
~PooledBuffer() {
this->Deallocate();
}
/* Move and assignment. */
explicit PooledBuffer(PooledBuffer &&rhs) : m_buffer(rhs.m_buffer), m_size(rhs.m_size) {
rhs.m_buffer = nullptr;
rhs.m_size = 0;
}
PooledBuffer &operator=(PooledBuffer &&rhs) {
PooledBuffer(std::move(rhs)).Swap(*this);
return *this;
}
/* Allocation API. */
void Allocate(size_t ideal_size, size_t required_size) {
return this->AllocateCore(ideal_size, required_size, false);
}
void AllocateParticularlyLarge(size_t ideal_size, size_t required_size) {
return this->AllocateCore(ideal_size, required_size, true);
}
void Shrink(size_t ideal_size);
void Deallocate() {
/* Shrink the buffer to empty. */
this->Shrink(0);
AMS_ASSERT(m_buffer == nullptr);
}
char *GetBuffer() const {
AMS_ASSERT(m_buffer != nullptr);
return m_buffer;
}
size_t GetSize() const {
AMS_ASSERT(m_buffer != nullptr);
return m_size;
}
private:
void AllocateCore(size_t ideal_size, size_t required_size, bool large);
};
Result InitializeBufferPool(char *buffer, size_t size);
Result InitializeBufferPool(char *buffer, size_t size, char *work, size_t work_size);
bool IsPooledBuffer(const void *buffer);
size_t GetPooledBufferRetriedCount();
size_t GetPooledBufferReduceAllocationCount();
size_t GetPooledBufferFreeSizePeak();
void ClearPooledBufferPeak();
void RegisterAdditionalDeviceAddress(uintptr_t address, size_t size);
void UnregisterAdditionalDeviceAddress(uintptr_t address);
bool IsAdditionalDeviceAddress(const void *ptr);
inline bool IsDeviceAddress(const void *buffer) {
return IsPooledBuffer(buffer) || IsAdditionalDeviceAddress(buffer);
}
}
| 3,945
|
C++
|
.h
| 93
| 32.698925
| 110
| 0.617332
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,498
|
fssystem_aes_xts_storage.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_aes_xts_storage.hpp
|
/*
* 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>
#include <stratosphere/fs/fs_istorage.hpp>
#include <stratosphere/fs/impl/fs_newable.hpp>
#include <stratosphere/os.hpp>
namespace ams::fssystem {
/* ACCURATE_TO_VERSION: Unknown */
template<fs::PointerToStorage BasePointer>
class AesXtsStorage : public ::ams::fs::IStorage, public ::ams::fs::impl::Newable {
NON_COPYABLE(AesXtsStorage);
NON_MOVEABLE(AesXtsStorage);
public:
static constexpr size_t AesBlockSize = crypto::Aes128XtsEncryptor::BlockSize;
static constexpr size_t KeySize = crypto::Aes128XtsEncryptor::KeySize;
static constexpr size_t IvSize = crypto::Aes128XtsEncryptor::IvSize;
private:
BasePointer m_base_storage;
char m_key[2][KeySize];
char m_iv[IvSize];
const size_t m_block_size;
os::SdkMutex m_mutex;
public:
static void MakeAesXtsIv(void *dst, size_t dst_size, s64 offset, size_t block_size);
public:
AesXtsStorage(BasePointer base, const void *key1, const void *key2, size_t key_size, const void *iv, size_t iv_size, size_t block_size);
virtual Result Read(s64 offset, void *buffer, size_t size) override;
virtual Result Write(s64 offset, const void *buffer, size_t size) override;
virtual Result Flush() override;
virtual Result SetSize(s64 size) override;
virtual Result GetSize(s64 *out) override;
virtual Result OperateRange(void *dst, size_t dst_size, fs::OperationId op_id, s64 offset, s64 size, const void *src, size_t src_size) override;
};
using AesXtsStorageByPointer = AesXtsStorage<fs::IStorage *>;
using AesXtsStorageBySharedPointer = AesXtsStorage<std::shared_ptr<fs::IStorage>>;
}
| 2,479
|
C++
|
.h
| 50
| 42.86
| 156
| 0.690211
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,499
|
fssystem_nca_file_system_driver.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_nca_file_system_driver.hpp
|
/*
* 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>
#include <stratosphere/fs/impl/fs_newable.hpp>
#include <stratosphere/fs/fs_istorage.hpp>
#include <stratosphere/fssystem/fssystem_compression_common.hpp>
#include <stratosphere/fssystem/fssystem_i_hash_256_generator.hpp>
#include <stratosphere/fssystem/fssystem_asynchronous_access.hpp>
#include <stratosphere/fssystem/fssystem_nca_header.hpp>
#include <stratosphere/fs/fs_i_buffer_manager.hpp>
namespace ams::fssystem {
/* ACCURATE_TO_VERSION: 14.3.0.0 */
class CompressedStorage;
class AesCtrCounterExtendedStorage;
class IndirectStorage;
class SparseStorage;
struct NcaCryptoConfiguration;
using KeyGenerationFunction = void (*)(void *dst_key, size_t dst_key_size, const void *src_key, size_t src_key_size, s32 key_type);
using DecryptAesCtrFunction = void (*)(void *dst, size_t dst_size, u8 key_index, u8 key_generation, const void *src_key, size_t src_key_size, const void *iv, size_t iv_size, const void *src, size_t src_size);
using CryptAesXtsFunction = Result (*)(void *dst, size_t dst_size, const void *key1, const void *key2, size_t key_size, const void *iv, size_t iv_size, const void *src, size_t src_size);
using VerifySign1Function = bool (*)(const void *sig, size_t sig_size, const void *data, size_t data_size, u8 generation);
struct NcaCryptoConfiguration {
static constexpr size_t Rsa2048KeyModulusSize = crypto::Rsa2048PssSha256Verifier::ModulusSize;
static constexpr size_t Rsa2048KeyPublicExponentSize = crypto::Rsa2048PssSha256Verifier::MaximumExponentSize;
static constexpr size_t Rsa2048KeyPrivateExponentSize = Rsa2048KeyModulusSize;
static constexpr size_t Aes128KeySize = crypto::AesEncryptor128::KeySize;
static constexpr size_t Header1SignatureKeyGenerationMax = 1;
static constexpr s32 KeyAreaEncryptionKeyIndexCount = 3;
static constexpr s32 HeaderEncryptionKeyCount = 2;
static constexpr u8 KeyAreaEncryptionKeyIndexZeroKey = 0xFF;
static constexpr size_t KeyGenerationMax = 32;
const u8 *header_1_sign_key_moduli[Header1SignatureKeyGenerationMax + 1];
u8 header_1_sign_key_public_exponent[Rsa2048KeyPublicExponentSize];
u8 key_area_encryption_key_source[KeyAreaEncryptionKeyIndexCount][Aes128KeySize];
u8 header_encryption_key_source[Aes128KeySize];
u8 header_encrypted_encryption_keys[HeaderEncryptionKeyCount][Aes128KeySize];
KeyGenerationFunction generate_key;
CryptAesXtsFunction decrypt_aes_xts_external;
CryptAesXtsFunction encrypt_aes_xts_external;
DecryptAesCtrFunction decrypt_aes_ctr;
DecryptAesCtrFunction decrypt_aes_ctr_external;
VerifySign1Function verify_sign1;
bool is_plaintext_header_available;
bool is_available_sw_key;
#if !defined(ATMOSPHERE_BOARD_NINTENDO_NX)
bool is_unsigned_header_available_for_host_tool;
#endif
};
static_assert(util::is_pod<NcaCryptoConfiguration>::value);
struct NcaCompressionConfiguration {
GetDecompressorFunction get_decompressor;
};
static_assert(util::is_pod<NcaCompressionConfiguration>::value);
constexpr inline s32 KeyAreaEncryptionKeyCount = NcaCryptoConfiguration::KeyAreaEncryptionKeyIndexCount * NcaCryptoConfiguration::KeyGenerationMax;
enum class KeyType : s32 {
ZeroKey = -2,
InvalidKey = -1,
NcaHeaderKey1 = KeyAreaEncryptionKeyCount + 0,
NcaHeaderKey2 = KeyAreaEncryptionKeyCount + 1,
NcaExternalKey = KeyAreaEncryptionKeyCount + 2,
SaveDataDeviceUniqueMac = KeyAreaEncryptionKeyCount + 3,
SaveDataSeedUniqueMac = KeyAreaEncryptionKeyCount + 4,
SaveDataTransferMac = KeyAreaEncryptionKeyCount + 5,
};
constexpr inline bool IsInvalidKeyTypeValue(s32 key_type) {
return key_type < 0;
}
constexpr inline s32 GetKeyTypeValue(u8 key_index, u8 key_generation) {
if (key_index == NcaCryptoConfiguration::KeyAreaEncryptionKeyIndexZeroKey) {
return util::ToUnderlying(KeyType::ZeroKey);
}
if (key_index >= NcaCryptoConfiguration::KeyAreaEncryptionKeyIndexCount) {
return util::ToUnderlying(KeyType::InvalidKey);
}
return NcaCryptoConfiguration::KeyAreaEncryptionKeyIndexCount * key_generation + key_index;
}
class NcaReader : public ::ams::fs::impl::Newable {
NON_COPYABLE(NcaReader);
NON_MOVEABLE(NcaReader);
private:
NcaHeader m_header;
u8 m_decryption_keys[NcaHeader::DecryptionKey_Count][NcaCryptoConfiguration::Aes128KeySize];
std::shared_ptr<fs::IStorage> m_body_storage;
std::unique_ptr<fs::IStorage> m_header_storage;
u8 m_external_decryption_key[NcaCryptoConfiguration::Aes128KeySize];
DecryptAesCtrFunction m_decrypt_aes_ctr;
DecryptAesCtrFunction m_decrypt_aes_ctr_external;
bool m_is_software_aes_prioritized;
bool m_is_available_sw_key;
NcaHeader::EncryptionType m_header_encryption_type;
bool m_is_header_sign1_signature_valid;
GetDecompressorFunction m_get_decompressor;
IHash256GeneratorFactorySelector *m_hash_generator_factory_selector;
public:
NcaReader();
~NcaReader();
Result Initialize(std::shared_ptr<fs::IStorage> base_storage, const NcaCryptoConfiguration &crypto_cfg, const NcaCompressionConfiguration &compression_cfg, IHash256GeneratorFactorySelector *hgf_selector);
std::shared_ptr<fs::IStorage> GetSharedBodyStorage();
u32 GetMagic() const;
NcaHeader::DistributionType GetDistributionType() const;
NcaHeader::ContentType GetContentType() const;
u8 GetHeaderSign1KeyGeneration() const;
u8 GetKeyGeneration() const;
u8 GetKeyIndex() const;
u64 GetContentSize() const;
u64 GetProgramId() const;
u32 GetContentIndex() const;
u32 GetSdkAddonVersion() const;
void GetRightsId(u8 *dst, size_t dst_size) const;
bool HasFsInfo(s32 index) const;
s32 GetFsCount() const;
const Hash &GetFsHeaderHash(s32 index) const;
void GetFsHeaderHash(Hash *dst, s32 index) const;
void GetFsInfo(NcaHeader::FsInfo *dst, s32 index) const;
u64 GetFsOffset(s32 index) const;
u64 GetFsEndOffset(s32 index) const;
u64 GetFsSize(s32 index) const;
void GetEncryptedKey(void *dst, size_t size) const;
const void *GetDecryptionKey(s32 index) const;
bool HasValidInternalKey() const;
bool HasInternalDecryptionKeyForAesHw() const;
bool IsSoftwareAesPrioritized() const;
void PrioritizeSoftwareAes();
bool IsAvailableSwKey() const;
bool HasExternalDecryptionKey() const;
const void *GetExternalDecryptionKey() const;
void SetExternalDecryptionKey(const void *src, size_t size);
void GetRawData(void *dst, size_t dst_size) const;
DecryptAesCtrFunction GetExternalDecryptAesCtrFunction() const;
DecryptAesCtrFunction GetExternalDecryptAesCtrFunctionForExternalKey() const;
NcaHeader::EncryptionType GetEncryptionType() const;
Result ReadHeader(NcaFsHeader *dst, s32 index) const;
GetDecompressorFunction GetDecompressor() const;
IHash256GeneratorFactorySelector *GetHashGeneratorFactorySelector() const;
bool GetHeaderSign1Valid() const;
void GetHeaderSign2(void *dst, size_t size) const;
void GetHeaderSign2TargetHash(void *dst, size_t size) const;
};
class NcaFsHeaderReader : public ::ams::fs::impl::Newable {
NON_COPYABLE(NcaFsHeaderReader);
NON_MOVEABLE(NcaFsHeaderReader);
private:
NcaFsHeader m_data;
s32 m_fs_index;
public:
NcaFsHeaderReader() : m_fs_index(-1) {
std::memset(std::addressof(m_data), 0, sizeof(m_data));
}
Result Initialize(const NcaReader &reader, s32 index);
bool IsInitialized() const { return m_fs_index >= 0; }
// NcaFsHeader &GetData() { return m_data; }
// const NcaFsHeader &GetData() const { return m_data; }
void GetRawData(void *dst, size_t dst_size) const;
NcaFsHeader::HashData &GetHashData();
const NcaFsHeader::HashData &GetHashData() const;
u16 GetVersion() const;
s32 GetFsIndex() const;
NcaFsHeader::FsType GetFsType() const;
NcaFsHeader::HashType GetHashType() const;
NcaFsHeader::EncryptionType GetEncryptionType() const;
NcaPatchInfo &GetPatchInfo();
const NcaPatchInfo &GetPatchInfo() const;
const NcaAesCtrUpperIv GetAesCtrUpperIv() const;
bool IsSkipLayerHashEncryption() const;
Result GetHashTargetOffset(s64 *out) const;
bool ExistsSparseLayer() const;
NcaSparseInfo &GetSparseInfo();
const NcaSparseInfo &GetSparseInfo() const;
bool ExistsCompressionLayer() const;
NcaCompressionInfo &GetCompressionInfo();
const NcaCompressionInfo &GetCompressionInfo() const;
bool ExistsPatchMetaHashLayer() const;
NcaMetaDataHashDataInfo &GetPatchMetaDataHashDataInfo();
const NcaMetaDataHashDataInfo &GetPatchMetaDataHashDataInfo() const;
NcaFsHeader::MetaDataHashType GetPatchMetaHashType() const;
bool ExistsSparseMetaHashLayer() const;
NcaMetaDataHashDataInfo &GetSparseMetaDataHashDataInfo();
const NcaMetaDataHashDataInfo &GetSparseMetaDataHashDataInfo() const;
NcaFsHeader::MetaDataHashType GetSparseMetaHashType() const;
};
class NcaFileSystemDriver : public ::ams::fs::impl::Newable {
NON_COPYABLE(NcaFileSystemDriver);
NON_MOVEABLE(NcaFileSystemDriver);
#if defined(ATMOSPHERE_BOARD_NINTENDO_NX)
private:
#else
public:
#endif
struct StorageContext {
bool open_raw_storage;
std::shared_ptr<fs::IStorage> body_substorage;
std::shared_ptr<fssystem::SparseStorage> current_sparse_storage;
std::shared_ptr<fs::IStorage> sparse_storage_meta_storage;
std::shared_ptr<fssystem::SparseStorage> original_sparse_storage;
void *external_current_sparse_storage; /* TODO: Add real type? */
void *external_original_sparse_storage; /* TODO: Add real type? */
std::shared_ptr<fs::IStorage> aes_ctr_ex_storage_meta_storage;
std::shared_ptr<fs::IStorage> aes_ctr_ex_storage_data_storage;
std::shared_ptr<fssystem::AesCtrCounterExtendedStorage> aes_ctr_ex_storage;
std::shared_ptr<fs::IStorage> indirect_storage_meta_storage;
std::shared_ptr<fssystem::IndirectStorage> indirect_storage;
std::shared_ptr<fs::IStorage> fs_data_storage;
std::shared_ptr<fs::IStorage> compressed_storage_meta_storage;
std::shared_ptr<fssystem::CompressedStorage> compressed_storage;
std::shared_ptr<fs::IStorage> patch_layer_info_storage;
std::shared_ptr<fs::IStorage> sparse_layer_info_storage;
/* For tools. */
std::shared_ptr<fs::IStorage> external_original_storage;
};
private:
enum AlignmentStorageRequirement {
/* TODO */
AlignmentStorageRequirement_CacheBlockSize = 0,
AlignmentStorageRequirement_None = 1,
};
private:
std::shared_ptr<NcaReader> m_original_reader;
std::shared_ptr<NcaReader> m_reader;
MemoryResource * const m_allocator;
fs::IBufferManager * const m_buffer_manager;
fssystem::IHash256GeneratorFactorySelector * const m_hash_generator_factory_selector;
public:
static Result SetupFsHeaderReader(NcaFsHeaderReader *out, const NcaReader &reader, s32 fs_index);
public:
NcaFileSystemDriver(std::shared_ptr<NcaReader> reader, MemoryResource *allocator, fs::IBufferManager *buffer_manager, IHash256GeneratorFactorySelector *hgf_selector) : m_original_reader(), m_reader(reader), m_allocator(allocator), m_buffer_manager(buffer_manager), m_hash_generator_factory_selector(hgf_selector) {
AMS_ASSERT(m_reader != nullptr);
AMS_ASSERT(m_hash_generator_factory_selector != nullptr);
}
NcaFileSystemDriver(std::shared_ptr<NcaReader> original_reader, std::shared_ptr<NcaReader> reader, MemoryResource *allocator, fs::IBufferManager *buffer_manager, IHash256GeneratorFactorySelector *hgf_selector) : m_original_reader(original_reader), m_reader(reader), m_allocator(allocator), m_buffer_manager(buffer_manager), m_hash_generator_factory_selector(hgf_selector) {
AMS_ASSERT(m_reader != nullptr);
AMS_ASSERT(m_hash_generator_factory_selector != nullptr);
}
Result OpenStorageWithContext(std::shared_ptr<fs::IStorage> *out, std::shared_ptr<IAsynchronousAccessSplitter> *out_splitter, NcaFsHeaderReader *out_header_reader, s32 fs_index, StorageContext *ctx);
Result OpenStorage(std::shared_ptr<fs::IStorage> *out, std::shared_ptr<IAsynchronousAccessSplitter> *out_splitter, NcaFsHeaderReader *out_header_reader, s32 fs_index) {
/* Create a storage context. */
StorageContext ctx{};
/* Open the storage. */
R_RETURN(OpenStorageWithContext(out, out_splitter, out_header_reader, fs_index, std::addressof(ctx)));
}
#if defined(ATMOSPHERE_BOARD_NINTENDO_NX)
private:
#else
public:
#endif
Result CreateStorageByRawStorage(std::shared_ptr<fs::IStorage> *out, const NcaFsHeaderReader *header_reader, std::shared_ptr<fs::IStorage> raw_storage, StorageContext *ctx);
private:
Result OpenStorageImpl(std::shared_ptr<fs::IStorage> *out, NcaFsHeaderReader *out_header_reader, s32 fs_index, StorageContext *ctx);
Result OpenIndirectableStorageAsOriginal(std::shared_ptr<fs::IStorage> *out, const NcaFsHeaderReader *header_reader, StorageContext *ctx);
Result CreateBodySubStorage(std::shared_ptr<fs::IStorage> *out, s64 offset, s64 size);
Result CreateAesCtrStorage(std::shared_ptr<fs::IStorage> *out, std::shared_ptr<fs::IStorage> base_storage, s64 offset, const NcaAesCtrUpperIv &upper_iv, AlignmentStorageRequirement alignment_storage_requirement);
Result CreateAesXtsStorage(std::shared_ptr<fs::IStorage> *out, std::shared_ptr<fs::IStorage> base_storage, s64 offset);
Result CreateSparseStorageMetaStorage(std::shared_ptr<fs::IStorage> *out, std::shared_ptr<fs::IStorage> base_storage, s64 offset, const NcaAesCtrUpperIv &upper_iv, const NcaSparseInfo &sparse_info);
Result CreateSparseStorageCore(std::shared_ptr<fssystem::SparseStorage> *out, std::shared_ptr<fs::IStorage> base_storage, s64 base_size, std::shared_ptr<fs::IStorage> meta_storage, const NcaSparseInfo &sparse_info, bool external_info);
Result CreateSparseStorage(std::shared_ptr<fs::IStorage> *out, s64 *out_fs_data_offset, std::shared_ptr<fssystem::SparseStorage> *out_sparse_storage, std::shared_ptr<fs::IStorage> *out_meta_storage, s32 index, const NcaAesCtrUpperIv &upper_iv, const NcaSparseInfo &sparse_info);
Result CreateSparseStorageMetaStorageWithVerification(std::shared_ptr<fs::IStorage> *out, std::shared_ptr<fs::IStorage> *out_verification, std::shared_ptr<fs::IStorage> base_storage, s64 offset, const NcaAesCtrUpperIv &upper_iv, const NcaSparseInfo &sparse_info, const NcaMetaDataHashDataInfo &meta_data_hash_data_info, IHash256GeneratorFactory *hgf);
Result CreateSparseStorageWithVerification(std::shared_ptr<fs::IStorage> *out, s64 *out_fs_data_offset, std::shared_ptr<fssystem::SparseStorage> *out_sparse_storage, std::shared_ptr<fs::IStorage> *out_meta_storage, std::shared_ptr<fs::IStorage> *out_verification, s32 index, const NcaAesCtrUpperIv &upper_iv, const NcaSparseInfo &sparse_info, const NcaMetaDataHashDataInfo &meta_data_hash_data_info, NcaFsHeader::MetaDataHashType meta_data_hash_type);
Result CreateAesCtrExStorageMetaStorage(std::shared_ptr<fs::IStorage> *out, std::shared_ptr<fs::IStorage> base_storage, s64 offset, NcaFsHeader::EncryptionType encryption_type, const NcaAesCtrUpperIv &upper_iv, const NcaPatchInfo &patch_info);
Result CreateAesCtrExStorage(std::shared_ptr<fs::IStorage> *out, std::shared_ptr<fssystem::AesCtrCounterExtendedStorage> *out_ext, std::shared_ptr<fs::IStorage> base_storage, std::shared_ptr<fs::IStorage> meta_storage, s64 counter_offset, const NcaAesCtrUpperIv &upper_iv, const NcaPatchInfo &patch_info);
Result CreateIndirectStorageMetaStorage(std::shared_ptr<fs::IStorage> *out, std::shared_ptr<fs::IStorage> base_storage, const NcaPatchInfo &patch_info);
Result CreateIndirectStorage(std::shared_ptr<fs::IStorage> *out, std::shared_ptr<fssystem::IndirectStorage> *out_ind, std::shared_ptr<fs::IStorage> base_storage, std::shared_ptr<fs::IStorage> original_data_storage, std::shared_ptr<fs::IStorage> meta_storage, const NcaPatchInfo &patch_info);
Result CreatePatchMetaStorage(std::shared_ptr<fs::IStorage> *out_aes_ctr_ex_meta, std::shared_ptr<fs::IStorage> *out_indirect_meta, std::shared_ptr<fs::IStorage> *out_verification, std::shared_ptr<fs::IStorage> base_storage, s64 offset, const NcaAesCtrUpperIv &upper_iv, const NcaPatchInfo &patch_info, const NcaMetaDataHashDataInfo &meta_data_hash_data_info, IHash256GeneratorFactory *hgf);
Result CreateSha256Storage(std::shared_ptr<fs::IStorage> *out, std::shared_ptr<fs::IStorage> base_storage, const NcaFsHeader::HashData::HierarchicalSha256Data &sha256_data, IHash256GeneratorFactory *hgf);
Result CreateIntegrityVerificationStorage(std::shared_ptr<fs::IStorage> *out, std::shared_ptr<fs::IStorage> base_storage, const NcaFsHeader::HashData::IntegrityMetaInfo &meta_info, IHash256GeneratorFactory *hgf);
Result CreateIntegrityVerificationStorageForMeta(std::shared_ptr<fs::IStorage> *out, std::shared_ptr<fs::IStorage> *out_verification, std::shared_ptr<fs::IStorage> base_storage, s64 offset, const NcaMetaDataHashDataInfo &meta_data_hash_data_info, IHash256GeneratorFactory *hgf);
Result CreateIntegrityVerificationStorageImpl(std::shared_ptr<fs::IStorage> *out, std::shared_ptr<fs::IStorage> base_storage, const NcaFsHeader::HashData::IntegrityMetaInfo &meta_info, s64 layer_info_offset, int max_data_cache_entries, int max_hash_cache_entries, s8 buffer_level, IHash256GeneratorFactory *hgf);
Result CreateRegionSwitchStorage(std::shared_ptr<fs::IStorage> *out, const NcaFsHeaderReader *header_reader, std::shared_ptr<fs::IStorage> inside_storage, std::shared_ptr<fs::IStorage> outside_storage);
Result CreateCompressedStorage(std::shared_ptr<fs::IStorage> *out, std::shared_ptr<fssystem::CompressedStorage> *out_cmp, std::shared_ptr<fs::IStorage> *out_meta, std::shared_ptr<fs::IStorage> base_storage, const NcaCompressionInfo &compression_info);
public:
Result CreateCompressedStorage(std::shared_ptr<fs::IStorage> *out, std::shared_ptr<fssystem::CompressedStorage> *out_cmp, std::shared_ptr<fs::IStorage> *out_meta, std::shared_ptr<fs::IStorage> base_storage, const NcaCompressionInfo &compression_info, GetDecompressorFunction get_decompressor, MemoryResource *allocator, fs::IBufferManager *buffer_manager);
};
}
| 20,852
|
C++
|
.h
| 285
| 62.312281
| 463
| 0.701302
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,500
|
fssystem_directory_redirection_filesystem.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_directory_redirection_filesystem.hpp
|
/*
* 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 <stratosphere/fs/fs_common.hpp>
#include <stratosphere/fs/fsa/fs_ifile.hpp>
#include <stratosphere/fs/fsa/fs_idirectory.hpp>
#include <stratosphere/fs/fsa/fs_ifilesystem.hpp>
#include <stratosphere/fs/impl/fs_newable.hpp>
namespace ams::fssystem {
class DirectoryRedirectionFileSystem : public fs::fsa::IFileSystem, public fs::impl::Newable {
NON_COPYABLE(DirectoryRedirectionFileSystem);
private:
std::unique_ptr<fs::fsa::IFileSystem> m_base_fs;
fs::Path m_before_dir;
fs::Path m_after_dir;
public:
DirectoryRedirectionFileSystem(std::unique_ptr<fs::fsa::IFileSystem> fs) : m_base_fs(std::move(fs)), m_before_dir(), m_after_dir() {
/* ... */
}
Result InitializeWithFixedPath(const char *before, const char *after) {
R_TRY(fs::SetUpFixedPath(std::addressof(m_before_dir), before));
R_TRY(fs::SetUpFixedPath(std::addressof(m_after_dir), after));
R_SUCCEED();
}
private:
Result ResolveFullPath(fs::Path *out, const fs::Path &path) {
if (path.IsMatchHead(m_before_dir.GetString(), m_before_dir.GetLength())) {
R_TRY(out->Initialize(m_after_dir));
R_TRY(out->AppendChild(path.GetString() + m_before_dir.GetLength()));
} else {
R_TRY(out->Initialize(path));
}
R_SUCCEED();
}
public:
virtual Result DoCreateFile(const fs::Path &path, s64 size, int option) override {
fs::Path full_path;
R_TRY(this->ResolveFullPath(std::addressof(full_path), path));
R_RETURN(m_base_fs->CreateFile(full_path, size, option));
}
virtual Result DoDeleteFile(const fs::Path &path) override {
fs::Path full_path;
R_TRY(this->ResolveFullPath(std::addressof(full_path), path));
R_RETURN(m_base_fs->DeleteFile(full_path));
}
virtual Result DoCreateDirectory(const fs::Path &path) override {
fs::Path full_path;
R_TRY(this->ResolveFullPath(std::addressof(full_path), path));
R_RETURN(m_base_fs->CreateDirectory(full_path));
}
virtual Result DoDeleteDirectory(const fs::Path &path) override {
fs::Path full_path;
R_TRY(this->ResolveFullPath(std::addressof(full_path), path));
R_RETURN(m_base_fs->DeleteDirectory(full_path));
}
virtual Result DoDeleteDirectoryRecursively(const fs::Path &path) override {
fs::Path full_path;
R_TRY(this->ResolveFullPath(std::addressof(full_path), path));
R_RETURN(m_base_fs->DeleteDirectoryRecursively(full_path));
}
virtual Result DoRenameFile(const fs::Path &old_path, const fs::Path &new_path) override {
fs::Path old_full_path;
fs::Path new_full_path;
R_TRY(this->ResolveFullPath(std::addressof(old_full_path), old_path));
R_TRY(this->ResolveFullPath(std::addressof(new_full_path), new_path));
R_RETURN(m_base_fs->RenameFile(old_full_path, new_full_path));
}
virtual Result DoRenameDirectory(const fs::Path &old_path, const fs::Path &new_path) override {
fs::Path old_full_path;
fs::Path new_full_path;
R_TRY(this->ResolveFullPath(std::addressof(old_full_path), old_path));
R_TRY(this->ResolveFullPath(std::addressof(new_full_path), new_path));
R_RETURN(m_base_fs->RenameDirectory(old_full_path, new_full_path));
}
virtual Result DoGetEntryType(fs::DirectoryEntryType *out, const fs::Path &path) override {
fs::Path full_path;
R_TRY(this->ResolveFullPath(std::addressof(full_path), path));
R_RETURN(m_base_fs->GetEntryType(out, full_path));
}
virtual Result DoOpenFile(std::unique_ptr<fs::fsa::IFile> *out_file, const fs::Path &path, fs::OpenMode mode) override {
fs::Path full_path;
R_TRY(this->ResolveFullPath(std::addressof(full_path), path));
R_RETURN(m_base_fs->OpenFile(out_file, full_path, mode));
}
virtual Result DoOpenDirectory(std::unique_ptr<fs::fsa::IDirectory> *out_dir, const fs::Path &path, fs::OpenDirectoryMode mode) override {
fs::Path full_path;
R_TRY(this->ResolveFullPath(std::addressof(full_path), path));
R_RETURN(m_base_fs->OpenDirectory(out_dir, full_path, mode));
}
virtual Result DoCommit() override {
R_RETURN(m_base_fs->Commit());
}
virtual Result DoGetFreeSpaceSize(s64 *out, const fs::Path &path) override {
fs::Path full_path;
R_TRY(this->ResolveFullPath(std::addressof(full_path), path));
R_RETURN(m_base_fs->GetFreeSpaceSize(out, full_path));
}
virtual Result DoGetTotalSpaceSize(s64 *out, const fs::Path &path) override {
fs::Path full_path;
R_TRY(this->ResolveFullPath(std::addressof(full_path), path));
R_RETURN(m_base_fs->GetTotalSpaceSize(out, full_path));
}
virtual Result DoCleanDirectoryRecursively(const fs::Path &path) override {
fs::Path full_path;
R_TRY(this->ResolveFullPath(std::addressof(full_path), path));
R_RETURN(m_base_fs->CleanDirectoryRecursively(full_path));
}
virtual Result DoGetFileTimeStampRaw(fs::FileTimeStampRaw *out, const fs::Path &path) override {
fs::Path full_path;
R_TRY(this->ResolveFullPath(std::addressof(full_path), path));
R_RETURN(m_base_fs->GetFileTimeStampRaw(out, full_path));
}
virtual Result DoQueryEntry(char *dst, size_t dst_size, const char *src, size_t src_size, fs::fsa::QueryId query, const fs::Path &path) override {
fs::Path full_path;
R_TRY(this->ResolveFullPath(std::addressof(full_path), path));
R_RETURN(m_base_fs->QueryEntry(dst, dst_size, src, src_size, query, full_path));
}
/* These aren't accessible as commands. */
virtual Result DoCommitProvisionally(s64 counter) override {
R_RETURN(m_base_fs->CommitProvisionally(counter));
}
virtual Result DoRollback() override {
R_RETURN(m_base_fs->Rollback());
}
virtual Result DoFlush() override {
R_RETURN(m_base_fs->Flush());
}
};
}
| 7,633
|
C++
|
.h
| 142
| 40.704225
| 158
| 0.591494
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,501
|
fssystem_romfs_file_system.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_romfs_file_system.hpp
|
/*
* 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>
#include <stratosphere/fs/fsa/fs_ifilesystem.hpp>
#include <stratosphere/fs/impl/fs_newable.hpp>
#include <stratosphere/fs/common/fs_dbm_hierarchical_rom_file_table.hpp>
#include <stratosphere/fs/fs_istorage.hpp>
namespace ams::fssystem {
/* ACCURATE_TO_VERSION: Unknown */
class RomFsFileSystem : public fs::fsa::IFileSystem, public fs::impl::Newable {
NON_COPYABLE(RomFsFileSystem);
public:
using RomFileTable = fs::HierarchicalRomFileTable;
private:
RomFileTable m_rom_file_table;
fs::IStorage *m_base_storage;
std::shared_ptr<fs::IStorage> m_shared_storage;
std::unique_ptr<fs::IStorage> m_dir_bucket_storage;
std::unique_ptr<fs::IStorage> m_dir_entry_storage;
std::unique_ptr<fs::IStorage> m_file_bucket_storage;
std::unique_ptr<fs::IStorage> m_file_entry_storage;
s64 m_entry_size;
private:
Result GetFileInfo(RomFileTable::FileInfo *out, const char *path);
Result GetFileInfo(RomFileTable::FileInfo *out, const fs::Path &path) {
R_RETURN(this->GetFileInfo(out, path.GetString()));
}
Result CheckPathFormat(const fs::Path &path) const {
R_RETURN(fs::PathFormatter::CheckPathFormat(path.GetString(), fs::PathFlags{}));
}
public:
static Result GetRequiredWorkingMemorySize(size_t *out, fs::IStorage *storage);
public:
RomFsFileSystem();
virtual ~RomFsFileSystem() override;
Result Initialize(fs::IStorage *base, void *work, size_t work_size, bool use_cache);
Result Initialize(std::shared_ptr<fs::IStorage> base, void *work, size_t work_size, bool use_cache);
fs::IStorage *GetBaseStorage();
RomFileTable *GetRomFileTable();
Result GetFileBaseOffset(s64 *out, const fs::Path &path);
public:
virtual Result DoCreateFile(const fs::Path &path, s64 size, int flags) override;
virtual Result DoDeleteFile(const fs::Path &path) override;
virtual Result DoCreateDirectory(const fs::Path &path) override;
virtual Result DoDeleteDirectory(const fs::Path &path) override;
virtual Result DoDeleteDirectoryRecursively(const fs::Path &path) override;
virtual Result DoRenameFile(const fs::Path &old_path, const fs::Path &new_path) override;
virtual Result DoRenameDirectory(const fs::Path &old_path, const fs::Path &new_path) override;
virtual Result DoGetEntryType(fs::DirectoryEntryType *out, const fs::Path &path) override;
virtual Result DoOpenFile(std::unique_ptr<fs::fsa::IFile> *out_file, const fs::Path &path, fs::OpenMode mode) override;
virtual Result DoOpenDirectory(std::unique_ptr<fs::fsa::IDirectory> *out_dir, const fs::Path &path, fs::OpenDirectoryMode mode) override;
virtual Result DoCommit() override;
virtual Result DoGetFreeSpaceSize(s64 *out, const fs::Path &path) override;
virtual Result DoCleanDirectoryRecursively(const fs::Path &path) override;
/* These aren't accessible as commands. */
virtual Result DoCommitProvisionally(s64 counter) override;
};
}
| 3,994
|
C++
|
.h
| 72
| 46.611111
| 149
| 0.676546
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,502
|
fssystem_sha_hash_generator.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_sha_hash_generator.hpp
|
/*
* 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>
#include <stratosphere/fssystem/fssystem_i_hash_256_generator.hpp>
namespace ams::fssystem {
/* ACCURATE_TO_VERSION: 14.3.0.0 */
namespace impl {
template<typename Traits>
class ShaHashGenerator final : public ::ams::fssystem::IHash256Generator, public ::ams::fs::impl::Newable {
static_assert(Traits::Generator::HashSize == IHash256Generator::HashSize);
NON_COPYABLE(ShaHashGenerator);
NON_MOVEABLE(ShaHashGenerator);
private:
using Generator = typename Traits::Generator;
private:
Generator m_generator;
public:
ShaHashGenerator() = default;
protected:
virtual void DoInitialize() override {
m_generator.Initialize();
}
virtual void DoUpdate(const void *data, size_t size) override {
m_generator.Update(data, size);
}
virtual void DoGetHash(void *dst, size_t dst_size) override {
m_generator.GetHash(dst, dst_size);
}
};
template<typename Traits>
class ShaHashGeneratorFactory final : public IHash256GeneratorFactory, public ::ams::fs::impl::Newable {
static_assert(Traits::Generator::HashSize == IHash256Generator::HashSize);
NON_COPYABLE(ShaHashGeneratorFactory);
NON_MOVEABLE(ShaHashGeneratorFactory);
public:
constexpr ShaHashGeneratorFactory() = default;
protected:
virtual Result DoCreate(std::unique_ptr<IHash256Generator> *out) override {
auto generator = std::unique_ptr<IHash256Generator>(new ShaHashGenerator<Traits>());
R_UNLESS(generator != nullptr, fs::ResultAllocationMemoryFailedNew());
*out = std::move(generator);
R_SUCCEED();
}
virtual void DoGenerateHash(void *dst, size_t dst_size, const void *src, size_t src_size) override {
Traits::Generate(dst, dst_size, src, src_size);
}
};
struct Sha256Traits {
using Generator = crypto::Sha256Generator;
static ALWAYS_INLINE void Generate(void *dst, size_t dst_size, const void *src, size_t src_size) {
return crypto::GenerateSha256(dst, dst_size, src, src_size);
}
};
struct Sha3256Traits {
using Generator = crypto::Sha3256Generator;
static ALWAYS_INLINE void Generate(void *dst, size_t dst_size, const void *src, size_t src_size) {
return crypto::GenerateSha3256(dst, dst_size, src, src_size);
}
};
}
using Sha256HashGenerator = impl::ShaHashGenerator<impl::Sha256Traits>;
using Sha256HashGeneratorFactory = impl::ShaHashGeneratorFactory<impl::Sha256Traits>;
using Sha3256HashGenerator = impl::ShaHashGenerator<impl::Sha3256Traits>;
using Sha3256HashGeneratorFactory = impl::ShaHashGeneratorFactory<impl::Sha3256Traits>;
class ShaHashGeneratorFactorySelector final : public IHash256GeneratorFactorySelector, public ::ams::fs::impl::Newable {
NON_COPYABLE(ShaHashGeneratorFactorySelector);
NON_MOVEABLE(ShaHashGeneratorFactorySelector);
private:
Sha256HashGeneratorFactory m_sha256_factory;
Sha3256HashGeneratorFactory m_sha3_256_factory;
public:
constexpr ShaHashGeneratorFactorySelector() = default;
protected:
virtual IHash256GeneratorFactory *DoGetFactory(HashAlgorithmType alg) override {
switch (alg) {
case HashAlgorithmType_Sha2: return std::addressof(m_sha256_factory);
case HashAlgorithmType_Sha3: return std::addressof(m_sha3_256_factory);
AMS_UNREACHABLE_DEFAULT_CASE();
}
}
};
}
| 4,700
|
C++
|
.h
| 96
| 37.84375
| 124
| 0.635492
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,503
|
fssystem_aes_ctr_storage_external.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_aes_ctr_storage_external.hpp
|
/*
* 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>
#include <stratosphere/fs/fs_istorage.hpp>
#include <stratosphere/fs/impl/fs_newable.hpp>
#include <stratosphere/fssystem/fssystem_nca_file_system_driver.hpp>
namespace ams::fssystem {
/* ACCURATE_TO_VERSION: 14.3.0.0 */
class AesCtrStorageExternal : public ::ams::fs::IStorage, public ::ams::fs::impl::Newable {
NON_COPYABLE(AesCtrStorageExternal);
NON_MOVEABLE(AesCtrStorageExternal);
public:
static constexpr size_t BlockSize = crypto::Aes128CtrEncryptor::BlockSize;
static constexpr size_t KeySize = crypto::Aes128CtrEncryptor::KeySize;
static constexpr size_t IvSize = crypto::Aes128CtrEncryptor::IvSize;
private:
std::shared_ptr<fs::IStorage> m_base_storage;
u8 m_iv[IvSize];
DecryptAesCtrFunction m_decrypt_function;
s32 m_key_index;
s32 m_key_generation;
u8 m_encrypted_key[KeySize];
public:
AesCtrStorageExternal(std::shared_ptr<fs::IStorage> bs, const void *enc_key, size_t enc_key_size, const void *iv, size_t iv_size, DecryptAesCtrFunction df, s32 kidx, s32 kgen);
virtual Result Read(s64 offset, void *buffer, size_t size) override;
virtual Result OperateRange(void *dst, size_t dst_size, fs::OperationId op_id, s64 offset, s64 size, const void *src, size_t src_size) override;
virtual Result GetSize(s64 *out) override;
virtual Result Flush() override;
virtual Result Write(s64 offset, const void *buffer, size_t size) override;
virtual Result SetSize(s64 size) override;
};
}
| 2,315
|
C++
|
.h
| 46
| 43.630435
| 188
| 0.695364
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,504
|
fssystem_alignment_matching_storage.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_alignment_matching_storage.hpp
|
/*
* 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>
#include <stratosphere/fs/fs_istorage.hpp>
#include <stratosphere/fs/impl/fs_newable.hpp>
#include <stratosphere/fssystem/fssystem_alignment_matching_storage_impl.hpp>
#include <stratosphere/fssystem/fssystem_pooled_buffer.hpp>
namespace ams::fssystem {
/* ACCURATE_TO_VERSION: Unknown */
template<size_t _DataAlign, size_t _BufferAlign>
class AlignmentMatchingStorage : public ::ams::fs::IStorage, public ::ams::fs::impl::Newable {
NON_COPYABLE(AlignmentMatchingStorage);
NON_MOVEABLE(AlignmentMatchingStorage);
public:
static constexpr size_t DataAlign = _DataAlign;
static constexpr size_t BufferAlign = _BufferAlign;
static constexpr size_t DataAlignMax = 0x200;
static_assert(DataAlign <= DataAlignMax);
static_assert(util::IsPowerOfTwo(DataAlign));
static_assert(util::IsPowerOfTwo(BufferAlign));
private:
std::shared_ptr<fs::IStorage> m_shared_base_storage;
fs::IStorage * const m_base_storage;
s64 m_base_storage_size;
bool m_is_base_storage_size_dirty;
public:
explicit AlignmentMatchingStorage(fs::IStorage *bs) : m_base_storage(bs), m_is_base_storage_size_dirty(true) {
/* ... */
}
explicit AlignmentMatchingStorage(std::shared_ptr<fs::IStorage> bs) : m_shared_base_storage(std::move(bs)), m_base_storage(m_shared_base_storage.get()), m_is_base_storage_size_dirty(true) {
/* ... */
}
virtual Result Read(s64 offset, void *buffer, size_t size) override {
/* Allocate a work buffer on stack. */
__attribute__((aligned(DataAlignMax))) char work_buf[DataAlign];
static_assert(util::IsAligned(alignof(work_buf), BufferAlign));
/* Succeed if zero size. */
R_SUCCEED_IF(size == 0);
/* Validate arguments. */
R_UNLESS(buffer != nullptr, fs::ResultNullptrArgument());
s64 bs_size = 0;
R_TRY(this->GetSize(std::addressof(bs_size)));
R_TRY(fs::IStorage::CheckAccessRange(offset, size, bs_size));
R_RETURN(AlignmentMatchingStorageImpl::Read(m_base_storage, work_buf, sizeof(work_buf), DataAlign, BufferAlign, offset, static_cast<char *>(buffer), size));
}
virtual Result Write(s64 offset, const void *buffer, size_t size) override {
/* Allocate a work buffer on stack. */
__attribute__((aligned(DataAlignMax))) char work_buf[DataAlign];
static_assert(util::IsAligned(alignof(work_buf), BufferAlign));
/* Succeed if zero size. */
R_SUCCEED_IF(size == 0);
/* Validate arguments. */
R_UNLESS(buffer != nullptr, fs::ResultNullptrArgument());
s64 bs_size = 0;
R_TRY(this->GetSize(std::addressof(bs_size)));
R_TRY(fs::IStorage::CheckAccessRange(offset, size, bs_size));
R_RETURN(AlignmentMatchingStorageImpl::Write(m_base_storage, work_buf, sizeof(work_buf), DataAlign, BufferAlign, offset, static_cast<const char *>(buffer), size));
}
virtual Result Flush() override {
R_RETURN(m_base_storage->Flush());
}
virtual Result SetSize(s64 size) override {
ON_SCOPE_EXIT { m_is_base_storage_size_dirty = true; };
R_RETURN(m_base_storage->SetSize(util::AlignUp(size, DataAlign)));
}
virtual Result GetSize(s64 *out) override {
AMS_ASSERT(out != nullptr);
if (m_is_base_storage_size_dirty) {
s64 size;
R_TRY(m_base_storage->GetSize(std::addressof(size)));
m_base_storage_size = size;
m_is_base_storage_size_dirty = false;
}
*out = m_base_storage_size;
R_SUCCEED();
}
virtual Result OperateRange(void *dst, size_t dst_size, fs::OperationId op_id, s64 offset, s64 size, const void *src, size_t src_size) override {
if (op_id == fs::OperationId::Invalidate) {
R_RETURN(m_base_storage->OperateRange(fs::OperationId::Invalidate, offset, size));
} else {
/* Succeed if zero size. */
R_SUCCEED_IF(size == 0);
/* Get the base storage size. */
s64 bs_size = 0;
R_TRY(this->GetSize(std::addressof(bs_size)));
R_TRY(fs::IStorage::CheckOffsetAndSize(offset, size));
/* Operate on the base storage. */
const auto valid_size = std::min(size, bs_size - offset);
const auto aligned_offset = util::AlignDown(offset, DataAlign);
const auto aligned_offset_end = util::AlignUp(offset + valid_size, DataAlign);
const auto aligned_size = aligned_offset_end - aligned_offset;
R_RETURN(m_base_storage->OperateRange(dst, dst_size, op_id, aligned_offset, aligned_size, src, src_size));
}
}
};
/* ACCURATE_TO_VERSION: Unknown */
template<fs::PointerToStorage BasePointer, size_t _BufferAlign>
class AlignmentMatchingStoragePooledBuffer : public ::ams::fs::IStorage, public ::ams::fs::impl::Newable {
NON_COPYABLE(AlignmentMatchingStoragePooledBuffer);
NON_MOVEABLE(AlignmentMatchingStoragePooledBuffer);
public:
static constexpr size_t BufferAlign = _BufferAlign;
static_assert(util::IsPowerOfTwo(BufferAlign));
private:
BasePointer m_base_storage;
s64 m_base_storage_size;
size_t m_data_align;
bool m_is_base_storage_size_dirty;
public:
explicit AlignmentMatchingStoragePooledBuffer(BasePointer bs, size_t da) : m_base_storage(std::move(bs)), m_data_align(da), m_is_base_storage_size_dirty(true) {
AMS_ASSERT(util::IsPowerOfTwo(da));
}
virtual Result Read(s64 offset, void *buffer, size_t size) override {
/* Succeed if zero size. */
R_SUCCEED_IF(size == 0);
/* Validate arguments. */
R_UNLESS(buffer != nullptr, fs::ResultNullptrArgument());
s64 bs_size = 0;
R_TRY(this->GetSize(std::addressof(bs_size)));
R_TRY(fs::IStorage::CheckAccessRange(offset, size, bs_size));
/* Allocate a pooled buffer. */
PooledBuffer pooled_buffer;
pooled_buffer.AllocateParticularlyLarge(m_data_align, m_data_align);
R_RETURN(AlignmentMatchingStorageImpl::Read(m_base_storage, pooled_buffer.GetBuffer(), pooled_buffer.GetSize(), m_data_align, BufferAlign, offset, static_cast<char *>(buffer), size));
}
virtual Result Write(s64 offset, const void *buffer, size_t size) override {
/* Succeed if zero size. */
R_SUCCEED_IF(size == 0);
/* Validate arguments. */
R_UNLESS(buffer != nullptr, fs::ResultNullptrArgument());
s64 bs_size = 0;
R_TRY(this->GetSize(std::addressof(bs_size)));
R_TRY(fs::IStorage::CheckAccessRange(offset, size, bs_size));
/* Allocate a pooled buffer. */
PooledBuffer pooled_buffer;
pooled_buffer.AllocateParticularlyLarge(m_data_align, m_data_align);
R_RETURN(AlignmentMatchingStorageImpl::Write(m_base_storage, pooled_buffer.GetBuffer(), pooled_buffer.GetSize(), m_data_align, BufferAlign, offset, static_cast<const char *>(buffer), size));
}
virtual Result Flush() override {
R_RETURN(m_base_storage->Flush());
}
virtual Result SetSize(s64 size) override {
ON_SCOPE_EXIT { m_is_base_storage_size_dirty = true; };
R_RETURN(m_base_storage->SetSize(util::AlignUp(size, m_data_align)));
}
virtual Result GetSize(s64 *out) override {
AMS_ASSERT(out != nullptr);
if (m_is_base_storage_size_dirty) {
s64 size;
R_TRY(m_base_storage->GetSize(std::addressof(size)));
m_base_storage_size = size;
m_is_base_storage_size_dirty = false;
}
*out = m_base_storage_size;
R_SUCCEED();
}
virtual Result OperateRange(void *dst, size_t dst_size, fs::OperationId op_id, s64 offset, s64 size, const void *src, size_t src_size) override {
if (op_id == fs::OperationId::Invalidate) {
R_RETURN(m_base_storage->OperateRange(fs::OperationId::Invalidate, offset, size));
} else {
/* Succeed if zero size. */
R_SUCCEED_IF(size == 0);
/* Get the base storage size. */
s64 bs_size = 0;
R_TRY(this->GetSize(std::addressof(bs_size)));
R_TRY(fs::IStorage::CheckOffsetAndSize(offset, size));
/* Operate on the base storage. */
const auto valid_size = std::min(size, bs_size - offset);
const auto aligned_offset = util::AlignDown(offset, m_data_align);
const auto aligned_offset_end = util::AlignUp(offset + valid_size, m_data_align);
const auto aligned_size = aligned_offset_end - aligned_offset;
R_RETURN(m_base_storage->OperateRange(dst, dst_size, op_id, aligned_offset, aligned_size, src, src_size));
}
}
};
/* ACCURATE_TO_VERSION: Unknown */
template<size_t _BufferAlign>
class AlignmentMatchingStorageInBulkRead : public ::ams::fs::IStorage, public ::ams::fs::impl::Newable {
NON_COPYABLE(AlignmentMatchingStorageInBulkRead);
NON_MOVEABLE(AlignmentMatchingStorageInBulkRead);
public:
static constexpr size_t BufferAlign = _BufferAlign;
static_assert(util::IsPowerOfTwo(BufferAlign));
private:
std::shared_ptr<fs::IStorage> m_shared_base_storage;
fs::IStorage * const m_base_storage;
s64 m_base_storage_size;
size_t m_data_align;
public:
explicit AlignmentMatchingStorageInBulkRead(fs::IStorage *bs, size_t da) : m_shared_base_storage(), m_base_storage(bs), m_base_storage_size(-1), m_data_align(da) {
AMS_ASSERT(util::IsPowerOfTwo(m_data_align));
}
explicit AlignmentMatchingStorageInBulkRead(std::shared_ptr<fs::IStorage> bs, size_t da) : m_shared_base_storage(bs), m_base_storage(m_shared_base_storage.get()), m_base_storage_size(-1), m_data_align(da) {
AMS_ASSERT(util::IsPowerOfTwo(da));
}
virtual Result Read(s64 offset, void *buffer, size_t size) override;
virtual Result Write(s64 offset, const void *buffer, size_t size) override {
/* Succeed if zero size. */
R_SUCCEED_IF(size == 0);
/* Validate arguments. */
R_UNLESS(buffer != nullptr, fs::ResultNullptrArgument());
s64 bs_size = 0;
R_TRY(this->GetSize(std::addressof(bs_size)));
R_TRY(fs::IStorage::CheckAccessRange(offset, size, bs_size));
/* Allocate a pooled buffer. */
PooledBuffer pooled_buffer(m_data_align, m_data_align);
R_RETURN(AlignmentMatchingStorageImpl::Write(m_base_storage, pooled_buffer.GetBuffer(), pooled_buffer.GetSize(), m_data_align, BufferAlign, offset, static_cast<const char *>(buffer), size));
}
virtual Result Flush() override {
R_RETURN(m_base_storage->Flush());
}
virtual Result SetSize(s64 size) override {
ON_SCOPE_EXIT { m_base_storage_size = -1; };
R_RETURN(m_base_storage->SetSize(util::AlignUp(size, m_data_align)));
}
virtual Result GetSize(s64 *out) override {
AMS_ASSERT(out != nullptr);
if (m_base_storage_size < 0) {
s64 size;
R_TRY(m_base_storage->GetSize(std::addressof(size)));
m_base_storage_size = size;
}
*out = m_base_storage_size;
R_SUCCEED();
}
virtual Result OperateRange(void *dst, size_t dst_size, fs::OperationId op_id, s64 offset, s64 size, const void *src, size_t src_size) override {
if (op_id == fs::OperationId::Invalidate) {
R_RETURN(m_base_storage->OperateRange(fs::OperationId::Invalidate, offset, size));
} else {
/* Succeed if zero size. */
R_SUCCEED_IF(size == 0);
/* Get the base storage size. */
s64 bs_size = 0;
R_TRY(this->GetSize(std::addressof(bs_size)));
R_TRY(fs::IStorage::CheckOffsetAndSize(offset, size));
/* Operate on the base storage. */
const auto valid_size = std::min(size, bs_size - offset);
const auto aligned_offset = util::AlignDown(offset, m_data_align);
const auto aligned_offset_end = util::AlignUp(offset + valid_size, m_data_align);
const auto aligned_size = aligned_offset_end - aligned_offset;
R_RETURN(m_base_storage->OperateRange(dst, dst_size, op_id, aligned_offset, aligned_size, src, src_size));
}
}
};
}
| 14,831
|
C++
|
.h
| 259
| 42.660232
| 218
| 0.571724
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,505
|
fssystem_switch_storage.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_switch_storage.hpp
|
/*
* 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>
#include <stratosphere/fs/fs_istorage.hpp>
#include <stratosphere/fs/impl/fs_newable.hpp>
namespace ams::fssystem {
/* ACCURATE_TO_VERSION: 14.3.0.0 */
template<typename F>
class SwitchStorage : public ::ams::fs::IStorage, public ::ams::fs::impl::Newable {
NON_COPYABLE(SwitchStorage);
NON_MOVEABLE(SwitchStorage);
private:
std::shared_ptr<fs::IStorage> m_true_storage;
std::shared_ptr<fs::IStorage> m_false_storage;
F m_truth_function;
private:
ALWAYS_INLINE std::shared_ptr<fs::IStorage> &SelectStorage() {
return m_truth_function() ? m_true_storage : m_false_storage;
}
public:
SwitchStorage(std::shared_ptr<fs::IStorage> t, std::shared_ptr<fs::IStorage> f, F func) : m_true_storage(std::move(t)), m_false_storage(std::move(f)), m_truth_function(func) { /* ... */ }
virtual Result Read(s64 offset, void *buffer, size_t size) override {
R_RETURN(this->SelectStorage()->Read(offset, buffer, size));
}
virtual Result OperateRange(void *dst, size_t dst_size, fs::OperationId op_id, s64 offset, s64 size, const void *src, size_t src_size) override {
switch (op_id) {
case fs::OperationId::Invalidate:
{
R_TRY(m_true_storage->OperateRange(dst, dst_size, op_id, offset, size, src, src_size));
R_TRY(m_false_storage->OperateRange(dst, dst_size, op_id, offset, size, src, src_size));
R_SUCCEED();
}
case fs::OperationId::QueryRange:
{
R_TRY(this->SelectStorage()->OperateRange(dst, dst_size, op_id, offset, size, src, src_size));
R_SUCCEED();
}
default:
R_THROW(fs::ResultUnsupportedOperateRangeForSwitchStorage());
}
}
virtual Result GetSize(s64 *out) override {
R_RETURN(this->SelectStorage()->GetSize(out));
}
virtual Result Flush() override {
R_RETURN(this->SelectStorage()->Flush());
}
virtual Result Write(s64 offset, const void *buffer, size_t size) override {
R_RETURN(this->SelectStorage()->Write(offset, buffer, size));
}
virtual Result SetSize(s64 size) override {
R_RETURN(this->SelectStorage()->SetSize(size));
}
};
class RegionSwitchStorage : public ::ams::fs::IStorage, public ::ams::fs::impl::Newable {
NON_COPYABLE(RegionSwitchStorage);
NON_MOVEABLE(RegionSwitchStorage);
public:
struct Region {
s64 offset;
s64 size;
};
private:
std::shared_ptr<fs::IStorage> m_inside_region_storage;
std::shared_ptr<fs::IStorage> m_outside_region_storage;
Region m_region;
public:
RegionSwitchStorage(std::shared_ptr<fs::IStorage> &&i, std::shared_ptr<fs::IStorage> &&o, Region r) : m_inside_region_storage(std::move(i)), m_outside_region_storage(std::move(o)), m_region(r) {
/* ... */
}
virtual Result Read(s64 offset, void *buffer, size_t size) override {
/* Process until we're done. */
size_t processed = 0;
while (processed < size) {
/* Process on the appropriate storage. */
s64 cur_size = 0;
if (this->CheckRegions(std::addressof(cur_size), offset + processed, size - processed)) {
R_TRY(m_inside_region_storage->Read(offset + processed, static_cast<u8 *>(buffer) + processed, cur_size));
} else {
R_TRY(m_outside_region_storage->Read(offset + processed, static_cast<u8 *>(buffer) + processed, cur_size));
}
/* Advance. */
processed += cur_size;
}
R_SUCCEED();
}
virtual Result Write(s64 offset, const void *buffer, size_t size) override {
/* Process until we're done. */
size_t processed = 0;
while (processed < size) {
/* Process on the appropriate storage. */
s64 cur_size = 0;
if (this->CheckRegions(std::addressof(cur_size), offset + processed, size - processed)) {
R_TRY(m_inside_region_storage->Write(offset + processed, static_cast<const u8 *>(buffer) + processed, cur_size));
} else {
R_TRY(m_outside_region_storage->Write(offset + processed, static_cast<const u8 *>(buffer) + processed, cur_size));
}
/* Advance. */
processed += cur_size;
}
R_SUCCEED();
}
virtual Result OperateRange(void *dst, size_t dst_size, fs::OperationId op_id, s64 offset, s64 size, const void *src, size_t src_size) override {
switch (op_id) {
case fs::OperationId::Invalidate:
{
R_TRY(m_inside_region_storage->OperateRange(dst, dst_size, op_id, offset, size, src, src_size));
R_TRY(m_outside_region_storage->OperateRange(dst, dst_size, op_id, offset, size, src, src_size));
R_SUCCEED();
}
case fs::OperationId::QueryRange:
{
/* Create a new info. */
fs::QueryRangeInfo merged_info;
merged_info.Clear();
/* Process until we're done. */
s64 processed = 0;
while (processed < size) {
/* Process on the appropriate storage. */
s64 cur_size = 0;
fs::QueryRangeInfo cur_info;
if (this->CheckRegions(std::addressof(cur_size), offset + processed, size - processed)) {
R_TRY(m_inside_region_storage->OperateRange(std::addressof(cur_info), sizeof(cur_info), op_id, offset + processed, cur_size, src, src_size));
} else {
R_TRY(m_outside_region_storage->OperateRange(std::addressof(cur_info), sizeof(cur_info), op_id, offset + processed, cur_size, src, src_size));
}
/* Merge the current info. */
merged_info.Merge(cur_info);
/* Advance. */
processed += cur_size;
}
/* Write the merged info. */
*reinterpret_cast<fs::QueryRangeInfo *>(dst) = merged_info;
R_SUCCEED();
}
default:
R_THROW(fs::ResultUnsupportedOperateRangeForRegionSwitchStorage());
}
}
virtual Result GetSize(s64 *out) override {
R_RETURN(m_inside_region_storage->GetSize(out));
}
virtual Result Flush() override {
/* Flush both storages. */
R_TRY(m_inside_region_storage->Flush());
R_TRY(m_outside_region_storage->Flush());
R_SUCCEED();
}
virtual Result SetSize(s64 size) override {
/* Set size for both storages. */
R_TRY(m_inside_region_storage->SetSize(size));
R_TRY(m_outside_region_storage->SetSize(size));
R_SUCCEED();
}
private:
bool CheckRegions(s64 *out_current_size, s64 offset, s64 size) const {
/* Check if our region contains the access. */
if (m_region.offset <= offset) {
if (offset < m_region.offset + m_region.size) {
if (m_region.offset + m_region.size <= offset + size) {
*out_current_size = m_region.offset + m_region.size - offset;
} else {
*out_current_size = size;
}
return true;
} else {
*out_current_size = size;
return false;
}
} else {
if (m_region.offset <= offset + size) {
*out_current_size = m_region.offset - offset;
} else {
*out_current_size = size;
}
return false;
}
}
};
}
| 9,924
|
C++
|
.h
| 194
| 33.587629
| 206
| 0.493509
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,506
|
fssystem_block_cache_buffered_storage.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_block_cache_buffered_storage.hpp
|
/*
* 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>
#include <stratosphere/os.hpp>
#include <stratosphere/fs/fs_storage_type.hpp>
#include <stratosphere/fs/fs_istorage.hpp>
#include <stratosphere/fs/fs_memory_management.hpp>
#include <stratosphere/fssystem/buffers/fssystem_file_system_buffer_manager.hpp>
#include <stratosphere/fssystem/impl/fssystem_block_cache_manager.hpp>
namespace ams::fssystem {
constexpr inline size_t IntegrityMinLayerCount = 2;
constexpr inline size_t IntegrityMaxLayerCount = 7;
constexpr inline size_t IntegrityLayerCountSave = 5;
constexpr inline size_t IntegrityLayerCountSaveDataMeta = 4;
struct FileSystemBufferManagerSet {
fs::IBufferManager *buffers[IntegrityMaxLayerCount];
};
static_assert(util::is_pod<FileSystemBufferManagerSet>::value);
/* ACCURATE_TO_VERSION: 13.4.0.0 */
class BlockCacheBufferedStorage : public ::ams::fs::IStorage {
NON_COPYABLE(BlockCacheBufferedStorage);
NON_MOVEABLE(BlockCacheBufferedStorage);
public:
static constexpr size_t DefaultMaxCacheEntryCount = 24;
private:
using MemoryRange = fs::IBufferManager::MemoryRange;
struct AccessRange {
s64 offset;
size_t size;
s64 GetEndOffset() const {
return this->offset + this->size;
}
bool IsIncluded(s64 ofs) const {
return this->offset <= ofs && ofs < this->GetEndOffset();
}
};
static_assert(util::is_pod<AccessRange>::value);
struct CacheEntry {
AccessRange range;
bool is_valid;
bool is_write_back;
bool is_cached;
bool is_flushing;
u16 lru_counter;
fs::IBufferManager::CacheHandle handle;
uintptr_t memory_address;
size_t memory_size;
void Invalidate() {
this->is_write_back = false;
this->is_flushing = false;
}
bool IsAllocated() const {
return this->is_valid && (this->is_write_back ? this->memory_address != 0 : this->handle != 0);
}
bool IsWriteBack() const {
return this->is_write_back;
}
};
static_assert(util::is_pod<CacheEntry>::value);
using BlockCacheManager = ::ams::fssystem::impl::BlockCacheManager<CacheEntry, fs::IBufferManager>;
using CacheIndex = BlockCacheManager::CacheIndex;
enum Flag : s32 {
Flag_KeepBurstMode = (1 << 8),
Flag_RealData = (1 << 10),
};
private:
os::SdkRecursiveMutex *m_mutex;
IStorage *m_data_storage;
Result m_last_result;
s64 m_data_size;
size_t m_verification_block_size;
size_t m_verification_block_shift;
s32 m_flags;
s32 m_buffer_level;
BlockCacheManager m_block_cache_manager;
bool m_is_writable;
public:
BlockCacheBufferedStorage();
virtual ~BlockCacheBufferedStorage() override;
Result Initialize(fs::IBufferManager *bm, os::SdkRecursiveMutex *mtx, IStorage *data, s64 data_size, size_t verif_block_size, s32 max_cache_entries, bool is_real_data, s8 buffer_level, bool is_keep_burst_mode, bool is_writable);
void Finalize();
virtual Result Read(s64 offset, void *buffer, size_t size) override;
virtual Result Write(s64 offset, const void *buffer, size_t size) override;
virtual Result SetSize(s64) override { R_THROW(fs::ResultUnsupportedSetSizeForBlockCacheBufferedStorage()); }
virtual Result GetSize(s64 *out) override;
virtual Result Flush() override;
virtual Result OperateRange(void *dst, size_t dst_size, fs::OperationId op_id, s64 offset, s64 size, const void *src, size_t src_size) override;
using IStorage::OperateRange;
Result Commit();
Result OnRollback();
bool IsEnabledKeepBurstMode() const {
return (m_flags & Flag_KeepBurstMode) != 0;
}
bool IsRealDataCache() const {
return (m_flags & Flag_RealData) != 0;
}
void SetKeepBurstMode(bool en) {
if (en) {
m_flags |= Flag_KeepBurstMode;
} else {
m_flags &= ~Flag_KeepBurstMode;
}
}
void SetRealDataCache(bool en) {
if (en) {
m_flags |= Flag_RealData;
} else {
m_flags &= ~Flag_RealData;
}
}
private:
Result FillZeroImpl(s64 offset, s64 size);
Result DestroySignatureImpl(s64 offset, s64 size);
Result InvalidateImpl();
Result QueryRangeImpl(void *dst, size_t dst_size, s64 offset, s64 size);
Result GetAssociateBuffer(MemoryRange *out_range, CacheEntry *out_entry, s64 offset, size_t ideal_size, bool is_allocate_for_write);
Result StoreOrDestroyBuffer(CacheIndex *out, const MemoryRange &range, CacheEntry *entry);
Result StoreOrDestroyBuffer(const MemoryRange &range, CacheEntry *entry) {
AMS_ASSERT(entry != nullptr);
CacheIndex dummy;
R_RETURN(this->StoreOrDestroyBuffer(std::addressof(dummy), range, entry));
}
Result FlushCacheEntry(CacheIndex index, bool invalidate);
Result FlushRangeCacheEntries(s64 offset, s64 size, bool invalidate);
Result FlushAllCacheEntries();
Result InvalidateAllCacheEntries();
Result ControlDirtiness();
Result UpdateLastResult(Result result);
Result ReadHeadCache(MemoryRange *out_range, CacheEntry *out_entry, bool *out_cache_needed, s64 *offset, s64 *aligned_offset, s64 aligned_offset_end, char **buffer, size_t *size);
Result ReadTailCache(MemoryRange *out_range, CacheEntry *out_entry, bool *out_cache_needed, s64 offset, s64 aligned_offset, s64 *aligned_offset_end, char *buffer, size_t *size);
Result BulkRead(s64 offset, void *buffer, size_t size, MemoryRange *range_head, MemoryRange *range_tail, CacheEntry *entry_head, CacheEntry *entry_tail, bool head_cache_needed, bool tail_cache_needed);
};
}
| 7,329
|
C++
|
.h
| 147
| 37.870748
| 240
| 0.610155
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,507
|
fssystem_allocator_utility.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_allocator_utility.hpp
|
/*
* 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>
/* Forward declare ams::fs allocate shared. */
namespace ams::fs::impl {
template<typename T, template<typename, typename> class AllocatorTemplateT, typename Impl, typename... Args>
std::shared_ptr<T> AllocateSharedImpl(Args &&... args);
}
namespace ams::fssystem {
/* ACCURATE_TO_VERSION: Unknown */
using AllocateFunction = void *(*)(size_t size);
using DeallocateFunction = void (*)(void *ptr, size_t size);
void InitializeAllocator(AllocateFunction allocate_func, DeallocateFunction deallocate_func);
void InitializeAllocatorForSystem(AllocateFunction allocate_func, DeallocateFunction deallocate_func);
void *Allocate(size_t size);
void Deallocate(void *ptr, size_t size);
namespace impl {
template<bool ForSystem>
class AllocatorFunctionSet {
public:
static void *Allocate(size_t size);
static void *AllocateUnsafe(size_t size);
static void Deallocate(void *ptr, size_t size);
static void DeallocateUnsafe(void *ptr, size_t size);
static void LockAllocatorMutex();
static void UnlockAllocatorMutex();
};
using AllocatorFunctionSetForNormal = AllocatorFunctionSet<false>;
using AllocatorFunctionSetForSystem = AllocatorFunctionSet<true>;
template<typename T, typename Impl, bool RequireNonNull, bool AllocateWhileLocked>
class AllocatorTemplate : public std::allocator<T> {
public:
template<typename U>
struct rebind {
using other = AllocatorTemplate<U, Impl, RequireNonNull, AllocateWhileLocked>;
};
private:
static ALWAYS_INLINE T *AllocateImpl(::std::size_t n) {
if constexpr (AllocateWhileLocked) {
auto * const p = Impl::AllocateUnsafe(sizeof(T) * n);
Impl::UnlockAllocatorMutex();
return static_cast<T *>(p);
} else {
return static_cast<T *>(Impl::Allocate(sizeof(T) * n));
}
}
public:
AllocatorTemplate() { /* ... */ }
template<typename U>
AllocatorTemplate(const AllocatorTemplate<U, Impl, RequireNonNull, AllocateWhileLocked> &) { /* ... */ }
[[nodiscard]] T *allocate(::std::size_t n) {
auto * const p = AllocateImpl(n);
if constexpr (RequireNonNull) {
AMS_ABORT_UNLESS(p != nullptr);
}
return p;
}
void deallocate(T *p, ::std::size_t n) {
Impl::Deallocate(p, sizeof(T) * n);
}
};
template<typename T, typename Impl>
using AllocatorTemplateForAllocateShared = AllocatorTemplate<T, Impl, true, true>;
}
template<typename T, typename... Args>
std::shared_ptr<T> AllocateShared(Args &&... args) {
return ::ams::fs::impl::AllocateSharedImpl<T, impl::AllocatorTemplateForAllocateShared, impl::AllocatorFunctionSetForNormal>(std::forward<Args>(args)...);
}
template<typename TImpl, typename ErrorResult, typename TIntf, typename... Args>
Result AllocateSharedForSystem(std::shared_ptr<TIntf> *out, Args &&... args) {
/* Allocate the object. */
auto p = ::ams::fs::impl::AllocateSharedImpl<TImpl, impl::AllocatorTemplateForAllocateShared, impl::AllocatorFunctionSetForSystem>(std::forward<Args>(args)...);
/* Check that allocation succeeded. */
R_UNLESS(p != nullptr, ErrorResult());
/* Return the allocated object. */
*out = std::move(p);
R_SUCCEED();
}
}
| 4,509
|
C++
|
.h
| 93
| 37.967742
| 168
| 0.619622
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,508
|
fssystem_forwarding_file_system.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_forwarding_file_system.hpp
|
/*
* 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 <stratosphere/fs/fs_common.hpp>
#include <stratosphere/fs/impl/fs_newable.hpp>
#include <stratosphere/fs/fsa/fs_ifile.hpp>
#include <stratosphere/fs/fsa/fs_idirectory.hpp>
#include <stratosphere/fs/fsa/fs_ifilesystem.hpp>
#include <stratosphere/fs/fs_query_range.hpp>
namespace ams::fssystem {
/* ACCURATE_TO_VERSION: 13.4.0.0 */
class ForwardingFile final : public ::ams::fs::fsa::IFile, public ::ams::fs::impl::Newable {
NON_COPYABLE(ForwardingFile);
NON_MOVEABLE(ForwardingFile);
private:
std::unique_ptr<fs::fsa::IFile> m_base_file;
public:
ForwardingFile(std::unique_ptr<fs::fsa::IFile> f) : m_base_file(std::move(f)) { /* ... */ }
virtual ~ForwardingFile() { /* ... */ }
public:
virtual Result DoRead(size_t *out, s64 offset, void *buffer, size_t size, const fs::ReadOption &option) override final {
R_RETURN(m_base_file->Read(out, offset, buffer, size, option));
}
virtual Result DoGetSize(s64 *out) override final {
R_RETURN(m_base_file->GetSize(out));
}
virtual Result DoFlush() override final {
R_RETURN(m_base_file->Flush());
}
virtual Result DoWrite(s64 offset, const void *buffer, size_t size, const fs::WriteOption &option) override final {
R_RETURN(m_base_file->Write(offset, buffer, size, option));
}
virtual Result DoSetSize(s64 size) override final {
R_RETURN(m_base_file->SetSize(size));
}
virtual Result DoOperateRange(void *dst, size_t dst_size, fs::OperationId op_id, s64 offset, s64 size, const void *src, size_t src_size) override final {
R_RETURN(m_base_file->OperateRange(dst, dst_size, op_id, offset, size, src, src_size));
}
public:
virtual sf::cmif::DomainObjectId GetDomainObjectId() const override final {
return m_base_file->GetDomainObjectId();
}
};
/* ACCURATE_TO_VERSION: 13.4.0.0 */
class ForwardingDirectory final : public ::ams::fs::fsa::IDirectory, public ::ams::fs::impl::Newable {
NON_COPYABLE(ForwardingDirectory);
NON_MOVEABLE(ForwardingDirectory);
private:
std::unique_ptr<fs::fsa::IDirectory> m_base_dir;
public:
ForwardingDirectory(std::unique_ptr<fs::fsa::IDirectory> d) : m_base_dir(std::move(d)) { /* ... */ }
virtual ~ForwardingDirectory() { /* ... */ }
public:
virtual Result DoRead(s64 *out_count, fs::DirectoryEntry *out_entries, s64 max_entries) override final {
R_RETURN(m_base_dir->Read(out_count, out_entries, max_entries));
}
virtual Result DoGetEntryCount(s64 *out) override final {
R_RETURN(m_base_dir->GetEntryCount(out));
}
public:
virtual sf::cmif::DomainObjectId GetDomainObjectId() const override final {
return m_base_dir->GetDomainObjectId();
}
};
/* ACCURATE_TO_VERSION: 13.4.0.0 */
class ForwardingFileSystem final : public ::ams::fs::fsa::IFileSystem, public ::ams::fs::impl::Newable {
NON_COPYABLE(ForwardingFileSystem);
NON_MOVEABLE(ForwardingFileSystem);
private:
std::shared_ptr<fs::fsa::IFileSystem> m_base_fs;
public:
ForwardingFileSystem(std::shared_ptr<fs::fsa::IFileSystem> fs) : m_base_fs(std::move(fs)) { /* ... */ }
virtual ~ForwardingFileSystem() { /* ... */ }
public:
virtual Result DoCreateFile(const fs::Path &path, s64 size, int flags) override final {
R_RETURN(m_base_fs->CreateFile(path, size, flags));
}
virtual Result DoDeleteFile(const fs::Path &path) override final {
R_RETURN(m_base_fs->DeleteFile(path));
}
virtual Result DoCreateDirectory(const fs::Path &path) override final {
R_RETURN(m_base_fs->CreateDirectory(path));
}
virtual Result DoDeleteDirectory(const fs::Path &path) override final {
R_RETURN(m_base_fs->DeleteDirectory(path));
}
virtual Result DoDeleteDirectoryRecursively(const fs::Path &path) override final {
R_RETURN(m_base_fs->DeleteDirectoryRecursively(path));
}
virtual Result DoRenameFile(const fs::Path &old_path, const fs::Path &new_path) override final {
R_RETURN(m_base_fs->RenameFile(old_path, new_path));
}
virtual Result DoRenameDirectory(const fs::Path &old_path, const fs::Path &new_path) override final {
R_RETURN(m_base_fs->RenameDirectory(old_path, new_path));
}
virtual Result DoGetEntryType(fs::DirectoryEntryType *out, const fs::Path &path) override final {
R_RETURN(m_base_fs->GetEntryType(out, path));
}
virtual Result DoOpenFile(std::unique_ptr<fs::fsa::IFile> *out_file, const fs::Path &path, fs::OpenMode mode) override final {
R_RETURN(m_base_fs->OpenFile(out_file, path, mode));
}
virtual Result DoOpenDirectory(std::unique_ptr<fs::fsa::IDirectory> *out_dir, const fs::Path &path, fs::OpenDirectoryMode mode) override final {
R_RETURN(m_base_fs->OpenDirectory(out_dir, path, mode));
}
virtual Result DoCommit() override final {
R_RETURN(m_base_fs->Commit());
}
virtual Result DoGetFreeSpaceSize(s64 *out, const fs::Path &path) override final {
R_RETURN(m_base_fs->GetFreeSpaceSize(out, path));
}
virtual Result DoGetTotalSpaceSize(s64 *out, const fs::Path &path) override final {
R_RETURN(m_base_fs->GetTotalSpaceSize(out, path));
}
virtual Result DoCleanDirectoryRecursively(const fs::Path &path) override final {
R_RETURN(m_base_fs->CleanDirectoryRecursively(path));
}
virtual Result DoGetFileTimeStampRaw(fs::FileTimeStampRaw *out, const fs::Path &path) override final {
R_RETURN(m_base_fs->GetFileTimeStampRaw(out, path));
}
virtual Result DoQueryEntry(char *dst, size_t dst_size, const char *src, size_t src_size, fs::fsa::QueryId query, const fs::Path &path) override final {
R_RETURN(m_base_fs->QueryEntry(dst, dst_size, src, src_size, query, path));
}
virtual Result DoCommitProvisionally(s64 counter) override final {
R_RETURN(m_base_fs->CommitProvisionally(counter));
}
virtual Result DoRollback() override final {
R_RETURN(m_base_fs->Rollback());
}
virtual Result DoFlush() override final {
R_RETURN(m_base_fs->Flush());
}
};
}
| 7,707
|
C++
|
.h
| 146
| 41.609589
| 165
| 0.611901
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,509
|
fssystem_integrity_romfs_storage.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_integrity_romfs_storage.hpp
|
/*
* 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>
#include <stratosphere/fs/fs_istorage.hpp>
#include <stratosphere/fs/fs_memory_storage.hpp>
#include <stratosphere/fs/impl/fs_newable.hpp>
#include <stratosphere/fssystem/fssystem_nca_header.hpp>
#include <stratosphere/fssystem/fssystem_hierarchical_integrity_verification_storage.hpp>
namespace ams::fssystem {
/* ACCURATE_TO_VERSION: Unknown */
constexpr inline size_t IntegrityLayerCountRomFs = 7;
constexpr inline size_t IntegrityHashLayerBlockSize = 16_KB;
class IntegrityRomFsStorage : public ::ams::fs::IStorage, public ::ams::fs::impl::Newable {
private:
HierarchicalIntegrityVerificationStorage m_integrity_storage;
FileSystemBufferManagerSet m_buffers;
os::SdkRecursiveMutex m_mutex;
Hash m_master_hash;
std::unique_ptr<fs::MemoryStorage> m_master_hash_storage;
public:
IntegrityRomFsStorage() : m_mutex() { /* ... */ }
virtual ~IntegrityRomFsStorage() override { this->Finalize(); }
Result Initialize(HierarchicalIntegrityVerificationInformation level_hash_info, Hash master_hash, HierarchicalIntegrityVerificationStorage::HierarchicalStorageInformation storage_info, fs::IBufferManager *bm, int max_data_cache_entries, int max_hash_cache_entries, s8 buffer_level, IHash256GeneratorFactory *hgf);
void Finalize();
virtual Result Read(s64 offset, void *buffer, size_t size) override {
R_RETURN(m_integrity_storage.Read(offset, buffer, size));
}
virtual Result Write(s64 offset, const void *buffer, size_t size) override {
R_RETURN(m_integrity_storage.Write(offset, buffer, size));
}
virtual Result SetSize(s64 size) override { AMS_UNUSED(size); R_THROW(fs::ResultUnsupportedSetSizeForIntegrityRomFsStorage()); }
virtual Result GetSize(s64 *out) override {
R_RETURN(m_integrity_storage.GetSize(out));
}
virtual Result Flush() override {
R_RETURN(m_integrity_storage.Flush());
}
virtual Result OperateRange(void *dst, size_t dst_size, fs::OperationId op_id, s64 offset, s64 size, const void *src, size_t src_size) override {
R_RETURN(m_integrity_storage.OperateRange(dst, dst_size, op_id, offset, size, src, src_size));
}
Result Commit() {
R_RETURN(m_integrity_storage.Commit());
}
FileSystemBufferManagerSet *GetBuffers() {
return m_integrity_storage.GetBuffers();
}
};
}
| 3,305
|
C++
|
.h
| 62
| 44.822581
| 325
| 0.681945
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,510
|
fssystem_file_system_proxy_api.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_file_system_proxy_api.hpp
|
/*
* 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::fssrv::fscreator {
struct FileSystemCreatorInterfaces;
}
namespace ams::fssystem {
/* TODO: This is kind of really a fs process function/tied into fs main. */
/* This should be re-examined when FS is reimplemented. */
void InitializeForFileSystemProxy();
void InitializeForAtmosphereMitm();
const ::ams::fssrv::fscreator::FileSystemCreatorInterfaces *GetFileSystemCreatorInterfaces();
}
| 1,105
|
C++
|
.h
| 27
| 38.222222
| 97
| 0.760748
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,511
|
fssystem_alignment_matching_storage_impl.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_alignment_matching_storage_impl.hpp
|
/*
* 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>
#include <stratosphere/fs/fs_istorage.hpp>
namespace ams::fssystem {
/* ACCURATE_TO_VERSION: Unknown */
class AlignmentMatchingStorageImpl {
public:
static Result Read(fs::IStorage *base_storage, char *work_buf, size_t work_buf_size, size_t data_alignment, size_t buffer_alignment, s64 offset, char *buffer, size_t size);
static Result Write(fs::IStorage *base_storage, char *work_buf, size_t work_buf_size, size_t data_alignment, size_t buffer_alignment, s64 offset, const char *buffer, size_t size);
static Result Read(std::shared_ptr<fs::IStorage> &base_storage, char *work_buf, size_t work_buf_size, size_t data_alignment, size_t buffer_alignment, s64 offset, char *buffer, size_t size) {
R_RETURN(Read(base_storage.get(), work_buf, work_buf_size, data_alignment, buffer_alignment, offset, buffer, size));
}
static Result Write(std::shared_ptr<fs::IStorage> &base_storage, char *work_buf, size_t work_buf_size, size_t data_alignment, size_t buffer_alignment, s64 offset, const char *buffer, size_t size) {
R_RETURN(Write(base_storage.get(), work_buf, work_buf_size, data_alignment, buffer_alignment, offset, buffer, size));
}
};
}
| 1,935
|
C++
|
.h
| 32
| 55
| 209
| 0.708114
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,512
|
fssystem_asynchronous_access.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_asynchronous_access.hpp
|
/*
* 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 {
/* ACCURATE_TO_VERSION: 13.4.0.0 */
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) { AMS_UNUSED(out, start_offset, end_offset, access_size, alignment_size); AMS_ABORT("TODO"); }
};
/* ACCURATE_TO_VERSION: 13.4.0.0 */
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);
R_SUCCEED();
}
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);
R_SUCCEED();
}
};
/* ACCURATE_TO_VERSION: 13.4.0.0 */
inline IAsynchronousAccessSplitter *IAsynchronousAccessSplitter::GetDefaultAsynchronousAccessSplitter() {
static constinit DefaultAsynchronousAccessSplitter s_default_access_splitter;
return std::addressof(s_default_access_splitter);
}
}
| 2,704
|
C++
|
.h
| 53
| 43.45283
| 223
| 0.688469
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,513
|
fssystem_nca_header.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_nca_header.hpp
|
/*
* 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>
#include <stratosphere/fssystem/fssystem_i_hash_256_generator.hpp>
namespace ams::fssystem {
/* ACCURATE_TO_VERSION: 14.3.0.0 */
struct Hash {
static constexpr size_t Size = IHash256Generator::HashSize;
u8 value[Size];
};
static_assert(sizeof(Hash) == Hash::Size);
static_assert(util::is_pod<Hash>::value);
using NcaDigest = Hash;
struct NcaHeader {
enum class ContentType : u8 {
Program = 0,
Meta = 1,
Control = 2,
Manual = 3,
Data = 4,
PublicData = 5,
Start = Program,
End = PublicData,
};
enum class DistributionType : u8 {
Download = 0,
GameCard = 1,
Start = Download,
End = GameCard,
};
enum class EncryptionType : u8 {
Auto = 0,
None = 1,
};
enum DecryptionKey {
DecryptionKey_AesXts = 0,
DecryptionKey_AesXts1 = DecryptionKey_AesXts,
DecryptionKey_AesXts2 = 1,
DecryptionKey_AesCtr = 2,
DecryptionKey_AesCtrEx = 3,
DecryptionKey_AesCtrHw = 4,
DecryptionKey_Count,
};
struct FsInfo {
u32 start_sector;
u32 end_sector;
u32 hash_sectors;
u32 reserved;
};
static_assert(sizeof(FsInfo) == 0x10);
static_assert(util::is_pod<FsInfo>::value);
static constexpr u32 Magic0 = util::FourCC<'N','C','A','0'>::Code;
static constexpr u32 Magic1 = util::FourCC<'N','C','A','1'>::Code;
static constexpr u32 Magic2 = util::FourCC<'N','C','A','2'>::Code;
static constexpr u32 Magic3 = util::FourCC<'N','C','A','3'>::Code;
static constexpr u32 Magic = Magic3;
static constexpr size_t Size = 1_KB;
static constexpr s32 FsCountMax = 4;
static constexpr size_t HeaderSignCount = 2;
static constexpr size_t HeaderSignSize = 0x100;
static constexpr size_t EncryptedKeyAreaSize = 0x100;
static constexpr size_t SectorSize = 0x200;
static constexpr size_t SectorShift = 9;
static constexpr size_t RightsIdSize = 0x10;
static constexpr size_t XtsBlockSize = 0x200;
static constexpr size_t CtrBlockSize = 0x10;
static_assert(SectorSize == (1 << SectorShift));
/* Data members. */
u8 header_sign_1[HeaderSignSize];
u8 header_sign_2[HeaderSignSize];
u32 magic;
DistributionType distribution_type;
ContentType content_type;
u8 key_generation;
u8 key_index;
u64 content_size;
u64 program_id;
u32 content_index;
u32 sdk_addon_version;
u8 key_generation_2;
u8 header1_signature_key_generation;
u8 reserved_222[2];
u32 reserved_224[3];
u8 rights_id[RightsIdSize];
FsInfo fs_info[FsCountMax];
Hash fs_header_hash[FsCountMax];
u8 encrypted_key_area[EncryptedKeyAreaSize];
static constexpr u64 SectorToByte(u32 sector) {
return static_cast<u64>(sector) << SectorShift;
}
static constexpr u32 ByteToSector(u64 byte) {
return static_cast<u32>(byte >> SectorShift);
}
u8 GetProperKeyGeneration() const;
};
static_assert(sizeof(NcaHeader) == NcaHeader::Size);
static_assert(util::is_pod<NcaHeader>::value);
struct NcaBucketInfo {
static constexpr size_t HeaderSize = 0x10;
fs::Int64 offset;
fs::Int64 size;
u8 header[HeaderSize];
};
static_assert(util::is_pod<NcaBucketInfo>::value);
struct NcaPatchInfo {
static constexpr size_t Size = 0x40;
static constexpr size_t Offset = 0x100;
fs::Int64 indirect_offset;
fs::Int64 indirect_size;
u8 indirect_header[NcaBucketInfo::HeaderSize];
fs::Int64 aes_ctr_ex_offset;
fs::Int64 aes_ctr_ex_size;
u8 aes_ctr_ex_header[NcaBucketInfo::HeaderSize];
bool HasIndirectTable() const;
bool HasAesCtrExTable() const;
};
static_assert(util::is_pod<NcaPatchInfo>::value);
union NcaAesCtrUpperIv {
u64 value;
struct {
u32 generation;
u32 secure_value;
} part;
};
static_assert(util::is_pod<NcaAesCtrUpperIv>::value);
struct NcaSparseInfo {
NcaBucketInfo bucket;
fs::Int64 physical_offset;
u16 generation;
u8 reserved[6];
s64 GetPhysicalSize() const {
return this->bucket.offset + this->bucket.size;
}
u32 GetGeneration() const {
return static_cast<u32>(this->generation) << 16;
}
const NcaAesCtrUpperIv MakeAesCtrUpperIv(NcaAesCtrUpperIv upper_iv) const {
NcaAesCtrUpperIv sparse_upper_iv = upper_iv;
sparse_upper_iv.part.generation = this->GetGeneration();
return sparse_upper_iv;
}
};
static_assert(util::is_pod<NcaSparseInfo>::value);
struct NcaCompressionInfo {
NcaBucketInfo bucket;
u8 reserved[8];
};
static_assert(util::is_pod<NcaCompressionInfo>::value);
struct NcaMetaDataHashDataInfo {
fs::Int64 offset;
fs::Int64 size;
Hash hash;
};
static_assert(util::is_pod<NcaMetaDataHashDataInfo>::value);
struct NcaFsHeader {
static constexpr size_t Size = 0x200;
static constexpr size_t HashDataOffset = 0x8;
struct Region {
fs::Int64 offset;
fs::Int64 size;
};
static_assert(util::is_pod<Region>::value);
enum class FsType : u8 {
RomFs = 0,
PartitionFs = 1,
};
enum class EncryptionType : u8 {
Auto = 0,
None = 1,
AesXts = 2,
AesCtr = 3,
AesCtrEx = 4,
AesCtrSkipLayerHash = 5,
AesCtrExSkipLayerHash = 6,
};
enum class HashType : u8 {
Auto = 0,
None = 1,
HierarchicalSha256Hash = 2,
HierarchicalIntegrityHash = 3,
AutoSha3 = 4,
HierarchicalSha3256Hash = 5,
HierarchicalIntegritySha3Hash = 6,
};
enum class MetaDataHashType : u8 {
None = 0,
HierarchicalIntegrity = 1,
};
union HashData {
struct HierarchicalSha256Data {
static constexpr size_t HashLayerCountMax = 5;
static const size_t MasterHashOffset;
Hash fs_data_master_hash;
s32 hash_block_size;
s32 hash_layer_count;
Region hash_layer_region[HashLayerCountMax];
} hierarchical_sha256_data;
static_assert(util::is_pod<HierarchicalSha256Data>::value);
struct IntegrityMetaInfo {
static const size_t MasterHashOffset;
u32 magic;
u32 version;
u32 master_hash_size;
struct LevelHashInfo {
u32 max_layers;
struct HierarchicalIntegrityVerificationLevelInformation {
static constexpr size_t IntegrityMaxLayerCount = 7;
fs::Int64 offset;
fs::Int64 size;
s32 block_order;
u8 reserved[4];
} info[HierarchicalIntegrityVerificationLevelInformation::IntegrityMaxLayerCount - 1];
struct SignatureSalt {
static constexpr size_t Size = 0x20;
u8 value[Size];
} seed;
} level_hash_info;
Hash master_hash;
} integrity_meta_info;
static_assert(util::is_pod<IntegrityMetaInfo>::value);
u8 padding[NcaPatchInfo::Offset - HashDataOffset];
};
u16 version;
FsType fs_type;
HashType hash_type;
EncryptionType encryption_type;
MetaDataHashType meta_data_hash_type;
u8 reserved[2];
HashData hash_data;
NcaPatchInfo patch_info;
NcaAesCtrUpperIv aes_ctr_upper_iv;
NcaSparseInfo sparse_info;
NcaCompressionInfo compression_info;
NcaMetaDataHashDataInfo meta_data_hash_data_info;
u8 pad[0x30];
bool IsSkipLayerHashEncryption() const {
return this->encryption_type == EncryptionType::AesCtrSkipLayerHash || this->encryption_type == EncryptionType::AesCtrExSkipLayerHash;
}
Result GetHashTargetOffset(s64 *out) const {
switch (this->hash_type) {
case HashType::HierarchicalIntegrityHash:
case HashType::HierarchicalIntegritySha3Hash:
*out = this->hash_data.integrity_meta_info.level_hash_info.info[this->hash_data.integrity_meta_info.level_hash_info.max_layers - 2].offset;
R_SUCCEED();
case HashType::HierarchicalSha256Hash:
case HashType::HierarchicalSha3256Hash:
*out = this->hash_data.hierarchical_sha256_data.hash_layer_region[this->hash_data.hierarchical_sha256_data.hash_layer_count - 1].offset;
R_SUCCEED();
default:
R_THROW(fs::ResultInvalidNcaFsHeader());
}
}
};
static_assert(sizeof(NcaFsHeader) == NcaFsHeader::Size);
static_assert(util::is_pod<NcaFsHeader>::value);
static_assert(AMS_OFFSETOF(NcaFsHeader, patch_info) == NcaPatchInfo::Offset);
inline constexpr const size_t NcaFsHeader::HashData::HierarchicalSha256Data::MasterHashOffset = AMS_OFFSETOF(NcaFsHeader, hash_data.hierarchical_sha256_data.fs_data_master_hash);
inline constexpr const size_t NcaFsHeader::HashData::IntegrityMetaInfo::MasterHashOffset = AMS_OFFSETOF(NcaFsHeader, hash_data.integrity_meta_info.master_hash);
struct NcaMetaDataHashData {
s64 layer_info_offset;
NcaFsHeader::HashData::IntegrityMetaInfo integrity_meta_info;
};
static_assert(sizeof(NcaMetaDataHashData) == sizeof(NcaFsHeader::HashData::IntegrityMetaInfo) + sizeof(s64));
static_assert(util::is_pod<NcaMetaDataHashData>::value);
}
| 11,527
|
C++
|
.h
| 279
| 30.949821
| 182
| 0.579977
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,514
|
fssystem_indirect_storage.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_indirect_storage.hpp
|
/*
* 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>
#include <stratosphere/fssystem/fssystem_bucket_tree.hpp>
namespace ams::fssystem {
/* ACCURATE_TO_VERSION: Unknown */
class IndirectStorage : public ::ams::fs::IStorage, public ::ams::fs::impl::Newable {
NON_COPYABLE(IndirectStorage);
NON_MOVEABLE(IndirectStorage);
public:
static constexpr s32 StorageCount = 2;
static constexpr size_t NodeSize = 16_KB;
using IAllocator = MemoryResource;
struct Entry {
u8 virt_offset[sizeof(s64)];
u8 phys_offset[sizeof(s64)];
s32 storage_index;
void SetVirtualOffset(const s64 &ofs) {
std::memcpy(this->virt_offset, std::addressof(ofs), sizeof(s64));
}
s64 GetVirtualOffset() const {
s64 offset;
std::memcpy(std::addressof(offset), this->virt_offset, sizeof(s64));
return offset;
}
void SetPhysicalOffset(const s64 &ofs) {
std::memcpy(this->phys_offset, std::addressof(ofs), sizeof(s64));
}
s64 GetPhysicalOffset() const {
s64 offset;
std::memcpy(std::addressof(offset), this->phys_offset, sizeof(s64));
return offset;
}
};
static_assert(util::is_pod<Entry>::value);
static_assert(sizeof(Entry) == 0x14);
struct EntryData {
s64 virt_offset;
s64 phys_offset;
s32 storage_index;
void Set(const Entry &entry) {
this->virt_offset = entry.GetVirtualOffset();
this->phys_offset = entry.GetPhysicalOffset();
this->storage_index = entry.storage_index;
}
};
static_assert(util::is_pod<EntryData>::value);
private:
struct ContinuousReadingEntry {
static constexpr size_t FragmentSizeMax = 4_KB;
IndirectStorage::Entry entry;
s64 GetVirtualOffset() const {
return this->entry.GetVirtualOffset();
}
s64 GetPhysicalOffset() const {
return this->entry.GetPhysicalOffset();
}
bool IsFragment() const {
return this->entry.storage_index != 0;
}
};
static_assert(util::is_pod<ContinuousReadingEntry>::value);
public:
static constexpr s64 QueryHeaderStorageSize() {
return BucketTree::QueryHeaderStorageSize();
}
static constexpr s64 QueryNodeStorageSize(s32 entry_count) {
return BucketTree::QueryNodeStorageSize(NodeSize, sizeof(Entry), entry_count);
}
static constexpr s64 QueryEntryStorageSize(s32 entry_count) {
return BucketTree::QueryEntryStorageSize(NodeSize, sizeof(Entry), entry_count);
}
private:
BucketTree m_table;
fs::SubStorage m_data_storage[StorageCount];
public:
IndirectStorage() : m_table(), m_data_storage() { /* ... */ }
virtual ~IndirectStorage() { this->Finalize(); }
Result Initialize(IAllocator *allocator, fs::SubStorage table_storage);
void Finalize();
bool IsInitialized() const { return m_table.IsInitialized(); }
Result Initialize(IAllocator *allocator, fs::SubStorage node_storage, fs::SubStorage entry_storage, s32 entry_count) {
R_RETURN(m_table.Initialize(allocator, node_storage, entry_storage, NodeSize, sizeof(Entry), entry_count));
}
void SetStorage(s32 idx, fs::SubStorage storage) {
AMS_ASSERT(0 <= idx && idx < StorageCount);
m_data_storage[idx] = storage;
}
template<typename T>
void SetStorage(s32 idx, T storage, s64 offset, s64 size) {
AMS_ASSERT(0 <= idx && idx < StorageCount);
m_data_storage[idx] = fs::SubStorage(storage, offset, size);
}
Result GetEntryList(Entry *out_entries, s32 *out_entry_count, s32 entry_count, s64 offset, s64 size);
virtual Result Read(s64 offset, void *buffer, size_t size) override;
virtual Result OperateRange(void *dst, size_t dst_size, fs::OperationId op_id, s64 offset, s64 size, const void *src, size_t src_size) override;
virtual Result GetSize(s64 *out) override {
AMS_ASSERT(out != nullptr);
BucketTree::Offsets offsets;
R_TRY(m_table.GetOffsets(std::addressof(offsets)));
*out = offsets.end_offset;
R_SUCCEED();
}
virtual Result Flush() override {
R_SUCCEED();
}
virtual Result Write(s64 offset, const void *buffer, size_t size) override {
AMS_UNUSED(offset, buffer, size);
R_THROW(fs::ResultUnsupportedWriteForIndirectStorage());
}
virtual Result SetSize(s64 size) override {
AMS_UNUSED(size);
R_THROW(fs::ResultUnsupportedSetSizeForIndirectStorage());
}
protected:
BucketTree &GetEntryTable() { return m_table; }
fs::SubStorage &GetDataStorage(s32 index) {
AMS_ASSERT(0 <= index && index < StorageCount);
return m_data_storage[index];
}
template<bool ContinuousCheck, bool RangeCheck, typename F>
Result OperatePerEntry(s64 offset, s64 size, F func);
};
}
| 6,518
|
C++
|
.h
| 138
| 33.956522
| 156
| 0.572779
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,515
|
fssystem_integrity_verification_storage.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_integrity_verification_storage.hpp
|
/*
* 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>
#include <stratosphere/os.hpp>
#include <stratosphere/fs/fs_istorage.hpp>
#include <stratosphere/fs/fs_substorage.hpp>
#include <stratosphere/fs/fs_storage_type.hpp>
#include <stratosphere/fssystem/fssystem_block_cache_buffered_storage.hpp>
namespace ams::fssystem {
/* ACCURATE_TO_VERSION: 14.3.0.0 */
class IntegrityVerificationStorage : public ::ams::fs::IStorage {
NON_COPYABLE(IntegrityVerificationStorage);
NON_MOVEABLE(IntegrityVerificationStorage);
public:
static constexpr s64 HashSize = crypto::Sha256Generator::HashSize;
struct BlockHash {
u8 hash[HashSize];
};
static_assert(util::is_pod<BlockHash>::value);
private:
fs::SubStorage m_hash_storage;
fs::SubStorage m_data_storage;
s64 m_verification_block_size;
s64 m_verification_block_order;
s64 m_upper_layer_verification_block_size;
s64 m_upper_layer_verification_block_order;
fs::IBufferManager *m_buffer_manager;
util::optional<fs::HashSalt> m_salt;
bool m_is_real_data;
fssystem::IHash256GeneratorFactory *m_hash_generator_factory;
bool m_is_writable;
bool m_allow_cleared_blocks;
public:
IntegrityVerificationStorage() : m_verification_block_size(0), m_verification_block_order(0), m_upper_layer_verification_block_size(0), m_upper_layer_verification_block_order(0), m_buffer_manager(nullptr), m_salt(util::nullopt) { /* ... */ }
virtual ~IntegrityVerificationStorage() override { this->Finalize(); }
void Initialize(fs::SubStorage hs, fs::SubStorage ds, s64 verif_block_size, s64 upper_layer_verif_block_size, fs::IBufferManager *bm, fssystem::IHash256GeneratorFactory *hgf, const util::optional<fs::HashSalt> &salt, bool is_real_data, bool is_writable, bool allow_cleared_blocks);
void Finalize();
virtual Result Read(s64 offset, void *buffer, size_t size) override;
virtual Result Write(s64 offset, const void *buffer, size_t size) override;
virtual Result SetSize(s64 size) override { AMS_UNUSED(size); R_THROW(fs::ResultUnsupportedSetSizeForIntegrityVerificationStorage()); }
virtual Result GetSize(s64 *out) override;
virtual Result Flush() override;
virtual Result OperateRange(void *dst, size_t dst_size, fs::OperationId op_id, s64 offset, s64 size, const void *src, size_t src_size) override;
using IStorage::OperateRange;
void CalcBlockHash(BlockHash *out, const void *buffer, std::unique_ptr<fssystem::IHash256Generator> &generator) const {
return this->CalcBlockHash(out, buffer, static_cast<size_t>(m_verification_block_size), generator);
}
s64 GetBlockSize() const {
return m_verification_block_size;
}
private:
Result ReadBlockSignature(void *dst, size_t dst_size, s64 offset, size_t size);
Result WriteBlockSignature(const void *src, size_t src_size, s64 offset, size_t size);
Result VerifyHash(const void *buf, BlockHash *hash, std::unique_ptr<fssystem::IHash256Generator> &generator);
void CalcBlockHash(BlockHash *out, const void *buffer, size_t block_size, std::unique_ptr<fssystem::IHash256Generator> &generator) const;
Result IsCleared(bool *is_cleared, const BlockHash &hash);
private:
static void SetValidationBit(BlockHash *hash) {
AMS_ASSERT(hash != nullptr);
hash->hash[HashSize - 1] |= 0x80;
}
static bool IsValidationBit(const BlockHash *hash) {
AMS_ASSERT(hash != nullptr);
return (hash->hash[HashSize - 1] & 0x80) != 0;
}
};
}
| 4,576
|
C++
|
.h
| 81
| 46.987654
| 293
| 0.667857
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,516
|
fssystem_aes_ctr_counter_extended_storage.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_aes_ctr_counter_extended_storage.hpp
|
/*
* 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>
#include <stratosphere/fssystem/fssystem_aes_ctr_storage.hpp>
#include <stratosphere/fssystem/fssystem_bucket_tree.hpp>
namespace ams::fssystem {
/* ACCURATE_TO_VERSION: Unknown */
class AesCtrCounterExtendedStorage : public ::ams::fs::IStorage, public ::ams::fs::impl::Newable {
NON_COPYABLE(AesCtrCounterExtendedStorage);
NON_MOVEABLE(AesCtrCounterExtendedStorage);
public:
static constexpr size_t BlockSize = crypto::Aes128CtrEncryptor::BlockSize;
static constexpr size_t KeySize = crypto::Aes128CtrEncryptor::KeySize;
static constexpr size_t IvSize = crypto::Aes128CtrEncryptor::IvSize;
static constexpr size_t NodeSize = 16_KB;
using IAllocator = BucketTree::IAllocator;
using DecryptFunction = void(*)(void *dst, size_t dst_size, u8 index, u8 gen, const void *enc_key, size_t enc_key_size, const void *iv, size_t iv_size, const void *src, size_t src_size);
class IDecryptor {
public:
virtual ~IDecryptor() { /* ... */ }
virtual void Decrypt(void *buf, size_t buf_size, const void *enc_key, size_t enc_key_size, void *iv, size_t iv_size) = 0;
virtual bool HasExternalDecryptionKey() const = 0;
};
struct Entry {
enum class Encryption : u8 {
Encrypted = 0,
NotEncrypted = 1,
};
u8 offset[sizeof(s64)];
Encryption encryption_value;
u8 reserved[3];
s32 generation;
void SetOffset(s64 value) {
std::memcpy(this->offset, std::addressof(value), sizeof(s64));
}
s64 GetOffset() const {
s64 value;
std::memcpy(std::addressof(value), this->offset, sizeof(s64));
return value;
}
};
static_assert(sizeof(Entry) == 0x10);
static_assert(alignof(Entry) == 4);
static_assert(util::is_pod<Entry>::value);
public:
static constexpr s64 QueryHeaderStorageSize() {
return BucketTree::QueryHeaderStorageSize();
}
static constexpr s64 QueryNodeStorageSize(s32 entry_count) {
return BucketTree::QueryNodeStorageSize(NodeSize, sizeof(Entry), entry_count);
}
static constexpr s64 QueryEntryStorageSize(s32 entry_count) {
return BucketTree::QueryEntryStorageSize(NodeSize, sizeof(Entry), entry_count);
}
static Result CreateExternalDecryptor(std::unique_ptr<IDecryptor> *out, DecryptFunction func, s32 key_index, s32 key_generation);
static Result CreateSoftwareDecryptor(std::unique_ptr<IDecryptor> *out);
private:
BucketTree m_table;
fs::SubStorage m_data_storage;
u8 m_key[KeySize];
u32 m_secure_value;
s64 m_counter_offset;
std::unique_ptr<IDecryptor> m_decryptor;
public:
AesCtrCounterExtendedStorage() : m_table(), m_data_storage(), m_secure_value(), m_counter_offset(), m_decryptor() { /* ... */ }
virtual ~AesCtrCounterExtendedStorage() { this->Finalize(); }
Result Initialize(IAllocator *allocator, const void *key, size_t key_size, u32 secure_value, s64 counter_offset, fs::SubStorage data_storage, fs::SubStorage node_storage, fs::SubStorage entry_storage, s32 entry_count, std::unique_ptr<IDecryptor> &&decryptor);
void Finalize();
bool IsInitialized() const { return m_table.IsInitialized(); }
virtual Result Read(s64 offset, void *buffer, size_t size) override;
virtual Result OperateRange(void *dst, size_t dst_size, fs::OperationId op_id, s64 offset, s64 size, const void *src, size_t src_size) override;
virtual Result GetSize(s64 *out) override {
AMS_ASSERT(out != nullptr);
BucketTree::Offsets offsets;
R_TRY(m_table.GetOffsets(std::addressof(offsets)));
*out = offsets.end_offset;
R_SUCCEED();
}
virtual Result Flush() override {
R_SUCCEED();
}
virtual Result Write(s64 offset, const void *buffer, size_t size) override {
AMS_UNUSED(offset, buffer, size);
R_THROW(fs::ResultUnsupportedWriteForAesCtrCounterExtendedStorage());
}
virtual Result SetSize(s64 size) override {
AMS_UNUSED(size);
R_THROW(fs::ResultUnsupportedSetSizeForAesCtrCounterExtendedStorage());
}
Result GetEntryList(Entry *out_entries, s32 *out_entry_count, s32 entry_count, s64 offset, s64 size);
private:
Result Initialize(IAllocator *allocator, const void *key, size_t key_size, u32 secure_value, fs::SubStorage data_storage, fs::SubStorage table_storage);
};
}
| 5,797
|
C++
|
.h
| 108
| 41.583333
| 271
| 0.61624
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,517
|
fssystem_partition_file_system.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_partition_file_system.hpp
|
/*
* 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 <stratosphere/fssystem/fssystem_partition_file_system_meta.hpp>
#include <stratosphere/fs/fsa/fs_ifile.hpp>
#include <stratosphere/fs/fsa/fs_idirectory.hpp>
#include <stratosphere/fs/fsa/fs_ifilesystem.hpp>
namespace ams::fssystem {
/* ACCURATE_TO_VERSION: Unknown */
template<typename MetaType>
class PartitionFileSystemCore : public fs::impl::Newable, public fs::fsa::IFileSystem {
NON_COPYABLE(PartitionFileSystemCore);
NON_MOVEABLE(PartitionFileSystemCore);
private:
class PartitionFile;
class PartitionDirectory;
private:
fs::IStorage *m_base_storage;
MetaType *m_meta_data;
bool m_initialized;
size_t m_meta_data_size;
std::unique_ptr<MetaType> m_unique_meta_data;
std::shared_ptr<fs::IStorage> m_shared_storage;
private:
Result Initialize(fs::IStorage *base_storage, MemoryResource *allocator);
public:
PartitionFileSystemCore();
virtual ~PartitionFileSystemCore() override;
Result Initialize(std::unique_ptr<MetaType> &&meta_data, std::shared_ptr<fs::IStorage> base_storage);
Result Initialize(MetaType *meta_data, std::shared_ptr<fs::IStorage> base_storage);
Result Initialize(fs::IStorage *base_storage);
Result Initialize(std::shared_ptr<fs::IStorage> base_storage);
Result Initialize(std::shared_ptr<fs::IStorage> base_storage, MemoryResource *allocator);
Result GetFileBaseOffset(s64 *out_offset, const char *path);
virtual Result DoCreateFile(const fs::Path &path, s64 size, int option) override;
virtual Result DoDeleteFile(const fs::Path &path) override;
virtual Result DoCreateDirectory(const fs::Path &path) override;
virtual Result DoDeleteDirectory(const fs::Path &path) override;
virtual Result DoDeleteDirectoryRecursively(const fs::Path &path) override;
virtual Result DoRenameFile(const fs::Path &old_path, const fs::Path &new_path) override;
virtual Result DoRenameDirectory(const fs::Path &old_path, const fs::Path &new_path) override;
virtual Result DoGetEntryType(fs::DirectoryEntryType *out, const fs::Path &path) override;
virtual Result DoOpenFile(std::unique_ptr<fs::fsa::IFile> *out_file, const fs::Path &path, fs::OpenMode mode) override;
virtual Result DoOpenDirectory(std::unique_ptr<fs::fsa::IDirectory> *out_dir, const fs::Path &path, fs::OpenDirectoryMode mode) override;
virtual Result DoCommit() override;
virtual Result DoCleanDirectoryRecursively(const fs::Path &path) override;
/* These aren't accessible as commands. */
virtual Result DoCommitProvisionally(s64 counter) override;
};
using PartitionFileSystem = PartitionFileSystemCore<PartitionFileSystemMeta>;
using Sha256PartitionFileSystem = PartitionFileSystemCore<Sha256PartitionFileSystemMeta>;
}
| 3,714
|
C++
|
.h
| 65
| 48.953846
| 149
| 0.703022
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,518
|
fssystem_i_hash_256_generator.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_i_hash_256_generator.hpp
|
/*
* 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 {
enum HashAlgorithmType : u8 {
HashAlgorithmType_Sha2 = 0,
HashAlgorithmType_Sha3 = 1,
};
/* ACCURATE_TO_VERSION: 14.3.0.0 */
class IHash256Generator {
public:
static constexpr size_t HashSize = 256 / BITSIZEOF(u8);
public:
constexpr IHash256Generator() = default;
virtual constexpr ~IHash256Generator() { /* ... */ }
public:
void Initialize() {
return this->DoInitialize();
}
void Update(const void *data, size_t size) {
/* Check pre-conditions. */
AMS_ASSERT(data != nullptr);
return this->DoUpdate(data, size);
}
void GetHash(void *dst, size_t dst_size) {
/* Check pre-conditions. */
AMS_ASSERT(dst_size == HashSize);
return this->DoGetHash(dst, dst_size);
}
protected:
virtual void DoInitialize() = 0;
virtual void DoUpdate(const void *data, size_t size) = 0;
virtual void DoGetHash(void *dst, size_t dst_size) = 0;
};
/* ACCURATE_TO_VERSION: 14.3.0.0 */
class IHash256GeneratorFactory {
public:
constexpr IHash256GeneratorFactory() = default;
virtual constexpr ~IHash256GeneratorFactory() { /* ... */ }
Result Create(std::unique_ptr<IHash256Generator> *out) {
return this->DoCreate(out);
}
void GenerateHash(void *dst, size_t dst_size, const void *src, size_t src_size) {
/* Check pre-conditions. */
AMS_ASSERT(dst != nullptr);
AMS_ASSERT(src != nullptr);
AMS_ASSERT(dst_size == IHash256Generator::HashSize);
return this->DoGenerateHash(dst, dst_size, src, src_size);
}
protected:
virtual Result DoCreate(std::unique_ptr<IHash256Generator> *out) = 0;
virtual void DoGenerateHash(void *dst, size_t dst_size, const void *src, size_t src_size) = 0;
};
/* ACCURATE_TO_VERSION: 14.3.0.0 */
class IHash256GeneratorFactorySelector {
public:
constexpr IHash256GeneratorFactorySelector() = default;
virtual constexpr ~IHash256GeneratorFactorySelector() { /* ... */ }
IHash256GeneratorFactory *GetFactory(HashAlgorithmType alg) { return this->DoGetFactory(alg); }
protected:
virtual IHash256GeneratorFactory *DoGetFactory(HashAlgorithmType alg) = 0;
};
}
| 3,280
|
C++
|
.h
| 77
| 33.181818
| 107
| 0.61085
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,519
|
fssystem_utility.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_utility.hpp
|
/*
* 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 <stratosphere/fs/fs_common.hpp>
#include <stratosphere/fs/fs_file.hpp>
#include <stratosphere/fs/fs_directory.hpp>
#include <stratosphere/fs/fs_filesystem.hpp>
#include <stratosphere/fs/fs_path.hpp>
namespace ams::fssystem {
/* ACCURATE_TO_VERSION: 13.4.0.0 */
namespace impl {
template<typename F>
concept IterateDirectoryHandler = requires (F f, const fs::Path &path, const fs::DirectoryEntry &entry) {
{ f(path, entry) } -> std::convertible_to<::ams::Result>;
};
/* Iteration. */
template<IterateDirectoryHandler OnEnterDir, IterateDirectoryHandler OnExitDir, IterateDirectoryHandler OnFile>
Result IterateDirectoryRecursivelyImpl(fs::fsa::IFileSystem *fs, fs::Path &work_path, fs::DirectoryEntry *dir_ent, OnEnterDir on_enter_dir, OnExitDir on_exit_dir, OnFile on_file) {
/* Open the directory. */
std::unique_ptr<fs::fsa::IDirectory> dir;
R_TRY(fs->OpenDirectory(std::addressof(dir), work_path, fs::OpenDirectoryMode_All));
/* Read and handle entries. */
while (true) {
/* Read a single entry. */
s64 read_count = 0;
R_TRY(dir->Read(std::addressof(read_count), dir_ent, 1));
/* If we're out of entries, we're done. */
if (read_count == 0) {
break;
}
/* Append child path. */
R_TRY(work_path.AppendChild(dir_ent->name));
{
if (dir_ent->type == fs::DirectoryEntryType_Directory) {
/* Enter directory. */
R_TRY(on_enter_dir(work_path, *dir_ent));
/* Recurse. */
R_TRY(IterateDirectoryRecursivelyImpl(fs, work_path, dir_ent, on_enter_dir, on_exit_dir, on_file));
/* Exit directory. */
R_TRY(on_exit_dir(work_path, *dir_ent));
} else {
/* Call file handler. */
R_TRY(on_file(work_path, *dir_ent));
}
}
R_TRY(work_path.RemoveChild());
}
R_SUCCEED();
}
/* TODO: Cleanup. */
}
/* Iteration API */
template<impl::IterateDirectoryHandler OnEnterDir, impl::IterateDirectoryHandler OnExitDir, impl::IterateDirectoryHandler OnFile>
Result IterateDirectoryRecursively(fs::fsa::IFileSystem *fs, const fs::Path &root_path, fs::DirectoryEntry *dir_ent_buf, OnEnterDir on_enter_dir, OnExitDir on_exit_dir, OnFile on_file) {
/* Create work path from the root path. */
fs::Path work_path;
R_TRY(work_path.Initialize(root_path));
R_RETURN(impl::IterateDirectoryRecursivelyImpl(fs, work_path, dir_ent_buf, on_enter_dir, on_exit_dir, on_file));
}
template<impl::IterateDirectoryHandler OnEnterDir, impl::IterateDirectoryHandler OnExitDir, impl::IterateDirectoryHandler OnFile>
Result IterateDirectoryRecursively(fs::fsa::IFileSystem *fs, const fs::Path &root_path, OnEnterDir on_enter_dir, OnExitDir on_exit_dir, OnFile on_file) {
fs::DirectoryEntry dir_entry = {};
R_RETURN(IterateDirectoryRecursively(fs, root_path, std::addressof(dir_entry), on_enter_dir, on_exit_dir, on_file));
}
template<impl::IterateDirectoryHandler OnEnterDir, impl::IterateDirectoryHandler OnExitDir, impl::IterateDirectoryHandler OnFile>
Result IterateDirectoryRecursively(fs::fsa::IFileSystem *fs, OnEnterDir on_enter_dir, OnExitDir on_exit_dir, OnFile on_file) {
R_RETURN(IterateDirectoryRecursively(fs, fs::MakeConstantPath("/"), on_enter_dir, on_exit_dir, on_file));
}
/* TODO: Cleanup API */
/* Copy API. */
Result CopyFile(fs::fsa::IFileSystem *dst_fs, fs::fsa::IFileSystem *src_fs, const fs::Path &dst_path, const fs::Path &src_path, void *work_buf, size_t work_buf_size);
ALWAYS_INLINE Result CopyFile(fs::fsa::IFileSystem *fs, const fs::Path &dst_path, const fs::Path &src_path, void *work_buf, size_t work_buf_size) {
R_RETURN(CopyFile(fs, fs, dst_path, src_path, work_buf, work_buf_size));
}
Result CopyDirectoryRecursively(fs::fsa::IFileSystem *dst_fs, fs::fsa::IFileSystem *src_fs, const fs::Path &dst_path, const fs::Path &src_path, fs::DirectoryEntry *entry, void *work_buf, size_t work_buf_size);
ALWAYS_INLINE Result CopyDirectoryRecursively(fs::fsa::IFileSystem *fs, const fs::Path &dst_path, const fs::Path &src_path, fs::DirectoryEntry *entry, void *work_buf, size_t work_buf_size) {
R_RETURN(CopyDirectoryRecursively(fs, fs, dst_path, src_path, entry, work_buf, work_buf_size));
}
/* Locking utilities. */
class SemaphoreAdaptor : public os::Semaphore {
public:
SemaphoreAdaptor(int c, int mc) : os::Semaphore(c, mc) { /* ... */ }
bool TryLock(int *out_acquired, int count) {
AMS_ASSERT(count > 0);
for (auto i = 0; i < count; ++i) {
if (!this->TryAcquire()) {
*out_acquired = i;
return false;
}
}
*out_acquired = count;
return true;
}
void Unlock(int count) {
if (count > 0) {
this->Release(count);
}
}
bool try_lock() {
return this->TryAcquire();
}
void unlock() {
this->Release();
}
};
Result TryAcquireCountSemaphore(util::unique_lock<SemaphoreAdaptor> *out, SemaphoreAdaptor *adaptor);
class IUniqueLock {
NON_COPYABLE(IUniqueLock);
NON_MOVEABLE(IUniqueLock);
public:
virtual ~IUniqueLock() { /* ... */ }
};
template<typename T>
class UniqueLockWithPin final : public IUniqueLock, public ::ams::fs::impl::Newable {
private:
util::unique_lock<SemaphoreAdaptor> m_lock;
T m_pinned_object;
public:
UniqueLockWithPin(util::unique_lock<SemaphoreAdaptor> lock, T obj) : m_lock(std::move(lock)), m_pinned_object(std::move(obj)) { /* ... */ }
virtual ~UniqueLockWithPin() override {
m_lock = {};
}
};
template<typename T>
class MultiLockWithPin final : public IUniqueLock, public ::ams::fs::impl::Newable {
private:
T m_pinned_object;
SemaphoreAdaptor *m_semaphore_adaptor;
int m_lock_count;
public:
MultiLockWithPin(T obj, SemaphoreAdaptor *adaptor) : m_pinned_object(std::move(obj)), m_semaphore_adaptor(adaptor), m_lock_count(0) {
/* ... */
}
virtual ~MultiLockWithPin() override {
if (m_lock_count > 0) {
m_semaphore_adaptor->Unlock(m_lock_count);
}
}
Result Lock(int count) {
AMS_ASSERT(m_lock_count == 0);
R_UNLESS(m_semaphore_adaptor->TryLock(std::addressof(m_lock_count), count), fs::ResultOpenCountLimit());
R_SUCCEED();
}
};
template<typename T>
Result MakeUniqueLockWithPin(std::unique_ptr<IUniqueLock> *out, SemaphoreAdaptor *adaptor, T obj) {
/* Create the semaphore unique lock. */
util::unique_lock<SemaphoreAdaptor> sema_lock;
R_TRY(TryAcquireCountSemaphore(std::addressof(sema_lock), adaptor));
/* Create the output unique lock. */
auto result_lock = std::unique_ptr<UniqueLockWithPin<T>>(new UniqueLockWithPin<T>(std::move(sema_lock), std::move(obj)));
R_UNLESS(result_lock != nullptr, fs::ResultAllocationMemoryFailedNew());
/* Set the output. */
*out = std::move(result_lock);
R_SUCCEED();
}
template<typename T>
Result MakeUniqueLockWithPin(std::unique_ptr<IUniqueLock> *out, SemaphoreAdaptor *adaptor, int count, T obj) {
/* Create the output unique lock. */
auto result_lock = std::unique_ptr<MultiLockWithPin<T>>(new MultiLockWithPin<T>(std::move(obj), adaptor));
R_UNLESS(result_lock != nullptr, fs::ResultAllocationMemoryFailedNew());
/* Acquire the output lock. */
R_TRY(result_lock->Lock(count));
/* Set the output. */
*out = std::move(result_lock);
R_SUCCEED();
}
/* Other utility. */
Result HasFile(bool *out, fs::fsa::IFileSystem *fs, const fs::Path &path);
Result HasDirectory(bool *out, fs::fsa::IFileSystem *fs, const fs::Path &path);
Result EnsureDirectory(fs::fsa::IFileSystem *fs, const fs::Path &path);
template<s64 RetryMilliSeconds = 100, s32 MaxTryCount = 10>
ALWAYS_INLINE Result RetryFinitelyForTargetLocked(auto f) {
/* Retry sleeping between retries. */
constexpr TimeSpan RetryWaitTime = TimeSpan::FromMilliSeconds(RetryMilliSeconds);
Result result = f();
for (int i = 0; i < MaxTryCount && fs::ResultTargetLocked::Includes(result); ++i) {
os::SleepThread(RetryWaitTime);
result = f();
}
R_RETURN(result);
}
ALWAYS_INLINE Result RetryToAvoidTargetLocked(auto f) {
R_RETURN((RetryFinitelyForTargetLocked<2, 25>(f)));
}
void AddCounter(void *counter, size_t counter_size, u64 value);
}
| 10,144
|
C++
|
.h
| 200
| 40.25
| 213
| 0.610696
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,520
|
fssystem_bucket_tree_template_impl.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_bucket_tree_template_impl.hpp
|
/*
* 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 <stratosphere/fssystem/fssystem_pooled_buffer.hpp>
#include <stratosphere/fssystem/fssystem_bucket_tree.hpp>
#include <stratosphere/fssystem/fssystem_bucket_tree_utils.hpp>
namespace ams::fssystem {
/* ACCURATE_TO_VERSION: 13.4.0.0 */
template<typename EntryType>
Result BucketTree::ScanContinuousReading(ContinuousReadingInfo *out_info, const ContinuousReadingParam<EntryType> ¶m) const {
static_assert(util::is_pod<ContinuousReadingParam<EntryType>>::value);
/* Validate our preconditions. */
AMS_ASSERT(this->IsInitialized());
AMS_ASSERT(out_info != nullptr);
AMS_ASSERT(m_entry_size == sizeof(EntryType));
/* Reset the output. */
out_info->Reset();
/* If there's nothing to read, we're done. */
R_SUCCEED_IF(param.size == 0);
/* If we're reading a fragment, we're done. */
R_SUCCEED_IF(param.entry.IsFragment());
/* Validate the first entry. */
auto entry = param.entry;
auto cur_offset = param.offset;
R_UNLESS(entry.GetVirtualOffset() <= cur_offset, fs::ResultOutOfRange());
/* Create a pooled buffer for our scan. */
PooledBuffer pool(m_node_size, 1);
char *buffer = nullptr;
s64 entry_storage_size;
R_TRY(m_entry_storage.GetSize(std::addressof(entry_storage_size)));
/* Read the node. */
if (m_node_size <= pool.GetSize()) {
buffer = pool.GetBuffer();
const auto ofs = param.entry_set.index * static_cast<s64>(m_node_size);
R_UNLESS(m_node_size + ofs <= static_cast<size_t>(entry_storage_size), fs::ResultInvalidBucketTreeNodeEntryCount());
R_TRY(m_entry_storage.Read(ofs, buffer, m_node_size));
}
/* Calculate extents. */
const auto end_offset = cur_offset + static_cast<s64>(param.size);
s64 phys_offset = entry.GetPhysicalOffset();
/* Start merge tracking. */
s64 merge_size = 0;
s64 readable_size = 0;
bool merged = false;
/* Iterate. */
auto entry_index = param.entry_index;
for (const auto entry_count = param.entry_set.count; entry_index < entry_count; ++entry_index) {
/* If we're past the end, we're done. */
if (end_offset <= cur_offset) {
break;
}
/* Validate the entry offset. */
const auto entry_offset = entry.GetVirtualOffset();
R_UNLESS(entry_offset <= cur_offset, fs::ResultInvalidIndirectEntryOffset());
/* Get the next entry. */
EntryType next_entry = {};
s64 next_entry_offset;
if (entry_index + 1 < entry_count) {
if (buffer != nullptr) {
const auto ofs = impl::GetBucketTreeEntryOffset(0, m_entry_size, entry_index + 1);
std::memcpy(std::addressof(next_entry), buffer + ofs, m_entry_size);
} else {
const auto ofs = impl::GetBucketTreeEntryOffset(param.entry_set.index, m_node_size, m_entry_size, entry_index + 1);
R_TRY(m_entry_storage.Read(ofs, std::addressof(next_entry), m_entry_size));
}
next_entry_offset = next_entry.GetVirtualOffset();
R_UNLESS(param.offsets.IsInclude(next_entry_offset), fs::ResultInvalidIndirectEntryOffset());
} else {
next_entry_offset = param.entry_set.offset;
}
/* Validate the next entry offset. */
R_UNLESS(cur_offset < next_entry_offset, fs::ResultInvalidIndirectEntryOffset());
/* Determine the much data there is. */
const auto data_size = next_entry_offset - cur_offset;
AMS_ASSERT(data_size > 0);
/* Determine how much data we should read. */
const auto remaining_size = end_offset - cur_offset;
const size_t read_size = static_cast<size_t>(std::min(data_size, remaining_size));
AMS_ASSERT(read_size <= param.size);
/* Update our merge tracking. */
if (entry.IsFragment()) {
/* If we can't merge, stop looping. */
if (EntryType::FragmentSizeMax <= read_size || remaining_size <= data_size) {
break;
}
/* Otherwise, add the current size to the merge size. */
merge_size += read_size;
} else {
/* If we can't merge, stop looping. */
if (phys_offset != entry.GetPhysicalOffset()) {
break;
}
/* Add the size to the readable amount. */
readable_size += merge_size + read_size;
AMS_ASSERT(readable_size <= static_cast<s64>(param.size));
/* Update whether we've merged. */
merged |= merge_size > 0;
merge_size = 0;
}
/* Advance. */
cur_offset += read_size;
AMS_ASSERT(cur_offset <= end_offset);
phys_offset += next_entry_offset - entry_offset;
entry = next_entry;
}
/* If we merged, set our readable size. */
if (merged) {
out_info->SetReadSize(static_cast<size_t>(readable_size));
}
out_info->SetSkipCount(entry_index - param.entry_index);
R_SUCCEED();
}
template<typename EntryType>
Result BucketTree::Visitor::ScanContinuousReading(ContinuousReadingInfo *out_info, s64 offset, size_t size) const {
static_assert(util::is_pod<EntryType>::value);
AMS_ASSERT(this->IsValid());
/* Create our parameters. */
ContinuousReadingParam<EntryType> param = {
offset, size, m_entry_set.header, m_entry_index
};
std::memcpy(std::addressof(param.offsets), std::addressof(m_offsets), sizeof(BucketTree::Offsets));
std::memcpy(std::addressof(param.entry), m_entry, sizeof(EntryType));
/* Scan. */
R_RETURN(m_tree->ScanContinuousReading<EntryType>(out_info, param));
}
}
| 6,831
|
C++
|
.h
| 139
| 38.453237
| 135
| 0.594984
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,521
|
fssystem_hierarchical_integrity_verification_storage.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_hierarchical_integrity_verification_storage.hpp
|
/*
* 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>
#include <stratosphere/os.hpp>
#include <stratosphere/fs/fs_istorage.hpp>
#include <stratosphere/fs/fs_substorage.hpp>
#include <stratosphere/fs/fs_storage_type.hpp>
#include <stratosphere/fssystem/fssystem_integrity_verification_storage.hpp>
#include <stratosphere/fssystem/fssystem_block_cache_buffered_storage.hpp>
namespace ams::fssystem {
/* ACCURATE_TO_VERSION: 14.3.0.0 */
struct HierarchicalIntegrityVerificationLevelInformation {
fs::Int64 offset;
fs::Int64 size;
s32 block_order;
u8 reserved[4];
};
static_assert(util::is_pod<HierarchicalIntegrityVerificationLevelInformation>::value);
static_assert(sizeof(HierarchicalIntegrityVerificationLevelInformation) == 0x18);
static_assert(alignof(HierarchicalIntegrityVerificationLevelInformation) == 0x4);
struct HierarchicalIntegrityVerificationInformation {
u32 max_layers;
HierarchicalIntegrityVerificationLevelInformation info[IntegrityMaxLayerCount - 1];
fs::HashSalt seed;
s64 GetLayeredHashSize() const {
return this->info[this->max_layers - 2].offset;
}
s64 GetDataOffset() const {
return this->info[this->max_layers - 2].offset;
}
s64 GetDataSize() const {
return this->info[this->max_layers - 2].size;
}
};
static_assert(util::is_pod<HierarchicalIntegrityVerificationInformation>::value);
struct HierarchicalIntegrityVerificationMetaInformation {
u32 magic;
u32 version;
u32 master_hash_size;
HierarchicalIntegrityVerificationInformation level_hash_info;
/* TODO: Format */
};
static_assert(util::is_pod<HierarchicalIntegrityVerificationMetaInformation>::value);
struct HierarchicalIntegrityVerificationSizeSet {
s64 control_size;
s64 master_hash_size;
s64 layered_hash_sizes[IntegrityMaxLayerCount - 2];
};
static_assert(util::is_pod<HierarchicalIntegrityVerificationSizeSet>::value);
class HierarchicalIntegrityVerificationStorageControlArea {
NON_COPYABLE(HierarchicalIntegrityVerificationStorageControlArea);
NON_MOVEABLE(HierarchicalIntegrityVerificationStorageControlArea);
public:
static constexpr size_t HashSize = crypto::Sha256Generator::HashSize;
struct InputParam {
size_t level_block_size[IntegrityMaxLayerCount - 1];
};
static_assert(util::is_pod<InputParam>::value);
private:
fs::SubStorage m_storage;
HierarchicalIntegrityVerificationMetaInformation m_meta;
public:
static Result QuerySize(HierarchicalIntegrityVerificationSizeSet *out, const InputParam &input_param, s32 layer_count, s64 data_size);
/* TODO Format */
static Result Expand(fs::SubStorage meta_storage, const HierarchicalIntegrityVerificationMetaInformation &meta);
public:
HierarchicalIntegrityVerificationStorageControlArea() { /* ... */ }
Result Initialize(fs::SubStorage meta_storage);
void Finalize();
u32 GetMasterHashSize() const { return m_meta.master_hash_size; }
void GetLevelHashInfo(HierarchicalIntegrityVerificationInformation *out) {
AMS_ASSERT(out != nullptr);
*out = m_meta.level_hash_info;
}
};
class HierarchicalIntegrityVerificationStorage : public ::ams::fs::IStorage {
NON_COPYABLE(HierarchicalIntegrityVerificationStorage);
NON_MOVEABLE(HierarchicalIntegrityVerificationStorage);
private:
friend struct HierarchicalIntegrityVerificationMetaInformation;
protected:
static constexpr s64 HashSize = crypto::Sha256Generator::HashSize;
static constexpr size_t MaxLayers = IntegrityMaxLayerCount;
public:
using GenerateRandomFunction = void (*)(void *dst, size_t size);
class HierarchicalStorageInformation {
public:
enum {
MasterStorage = 0,
Layer1Storage = 1,
Layer2Storage = 2,
Layer3Storage = 3,
Layer4Storage = 4,
Layer5Storage = 5,
DataStorage = 6,
};
private:
fs::SubStorage m_storages[DataStorage + 1];
public:
void SetMasterHashStorage(fs::SubStorage s) { m_storages[MasterStorage] = s; }
void SetLayer1HashStorage(fs::SubStorage s) { m_storages[Layer1Storage] = s; }
void SetLayer2HashStorage(fs::SubStorage s) { m_storages[Layer2Storage] = s; }
void SetLayer3HashStorage(fs::SubStorage s) { m_storages[Layer3Storage] = s; }
void SetLayer4HashStorage(fs::SubStorage s) { m_storages[Layer4Storage] = s; }
void SetLayer5HashStorage(fs::SubStorage s) { m_storages[Layer5Storage] = s; }
void SetDataStorage(fs::SubStorage s) { m_storages[DataStorage] = s; }
fs::SubStorage &operator[](s32 index) {
AMS_ASSERT(MasterStorage <= index && index <= DataStorage);
return m_storages[index];
}
};
private:
static GenerateRandomFunction s_generate_random;
static void SetGenerateRandomFunction(GenerateRandomFunction func) {
s_generate_random = func;
}
private:
FileSystemBufferManagerSet *m_buffers;
os::SdkRecursiveMutex *m_mutex;
IntegrityVerificationStorage m_verify_storages[MaxLayers - 1];
BlockCacheBufferedStorage m_buffer_storages[MaxLayers - 1];
os::Semaphore *m_read_semaphore;
os::Semaphore *m_write_semaphore;
s64 m_data_size;
s32 m_max_layers;
public:
HierarchicalIntegrityVerificationStorage() : m_buffers(nullptr), m_mutex(nullptr), m_data_size(-1) { /* ... */ }
virtual ~HierarchicalIntegrityVerificationStorage() override { this->Finalize(); }
Result Initialize(const HierarchicalIntegrityVerificationInformation &info, HierarchicalStorageInformation storage, FileSystemBufferManagerSet *bufs, IHash256GeneratorFactory *hgf, bool hash_salt_enabled, os::SdkRecursiveMutex *mtx, os::Semaphore *read_sema, os::Semaphore *write_sema, int max_data_cache_entries, int max_hash_cache_entries, s8 buffer_level, bool is_writable, bool allow_cleared_blocks);
Result Initialize(const HierarchicalIntegrityVerificationInformation &info, HierarchicalStorageInformation storage, FileSystemBufferManagerSet *bufs, IHash256GeneratorFactory *hgf, bool hash_salt_enabled, os::SdkRecursiveMutex *mtx, int max_data_cache_entries, int max_hash_cache_entries, s8 buffer_level, bool is_writable, bool allow_cleared_blocks) {
R_RETURN(this->Initialize(info, storage, bufs, hgf, hash_salt_enabled, mtx, nullptr, nullptr, max_data_cache_entries, max_hash_cache_entries, buffer_level, is_writable, allow_cleared_blocks));
}
void Finalize();
virtual Result Read(s64 offset, void *buffer, size_t size) override;
virtual Result Write(s64 offset, const void *buffer, size_t size) override;
virtual Result SetSize(s64 size) override { AMS_UNUSED(size); R_THROW(fs::ResultUnsupportedSetSizeForHierarchicalIntegrityVerificationStorage()); }
virtual Result GetSize(s64 *out) override;
virtual Result Flush() override;
virtual Result OperateRange(void *dst, size_t dst_size, fs::OperationId op_id, s64 offset, s64 size, const void *src, size_t src_size) override;
using IStorage::OperateRange;
Result Commit();
Result OnRollback();
bool IsInitialized() const {
return m_data_size >= 0;
}
FileSystemBufferManagerSet *GetBuffers() {
return m_buffers;
}
void GetParameters(HierarchicalIntegrityVerificationStorageControlArea::InputParam *out) const {
AMS_ASSERT(out != nullptr);
for (auto level = 0; level <= m_max_layers - 2; ++level) {
out->level_block_size[level] = static_cast<size_t>(m_verify_storages[level].GetBlockSize());
}
}
s64 GetL1HashVerificationBlockSize() const {
return m_verify_storages[m_max_layers - 2].GetBlockSize();
}
fs::SubStorage GetL1HashStorage() {
return fs::SubStorage(std::addressof(m_buffer_storages[m_max_layers - 3]), 0, util::DivideUp(m_data_size, this->GetL1HashVerificationBlockSize()));
}
public:
static constexpr s8 GetDefaultDataCacheBufferLevel(u32 max_layers) {
return 16 + max_layers - 2;
}
};
}
| 9,834
|
C++
|
.h
| 180
| 43.161111
| 416
| 0.654474
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,522
|
fssystem_external_code.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_external_code.hpp
|
/*
* 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>
#include <stratosphere/ncm/ncm_ids.hpp>
#include <stratosphere/fs/fsa/fs_ifilesystem.hpp>
namespace ams::fssystem {
fs::fsa::IFileSystem *GetExternalCodeFileSystem(ncm::ProgramId program_id);
Result CreateExternalCode(os::NativeHandle *out, ncm::ProgramId program_id);
void DestroyExternalCode(ncm::ProgramId program_id);
}
| 1,013
|
C++
|
.h
| 24
| 39.958333
| 80
| 0.766497
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,523
|
fssystem_compression_common.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_compression_common.hpp
|
/*
* 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 {
/* ACCURATE_TO_VERSION: 13.4.0.0 */
enum CompressionType : u8 {
CompressionType_None = 0,
CompressionType_Zeros = 1,
CompressionType_2 = 2,
CompressionType_Lz4 = 3,
CompressionType_Unknown = 4,
};
using DecompressorFunction = Result (*)(void *, size_t, const void *, size_t);
using GetDecompressorFunction = DecompressorFunction (*)(CompressionType);
constexpr s64 CompressionBlockAlignment = 0x10;
namespace CompressionTypeUtility {
constexpr bool IsBlockAlignmentRequired(CompressionType type) {
return type != CompressionType_None && type != CompressionType_Zeros;
}
constexpr bool IsDataStorageAccessRequired(CompressionType type) {
return type != CompressionType_Zeros;
}
constexpr bool IsRandomAccessible(CompressionType type) {
return type == CompressionType_None;
}
constexpr bool IsUnknownType(CompressionType type) {
return type >= CompressionType_Unknown;
}
}
}
| 1,783
|
C++
|
.h
| 44
| 34.772727
| 85
| 0.695602
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,524
|
fssystem_sparse_storage.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_sparse_storage.hpp
|
/*
* 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>
#include <stratosphere/fssystem/fssystem_indirect_storage.hpp>
namespace ams::fssystem {
/* ACCURATE_TO_VERSION: Unknown */
class SparseStorage : public IndirectStorage {
NON_COPYABLE(SparseStorage);
NON_MOVEABLE(SparseStorage);
private:
class ZeroStorage : public ::ams::fs::IStorage, public ::ams::fs::impl::Newable {
public:
ZeroStorage() { /* ... */ }
virtual ~ZeroStorage() { /* ... */ }
public:
virtual Result Read(s64 offset, void *buffer, size_t size) override {
AMS_ASSERT(offset >= 0);
AMS_ASSERT(buffer != nullptr || size == 0);
AMS_UNUSED(offset);
if (size > 0) {
std::memset(buffer, 0, size);
}
R_SUCCEED();
}
virtual Result OperateRange(void *dst, size_t dst_size, fs::OperationId op_id, s64 offset, s64 size, const void *src, size_t src_size) override {
AMS_UNUSED(dst, dst_size, op_id, offset, size, src, src_size);
R_SUCCEED();
}
virtual Result GetSize(s64 *out) override {
AMS_ASSERT(out != nullptr);
*out = std::numeric_limits<s64>::max();
R_SUCCEED();
}
virtual Result Flush() override {
R_SUCCEED();
}
virtual Result Write(s64 offset, const void *buffer, size_t size) override {
AMS_UNUSED(offset, buffer, size);
R_THROW(fs::ResultUnsupportedWriteForZeroStorage());
}
virtual Result SetSize(s64 size) override {
AMS_UNUSED(size);
R_THROW(fs::ResultUnsupportedSetSizeForZeroStorage());
}
};
private:
ZeroStorage m_zero_storage;
public:
SparseStorage() : IndirectStorage(), m_zero_storage() { /* ... */ }
virtual ~SparseStorage() { /* ... */ }
using IndirectStorage::Initialize;
void Initialize(s64 end_offset) {
this->GetEntryTable().Initialize(NodeSize, end_offset);
this->SetZeroStorage();
}
void SetDataStorage(fs::SubStorage storage) {
AMS_ASSERT(this->IsInitialized());
this->SetStorage(0, storage);
this->SetZeroStorage();
}
template<typename T>
void SetDataStorage(T storage, s64 offset, s64 size) {
AMS_ASSERT(this->IsInitialized());
this->SetStorage(0, storage, offset, size);
this->SetZeroStorage();
}
virtual Result Read(s64 offset, void *buffer, size_t size) override;
private:
void SetZeroStorage() {
return this->SetStorage(1, std::addressof(m_zero_storage), 0, std::numeric_limits<s64>::max());
}
};
}
| 3,945
|
C++
|
.h
| 87
| 31.114943
| 165
| 0.528769
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,525
|
fssystem_aes_ctr_storage.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_aes_ctr_storage.hpp
|
/*
* 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>
#include <stratosphere/fs/fs_istorage.hpp>
#include <stratosphere/fs/impl/fs_newable.hpp>
namespace ams::fssystem {
/* ACCURATE_TO_VERSION: Unknown */
template<fs::PointerToStorage BasePointer>
class AesCtrStorage : public ::ams::fs::IStorage, public ::ams::fs::impl::Newable {
NON_COPYABLE(AesCtrStorage);
NON_MOVEABLE(AesCtrStorage);
public:
static constexpr size_t BlockSize = crypto::Aes128CtrEncryptor::BlockSize;
static constexpr size_t KeySize = crypto::Aes128CtrEncryptor::KeySize;
static constexpr size_t IvSize = crypto::Aes128CtrEncryptor::IvSize;
private:
BasePointer m_base_storage;
char m_key[KeySize];
char m_iv[IvSize];
public:
static void MakeIv(void *dst, size_t dst_size, u64 upper, s64 offset);
public:
AesCtrStorage(BasePointer base, const void *key, size_t key_size, const void *iv, size_t iv_size);
virtual Result Read(s64 offset, void *buffer, size_t size) override;
virtual Result Write(s64 offset, const void *buffer, size_t size) override;
virtual Result Flush() override;
virtual Result SetSize(s64 size) override;
virtual Result GetSize(s64 *out) override;
virtual Result OperateRange(void *dst, size_t dst_size, fs::OperationId op_id, s64 offset, s64 size, const void *src, size_t src_size) override;
};
using AesCtrStorageByPointer = AesCtrStorage<fs::IStorage *>;
using AesCtrStorageBySharedPointer = AesCtrStorage<std::shared_ptr<fs::IStorage>>;
}
| 2,311
|
C++
|
.h
| 47
| 42.595745
| 156
| 0.694592
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,526
|
fssystem_pimpl.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_pimpl.hpp
|
/*
* 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 {
/* ACCURATE_TO_VERSION: 13.4.0.0 */
namespace impl {
template<typename T, size_t Size>
struct PimplHelper {
static void Construct(void *);
static void Destroy(void *);
};
}
template<typename T, size_t Size>
class Pimpl {
private:
#if defined(ATMOSPHERE_OS_HORIZON) || defined(ATMOSPHERE_OS_WINDOWS) || defined(ATMOSPHERE_OS_LINUX)
static constexpr size_t ExtraSizeToEnsureCompatibility = 0;
#elif defined(ATMOSPHERE_OS_MACOS)
static constexpr size_t ExtraSizeToEnsureCompatibility = 0x20;
#endif
static constexpr size_t StorageSize = Size + ExtraSizeToEnsureCompatibility;
private:
alignas(0x10) u8 m_storage[StorageSize];
public:
ALWAYS_INLINE Pimpl() { impl::PimplHelper<T, StorageSize>::Construct(m_storage); }
ALWAYS_INLINE ~Pimpl() { impl::PimplHelper<T, StorageSize>::Destroy(m_storage); }
ALWAYS_INLINE T *Get() { return reinterpret_cast<T *>(m_storage + 0); }
ALWAYS_INLINE T *operator->() { return reinterpret_cast<T *>(m_storage + 0); }
};
#define AMS_FSSYSTEM_ENABLE_PIMPL(_CLASSNAME_) \
namespace ams::fssystem::impl { \
\
template<size_t Size> \
struct PimplHelper<_CLASSNAME_, Size> { \
static ALWAYS_INLINE void Construct(void *p) { \
static_assert(sizeof(_CLASSNAME_) <= Size); \
static_assert(alignof(_CLASSNAME_) <= 0x10); \
\
std::construct_at(static_cast<_CLASSNAME_ *>(p)); \
} \
\
static ALWAYS_INLINE void Destroy(void *p) { \
std::destroy_at(static_cast<_CLASSNAME_ *>(p)); \
} \
}; \
\
}
}
| 3,130
|
C++
|
.h
| 62
| 37.548387
| 112
| 0.501308
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,527
|
fssystem_crypto_configuration.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_crypto_configuration.hpp
|
/*
* 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>
#include <stratosphere/fssystem/fssystem_nca_file_system_driver.hpp>
#include <stratosphere/ncm/ncm_content_meta_platform.hpp>
namespace ams::fssystem {
const ::ams::fssystem::NcaCryptoConfiguration *GetNcaCryptoConfiguration(bool prod);
void SetUpKekAccessKeys(bool prod);
void InvalidateHardwareAesKey();
bool IsValidSignatureKeyGeneration(ncm::ContentMetaPlatform platform, size_t key_generation);
const u8 *GetAcidSignatureKeyModulus(ncm::ContentMetaPlatform platform, bool prod, size_t key_generation, bool unk_unused);
size_t GetAcidSignatureKeyModulusSize(ncm::ContentMetaPlatform platform, bool unk_unused);
const u8 *GetAcidSignatureKeyPublicExponent();
constexpr inline size_t AcidSignatureKeyPublicExponentSize = NcaCryptoConfiguration::Rsa2048KeyPublicExponentSize;
}
| 1,492
|
C++
|
.h
| 29
| 48.551724
| 127
| 0.793673
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,528
|
fssystem_buffered_storage.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_buffered_storage.hpp
|
/*
* 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>
#include <stratosphere/os.hpp>
#include <stratosphere/fs/fs_istorage.hpp>
#include <stratosphere/fs/fs_substorage.hpp>
#include <stratosphere/fs/fs_i_buffer_manager.hpp>
namespace ams::fssystem {
/* ACCURATE_TO_VERSION: Unknown */
class BufferedStorage : public ::ams::fs::IStorage {
NON_COPYABLE(BufferedStorage);
NON_MOVEABLE(BufferedStorage);
private:
class Cache;
class UniqueCache;
class SharedCache;
private:
fs::SubStorage m_base_storage;
fs::IBufferManager *m_buffer_manager;
size_t m_block_size;
s64 m_base_storage_size;
std::unique_ptr<Cache[]> m_caches;
s32 m_cache_count;
Cache *m_next_acquire_cache;
Cache *m_next_fetch_cache;
os::SdkMutex m_mutex;
bool m_bulk_read_enabled;
public:
BufferedStorage();
virtual ~BufferedStorage();
Result Initialize(fs::SubStorage base_storage, fs::IBufferManager *buffer_manager, size_t block_size, s32 buffer_count);
void Finalize();
bool IsInitialized() const { return m_caches != nullptr; }
virtual Result Read(s64 offset, void *buffer, size_t size) override;
virtual Result Write(s64 offset, const void *buffer, size_t size) override;
virtual Result GetSize(s64 *out) override;
virtual Result SetSize(s64 size) override;
virtual Result Flush() override;
virtual Result OperateRange(void *dst, size_t dst_size, fs::OperationId op_id, s64 offset, s64 size, const void *src, size_t src_size) override;
using IStorage::OperateRange;
void InvalidateCaches();
fs::IBufferManager *GetBufferManager() const { return m_buffer_manager; }
void EnableBulkRead() { m_bulk_read_enabled = true; }
private:
Result PrepareAllocation();
Result ControlDirtiness();
Result ReadCore(s64 offset, void *buffer, size_t size);
bool ReadHeadCache(s64 *offset, void *buffer, size_t *size, s64 *buffer_offset);
bool ReadTailCache(s64 offset, void *buffer, size_t *size, s64 buffer_offset);
Result BulkRead(s64 offset, void *buffer, size_t size, bool head_cache_needed, bool tail_cache_needed);
Result WriteCore(s64 offset, const void *buffer, size_t size);
};
}
| 3,149
|
C++
|
.h
| 67
| 38.41791
| 156
| 0.657106
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,529
|
fssystem_service_context.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_service_context.hpp
|
/*
* 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>
#include <stratosphere/fs/fs_priority.hpp>
namespace ams::fssystem {
/* ACCURATE_TO_VERSION: 13.4.0.0 */
class ServiceContext {
private:
struct DeferredProcessContextForDeviceError {
u64 process_id;
bool is_process_deferred;
bool is_invoke_deferral_requested;
};
struct DeferredProcessContextForPriority {
int session_type;
bool is_process_deferred;
bool is_acquired;
};
private:
fs::PriorityRaw m_priority;
DeferredProcessContextForDeviceError m_deferred_process_context_for_device_error;
DeferredProcessContextForPriority m_deferred_process_context_for_priority;
int m_storage_flag;
void *m_request_hook_context;
bool m_enable_count_failed_ideal_pooled_buffer_allocations;
public:
ServiceContext() : m_priority(fs::PriorityRaw_Normal), m_storage_flag(0), m_request_hook_context(nullptr), m_enable_count_failed_ideal_pooled_buffer_allocations(false) {
/* ... */
}
};
void RegisterServiceContext(ServiceContext *context);
void UnregisterServiceContext();
ServiceContext *GetServiceContext();
}
| 1,976
|
C++
|
.h
| 48
| 33.395833
| 181
| 0.672046
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,530
|
fssystem_directory_savedata_filesystem.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_directory_savedata_filesystem.hpp
|
/*
* 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 <stratosphere/fs/fs_common.hpp>
#include <stratosphere/fs/fsa/fs_ifile.hpp>
#include <stratosphere/fs/fsa/fs_idirectory.hpp>
#include <stratosphere/fs/fsa/fs_ifilesystem.hpp>
#include <stratosphere/fs/impl/fs_newable.hpp>
namespace ams::fssystem {
/* ACCURATE_TO_VERSION: 13.4.0.0 */
class DirectorySaveDataFileSystem : public fs::fsa::IFileSystem, public fs::impl::Newable {
NON_COPYABLE(DirectorySaveDataFileSystem);
private:
std::unique_ptr<fs::fsa::IFileSystem> m_unique_fs;
fs::fsa::IFileSystem * const m_base_fs;
os::SdkMutex m_accessor_mutex = {};
s32 m_open_writable_files = 0;
bool m_is_journaling_supported = false;
bool m_is_multi_commit_supported = false;
bool m_is_journaling_enabled = false;
/* Extension member to ensure proper savedata locking. */
std::unique_ptr<fs::fsa::IFile> m_lock_file = nullptr;
public:
DirectorySaveDataFileSystem(std::unique_ptr<fs::fsa::IFileSystem> fs) : m_unique_fs(std::move(fs)), m_base_fs(m_unique_fs.get()) { /* ... */ }
DirectorySaveDataFileSystem(fs::fsa::IFileSystem *fs) : m_unique_fs(), m_base_fs(fs) { /* ... */ }
Result Initialize(bool journaling_supported, bool multi_commit_enabled, bool journaling_enabled);
private:
Result SynchronizeDirectory(const fs::Path &dst, const fs::Path &src);
Result ResolvePath(fs::Path *out, const fs::Path &path);
Result AcquireLockFile();
public:
void DecrementWriteOpenFileCount();
public:
virtual Result DoCreateFile(const fs::Path &path, s64 size, int option) override;
virtual Result DoDeleteFile(const fs::Path &path) override;
virtual Result DoCreateDirectory(const fs::Path &path) override;
virtual Result DoDeleteDirectory(const fs::Path &path) override;
virtual Result DoDeleteDirectoryRecursively(const fs::Path &path) override;
virtual Result DoRenameFile(const fs::Path &old_path, const fs::Path &new_path) override;
virtual Result DoRenameDirectory(const fs::Path &old_path, const fs::Path &new_path) override;
virtual Result DoGetEntryType(fs::DirectoryEntryType *out, const fs::Path &path) override;
virtual Result DoOpenFile(std::unique_ptr<fs::fsa::IFile> *out_file, const fs::Path &path, fs::OpenMode mode) override;
virtual Result DoOpenDirectory(std::unique_ptr<fs::fsa::IDirectory> *out_dir, const fs::Path &path, fs::OpenDirectoryMode mode) override;
virtual Result DoCommit() override;
virtual Result DoGetFreeSpaceSize(s64 *out, const fs::Path &path) override;
virtual Result DoGetTotalSpaceSize(s64 *out, const fs::Path &path) override;
virtual Result DoCleanDirectoryRecursively(const fs::Path &path) override;
/* These aren't accessible as commands. */
virtual Result DoCommitProvisionally(s64 counter) override;
virtual Result DoRollback() override;
};
}
| 3,808
|
C++
|
.h
| 65
| 50.276923
| 154
| 0.678705
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,531
|
fssystem_indirect_storage_template_impl.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_indirect_storage_template_impl.hpp
|
/*
* 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 <stratosphere/fssystem/fssystem_indirect_storage.hpp>
namespace ams::fssystem {
/* ACCURATE_TO_VERSION: 13.4.0.0 */
template<bool ContinuousCheck, bool RangeCheck, typename F>
Result IndirectStorage::OperatePerEntry(s64 offset, s64 size, F func) {
/* Validate preconditions. */
AMS_ASSERT(offset >= 0);
AMS_ASSERT(size >= 0);
AMS_ASSERT(this->IsInitialized());
/* Succeed if there's nothing to operate on. */
R_SUCCEED_IF(size == 0);
/* Get the table offsets. */
BucketTree::Offsets table_offsets;
R_TRY(m_table.GetOffsets(std::addressof(table_offsets)));
/* Validate arguments. */
R_UNLESS(table_offsets.IsInclude(offset, size), fs::ResultOutOfRange());
/* Find the offset in our tree. */
BucketTree::Visitor visitor;
R_TRY(m_table.Find(std::addressof(visitor), offset));
{
const auto entry_offset = visitor.Get<Entry>()->GetVirtualOffset();
R_UNLESS(0 <= entry_offset && table_offsets.IsInclude(entry_offset), fs::ResultInvalidIndirectEntryOffset());
}
/* Prepare to operate in chunks. */
auto cur_offset = offset;
const auto end_offset = offset + static_cast<s64>(size);
BucketTree::ContinuousReadingInfo cr_info;
while (cur_offset < end_offset) {
/* Get the current entry. */
const auto cur_entry = *visitor.Get<Entry>();
/* Get and validate the entry's offset. */
const auto cur_entry_offset = cur_entry.GetVirtualOffset();
R_UNLESS(cur_entry_offset <= cur_offset, fs::ResultInvalidIndirectEntryOffset());
/* Validate the storage index. */
R_UNLESS(0 <= cur_entry.storage_index && cur_entry.storage_index < StorageCount, fs::ResultInvalidIndirectEntryStorageIndex());
/* If we need to check the continuous info, do so. */
if constexpr (ContinuousCheck) {
/* Scan, if we need to. */
if (cr_info.CheckNeedScan()) {
R_TRY(visitor.ScanContinuousReading<ContinuousReadingEntry>(std::addressof(cr_info), cur_offset, static_cast<size_t>(end_offset - cur_offset)));
}
/* Process a base storage entry. */
if (cr_info.CanDo()) {
/* Ensure that we can process. */
R_UNLESS(cur_entry.storage_index == 0, fs::ResultInvalidIndirectEntryStorageIndex());
/* Ensure that we remain within range. */
const auto data_offset = cur_offset - cur_entry_offset;
const auto cur_entry_phys_offset = cur_entry.GetPhysicalOffset();
const auto cur_size = static_cast<s64>(cr_info.GetReadSize());
/* If we should, verify the range. */
if constexpr (RangeCheck) {
/* Get the current data storage's size. */
s64 cur_data_storage_size;
R_TRY(m_data_storage[0].GetSize(std::addressof(cur_data_storage_size)));
R_UNLESS(0 <= cur_entry_phys_offset && cur_entry_phys_offset <= cur_data_storage_size, fs::ResultInvalidIndirectEntryOffset());
R_UNLESS(cur_entry_phys_offset + data_offset + cur_size <= cur_data_storage_size, fs::ResultInvalidIndirectStorageSize());
}
/* Operate. */
R_TRY(func(std::addressof(m_data_storage[0]), cur_entry_phys_offset + data_offset, cur_offset, cur_size));
/* Mark as done. */
cr_info.Done();
}
}
/* Get and validate the next entry offset. */
s64 next_entry_offset;
if (visitor.CanMoveNext()) {
R_TRY(visitor.MoveNext());
next_entry_offset = visitor.Get<Entry>()->GetVirtualOffset();
R_UNLESS(table_offsets.IsInclude(next_entry_offset), fs::ResultInvalidIndirectEntryOffset());
} else {
next_entry_offset = table_offsets.end_offset;
}
R_UNLESS(cur_offset < next_entry_offset, fs::ResultInvalidIndirectEntryOffset());
/* Get the offset of the entry in the data we read. */
const auto data_offset = cur_offset - cur_entry_offset;
const auto data_size = (next_entry_offset - cur_entry_offset);
AMS_ASSERT(data_size > 0);
/* Determine how much is left. */
const auto remaining_size = end_offset - cur_offset;
const auto cur_size = std::min<s64>(remaining_size, data_size - data_offset);
AMS_ASSERT(cur_size <= size);
/* Operate, if we need to. */
bool needs_operate;
if constexpr (!ContinuousCheck) {
needs_operate = true;
} else {
needs_operate = !cr_info.IsDone() || cur_entry.storage_index != 0;
}
if (needs_operate) {
const auto cur_entry_phys_offset = cur_entry.GetPhysicalOffset();
if constexpr (RangeCheck) {
/* Get the current data storage's size. */
s64 cur_data_storage_size;
R_TRY(m_data_storage[cur_entry.storage_index].GetSize(std::addressof(cur_data_storage_size)));
/* Ensure that we remain within range. */
R_UNLESS(0 <= cur_entry_phys_offset && cur_entry_phys_offset <= cur_data_storage_size, fs::ResultIndirectStorageCorrupted());
R_UNLESS(cur_entry_phys_offset + data_offset + cur_size <= cur_data_storage_size, fs::ResultIndirectStorageCorrupted());
}
R_TRY(func(std::addressof(m_data_storage[cur_entry.storage_index]), cur_entry_phys_offset + data_offset, cur_offset, cur_size));
}
cur_offset += cur_size;
}
R_SUCCEED();
}
}
| 6,751
|
C++
|
.h
| 121
| 43
| 164
| 0.585517
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
7,532
|
fssystem_bucket_tree.hpp
|
Atmosphere-NX_Atmosphere/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_bucket_tree.hpp
|
/*
* 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>
#include <stratosphere/fs/fs_substorage.hpp>
namespace ams::fssystem {
/* ACCURATE_TO_VERSION: Unknown */
class BucketTree {
NON_COPYABLE(BucketTree);
NON_MOVEABLE(BucketTree);
public:
static constexpr u32 Magic = util::FourCC<'B','K','T','R'>::Code;
static constexpr u32 Version = 1;
static constexpr size_t NodeSizeMin = 1_KB;
static constexpr size_t NodeSizeMax = 512_KB;
public:
class Visitor;
struct Header {
u32 magic;
u32 version;
s32 entry_count;
s32 reserved;
void Format(s32 entry_count);
Result Verify() const;
};
static_assert(util::is_pod<Header>::value);
static_assert(sizeof(Header) == 0x10);
struct NodeHeader {
s32 index;
s32 count;
s64 offset;
Result Verify(s32 node_index, size_t node_size, size_t entry_size) const;
};
static_assert(util::is_pod<NodeHeader>::value);
static_assert(sizeof(NodeHeader) == 0x10);
struct Offsets {
s64 start_offset;
s64 end_offset;
constexpr bool IsInclude(s64 offset) const {
return this->start_offset <= offset && offset < this->end_offset;
}
constexpr bool IsInclude(s64 offset, s64 size) const {
return size > 0 && this->start_offset <= offset && size <= (this->end_offset - offset);
}
};
static_assert(util::is_pod<Offsets>::value);
static_assert(sizeof(Offsets) == 0x10);
struct OffsetCache {
Offsets offsets;
os::SdkMutex mutex;
bool is_initialized;
constexpr OffsetCache() : offsets{ -1, -1 }, mutex(), is_initialized(false) { /* ... */ }
};
class ContinuousReadingInfo {
private:
size_t m_read_size;
s32 m_skip_count;
bool m_done;
public:
constexpr ContinuousReadingInfo() : m_read_size(), m_skip_count(), m_done() { /* ... */ }
constexpr void Reset() { m_read_size = 0; m_skip_count = 0; m_done = false; }
constexpr void SetSkipCount(s32 count) { AMS_ASSERT(count >= 0); m_skip_count = count; }
constexpr s32 GetSkipCount() const { return m_skip_count; }
constexpr bool CheckNeedScan() { return (--m_skip_count) <= 0; }
constexpr void Done() { m_read_size = 0; m_done = true; }
constexpr bool IsDone() const { return m_done; }
constexpr void SetReadSize(size_t size) { m_read_size = size; }
constexpr size_t GetReadSize() const { return m_read_size; }
constexpr bool CanDo() const { return m_read_size > 0; }
};
using IAllocator = MemoryResource;
private:
class NodeBuffer {
NON_COPYABLE(NodeBuffer);
private:
IAllocator *m_allocator;
void *m_header;
public:
NodeBuffer() : m_allocator(), m_header() { /* ... */ }
~NodeBuffer() {
AMS_ASSERT(m_header == nullptr);
}
NodeBuffer(NodeBuffer &&rhs) : m_allocator(rhs.m_allocator), m_header(rhs.m_header) {
rhs.m_allocator = nullptr;
rhs.m_header = nullptr;
}
NodeBuffer &operator=(NodeBuffer &&rhs) {
if (this != std::addressof(rhs)) {
AMS_ASSERT(m_header == nullptr);
m_allocator = rhs.m_allocator;
m_header = rhs.m_header;
rhs.m_allocator = nullptr;
rhs.m_header = nullptr;
}
return *this;
}
bool Allocate(IAllocator *allocator, size_t node_size) {
AMS_ASSERT(m_header == nullptr);
m_allocator = allocator;
m_header = allocator->Allocate(node_size, sizeof(s64));
AMS_ASSERT(util::IsAligned(m_header, sizeof(s64)));
return m_header != nullptr;
}
void Free(size_t node_size) {
if (m_header) {
m_allocator->Deallocate(m_header, node_size);
m_header = nullptr;
}
m_allocator = nullptr;
}
void FillZero(size_t node_size) const {
if (m_header) {
std::memset(m_header, 0, node_size);
}
}
NodeHeader *Get() const {
return reinterpret_cast<NodeHeader *>(m_header);
}
NodeHeader *operator->() const { return this->Get(); }
template<typename T>
T *Get() const {
static_assert(util::is_pod<T>::value);
static_assert(sizeof(T) == sizeof(NodeHeader));
return reinterpret_cast<T *>(m_header);
}
IAllocator *GetAllocator() const {
return m_allocator;
}
};
private:
static constexpr s32 GetEntryCount(size_t node_size, size_t entry_size) {
return static_cast<s32>((node_size - sizeof(NodeHeader)) / entry_size);
}
static constexpr s32 GetOffsetCount(size_t node_size) {
return static_cast<s32>((node_size - sizeof(NodeHeader)) / sizeof(s64));
}
static constexpr s32 GetEntrySetCount(size_t node_size, size_t entry_size, s32 entry_count) {
const s32 entry_count_per_node = GetEntryCount(node_size, entry_size);
return util::DivideUp(entry_count, entry_count_per_node);
}
static constexpr s32 GetNodeL2Count(size_t node_size, size_t entry_size, s32 entry_count) {
const s32 offset_count_per_node = GetOffsetCount(node_size);
const s32 entry_set_count = GetEntrySetCount(node_size, entry_size, entry_count);
if (entry_set_count <= offset_count_per_node) {
return 0;
}
const s32 node_l2_count = util::DivideUp(entry_set_count, offset_count_per_node);
AMS_ABORT_UNLESS(node_l2_count <= offset_count_per_node);
return util::DivideUp(entry_set_count - (offset_count_per_node - (node_l2_count - 1)), offset_count_per_node);
}
public:
static constexpr s64 QueryHeaderStorageSize() { return sizeof(Header); }
static constexpr s64 QueryNodeStorageSize(size_t node_size, size_t entry_size, s32 entry_count) {
AMS_ASSERT(entry_size >= sizeof(s64));
AMS_ASSERT(node_size >= entry_size + sizeof(NodeHeader));
AMS_ASSERT(NodeSizeMin <= node_size && node_size <= NodeSizeMax);
AMS_ASSERT(util::IsPowerOfTwo(node_size));
AMS_ASSERT(entry_count >= 0);
if (entry_count <= 0) {
return 0;
}
return (1 + GetNodeL2Count(node_size, entry_size, entry_count)) * static_cast<s64>(node_size);
}
static constexpr s64 QueryEntryStorageSize(size_t node_size, size_t entry_size, s32 entry_count) {
AMS_ASSERT(entry_size >= sizeof(s64));
AMS_ASSERT(node_size >= entry_size + sizeof(NodeHeader));
AMS_ASSERT(NodeSizeMin <= node_size && node_size <= NodeSizeMax);
AMS_ASSERT(util::IsPowerOfTwo(node_size));
AMS_ASSERT(entry_count >= 0);
if (entry_count <= 0) {
return 0;
}
return GetEntrySetCount(node_size, entry_size, entry_count) * static_cast<s64>(node_size);
}
private:
mutable fs::SubStorage m_node_storage;
mutable fs::SubStorage m_entry_storage;
NodeBuffer m_node_l1;
size_t m_node_size;
size_t m_entry_size;
s32 m_entry_count;
s32 m_offset_count;
s32 m_entry_set_count;
OffsetCache m_offset_cache;
public:
BucketTree() : m_node_storage(), m_entry_storage(), m_node_l1(), m_node_size(), m_entry_size(), m_entry_count(), m_offset_count(), m_entry_set_count(), m_offset_cache() { /* ... */ }
~BucketTree() { this->Finalize(); }
Result Initialize(IAllocator *allocator, fs::SubStorage node_storage, fs::SubStorage entry_storage, size_t node_size, size_t entry_size, s32 entry_count);
void Initialize(size_t node_size, s64 end_offset);
void Finalize();
bool IsInitialized() const { return m_node_size > 0; }
bool IsEmpty() const { return m_entry_size == 0; }
Result Find(Visitor *visitor, s64 virtual_address);
Result InvalidateCache();
s32 GetEntryCount() const { return m_entry_count; }
IAllocator *GetAllocator() const { return m_node_l1.GetAllocator(); }
Result GetOffsets(Offsets *out) {
/* Ensure we have an offset cache. */
R_TRY(this->EnsureOffsetCache());
/* Set the output. */
*out = m_offset_cache.offsets;
R_SUCCEED();
}
private:
template<typename EntryType>
struct ContinuousReadingParam {
s64 offset;
size_t size;
NodeHeader entry_set;
s32 entry_index;
Offsets offsets;
EntryType entry;
};
private:
template<typename EntryType>
Result ScanContinuousReading(ContinuousReadingInfo *out_info, const ContinuousReadingParam<EntryType> ¶m) const;
bool IsExistL2() const { return m_offset_count < m_entry_set_count; }
bool IsExistOffsetL2OnL1() const { return this->IsExistL2() && m_node_l1->count < m_offset_count; }
s64 GetEntrySetIndex(s32 node_index, s32 offset_index) const {
return (m_offset_count - m_node_l1->count) + (m_offset_count * node_index) + offset_index;
}
Result EnsureOffsetCache();
};
/* ACCURATE_TO_VERSION: Unknown */
class BucketTree::Visitor {
NON_COPYABLE(Visitor);
NON_MOVEABLE(Visitor);
private:
friend class BucketTree;
union EntrySetHeader {
NodeHeader header;
struct Info {
s32 index;
s32 count;
s64 end;
s64 start;
} info;
static_assert(util::is_pod<Info>::value);
};
static_assert(util::is_pod<EntrySetHeader>::value);
private:
const BucketTree *m_tree;
BucketTree::Offsets m_offsets;
void *m_entry;
s32 m_entry_index;
s32 m_entry_set_count;
EntrySetHeader m_entry_set;
public:
constexpr Visitor() : m_tree(), m_entry(), m_entry_index(-1), m_entry_set_count(), m_entry_set{} { /* ... */ }
~Visitor() {
if (m_entry != nullptr) {
m_tree->GetAllocator()->Deallocate(m_entry, m_tree->m_entry_size);
m_tree = nullptr;
m_entry = nullptr;
}
}
bool IsValid() const { return m_entry_index >= 0; }
bool CanMoveNext() const { return this->IsValid() && (m_entry_index + 1 < m_entry_set.info.count || m_entry_set.info.index + 1 < m_entry_set_count); }
bool CanMovePrevious() const { return this->IsValid() && (m_entry_index > 0 || m_entry_set.info.index > 0); }
Result MoveNext();
Result MovePrevious();
template<typename EntryType>
Result ScanContinuousReading(ContinuousReadingInfo *out_info, s64 offset, size_t size) const;
const void *Get() const { AMS_ASSERT(this->IsValid()); return m_entry; }
template<typename T>
const T *Get() const { AMS_ASSERT(this->IsValid()); return reinterpret_cast<const T *>(m_entry); }
const BucketTree *GetTree() const { return m_tree; }
private:
Result Initialize(const BucketTree *tree, const BucketTree::Offsets &offsets);
Result Find(s64 virtual_address);
Result FindEntrySet(s32 *out_index, s64 virtual_address, s32 node_index);
Result FindEntrySetWithBuffer(s32 *out_index, s64 virtual_address, s32 node_index, char *buffer);
Result FindEntrySetWithoutBuffer(s32 *out_index, s64 virtual_address, s32 node_index);
Result FindEntry(s64 virtual_address, s32 entry_set_index);
Result FindEntryWithBuffer(s64 virtual_address, s32 entry_set_index, char *buffer);
Result FindEntryWithoutBuffer(s64 virtual_address, s32 entry_set_index);
};
}
| 14,600
|
C++
|
.h
| 291
| 34.539519
| 194
| 0.526711
|
Atmosphere-NX/Atmosphere
| 14,324
| 1,207
| 54
|
GPL-2.0
|
9/20/2024, 9:26:25 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.