From d4f99ddb4db6c81e1b08462694f451d44a1b96eb Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Mon, 9 Dec 2019 03:58:48 -0800 Subject: [PATCH] libstratosphere: use from /atmosphere/libraries --- .gitattributes | 2 +- Makefile | 16 +- common/include/atmosphere.h | 31 - common/include/atmosphere/target_fw.h | 41 - common/include/atmosphere/version.h | 28 - {common/defaults => config_templates}/BCT.ini | 0 .../accessible-urls/accessible-urls.txt | 0 ...E0377EF526CE6AD2AC6F2CAD7180CE69E74311.ips | Bin ...6F10FB367A00BBD8B7D8D1F25CCE0B458D7E89.ips | Bin ...AC2DF1E2BCAB3BC19DC5CD63DB6FAEC0947097.ips | Bin ...99C93305D6A69D465CF597D67465CD69BACCE8.ips | Bin ...74BED302613F1E442581FD863708E39112DB50.ips | Bin ...0276B3EAD664DA79826FA936F99803B6C28F3B.ips | Bin ...076B11737132EBB1484CF906B6A8EB3B1BF459.ips | Bin ...D9F762CBA1185ADDAD4EC3C479EC8FBFEC31DD.ips | Bin ...CE4A5A1DA2D5C393F74224F8BC09DE4AAA4217.ips | Bin ...F5D3090215C46F37BD079442977A85B8243BA5.ips | Bin ...CEBB93E3E9695C7CFD390F00509B1204101C24.ips | Bin ...6957A4B1271C1F8201B99735D8DF152E7913F1.ips | Bin ...413B0B64CE03BD9BBFEB26F2B3E01C5427C69E.ips | Bin ...785A0CD7AA9DC1A63C57D10049423DE7B77E2C.ips | Bin ...A23B06AFFF5A98055576D5F337A621C0233CE3.ips | Bin ...F609C363834471BF18CA375CB6A1DEB77755EA.ips | Bin ...42F75B0159771671F73082448ACE30BD6BAE89.ips | Bin ...2B32B432340DD2C7590CDEFC03E51B844AE805.ips | Bin ...E0F78013A3684D8AB5D128096674A8F7755B3D.ips | Bin ...5B7FC305B54F961024BF432575296E4D52BC99.ips | Bin .../override_config.ini | 0 .../system_settings.ini | 0 exosphere/Makefile | 4 +- exosphere/lp0fw/Makefile | 2 +- exosphere/lp0fw/src/utils.h | 4 +- exosphere/src/configitem.c | 2 +- exosphere/src/emummc_cfg.h | 4 +- exosphere/src/exocfg.c | 2 +- exosphere/src/exocfg.h | 4 +- exosphere/src/smc_api.c | 2 +- fusee/fusee-secondary/Makefile | 2 +- fusee/fusee-secondary/src/emummc_cfg.h | 2 +- fusee/fusee-secondary/src/exocfg.h | 2 +- fusee/fusee-secondary/src/package2.c | 2 +- fusee/fusee-secondary/src/start.s | 2 +- stratosphere/Makefile | 4 +- stratosphere/ams_mitm/Makefile | 95 +- stratosphere/boot/Makefile | 112 +- stratosphere/boot2/Makefile | 95 +- stratosphere/creport/Makefile | 95 +- stratosphere/dmnt/Makefile | 95 +- stratosphere/eclct.stub/Makefile | 95 +- stratosphere/fatal/Makefile | 96 +- stratosphere/libstratosphere/.gitignore | 74 - stratosphere/libstratosphere/.gitmodules | 0 stratosphere/libstratosphere/.gitrepo | 12 - stratosphere/libstratosphere/LICENSE | 339 --- stratosphere/libstratosphere/Makefile | 142 -- stratosphere/libstratosphere/README.md | 31 - .../include/atmosphere/common.hpp | 22 - .../include/atmosphere/common_includes.hpp | 53 - .../include/atmosphere/defines.hpp | 46 - .../include/atmosphere/results.hpp | 50 - .../atmosphere/results/cal_results.hpp | 26 - .../atmosphere/results/creport_results.hpp | 37 - .../atmosphere/results/debug_results.hpp | 28 - .../atmosphere/results/dmnt_results.hpp | 50 - .../atmosphere/results/err_results.hpp | 27 - .../atmosphere/results/exosphere_results.hpp | 30 - .../atmosphere/results/fatal_results.hpp | 31 - .../include/atmosphere/results/fs_results.hpp | 124 -- .../atmosphere/results/hipc_results.hpp | 41 - .../atmosphere/results/i2c_results.hpp | 30 - .../atmosphere/results/kvdb_results.hpp | 33 - .../atmosphere/results/loader_results.hpp | 63 - .../include/atmosphere/results/lr_results.hpp | 34 - .../atmosphere/results/ncm_results.hpp | 55 - .../include/atmosphere/results/os_results.hpp | 32 - .../include/atmosphere/results/pm_results.hpp | 31 - .../atmosphere/results/results_common.hpp | 289 --- .../include/atmosphere/results/ro_results.hpp | 45 - .../atmosphere/results/settings_results.hpp | 47 - .../include/atmosphere/results/sf_results.hpp | 54 - .../include/atmosphere/results/sm_results.hpp | 42 - .../atmosphere/results/spl_results.hpp | 42 - .../atmosphere/results/svc_results.hpp | 73 - .../atmosphere/results/updater_results.hpp | 30 - .../include/atmosphere/results/vi_results.hpp | 28 - .../include/atmosphere/svc.hpp | 21 - .../include/atmosphere/svc/svc_types.hpp | 208 -- .../include/atmosphere/util.hpp | 27 - .../atmosphere/util/util_alignment.hpp | 75 - .../atmosphere/util/util_compression.hpp | 28 - .../include/atmosphere/util/util_ini.hpp | 31 - .../atmosphere/util/util_intrusive_list.hpp | 595 ------ .../util/util_intrusive_red_black_tree.hpp | 297 --- .../atmosphere/util/util_parent_of_member.hpp | 77 - .../atmosphere/util/util_scope_guard.hpp | 58 - .../include/atmosphere/util/util_size.hpp | 37 - .../atmosphere/util/util_typed_storage.hpp | 49 - .../include/freebsd/sys/tree.h | 812 ------- .../libstratosphere/include/stratosphere.hpp | 55 - .../include/stratosphere/ams.hpp | 22 - .../stratosphere/ams/ams_emummc_api.hpp | 31 - .../stratosphere/ams/ams_environment.hpp | 25 - .../stratosphere/ams/ams_exosphere_api.hpp | 53 - .../include/stratosphere/ams/ams_types.hpp | 139 -- .../include/stratosphere/boot2.hpp | 19 - .../include/stratosphere/boot2/boot2_api.hpp | 30 - .../include/stratosphere/cfg.hpp | 19 - .../include/stratosphere/cfg/cfg_api.hpp | 49 - .../stratosphere/cfg/cfg_locale_types.hpp | 27 - .../include/stratosphere/cfg/cfg_types.hpp | 62 - .../include/stratosphere/dd.hpp | 20 - .../stratosphere/dd/dd_io_mappings.hpp | 36 - .../stratosphere/dd/dd_process_handle.hpp | 24 - .../include/stratosphere/dmnt.hpp | 19 - .../stratosphere/dmnt/dmnt_cheat_types.hpp | 66 - .../include/stratosphere/fatal.hpp | 19 - .../stratosphere/fatal/fatal_types.hpp | 348 --- .../include/stratosphere/fs.hpp | 28 - .../include/stratosphere/fs/fs_common.hpp | 27 - .../include/stratosphere/fs/fs_directory.hpp | 25 - .../include/stratosphere/fs/fs_file.hpp | 63 - .../stratosphere/fs/fs_file_storage.hpp | 56 - .../include/stratosphere/fs/fs_filesystem.hpp | 52 - .../include/stratosphere/fs/fs_istorage.hpp | 106 - .../stratosphere/fs/fs_operate_range.hpp | 28 - .../include/stratosphere/fs/fs_path_tool.hpp | 73 - .../include/stratosphere/fs/fs_path_utils.hpp | 48 - .../stratosphere/fs/fs_query_range.hpp | 45 - .../stratosphere/fs/fs_remote_filesystem.hpp | 179 -- .../stratosphere/fs/fs_remote_storage.hpp | 60 - .../stratosphere/fs/fsa/fs_idirectory.hpp | 52 - .../include/stratosphere/fs/fsa/fs_ifile.hpp | 95 - .../stratosphere/fs/fsa/fs_ifilesystem.hpp | 191 -- .../include/stratosphere/fssrv.hpp | 19 - .../fssrv/fssrv_interface_adapters.hpp | 18 - .../fssrv/fssrv_path_normalizer.hpp | 66 - .../stratosphere/fssrv/fssrv_sf_path.hpp | 50 - .../fssrv_filesystem_interface_adapter.hpp | 192 -- .../fssrv_storage_interface_adapter.hpp | 78 - .../include/stratosphere/fssystem.hpp | 22 - ...ystem_directory_redirection_filesystem.hpp | 47 - ...fssystem_directory_savedata_filesystem.hpp | 64 - .../fssystem/fssystem_path_tool.hpp | 26 - .../fssystem_subdirectory_filesystem.hpp | 44 - .../fssystem/fssystem_utility.hpp | 169 -- .../fssystem_path_resolution_filesystem.hpp | 194 -- .../include/stratosphere/hid.hpp | 19 - .../include/stratosphere/hid/hid_api.hpp | 24 - .../include/stratosphere/hos.hpp | 20 - .../include/stratosphere/hos/hos_types.hpp | 39 - .../stratosphere/hos/hos_version_api.hpp | 25 - .../include/stratosphere/kvdb.hpp | 24 - .../stratosphere/kvdb/kvdb_archive.hpp | 64 - .../stratosphere/kvdb/kvdb_auto_buffer.hpp | 90 - .../stratosphere/kvdb/kvdb_bounded_string.hpp | 145 -- .../kvdb/kvdb_file_key_value_cache.hpp | 391 ---- .../kvdb/kvdb_file_key_value_store.hpp | 122 -- .../kvdb/kvdb_memory_key_value_store.hpp | 525 ----- .../include/stratosphere/ldr.hpp | 20 - .../include/stratosphere/ldr/ldr_pm_api.hpp | 33 - .../include/stratosphere/ldr/ldr_types.hpp | 242 --- .../include/stratosphere/map.hpp | 20 - .../include/stratosphere/map/map_api.hpp | 28 - .../include/stratosphere/map/map_types.hpp | 122 -- .../include/stratosphere/ncm.hpp | 19 - .../include/stratosphere/ncm/ncm_types.hpp | 447 ---- .../include/stratosphere/os.hpp | 34 - .../stratosphere/os/os_common_types.hpp | 81 - .../include/stratosphere/os/os_condvar.hpp | 70 - .../include/stratosphere/os/os_event.hpp | 53 - .../stratosphere/os/os_interrupt_event.hpp | 49 - .../stratosphere/os/os_managed_handle.hpp | 82 - .../stratosphere/os/os_memory_common.hpp | 25 - .../stratosphere/os/os_message_queue.hpp | 89 - .../include/stratosphere/os/os_mutex.hpp | 101 - .../stratosphere/os/os_process_handle.hpp | 28 - .../include/stratosphere/os/os_rw_lock.hpp | 89 - .../include/stratosphere/os/os_semaphore.hpp | 56 - .../stratosphere/os/os_system_event.hpp | 80 - .../include/stratosphere/os/os_thread.hpp | 110 - .../stratosphere/os/os_timeout_helper.hpp | 63 - .../stratosphere/os/os_waitable_holder.hpp | 67 - .../stratosphere/os/os_waitable_manager.hpp | 51 - .../include/stratosphere/patcher.hpp | 19 - .../stratosphere/patcher/patcher_api.hpp | 26 - .../include/stratosphere/pm.hpp | 23 - .../stratosphere/pm/pm_boot_mode_api.hpp | 27 - .../include/stratosphere/pm/pm_dmnt_api.hpp | 32 - .../include/stratosphere/pm/pm_info_api.hpp | 37 - .../include/stratosphere/pm/pm_shell_api.hpp | 27 - .../include/stratosphere/pm/pm_types.hpp | 43 - .../include/stratosphere/reg.hpp | 70 - .../include/stratosphere/rnd.hpp | 19 - .../include/stratosphere/rnd/rnd_api.hpp | 27 - .../include/stratosphere/ro.hpp | 19 - .../include/stratosphere/ro/ro_types.hpp | 150 -- .../include/stratosphere/settings.hpp | 21 - .../settings/settings_fwdbg_api.hpp | 28 - .../settings/settings_fwdbg_types.hpp | 38 - .../stratosphere/settings/settings_types.hpp | 223 -- .../include/stratosphere/sf.hpp | 29 - .../sf/cmif/sf_cmif_domain_api.hpp | 68 - .../sf/cmif/sf_cmif_domain_manager.hpp | 128 -- .../sf/cmif/sf_cmif_domain_service_object.hpp | 136 -- .../sf/cmif/sf_cmif_pointer_and_size.hpp | 44 - .../cmif/sf_cmif_server_message_processor.hpp | 81 - .../sf/cmif/sf_cmif_service_dispatch.hpp | 150 -- .../sf/cmif/sf_cmif_service_object_holder.hpp | 110 - .../stratosphere/sf/hipc/sf_hipc_api.hpp | 37 - .../sf_hipc_server_domain_session_manager.hpp | 37 - .../sf/hipc/sf_hipc_server_manager.hpp | 394 ---- .../hipc/sf_hipc_server_session_manager.hpp | 182 -- .../sf/impl/sf_impl_command_serialization.hpp | 1161 ----------- .../stratosphere/sf/sf_buffer_tags.hpp | 30 - .../include/stratosphere/sf/sf_buffers.hpp | 301 --- .../include/stratosphere/sf/sf_common.hpp | 21 - .../include/stratosphere/sf/sf_handles.hpp | 171 -- .../stratosphere/sf/sf_mitm_dispatch.h | 100 - .../include/stratosphere/sf/sf_out.hpp | 76 - .../stratosphere/sf/sf_service_object.hpp | 62 - .../include/stratosphere/sm.hpp | 24 - .../include/stratosphere/sm/sm_api.hpp | 45 - .../stratosphere/sm/sm_manager_api.hpp | 33 - .../include/stratosphere/sm/sm_mitm_api.hpp | 31 - .../stratosphere/sm/sm_scoped_holder.hpp | 86 - .../include/stratosphere/sm/sm_types.hpp | 78 - .../include/stratosphere/spl.hpp | 21 - .../include/stratosphere/spl/smc/spl_smc.hpp | 73 - .../include/stratosphere/spl/spl_api.hpp | 29 - .../include/stratosphere/spl/spl_types.hpp | 192 -- .../include/stratosphere/updater.hpp | 20 - .../stratosphere/updater/updater_api.hpp | 27 - .../stratosphere/updater/updater_types.hpp | 44 - .../libstratosphere/source/ams/ams_bpc.c | 46 - .../libstratosphere/source/ams/ams_bpc.h | 34 - .../source/ams/ams_emummc_api.cpp | 137 -- .../source/ams/ams_environment.cpp | 176 -- .../source/ams/ams_exosphere_api.cpp | 75 - .../source/boot2/boot2_api.cpp | 349 ---- .../libstratosphere/source/cfg/cfg_flags.cpp | 72 - .../source/cfg/cfg_override.cpp | 308 --- .../source/cfg/cfg_privileged_process.cpp | 87 - .../source/cfg/cfg_sd_card.cpp | 97 - .../source/dd/dd_io_mappings.cpp | 55 - .../libstratosphere/source/dmnt/dmntcht.c | 167 -- .../libstratosphere/source/dmnt/dmntcht.h | 93 - .../source/fs/fs_file_storage.cpp | 93 - .../source/fs/fs_path_tool.cpp | 248 --- .../source/fs/fs_path_utils.cpp | 47 - .../fssrv_filesystem_interface_adapter.cpp | 343 --- .../source/fssrv/fssrv_path_normalizer.cpp | 77 - .../fssrv/fssrv_storage_interface_adapter.cpp | 94 - ...ystem_directory_redirection_filesystem.cpp | 119 -- ...fssystem_directory_savedata_filesystem.cpp | 272 --- .../fssystem_subdirectory_filesystem.cpp | 82 - .../source/fssystem/fssystem_utility.cpp | 118 -- .../libstratosphere/source/hid/hid_api.cpp | 66 - .../source/hos/hos_version_api.cpp | 147 -- .../source/kvdb/kvdb_archive.cpp | 168 -- .../source/kvdb/kvdb_file_key_value_store.cpp | 318 --- .../libstratosphere/source/ldr/ldr_ams.c | 48 - .../libstratosphere/source/ldr/ldr_ams.h | 27 - .../libstratosphere/source/ldr/ldr_pm_api.cpp | 54 - .../libstratosphere/source/map/map_api.cpp | 236 --- .../source/os/impl/os_inter_process_event.cpp | 179 -- .../source/os/impl/os_inter_process_event.hpp | 54 - .../os/impl/os_waitable_holder_base.hpp | 77 - .../os/impl/os_waitable_holder_impl.hpp | 56 - .../os/impl/os_waitable_holder_of_event.hpp | 52 - .../os/impl/os_waitable_holder_of_handle.hpp | 37 - ...waitable_holder_of_inter_process_event.hpp | 39 - .../os_waitable_holder_of_interrupt_event.hpp | 38 - .../os_waitable_holder_of_message_queue.hpp | 75 - .../impl/os_waitable_holder_of_semaphore.hpp | 52 - .../os/impl/os_waitable_holder_of_thread.hpp | 39 - .../os/impl/os_waitable_manager_impl.cpp | 177 -- .../os/impl/os_waitable_manager_impl.hpp | 94 - .../os/impl/os_waitable_object_list.hpp | 53 - .../libstratosphere/source/os/os_event.cpp | 105 - .../source/os/os_interrupt_event.cpp | 111 - .../source/os/os_message_queue.cpp | 247 --- .../source/os/os_process_handle.cpp | 44 - .../source/os/os_semaphore.cpp | 85 - .../source/os/os_system_event.cpp | 188 -- .../source/os/os_waitable_holder.cpp | 116 - .../source/os/os_waitable_manager.cpp | 88 - .../source/patcher/patcher_api.cpp | 235 --- .../libstratosphere/source/pm/pm_ams.c | 92 - .../libstratosphere/source/pm/pm_ams.h | 28 - .../source/pm/pm_boot_mode_api.cpp | 32 - .../libstratosphere/source/pm/pm_dmnt_api.cpp | 56 - .../libstratosphere/source/pm/pm_info_api.cpp | 93 - .../source/pm/pm_shell_api.cpp | 27 - .../source/result/result_on_assertion.cpp | 37 - .../libstratosphere/source/rnd/rnd_api.cpp | 129 -- .../libstratosphere/source/service_guard.h | 64 - .../source/settings/settings_fwdbg_api.cpp | 35 - .../source/sf/cmif/sf_cmif_domain_manager.cpp | 158 -- .../sf/cmif/sf_cmif_domain_service_object.cpp | 220 -- .../sf/cmif/sf_cmif_service_dispatch.cpp | 107 - .../sf/cmif/sf_cmif_service_object_holder.cpp | 26 - .../source/sf/hipc/sf_hipc_api.cpp | 86 - .../source/sf/hipc/sf_hipc_mitm_query_api.cpp | 78 - .../source/sf/hipc/sf_hipc_mitm_query_api.hpp | 23 - .../sf_hipc_server_domain_session_manager.cpp | 174 -- .../source/sf/hipc/sf_hipc_server_manager.cpp | 225 -- .../hipc/sf_hipc_server_session_manager.cpp | 303 --- .../libstratosphere/source/sm/sm_ams.c | 131 -- .../libstratosphere/source/sm/sm_ams.h | 35 - .../libstratosphere/source/sm/sm_api.cpp | 63 - .../source/sm/sm_manager_api.cpp | 40 - .../libstratosphere/source/sm/sm_mitm_api.cpp | 57 - .../libstratosphere/source/sm/sm_utils.cpp | 42 - .../libstratosphere/source/sm/sm_utils.hpp | 70 - .../libstratosphere/source/sm/smm_ams.c | 49 - .../libstratosphere/source/sm/smm_ams.h | 25 - .../source/spl/smc/spl_smc.cpp | 378 ---- .../libstratosphere/source/spl/spl_api.cpp | 75 - .../source/updater/updater_api.cpp | 530 ----- .../source/updater/updater_bis_management.cpp | 149 -- .../source/updater/updater_bis_management.hpp | 235 --- .../source/updater/updater_bis_save.cpp | 62 - .../source/updater/updater_bis_save.hpp | 42 - .../source/updater/updater_files.cpp | 68 - .../source/updater/updater_files.hpp | 25 - .../source/updater/updater_paths.cpp | 110 - .../source/updater/updater_paths.hpp | 27 - .../libstratosphere/source/util/ini.c | 269 --- .../libstratosphere/source/util/ini.h | 130 -- .../libstratosphere/source/util/lz4.c | 1857 ----------------- .../libstratosphere/source/util/lz4.h | 569 ----- .../source/util/util_compression.cpp | 41 - .../libstratosphere/source/util/util_ini.cpp | 91 - stratosphere/loader/Makefile | 95 +- stratosphere/pm/Makefile | 95 +- stratosphere/ro/Makefile | 95 +- stratosphere/sm/Makefile | 96 +- stratosphere/spl/Makefile | 95 +- 338 files changed, 293 insertions(+), 30662 deletions(-) delete mode 100644 common/include/atmosphere.h delete mode 100644 common/include/atmosphere/target_fw.h delete mode 100644 common/include/atmosphere/version.h rename {common/defaults => config_templates}/BCT.ini (100%) rename {common/defaults => config_templates}/hbl_html/accessible-urls/accessible-urls.txt (100%) rename {common/defaults => config_templates}/kip_patches/default_nogc/02D5ABAAFD20C8B0633AA0DBAEE0377EF526CE6AD2AC6F2CAD7180CE69E74311.ips (100%) rename {common/defaults => config_templates}/kip_patches/default_nogc/06E90719595A010C6246FF70946F10FB367A00BBD8B7D8D1F25CCE0B458D7E89.ips (100%) rename {common/defaults => config_templates}/kip_patches/default_nogc/10B2D81605488599DF2242CB6BAC2DF1E2BCAB3BC19DC5CD63DB6FAEC0947097.ips (100%) rename {common/defaults => config_templates}/kip_patches/default_nogc/2ADBE97E9B5F41779EC95FFE2699C93305D6A69D465CF597D67465CD69BACCE8.ips (100%) rename {common/defaults => config_templates}/kip_patches/default_nogc/2CCE659CEC536A8E4D91F3BE4B74BED302613F1E442581FD863708E39112DB50.ips (100%) rename {common/defaults => config_templates}/kip_patches/default_nogc/330553F6B5FB55C4C2D7B736240276B3EAD664DA79826FA936F99803B6C28F3B.ips (100%) rename {common/defaults => config_templates}/kip_patches/default_nogc/3A574D436186191D1788EB2C0F076B11737132EBB1484CF906B6A8EB3B1BF459.ips (100%) rename {common/defaults => config_templates}/kip_patches/default_nogc/468740761E193EB758794688F1D9F762CBA1185ADDAD4EC3C479EC8FBFEC31DD.ips (100%) rename {common/defaults => config_templates}/kip_patches/default_nogc/549B0F8D6F72C4E9F3FD1F19EACE4A5A1DA2D5C393F74224F8BC09DE4AAA4217.ips (100%) rename {common/defaults => config_templates}/kip_patches/default_nogc/6B09B67B29C020246DC34F5A04F5D3090215C46F37BD079442977A85B8243BA5.ips (100%) rename {common/defaults => config_templates}/kip_patches/default_nogc/76F87402C9387C0F0A2FAB1B45CEBB93E3E9695C7CFD390F00509B1204101C24.ips (100%) rename {common/defaults => config_templates}/kip_patches/default_nogc/7C951376E5C12DF85FA6A9F46F6957A4B1271C1F8201B99735D8DF152E7913F1.ips (100%) rename {common/defaults => config_templates}/kip_patches/default_nogc/8096AF7C6A35AA8271F3916995413B0B64CE03BD9BBFEB26F2B3E01C5427C69E.ips (100%) rename {common/defaults => config_templates}/kip_patches/default_nogc/A6F27AD9AC7C73AD419B63B23E785A0CD7AA9DC1A63C57D10049423DE7B77E2C.ips (100%) rename {common/defaults => config_templates}/kip_patches/default_nogc/B2F5176B3548364D079A29B141A23B06AFFF5A98055576D5F337A621C0233CE3.ips (100%) rename {common/defaults => config_templates}/kip_patches/default_nogc/B4CAE1F24965D92ED24EBE9E97F609C363834471BF18CA375CB6A1DEB77755EA.ips (100%) rename {common/defaults => config_templates}/kip_patches/default_nogc/B5E7A64C6F5C4FE319C36FD7D642F75B0159771671F73082448ACE30BD6BAE89.ips (100%) rename {common/defaults => config_templates}/kip_patches/default_nogc/CE3ECBA2F2F062F575F8F360842B32B432340DD2C7590CDEFC03E51B844AE805.ips (100%) rename {common/defaults => config_templates}/kip_patches/default_nogc/DBD941C0C53C52CCF7202C84D8E0F78013A3684D8AB5D128096674A8F7755B3D.ips (100%) rename {common/defaults => config_templates}/kip_patches/default_nogc/F196D144D04445B6E7497CB6405B7FC305B54F961024BF432575296E4D52BC99.ips (100%) rename {common/defaults => config_templates}/override_config.ini (100%) rename {common/defaults => config_templates}/system_settings.ini (100%) delete mode 100644 stratosphere/libstratosphere/.gitignore delete mode 100644 stratosphere/libstratosphere/.gitmodules delete mode 100644 stratosphere/libstratosphere/.gitrepo delete mode 100644 stratosphere/libstratosphere/LICENSE delete mode 100644 stratosphere/libstratosphere/Makefile delete mode 100644 stratosphere/libstratosphere/README.md delete mode 100644 stratosphere/libstratosphere/include/atmosphere/common.hpp delete mode 100644 stratosphere/libstratosphere/include/atmosphere/common_includes.hpp delete mode 100644 stratosphere/libstratosphere/include/atmosphere/defines.hpp delete mode 100644 stratosphere/libstratosphere/include/atmosphere/results.hpp delete mode 100644 stratosphere/libstratosphere/include/atmosphere/results/cal_results.hpp delete mode 100644 stratosphere/libstratosphere/include/atmosphere/results/creport_results.hpp delete mode 100644 stratosphere/libstratosphere/include/atmosphere/results/debug_results.hpp delete mode 100644 stratosphere/libstratosphere/include/atmosphere/results/dmnt_results.hpp delete mode 100644 stratosphere/libstratosphere/include/atmosphere/results/err_results.hpp delete mode 100644 stratosphere/libstratosphere/include/atmosphere/results/exosphere_results.hpp delete mode 100644 stratosphere/libstratosphere/include/atmosphere/results/fatal_results.hpp delete mode 100644 stratosphere/libstratosphere/include/atmosphere/results/fs_results.hpp delete mode 100644 stratosphere/libstratosphere/include/atmosphere/results/hipc_results.hpp delete mode 100644 stratosphere/libstratosphere/include/atmosphere/results/i2c_results.hpp delete mode 100644 stratosphere/libstratosphere/include/atmosphere/results/kvdb_results.hpp delete mode 100644 stratosphere/libstratosphere/include/atmosphere/results/loader_results.hpp delete mode 100644 stratosphere/libstratosphere/include/atmosphere/results/lr_results.hpp delete mode 100644 stratosphere/libstratosphere/include/atmosphere/results/ncm_results.hpp delete mode 100644 stratosphere/libstratosphere/include/atmosphere/results/os_results.hpp delete mode 100644 stratosphere/libstratosphere/include/atmosphere/results/pm_results.hpp delete mode 100644 stratosphere/libstratosphere/include/atmosphere/results/results_common.hpp delete mode 100644 stratosphere/libstratosphere/include/atmosphere/results/ro_results.hpp delete mode 100644 stratosphere/libstratosphere/include/atmosphere/results/settings_results.hpp delete mode 100644 stratosphere/libstratosphere/include/atmosphere/results/sf_results.hpp delete mode 100644 stratosphere/libstratosphere/include/atmosphere/results/sm_results.hpp delete mode 100644 stratosphere/libstratosphere/include/atmosphere/results/spl_results.hpp delete mode 100644 stratosphere/libstratosphere/include/atmosphere/results/svc_results.hpp delete mode 100644 stratosphere/libstratosphere/include/atmosphere/results/updater_results.hpp delete mode 100644 stratosphere/libstratosphere/include/atmosphere/results/vi_results.hpp delete mode 100644 stratosphere/libstratosphere/include/atmosphere/svc.hpp delete mode 100644 stratosphere/libstratosphere/include/atmosphere/svc/svc_types.hpp delete mode 100644 stratosphere/libstratosphere/include/atmosphere/util.hpp delete mode 100644 stratosphere/libstratosphere/include/atmosphere/util/util_alignment.hpp delete mode 100644 stratosphere/libstratosphere/include/atmosphere/util/util_compression.hpp delete mode 100644 stratosphere/libstratosphere/include/atmosphere/util/util_ini.hpp delete mode 100644 stratosphere/libstratosphere/include/atmosphere/util/util_intrusive_list.hpp delete mode 100644 stratosphere/libstratosphere/include/atmosphere/util/util_intrusive_red_black_tree.hpp delete mode 100644 stratosphere/libstratosphere/include/atmosphere/util/util_parent_of_member.hpp delete mode 100644 stratosphere/libstratosphere/include/atmosphere/util/util_scope_guard.hpp delete mode 100644 stratosphere/libstratosphere/include/atmosphere/util/util_size.hpp delete mode 100644 stratosphere/libstratosphere/include/atmosphere/util/util_typed_storage.hpp delete mode 100644 stratosphere/libstratosphere/include/freebsd/sys/tree.h delete mode 100644 stratosphere/libstratosphere/include/stratosphere.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/ams.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/ams/ams_emummc_api.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/ams/ams_environment.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/ams/ams_exosphere_api.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/ams/ams_types.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/boot2.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/boot2/boot2_api.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/cfg.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/cfg/cfg_api.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/cfg/cfg_locale_types.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/cfg/cfg_types.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/dd.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/dd/dd_io_mappings.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/dd/dd_process_handle.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/dmnt.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/dmnt/dmnt_cheat_types.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/fatal.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/fatal/fatal_types.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/fs.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/fs/fs_common.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/fs/fs_directory.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/fs/fs_file.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/fs/fs_file_storage.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/fs/fs_filesystem.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/fs/fs_istorage.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/fs/fs_operate_range.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/fs/fs_path_tool.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/fs/fs_path_utils.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/fs/fs_query_range.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/fs/fs_remote_filesystem.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/fs/fs_remote_storage.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/fs/fsa/fs_idirectory.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/fs/fsa/fs_ifile.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/fs/fsa/fs_ifilesystem.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/fssrv.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/fssrv/fssrv_interface_adapters.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/fssrv/fssrv_path_normalizer.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/fssrv/fssrv_sf_path.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/fssrv/interface_adapters/fssrv_filesystem_interface_adapter.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/fssrv/interface_adapters/fssrv_storage_interface_adapter.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/fssystem.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/fssystem/fssystem_directory_redirection_filesystem.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/fssystem/fssystem_directory_savedata_filesystem.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/fssystem/fssystem_path_tool.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/fssystem/fssystem_subdirectory_filesystem.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/fssystem/fssystem_utility.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/fssystem/impl/fssystem_path_resolution_filesystem.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/hid.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/hid/hid_api.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/hos.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/hos/hos_types.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/hos/hos_version_api.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/kvdb.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/kvdb/kvdb_archive.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/kvdb/kvdb_auto_buffer.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/kvdb/kvdb_bounded_string.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/kvdb/kvdb_file_key_value_cache.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/kvdb/kvdb_file_key_value_store.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/kvdb/kvdb_memory_key_value_store.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/ldr.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/ldr/ldr_pm_api.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/ldr/ldr_types.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/map.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/map/map_api.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/map/map_types.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/ncm.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/ncm/ncm_types.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/os.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/os/os_common_types.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/os/os_condvar.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/os/os_event.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/os/os_interrupt_event.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/os/os_managed_handle.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/os/os_memory_common.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/os/os_message_queue.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/os/os_mutex.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/os/os_process_handle.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/os/os_rw_lock.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/os/os_semaphore.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/os/os_system_event.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/os/os_thread.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/os/os_timeout_helper.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/os/os_waitable_holder.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/os/os_waitable_manager.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/patcher.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/patcher/patcher_api.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/pm.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/pm/pm_boot_mode_api.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/pm/pm_dmnt_api.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/pm/pm_info_api.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/pm/pm_shell_api.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/pm/pm_types.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/reg.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/rnd.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/rnd/rnd_api.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/ro.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/ro/ro_types.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/settings.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/settings/settings_fwdbg_api.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/settings/settings_fwdbg_types.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/settings/settings_types.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/sf.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_domain_api.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_domain_manager.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_domain_service_object.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_pointer_and_size.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_server_message_processor.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_service_dispatch.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_service_object_holder.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/sf/hipc/sf_hipc_api.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/sf/hipc/sf_hipc_server_domain_session_manager.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/sf/hipc/sf_hipc_server_manager.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/sf/hipc/sf_hipc_server_session_manager.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/sf/impl/sf_impl_command_serialization.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/sf/sf_buffer_tags.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/sf/sf_buffers.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/sf/sf_common.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/sf/sf_handles.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/sf/sf_mitm_dispatch.h delete mode 100644 stratosphere/libstratosphere/include/stratosphere/sf/sf_out.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/sf/sf_service_object.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/sm.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/sm/sm_api.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/sm/sm_manager_api.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/sm/sm_mitm_api.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/sm/sm_scoped_holder.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/sm/sm_types.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/spl.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/spl/smc/spl_smc.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/spl/spl_api.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/spl/spl_types.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/updater.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/updater/updater_api.hpp delete mode 100644 stratosphere/libstratosphere/include/stratosphere/updater/updater_types.hpp delete mode 100644 stratosphere/libstratosphere/source/ams/ams_bpc.c delete mode 100644 stratosphere/libstratosphere/source/ams/ams_bpc.h delete mode 100644 stratosphere/libstratosphere/source/ams/ams_emummc_api.cpp delete mode 100644 stratosphere/libstratosphere/source/ams/ams_environment.cpp delete mode 100644 stratosphere/libstratosphere/source/ams/ams_exosphere_api.cpp delete mode 100644 stratosphere/libstratosphere/source/boot2/boot2_api.cpp delete mode 100644 stratosphere/libstratosphere/source/cfg/cfg_flags.cpp delete mode 100644 stratosphere/libstratosphere/source/cfg/cfg_override.cpp delete mode 100644 stratosphere/libstratosphere/source/cfg/cfg_privileged_process.cpp delete mode 100644 stratosphere/libstratosphere/source/cfg/cfg_sd_card.cpp delete mode 100644 stratosphere/libstratosphere/source/dd/dd_io_mappings.cpp delete mode 100644 stratosphere/libstratosphere/source/dmnt/dmntcht.c delete mode 100644 stratosphere/libstratosphere/source/dmnt/dmntcht.h delete mode 100644 stratosphere/libstratosphere/source/fs/fs_file_storage.cpp delete mode 100644 stratosphere/libstratosphere/source/fs/fs_path_tool.cpp delete mode 100644 stratosphere/libstratosphere/source/fs/fs_path_utils.cpp delete mode 100644 stratosphere/libstratosphere/source/fssrv/fssrv_filesystem_interface_adapter.cpp delete mode 100644 stratosphere/libstratosphere/source/fssrv/fssrv_path_normalizer.cpp delete mode 100644 stratosphere/libstratosphere/source/fssrv/fssrv_storage_interface_adapter.cpp delete mode 100644 stratosphere/libstratosphere/source/fssystem/fssystem_directory_redirection_filesystem.cpp delete mode 100644 stratosphere/libstratosphere/source/fssystem/fssystem_directory_savedata_filesystem.cpp delete mode 100644 stratosphere/libstratosphere/source/fssystem/fssystem_subdirectory_filesystem.cpp delete mode 100644 stratosphere/libstratosphere/source/fssystem/fssystem_utility.cpp delete mode 100644 stratosphere/libstratosphere/source/hid/hid_api.cpp delete mode 100644 stratosphere/libstratosphere/source/hos/hos_version_api.cpp delete mode 100644 stratosphere/libstratosphere/source/kvdb/kvdb_archive.cpp delete mode 100644 stratosphere/libstratosphere/source/kvdb/kvdb_file_key_value_store.cpp delete mode 100644 stratosphere/libstratosphere/source/ldr/ldr_ams.c delete mode 100644 stratosphere/libstratosphere/source/ldr/ldr_ams.h delete mode 100644 stratosphere/libstratosphere/source/ldr/ldr_pm_api.cpp delete mode 100644 stratosphere/libstratosphere/source/map/map_api.cpp delete mode 100644 stratosphere/libstratosphere/source/os/impl/os_inter_process_event.cpp delete mode 100644 stratosphere/libstratosphere/source/os/impl/os_inter_process_event.hpp delete mode 100644 stratosphere/libstratosphere/source/os/impl/os_waitable_holder_base.hpp delete mode 100644 stratosphere/libstratosphere/source/os/impl/os_waitable_holder_impl.hpp delete mode 100644 stratosphere/libstratosphere/source/os/impl/os_waitable_holder_of_event.hpp delete mode 100644 stratosphere/libstratosphere/source/os/impl/os_waitable_holder_of_handle.hpp delete mode 100644 stratosphere/libstratosphere/source/os/impl/os_waitable_holder_of_inter_process_event.hpp delete mode 100644 stratosphere/libstratosphere/source/os/impl/os_waitable_holder_of_interrupt_event.hpp delete mode 100644 stratosphere/libstratosphere/source/os/impl/os_waitable_holder_of_message_queue.hpp delete mode 100644 stratosphere/libstratosphere/source/os/impl/os_waitable_holder_of_semaphore.hpp delete mode 100644 stratosphere/libstratosphere/source/os/impl/os_waitable_holder_of_thread.hpp delete mode 100644 stratosphere/libstratosphere/source/os/impl/os_waitable_manager_impl.cpp delete mode 100644 stratosphere/libstratosphere/source/os/impl/os_waitable_manager_impl.hpp delete mode 100644 stratosphere/libstratosphere/source/os/impl/os_waitable_object_list.hpp delete mode 100644 stratosphere/libstratosphere/source/os/os_event.cpp delete mode 100644 stratosphere/libstratosphere/source/os/os_interrupt_event.cpp delete mode 100644 stratosphere/libstratosphere/source/os/os_message_queue.cpp delete mode 100644 stratosphere/libstratosphere/source/os/os_process_handle.cpp delete mode 100644 stratosphere/libstratosphere/source/os/os_semaphore.cpp delete mode 100644 stratosphere/libstratosphere/source/os/os_system_event.cpp delete mode 100644 stratosphere/libstratosphere/source/os/os_waitable_holder.cpp delete mode 100644 stratosphere/libstratosphere/source/os/os_waitable_manager.cpp delete mode 100644 stratosphere/libstratosphere/source/patcher/patcher_api.cpp delete mode 100644 stratosphere/libstratosphere/source/pm/pm_ams.c delete mode 100644 stratosphere/libstratosphere/source/pm/pm_ams.h delete mode 100644 stratosphere/libstratosphere/source/pm/pm_boot_mode_api.cpp delete mode 100644 stratosphere/libstratosphere/source/pm/pm_dmnt_api.cpp delete mode 100644 stratosphere/libstratosphere/source/pm/pm_info_api.cpp delete mode 100644 stratosphere/libstratosphere/source/pm/pm_shell_api.cpp delete mode 100644 stratosphere/libstratosphere/source/result/result_on_assertion.cpp delete mode 100644 stratosphere/libstratosphere/source/rnd/rnd_api.cpp delete mode 100644 stratosphere/libstratosphere/source/service_guard.h delete mode 100644 stratosphere/libstratosphere/source/settings/settings_fwdbg_api.cpp delete mode 100644 stratosphere/libstratosphere/source/sf/cmif/sf_cmif_domain_manager.cpp delete mode 100644 stratosphere/libstratosphere/source/sf/cmif/sf_cmif_domain_service_object.cpp delete mode 100644 stratosphere/libstratosphere/source/sf/cmif/sf_cmif_service_dispatch.cpp delete mode 100644 stratosphere/libstratosphere/source/sf/cmif/sf_cmif_service_object_holder.cpp delete mode 100644 stratosphere/libstratosphere/source/sf/hipc/sf_hipc_api.cpp delete mode 100644 stratosphere/libstratosphere/source/sf/hipc/sf_hipc_mitm_query_api.cpp delete mode 100644 stratosphere/libstratosphere/source/sf/hipc/sf_hipc_mitm_query_api.hpp delete mode 100644 stratosphere/libstratosphere/source/sf/hipc/sf_hipc_server_domain_session_manager.cpp delete mode 100644 stratosphere/libstratosphere/source/sf/hipc/sf_hipc_server_manager.cpp delete mode 100644 stratosphere/libstratosphere/source/sf/hipc/sf_hipc_server_session_manager.cpp delete mode 100644 stratosphere/libstratosphere/source/sm/sm_ams.c delete mode 100644 stratosphere/libstratosphere/source/sm/sm_ams.h delete mode 100644 stratosphere/libstratosphere/source/sm/sm_api.cpp delete mode 100644 stratosphere/libstratosphere/source/sm/sm_manager_api.cpp delete mode 100644 stratosphere/libstratosphere/source/sm/sm_mitm_api.cpp delete mode 100644 stratosphere/libstratosphere/source/sm/sm_utils.cpp delete mode 100644 stratosphere/libstratosphere/source/sm/sm_utils.hpp delete mode 100644 stratosphere/libstratosphere/source/sm/smm_ams.c delete mode 100644 stratosphere/libstratosphere/source/sm/smm_ams.h delete mode 100644 stratosphere/libstratosphere/source/spl/smc/spl_smc.cpp delete mode 100644 stratosphere/libstratosphere/source/spl/spl_api.cpp delete mode 100644 stratosphere/libstratosphere/source/updater/updater_api.cpp delete mode 100644 stratosphere/libstratosphere/source/updater/updater_bis_management.cpp delete mode 100644 stratosphere/libstratosphere/source/updater/updater_bis_management.hpp delete mode 100644 stratosphere/libstratosphere/source/updater/updater_bis_save.cpp delete mode 100644 stratosphere/libstratosphere/source/updater/updater_bis_save.hpp delete mode 100644 stratosphere/libstratosphere/source/updater/updater_files.cpp delete mode 100644 stratosphere/libstratosphere/source/updater/updater_files.hpp delete mode 100644 stratosphere/libstratosphere/source/updater/updater_paths.cpp delete mode 100644 stratosphere/libstratosphere/source/updater/updater_paths.hpp delete mode 100644 stratosphere/libstratosphere/source/util/ini.c delete mode 100644 stratosphere/libstratosphere/source/util/ini.h delete mode 100644 stratosphere/libstratosphere/source/util/lz4.c delete mode 100644 stratosphere/libstratosphere/source/util/lz4.h delete mode 100644 stratosphere/libstratosphere/source/util/util_compression.cpp delete mode 100644 stratosphere/libstratosphere/source/util/util_ini.cpp diff --git a/.gitattributes b/.gitattributes index 96476bd0a..9b4bbb4f5 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1 +1 @@ -common/defaults/hbl_html/accessible-urls/accessible-urls.txt text eol=lf +config_templates/hbl_html/accessible-urls/accessible-urls.txt text eol=lf diff --git a/Makefile b/Makefile index 5c4d7d446..37b6ed48b 100644 --- a/Makefile +++ b/Makefile @@ -34,13 +34,13 @@ clean: rm -rf out dist: all - $(eval MAJORVER = $(shell grep '\ATMOSPHERE_RELEASE_VERSION_MAJOR\b' common/include/atmosphere/version.h \ + $(eval MAJORVER = $(shell grep 'define ATMOSPHERE_RELEASE_VERSION_MAJOR\b' libraries/libvapours/include/vapours/ams/ams_api_version.h \ | tr -s [:blank:] \ | cut -d' ' -f3)) - $(eval MINORVER = $(shell grep '\ATMOSPHERE_RELEASE_VERSION_MINOR\b' common/include/atmosphere/version.h \ + $(eval MINORVER = $(shell grep 'define ATMOSPHERE_RELEASE_VERSION_MINOR\b' libraries/libvapours/include/vapours/ams/ams_api_version.h \ | tr -s [:blank:] \ | cut -d' ' -f3)) - $(eval MICROVER = $(shell grep '\ATMOSPHERE_RELEASE_VERSION_MICRO\b' common/include/atmosphere/version.h \ + $(eval MICROVER = $(shell grep 'define ATMOSPHERE_RELEASE_VERSION_MICRO\b' libraries/libvapours/include/vapours/ams/ams_api_version.h \ | tr -s [:blank:] \ | cut -d' ' -f3)) $(eval AMSVER = $(MAJORVER).$(MINORVER).$(MICROVER)-$(AMSREV)) @@ -67,11 +67,11 @@ dist: all cp sept/sept-secondary/sept-secondary.bin atmosphere-$(AMSVER)/sept/sept-secondary.bin cp sept/sept-secondary/sept-secondary_00.enc atmosphere-$(AMSVER)/sept/sept-secondary_00.enc cp sept/sept-secondary/sept-secondary_01.enc atmosphere-$(AMSVER)/sept/sept-secondary_01.enc - cp common/defaults/BCT.ini atmosphere-$(AMSVER)/atmosphere/config/BCT.ini - cp common/defaults/override_config.ini atmosphere-$(AMSVER)/atmosphere/config_templates/override_config.ini - cp common/defaults/system_settings.ini atmosphere-$(AMSVER)/atmosphere/config_templates/system_settings.ini - cp -r common/defaults/kip_patches atmosphere-$(AMSVER)/atmosphere/kip_patches - cp -r common/defaults/hbl_html atmosphere-$(AMSVER)/atmosphere/hbl_html + cp config_templates/BCT.ini atmosphere-$(AMSVER)/atmosphere/config/BCT.ini + cp config_templates/override_config.ini atmosphere-$(AMSVER)/atmosphere/config_templates/override_config.ini + cp config_templates/system_settings.ini atmosphere-$(AMSVER)/atmosphere/config_templates/system_settings.ini + cp -r config_templates/kip_patches atmosphere-$(AMSVER)/atmosphere/kip_patches + cp -r config_templates/hbl_html atmosphere-$(AMSVER)/atmosphere/hbl_html cp stratosphere/boot2/boot2.nsp atmosphere-$(AMSVER)/atmosphere/contents/0100000000000008/exefs.nsp cp stratosphere/dmnt/dmnt.nsp atmosphere-$(AMSVER)/atmosphere/contents/010000000000000D/exefs.nsp cp stratosphere/eclct.stub/eclct.stub.nsp atmosphere-$(AMSVER)/atmosphere/contents/0100000000000032/exefs.nsp diff --git a/common/include/atmosphere.h b/common/include/atmosphere.h deleted file mode 100644 index f2080a76b..000000000 --- a/common/include/atmosphere.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2018-2019 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 . - */ - -#ifndef ATMOSPHERE_H -#define ATMOSPHERE_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include "atmosphere/version.h" -#include "atmosphere/target_fw.h" - -#ifdef __cplusplus -} -#endif - -#endif \ No newline at end of file diff --git a/common/include/atmosphere/target_fw.h b/common/include/atmosphere/target_fw.h deleted file mode 100644 index 8628272b9..000000000 --- a/common/include/atmosphere/target_fw.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2018-2019 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 . - */ - -#ifndef ATMOSPHERE_TARGET_FIRMWARE_H -#define ATMOSPHERE_TARGET_FIRMWARE_H - -#define ATMOSPHERE_TARGET_FIRMWARE_100 1 -#define ATMOSPHERE_TARGET_FIRMWARE_200 2 -#define ATMOSPHERE_TARGET_FIRMWARE_300 3 -#define ATMOSPHERE_TARGET_FIRMWARE_400 4 -#define ATMOSPHERE_TARGET_FIRMWARE_500 5 -#define ATMOSPHERE_TARGET_FIRMWARE_600 6 -#define ATMOSPHERE_TARGET_FIRMWARE_620 7 -#define ATMOSPHERE_TARGET_FIRMWARE_700 8 -#define ATMOSPHERE_TARGET_FIRMWARE_800 9 -#define ATMOSPHERE_TARGET_FIRMWARE_810 10 -#define ATMOSPHERE_TARGET_FIRMWARE_900 11 -#define ATMOSPHERE_TARGET_FIRMWARE_910 12 - -#define ATMOSPHERE_TARGET_FIRMWARE_CURRENT ATMOSPHERE_TARGET_FIRMWARE_910 - -#define ATMOSPHERE_TARGET_FIRMWARE_MIN ATMOSPHERE_TARGET_FIRMWARE_100 -#define ATMOSPHERE_TARGET_FIRMWARE_MAX ATMOSPHERE_TARGET_FIRMWARE_910 - -/* TODO: What should this be, for release? */ -#define ATMOSPHERE_TARGET_FIRMWARE_DEFAULT_FOR_DEBUG ATMOSPHERE_TARGET_FIRMWARE_CURRENT - -#endif \ No newline at end of file diff --git a/common/include/atmosphere/version.h b/common/include/atmosphere/version.h deleted file mode 100644 index 70545ef7e..000000000 --- a/common/include/atmosphere/version.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2018-2019 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 . - */ - -#ifndef ATMOSPHERE_VERSION_H -#define ATMOSPHERE_VERSION_H - -#define ATMOSPHERE_RELEASE_VERSION_MAJOR 0 -#define ATMOSPHERE_RELEASE_VERSION_MINOR 10 -#define ATMOSPHERE_RELEASE_VERSION_MICRO 0 - -#define ATMOSPHERE_SUPPORTED_HOS_VERSION_MAJOR 9 -#define ATMOSPHERE_SUPPORTED_HOS_VERSION_MINOR 1 -#define ATMOSPHERE_SUPPORTED_HOS_VERSION_MICRO 0 - -#endif \ No newline at end of file diff --git a/common/defaults/BCT.ini b/config_templates/BCT.ini similarity index 100% rename from common/defaults/BCT.ini rename to config_templates/BCT.ini diff --git a/common/defaults/hbl_html/accessible-urls/accessible-urls.txt b/config_templates/hbl_html/accessible-urls/accessible-urls.txt similarity index 100% rename from common/defaults/hbl_html/accessible-urls/accessible-urls.txt rename to config_templates/hbl_html/accessible-urls/accessible-urls.txt diff --git a/common/defaults/kip_patches/default_nogc/02D5ABAAFD20C8B0633AA0DBAEE0377EF526CE6AD2AC6F2CAD7180CE69E74311.ips b/config_templates/kip_patches/default_nogc/02D5ABAAFD20C8B0633AA0DBAEE0377EF526CE6AD2AC6F2CAD7180CE69E74311.ips similarity index 100% rename from common/defaults/kip_patches/default_nogc/02D5ABAAFD20C8B0633AA0DBAEE0377EF526CE6AD2AC6F2CAD7180CE69E74311.ips rename to config_templates/kip_patches/default_nogc/02D5ABAAFD20C8B0633AA0DBAEE0377EF526CE6AD2AC6F2CAD7180CE69E74311.ips diff --git a/common/defaults/kip_patches/default_nogc/06E90719595A010C6246FF70946F10FB367A00BBD8B7D8D1F25CCE0B458D7E89.ips b/config_templates/kip_patches/default_nogc/06E90719595A010C6246FF70946F10FB367A00BBD8B7D8D1F25CCE0B458D7E89.ips similarity index 100% rename from common/defaults/kip_patches/default_nogc/06E90719595A010C6246FF70946F10FB367A00BBD8B7D8D1F25CCE0B458D7E89.ips rename to config_templates/kip_patches/default_nogc/06E90719595A010C6246FF70946F10FB367A00BBD8B7D8D1F25CCE0B458D7E89.ips diff --git a/common/defaults/kip_patches/default_nogc/10B2D81605488599DF2242CB6BAC2DF1E2BCAB3BC19DC5CD63DB6FAEC0947097.ips b/config_templates/kip_patches/default_nogc/10B2D81605488599DF2242CB6BAC2DF1E2BCAB3BC19DC5CD63DB6FAEC0947097.ips similarity index 100% rename from common/defaults/kip_patches/default_nogc/10B2D81605488599DF2242CB6BAC2DF1E2BCAB3BC19DC5CD63DB6FAEC0947097.ips rename to config_templates/kip_patches/default_nogc/10B2D81605488599DF2242CB6BAC2DF1E2BCAB3BC19DC5CD63DB6FAEC0947097.ips diff --git a/common/defaults/kip_patches/default_nogc/2ADBE97E9B5F41779EC95FFE2699C93305D6A69D465CF597D67465CD69BACCE8.ips b/config_templates/kip_patches/default_nogc/2ADBE97E9B5F41779EC95FFE2699C93305D6A69D465CF597D67465CD69BACCE8.ips similarity index 100% rename from common/defaults/kip_patches/default_nogc/2ADBE97E9B5F41779EC95FFE2699C93305D6A69D465CF597D67465CD69BACCE8.ips rename to config_templates/kip_patches/default_nogc/2ADBE97E9B5F41779EC95FFE2699C93305D6A69D465CF597D67465CD69BACCE8.ips diff --git a/common/defaults/kip_patches/default_nogc/2CCE659CEC536A8E4D91F3BE4B74BED302613F1E442581FD863708E39112DB50.ips b/config_templates/kip_patches/default_nogc/2CCE659CEC536A8E4D91F3BE4B74BED302613F1E442581FD863708E39112DB50.ips similarity index 100% rename from common/defaults/kip_patches/default_nogc/2CCE659CEC536A8E4D91F3BE4B74BED302613F1E442581FD863708E39112DB50.ips rename to config_templates/kip_patches/default_nogc/2CCE659CEC536A8E4D91F3BE4B74BED302613F1E442581FD863708E39112DB50.ips diff --git a/common/defaults/kip_patches/default_nogc/330553F6B5FB55C4C2D7B736240276B3EAD664DA79826FA936F99803B6C28F3B.ips b/config_templates/kip_patches/default_nogc/330553F6B5FB55C4C2D7B736240276B3EAD664DA79826FA936F99803B6C28F3B.ips similarity index 100% rename from common/defaults/kip_patches/default_nogc/330553F6B5FB55C4C2D7B736240276B3EAD664DA79826FA936F99803B6C28F3B.ips rename to config_templates/kip_patches/default_nogc/330553F6B5FB55C4C2D7B736240276B3EAD664DA79826FA936F99803B6C28F3B.ips diff --git a/common/defaults/kip_patches/default_nogc/3A574D436186191D1788EB2C0F076B11737132EBB1484CF906B6A8EB3B1BF459.ips b/config_templates/kip_patches/default_nogc/3A574D436186191D1788EB2C0F076B11737132EBB1484CF906B6A8EB3B1BF459.ips similarity index 100% rename from common/defaults/kip_patches/default_nogc/3A574D436186191D1788EB2C0F076B11737132EBB1484CF906B6A8EB3B1BF459.ips rename to config_templates/kip_patches/default_nogc/3A574D436186191D1788EB2C0F076B11737132EBB1484CF906B6A8EB3B1BF459.ips diff --git a/common/defaults/kip_patches/default_nogc/468740761E193EB758794688F1D9F762CBA1185ADDAD4EC3C479EC8FBFEC31DD.ips b/config_templates/kip_patches/default_nogc/468740761E193EB758794688F1D9F762CBA1185ADDAD4EC3C479EC8FBFEC31DD.ips similarity index 100% rename from common/defaults/kip_patches/default_nogc/468740761E193EB758794688F1D9F762CBA1185ADDAD4EC3C479EC8FBFEC31DD.ips rename to config_templates/kip_patches/default_nogc/468740761E193EB758794688F1D9F762CBA1185ADDAD4EC3C479EC8FBFEC31DD.ips diff --git a/common/defaults/kip_patches/default_nogc/549B0F8D6F72C4E9F3FD1F19EACE4A5A1DA2D5C393F74224F8BC09DE4AAA4217.ips b/config_templates/kip_patches/default_nogc/549B0F8D6F72C4E9F3FD1F19EACE4A5A1DA2D5C393F74224F8BC09DE4AAA4217.ips similarity index 100% rename from common/defaults/kip_patches/default_nogc/549B0F8D6F72C4E9F3FD1F19EACE4A5A1DA2D5C393F74224F8BC09DE4AAA4217.ips rename to config_templates/kip_patches/default_nogc/549B0F8D6F72C4E9F3FD1F19EACE4A5A1DA2D5C393F74224F8BC09DE4AAA4217.ips diff --git a/common/defaults/kip_patches/default_nogc/6B09B67B29C020246DC34F5A04F5D3090215C46F37BD079442977A85B8243BA5.ips b/config_templates/kip_patches/default_nogc/6B09B67B29C020246DC34F5A04F5D3090215C46F37BD079442977A85B8243BA5.ips similarity index 100% rename from common/defaults/kip_patches/default_nogc/6B09B67B29C020246DC34F5A04F5D3090215C46F37BD079442977A85B8243BA5.ips rename to config_templates/kip_patches/default_nogc/6B09B67B29C020246DC34F5A04F5D3090215C46F37BD079442977A85B8243BA5.ips diff --git a/common/defaults/kip_patches/default_nogc/76F87402C9387C0F0A2FAB1B45CEBB93E3E9695C7CFD390F00509B1204101C24.ips b/config_templates/kip_patches/default_nogc/76F87402C9387C0F0A2FAB1B45CEBB93E3E9695C7CFD390F00509B1204101C24.ips similarity index 100% rename from common/defaults/kip_patches/default_nogc/76F87402C9387C0F0A2FAB1B45CEBB93E3E9695C7CFD390F00509B1204101C24.ips rename to config_templates/kip_patches/default_nogc/76F87402C9387C0F0A2FAB1B45CEBB93E3E9695C7CFD390F00509B1204101C24.ips diff --git a/common/defaults/kip_patches/default_nogc/7C951376E5C12DF85FA6A9F46F6957A4B1271C1F8201B99735D8DF152E7913F1.ips b/config_templates/kip_patches/default_nogc/7C951376E5C12DF85FA6A9F46F6957A4B1271C1F8201B99735D8DF152E7913F1.ips similarity index 100% rename from common/defaults/kip_patches/default_nogc/7C951376E5C12DF85FA6A9F46F6957A4B1271C1F8201B99735D8DF152E7913F1.ips rename to config_templates/kip_patches/default_nogc/7C951376E5C12DF85FA6A9F46F6957A4B1271C1F8201B99735D8DF152E7913F1.ips diff --git a/common/defaults/kip_patches/default_nogc/8096AF7C6A35AA8271F3916995413B0B64CE03BD9BBFEB26F2B3E01C5427C69E.ips b/config_templates/kip_patches/default_nogc/8096AF7C6A35AA8271F3916995413B0B64CE03BD9BBFEB26F2B3E01C5427C69E.ips similarity index 100% rename from common/defaults/kip_patches/default_nogc/8096AF7C6A35AA8271F3916995413B0B64CE03BD9BBFEB26F2B3E01C5427C69E.ips rename to config_templates/kip_patches/default_nogc/8096AF7C6A35AA8271F3916995413B0B64CE03BD9BBFEB26F2B3E01C5427C69E.ips diff --git a/common/defaults/kip_patches/default_nogc/A6F27AD9AC7C73AD419B63B23E785A0CD7AA9DC1A63C57D10049423DE7B77E2C.ips b/config_templates/kip_patches/default_nogc/A6F27AD9AC7C73AD419B63B23E785A0CD7AA9DC1A63C57D10049423DE7B77E2C.ips similarity index 100% rename from common/defaults/kip_patches/default_nogc/A6F27AD9AC7C73AD419B63B23E785A0CD7AA9DC1A63C57D10049423DE7B77E2C.ips rename to config_templates/kip_patches/default_nogc/A6F27AD9AC7C73AD419B63B23E785A0CD7AA9DC1A63C57D10049423DE7B77E2C.ips diff --git a/common/defaults/kip_patches/default_nogc/B2F5176B3548364D079A29B141A23B06AFFF5A98055576D5F337A621C0233CE3.ips b/config_templates/kip_patches/default_nogc/B2F5176B3548364D079A29B141A23B06AFFF5A98055576D5F337A621C0233CE3.ips similarity index 100% rename from common/defaults/kip_patches/default_nogc/B2F5176B3548364D079A29B141A23B06AFFF5A98055576D5F337A621C0233CE3.ips rename to config_templates/kip_patches/default_nogc/B2F5176B3548364D079A29B141A23B06AFFF5A98055576D5F337A621C0233CE3.ips diff --git a/common/defaults/kip_patches/default_nogc/B4CAE1F24965D92ED24EBE9E97F609C363834471BF18CA375CB6A1DEB77755EA.ips b/config_templates/kip_patches/default_nogc/B4CAE1F24965D92ED24EBE9E97F609C363834471BF18CA375CB6A1DEB77755EA.ips similarity index 100% rename from common/defaults/kip_patches/default_nogc/B4CAE1F24965D92ED24EBE9E97F609C363834471BF18CA375CB6A1DEB77755EA.ips rename to config_templates/kip_patches/default_nogc/B4CAE1F24965D92ED24EBE9E97F609C363834471BF18CA375CB6A1DEB77755EA.ips diff --git a/common/defaults/kip_patches/default_nogc/B5E7A64C6F5C4FE319C36FD7D642F75B0159771671F73082448ACE30BD6BAE89.ips b/config_templates/kip_patches/default_nogc/B5E7A64C6F5C4FE319C36FD7D642F75B0159771671F73082448ACE30BD6BAE89.ips similarity index 100% rename from common/defaults/kip_patches/default_nogc/B5E7A64C6F5C4FE319C36FD7D642F75B0159771671F73082448ACE30BD6BAE89.ips rename to config_templates/kip_patches/default_nogc/B5E7A64C6F5C4FE319C36FD7D642F75B0159771671F73082448ACE30BD6BAE89.ips diff --git a/common/defaults/kip_patches/default_nogc/CE3ECBA2F2F062F575F8F360842B32B432340DD2C7590CDEFC03E51B844AE805.ips b/config_templates/kip_patches/default_nogc/CE3ECBA2F2F062F575F8F360842B32B432340DD2C7590CDEFC03E51B844AE805.ips similarity index 100% rename from common/defaults/kip_patches/default_nogc/CE3ECBA2F2F062F575F8F360842B32B432340DD2C7590CDEFC03E51B844AE805.ips rename to config_templates/kip_patches/default_nogc/CE3ECBA2F2F062F575F8F360842B32B432340DD2C7590CDEFC03E51B844AE805.ips diff --git a/common/defaults/kip_patches/default_nogc/DBD941C0C53C52CCF7202C84D8E0F78013A3684D8AB5D128096674A8F7755B3D.ips b/config_templates/kip_patches/default_nogc/DBD941C0C53C52CCF7202C84D8E0F78013A3684D8AB5D128096674A8F7755B3D.ips similarity index 100% rename from common/defaults/kip_patches/default_nogc/DBD941C0C53C52CCF7202C84D8E0F78013A3684D8AB5D128096674A8F7755B3D.ips rename to config_templates/kip_patches/default_nogc/DBD941C0C53C52CCF7202C84D8E0F78013A3684D8AB5D128096674A8F7755B3D.ips diff --git a/common/defaults/kip_patches/default_nogc/F196D144D04445B6E7497CB6405B7FC305B54F961024BF432575296E4D52BC99.ips b/config_templates/kip_patches/default_nogc/F196D144D04445B6E7497CB6405B7FC305B54F961024BF432575296E4D52BC99.ips similarity index 100% rename from common/defaults/kip_patches/default_nogc/F196D144D04445B6E7497CB6405B7FC305B54F961024BF432575296E4D52BC99.ips rename to config_templates/kip_patches/default_nogc/F196D144D04445B6E7497CB6405B7FC305B54F961024BF432575296E4D52BC99.ips diff --git a/common/defaults/override_config.ini b/config_templates/override_config.ini similarity index 100% rename from common/defaults/override_config.ini rename to config_templates/override_config.ini diff --git a/common/defaults/system_settings.ini b/config_templates/system_settings.ini similarity index 100% rename from common/defaults/system_settings.ini rename to config_templates/system_settings.ini diff --git a/exosphere/Makefile b/exosphere/Makefile index 3b9792116..09630e14d 100644 --- a/exosphere/Makefile +++ b/exosphere/Makefile @@ -28,7 +28,7 @@ TARGET := $(notdir $(CURDIR)) BUILD := build SOURCES := src src/dbg DATA := data -INCLUDES := include ../common/include +INCLUDES := include ../libraries/libvapours/include #--------------------------------------------------------------------------------- # options for code generation @@ -48,7 +48,7 @@ CFLAGS := \ -Wall \ $(ARCH) $(DEFINES) -CFLAGS += $(INCLUDE) +CFLAGS += $(INCLUDE) CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11 diff --git a/exosphere/lp0fw/Makefile b/exosphere/lp0fw/Makefile index b3b032b84..a1073d35e 100644 --- a/exosphere/lp0fw/Makefile +++ b/exosphere/lp0fw/Makefile @@ -20,7 +20,7 @@ TARGET := $(notdir $(CURDIR)) BUILD := build SOURCES := src DATA := data -INCLUDES := include ../../common/include +INCLUDES := include ../../libraries/libvapours/include #--------------------------------------------------------------------------------- # options for code generation diff --git a/exosphere/lp0fw/src/utils.h b/exosphere/lp0fw/src/utils.h index 78551d04d..02e6c6fe2 100644 --- a/exosphere/lp0fw/src/utils.h +++ b/exosphere/lp0fw/src/utils.h @@ -13,14 +13,14 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - + #ifndef EXOSPHERE_WARMBOOT_BIN_UTILS_H #define EXOSPHERE_WARMBOOT_BIN_UTILS_H #include #include #include -#include +#include #define BIT(n) (1u << (n)) #define BITL(n) (1ull << (n)) diff --git a/exosphere/src/configitem.c b/exosphere/src/configitem.c index 84ca86acb..7cdf3ff13 100644 --- a/exosphere/src/configitem.c +++ b/exosphere/src/configitem.c @@ -15,7 +15,7 @@ */ #include -#include +#include #include "bootconfig.h" #include "configitem.h" diff --git a/exosphere/src/emummc_cfg.h b/exosphere/src/emummc_cfg.h index 6a2f6d124..bd5e6a221 100644 --- a/exosphere/src/emummc_cfg.h +++ b/exosphere/src/emummc_cfg.h @@ -13,12 +13,12 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - + #ifndef EXOSPHERE_EMUMMC_CONFIG_H #define EXOSPHERE_EMUMMC_CONFIG_H #include -#include +#include #include "utils.h" /* "EFS0" */ diff --git a/exosphere/src/exocfg.c b/exosphere/src/exocfg.c index 00827c69f..7b0f9952d 100644 --- a/exosphere/src/exocfg.c +++ b/exosphere/src/exocfg.c @@ -22,7 +22,7 @@ #include "mmu.h" #include "memory_map.h" -static exosphere_config_t g_exosphere_cfg = {MAGIC_EXOSPHERE_CONFIG, ATMOSPHERE_TARGET_FIRMWARE_DEFAULT_FOR_DEBUG, EXOSPHERE_FLAGS_DEFAULT}; +static exosphere_config_t g_exosphere_cfg = {MAGIC_EXOSPHERE_CONFIG, ATMOSPHERE_TARGET_FIRMWARE_CURRENT, EXOSPHERE_FLAGS_DEFAULT}; static bool g_has_loaded_config = false; #define EXOSPHERE_CHECK_FLAG(flag) ((g_exosphere_cfg.flags & flag) != 0) diff --git a/exosphere/src/exocfg.h b/exosphere/src/exocfg.h index 902ab02e0..81455415b 100644 --- a/exosphere/src/exocfg.h +++ b/exosphere/src/exocfg.h @@ -18,7 +18,7 @@ #define EXOSPHERE_EXOSPHERE_CONFIG_H #include -#include +#include #include "utils.h" #include "memory_map.h" @@ -68,7 +68,7 @@ static inline unsigned int exosphere_get_target_firmware_for_init(void) { if (magic == MAGIC_EXOSPHERE_CONFIG) { return MAILBOX_EXOSPHERE_CONFIG_PHYS.target_firmware; } else { - return ATMOSPHERE_TARGET_FIRMWARE_DEFAULT_FOR_DEBUG; + return ATMOSPHERE_TARGET_FIRMWARE_CURRENT; } } diff --git a/exosphere/src/smc_api.c b/exosphere/src/smc_api.c index bdf8ff1a0..dbd09ff44 100644 --- a/exosphere/src/smc_api.c +++ b/exosphere/src/smc_api.c @@ -318,7 +318,7 @@ void call_smc_handler(uint32_t handler_id, smc_args_t *args) { #endif #if DEBUG_PANIC_ON_FAILURE - if (args->X[0] && (!is_aes_kek || args->X[3] <= ATMOSPHERE_TARGET_FIRMWARE_DEFAULT_FOR_DEBUG)) + if (args->X[0] && (!is_aes_kek || args->X[3] <= ATMOSPHERE_TARGET_FIRMWARE_CURRENT)) { MAKE_REG32(get_iram_address_for_debug() + 0x4FF0) = handler_id; MAKE_REG32(get_iram_address_for_debug() + 0x4FF4) = smc_id; diff --git a/fusee/fusee-secondary/Makefile b/fusee/fusee-secondary/Makefile index 64fa59ba3..67110da57 100644 --- a/fusee/fusee-secondary/Makefile +++ b/fusee/fusee-secondary/Makefile @@ -38,7 +38,7 @@ TARGET := $(notdir $(CURDIR)) BUILD := build SOURCES := src src/sdmmc src/lib src/lib/fatfs src/display DATA := data -INCLUDES := include ../../common/include +INCLUDES := include ../../libraries/libvapours/include #--------------------------------------------------------------------------------- # options for code generation diff --git a/fusee/fusee-secondary/src/emummc_cfg.h b/fusee/fusee-secondary/src/emummc_cfg.h index 3e9f21004..53206d474 100644 --- a/fusee/fusee-secondary/src/emummc_cfg.h +++ b/fusee/fusee-secondary/src/emummc_cfg.h @@ -18,7 +18,7 @@ #define EXOSPHERE_EMUMMC_CONFIG_H #include -#include +#include /* "EFS0" */ #define MAGIC_EMUMMC_CONFIG (0x30534645) diff --git a/fusee/fusee-secondary/src/exocfg.h b/fusee/fusee-secondary/src/exocfg.h index 685b15ce8..773c18bf7 100644 --- a/fusee/fusee-secondary/src/exocfg.h +++ b/fusee/fusee-secondary/src/exocfg.h @@ -18,7 +18,7 @@ #define FUSEE_EXOSPHERE_CONFIG_H #include -#include +#include #include "emummc_cfg.h" /* This serves to set configuration for *exosphere itself*, separate from the SecMon Exosphere mimics. */ diff --git a/fusee/fusee-secondary/src/package2.c b/fusee/fusee-secondary/src/package2.c index 3ed9e8cc2..d1b1b8a7b 100644 --- a/fusee/fusee-secondary/src/package2.c +++ b/fusee/fusee-secondary/src/package2.c @@ -16,7 +16,7 @@ #include #include -#include +#include #include "utils.h" #include "masterkey.h" #include "stratosphere.h" diff --git a/fusee/fusee-secondary/src/start.s b/fusee/fusee-secondary/src/start.s index 74185b7a4..556e7bbdb 100644 --- a/fusee/fusee-secondary/src/start.s +++ b/fusee/fusee-secondary/src/start.s @@ -13,7 +13,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -#include +#include .macro CLEAR_GPR_REG_ITER mov r\@, #0 diff --git a/stratosphere/Makefile b/stratosphere/Makefile index 098c001a3..645bc1b7f 100644 --- a/stratosphere/Makefile +++ b/stratosphere/Makefile @@ -1,6 +1,6 @@ MODULES := loader pm sm boot ams_mitm spl eclct.stub ro creport fatal dmnt boot2 -SUBFOLDERS := libstratosphere $(MODULES) +SUBFOLDERS := $(MODULES) TOPTARGETS := all clean @@ -9,6 +9,4 @@ $(TOPTARGETS): $(SUBFOLDERS) $(SUBFOLDERS): $(MAKE) -C $@ $(MAKECMDGOALS) -$(MODULES): libstratosphere - .PHONY: $(TOPTARGETS) $(SUBFOLDERS) diff --git a/stratosphere/ams_mitm/Makefile b/stratosphere/ams_mitm/Makefile index 4bd985667..a92187ef8 100644 --- a/stratosphere/ams_mitm/Makefile +++ b/stratosphere/ams_mitm/Makefile @@ -1,76 +1,7 @@ #--------------------------------------------------------------------------------- -.SUFFIXES: +# pull in common stratosphere sysmodule configuration #--------------------------------------------------------------------------------- - -ifeq ($(strip $(DEVKITPRO)),) -$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=/devkitpro") -endif - -TOPDIR ?= $(CURDIR) -include $(DEVKITPRO)/libnx/switch_rules - -AMSBRANCH := $(shell git symbolic-ref --short HEAD) -AMSREV := $(AMSBRANCH)-$(shell git rev-parse --short HEAD) - -ifneq (, $(strip $(shell git status --porcelain 2>/dev/null))) - AMSREV := $(AMSREV)-dirty -endif - -#--------------------------------------------------------------------------------- -# TARGET is the name of the output -# BUILD is the directory where object files & intermediate files will be placed -# SOURCES is a list of directories containing source code -# DATA is a list of directories containing data files -# INCLUDES is a list of directories containing header files -# EXEFS_SRC is the optional input directory containing data copied into exefs, if anything this normally should only contain "main.npdm". -#--------------------------------------------------------------------------------- -TARGET := $(notdir $(CURDIR)) -BUILD := build -SOURCES := source source/fs_mitm source/set_mitm source/bpc_mitm source/ns_mitm source/hid_mitm -DATA := data -INCLUDES := include ../../common/include -EXEFS_SRC := exefs_src - -DEFINES := -DATMOSPHERE_GIT_BRANCH=\"$(AMSBRANCH)\" -DATMOSPHERE_GIT_REV=\"$(AMSREV)\" - -#--------------------------------------------------------------------------------- -# options for code generation -#--------------------------------------------------------------------------------- -ARCH := -march=armv8-a -mtune=cortex-a57 -mtp=soft -fPIE - -CFLAGS := -g -Wall -O2 -ffunction-sections \ - $(ARCH) $(DEFINES) - -CFLAGS += $(INCLUDE) -D__SWITCH__ - -CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++17 - -CXXWRAPS := -Wl,--wrap,__cxa_pure_virtual \ - -Wl,--wrap,__cxa_throw \ - -Wl,--wrap,__cxa_rethrow \ - -Wl,--wrap,__cxa_allocate_exception \ - -Wl,--wrap,__cxa_free_exception \ - -Wl,--wrap,__cxa_begin_catch \ - -Wl,--wrap,__cxa_end_catch \ - -Wl,--wrap,__cxa_call_unexpected \ - -Wl,--wrap,__cxa_call_terminate \ - -Wl,--wrap,__gxx_personality_v0 \ - -Wl,--wrap,_Unwind_Resume \ - -Wl,--wrap,_ZSt19__throw_logic_errorPKc \ - -Wl,--wrap,_ZSt20__throw_length_errorPKc \ - -Wl,--wrap,_ZNSt11logic_errorC2EPKc - -ASFLAGS := -g $(ARCH) -LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) $(CXXWRAPS) -Wl,-Map,$(notdir $*.map) - -LIBS := -lstratosphere -lnx - -#--------------------------------------------------------------------------------- -# list of directories containing libraries, this must be the top level containing -# include and lib -#--------------------------------------------------------------------------------- -LIBDIRS := $(PORTLIBS) $(LIBNX) $(CURDIR)/../libstratosphere - +include $(dir $(abspath $(lastword $(MAKEFILE_LIST))))/../../libraries/config/templates/stratosphere.mk #--------------------------------------------------------------------------------- # no real need to edit anything past this point unless you need to add additional @@ -87,9 +18,25 @@ export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ export DEPSDIR := $(CURDIR)/$(BUILD) -CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) -CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) -SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) + +CFILES := $(foreach dir,$(SOURCES),$(filter-out $(notdir $(wildcard $(dir)/*.arch.*.c)) $(notdir $(wildcard $(dir)/*.board.*.c)) $(notdir $(wildcard $(dir)/*.os.*.c)), \ + $(notdir $(wildcard $(dir)/*.c)))) +CFILES += $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.arch.$(ATMOSPHERE_ARCH_NAME).c))) +CFILES += $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.board.$(ATMOSPHERE_BOARD_NAME).c))) +CFILES += $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.os.$(ATMOSPHERE_OS_NAME).c))) + +CPPFILES := $(foreach dir,$(SOURCES),$(filter-out $(notdir $(wildcard $(dir)/*.arch.*.cpp)) $(notdir $(wildcard $(dir)/*.board.*.cpp)) $(notdir $(wildcard $(dir)/*.os.*.cpp)), \ + $(notdir $(wildcard $(dir)/*.cpp)))) +CPPFILES += $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.arch.$(ATMOSPHERE_ARCH_NAME).cpp))) +CPPFILES += $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.board.$(ATMOSPHERE_BOARD_NAME).cpp))) +CPPFILES += $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.os.$(ATMOSPHERE_OS_NAME).cpp))) + +SFILES := $(foreach dir,$(SOURCES),$(filter-out $(notdir $(wildcard $(dir)/*.arch.*.s)) $(notdir $(wildcard $(dir)/*.board.*.s)) $(notdir $(wildcard $(dir)/*.os.*.s)), \ + $(notdir $(wildcard $(dir)/*.s)))) +SFILES += $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.arch.$(ATMOSPHERE_ARCH_NAME).s))) +SFILES += $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.board.$(ATMOSPHERE_BOARD_NAME).s))) +SFILES += $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.os.$(ATMOSPHERE_OS_NAME).s))) + BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) #--------------------------------------------------------------------------------- diff --git a/stratosphere/boot/Makefile b/stratosphere/boot/Makefile index f70d9049b..8fa028c65 100644 --- a/stratosphere/boot/Makefile +++ b/stratosphere/boot/Makefile @@ -1,83 +1,7 @@ #--------------------------------------------------------------------------------- -.SUFFIXES: +# pull in common stratosphere sysmodule configuration #--------------------------------------------------------------------------------- - -ifeq ($(strip $(DEVKITPRO)),) -$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=/devkitpro") -endif - -TOPDIR ?= $(CURDIR) -include $(DEVKITPRO)/libnx/switch_rules - -AMSBRANCH := $(shell git symbolic-ref --short HEAD) -AMSREV := $(AMSBRANCH)-$(shell git rev-parse --short HEAD) - -ifneq (, $(strip $(shell git status --porcelain 2>/dev/null))) - AMSREV := $(AMSREV)-dirty -endif - -define _bin2o - bin2s $< | $(AS) -o $(@) - echo "extern const u8" `(echo $( `(echo $(> `(echo $(> `(echo $( fusee_primary +#--------------------------------------------------------------------------------- +define _bin2o + bin2s $< | $(AS) -o $(@) + echo "extern const u8" `(echo $( `(echo $(> `(echo $(> `(echo $(/devkitpro") -endif - -TOPDIR ?= $(CURDIR) -include $(DEVKITPRO)/libnx/switch_rules - -AMSBRANCH := $(shell git symbolic-ref --short HEAD) -AMSREV := $(AMSBRANCH)-$(shell git rev-parse --short HEAD) - -ifneq (, $(strip $(shell git status --porcelain 2>/dev/null))) - AMSREV := $(AMSREV)-dirty -endif - -#--------------------------------------------------------------------------------- -# TARGET is the name of the output -# BUILD is the directory where object files & intermediate files will be placed -# SOURCES is a list of directories containing source code -# DATA is a list of directories containing data files -# INCLUDES is a list of directories containing header files -# EXEFS_SRC is the optional input directory containing data copied into exefs, if anything this normally should only contain "main.npdm". -#--------------------------------------------------------------------------------- -TARGET := $(notdir $(CURDIR)) -BUILD := build -SOURCES := source -DATA := data -INCLUDES := include ../../common/include -EXEFS_SRC := exefs_src - -DEFINES := -DATMOSPHERE_GIT_BRANCH=\"$(AMSBRANCH)\" -DATMOSPHERE_GIT_REV=\"$(AMSREV)\" -DINI_MAX_LINE=768 - -#--------------------------------------------------------------------------------- -# options for code generation -#--------------------------------------------------------------------------------- -ARCH := -march=armv8-a -mtune=cortex-a57 -mtp=soft -fPIE - -CFLAGS := -g -Wall -O2 -ffunction-sections \ - $(ARCH) $(DEFINES) - -CFLAGS += $(INCLUDE) -D__SWITCH__ - -CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++17 - -CXXWRAPS := -Wl,--wrap,__cxa_pure_virtual \ - -Wl,--wrap,__cxa_throw \ - -Wl,--wrap,__cxa_rethrow \ - -Wl,--wrap,__cxa_allocate_exception \ - -Wl,--wrap,__cxa_free_exception \ - -Wl,--wrap,__cxa_begin_catch \ - -Wl,--wrap,__cxa_end_catch \ - -Wl,--wrap,__cxa_call_unexpected \ - -Wl,--wrap,__cxa_call_terminate \ - -Wl,--wrap,__gxx_personality_v0 \ - -Wl,--wrap,_Unwind_Resume \ - -Wl,--wrap,_ZSt19__throw_logic_errorPKc \ - -Wl,--wrap,_ZSt20__throw_length_errorPKc \ - -Wl,--wrap,_ZNSt11logic_errorC2EPKc - -ASFLAGS := -g $(ARCH) -LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) $(CXXWRAPS) -Wl,-Map,$(notdir $*.map) - -LIBS := -lstratosphere -lnx - -#--------------------------------------------------------------------------------- -# list of directories containing libraries, this must be the top level containing -# include and lib -#--------------------------------------------------------------------------------- -LIBDIRS := $(PORTLIBS) $(LIBNX) $(CURDIR)/../libstratosphere - +include $(dir $(abspath $(lastword $(MAKEFILE_LIST))))/../../libraries/config/templates/stratosphere.mk #--------------------------------------------------------------------------------- # no real need to edit anything past this point unless you need to add additional @@ -87,9 +18,25 @@ export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ export DEPSDIR := $(CURDIR)/$(BUILD) -CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) -CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) -SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) + +CFILES := $(foreach dir,$(SOURCES),$(filter-out $(notdir $(wildcard $(dir)/*.arch.*.c)) $(notdir $(wildcard $(dir)/*.board.*.c)) $(notdir $(wildcard $(dir)/*.os.*.c)), \ + $(notdir $(wildcard $(dir)/*.c)))) +CFILES += $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.arch.$(ATMOSPHERE_ARCH_NAME).c))) +CFILES += $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.board.$(ATMOSPHERE_BOARD_NAME).c))) +CFILES += $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.os.$(ATMOSPHERE_OS_NAME).c))) + +CPPFILES := $(foreach dir,$(SOURCES),$(filter-out $(notdir $(wildcard $(dir)/*.arch.*.cpp)) $(notdir $(wildcard $(dir)/*.board.*.cpp)) $(notdir $(wildcard $(dir)/*.os.*.cpp)), \ + $(notdir $(wildcard $(dir)/*.cpp)))) +CPPFILES += $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.arch.$(ATMOSPHERE_ARCH_NAME).cpp))) +CPPFILES += $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.board.$(ATMOSPHERE_BOARD_NAME).cpp))) +CPPFILES += $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.os.$(ATMOSPHERE_OS_NAME).cpp))) + +SFILES := $(foreach dir,$(SOURCES),$(filter-out $(notdir $(wildcard $(dir)/*.arch.*.s)) $(notdir $(wildcard $(dir)/*.board.*.s)) $(notdir $(wildcard $(dir)/*.os.*.s)), \ + $(notdir $(wildcard $(dir)/*.s)))) +SFILES += $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.arch.$(ATMOSPHERE_ARCH_NAME).s))) +SFILES += $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.board.$(ATMOSPHERE_BOARD_NAME).s))) +SFILES += $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.os.$(ATMOSPHERE_OS_NAME).s))) + BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) #--------------------------------------------------------------------------------- diff --git a/stratosphere/creport/Makefile b/stratosphere/creport/Makefile index ab283ad98..7320b9f99 100644 --- a/stratosphere/creport/Makefile +++ b/stratosphere/creport/Makefile @@ -1,76 +1,7 @@ #--------------------------------------------------------------------------------- -.SUFFIXES: +# pull in common stratosphere sysmodule configuration #--------------------------------------------------------------------------------- - -ifeq ($(strip $(DEVKITPRO)),) -$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=/devkitpro") -endif - -TOPDIR ?= $(CURDIR) -include $(DEVKITPRO)/libnx/switch_rules - -AMSBRANCH := $(shell git symbolic-ref --short HEAD) -AMSREV := $(AMSBRANCH)-$(shell git rev-parse --short HEAD) - -ifneq (, $(strip $(shell git status --porcelain 2>/dev/null))) - AMSREV := $(AMSREV)-dirty -endif - -#--------------------------------------------------------------------------------- -# TARGET is the name of the output -# BUILD is the directory where object files & intermediate files will be placed -# SOURCES is a list of directories containing source code -# DATA is a list of directories containing data files -# INCLUDES is a list of directories containing header files -# EXEFS_SRC is the optional input directory containing data copied into exefs, if anything this normally should only contain "main.npdm". -#--------------------------------------------------------------------------------- -TARGET := $(notdir $(CURDIR)) -BUILD := build -SOURCES := source -DATA := data -INCLUDES := include ../../common/include -EXEFS_SRC := exefs_src - -DEFINES := -DATMOSPHERE_GIT_BRANCH=\"$(AMSBRANCH)\" -DATMOSPHERE_GIT_REV=\"$(AMSREV)\" - -#--------------------------------------------------------------------------------- -# options for code generation -#--------------------------------------------------------------------------------- -ARCH := -march=armv8-a -mtune=cortex-a57 -mtp=soft -fPIE - -CFLAGS := -g -Wall -O2 -ffunction-sections \ - $(ARCH) $(DEFINES) - -CFLAGS += $(INCLUDE) -D__SWITCH__ - -CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++17 - -CXXWRAPS := -Wl,--wrap,__cxa_pure_virtual \ - -Wl,--wrap,__cxa_throw \ - -Wl,--wrap,__cxa_rethrow \ - -Wl,--wrap,__cxa_allocate_exception \ - -Wl,--wrap,__cxa_free_exception \ - -Wl,--wrap,__cxa_begin_catch \ - -Wl,--wrap,__cxa_end_catch \ - -Wl,--wrap,__cxa_call_unexpected \ - -Wl,--wrap,__cxa_call_terminate \ - -Wl,--wrap,__gxx_personality_v0 \ - -Wl,--wrap,_Unwind_Resume \ - -Wl,--wrap,_ZSt19__throw_logic_errorPKc \ - -Wl,--wrap,_ZSt20__throw_length_errorPKc \ - -Wl,--wrap,_ZNSt11logic_errorC2EPKc - -ASFLAGS := -g $(ARCH) -LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) $(CXXWRAPS) -Wl,-Map,$(notdir $*.map) - -LIBS := -lstratosphere -lnx - -#--------------------------------------------------------------------------------- -# list of directories containing libraries, this must be the top level containing -# include and lib -#--------------------------------------------------------------------------------- -LIBDIRS := $(PORTLIBS) $(LIBNX) $(CURDIR)/../libstratosphere - +include $(dir $(abspath $(lastword $(MAKEFILE_LIST))))/../../libraries/config/templates/stratosphere.mk #--------------------------------------------------------------------------------- # no real need to edit anything past this point unless you need to add additional @@ -87,9 +18,25 @@ export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ export DEPSDIR := $(CURDIR)/$(BUILD) -CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) -CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) -SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) + +CFILES := $(foreach dir,$(SOURCES),$(filter-out $(notdir $(wildcard $(dir)/*.arch.*.c)) $(notdir $(wildcard $(dir)/*.board.*.c)) $(notdir $(wildcard $(dir)/*.os.*.c)), \ + $(notdir $(wildcard $(dir)/*.c)))) +CFILES += $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.arch.$(ATMOSPHERE_ARCH_NAME).c))) +CFILES += $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.board.$(ATMOSPHERE_BOARD_NAME).c))) +CFILES += $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.os.$(ATMOSPHERE_OS_NAME).c))) + +CPPFILES := $(foreach dir,$(SOURCES),$(filter-out $(notdir $(wildcard $(dir)/*.arch.*.cpp)) $(notdir $(wildcard $(dir)/*.board.*.cpp)) $(notdir $(wildcard $(dir)/*.os.*.cpp)), \ + $(notdir $(wildcard $(dir)/*.cpp)))) +CPPFILES += $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.arch.$(ATMOSPHERE_ARCH_NAME).cpp))) +CPPFILES += $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.board.$(ATMOSPHERE_BOARD_NAME).cpp))) +CPPFILES += $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.os.$(ATMOSPHERE_OS_NAME).cpp))) + +SFILES := $(foreach dir,$(SOURCES),$(filter-out $(notdir $(wildcard $(dir)/*.arch.*.s)) $(notdir $(wildcard $(dir)/*.board.*.s)) $(notdir $(wildcard $(dir)/*.os.*.s)), \ + $(notdir $(wildcard $(dir)/*.s)))) +SFILES += $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.arch.$(ATMOSPHERE_ARCH_NAME).s))) +SFILES += $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.board.$(ATMOSPHERE_BOARD_NAME).s))) +SFILES += $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.os.$(ATMOSPHERE_OS_NAME).s))) + BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) #--------------------------------------------------------------------------------- diff --git a/stratosphere/dmnt/Makefile b/stratosphere/dmnt/Makefile index 9c3e0a2fc..7320b9f99 100644 --- a/stratosphere/dmnt/Makefile +++ b/stratosphere/dmnt/Makefile @@ -1,76 +1,7 @@ #--------------------------------------------------------------------------------- -.SUFFIXES: +# pull in common stratosphere sysmodule configuration #--------------------------------------------------------------------------------- - -ifeq ($(strip $(DEVKITPRO)),) -$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=/devkitpro") -endif - -TOPDIR ?= $(CURDIR) -include $(DEVKITPRO)/libnx/switch_rules - -AMSBRANCH := $(shell git symbolic-ref --short HEAD) -AMSREV := $(AMSBRANCH)-$(shell git rev-parse --short HEAD) - -ifneq (, $(strip $(shell git status --porcelain 2>/dev/null))) - AMSREV := $(AMSREV)-dirty -endif - -#--------------------------------------------------------------------------------- -# TARGET is the name of the output -# BUILD is the directory where object files & intermediate files will be placed -# SOURCES is a list of directories containing source code -# DATA is a list of directories containing data files -# INCLUDES is a list of directories containing header files -# EXEFS_SRC is the optional input directory containing data copied into exefs, if anything this normally should only contain "main.npdm". -#--------------------------------------------------------------------------------- -TARGET := $(notdir $(CURDIR)) -BUILD := build -SOURCES := source source/cheat source/cheat/impl -DATA := data -INCLUDES := include ../../common/include -EXEFS_SRC := exefs_src - -DEFINES := -DATMOSPHERE_GIT_BRANCH=\"$(AMSBRANCH)\" -DATMOSPHERE_GIT_REV=\"$(AMSREV)\" - -#--------------------------------------------------------------------------------- -# options for code generation -#--------------------------------------------------------------------------------- -ARCH := -march=armv8-a -mtune=cortex-a57 -mtp=soft -fPIE - -CFLAGS := -g -Wall -O2 -ffunction-sections \ - $(ARCH) $(DEFINES) - -CFLAGS += $(INCLUDE) -D__SWITCH__ - -CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++17 - -CXXWRAPS := -Wl,--wrap,__cxa_pure_virtual \ - -Wl,--wrap,__cxa_throw \ - -Wl,--wrap,__cxa_rethrow \ - -Wl,--wrap,__cxa_allocate_exception \ - -Wl,--wrap,__cxa_free_exception \ - -Wl,--wrap,__cxa_begin_catch \ - -Wl,--wrap,__cxa_end_catch \ - -Wl,--wrap,__cxa_call_unexpected \ - -Wl,--wrap,__cxa_call_terminate \ - -Wl,--wrap,__gxx_personality_v0 \ - -Wl,--wrap,_Unwind_Resume \ - -Wl,--wrap,_ZSt19__throw_logic_errorPKc \ - -Wl,--wrap,_ZSt20__throw_length_errorPKc \ - -Wl,--wrap,_ZNSt11logic_errorC2EPKc - -ASFLAGS := -g $(ARCH) -LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) $(CXXWRAPS) -Wl,-Map,$(notdir $*.map) - -LIBS := -lstratosphere -lnx - -#--------------------------------------------------------------------------------- -# list of directories containing libraries, this must be the top level containing -# include and lib -#--------------------------------------------------------------------------------- -LIBDIRS := $(PORTLIBS) $(LIBNX) $(CURDIR)/../libstratosphere - +include $(dir $(abspath $(lastword $(MAKEFILE_LIST))))/../../libraries/config/templates/stratosphere.mk #--------------------------------------------------------------------------------- # no real need to edit anything past this point unless you need to add additional @@ -87,9 +18,25 @@ export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ export DEPSDIR := $(CURDIR)/$(BUILD) -CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) -CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) -SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) + +CFILES := $(foreach dir,$(SOURCES),$(filter-out $(notdir $(wildcard $(dir)/*.arch.*.c)) $(notdir $(wildcard $(dir)/*.board.*.c)) $(notdir $(wildcard $(dir)/*.os.*.c)), \ + $(notdir $(wildcard $(dir)/*.c)))) +CFILES += $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.arch.$(ATMOSPHERE_ARCH_NAME).c))) +CFILES += $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.board.$(ATMOSPHERE_BOARD_NAME).c))) +CFILES += $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.os.$(ATMOSPHERE_OS_NAME).c))) + +CPPFILES := $(foreach dir,$(SOURCES),$(filter-out $(notdir $(wildcard $(dir)/*.arch.*.cpp)) $(notdir $(wildcard $(dir)/*.board.*.cpp)) $(notdir $(wildcard $(dir)/*.os.*.cpp)), \ + $(notdir $(wildcard $(dir)/*.cpp)))) +CPPFILES += $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.arch.$(ATMOSPHERE_ARCH_NAME).cpp))) +CPPFILES += $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.board.$(ATMOSPHERE_BOARD_NAME).cpp))) +CPPFILES += $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.os.$(ATMOSPHERE_OS_NAME).cpp))) + +SFILES := $(foreach dir,$(SOURCES),$(filter-out $(notdir $(wildcard $(dir)/*.arch.*.s)) $(notdir $(wildcard $(dir)/*.board.*.s)) $(notdir $(wildcard $(dir)/*.os.*.s)), \ + $(notdir $(wildcard $(dir)/*.s)))) +SFILES += $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.arch.$(ATMOSPHERE_ARCH_NAME).s))) +SFILES += $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.board.$(ATMOSPHERE_BOARD_NAME).s))) +SFILES += $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.os.$(ATMOSPHERE_OS_NAME).s))) + BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) #--------------------------------------------------------------------------------- diff --git a/stratosphere/eclct.stub/Makefile b/stratosphere/eclct.stub/Makefile index cedb94b15..7320b9f99 100644 --- a/stratosphere/eclct.stub/Makefile +++ b/stratosphere/eclct.stub/Makefile @@ -1,76 +1,7 @@ #--------------------------------------------------------------------------------- -.SUFFIXES: +# pull in common stratosphere sysmodule configuration #--------------------------------------------------------------------------------- - -ifeq ($(strip $(DEVKITPRO)),) -$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=/devkitpro") -endif - -TOPDIR ?= $(CURDIR) -include $(DEVKITPRO)/libnx/switch_rules - -AMSBRANCH := $(shell git symbolic-ref --short HEAD) -AMSREV := $(AMSBRANCH)-$(shell git rev-parse --short HEAD) - -ifneq (, $(strip $(shell git status --porcelain 2>/dev/null))) - AMSREV := $(AMSREV)-dirty -endif - -#--------------------------------------------------------------------------------- -# TARGET is the name of the output -# BUILD is the directory where object files & intermediate files will be placed -# SOURCES is a list of directories containing source code -# DATA is a list of directories containing data files -# INCLUDES is a list of directories containing header files -# EXEFS_SRC is the optional input directory containing data copied into exefs, if anything this normally should only contain "main.npdm". -#--------------------------------------------------------------------------------- -TARGET := $(notdir $(CURDIR)) -BUILD := build -SOURCES := source -DATA := data -INCLUDES := include ../../common/include -EXEFS_SRC := exefs_src - -DEFINES := -DATMOSPHERE_GIT_BRANCH=\"$(AMSBRANCH)\" -DATMOSPHERE_GIT_REV=\"$(AMSREV)\" -DINI_MAX_LINE=768 - -#--------------------------------------------------------------------------------- -# options for code generation -#--------------------------------------------------------------------------------- -ARCH := -march=armv8-a -mtune=cortex-a57 -mtp=soft -fPIE - -CFLAGS := -g -Wall -O2 -ffunction-sections \ - $(ARCH) $(DEFINES) - -CFLAGS += $(INCLUDE) -D__SWITCH__ - -CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++17 - -CXXWRAPS := -Wl,--wrap,__cxa_pure_virtual \ - -Wl,--wrap,__cxa_throw \ - -Wl,--wrap,__cxa_rethrow \ - -Wl,--wrap,__cxa_allocate_exception \ - -Wl,--wrap,__cxa_free_exception \ - -Wl,--wrap,__cxa_begin_catch \ - -Wl,--wrap,__cxa_end_catch \ - -Wl,--wrap,__cxa_call_unexpected \ - -Wl,--wrap,__cxa_call_terminate \ - -Wl,--wrap,__gxx_personality_v0 \ - -Wl,--wrap,_Unwind_Resume \ - -Wl,--wrap,_ZSt19__throw_logic_errorPKc \ - -Wl,--wrap,_ZSt20__throw_length_errorPKc \ - -Wl,--wrap,_ZNSt11logic_errorC2EPKc - -ASFLAGS := -g $(ARCH) -LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) $(CXXWRAPS) -Wl,-Map,$(notdir $*.map) - -LIBS := -lstratosphere -lnx - -#--------------------------------------------------------------------------------- -# list of directories containing libraries, this must be the top level containing -# include and lib -#--------------------------------------------------------------------------------- -LIBDIRS := $(PORTLIBS) $(LIBNX) $(CURDIR)/../libstratosphere - +include $(dir $(abspath $(lastword $(MAKEFILE_LIST))))/../../libraries/config/templates/stratosphere.mk #--------------------------------------------------------------------------------- # no real need to edit anything past this point unless you need to add additional @@ -87,9 +18,25 @@ export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ export DEPSDIR := $(CURDIR)/$(BUILD) -CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) -CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) -SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) + +CFILES := $(foreach dir,$(SOURCES),$(filter-out $(notdir $(wildcard $(dir)/*.arch.*.c)) $(notdir $(wildcard $(dir)/*.board.*.c)) $(notdir $(wildcard $(dir)/*.os.*.c)), \ + $(notdir $(wildcard $(dir)/*.c)))) +CFILES += $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.arch.$(ATMOSPHERE_ARCH_NAME).c))) +CFILES += $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.board.$(ATMOSPHERE_BOARD_NAME).c))) +CFILES += $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.os.$(ATMOSPHERE_OS_NAME).c))) + +CPPFILES := $(foreach dir,$(SOURCES),$(filter-out $(notdir $(wildcard $(dir)/*.arch.*.cpp)) $(notdir $(wildcard $(dir)/*.board.*.cpp)) $(notdir $(wildcard $(dir)/*.os.*.cpp)), \ + $(notdir $(wildcard $(dir)/*.cpp)))) +CPPFILES += $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.arch.$(ATMOSPHERE_ARCH_NAME).cpp))) +CPPFILES += $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.board.$(ATMOSPHERE_BOARD_NAME).cpp))) +CPPFILES += $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.os.$(ATMOSPHERE_OS_NAME).cpp))) + +SFILES := $(foreach dir,$(SOURCES),$(filter-out $(notdir $(wildcard $(dir)/*.arch.*.s)) $(notdir $(wildcard $(dir)/*.board.*.s)) $(notdir $(wildcard $(dir)/*.os.*.s)), \ + $(notdir $(wildcard $(dir)/*.s)))) +SFILES += $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.arch.$(ATMOSPHERE_ARCH_NAME).s))) +SFILES += $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.board.$(ATMOSPHERE_BOARD_NAME).s))) +SFILES += $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.os.$(ATMOSPHERE_OS_NAME).s))) + BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) #--------------------------------------------------------------------------------- diff --git a/stratosphere/fatal/Makefile b/stratosphere/fatal/Makefile index ec1821d26..8d8e58e5a 100644 --- a/stratosphere/fatal/Makefile +++ b/stratosphere/fatal/Makefile @@ -1,76 +1,14 @@ #--------------------------------------------------------------------------------- -.SUFFIXES: +# pull in common stratosphere sysmodule configuration #--------------------------------------------------------------------------------- - -ifeq ($(strip $(DEVKITPRO)),) -$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=/devkitpro") -endif - -TOPDIR ?= $(CURDIR) -include $(DEVKITPRO)/libnx/switch_rules - -AMSBRANCH := $(shell git symbolic-ref --short HEAD) -AMSREV := $(AMSBRANCH)-$(shell git rev-parse --short HEAD) - -ifneq (, $(strip $(shell git status --porcelain 2>/dev/null))) - AMSREV := $(AMSREV)-dirty -endif +include $(dir $(abspath $(lastword $(MAKEFILE_LIST))))/../../libraries/config/templates/stratosphere.mk #--------------------------------------------------------------------------------- -# TARGET is the name of the output -# BUILD is the directory where object files & intermediate files will be placed -# SOURCES is a list of directories containing source code -# DATA is a list of directories containing data files -# INCLUDES is a list of directories containing header files -# EXEFS_SRC is the optional input directory containing data copied into exefs, if anything this normally should only contain "main.npdm". +# atmosphere-fatal needs freetype. #--------------------------------------------------------------------------------- -TARGET := $(notdir $(CURDIR)) -BUILD := build -SOURCES := source -DATA := data -INCLUDES := include ../../common/include -EXEFS_SRC := exefs_src - -DEFINES := -DATMOSPHERE_GIT_BRANCH=\"$(AMSBRANCH)\" -DATMOSPHERE_GIT_REV=\"$(AMSREV)\" - -#--------------------------------------------------------------------------------- -# options for code generation -#--------------------------------------------------------------------------------- -ARCH := -march=armv8-a -mtune=cortex-a57 -mtp=soft -fPIE - -CFLAGS := -g -Wall -O2 -ffunction-sections \ - $(ARCH) $(DEFINES) - -CFLAGS += $(INCLUDE) -D__SWITCH__ `freetype-config --cflags` - -CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++17 - -CXXWRAPS := -Wl,--wrap,__cxa_pure_virtual \ - -Wl,--wrap,__cxa_throw \ - -Wl,--wrap,__cxa_rethrow \ - -Wl,--wrap,__cxa_allocate_exception \ - -Wl,--wrap,__cxa_free_exception \ - -Wl,--wrap,__cxa_begin_catch \ - -Wl,--wrap,__cxa_end_catch \ - -Wl,--wrap,__cxa_call_unexpected \ - -Wl,--wrap,__cxa_call_terminate \ - -Wl,--wrap,__gxx_personality_v0 \ - -Wl,--wrap,_Unwind_Resume \ - -Wl,--wrap,_ZSt19__throw_logic_errorPKc \ - -Wl,--wrap,_ZSt20__throw_length_errorPKc \ - -Wl,--wrap,_ZNSt11logic_errorC2EPKc - -ASFLAGS := -g $(ARCH) -LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) $(CXXWRAPS) -Wl,-Map,$(notdir $*.map) - -LIBS := `freetype-config --libs` -lstratosphere -lnx - -#--------------------------------------------------------------------------------- -# list of directories containing libraries, this must be the top level containing -# include and lib -#--------------------------------------------------------------------------------- -LIBDIRS := $(PORTLIBS) $(LIBNX) $(CURDIR)/../libstratosphere - +LIBS += `freetype-config --libs` +CFLAGS += `freetype-config --cflags` +CXXFLAGS += `freetype-config --cflags` #--------------------------------------------------------------------------------- # no real need to edit anything past this point unless you need to add additional @@ -87,9 +25,25 @@ export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ export DEPSDIR := $(CURDIR)/$(BUILD) -CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) -CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) -SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) + +CFILES := $(foreach dir,$(SOURCES),$(filter-out $(notdir $(wildcard $(dir)/*.arch.*.c)) $(notdir $(wildcard $(dir)/*.board.*.c)) $(notdir $(wildcard $(dir)/*.os.*.c)), \ + $(notdir $(wildcard $(dir)/*.c)))) +CFILES += $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.arch.$(ATMOSPHERE_ARCH_NAME).c))) +CFILES += $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.board.$(ATMOSPHERE_BOARD_NAME).c))) +CFILES += $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.os.$(ATMOSPHERE_OS_NAME).c))) + +CPPFILES := $(foreach dir,$(SOURCES),$(filter-out $(notdir $(wildcard $(dir)/*.arch.*.cpp)) $(notdir $(wildcard $(dir)/*.board.*.cpp)) $(notdir $(wildcard $(dir)/*.os.*.cpp)), \ + $(notdir $(wildcard $(dir)/*.cpp)))) +CPPFILES += $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.arch.$(ATMOSPHERE_ARCH_NAME).cpp))) +CPPFILES += $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.board.$(ATMOSPHERE_BOARD_NAME).cpp))) +CPPFILES += $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.os.$(ATMOSPHERE_OS_NAME).cpp))) + +SFILES := $(foreach dir,$(SOURCES),$(filter-out $(notdir $(wildcard $(dir)/*.arch.*.s)) $(notdir $(wildcard $(dir)/*.board.*.s)) $(notdir $(wildcard $(dir)/*.os.*.s)), \ + $(notdir $(wildcard $(dir)/*.s)))) +SFILES += $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.arch.$(ATMOSPHERE_ARCH_NAME).s))) +SFILES += $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.board.$(ATMOSPHERE_BOARD_NAME).s))) +SFILES += $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.os.$(ATMOSPHERE_OS_NAME).s))) + BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) #--------------------------------------------------------------------------------- diff --git a/stratosphere/libstratosphere/.gitignore b/stratosphere/libstratosphere/.gitignore deleted file mode 100644 index f55c55a62..000000000 --- a/stratosphere/libstratosphere/.gitignore +++ /dev/null @@ -1,74 +0,0 @@ -# Prerequisites -*.d - -# Object files -*.o -*.ko -*.obj -*.elf - -# Linker output -*.ilk -*.map -*.exp -*.lst - -# Precompiled Headers -*.gch -*.pch - -# Libraries -*.lib -*.a -*.la -*.lo - -# Shared objects (inc. Windows DLLs) -*.dll -*.so -*.so.* -*.dylib - -# Executables -*.exe -*.out -*.app -*.i*86 -*.x86_64 -*.hex - -# Switch Executables -*.nso -*.nro -*.nacp -*.npdm -*.pfs0 -*.nsp -*.kip - -# Debug files -*.dSYM/ -*.su -*.idb -*.pdb - -# Kernel Module Compile Results -*.mod* -*.cmd -.tmp_versions/ -modules.order -Module.symvers -Mkfile.old -dkms.conf - -# Distribution files -*.tgz -*.zip - -.**/ - -# NOTE: make sure to make exceptions to this pattern when needed! -*.bin - -**/out -**/build diff --git a/stratosphere/libstratosphere/.gitmodules b/stratosphere/libstratosphere/.gitmodules deleted file mode 100644 index e69de29bb..000000000 diff --git a/stratosphere/libstratosphere/.gitrepo b/stratosphere/libstratosphere/.gitrepo deleted file mode 100644 index 247decb03..000000000 --- a/stratosphere/libstratosphere/.gitrepo +++ /dev/null @@ -1,12 +0,0 @@ -; DO NOT EDIT (unless you know what you are doing) -; -; This subdirectory is a git "subrepo", and this file is maintained by the -; git-subrepo command. See https://github.com/git-commands/git-subrepo#readme -; -[subrepo] - remote = https://github.com/Atmosphere-NX/libstratosphere - branch = master - commit = 303fc400dda9e592acbcb405153dd0dbde36281d - parent = 9d7b52e2d4c0112f0f6d708faa66ea53f53961e4 - method = merge - cmdver = 0.4.0 diff --git a/stratosphere/libstratosphere/LICENSE b/stratosphere/libstratosphere/LICENSE deleted file mode 100644 index ecbc05937..000000000 --- a/stratosphere/libstratosphere/LICENSE +++ /dev/null @@ -1,339 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Lesser General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that 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, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. \ No newline at end of file diff --git a/stratosphere/libstratosphere/Makefile b/stratosphere/libstratosphere/Makefile deleted file mode 100644 index 08d494fe5..000000000 --- a/stratosphere/libstratosphere/Makefile +++ /dev/null @@ -1,142 +0,0 @@ -#--------------------------------------------------------------------------------- -.SUFFIXES: -#--------------------------------------------------------------------------------- - -ifeq ($(strip $(DEVKITPRO)),) -$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=/devkitpro") -endif - -TOPDIR ?= $(CURDIR) -include $(DEVKITPRO)/libnx/switch_rules - -#--------------------------------------------------------------------------------- -# TARGET is the name of the output -# SOURCES is a list of directories containing source code -# DATA is a list of directories containing data files -# INCLUDES is a list of directories containing header files -#--------------------------------------------------------------------------------- -TARGET := $(notdir $(CURDIR)) -SOURCES ?= $(shell find source -type d) -DATA := data -INCLUDES := include - -DEFINES := - -#--------------------------------------------------------------------------------- -# options for code generation -#--------------------------------------------------------------------------------- -ARCH := -march=armv8-a -mtune=cortex-a57 -mtp=soft -fPIE - -CFLAGS := -g -Wall -O2 -ffunction-sections \ - $(ARCH) $(DEFINES) - -CFLAGS += $(INCLUDE) -D__SWITCH__ - -CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++17 -flto - -ASFLAGS := -g $(ARCH) -LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) - -LIBS := -lnx - -#--------------------------------------------------------------------------------- -# list of directories containing libraries, this must be the top level containing -# include and lib -#--------------------------------------------------------------------------------- -LIBDIRS := $(PORTLIBS) $(LIBNX) - -#--------------------------------------------------------------------------------- -# no real need to edit anything past this point unless you need to add additional -# rules for different file extensions -#--------------------------------------------------------------------------------- -ifneq ($(BUILD),$(notdir $(CURDIR))) -#--------------------------------------------------------------------------------- - -export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ - $(foreach dir,$(DATA),$(CURDIR)/$(dir)) - -CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) -CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) -SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) -BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) - -#--------------------------------------------------------------------------------- -# use CXX for linking C++ projects, CC for standard C -#--------------------------------------------------------------------------------- -ifeq ($(strip $(CPPFILES)),) -#--------------------------------------------------------------------------------- - export LD := $(CC) -#--------------------------------------------------------------------------------- -else -#--------------------------------------------------------------------------------- - export LD := $(CXX) -#--------------------------------------------------------------------------------- -endif -#--------------------------------------------------------------------------------- - -export OFILES_BIN := $(addsuffix .o,$(BINFILES)) -export OFILES_SRC := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) -export OFILES := $(OFILES_BIN) $(OFILES_SRC) -export HFILES := $(addsuffix .h,$(subst .,_,$(BINFILES))) - -export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ - $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ - -I. \ - -iquote $(CURDIR)/include/switch/ - -.PHONY: clean all - -#--------------------------------------------------------------------------------- -all: lib/$(TARGET).a - -lib: - @[ -d $@ ] || mkdir -p $@ - -release: - @[ -d $@ ] || mkdir -p $@ - -lib/$(TARGET).a : lib release $(SOURCES) $(INCLUDES) - @$(MAKE) BUILD=release OUTPUT=$(CURDIR)/$@ \ - BUILD_CFLAGS="-DNDEBUG=1 -O2" \ - DEPSDIR=$(CURDIR)/release \ - --no-print-directory -C release \ - -f $(CURDIR)/Makefile - -dist-bin: all - @tar --exclude=*~ -cjf $(TARGET).tar.bz2 include lib - -dist-src: - @tar --exclude=*~ -cjf $(TARGET)-src.tar.bz2 include source Makefile - -dist: dist-src dist-bin - -#--------------------------------------------------------------------------------- -clean: - @echo clean ... - @rm -fr release lib *.bz2 - -#--------------------------------------------------------------------------------- -else - -DEPENDS := $(OFILES:.o=.d) - -#--------------------------------------------------------------------------------- -# main targets -#--------------------------------------------------------------------------------- -$(OUTPUT) : $(OFILES) - -$(OFILES_SRC) : $(HFILES) - -#--------------------------------------------------------------------------------- -%_bin.h %.bin.o : %.bin -#--------------------------------------------------------------------------------- - @echo $(notdir $<) - @$(bin2o) - - --include $(DEPENDS) - -#--------------------------------------------------------------------------------------- -endif -#--------------------------------------------------------------------------------------- - diff --git a/stratosphere/libstratosphere/README.md b/stratosphere/libstratosphere/README.md deleted file mode 100644 index 0dc7138b4..000000000 --- a/stratosphere/libstratosphere/README.md +++ /dev/null @@ -1,31 +0,0 @@ -![License](https://img.shields.io/badge/License-GPLv2-blue.svg) - -libstratosphere is a work-in-progress C++ library for development of system modules for the Nintendo Switch. - -It is built around extending [libnx](https://github.com/switchbrew/libnx). - -It also provides bindings for custom extensions to Horizon OS implemented by [Atmosphère](https://github.com/Atmosphere-NX). - -Licensing -===== - -This software is licensed under the terms of the GPLv2, with exemptions for specific projects noted below. - -You can find a copy of the license in the [LICENSE file](LICENSE). - -Exemptions: -* The [yuzu emulator project](https://github.com/yuzu-emu/yuzu) is exempt from GPLv2 licensing and may (at its option) instead license any source code authored for the libstratosphere project as GPLv2 or later. - -Credits -===== - -libstratosphere is currently being developed and maintained by __SciresM__.
- -In addition to those credited in [Atmosphère's credits](https://github.com/Atmosphere-NX/Atmosphere/blob/master/README.md#Credits), we would like to thank for contributing to libstratosphere in some significant way: - -* __hthh__ -* __fincs__ -* __lioncash__ -* __misson20000__ -* __neobrain__ -* __yellows8__ diff --git a/stratosphere/libstratosphere/include/atmosphere/common.hpp b/stratosphere/libstratosphere/include/atmosphere/common.hpp deleted file mode 100644 index 6a87be4fe..000000000 --- a/stratosphere/libstratosphere/include/atmosphere/common.hpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include "common_includes.hpp" -#include "defines.hpp" -#include "util.hpp" -#include "results.hpp" -#include "svc.hpp" diff --git a/stratosphere/libstratosphere/include/atmosphere/common_includes.hpp b/stratosphere/libstratosphere/include/atmosphere/common_includes.hpp deleted file mode 100644 index 82887c8aa..000000000 --- a/stratosphere/libstratosphere/include/atmosphere/common_includes.hpp +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once - -/* C headers. */ -#include -#include -#include -#include -#include -#include -#include -#include - -/* C++ headers. */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* Libnx. */ -#include - -/* Atmosphere meta. */ -#if __has_include() -#include -#endif diff --git a/stratosphere/libstratosphere/include/atmosphere/defines.hpp b/stratosphere/libstratosphere/include/atmosphere/defines.hpp deleted file mode 100644 index a20d4c765..000000000 --- a/stratosphere/libstratosphere/include/atmosphere/defines.hpp +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include "common_includes.hpp" - -/* Any broadly useful language defines should go here. */ - -#define AMS_ASSERT(expr) do { if (!(expr)) { std::abort(); } } while (0) - -#define AMS_UNREACHABLE_DEFAULT_CASE() default: std::abort() - -#define NON_COPYABLE(cls) \ - cls(const cls&) = delete; \ - cls& operator=(const cls&) = delete - -#define NON_MOVEABLE(cls) \ - cls(cls&&) = delete; \ - cls& operator=(cls&&) = delete - -#define ALIGNED(algn) __attribute__((aligned(algn))) -#define NORETURN __attribute__((noreturn)) -#define WEAK __attribute__((weak)) - - -#define CONCATENATE_IMPL(S1, s2) s1##s2 -#define CONCATENATE(s1, s2) CONCATENATE_IMPL(s1, s2) - -#ifdef __COUNTER__ -#define ANONYMOUS_VARIABLE(pref) CONCATENATE(pref, __COUNTER__) -#else -#define ANONYMOUS_VARIABLE(pref) CONCATENATE(pref, __LINE__) -#endif diff --git a/stratosphere/libstratosphere/include/atmosphere/results.hpp b/stratosphere/libstratosphere/include/atmosphere/results.hpp deleted file mode 100644 index 992733d70..000000000 --- a/stratosphere/libstratosphere/include/atmosphere/results.hpp +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include "defines.hpp" -#include "util.hpp" - -/* Utilities. */ -#include "results/results_common.hpp" - -/* Official. */ -#include "results/cal_results.hpp" -#include "results/creport_results.hpp" -#include "results/debug_results.hpp" -#include "results/dmnt_results.hpp" -#include "results/err_results.hpp" -#include "results/fatal_results.hpp" -#include "results/fs_results.hpp" -#include "results/hipc_results.hpp" -#include "results/i2c_results.hpp" -#include "results/kvdb_results.hpp" -#include "results/loader_results.hpp" -#include "results/lr_results.hpp" -#include "results/os_results.hpp" -#include "results/ncm_results.hpp" -#include "results/pm_results.hpp" -#include "results/ro_results.hpp" -#include "results/settings_results.hpp" -#include "results/sf_results.hpp" -#include "results/sm_results.hpp" -#include "results/spl_results.hpp" -#include "results/svc_results.hpp" -#include "results/updater_results.hpp" -#include "results/vi_results.hpp" - -/* Unofficial. */ -#include "results/exosphere_results.hpp" diff --git a/stratosphere/libstratosphere/include/atmosphere/results/cal_results.hpp b/stratosphere/libstratosphere/include/atmosphere/results/cal_results.hpp deleted file mode 100644 index 69f3a8b1f..000000000 --- a/stratosphere/libstratosphere/include/atmosphere/results/cal_results.hpp +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include "results_common.hpp" - -namespace ams::cal { - - R_DEFINE_NAMESPACE_RESULT_MODULE(198); - - R_DEFINE_ERROR_RESULT(CalibrationDataCrcError, 101); - -} diff --git a/stratosphere/libstratosphere/include/atmosphere/results/creport_results.hpp b/stratosphere/libstratosphere/include/atmosphere/results/creport_results.hpp deleted file mode 100644 index 6f836d8bf..000000000 --- a/stratosphere/libstratosphere/include/atmosphere/results/creport_results.hpp +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include "results_common.hpp" - -namespace ams::creport { - - R_DEFINE_NAMESPACE_RESULT_MODULE(168); - - R_DEFINE_ERROR_RESULT(UndefinedInstruction, 0); - R_DEFINE_ERROR_RESULT(InstructionAbort, 1); - R_DEFINE_ERROR_RESULT(DataAbort, 2); - R_DEFINE_ERROR_RESULT(AlignmentFault, 3); - R_DEFINE_ERROR_RESULT(DebuggerAttached, 4); - R_DEFINE_ERROR_RESULT(BreakPoint, 5); - R_DEFINE_ERROR_RESULT(UserBreak, 6); - R_DEFINE_ERROR_RESULT(DebuggerBreak, 7); - R_DEFINE_ERROR_RESULT(UndefinedSystemCall, 8); - R_DEFINE_ERROR_RESULT(SystemMemoryError, 9); - - R_DEFINE_ERROR_RESULT(IncompleteReport, 99); - -} diff --git a/stratosphere/libstratosphere/include/atmosphere/results/debug_results.hpp b/stratosphere/libstratosphere/include/atmosphere/results/debug_results.hpp deleted file mode 100644 index fcf9d6613..000000000 --- a/stratosphere/libstratosphere/include/atmosphere/results/debug_results.hpp +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include "results_common.hpp" - -namespace ams::dbg { - - R_DEFINE_NAMESPACE_RESULT_MODULE(183); - - R_DEFINE_ERROR_RESULT(CannotDebug, 1); - R_DEFINE_ERROR_RESULT(AlreadyAttached, 2); - R_DEFINE_ERROR_RESULT(Cancelled, 3); - -} diff --git a/stratosphere/libstratosphere/include/atmosphere/results/dmnt_results.hpp b/stratosphere/libstratosphere/include/atmosphere/results/dmnt_results.hpp deleted file mode 100644 index aaa1a3d80..000000000 --- a/stratosphere/libstratosphere/include/atmosphere/results/dmnt_results.hpp +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include "results_common.hpp" - -namespace ams::dmnt { - - R_DEFINE_NAMESPACE_RESULT_MODULE(13); - - R_DEFINE_ERROR_RESULT(Unknown, 1); - R_DEFINE_ERROR_RESULT(DebuggingDisabled, 2); - - /* Atmosphere extension. */ - namespace cheat { - - R_DEFINE_ABSTRACT_ERROR_RANGE(CheatError, 6500, 6599); - R_DEFINE_ERROR_RESULT(CheatNotAttached, 6500); - R_DEFINE_ERROR_RESULT(CheatNullBuffer, 6501); - R_DEFINE_ERROR_RESULT(CheatInvalidBuffer, 6502); - R_DEFINE_ERROR_RESULT(CheatUnknownId, 6503); - R_DEFINE_ERROR_RESULT(CheatOutOfResource, 6504); - R_DEFINE_ERROR_RESULT(CheatInvalid, 6505); - R_DEFINE_ERROR_RESULT(CheatCannotDisable, 6506); - - R_DEFINE_ABSTRACT_ERROR_RANGE(FrozenAddressError, 6600, 6699); - R_DEFINE_ERROR_RESULT(FrozenAddressInvalidWidth, 6600); - R_DEFINE_ERROR_RESULT(FrozenAddressAlreadyExists, 6601); - R_DEFINE_ERROR_RESULT(FrozenAddressNotFound, 6602); - R_DEFINE_ERROR_RESULT(FrozenAddressOutOfResource, 6603); - - R_DEFINE_ABSTRACT_ERROR_RANGE(VirtualMachineError, 6700, 6799); - R_DEFINE_ERROR_RESULT(VirtualMachineInvalidConditionDepth, 6700); - - } - -} diff --git a/stratosphere/libstratosphere/include/atmosphere/results/err_results.hpp b/stratosphere/libstratosphere/include/atmosphere/results/err_results.hpp deleted file mode 100644 index dd46dc539..000000000 --- a/stratosphere/libstratosphere/include/atmosphere/results/err_results.hpp +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include "results_common.hpp" - -namespace ams::err { - - R_DEFINE_NAMESPACE_RESULT_MODULE(162); - - R_DEFINE_ERROR_RESULT(ApplicationAborted, 1); - R_DEFINE_ERROR_RESULT(SystemModuleAborted, 2); - -} diff --git a/stratosphere/libstratosphere/include/atmosphere/results/exosphere_results.hpp b/stratosphere/libstratosphere/include/atmosphere/results/exosphere_results.hpp deleted file mode 100644 index 8804473bb..000000000 --- a/stratosphere/libstratosphere/include/atmosphere/results/exosphere_results.hpp +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include "results_common.hpp" - -namespace ams::exosphere { - - /* Please note: These results are all custom, and not official. */ - R_DEFINE_NAMESPACE_RESULT_MODULE(444); - - - /* Result 1-1000 reserved for Atmosphere. */ - R_DEFINE_ERROR_RESULT(NotPresent, 1); - R_DEFINE_ERROR_RESULT(VersionMismatch, 2); - -} diff --git a/stratosphere/libstratosphere/include/atmosphere/results/fatal_results.hpp b/stratosphere/libstratosphere/include/atmosphere/results/fatal_results.hpp deleted file mode 100644 index 076171d59..000000000 --- a/stratosphere/libstratosphere/include/atmosphere/results/fatal_results.hpp +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include "results_common.hpp" - -namespace ams::fatal { - - R_DEFINE_NAMESPACE_RESULT_MODULE(163); - - R_DEFINE_ERROR_RESULT(AllocationFailed, 1); - R_DEFINE_ERROR_RESULT(NullGraphicsBuffer, 2); - R_DEFINE_ERROR_RESULT(AlreadyThrown, 3); - R_DEFINE_ERROR_RESULT(TooManyEvents, 4); - R_DEFINE_ERROR_RESULT(InRepairWithoutVolHeld, 5); - R_DEFINE_ERROR_RESULT(InRepairWithoutTimeReviserCartridge, 6); - -} diff --git a/stratosphere/libstratosphere/include/atmosphere/results/fs_results.hpp b/stratosphere/libstratosphere/include/atmosphere/results/fs_results.hpp deleted file mode 100644 index f7fe264a1..000000000 --- a/stratosphere/libstratosphere/include/atmosphere/results/fs_results.hpp +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include "results_common.hpp" - -namespace ams::fs { - - R_DEFINE_NAMESPACE_RESULT_MODULE(2); - - R_DEFINE_ERROR_RESULT(PathNotFound, 1); - R_DEFINE_ERROR_RESULT(PathAlreadyExists, 2); - - R_DEFINE_ERROR_RESULT(TargetLocked, 7); - R_DEFINE_ERROR_RESULT(DirectoryNotEmpty, 8); - - R_DEFINE_ERROR_RANGE (NotEnoughFreeSpace, 30, 45); - R_DEFINE_ERROR_RANGE(NotEnoughFreeSpaceBis, 34, 38); - R_DEFINE_ERROR_RESULT(NotEnoughFreeSpaceBisCalibration, 35); - R_DEFINE_ERROR_RESULT(NotEnoughFreeSpaceBisSafe, 36); - R_DEFINE_ERROR_RESULT(NotEnoughFreeSpaceBisUser, 37); - R_DEFINE_ERROR_RESULT(NotEnoughFreeSpaceBisSystem, 38); - R_DEFINE_ERROR_RESULT(NotEnoughFreeSpaceSdCard, 39); - - R_DEFINE_ERROR_RESULT(MountNameAlreadyExists, 60); - - R_DEFINE_ERROR_RESULT(TargetNotFound, 1002); - - R_DEFINE_ERROR_RANGE(SdCardAccessFailed, 2000, 2499); - R_DEFINE_ERROR_RESULT(SdCardNotPresent, 2001); - - R_DEFINE_ERROR_RANGE(GameCardAccessFailed, 2500, 2999); - - R_DEFINE_ERROR_RESULT(NotImplemented, 3001); - R_DEFINE_ERROR_RESULT(OutOfRange, 3005); - - R_DEFINE_ERROR_RANGE(AllocationFailure, 3200, 3499); - R_DEFINE_ERROR_RESULT(AllocationFailureInDirectorySaveDataFileSystem, 3321); - R_DEFINE_ERROR_RESULT(AllocationFailureInSubDirectoryFileSystem, 3355); - R_DEFINE_ERROR_RESULT(AllocationFailureInPathNormalizer, 3367); - R_DEFINE_ERROR_RESULT(AllocationFailureInFileSystemInterfaceAdapter, 3407); - - R_DEFINE_ERROR_RANGE(MmcAccessFailed, 3500, 3999); - - R_DEFINE_ERROR_RANGE(DataCorrupted, 4000, 4999); - R_DEFINE_ERROR_RANGE(RomCorrupted, 4001, 4299); - R_DEFINE_ERROR_RANGE(SaveDataCorrupted, 4301, 4499); - R_DEFINE_ERROR_RANGE(NcaCorrupted, 4501, 4599); - R_DEFINE_ERROR_RANGE(IntegrityVerificationStorageCorrupted, 4601, 4639); - R_DEFINE_ERROR_RANGE(PartitionFileSystemCorrupted, 4641, 4659); - R_DEFINE_ERROR_RANGE(BuiltInStorageCorrupted, 4661, 4679); - R_DEFINE_ERROR_RANGE(HostFileSystemCorrupted, 4701, 4719); - R_DEFINE_ERROR_RANGE(DatabaseCorrupted, 4721, 4739); - R_DEFINE_ERROR_RANGE(AesXtsFileSystemCorrupted, 4741, 4759); - R_DEFINE_ERROR_RANGE(SaveDataTransferDataCorrupted, 4761, 4769); - R_DEFINE_ERROR_RANGE(SignedSystemPartitionDataCorrupted, 4771, 4779); - - R_DEFINE_ERROR_RESULT(GameCardLogoDataCorrupted, 4781); - - R_DEFINE_ERROR_RANGE(Unexpected, 5000, 5999); - - R_DEFINE_ERROR_RANGE(PreconditionViolation, 6000, 6499); - R_DEFINE_ERROR_RANGE(InvalidArgument, 6001, 6199); - R_DEFINE_ERROR_RANGE(InvalidPath, 6002, 6029); - R_DEFINE_ERROR_RESULT(TooLongPath, 6003); - R_DEFINE_ERROR_RESULT(InvalidCharacter, 6004); - R_DEFINE_ERROR_RESULT(InvalidPathFormat, 6005); - R_DEFINE_ERROR_RESULT(DirectoryUnobtainable, 6006); - R_DEFINE_ERROR_RESULT(NotNormalized, 6007); - - R_DEFINE_ERROR_RANGE(InvalidPathForOperation, 6030, 6059); - R_DEFINE_ERROR_RESULT(DirectoryNotDeletable, 6031); - R_DEFINE_ERROR_RESULT(DirectoryNotRenamable, 6032); - R_DEFINE_ERROR_RESULT(IncompatiblePath, 6033); - R_DEFINE_ERROR_RESULT(RenameToOtherFileSystem, 6034); - - R_DEFINE_ERROR_RESULT(InvalidOffset, 6061); - R_DEFINE_ERROR_RESULT(InvalidSize, 6062); - R_DEFINE_ERROR_RESULT(NullptrArgument, 6063); - R_DEFINE_ERROR_RESULT(InvalidAlignment, 6064); - R_DEFINE_ERROR_RESULT(InvalidMountName, 6065); - - R_DEFINE_ERROR_RESULT(ExtensionSizeTooLarge, 6066); - R_DEFINE_ERROR_RESULT(ExtensionSizeInvalid, 6067); - - R_DEFINE_ERROR_RANGE(InvalidEnumValue, 6080, 6099); - R_DEFINE_ERROR_RESULT(InvalidSaveDataState, 6081); - R_DEFINE_ERROR_RESULT(InvalidSaveDataSpaceId, 6082); - - R_DEFINE_ERROR_RANGE(InvalidOperationForOpenMode, 6200, 6299); - R_DEFINE_ERROR_RESULT(FileExtensionWithoutOpenModeAllowAppend, 6201); - - R_DEFINE_ERROR_RANGE(UnsupportedOperation, 6300, 6399); - - R_DEFINE_ERROR_RANGE(PermissionDenied, 6400, 6449); - - R_DEFINE_ERROR_RESULT(WriteModeFileNotClosed, 6457); - R_DEFINE_ERROR_RESULT(AllocatorAlignmentViolation, 6461); - R_DEFINE_ERROR_RESULT(UserNotExist, 6465); - - R_DEFINE_ERROR_RANGE(OutOfResource, 6700, 6799); - R_DEFINE_ERROR_RESULT(MappingTableFull, 6706); - R_DEFINE_ERROR_RESULT(OpenCountLimit, 6709); - - R_DEFINE_ERROR_RANGE(MappingFailed, 6800, 6899); - R_DEFINE_ERROR_RESULT(MapFull, 6811); - - R_DEFINE_ERROR_RANGE(BadState, 6900, 6999); - R_DEFINE_ERROR_RESULT(NotMounted, 6905); - -} diff --git a/stratosphere/libstratosphere/include/atmosphere/results/hipc_results.hpp b/stratosphere/libstratosphere/include/atmosphere/results/hipc_results.hpp deleted file mode 100644 index 65f396f01..000000000 --- a/stratosphere/libstratosphere/include/atmosphere/results/hipc_results.hpp +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include "results_common.hpp" - -namespace ams::sf::hipc { - - R_DEFINE_NAMESPACE_RESULT_MODULE(11); - - R_DEFINE_ABSTRACT_ERROR_RANGE(OutOfResource, 100, 299); - R_DEFINE_ERROR_RESULT(OutOfSessionMemory, 102); - R_DEFINE_ERROR_RANGE (OutOfSessions, 131, 139); - R_DEFINE_ERROR_RESULT(PointerBufferTooSmall, 141); - - R_DEFINE_ERROR_RESULT(OutOfDomains, 200); - - R_DEFINE_ERROR_RESULT(SessionClosed, 301); - - R_DEFINE_ERROR_RESULT(InvalidRequestSize, 402); - R_DEFINE_ERROR_RESULT(UnknownCommandType, 403); - - R_DEFINE_ERROR_RESULT(InvalidCmifRequest, 420); - - R_DEFINE_ERROR_RESULT(TargetNotDomain, 491); - R_DEFINE_ERROR_RESULT(DomainObjectNotFound, 492); - -} diff --git a/stratosphere/libstratosphere/include/atmosphere/results/i2c_results.hpp b/stratosphere/libstratosphere/include/atmosphere/results/i2c_results.hpp deleted file mode 100644 index bd7f7955b..000000000 --- a/stratosphere/libstratosphere/include/atmosphere/results/i2c_results.hpp +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include "results_common.hpp" - -namespace ams::i2c { - - R_DEFINE_NAMESPACE_RESULT_MODULE(101); - - R_DEFINE_ERROR_RESULT(NoAck, 1); - R_DEFINE_ERROR_RESULT(BusBusy, 2); - R_DEFINE_ERROR_RESULT(FullCommandList, 3); - R_DEFINE_ERROR_RESULT(TimedOut, 4); - R_DEFINE_ERROR_RESULT(UnknownDevice, 5); - -} diff --git a/stratosphere/libstratosphere/include/atmosphere/results/kvdb_results.hpp b/stratosphere/libstratosphere/include/atmosphere/results/kvdb_results.hpp deleted file mode 100644 index 052ced408..000000000 --- a/stratosphere/libstratosphere/include/atmosphere/results/kvdb_results.hpp +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include "results_common.hpp" - -namespace ams::kvdb { - - R_DEFINE_NAMESPACE_RESULT_MODULE(20); - - R_DEFINE_ERROR_RESULT(OutOfKeyResource, 1); - R_DEFINE_ERROR_RESULT(KeyNotFound, 2); - R_DEFINE_ERROR_RESULT(AllocationFailed, 4); - R_DEFINE_ERROR_RESULT(InvalidKeyValue, 5); - R_DEFINE_ERROR_RESULT(BufferInsufficient, 6); - - R_DEFINE_ERROR_RESULT(InvalidFilesystemState, 8); - R_DEFINE_ERROR_RESULT(NotCreated, 9); - -} diff --git a/stratosphere/libstratosphere/include/atmosphere/results/loader_results.hpp b/stratosphere/libstratosphere/include/atmosphere/results/loader_results.hpp deleted file mode 100644 index 29b80bf42..000000000 --- a/stratosphere/libstratosphere/include/atmosphere/results/loader_results.hpp +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include "results_common.hpp" - -namespace ams::ldr { - - R_DEFINE_NAMESPACE_RESULT_MODULE(9); - - R_DEFINE_ERROR_RESULT(TooLongArgument, 1); - R_DEFINE_ERROR_RESULT(TooManyArguments, 2); - R_DEFINE_ERROR_RESULT(TooLargeMeta, 3); - R_DEFINE_ERROR_RESULT(InvalidMeta, 4); - R_DEFINE_ERROR_RESULT(InvalidNso, 5); - R_DEFINE_ERROR_RESULT(InvalidPath, 6); - R_DEFINE_ERROR_RESULT(TooManyProcesses, 7); - R_DEFINE_ERROR_RESULT(NotPinned, 8); - R_DEFINE_ERROR_RESULT(InvalidProgramId, 9); - R_DEFINE_ERROR_RESULT(InvalidVersion, 10); - - R_DEFINE_ERROR_RESULT(InsufficientAddressSpace, 51); - R_DEFINE_ERROR_RESULT(InvalidNro, 52); - R_DEFINE_ERROR_RESULT(InvalidNrr, 53); - R_DEFINE_ERROR_RESULT(InvalidSignature, 54); - R_DEFINE_ERROR_RESULT(InsufficientNroRegistrations, 55); - R_DEFINE_ERROR_RESULT(InsufficientNrrRegistrations, 56); - R_DEFINE_ERROR_RESULT(NroAlreadyLoaded, 57); - - R_DEFINE_ERROR_RESULT(InvalidAddress, 81); - R_DEFINE_ERROR_RESULT(InvalidSize, 82); - R_DEFINE_ERROR_RESULT(NotLoaded, 84); - R_DEFINE_ERROR_RESULT(NotRegistered, 85); - R_DEFINE_ERROR_RESULT(InvalidSession, 86); - R_DEFINE_ERROR_RESULT(InvalidProcess, 87); - - R_DEFINE_ERROR_RESULT(UnknownCapability, 100); - R_DEFINE_ERROR_RESULT(InvalidCapabilityKernelFlags, 103); - R_DEFINE_ERROR_RESULT(InvalidCapabilitySyscallMask, 104); - R_DEFINE_ERROR_RESULT(InvalidCapabilityMapRange, 106); - R_DEFINE_ERROR_RESULT(InvalidCapabilityMapPage, 107); - R_DEFINE_ERROR_RESULT(InvalidCapabilityInterruptPair, 111); - R_DEFINE_ERROR_RESULT(InvalidCapabilityApplicationType, 113); - R_DEFINE_ERROR_RESULT(InvalidCapabilityKernelVersion, 114); - R_DEFINE_ERROR_RESULT(InvalidCapabilityHandleTable, 115); - R_DEFINE_ERROR_RESULT(InvalidCapabilityDebugFlags, 116); - - R_DEFINE_ERROR_RESULT(InternalError, 200); - -} diff --git a/stratosphere/libstratosphere/include/atmosphere/results/lr_results.hpp b/stratosphere/libstratosphere/include/atmosphere/results/lr_results.hpp deleted file mode 100644 index c1983ee07..000000000 --- a/stratosphere/libstratosphere/include/atmosphere/results/lr_results.hpp +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include "results_common.hpp" - -namespace ams::lr { - - R_DEFINE_NAMESPACE_RESULT_MODULE(8); - - R_DEFINE_ERROR_RESULT(ProgramNotFound, 2); - R_DEFINE_ERROR_RESULT(DataNotFound, 3); - R_DEFINE_ERROR_RESULT(UnknownStorageId, 4); - R_DEFINE_ERROR_RESULT(HtmlDocumentNotFound, 6); - R_DEFINE_ERROR_RESULT(AddOnContentNotFound, 7); - R_DEFINE_ERROR_RESULT(ControlNotFound, 8); - R_DEFINE_ERROR_RESULT(LegalInformationNotFound, 9); - - R_DEFINE_ERROR_RESULT(TooManyRegisteredPaths, 90); - -} diff --git a/stratosphere/libstratosphere/include/atmosphere/results/ncm_results.hpp b/stratosphere/libstratosphere/include/atmosphere/results/ncm_results.hpp deleted file mode 100644 index cdba12c7c..000000000 --- a/stratosphere/libstratosphere/include/atmosphere/results/ncm_results.hpp +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include "results_common.hpp" - -namespace ams::ncm { - - R_DEFINE_NAMESPACE_RESULT_MODULE(5); - - R_DEFINE_ERROR_RESULT(PlaceHolderAlreadyExists, 2); - R_DEFINE_ERROR_RESULT(PlaceHolderNotFound, 3); - R_DEFINE_ERROR_RESULT(ContentAlreadyExists, 4); - R_DEFINE_ERROR_RESULT(ContentNotFound, 5); - R_DEFINE_ERROR_RESULT(ContentMetaNotFound, 7); - R_DEFINE_ERROR_RESULT(AllocationFailed, 8); - R_DEFINE_ERROR_RESULT(UnknownStorage, 12); - - R_DEFINE_ERROR_RESULT(InvalidContentStorage, 100); - R_DEFINE_ERROR_RESULT(InvalidContentMetaDatabase, 110); - - R_DEFINE_ERROR_RESULT(BufferInsufficient, 180); - R_DEFINE_ERROR_RESULT(InvalidContentMetaKey, 240); - - R_DEFINE_ERROR_RANGE(ContentStorageNotActive, 250, 258); - R_DEFINE_ERROR_RESULT(GameCardContentStorageNotActive, 251); - R_DEFINE_ERROR_RESULT(NandSystemContentStorageNotActive, 252); - R_DEFINE_ERROR_RESULT(NandUserContentStorageNotActive, 253); - R_DEFINE_ERROR_RESULT(SdCardContentStorageNotActive, 254); - R_DEFINE_ERROR_RESULT(UnknownContentStorageNotActive, 258); - - R_DEFINE_ERROR_RANGE(ContentMetaDatabaseNotActive, 260, 268); - R_DEFINE_ERROR_RESULT(GameCardContentMetaDatabaseNotActive, 261); - R_DEFINE_ERROR_RESULT(NandSystemContentMetaDatabaseNotActive, 262); - R_DEFINE_ERROR_RESULT(NandUserContentMetaDatabaseNotActive, 263); - R_DEFINE_ERROR_RESULT(SdCardContentMetaDatabaseNotActive, 264); - R_DEFINE_ERROR_RESULT(UnknownContentMetaDatabaseNotActive, 268); - - R_DEFINE_ERROR_RANGE(InvalidArgument, 8181, 8191); - R_DEFINE_ERROR_RESULT(InvalidOffset, 8182); - -} diff --git a/stratosphere/libstratosphere/include/atmosphere/results/os_results.hpp b/stratosphere/libstratosphere/include/atmosphere/results/os_results.hpp deleted file mode 100644 index 5fd716d00..000000000 --- a/stratosphere/libstratosphere/include/atmosphere/results/os_results.hpp +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include "results_common.hpp" - -namespace ams::os { - - R_DEFINE_NAMESPACE_RESULT_MODULE(3); - - R_DEFINE_ERROR_RESULT(Busy, 4); - - R_DEFINE_ERROR_RESULT(OutOfMemory, 8); - R_DEFINE_ERROR_RESULT(OutOfResource, 9); - - R_DEFINE_ERROR_RESULT(OutOfVirtualAddressSpace, 12); - R_DEFINE_ERROR_RESULT(ResourceLimit, 13); - -} diff --git a/stratosphere/libstratosphere/include/atmosphere/results/pm_results.hpp b/stratosphere/libstratosphere/include/atmosphere/results/pm_results.hpp deleted file mode 100644 index 50d4c3f7e..000000000 --- a/stratosphere/libstratosphere/include/atmosphere/results/pm_results.hpp +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include "results_common.hpp" - -namespace ams::pm { - - R_DEFINE_NAMESPACE_RESULT_MODULE(15); - - R_DEFINE_ERROR_RESULT(ProcessNotFound, 1); - R_DEFINE_ERROR_RESULT(AlreadyStarted, 2); - R_DEFINE_ERROR_RESULT(NotExited, 3); - R_DEFINE_ERROR_RESULT(DebugHookInUse, 4); - R_DEFINE_ERROR_RESULT(ApplicationRunning, 5); - R_DEFINE_ERROR_RESULT(InvalidSize, 6); - -} diff --git a/stratosphere/libstratosphere/include/atmosphere/results/results_common.hpp b/stratosphere/libstratosphere/include/atmosphere/results/results_common.hpp deleted file mode 100644 index 3166e4736..000000000 --- a/stratosphere/libstratosphere/include/atmosphere/results/results_common.hpp +++ /dev/null @@ -1,289 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include "../defines.hpp" - -namespace ams { - - namespace result::impl { - - class ResultTraits { - public: - using BaseType = u32; - static_assert(std::is_same::value, "std::is_same::value"); - static constexpr BaseType SuccessValue = BaseType(); - static constexpr BaseType ModuleBits = 9; - static constexpr BaseType DescriptionBits = 13; - static constexpr BaseType ReservedBits = 10; - static_assert(ModuleBits + DescriptionBits + ReservedBits == sizeof(BaseType) * CHAR_BIT, "ModuleBits + DescriptionBits + ReservedBits == sizeof(BaseType) * CHAR_BIT"); - public: - NX_CONSTEXPR BaseType MakeValue(BaseType module, BaseType description) { - return (module) | (description << ModuleBits); - } - - template - struct MakeStaticValue : public std::integral_constant { - static_assert(module < (1 << ModuleBits), "Invalid Module"); - static_assert(description < (1 << DescriptionBits), "Invalid Description"); - }; - - NX_CONSTEXPR BaseType GetModuleFromValue(BaseType value) { - return value & ~(~BaseType() << ModuleBits); - } - - NX_CONSTEXPR BaseType GetDescriptionFromValue(BaseType value) { - return ((value >> ModuleBits) & ~(~BaseType() << DescriptionBits)); - } - }; - - /* Use CRTP for Results. */ - template - class ResultBase { - public: - using BaseType = typename ResultTraits::BaseType; - static constexpr BaseType SuccessValue = ResultTraits::SuccessValue; - public: - constexpr inline BaseType GetModule() const { return ResultTraits::GetModuleFromValue(static_cast(this)->GetValue()); } - constexpr inline BaseType GetDescription() const { return ResultTraits::GetDescriptionFromValue(static_cast(this)->GetValue()); } - }; - - class ResultConstructor; - - } - - class ResultSuccess; - - class Result final : public result::impl::ResultBase { - friend class ResultConstructor; - public: - using Base = typename result::impl::ResultBase; - private: - typename Base::BaseType value; - private: - /* TODO: Maybe one-day, the result constructor. */ - public: - Result() { /* ... */ } - - /* TODO: It sure would be nice to make this private. */ - constexpr Result(typename Base::BaseType v) : value(v) { static_assert(std::is_same::value); } - - constexpr inline operator ResultSuccess() const; - NX_CONSTEXPR bool CanAccept(Result result) { return true; } - - constexpr inline bool IsSuccess() const { return this->GetValue() == Base::SuccessValue; } - constexpr inline bool IsFailure() const { return !this->IsSuccess(); } - constexpr inline typename Base::BaseType GetModule() const { return Base::GetModule(); } - constexpr inline typename Base::BaseType GetDescription() const { return Base::GetDescription(); } - - constexpr inline typename Base::BaseType GetValue() const { return this->value; } - }; - static_assert(sizeof(Result) == sizeof(Result::Base::BaseType), "sizeof(Result) == sizeof(Result::Base::BaseType)"); - static_assert(std::is_trivially_destructible::value, "std::is_trivially_destructible::value"); - - namespace result::impl { - - class ResultConstructor { - public: - static constexpr inline Result MakeResult(ResultTraits::BaseType value) { - return Result(value); - } - }; - - constexpr inline Result MakeResult(ResultTraits::BaseType value) { - return ResultConstructor::MakeResult(value); - } - - } - - class ResultSuccess final : public result::impl::ResultBase { - public: - using Base = typename result::impl::ResultBase; - public: - constexpr operator Result() const { return result::impl::MakeResult(Base::SuccessValue); } - NX_CONSTEXPR bool CanAccept(Result result) { return result.IsSuccess(); } - - constexpr inline bool IsSuccess() const { return true; } - constexpr inline bool IsFailure() const { return !this->IsSuccess(); } - constexpr inline typename Base::BaseType GetModule() const { return Base::GetModule(); } - constexpr inline typename Base::BaseType GetDescription() const { return Base::GetDescription(); } - - constexpr inline typename Base::BaseType GetValue() const { return Base::SuccessValue; } - }; - - namespace result::impl { - - NORETURN void OnResultAssertion(Result result); - - } - - constexpr inline Result::operator ResultSuccess() const { - if (!ResultSuccess::CanAccept(*this)) { - result::impl::OnResultAssertion(*this); - } - return ResultSuccess(); - } - - namespace result::impl { - - template - class ResultErrorBase : public ResultBase> { - public: - using Base = typename result::impl::ResultBase>; - static constexpr typename Base::BaseType Module = _Module; - static constexpr typename Base::BaseType Description = _Description; - static constexpr typename Base::BaseType Value = ResultTraits::MakeStaticValue::value; - static_assert(Value != Base::SuccessValue, "Value != Base::SuccessValue"); - public: - constexpr operator Result() const { return MakeResult(Value); } - constexpr operator ResultSuccess() const { OnResultAssertion(Value); } - - constexpr inline bool IsSuccess() const { return false; } - constexpr inline bool IsFailure() const { return !this->IsSuccess(); } - - constexpr inline typename Base::BaseType GetValue() const { return Value; } - }; - - template - class ResultErrorRangeBase { - public: - static constexpr ResultTraits::BaseType Module = _Module; - static constexpr ResultTraits::BaseType DescriptionStart = DescStart; - static constexpr ResultTraits::BaseType DescriptionEnd = DescEnd; - static_assert(DescriptionStart <= DescriptionEnd, "DescriptionStart <= DescriptionEnd"); - static constexpr typename ResultTraits::BaseType StartValue = ResultTraits::MakeStaticValue::value; - static constexpr typename ResultTraits::BaseType EndValue = ResultTraits::MakeStaticValue::value; - public: - NX_CONSTEXPR bool Includes(Result result) { - return StartValue <= result.GetValue() && result.GetValue() <= EndValue; - } - }; - - } - -} - -/* Macros for defining new results. */ -#define R_DEFINE_NAMESPACE_RESULT_MODULE(value) namespace impl::result { static constexpr inline ::ams::result::impl::ResultTraits::BaseType ResultModuleId = value; } -#define R_CURRENT_NAMESPACE_RESULT_MODULE impl::result::ResultModuleId -#define R_NAMESPACE_MODULE_ID(nmspc) nmspc::R_CURRENT_NAMESPACE_RESULT_MODULE - -#define R_MAKE_NAMESPACE_RESULT(nmspc, desc) static_cast<::ams::Result>(::ams::result::impl::ResultTraits::MakeValue(R_NAMESPACE_MODULE_ID(nmspc), desc)) - -#define R_DEFINE_ERROR_RESULT_IMPL(name, desc_start, desc_end) \ - class Result##name final : public ::ams::result::impl::ResultErrorBase, public ::ams::result::impl::ResultErrorRangeBase {} - -#define R_DEFINE_ABSTRACT_ERROR_RESULT_IMPL(name, desc_start, desc_end) \ - class Result##name final : public ::ams::result::impl::ResultErrorRangeBase {} - - -#define R_DEFINE_ERROR_RESULT(name, desc) R_DEFINE_ERROR_RESULT_IMPL(name, desc, desc) -#define R_DEFINE_ERROR_RANGE(name, start, end) R_DEFINE_ERROR_RESULT_IMPL(name, start, end) - -#define R_DEFINE_ABSTRACT_ERROR_RESULT(name, desc) R_DEFINE_ABSTRACT_ERROR_RESULT_IMPL(name, desc, desc) -#define R_DEFINE_ABSTRACT_ERROR_RANGE(name, start, end) R_DEFINE_ABSTRACT_ERROR_RESULT_IMPL(name, start, end) - -/* Remove libnx macros, replace with our own. */ -#ifndef R_SUCCEEDED -#error "R_SUCCEEDED not defined." -#endif - -#undef R_SUCCEEDED - -#ifndef R_FAILED -#error "R_FAILED not defined" -#endif - -#undef R_FAILED - -#define R_SUCCEEDED(res) (static_cast<::ams::Result>(res).IsSuccess()) -#define R_FAILED(res) (static_cast<::ams::Result>(res).IsFailure()) - - -/// Evaluates an expression that returns a result, and returns the result if it would fail. -#define R_TRY(res_expr) \ - ({ \ - const auto _tmp_r_try_rc = res_expr; \ - if (R_FAILED(_tmp_r_try_rc)) { \ - return _tmp_r_try_rc; \ - } \ - }) - -/// Evaluates an expression that returns a result, and fatals the result if it would fail. -#define R_ASSERT(res_expr) \ - ({ \ - const auto _tmp_r_assert_rc = res_expr; \ - if (R_FAILED(_tmp_r_assert_rc)) { \ - ::ams::result::impl::OnResultAssertion(_tmp_r_assert_rc); \ - } \ - }) - -/// Evaluates a boolean expression, and returns a result unless that expression is true. -#define R_UNLESS(expr, res) \ - ({ \ - if (!(expr)) { \ - return static_cast<::ams::Result>(res); \ - } \ - }) - -/// Helpers for pattern-matching on a result expression, if the result would fail. -#define R_CURRENT_RESULT _tmp_r_current_result - -#define R_TRY_CATCH(res_expr) \ - ({ \ - const auto R_CURRENT_RESULT = res_expr; \ - if (R_FAILED(R_CURRENT_RESULT)) { \ - if (false) - -namespace ams::result::impl { - - template - NX_CONSTEXPR bool AnyIncludes(Result result) { - return (Rs::Includes(result) || ...); - } - -} - -#define R_CATCH(...) \ - } else if (::ams::result::impl::AnyIncludes<__VA_ARGS__>(R_CURRENT_RESULT)) { \ - if (true) - -#define R_CONVERT(catch_type, convert_type) \ - R_CATCH(catch_type) { return static_cast<::ams::Result>(convert_type); } - -#define R_CATCH_ALL() \ - } else if (R_FAILED(R_CURRENT_RESULT)) { \ - if (true) - -#define R_CONVERT_ALL(convert_type) \ - R_CATCH_ALL() { return static_cast<::ams::Result>(convert_type); } - -#define R_CATCH_RETHROW(catch_type) \ - R_CONVERT(catch_type, R_CURRENT_RESULT) - -#define R_END_TRY_CATCH \ - else if (R_FAILED(R_CURRENT_RESULT)) { \ - return R_CURRENT_RESULT; \ - } \ - } \ - }) - -#define R_END_TRY_CATCH_WITH_ASSERT \ - else { \ - R_ASSERT(R_CURRENT_RESULT); \ - } \ - } \ - }) diff --git a/stratosphere/libstratosphere/include/atmosphere/results/ro_results.hpp b/stratosphere/libstratosphere/include/atmosphere/results/ro_results.hpp deleted file mode 100644 index 672270507..000000000 --- a/stratosphere/libstratosphere/include/atmosphere/results/ro_results.hpp +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include "results_common.hpp" - -namespace ams::ro { - - R_DEFINE_NAMESPACE_RESULT_MODULE(22); - - R_DEFINE_ERROR_RANGE(RoError, 1, 1023); - R_DEFINE_ERROR_RESULT(OutOfAddressSpace, 2); - R_DEFINE_ERROR_RESULT(AlreadyLoaded, 3); - R_DEFINE_ERROR_RESULT(InvalidNro, 4); - - R_DEFINE_ERROR_RESULT(InvalidNrr, 6); - R_DEFINE_ERROR_RESULT(TooManyNro, 7); - R_DEFINE_ERROR_RESULT(TooManyNrr, 8); - R_DEFINE_ERROR_RESULT(NotAuthorized, 9); - R_DEFINE_ERROR_RESULT(InvalidNrrType, 10); - - R_DEFINE_ERROR_RESULT(InternalError, 1023); - - R_DEFINE_ERROR_RESULT(InvalidAddress, 1025); - R_DEFINE_ERROR_RESULT(InvalidSize, 1026); - - R_DEFINE_ERROR_RESULT(NotLoaded, 1028); - R_DEFINE_ERROR_RESULT(NotRegistered, 1029); - R_DEFINE_ERROR_RESULT(InvalidSession, 1030); - R_DEFINE_ERROR_RESULT(InvalidProcess, 1031); - -} diff --git a/stratosphere/libstratosphere/include/atmosphere/results/settings_results.hpp b/stratosphere/libstratosphere/include/atmosphere/results/settings_results.hpp deleted file mode 100644 index fed3ff33e..000000000 --- a/stratosphere/libstratosphere/include/atmosphere/results/settings_results.hpp +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include "results_common.hpp" - -namespace ams::settings { - - R_DEFINE_NAMESPACE_RESULT_MODULE(105); - - R_DEFINE_ERROR_RESULT(SettingsItemNotFound, 11); - - R_DEFINE_ERROR_RANGE(InternalError, 100, 149); - R_DEFINE_ERROR_RESULT(SettingsItemKeyAllocationFailed, 101); - R_DEFINE_ERROR_RESULT(SettingsItemValueAllocationFailed, 102); - - R_DEFINE_ERROR_RANGE(InvalidArgument, 200, 399); - R_DEFINE_ERROR_RESULT(SettingsNameNull, 201); - R_DEFINE_ERROR_RESULT(SettingsItemKeyNull, 202); - R_DEFINE_ERROR_RESULT(SettingsItemValueNull, 203); - R_DEFINE_ERROR_RESULT(SettingsItemKeyBufferNull, 204); - R_DEFINE_ERROR_RESULT(SettingsItemValueBufferNull, 205); - - R_DEFINE_ERROR_RESULT(SettingsNameEmpty, 221); - R_DEFINE_ERROR_RESULT(SettingsItemKeyEmpty, 222); - - R_DEFINE_ERROR_RESULT(SettingsNameTooLong, 241); - R_DEFINE_ERROR_RESULT(SettingsItemKeyTooLong, 242); - - R_DEFINE_ERROR_RESULT(SettingsNameInvalidFormat, 261); - R_DEFINE_ERROR_RESULT(SettingsItemKeyInvalidFormat, 262); - R_DEFINE_ERROR_RESULT(SettingsItemValueInvalidFormat, 263); - -} diff --git a/stratosphere/libstratosphere/include/atmosphere/results/sf_results.hpp b/stratosphere/libstratosphere/include/atmosphere/results/sf_results.hpp deleted file mode 100644 index 192525538..000000000 --- a/stratosphere/libstratosphere/include/atmosphere/results/sf_results.hpp +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include "results_common.hpp" - -namespace ams::sf { - - R_DEFINE_NAMESPACE_RESULT_MODULE(10); - - R_DEFINE_ERROR_RESULT(NotSupported, 1); - R_DEFINE_ERROR_RESULT(PreconditionViolation, 3); - - namespace cmif { - - R_DEFINE_ERROR_RESULT(InvalidHeaderSize, 202); - R_DEFINE_ERROR_RESULT(InvalidInHeader, 211); - R_DEFINE_ERROR_RESULT(UnknownCommandId, 221); - R_DEFINE_ERROR_RESULT(InvalidOutRawSize, 232); - R_DEFINE_ERROR_RESULT(InvalidNumInObjects, 235); - R_DEFINE_ERROR_RESULT(InvalidNumOutObjects, 236); - R_DEFINE_ERROR_RESULT(InvalidInObject, 239); - - R_DEFINE_ERROR_RESULT(TargetNotFound, 261); - - R_DEFINE_ERROR_RESULT(OutOfDomainEntries, 301); - - } - - namespace impl { - - R_DEFINE_ABSTRACT_ERROR_RANGE(RequestContextChanged, 800, 899); - R_DEFINE_ABSTRACT_ERROR_RANGE(RequestInvalidated, 801, 809); - R_DEFINE_ERROR_RESULT(RequestInvalidatedByUser, 802); - - } - - R_DEFINE_ABSTRACT_ERROR_RANGE(RequestDeferred, 811, 819); - R_DEFINE_ERROR_RESULT(RequestDeferredByUser, 812); - -} diff --git a/stratosphere/libstratosphere/include/atmosphere/results/sm_results.hpp b/stratosphere/libstratosphere/include/atmosphere/results/sm_results.hpp deleted file mode 100644 index 89829f798..000000000 --- a/stratosphere/libstratosphere/include/atmosphere/results/sm_results.hpp +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include "results_common.hpp" - -namespace ams::sm { - - R_DEFINE_NAMESPACE_RESULT_MODULE(21); - - R_DEFINE_ERROR_RESULT(OutOfProcesses, 1); - R_DEFINE_ERROR_RESULT(InvalidClient, 2); - R_DEFINE_ERROR_RESULT(OutOfSessions, 3); - R_DEFINE_ERROR_RESULT(AlreadyRegistered, 4); - R_DEFINE_ERROR_RESULT(OutOfServices, 5); - R_DEFINE_ERROR_RESULT(InvalidServiceName, 6); - R_DEFINE_ERROR_RESULT(NotRegistered, 7); - R_DEFINE_ERROR_RESULT(NotAllowed, 8); - R_DEFINE_ERROR_RESULT(TooLargeAccessControl, 9); - - /* Results 1000-2000 used as extension for Atmosphere Mitm. */ - namespace mitm { - - R_DEFINE_ERROR_RESULT(ShouldForwardToSession, 1000); - R_DEFINE_ERROR_RESULT(ProcessNotAssociated, 1100); - - } - -} diff --git a/stratosphere/libstratosphere/include/atmosphere/results/spl_results.hpp b/stratosphere/libstratosphere/include/atmosphere/results/spl_results.hpp deleted file mode 100644 index 0670c6fae..000000000 --- a/stratosphere/libstratosphere/include/atmosphere/results/spl_results.hpp +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include "results_common.hpp" - -namespace ams::spl { - - R_DEFINE_NAMESPACE_RESULT_MODULE(26); - - R_DEFINE_ERROR_RANGE(SecureMonitorError, 0, 99); - R_DEFINE_ERROR_RESULT(SecureMonitorNotImplemented, 1); - R_DEFINE_ERROR_RESULT(SecureMonitorInvalidArgument, 2); - R_DEFINE_ERROR_RESULT(SecureMonitorBusy, 3); - R_DEFINE_ERROR_RESULT(SecureMonitorNoAsyncOperation, 4); - R_DEFINE_ERROR_RESULT(SecureMonitorInvalidAsyncOperation, 5); - R_DEFINE_ERROR_RESULT(SecureMonitorNotPermitted, 6); - - R_DEFINE_ERROR_RESULT(InvalidSize, 100); - R_DEFINE_ERROR_RESULT(UnknownSecureMonitorError, 101); - R_DEFINE_ERROR_RESULT(DecryptionFailed, 102); - - R_DEFINE_ERROR_RESULT(OutOfKeyslots, 104); - R_DEFINE_ERROR_RESULT(InvalidKeyslot, 105); - R_DEFINE_ERROR_RESULT(BootReasonAlreadySet, 106); - R_DEFINE_ERROR_RESULT(BootReasonNotSet, 107); - R_DEFINE_ERROR_RESULT(InvalidArgument, 108); - -} diff --git a/stratosphere/libstratosphere/include/atmosphere/results/svc_results.hpp b/stratosphere/libstratosphere/include/atmosphere/results/svc_results.hpp deleted file mode 100644 index 8b5149e35..000000000 --- a/stratosphere/libstratosphere/include/atmosphere/results/svc_results.hpp +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include "results_common.hpp" - -namespace ams::svc { - - R_DEFINE_NAMESPACE_RESULT_MODULE(1); - - R_DEFINE_ERROR_RESULT(OutOfSessions, 7); - - R_DEFINE_ERROR_RESULT(InvalidArgument, 14); - - R_DEFINE_ERROR_RESULT(NotImplemented, 33); - - R_DEFINE_ERROR_RESULT(ThreadTerminating, 59); - - R_DEFINE_ERROR_RESULT(NoEvent, 70); - - R_DEFINE_ERROR_RESULT(InvalidSize, 101); - R_DEFINE_ERROR_RESULT(InvalidAddress, 102); - R_DEFINE_ERROR_RESULT(OutOfResource, 103); - R_DEFINE_ERROR_RESULT(OutOfMemory, 104); - R_DEFINE_ERROR_RESULT(OutOfHandles, 105); - R_DEFINE_ERROR_RESULT(InvalidCurrentMemoryState, 106); - - R_DEFINE_ERROR_RESULT(InvalidNewMemoryPermissions, 108); - - R_DEFINE_ERROR_RESULT(InvalidMemoryRegion, 110); - - R_DEFINE_ERROR_RESULT(InvalidPriority, 112); - R_DEFINE_ERROR_RESULT(InvalidCoreId, 113); - R_DEFINE_ERROR_RESULT(InvalidHandle, 114); - R_DEFINE_ERROR_RESULT(InvalidPointer, 115); - R_DEFINE_ERROR_RESULT(InvalidCombination, 116); - R_DEFINE_ERROR_RESULT(TimedOut, 117); - R_DEFINE_ERROR_RESULT(Cancelled, 118); - R_DEFINE_ERROR_RESULT(OutOfRange, 119); - R_DEFINE_ERROR_RESULT(InvalidEnumValue, 120); - R_DEFINE_ERROR_RESULT(NotFound, 121); - R_DEFINE_ERROR_RESULT(Busy, 122); - R_DEFINE_ERROR_RESULT(SessionClosed, 123); - R_DEFINE_ERROR_RESULT(NotHandled, 124); - R_DEFINE_ERROR_RESULT(InvalidState, 125); - R_DEFINE_ERROR_RESULT(ReservedValue, 126); - R_DEFINE_ERROR_RESULT(NotSupported, 127); - R_DEFINE_ERROR_RESULT(Debug, 128); - R_DEFINE_ERROR_RESULT(ThreadNotOwned, 129); - - R_DEFINE_ERROR_RESULT(PortClosed, 131); - R_DEFINE_ERROR_RESULT(LimitReached, 132); - - R_DEFINE_ERROR_RESULT(ReceiveListBroken, 258); - R_DEFINE_ERROR_RESULT(OutOfAddressSpace, 259); - R_DEFINE_ERROR_RESULT(MessageTooLarge, 260); - - R_DEFINE_ERROR_RESULT(ProcessTerminated, 520); - -} diff --git a/stratosphere/libstratosphere/include/atmosphere/results/updater_results.hpp b/stratosphere/libstratosphere/include/atmosphere/results/updater_results.hpp deleted file mode 100644 index ea40f962d..000000000 --- a/stratosphere/libstratosphere/include/atmosphere/results/updater_results.hpp +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include "results_common.hpp" - -namespace ams::updater { - - R_DEFINE_NAMESPACE_RESULT_MODULE(158); - - R_DEFINE_ERROR_RESULT(BootImagePackageNotFound, 2); - R_DEFINE_ERROR_RESULT(InvalidBootImagePackage, 3); - R_DEFINE_ERROR_RESULT(TooSmallWorkBuffer, 4); - R_DEFINE_ERROR_RESULT(NotAlignedWorkBuffer, 5); - R_DEFINE_ERROR_RESULT(NeedsRepairBootImages, 6); - -} diff --git a/stratosphere/libstratosphere/include/atmosphere/results/vi_results.hpp b/stratosphere/libstratosphere/include/atmosphere/results/vi_results.hpp deleted file mode 100644 index 30b5190cf..000000000 --- a/stratosphere/libstratosphere/include/atmosphere/results/vi_results.hpp +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include "results_common.hpp" - -namespace ams::vi { - - R_DEFINE_NAMESPACE_RESULT_MODULE(114); - - R_DEFINE_ERROR_RESULT(OperationFailed, 1); - R_DEFINE_ERROR_RESULT(NotSupported, 6); - R_DEFINE_ERROR_RESULT(NotFound, 7); - -} diff --git a/stratosphere/libstratosphere/include/atmosphere/svc.hpp b/stratosphere/libstratosphere/include/atmosphere/svc.hpp deleted file mode 100644 index fce887145..000000000 --- a/stratosphere/libstratosphere/include/atmosphere/svc.hpp +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include "defines.hpp" -#include "results.hpp" - -#include "svc/svc_types.hpp" diff --git a/stratosphere/libstratosphere/include/atmosphere/svc/svc_types.hpp b/stratosphere/libstratosphere/include/atmosphere/svc/svc_types.hpp deleted file mode 100644 index 2284f9558..000000000 --- a/stratosphere/libstratosphere/include/atmosphere/svc/svc_types.hpp +++ /dev/null @@ -1,208 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include "../results.hpp" - -namespace ams::svc { - - /* Debug event types. */ - enum class DebugEventType : u32 { - AttachProcess = 0, - AttachThread = 1, - ExitProcess = 2, - ExitThread = 3, - Exception = 4, - }; - - struct DebugInfoAttachProcess { - u64 program_id; - u64 process_id; - char name[0xC]; - u32 flags; - u64 user_exception_context_address; /* 5.0.0+ */ - }; - - struct DebugInfoAttachThread { - u64 thread_id; - u64 tls_address; - u64 entrypoint; - }; - - enum class ExitProcessReason : u32 { - ExitProcess = 0, - TerminateProcess = 1, - Exception = 2, - }; - - struct DebugInfoExitProcess { - ExitProcessReason reason; - }; - - enum class ExitThreadReason : u32 { - ExitThread = 0, - TerminateThread = 1, - ExitProcess = 2, - TerminateProcess = 3, - }; - - struct DebugInfoExitThread { - ExitThreadReason reason; - }; - - enum class DebugExceptionType : u32 { - UndefinedInstruction = 0, - InstructionAbort = 1, - DataAbort = 2, - AlignmentFault = 3, - DebuggerAttached = 4, - BreakPoint = 5, - UserBreak = 6, - DebuggerBreak = 7, - UndefinedSystemCall = 8, - SystemMemoryError = 9, - }; - - struct DebugInfoUndefinedInstructionException { - u32 insn; - }; - - struct DebugInfoDataAbortException { - u64 address; - }; - - struct DebugInfoAligntmentFaultException { - u64 address; - }; - - enum class BreakPointType : u32 { - BreakPoint = 0, - WatchPoint = 1, - }; - - struct DebugInfoBreakPointException { - BreakPointType type; - u64 address; - }; - - struct DebugInfoUserBreakException { - u32 break_reason; /* TODO: enum? */ - u64 address; - u64 size; - }; - - struct DebugInfoDebuggerBreakException { - u64 active_thread_ids[4]; - }; - - struct DebugInfoUndefinedSystemCallException { - u32 id; - }; - - union DebugInfoSpecificException { - DebugInfoUndefinedInstructionException undefined_instruction; - DebugInfoDataAbortException data_abort; - DebugInfoAligntmentFaultException alignment_fault; - DebugInfoBreakPointException break_point; - DebugInfoUserBreakException user_break; - DebugInfoDebuggerBreakException debugger_break; - DebugInfoUndefinedSystemCallException undefined_system_call; - u64 raw; - }; - - struct DebugInfoException { - DebugExceptionType type; - u64 address; - DebugInfoSpecificException specific; - }; - - union DebugInfo { - DebugInfoAttachProcess attach_process; - DebugInfoAttachThread attach_thread; - DebugInfoExitProcess exit_process; - DebugInfoExitThread exit_thread; - DebugInfoException exception; - }; - - struct DebugEventInfo { - DebugEventType type; - u32 flags; - u64 thread_id; - DebugInfo info; - }; - static_assert(sizeof(DebugEventInfo) >= 0x40, "DebugEventInfo definition!"); - - /* Thread State, for svcGetDebugThreadParam. */ - enum class ThreadState : u32 { - Waiting = 0, - Running = 1, - Terminated = 4, - Initializing = 5, - }; - - enum ThreadContextFlag : u32 { - ThreadContextFlag_General = (1 << 0), - ThreadContextFlag_Control = (1 << 1), - ThreadContextFlag_Fpu = (1 << 2), - ThreadContextFlag_FpuControl = (1 << 3), - - ThreadContextFlag_All = (ThreadContextFlag_General | ThreadContextFlag_Control | ThreadContextFlag_Fpu | ThreadContextFlag_FpuControl), - }; - - /* Flags for svcCreateProcess. */ - enum CreateProcessFlag : u32 { - /* Is 64 bit? */ - CreateProcessFlag_Is64Bit = (1 << 0), - - /* What kind of address space? */ - CreateProcessFlag_AddressSpaceShift = 1, - CreateProcessFlag_AddressSpaceMask = (7 << CreateProcessFlag_AddressSpaceShift), - CreateProcessFlag_AddressSpace32Bit = (0 << CreateProcessFlag_AddressSpaceShift), - CreateProcessFlag_AddressSpace64BitDeprecated = (1 << CreateProcessFlag_AddressSpaceShift), - CreateProcessFlag_AddressSpace32BitWithoutAlias = (2 << CreateProcessFlag_AddressSpaceShift), - CreateProcessFlag_AddressSpace64Bit = (3 << CreateProcessFlag_AddressSpaceShift), - - /* Should JIT debug be done on crash? */ - CreateProcessFlag_EnableDebug = (1 << 4), - - /* Should ASLR be enabled for the process? */ - CreateProcessFlag_EnableAslr = (1 << 5), - - /* Is the process an application? */ - CreateProcessFlag_IsApplication = (1 << 6), - - /* 4.x deprecated: Should use secure memory? */ - CreateProcessFlag_DeprecatedUseSecureMemory = (1 << 7), - - /* 5.x+ Pool partition type. */ - CreateProcessFlag_PoolPartitionShift = 7, - CreateProcessFlag_PoolPartitionMask = (0xF << CreateProcessFlag_PoolPartitionShift), - CreateProcessFlag_PoolPartitionApplication = (0 << CreateProcessFlag_PoolPartitionShift), - CreateProcessFlag_PoolPartitionApplet = (1 << CreateProcessFlag_PoolPartitionShift), - CreateProcessFlag_PoolPartitionSystem = (2 << CreateProcessFlag_PoolPartitionShift), - CreateProcessFlag_PoolPartitionSystemNonSecure = (3 << CreateProcessFlag_PoolPartitionShift), - - /* 7.x+ Should memory allocation be optimized? This requires IsApplication. */ - CreateProcessFlag_OptimizeMemoryAllocation = (1 << 11), - }; - - /* Type for svcCreateInterruptEvent. */ - enum InterruptType : u32 { - InterruptType_Edge = 0, - InterruptType_Level = 1, - }; - -} diff --git a/stratosphere/libstratosphere/include/atmosphere/util.hpp b/stratosphere/libstratosphere/include/atmosphere/util.hpp deleted file mode 100644 index c05836218..000000000 --- a/stratosphere/libstratosphere/include/atmosphere/util.hpp +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include "defines.hpp" - -#include "util/util_alignment.hpp" -#include "util/util_size.hpp" -#include "util/util_scope_guard.hpp" -#include "util/util_typed_storage.hpp" -#include "util/util_intrusive_list.hpp" -#include "util/util_intrusive_red_black_tree.hpp" -#include "util/util_compression.hpp" -#include "util/util_ini.hpp" diff --git a/stratosphere/libstratosphere/include/atmosphere/util/util_alignment.hpp b/stratosphere/libstratosphere/include/atmosphere/util/util_alignment.hpp deleted file mode 100644 index 36f28e717..000000000 --- a/stratosphere/libstratosphere/include/atmosphere/util/util_alignment.hpp +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include "../defines.hpp" - -namespace ams::util { - - /* Utilities for alignment to power of two. */ - - template - constexpr inline T AlignUp(T value, size_t alignment) { - using U = typename std::make_unsigned::type; - const U invmask = static_cast(alignment - 1); - return static_cast((value + invmask) & ~invmask); - } - - template - constexpr inline T AlignDown(T value, size_t alignment) { - using U = typename std::make_unsigned::type; - const U invmask = static_cast(alignment - 1); - return static_cast(value & ~invmask); - } - - template - constexpr inline bool IsAligned(T value, size_t alignment) { - using U = typename std::make_unsigned::type; - const U invmask = static_cast(alignment - 1); - return (value & invmask) == 0; - } - - template<> - constexpr inline void *AlignUp(void *value, size_t alignment) { - return reinterpret_cast(AlignUp(reinterpret_cast(value), alignment)); - } - - template<> - constexpr inline const void *AlignUp(const void *value, size_t alignment) { - return reinterpret_cast(AlignUp(reinterpret_cast(value), alignment)); - } - - template<> - constexpr inline void *AlignDown(void *value, size_t alignment) { - return reinterpret_cast(AlignDown(reinterpret_cast(value), alignment)); - } - - template<> - constexpr inline const void *AlignDown(const void *value, size_t alignment) { - return reinterpret_cast(AlignDown(reinterpret_cast(value), alignment)); - } - - template<> - constexpr inline bool IsAligned(void *value, size_t alignment) { - return IsAligned(reinterpret_cast(value), alignment); - } - - template<> - constexpr inline bool IsAligned(const void *value, size_t alignment) { - return IsAligned(reinterpret_cast(value), alignment); - } - -} \ No newline at end of file diff --git a/stratosphere/libstratosphere/include/atmosphere/util/util_compression.hpp b/stratosphere/libstratosphere/include/atmosphere/util/util_compression.hpp deleted file mode 100644 index 3f310ae81..000000000 --- a/stratosphere/libstratosphere/include/atmosphere/util/util_compression.hpp +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include "../defines.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); - -} \ No newline at end of file diff --git a/stratosphere/libstratosphere/include/atmosphere/util/util_ini.hpp b/stratosphere/libstratosphere/include/atmosphere/util/util_ini.hpp deleted file mode 100644 index 7815820bd..000000000 --- a/stratosphere/libstratosphere/include/atmosphere/util/util_ini.hpp +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include "../defines.hpp" - -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(FILE *f, void *user_ctx, Handler h); - int ParseFile(FsFile *f, void *user_ctx, Handler h); - int ParseFile(const char *path, void *user_ctx, Handler h); - -} \ No newline at end of file diff --git a/stratosphere/libstratosphere/include/atmosphere/util/util_intrusive_list.hpp b/stratosphere/libstratosphere/include/atmosphere/util/util_intrusive_list.hpp deleted file mode 100644 index df7489601..000000000 --- a/stratosphere/libstratosphere/include/atmosphere/util/util_intrusive_list.hpp +++ /dev/null @@ -1,595 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include "util_parent_of_member.hpp" - -namespace ams::util { - - /* Forward declare implementation class for Node. */ - namespace impl { - - class IntrusiveListImpl; - - } - - class IntrusiveListNode { - NON_COPYABLE(IntrusiveListNode); - private: - friend class impl::IntrusiveListImpl; - - IntrusiveListNode *prev; - IntrusiveListNode *next; - public: - IntrusiveListNode() { - this->prev = this; - this->next = this; - } - - bool IsLinked() const { - return this->next != this; - } - private: - void LinkPrev(IntrusiveListNode *node) { - /* We can't link an already linked node. */ - AMS_ASSERT(!node->IsLinked()); - this->SplicePrev(node, node); - } - - void SplicePrev(IntrusiveListNode *first, IntrusiveListNode *last) { - /* Splice a range into the list. */ - auto last_prev = last->prev; - first->prev = this->prev; - this->prev->next = first; - last_prev->next = this; - this->prev = last_prev; - } - - void LinkNext(IntrusiveListNode *node) { - /* We can't link an already linked node. */ - AMS_ASSERT(!node->IsLinked()); - return this->SpliceNext(node, node); - } - - void SpliceNext(IntrusiveListNode *first, IntrusiveListNode *last) { - /* Splice a range into the list. */ - auto last_prev = last->prev; - first->prev = this; - this->next = first; - last_prev->next = next; - this->next->prev = last_prev; - } - - void Unlink() { - this->Unlink(this->next); - } - - void Unlink(IntrusiveListNode *last) { - /* Unlink a node from a next node. */ - auto last_prev = last->prev; - this->prev->next = last; - last->prev = this->prev; - last_prev->next = this; - this->prev = last_prev; - } - - IntrusiveListNode *GetPrev() { - return this->prev; - } - - const IntrusiveListNode *GetPrev() const { - return this->prev; - } - - IntrusiveListNode *GetNext() { - return this->next; - } - - const IntrusiveListNode *GetNext() const { - return this->next; - } - }; - - namespace impl { - - class IntrusiveListImpl { - NON_COPYABLE(IntrusiveListImpl); - private: - IntrusiveListNode root_node; - public: - template - class Iterator; - - using value_type = IntrusiveListNode; - using size_type = size_t; - using difference_type = ptrdiff_t; - using pointer = value_type *; - using const_pointer = const value_type *; - using reference = value_type &; - using const_reference = const value_type &; - using iterator = Iterator; - using const_iterator = Iterator; - using reverse_iterator = std::reverse_iterator; - using const_reverse_iterator = std::reverse_iterator; - - template - class Iterator { - public: - using iterator_category = std::bidirectional_iterator_tag; - using value_type = typename IntrusiveListImpl::value_type; - using difference_type = typename IntrusiveListImpl::difference_type; - using pointer = typename std::conditional::type; - using reference = typename std::conditional::type; - private: - pointer node; - public: - explicit Iterator(pointer n) : node(n) { /* ... */ } - - bool operator==(const Iterator &rhs) const { - return this->node == rhs.node; - } - - bool operator!=(const Iterator &rhs) const { - return !(*this == rhs); - } - - pointer operator->() const { - return this->node; - } - - reference operator*() const { - return *this->node; - } - - Iterator &operator++() { - this->node = this->node->next; - return *this; - } - - Iterator &operator--() { - this->node = this->node->prev; - return *this; - } - - Iterator operator++(int) { - const Iterator it{*this}; - ++(*this); - return it; - } - - Iterator operator--(int) { - const Iterator it{*this}; - --(*this); - return it; - } - - operator Iterator() const { - return Iterator(this->node); - } - - Iterator GetNonConstIterator() const { - return Iterator(const_cast(this->node)); - } - }; - public: - IntrusiveListImpl() : root_node() { /* ... */ } - - /* Iterator accessors. */ - iterator begin() { - return iterator(this->root_node.GetNext()); - } - - const_iterator begin() const { - return const_iterator(this->root_node.GetNext()); - } - - iterator end() { - return iterator(&this->root_node); - } - - const_iterator end() const { - return const_iterator(&this->root_node); - } - - iterator iterator_to(reference v) { - /* Only allow iterator_to for values in lists. */ - AMS_ASSERT(v.IsLinked()); - return iterator(&v); - } - - const_iterator iterator_to(const_reference v) const { - /* Only allow iterator_to for values in lists. */ - AMS_ASSERT(v.IsLinked()); - return const_iterator(&v); - } - - /* Content management. */ - bool empty() const { - return !this->root_node.IsLinked(); - } - - size_type size() const { - return static_cast(std::distance(this->begin(), this->end())); - } - - reference back() { - return *this->root_node.GetPrev(); - } - - const_reference back() const { - return *this->root_node.GetPrev(); - } - - reference front() { - return *this->root_node.GetNext(); - } - - const_reference front() const { - return *this->root_node.GetNext(); - } - - void push_back(reference node) { - this->root_node.LinkPrev(&node); - } - - void push_front(reference node) { - this->root_node.LinkNext(&node); - } - - void pop_back() { - this->root_node.GetPrev()->Unlink(); - } - - void pop_front() { - this->root_node.GetNext()->Unlink(); - } - - iterator insert(const_iterator pos, reference node) { - pos.GetNonConstIterator()->LinkPrev(&node); - return iterator(&node); - } - - void splice(const_iterator pos, IntrusiveListImpl &o) { - splice_impl(pos, o.begin(), o.end()); - } - - void splice(const_iterator pos, IntrusiveListImpl &o, const_iterator first) { - const_iterator last(first); - std::advance(last, 1); - splice_impl(pos, first, last); - } - - void splice(const_iterator pos, IntrusiveListImpl &o, const_iterator first, const_iterator last) { - splice_impl(pos, first, last); - } - - iterator erase(const iterator pos) { - if (pos == this->end()) { - return this->end(); - } - iterator it(pos.GetNonConstIterator()); - (it++)->Unlink(); - return it; - } - - void clear() { - while (!this->empty()) { - this->pop_front(); - } - } - private: - void splice_impl(const_iterator _pos, const_iterator _first, const_iterator _last) { - if (_first == _last) { - return; - } - iterator pos(_pos.GetNonConstIterator()); - iterator first(_first.GetNonConstIterator()); - iterator last(_last.GetNonConstIterator()); - first->Unlink(&*last); - pos->SplicePrev(&*first, &*first); - } - - }; - - } - - template - class IntrusiveList { - NON_COPYABLE(IntrusiveList); - private: - impl::IntrusiveListImpl impl; - public: - template - class Iterator; - - using value_type = T; - using size_type = size_t; - using difference_type = ptrdiff_t; - using pointer = value_type *; - using const_pointer = const value_type *; - using reference = value_type &; - using const_reference = const value_type &; - using iterator = Iterator; - using const_iterator = Iterator; - using reverse_iterator = std::reverse_iterator; - using const_reverse_iterator = std::reverse_iterator; - - template - class Iterator { - public: - friend class ams::util::IntrusiveList; - - using ImplIterator = typename std::conditional::type; - - using iterator_category = std::bidirectional_iterator_tag; - using value_type = typename IntrusiveList::value_type; - using difference_type = typename IntrusiveList::difference_type; - using pointer = typename std::conditional::type; - using reference = typename std::conditional::type; - private: - ImplIterator iterator; - private: - explicit Iterator(ImplIterator it) : iterator(it) { /* ... */ } - - ImplIterator GetImplIterator() const { - return this->iterator; - } - public: - bool operator==(const Iterator &rhs) const { - return this->iterator == rhs.iterator; - } - - bool operator!=(const Iterator &rhs) const { - return !(*this == rhs); - } - - pointer operator->() const { - return &Traits::GetParent(*this->iterator); - } - - reference operator*() const { - return Traits::GetParent(*this->iterator); - } - - Iterator &operator++() { - ++this->iterator; - return *this; - } - - Iterator &operator--() { - --this->iterator; - return *this; - } - - Iterator operator++(int) { - const Iterator it{*this}; - ++this->iterator; - return it; - } - - Iterator operator--(int) { - const Iterator it{*this}; - --this->iterator; - return it; - } - - operator Iterator() const { - return Iterator(this->iterator); - } - }; - private: - static constexpr IntrusiveListNode &GetNode(reference ref) { - return Traits::GetNode(ref); - } - - static constexpr IntrusiveListNode const &GetNode(const_reference ref) { - return Traits::GetNode(ref); - } - - static constexpr reference GetParent(IntrusiveListNode &node) { - return Traits::GetParent(node); - } - - static constexpr const_reference GetParent(IntrusiveListNode const &node) { - return Traits::GetParent(node); - } - public: - IntrusiveList() : impl() { /* ... */ } - - /* Iterator accessors. */ - iterator begin() { - return iterator(this->impl.begin()); - } - - const_iterator begin() const { - return const_iterator(this->impl.begin()); - } - - iterator end() { - return iterator(this->impl.end()); - } - - const_iterator end() const { - return const_iterator(this->impl.end()); - } - - const_iterator cbegin() const { - return this->begin(); - } - - const_iterator cend() const { - return this->end(); - } - - reverse_iterator rbegin() { - return reverse_iterator(this->end()); - } - - const_reverse_iterator rbegin() const { - return const_reverse_iterator(this->end()); - } - - reverse_iterator rend() { - return reverse_iterator(this->begin()); - } - - const_reverse_iterator rend() const { - return const_reverse_iterator(this->begin()); - } - - const_reverse_iterator crbegin() const { - return this->rbegin(); - } - - const_reverse_iterator crend() const { - return this->rend(); - } - - iterator iterator_to(reference v) { - return iterator(this->impl.iterator_to(GetNode(v))); - } - - const_iterator iterator_to(const_reference v) const { - return const_iterator(this->impl.iterator_to(GetNode(v))); - } - - /* Content management. */ - bool empty() const { - return this->impl.empty(); - } - - size_type size() const { - return this->impl.size(); - } - - reference back() { - AMS_ASSERT(!this->impl.empty()); - return GetParent(this->impl.back()); - } - - const_reference back() const { - AMS_ASSERT(!this->impl.empty()); - return GetParent(this->impl.back()); - } - - reference front() { - AMS_ASSERT(!this->impl.empty()); - return GetParent(this->impl.front()); - } - - const_reference front() const { - AMS_ASSERT(!this->impl.empty()); - return GetParent(this->impl.front()); - } - - void push_back(reference ref) { - this->impl.push_back(GetNode(ref)); - } - - void push_front(reference ref) { - this->impl.push_back(GetNode(ref)); - } - - void pop_back() { - AMS_ASSERT(!this->impl.empty()); - this->impl.pop_back(); - } - - void pop_front() { - AMS_ASSERT(!this->impl.empty()); - this->impl.pop_front(); - } - - iterator insert(const_iterator pos, reference ref) { - return iterator(this->impl.insert(pos.GetImplIterator(), GetNode(ref))); - } - - void splice(const_iterator pos, IntrusiveList &o) { - this->impl.splice(pos.GetImplIterator(), o.impl); - } - - void splice(const_iterator pos, IntrusiveList &o, const_iterator first) { - this->impl.splice(pos.GetImplIterator(), o.impl, first.GetImplIterator()); - } - - void splice(const_iterator pos, IntrusiveList &o, const_iterator first, const_iterator last) { - this->impl.splice(pos.GetImplIterator(), o.impl, first.GetImplIterator(), last.GetImplIterator()); - } - - iterator erase(const iterator pos) { - return iterator(this->impl.erase(pos.GetImplIterator())); - } - - void clear() { - this->impl.clear(); - } - }; - - template> - class IntrusiveListMemberTraits; - - template - class IntrusiveListMemberTraits { - public: - using ListType = IntrusiveList; - private: - friend class IntrusiveList; - - static constexpr IntrusiveListNode &GetNode(Derived &parent) { - return parent.*Member; - } - - static constexpr IntrusiveListNode const &GetNode(Derived const &parent) { - return parent.*Member; - } - - static constexpr Derived &GetParent(IntrusiveListNode &node) { - return static_cast(util::GetParentReference(&node)); - } - - static constexpr Derived const &GetParent(IntrusiveListNode const &node) { - return static_cast(util::GetParentReference(&node)); - } - }; - - template - class IntrusiveListBaseNode : public IntrusiveListNode{}; - - template - class IntrusiveListBaseTraits { - public: - using ListType = IntrusiveList; - private: - friend class IntrusiveList; - - static constexpr IntrusiveListNode &GetNode(Derived &parent) { - return static_cast(parent); - } - - static constexpr IntrusiveListNode const &GetNode(Derived const &parent) { - return static_cast(parent); - } - - static constexpr Derived &GetParent(IntrusiveListNode &node) { - return static_cast(node); - } - - static constexpr Derived const &GetParent(IntrusiveListNode const &node) { - return static_cast(node); - } - }; - -} \ No newline at end of file diff --git a/stratosphere/libstratosphere/include/atmosphere/util/util_intrusive_red_black_tree.hpp b/stratosphere/libstratosphere/include/atmosphere/util/util_intrusive_red_black_tree.hpp deleted file mode 100644 index 088286dd5..000000000 --- a/stratosphere/libstratosphere/include/atmosphere/util/util_intrusive_red_black_tree.hpp +++ /dev/null @@ -1,297 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include -#include "util_parent_of_member.hpp" - -namespace ams::util { - - struct IntrusiveRedBlackTreeNode { - NON_COPYABLE(IntrusiveRedBlackTreeNode); - private: - RB_ENTRY(IntrusiveRedBlackTreeNode) entry; - - template - friend class IntrusiveRedBlackTree; - public: - IntrusiveRedBlackTreeNode() { /* ... */} - }; - - template - class IntrusiveRedBlackTree { - NON_COPYABLE(IntrusiveRedBlackTree); - private: - RB_HEAD(IntrusiveRedBlackTreeRoot, IntrusiveRedBlackTreeNode); - - IntrusiveRedBlackTreeRoot root; - public: - template - class Iterator; - - using value_type = T; - using size_type = size_t; - using difference_type = ptrdiff_t; - using pointer = T *; - using const_pointer = const T *; - using reference = T &; - using const_reference = const T &; - using iterator = Iterator; - using const_iterator = Iterator; - - template - class Iterator { - public: - using iterator_category = std::bidirectional_iterator_tag; - using value_type = typename IntrusiveRedBlackTree::value_type; - using difference_type = typename IntrusiveRedBlackTree::difference_type; - using pointer = typename std::conditional::type; - using reference = typename std::conditional::type; - private: - pointer node; - public: - explicit Iterator(pointer n) : node(n) { /* ... */ } - - bool operator==(const Iterator &rhs) const { - return this->node == rhs.node; - } - - bool operator!=(const Iterator &rhs) const { - return !(*this == rhs); - } - - pointer operator->() const { - return this->node; - } - - reference operator*() const { - return *this->node; - } - - Iterator &operator++() { - this->node = Traits::GetParent(GetNext(Traits::GetNode(this->node))); - return *this; - } - - Iterator &operator--() { - this->node = Traits::GetParent(GetPrev(Traits::GetNode(this->node))); - return *this; - } - - Iterator operator++(int) { - const Iterator it{*this}; - ++(*this); - return it; - } - - Iterator operator--(int) { - const Iterator it{*this}; - --(*this); - return it; - } - - operator Iterator() const { - return Iterator(this->node); - } - }; - private: - static int CompareImpl(const IntrusiveRedBlackTreeNode *lhs, const IntrusiveRedBlackTreeNode *rhs) { - return Comparator::Compare(*Traits::GetParent(lhs), *Traits::GetParent(rhs)); - } - - /* Generate static implementations for IntrusiveRedBlackTreeRoot. */ - RB_GENERATE_STATIC(IntrusiveRedBlackTreeRoot, IntrusiveRedBlackTreeNode, entry, CompareImpl); - - static constexpr inline IntrusiveRedBlackTreeNode *GetNext(IntrusiveRedBlackTreeNode *node) { - return RB_NEXT(IntrusiveRedBlackTreeRoot, nullptr, node); - } - - static constexpr inline IntrusiveRedBlackTreeNode const *GetNext(IntrusiveRedBlackTreeNode const *node) { - return const_cast(GetNext(const_cast(node))); - } - - static constexpr inline IntrusiveRedBlackTreeNode *GetPrev(IntrusiveRedBlackTreeNode *node) { - return RB_NEXT(IntrusiveRedBlackTreeRoot, nullptr, node); - } - - static constexpr inline IntrusiveRedBlackTreeNode const *GetPrev(IntrusiveRedBlackTreeNode const *node) { - return const_cast(GetPrev(const_cast(node))); - } - - /* Define accessors using RB_* functions. */ - void InitializeImpl() { - RB_INIT(&this->root); - } - - bool EmptyImpl() const { - return RB_EMPTY(&this->root); - } - - IntrusiveRedBlackTreeNode *GetMinImpl() const { - return RB_MIN(IntrusiveRedBlackTreeRoot, const_cast(&this->root)); - } - - IntrusiveRedBlackTreeNode *GetMaxImpl() const { - return RB_MIN(IntrusiveRedBlackTreeRoot, const_cast(&this->root)); - } - - IntrusiveRedBlackTreeNode *InsertImpl(IntrusiveRedBlackTreeNode *node) { - return RB_INSERT(IntrusiveRedBlackTreeRoot, &this->root, node); - } - - IntrusiveRedBlackTreeNode *RemoveImpl(IntrusiveRedBlackTreeNode *node) { - return RB_REMOVE(IntrusiveRedBlackTreeRoot, &this->root, node); - } - - IntrusiveRedBlackTreeNode *FindImpl(IntrusiveRedBlackTreeNode const *node) const { - return RB_FIND(IntrusiveRedBlackTreeRoot, const_cast(&this->root), const_cast(node)); - } - - IntrusiveRedBlackTreeNode *NFindImpl(IntrusiveRedBlackTreeNode const *node) const { - return RB_NFIND(IntrusiveRedBlackTreeRoot, const_cast(&this->root), const_cast(node)); - } - - public: - IntrusiveRedBlackTree() { - this->InitializeImpl(); - } - - /* Iterator accessors. */ - iterator begin() { - return iterator(Traits::GetParent(this->GetMinImpl())); - } - - const_iterator begin() const { - return const_iterator(Traits::GetParent(this->GetMinImpl())); - } - - iterator end() { - return iterator(Traits::GetParent(static_cast(nullptr))); - } - - const_iterator end() const { - return const_iterator(Traits::GetParent(static_cast(nullptr))); - } - - iterator iterator_to(reference ref) { - return iterator(&ref); - } - - const_iterator iterator_to(const_reference ref) const { - return const_iterator(&ref); - } - - /* Content management. */ - bool empty() const { - return this->EmptyImpl(); - } - - reference back() { - return Traits::GetParent(this->GetMaxImpl()); - } - - const_reference back() const { - return Traits::GetParent(this->GetMaxImpl()); - } - - reference front() { - return Traits::GetParent(this->GetMinImpl()); - } - - const_reference front() const { - return Traits::GetParent(this->GetMinImpl()); - } - - iterator insert(reference ref) { - this->InsertImpl(Traits::GetNode(&ref)); - return iterator(&ref); - } - - iterator erase(iterator it) { - auto cur = Traits::GetNode(&*it); - auto next = Traits::GetParent(GetNext(cur)); - this->RemoveImpl(cur); - return iterator(next); - } - - iterator find(const_reference ref) const { - return iterator(Traits::GetParent(this->FindImpl(Traits::GetNode(&ref)))); - } - - iterator nfind(const_reference ref) const { - return iterator(Traits::GetParent(this->NFindImpl(Traits::GetNode(&ref)))); - } - }; - - template> - class IntrusiveRedBlackTreeMemberTraits; - - template - class IntrusiveRedBlackTreeMemberTraits { - public: - template - using ListType = IntrusiveRedBlackTree; - private: - template - friend class IntrusiveRedBlackTree; - - static constexpr IntrusiveRedBlackTreeNode *GetNode(Derived *parent) { - return &(parent->*Member); - } - - static constexpr IntrusiveRedBlackTreeNode const *GetNode(Derived const *parent) { - return &(parent->*Member); - } - - static constexpr Derived *GetParent(IntrusiveRedBlackTreeNode *node) { - return static_cast(util::GetParentPointer(node)); - } - - static constexpr Derived const *GetParent(IntrusiveRedBlackTreeNode const *node) { - return static_cast(util::GetParentPointer(node)); - } - }; - - template - class IntrusiveRedBlackTreeBaseNode : public IntrusiveRedBlackTreeNode{}; - - template - class IntrusiveRedBlackTreeBaseTraits { - public: - template - using ListType = IntrusiveRedBlackTree; - private: - template - friend class IntrusiveRedBlackTree; - - static constexpr IntrusiveRedBlackTreeNode *GetNode(Derived *parent) { - return static_cast(parent); - } - - static constexpr IntrusiveRedBlackTreeNode const *GetNode(Derived const *parent) { - return static_cast(parent); - } - - static constexpr Derived *GetParent(IntrusiveRedBlackTreeNode *node) { - return static_cast(node); - } - - static constexpr Derived const *GetParent(IntrusiveRedBlackTreeNode const *node) { - return static_cast(node); - } - }; - -} \ No newline at end of file diff --git a/stratosphere/libstratosphere/include/atmosphere/util/util_parent_of_member.hpp b/stratosphere/libstratosphere/include/atmosphere/util/util_parent_of_member.hpp deleted file mode 100644 index 4402e927b..000000000 --- a/stratosphere/libstratosphere/include/atmosphere/util/util_parent_of_member.hpp +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include "../defines.hpp" - -namespace ams::util { - - namespace impl { - - template - union OffsetOfImpl { - Member Parent::* ptr; - intptr_t offset; - }; - - template - constexpr inline Parent *GetParentOfMemberImpl(Member *member, Member Parent::* ptr) { - return reinterpret_cast(reinterpret_cast(member) - OffsetOfImpl{ ptr }.offset); - } - - template - constexpr inline Parent const *GetParentOfMemberImpl(Member const *member, Member Parent::* ptr) { - return reinterpret_cast(reinterpret_cast(member) - OffsetOfImpl{ ptr }.offset); - } - - template - struct GetMemberPointerTraits; - - template - struct GetMemberPointerTraits { - using Parent = P; - using Member = M; - }; - - template - using GetParentType = typename GetMemberPointerTraits::Parent; - - template - using GetMemberType = typename GetMemberPointerTraits::Member; - - } - - template - constexpr inline impl::GetParentType *GetParentPointer(impl::GetMemberType *member) { - return impl::GetParentOfMemberImpl, impl::GetMemberType>(member, MemberPtr); - } - - template - constexpr inline impl::GetParentType const *GetParentPointer(impl::GetMemberType const *member) { - return impl::GetParentOfMemberImpl, impl::GetMemberType>(member, MemberPtr); - } - - template - constexpr inline impl::GetParentType &GetParentReference(impl::GetMemberType *member) { - return *impl::GetParentOfMemberImpl, impl::GetMemberType>(member, MemberPtr); - } - - template - constexpr inline impl::GetParentType const &GetParentReference(impl::GetMemberType const *member) { - return *impl::GetParentOfMemberImpl, impl::GetMemberType>(member, MemberPtr); - } - -} \ No newline at end of file diff --git a/stratosphere/libstratosphere/include/atmosphere/util/util_scope_guard.hpp b/stratosphere/libstratosphere/include/atmosphere/util/util_scope_guard.hpp deleted file mode 100644 index a48d825e8..000000000 --- a/stratosphere/libstratosphere/include/atmosphere/util/util_scope_guard.hpp +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2018-2019 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 . - */ - - /* Scope guard logic lovingly taken from Andrei Alexandrescu's "Systemic Error Handling in C++" */ -#pragma once -#include "../defines.hpp" - -namespace ams::util { - - namespace impl { - - template - class ScopeGuard { - NON_COPYABLE(ScopeGuard); - private: - F f; - bool active; - public: - constexpr ScopeGuard(F f) : f(std::move(f)), active(true) { } - ~ScopeGuard() { if (active) { f(); } } - void Cancel() { active = false; } - - ScopeGuard(ScopeGuard&& rhs) : f(std::move(rhs.f)), active(rhs.active) { - rhs.Cancel(); - } - }; - - template - constexpr ScopeGuard MakeScopeGuard(F f) { - return ScopeGuard(std::move(f)); - } - - enum class ScopeGuardOnExit {}; - - template - constexpr ScopeGuard operator+(ScopeGuardOnExit, F&& f) { - return ScopeGuard(std::forward(f)); - } - - } - -} - -#define SCOPE_GUARD ::ams::util::impl::ScopeGuardOnExit() + [&]() -#define ON_SCOPE_EXIT auto ANONYMOUS_VARIABLE(SCOPE_EXIT_STATE_) = SCOPE_GUARD diff --git a/stratosphere/libstratosphere/include/atmosphere/util/util_size.hpp b/stratosphere/libstratosphere/include/atmosphere/util/util_size.hpp deleted file mode 100644 index c4db1a3bd..000000000 --- a/stratosphere/libstratosphere/include/atmosphere/util/util_size.hpp +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include "../defines.hpp" - -namespace ams::util { - - /* std::size() does not support zero-size C arrays. We're fixing that. */ - template - constexpr auto size(const C& c) -> decltype(c.size()) { - return std::size(c); - } - - template - constexpr std::size_t size(const C& c) { - if constexpr (sizeof(C) == 0) { - return 0; - } else { - return std::size(c); - } - } - -} \ No newline at end of file diff --git a/stratosphere/libstratosphere/include/atmosphere/util/util_typed_storage.hpp b/stratosphere/libstratosphere/include/atmosphere/util/util_typed_storage.hpp deleted file mode 100644 index 62d65b2de..000000000 --- a/stratosphere/libstratosphere/include/atmosphere/util/util_typed_storage.hpp +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include "../defines.hpp" - -namespace ams::util { - - template - struct TypedStorage { - typename std::aligned_storage::type _storage; - }; - - #define TYPED_STORAGE(T) ::ams::util::TypedStorage - - template - static constexpr inline __attribute__((always_inline)) T *GetPointer(TYPED_STORAGE(T) &ts) { - return reinterpret_cast(&ts._storage); - } - - template - static constexpr inline __attribute__((always_inline)) const T *GetPointer(const TYPED_STORAGE(T) &ts) { - return reinterpret_cast(&ts._storage); - } - - template - static constexpr inline __attribute__((always_inline)) T &GetReference(TYPED_STORAGE(T) &ts) { - return *GetPointer(ts); - } - - template - static constexpr inline __attribute__((always_inline)) const T &GetReference(const TYPED_STORAGE(T) &ts) { - return *GetPointer(ts); - } - -} diff --git a/stratosphere/libstratosphere/include/freebsd/sys/tree.h b/stratosphere/libstratosphere/include/freebsd/sys/tree.h deleted file mode 100644 index fecde6913..000000000 --- a/stratosphere/libstratosphere/include/freebsd/sys/tree.h +++ /dev/null @@ -1,812 +0,0 @@ -/* $NetBSD: tree.h,v 1.8 2004/03/28 19:38:30 provos Exp $ */ -/* $OpenBSD: tree.h,v 1.7 2002/10/17 21:51:54 art Exp $ */ -/* $FreeBSD$ */ - -/*- - * Copyright 2002 Niels Provos - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _SYS_TREE_H_ -#define _SYS_TREE_H_ - -/* FreeBSD has a lot of defines we don't really want. */ -/* tree.h only actually uses __inline and __unused, so we'll just define those. */ - -/* #include */ - -#ifndef __inline -#define __inline inline -#endif - -#ifndef __unused -#define __unused __attribute__((__unused__)) -#endif - -/* - * This file defines data structures for different types of trees: - * splay trees and red-black trees. - * - * A splay tree is a self-organizing data structure. Every operation - * on the tree causes a splay to happen. The splay moves the requested - * node to the root of the tree and partly rebalances it. - * - * This has the benefit that request locality causes faster lookups as - * the requested nodes move to the top of the tree. On the other hand, - * every lookup causes memory writes. - * - * The Balance Theorem bounds the total access time for m operations - * and n inserts on an initially empty tree as O((m + n)lg n). The - * amortized cost for a sequence of m accesses to a splay tree is O(lg n); - * - * A red-black tree is a binary search tree with the node color as an - * extra attribute. It fulfills a set of conditions: - * - every search path from the root to a leaf consists of the - * same number of black nodes, - * - each red node (except for the root) has a black parent, - * - each leaf node is black. - * - * Every operation on a red-black tree is bounded as O(lg n). - * The maximum height of a red-black tree is 2lg (n+1). - */ - -#define SPLAY_HEAD(name, type) \ -struct name { \ - struct type *sph_root; /* root of the tree */ \ -} - -#define SPLAY_INITIALIZER(root) \ - { NULL } - -#define SPLAY_INIT(root) do { \ - (root)->sph_root = NULL; \ -} while (/*CONSTCOND*/ 0) - -#define SPLAY_ENTRY(type) \ -struct { \ - struct type *spe_left; /* left element */ \ - struct type *spe_right; /* right element */ \ -} - -#define SPLAY_LEFT(elm, field) (elm)->field.spe_left -#define SPLAY_RIGHT(elm, field) (elm)->field.spe_right -#define SPLAY_ROOT(head) (head)->sph_root -#define SPLAY_EMPTY(head) (SPLAY_ROOT(head) == NULL) - -/* SPLAY_ROTATE_{LEFT,RIGHT} expect that tmp hold SPLAY_{RIGHT,LEFT} */ -#define SPLAY_ROTATE_RIGHT(head, tmp, field) do { \ - SPLAY_LEFT((head)->sph_root, field) = SPLAY_RIGHT(tmp, field); \ - SPLAY_RIGHT(tmp, field) = (head)->sph_root; \ - (head)->sph_root = tmp; \ -} while (/*CONSTCOND*/ 0) - -#define SPLAY_ROTATE_LEFT(head, tmp, field) do { \ - SPLAY_RIGHT((head)->sph_root, field) = SPLAY_LEFT(tmp, field); \ - SPLAY_LEFT(tmp, field) = (head)->sph_root; \ - (head)->sph_root = tmp; \ -} while (/*CONSTCOND*/ 0) - -#define SPLAY_LINKLEFT(head, tmp, field) do { \ - SPLAY_LEFT(tmp, field) = (head)->sph_root; \ - tmp = (head)->sph_root; \ - (head)->sph_root = SPLAY_LEFT((head)->sph_root, field); \ -} while (/*CONSTCOND*/ 0) - -#define SPLAY_LINKRIGHT(head, tmp, field) do { \ - SPLAY_RIGHT(tmp, field) = (head)->sph_root; \ - tmp = (head)->sph_root; \ - (head)->sph_root = SPLAY_RIGHT((head)->sph_root, field); \ -} while (/*CONSTCOND*/ 0) - -#define SPLAY_ASSEMBLE(head, node, left, right, field) do { \ - SPLAY_RIGHT(left, field) = SPLAY_LEFT((head)->sph_root, field); \ - SPLAY_LEFT(right, field) = SPLAY_RIGHT((head)->sph_root, field);\ - SPLAY_LEFT((head)->sph_root, field) = SPLAY_RIGHT(node, field); \ - SPLAY_RIGHT((head)->sph_root, field) = SPLAY_LEFT(node, field); \ -} while (/*CONSTCOND*/ 0) - -/* Generates prototypes and inline functions */ - -#define SPLAY_PROTOTYPE(name, type, field, cmp) \ -void name##_SPLAY(struct name *, struct type *); \ -void name##_SPLAY_MINMAX(struct name *, int); \ -struct type *name##_SPLAY_INSERT(struct name *, struct type *); \ -struct type *name##_SPLAY_REMOVE(struct name *, struct type *); \ - \ -/* Finds the node with the same key as elm */ \ -static __inline struct type * \ -name##_SPLAY_FIND(struct name *head, struct type *elm) \ -{ \ - if (SPLAY_EMPTY(head)) \ - return(NULL); \ - name##_SPLAY(head, elm); \ - if ((cmp)(elm, (head)->sph_root) == 0) \ - return (head->sph_root); \ - return (NULL); \ -} \ - \ -static __inline struct type * \ -name##_SPLAY_NEXT(struct name *head, struct type *elm) \ -{ \ - name##_SPLAY(head, elm); \ - if (SPLAY_RIGHT(elm, field) != NULL) { \ - elm = SPLAY_RIGHT(elm, field); \ - while (SPLAY_LEFT(elm, field) != NULL) { \ - elm = SPLAY_LEFT(elm, field); \ - } \ - } else \ - elm = NULL; \ - return (elm); \ -} \ - \ -static __inline struct type * \ -name##_SPLAY_MIN_MAX(struct name *head, int val) \ -{ \ - name##_SPLAY_MINMAX(head, val); \ - return (SPLAY_ROOT(head)); \ -} - -/* Main splay operation. - * Moves node close to the key of elm to top - */ -#define SPLAY_GENERATE(name, type, field, cmp) \ -struct type * \ -name##_SPLAY_INSERT(struct name *head, struct type *elm) \ -{ \ - if (SPLAY_EMPTY(head)) { \ - SPLAY_LEFT(elm, field) = SPLAY_RIGHT(elm, field) = NULL; \ - } else { \ - int __comp; \ - name##_SPLAY(head, elm); \ - __comp = (cmp)(elm, (head)->sph_root); \ - if(__comp < 0) { \ - SPLAY_LEFT(elm, field) = SPLAY_LEFT((head)->sph_root, field);\ - SPLAY_RIGHT(elm, field) = (head)->sph_root; \ - SPLAY_LEFT((head)->sph_root, field) = NULL; \ - } else if (__comp > 0) { \ - SPLAY_RIGHT(elm, field) = SPLAY_RIGHT((head)->sph_root, field);\ - SPLAY_LEFT(elm, field) = (head)->sph_root; \ - SPLAY_RIGHT((head)->sph_root, field) = NULL; \ - } else \ - return ((head)->sph_root); \ - } \ - (head)->sph_root = (elm); \ - return (NULL); \ -} \ - \ -struct type * \ -name##_SPLAY_REMOVE(struct name *head, struct type *elm) \ -{ \ - struct type *__tmp; \ - if (SPLAY_EMPTY(head)) \ - return (NULL); \ - name##_SPLAY(head, elm); \ - if ((cmp)(elm, (head)->sph_root) == 0) { \ - if (SPLAY_LEFT((head)->sph_root, field) == NULL) { \ - (head)->sph_root = SPLAY_RIGHT((head)->sph_root, field);\ - } else { \ - __tmp = SPLAY_RIGHT((head)->sph_root, field); \ - (head)->sph_root = SPLAY_LEFT((head)->sph_root, field);\ - name##_SPLAY(head, elm); \ - SPLAY_RIGHT((head)->sph_root, field) = __tmp; \ - } \ - return (elm); \ - } \ - return (NULL); \ -} \ - \ -void \ -name##_SPLAY(struct name *head, struct type *elm) \ -{ \ - struct type __node, *__left, *__right, *__tmp; \ - int __comp; \ -\ - SPLAY_LEFT(&__node, field) = SPLAY_RIGHT(&__node, field) = NULL;\ - __left = __right = &__node; \ -\ - while ((__comp = (cmp)(elm, (head)->sph_root)) != 0) { \ - if (__comp < 0) { \ - __tmp = SPLAY_LEFT((head)->sph_root, field); \ - if (__tmp == NULL) \ - break; \ - if ((cmp)(elm, __tmp) < 0){ \ - SPLAY_ROTATE_RIGHT(head, __tmp, field); \ - if (SPLAY_LEFT((head)->sph_root, field) == NULL)\ - break; \ - } \ - SPLAY_LINKLEFT(head, __right, field); \ - } else if (__comp > 0) { \ - __tmp = SPLAY_RIGHT((head)->sph_root, field); \ - if (__tmp == NULL) \ - break; \ - if ((cmp)(elm, __tmp) > 0){ \ - SPLAY_ROTATE_LEFT(head, __tmp, field); \ - if (SPLAY_RIGHT((head)->sph_root, field) == NULL)\ - break; \ - } \ - SPLAY_LINKRIGHT(head, __left, field); \ - } \ - } \ - SPLAY_ASSEMBLE(head, &__node, __left, __right, field); \ -} \ - \ -/* Splay with either the minimum or the maximum element \ - * Used to find minimum or maximum element in tree. \ - */ \ -void name##_SPLAY_MINMAX(struct name *head, int __comp) \ -{ \ - struct type __node, *__left, *__right, *__tmp; \ -\ - SPLAY_LEFT(&__node, field) = SPLAY_RIGHT(&__node, field) = NULL;\ - __left = __right = &__node; \ -\ - while (1) { \ - if (__comp < 0) { \ - __tmp = SPLAY_LEFT((head)->sph_root, field); \ - if (__tmp == NULL) \ - break; \ - if (__comp < 0){ \ - SPLAY_ROTATE_RIGHT(head, __tmp, field); \ - if (SPLAY_LEFT((head)->sph_root, field) == NULL)\ - break; \ - } \ - SPLAY_LINKLEFT(head, __right, field); \ - } else if (__comp > 0) { \ - __tmp = SPLAY_RIGHT((head)->sph_root, field); \ - if (__tmp == NULL) \ - break; \ - if (__comp > 0) { \ - SPLAY_ROTATE_LEFT(head, __tmp, field); \ - if (SPLAY_RIGHT((head)->sph_root, field) == NULL)\ - break; \ - } \ - SPLAY_LINKRIGHT(head, __left, field); \ - } \ - } \ - SPLAY_ASSEMBLE(head, &__node, __left, __right, field); \ -} - -#define SPLAY_NEGINF -1 -#define SPLAY_INF 1 - -#define SPLAY_INSERT(name, x, y) name##_SPLAY_INSERT(x, y) -#define SPLAY_REMOVE(name, x, y) name##_SPLAY_REMOVE(x, y) -#define SPLAY_FIND(name, x, y) name##_SPLAY_FIND(x, y) -#define SPLAY_NEXT(name, x, y) name##_SPLAY_NEXT(x, y) -#define SPLAY_MIN(name, x) (SPLAY_EMPTY(x) ? NULL \ - : name##_SPLAY_MIN_MAX(x, SPLAY_NEGINF)) -#define SPLAY_MAX(name, x) (SPLAY_EMPTY(x) ? NULL \ - : name##_SPLAY_MIN_MAX(x, SPLAY_INF)) - -#define SPLAY_FOREACH(x, name, head) \ - for ((x) = SPLAY_MIN(name, head); \ - (x) != NULL; \ - (x) = SPLAY_NEXT(name, head, x)) - -/* Macros that define a red-black tree */ -#define RB_HEAD(name, type) \ -struct name { \ - struct type *rbh_root; /* root of the tree */ \ -} - -#define RB_INITIALIZER(root) \ - { NULL } - -#define RB_INIT(root) do { \ - (root)->rbh_root = NULL; \ -} while (/*CONSTCOND*/ 0) - -#define RB_BLACK 0 -#define RB_RED 1 -#define RB_ENTRY(type) \ -struct { \ - struct type *rbe_left; /* left element */ \ - struct type *rbe_right; /* right element */ \ - struct type *rbe_parent; /* parent element */ \ - int rbe_color; /* node color */ \ -} - -#define RB_LEFT(elm, field) (elm)->field.rbe_left -#define RB_RIGHT(elm, field) (elm)->field.rbe_right -#define RB_PARENT(elm, field) (elm)->field.rbe_parent -#define RB_COLOR(elm, field) (elm)->field.rbe_color -#define RB_ROOT(head) (head)->rbh_root -#define RB_EMPTY(head) (RB_ROOT(head) == NULL) - -#define RB_SET(elm, parent, field) do { \ - RB_PARENT(elm, field) = parent; \ - RB_LEFT(elm, field) = RB_RIGHT(elm, field) = NULL; \ - RB_COLOR(elm, field) = RB_RED; \ -} while (/*CONSTCOND*/ 0) - -#define RB_SET_BLACKRED(black, red, field) do { \ - RB_COLOR(black, field) = RB_BLACK; \ - RB_COLOR(red, field) = RB_RED; \ -} while (/*CONSTCOND*/ 0) - -#ifndef RB_AUGMENT -#define RB_AUGMENT(x) do {} while (0) -#endif - -#define RB_ROTATE_LEFT(head, elm, tmp, field) do { \ - (tmp) = RB_RIGHT(elm, field); \ - if ((RB_RIGHT(elm, field) = RB_LEFT(tmp, field)) != NULL) { \ - RB_PARENT(RB_LEFT(tmp, field), field) = (elm); \ - } \ - RB_AUGMENT(elm); \ - if ((RB_PARENT(tmp, field) = RB_PARENT(elm, field)) != NULL) { \ - if ((elm) == RB_LEFT(RB_PARENT(elm, field), field)) \ - RB_LEFT(RB_PARENT(elm, field), field) = (tmp); \ - else \ - RB_RIGHT(RB_PARENT(elm, field), field) = (tmp); \ - } else \ - (head)->rbh_root = (tmp); \ - RB_LEFT(tmp, field) = (elm); \ - RB_PARENT(elm, field) = (tmp); \ - RB_AUGMENT(tmp); \ - if ((RB_PARENT(tmp, field))) \ - RB_AUGMENT(RB_PARENT(tmp, field)); \ -} while (/*CONSTCOND*/ 0) - -#define RB_ROTATE_RIGHT(head, elm, tmp, field) do { \ - (tmp) = RB_LEFT(elm, field); \ - if ((RB_LEFT(elm, field) = RB_RIGHT(tmp, field)) != NULL) { \ - RB_PARENT(RB_RIGHT(tmp, field), field) = (elm); \ - } \ - RB_AUGMENT(elm); \ - if ((RB_PARENT(tmp, field) = RB_PARENT(elm, field)) != NULL) { \ - if ((elm) == RB_LEFT(RB_PARENT(elm, field), field)) \ - RB_LEFT(RB_PARENT(elm, field), field) = (tmp); \ - else \ - RB_RIGHT(RB_PARENT(elm, field), field) = (tmp); \ - } else \ - (head)->rbh_root = (tmp); \ - RB_RIGHT(tmp, field) = (elm); \ - RB_PARENT(elm, field) = (tmp); \ - RB_AUGMENT(tmp); \ - if ((RB_PARENT(tmp, field))) \ - RB_AUGMENT(RB_PARENT(tmp, field)); \ -} while (/*CONSTCOND*/ 0) - -/* Generates prototypes and inline functions */ -#define RB_PROTOTYPE(name, type, field, cmp) \ - RB_PROTOTYPE_INTERNAL(name, type, field, cmp,) -#define RB_PROTOTYPE_STATIC(name, type, field, cmp) \ - RB_PROTOTYPE_INTERNAL(name, type, field, cmp, __unused static) -#define RB_PROTOTYPE_INTERNAL(name, type, field, cmp, attr) \ - RB_PROTOTYPE_INSERT_COLOR(name, type, attr); \ - RB_PROTOTYPE_REMOVE_COLOR(name, type, attr); \ - RB_PROTOTYPE_INSERT(name, type, attr); \ - RB_PROTOTYPE_REMOVE(name, type, attr); \ - RB_PROTOTYPE_FIND(name, type, attr); \ - RB_PROTOTYPE_NFIND(name, type, attr); \ - RB_PROTOTYPE_NEXT(name, type, attr); \ - RB_PROTOTYPE_PREV(name, type, attr); \ - RB_PROTOTYPE_MINMAX(name, type, attr); -#define RB_PROTOTYPE_INSERT_COLOR(name, type, attr) \ - attr void name##_RB_INSERT_COLOR(struct name *, struct type *) -#define RB_PROTOTYPE_REMOVE_COLOR(name, type, attr) \ - attr void name##_RB_REMOVE_COLOR(struct name *, struct type *, struct type *) -#define RB_PROTOTYPE_REMOVE(name, type, attr) \ - attr struct type *name##_RB_REMOVE(struct name *, struct type *) -#define RB_PROTOTYPE_INSERT(name, type, attr) \ - attr struct type *name##_RB_INSERT(struct name *, struct type *) -#define RB_PROTOTYPE_FIND(name, type, attr) \ - attr struct type *name##_RB_FIND(struct name *, struct type *) -#define RB_PROTOTYPE_NFIND(name, type, attr) \ - attr struct type *name##_RB_NFIND(struct name *, struct type *) -#define RB_PROTOTYPE_NEXT(name, type, attr) \ - attr struct type *name##_RB_NEXT(struct type *) -#define RB_PROTOTYPE_PREV(name, type, attr) \ - attr struct type *name##_RB_PREV(struct type *) -#define RB_PROTOTYPE_MINMAX(name, type, attr) \ - attr struct type *name##_RB_MINMAX(struct name *, int) - -/* Main rb operation. - * Moves node close to the key of elm to top - */ -#define RB_GENERATE(name, type, field, cmp) \ - RB_GENERATE_INTERNAL(name, type, field, cmp,) -#define RB_GENERATE_STATIC(name, type, field, cmp) \ - RB_GENERATE_INTERNAL(name, type, field, cmp, __unused static) -#define RB_GENERATE_INTERNAL(name, type, field, cmp, attr) \ - RB_GENERATE_INSERT_COLOR(name, type, field, attr) \ - RB_GENERATE_REMOVE_COLOR(name, type, field, attr) \ - RB_GENERATE_INSERT(name, type, field, cmp, attr) \ - RB_GENERATE_REMOVE(name, type, field, attr) \ - RB_GENERATE_FIND(name, type, field, cmp, attr) \ - RB_GENERATE_NFIND(name, type, field, cmp, attr) \ - RB_GENERATE_NEXT(name, type, field, attr) \ - RB_GENERATE_PREV(name, type, field, attr) \ - RB_GENERATE_MINMAX(name, type, field, attr) - -#define RB_GENERATE_INSERT_COLOR(name, type, field, attr) \ -attr void \ -name##_RB_INSERT_COLOR(struct name *head, struct type *elm) \ -{ \ - struct type *parent, *gparent, *tmp; \ - while ((parent = RB_PARENT(elm, field)) != NULL && \ - RB_COLOR(parent, field) == RB_RED) { \ - gparent = RB_PARENT(parent, field); \ - if (parent == RB_LEFT(gparent, field)) { \ - tmp = RB_RIGHT(gparent, field); \ - if (tmp && RB_COLOR(tmp, field) == RB_RED) { \ - RB_COLOR(tmp, field) = RB_BLACK; \ - RB_SET_BLACKRED(parent, gparent, field);\ - elm = gparent; \ - continue; \ - } \ - if (RB_RIGHT(parent, field) == elm) { \ - RB_ROTATE_LEFT(head, parent, tmp, field);\ - tmp = parent; \ - parent = elm; \ - elm = tmp; \ - } \ - RB_SET_BLACKRED(parent, gparent, field); \ - RB_ROTATE_RIGHT(head, gparent, tmp, field); \ - } else { \ - tmp = RB_LEFT(gparent, field); \ - if (tmp && RB_COLOR(tmp, field) == RB_RED) { \ - RB_COLOR(tmp, field) = RB_BLACK; \ - RB_SET_BLACKRED(parent, gparent, field);\ - elm = gparent; \ - continue; \ - } \ - if (RB_LEFT(parent, field) == elm) { \ - RB_ROTATE_RIGHT(head, parent, tmp, field);\ - tmp = parent; \ - parent = elm; \ - elm = tmp; \ - } \ - RB_SET_BLACKRED(parent, gparent, field); \ - RB_ROTATE_LEFT(head, gparent, tmp, field); \ - } \ - } \ - RB_COLOR(head->rbh_root, field) = RB_BLACK; \ -} - -#define RB_GENERATE_REMOVE_COLOR(name, type, field, attr) \ -attr void \ -name##_RB_REMOVE_COLOR(struct name *head, struct type *parent, struct type *elm) \ -{ \ - struct type *tmp; \ - while ((elm == NULL || RB_COLOR(elm, field) == RB_BLACK) && \ - elm != RB_ROOT(head)) { \ - if (RB_LEFT(parent, field) == elm) { \ - tmp = RB_RIGHT(parent, field); \ - if (RB_COLOR(tmp, field) == RB_RED) { \ - RB_SET_BLACKRED(tmp, parent, field); \ - RB_ROTATE_LEFT(head, parent, tmp, field);\ - tmp = RB_RIGHT(parent, field); \ - } \ - if ((RB_LEFT(tmp, field) == NULL || \ - RB_COLOR(RB_LEFT(tmp, field), field) == RB_BLACK) &&\ - (RB_RIGHT(tmp, field) == NULL || \ - RB_COLOR(RB_RIGHT(tmp, field), field) == RB_BLACK)) {\ - RB_COLOR(tmp, field) = RB_RED; \ - elm = parent; \ - parent = RB_PARENT(elm, field); \ - } else { \ - if (RB_RIGHT(tmp, field) == NULL || \ - RB_COLOR(RB_RIGHT(tmp, field), field) == RB_BLACK) {\ - struct type *oleft; \ - if ((oleft = RB_LEFT(tmp, field)) \ - != NULL) \ - RB_COLOR(oleft, field) = RB_BLACK;\ - RB_COLOR(tmp, field) = RB_RED; \ - RB_ROTATE_RIGHT(head, tmp, oleft, field);\ - tmp = RB_RIGHT(parent, field); \ - } \ - RB_COLOR(tmp, field) = RB_COLOR(parent, field);\ - RB_COLOR(parent, field) = RB_BLACK; \ - if (RB_RIGHT(tmp, field)) \ - RB_COLOR(RB_RIGHT(tmp, field), field) = RB_BLACK;\ - RB_ROTATE_LEFT(head, parent, tmp, field);\ - elm = RB_ROOT(head); \ - break; \ - } \ - } else { \ - tmp = RB_LEFT(parent, field); \ - if (RB_COLOR(tmp, field) == RB_RED) { \ - RB_SET_BLACKRED(tmp, parent, field); \ - RB_ROTATE_RIGHT(head, parent, tmp, field);\ - tmp = RB_LEFT(parent, field); \ - } \ - if ((RB_LEFT(tmp, field) == NULL || \ - RB_COLOR(RB_LEFT(tmp, field), field) == RB_BLACK) &&\ - (RB_RIGHT(tmp, field) == NULL || \ - RB_COLOR(RB_RIGHT(tmp, field), field) == RB_BLACK)) {\ - RB_COLOR(tmp, field) = RB_RED; \ - elm = parent; \ - parent = RB_PARENT(elm, field); \ - } else { \ - if (RB_LEFT(tmp, field) == NULL || \ - RB_COLOR(RB_LEFT(tmp, field), field) == RB_BLACK) {\ - struct type *oright; \ - if ((oright = RB_RIGHT(tmp, field)) \ - != NULL) \ - RB_COLOR(oright, field) = RB_BLACK;\ - RB_COLOR(tmp, field) = RB_RED; \ - RB_ROTATE_LEFT(head, tmp, oright, field);\ - tmp = RB_LEFT(parent, field); \ - } \ - RB_COLOR(tmp, field) = RB_COLOR(parent, field);\ - RB_COLOR(parent, field) = RB_BLACK; \ - if (RB_LEFT(tmp, field)) \ - RB_COLOR(RB_LEFT(tmp, field), field) = RB_BLACK;\ - RB_ROTATE_RIGHT(head, parent, tmp, field);\ - elm = RB_ROOT(head); \ - break; \ - } \ - } \ - } \ - if (elm) \ - RB_COLOR(elm, field) = RB_BLACK; \ -} - -#define RB_GENERATE_REMOVE(name, type, field, attr) \ -attr struct type * \ -name##_RB_REMOVE(struct name *head, struct type *elm) \ -{ \ - struct type *child, *parent, *old = elm; \ - int color; \ - if (RB_LEFT(elm, field) == NULL) \ - child = RB_RIGHT(elm, field); \ - else if (RB_RIGHT(elm, field) == NULL) \ - child = RB_LEFT(elm, field); \ - else { \ - struct type *left; \ - elm = RB_RIGHT(elm, field); \ - while ((left = RB_LEFT(elm, field)) != NULL) \ - elm = left; \ - child = RB_RIGHT(elm, field); \ - parent = RB_PARENT(elm, field); \ - color = RB_COLOR(elm, field); \ - if (child) \ - RB_PARENT(child, field) = parent; \ - if (parent) { \ - if (RB_LEFT(parent, field) == elm) \ - RB_LEFT(parent, field) = child; \ - else \ - RB_RIGHT(parent, field) = child; \ - RB_AUGMENT(parent); \ - } else \ - RB_ROOT(head) = child; \ - if (RB_PARENT(elm, field) == old) \ - parent = elm; \ - (elm)->field = (old)->field; \ - if (RB_PARENT(old, field)) { \ - if (RB_LEFT(RB_PARENT(old, field), field) == old)\ - RB_LEFT(RB_PARENT(old, field), field) = elm;\ - else \ - RB_RIGHT(RB_PARENT(old, field), field) = elm;\ - RB_AUGMENT(RB_PARENT(old, field)); \ - } else \ - RB_ROOT(head) = elm; \ - RB_PARENT(RB_LEFT(old, field), field) = elm; \ - if (RB_RIGHT(old, field)) \ - RB_PARENT(RB_RIGHT(old, field), field) = elm; \ - if (parent) { \ - left = parent; \ - do { \ - RB_AUGMENT(left); \ - } while ((left = RB_PARENT(left, field)) != NULL); \ - } \ - goto color; \ - } \ - parent = RB_PARENT(elm, field); \ - color = RB_COLOR(elm, field); \ - if (child) \ - RB_PARENT(child, field) = parent; \ - if (parent) { \ - if (RB_LEFT(parent, field) == elm) \ - RB_LEFT(parent, field) = child; \ - else \ - RB_RIGHT(parent, field) = child; \ - RB_AUGMENT(parent); \ - } else \ - RB_ROOT(head) = child; \ -color: \ - if (color == RB_BLACK) \ - name##_RB_REMOVE_COLOR(head, parent, child); \ - return (old); \ -} \ - -#define RB_GENERATE_INSERT(name, type, field, cmp, attr) \ -/* Inserts a node into the RB tree */ \ -attr struct type * \ -name##_RB_INSERT(struct name *head, struct type *elm) \ -{ \ - struct type *tmp; \ - struct type *parent = NULL; \ - int comp = 0; \ - tmp = RB_ROOT(head); \ - while (tmp) { \ - parent = tmp; \ - comp = (cmp)(elm, parent); \ - if (comp < 0) \ - tmp = RB_LEFT(tmp, field); \ - else if (comp > 0) \ - tmp = RB_RIGHT(tmp, field); \ - else \ - return (tmp); \ - } \ - RB_SET(elm, parent, field); \ - if (parent != NULL) { \ - if (comp < 0) \ - RB_LEFT(parent, field) = elm; \ - else \ - RB_RIGHT(parent, field) = elm; \ - RB_AUGMENT(parent); \ - } else \ - RB_ROOT(head) = elm; \ - name##_RB_INSERT_COLOR(head, elm); \ - return (NULL); \ -} - -#define RB_GENERATE_FIND(name, type, field, cmp, attr) \ -/* Finds the node with the same key as elm */ \ -attr struct type * \ -name##_RB_FIND(struct name *head, struct type *elm) \ -{ \ - struct type *tmp = RB_ROOT(head); \ - int comp; \ - while (tmp) { \ - comp = cmp(elm, tmp); \ - if (comp < 0) \ - tmp = RB_LEFT(tmp, field); \ - else if (comp > 0) \ - tmp = RB_RIGHT(tmp, field); \ - else \ - return (tmp); \ - } \ - return (NULL); \ -} - -#define RB_GENERATE_NFIND(name, type, field, cmp, attr) \ -/* Finds the first node greater than or equal to the search key */ \ -attr struct type * \ -name##_RB_NFIND(struct name *head, struct type *elm) \ -{ \ - struct type *tmp = RB_ROOT(head); \ - struct type *res = NULL; \ - int comp; \ - while (tmp) { \ - comp = cmp(elm, tmp); \ - if (comp < 0) { \ - res = tmp; \ - tmp = RB_LEFT(tmp, field); \ - } \ - else if (comp > 0) \ - tmp = RB_RIGHT(tmp, field); \ - else \ - return (tmp); \ - } \ - return (res); \ -} - -#define RB_GENERATE_NEXT(name, type, field, attr) \ -/* ARGSUSED */ \ -attr struct type * \ -name##_RB_NEXT(struct type *elm) \ -{ \ - if (RB_RIGHT(elm, field)) { \ - elm = RB_RIGHT(elm, field); \ - while (RB_LEFT(elm, field)) \ - elm = RB_LEFT(elm, field); \ - } else { \ - if (RB_PARENT(elm, field) && \ - (elm == RB_LEFT(RB_PARENT(elm, field), field))) \ - elm = RB_PARENT(elm, field); \ - else { \ - while (RB_PARENT(elm, field) && \ - (elm == RB_RIGHT(RB_PARENT(elm, field), field)))\ - elm = RB_PARENT(elm, field); \ - elm = RB_PARENT(elm, field); \ - } \ - } \ - return (elm); \ -} - -#define RB_GENERATE_PREV(name, type, field, attr) \ -/* ARGSUSED */ \ -attr struct type * \ -name##_RB_PREV(struct type *elm) \ -{ \ - if (RB_LEFT(elm, field)) { \ - elm = RB_LEFT(elm, field); \ - while (RB_RIGHT(elm, field)) \ - elm = RB_RIGHT(elm, field); \ - } else { \ - if (RB_PARENT(elm, field) && \ - (elm == RB_RIGHT(RB_PARENT(elm, field), field))) \ - elm = RB_PARENT(elm, field); \ - else { \ - while (RB_PARENT(elm, field) && \ - (elm == RB_LEFT(RB_PARENT(elm, field), field)))\ - elm = RB_PARENT(elm, field); \ - elm = RB_PARENT(elm, field); \ - } \ - } \ - return (elm); \ -} - -#define RB_GENERATE_MINMAX(name, type, field, attr) \ -attr struct type * \ -name##_RB_MINMAX(struct name *head, int val) \ -{ \ - struct type *tmp = RB_ROOT(head); \ - struct type *parent = NULL; \ - while (tmp) { \ - parent = tmp; \ - if (val < 0) \ - tmp = RB_LEFT(tmp, field); \ - else \ - tmp = RB_RIGHT(tmp, field); \ - } \ - return (parent); \ -} - -#define RB_NEGINF -1 -#define RB_INF 1 - -#define RB_INSERT(name, x, y) name##_RB_INSERT(x, y) -#define RB_REMOVE(name, x, y) name##_RB_REMOVE(x, y) -#define RB_FIND(name, x, y) name##_RB_FIND(x, y) -#define RB_NFIND(name, x, y) name##_RB_NFIND(x, y) -#define RB_NEXT(name, x, y) name##_RB_NEXT(y) -#define RB_PREV(name, x, y) name##_RB_PREV(y) -#define RB_MIN(name, x) name##_RB_MINMAX(x, RB_NEGINF) -#define RB_MAX(name, x) name##_RB_MINMAX(x, RB_INF) - -#define RB_FOREACH(x, name, head) \ - for ((x) = RB_MIN(name, head); \ - (x) != NULL; \ - (x) = name##_RB_NEXT(x)) - -#define RB_FOREACH_FROM(x, name, y) \ - for ((x) = (y); \ - ((x) != NULL) && ((y) = name##_RB_NEXT(x), (x) != NULL); \ - (x) = (y)) - -#define RB_FOREACH_SAFE(x, name, head, y) \ - for ((x) = RB_MIN(name, head); \ - ((x) != NULL) && ((y) = name##_RB_NEXT(x), (x) != NULL); \ - (x) = (y)) - -#define RB_FOREACH_REVERSE(x, name, head) \ - for ((x) = RB_MAX(name, head); \ - (x) != NULL; \ - (x) = name##_RB_PREV(x)) - -#define RB_FOREACH_REVERSE_FROM(x, name, y) \ - for ((x) = (y); \ - ((x) != NULL) && ((y) = name##_RB_PREV(x), (x) != NULL); \ - (x) = (y)) - -#define RB_FOREACH_REVERSE_SAFE(x, name, head, y) \ - for ((x) = RB_MAX(name, head); \ - ((x) != NULL) && ((y) = name##_RB_PREV(x), (x) != NULL); \ - (x) = (y)) - -#endif /* _SYS_TREE_H_ */ diff --git a/stratosphere/libstratosphere/include/stratosphere.hpp b/stratosphere/libstratosphere/include/stratosphere.hpp deleted file mode 100644 index a432ace74..000000000 --- a/stratosphere/libstratosphere/include/stratosphere.hpp +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once - -/* Pulls in util, svc. */ -#include "atmosphere/common.hpp" - -/* Critical modules with no dependencies. */ -#include "stratosphere/ams.hpp" -#include "stratosphere/os.hpp" -#include "stratosphere/dd.hpp" - -/* Lots of things depend on NCM, for Program IDs. */ -#include "stratosphere/ncm.hpp" - -/* At this point, just include the rest alphabetically. */ -/* TODO: Figure out optimal order. */ -#include "stratosphere/boot2.hpp" -#include "stratosphere/cfg.hpp" -#include "stratosphere/dmnt.hpp" -#include "stratosphere/fatal.hpp" -#include "stratosphere/hid.hpp" -#include "stratosphere/hos.hpp" -#include "stratosphere/kvdb.hpp" -#include "stratosphere/ldr.hpp" -#include "stratosphere/map.hpp" -#include "stratosphere/patcher.hpp" -#include "stratosphere/pm.hpp" -#include "stratosphere/reg.hpp" -#include "stratosphere/rnd.hpp" -#include "stratosphere/ro.hpp" -#include "stratosphere/settings.hpp" -#include "stratosphere/sf.hpp" -#include "stratosphere/sm.hpp" -#include "stratosphere/spl.hpp" -#include "stratosphere/updater.hpp" - -/* Include FS last. */ -#include "stratosphere/fs.hpp" -#include "stratosphere/fssrv.hpp" -#include "stratosphere/fssystem.hpp" diff --git a/stratosphere/libstratosphere/include/stratosphere/ams.hpp b/stratosphere/libstratosphere/include/stratosphere/ams.hpp deleted file mode 100644 index 8abd99240..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/ams.hpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once - -#include "ams/ams_types.hpp" -#include "ams/ams_exosphere_api.hpp" -#include "ams/ams_emummc_api.hpp" -#include "ams/ams_environment.hpp" diff --git a/stratosphere/libstratosphere/include/stratosphere/ams/ams_emummc_api.hpp b/stratosphere/libstratosphere/include/stratosphere/ams/ams_emummc_api.hpp deleted file mode 100644 index e1d3d21ec..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/ams/ams_emummc_api.hpp +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include "ams_types.hpp" - -namespace ams::emummc { - - /* Get whether emummc is active. */ - bool IsActive(); - - /* Get Nintendo redirection path. */ - const char *GetNintendoDirPath(); - - /* Get Emummc folderpath, NULL if not file-based. */ - const char *GetFilePath(); - -} diff --git a/stratosphere/libstratosphere/include/stratosphere/ams/ams_environment.hpp b/stratosphere/libstratosphere/include/stratosphere/ams/ams_environment.hpp deleted file mode 100644 index d6138e1ca..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/ams/ams_environment.hpp +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include "ams_types.hpp" - -namespace ams { - - /* Will be called by libstratosphere on crash. */ - void CrashHandler(ThreadExceptionDump *ctx); - -} diff --git a/stratosphere/libstratosphere/include/stratosphere/ams/ams_exosphere_api.hpp b/stratosphere/libstratosphere/include/stratosphere/ams/ams_exosphere_api.hpp deleted file mode 100644 index 9307ae7ba..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/ams/ams_exosphere_api.hpp +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include "ams_types.hpp" - -namespace ams::exosphere { - - ApiInfo GetApiInfo(); - - void ForceRebootToRcm(); - void ForceRebootToIramPayload(); - void ForceShutdown(); - - bool IsRcmBugPatched(); - - void CopyToIram(uintptr_t iram_dst, const void *dram_src, size_t size); - void CopyFromIram(void *dram_dst, uintptr_t iram_src, size_t size); - -} - -namespace ams { - - /* Version checking utility. */ -#ifdef ATMOSPHERE_RELEASE_VERSION_MAJOR - -#define ATMOSPHERE_RELEASE_VERSION ATMOSPHERE_RELEASE_VERSION_MAJOR, ATMOSPHERE_RELEASE_VERSION_MINOR, ATMOSPHERE_RELEASE_VERSION_MICRO - - inline void CheckApiVersion() { - const u32 runtime_version = exosphere::GetApiInfo().GetVersion(); - const u32 build_version = exosphere::GetVersion(ATMOSPHERE_RELEASE_VERSION); - - if (runtime_version < build_version) { - R_ASSERT(exosphere::ResultVersionMismatch()); - } - } - -#endif - -} diff --git a/stratosphere/libstratosphere/include/stratosphere/ams/ams_types.hpp b/stratosphere/libstratosphere/include/stratosphere/ams/ams_types.hpp deleted file mode 100644 index 75e7adfe7..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/ams/ams_types.hpp +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include -#include "../sf/sf_buffer_tags.hpp" -#include "../hos.hpp" - -namespace ams::exosphere { - - enum TargetFirmware : u32 { - TargetFirmware_100 = 1, - TargetFirmware_200 = 2, - TargetFirmware_300 = 3, - TargetFirmware_400 = 4, - TargetFirmware_500 = 5, - TargetFirmware_600 = 6, - TargetFirmware_620 = 7, - TargetFirmware_700 = 8, - TargetFirmware_800 = 9, - TargetFirmware_810 = 10, - TargetFirmware_900 = 11, - TargetFirmware_910 = 12, - }; - -#ifdef ATMOSPHERE_H -/* #ifdef __has_include() */ - -#define AMS_VALIDATE_TARGET_FIRMWARE_ENUM(n) static_assert(TargetFirmware_##n == ATMOSPHERE_TARGET_FIRMWARE_##n) - - AMS_VALIDATE_TARGET_FIRMWARE_ENUM(100); - AMS_VALIDATE_TARGET_FIRMWARE_ENUM(200); - AMS_VALIDATE_TARGET_FIRMWARE_ENUM(300); - AMS_VALIDATE_TARGET_FIRMWARE_ENUM(400); - AMS_VALIDATE_TARGET_FIRMWARE_ENUM(500); - AMS_VALIDATE_TARGET_FIRMWARE_ENUM(620); - AMS_VALIDATE_TARGET_FIRMWARE_ENUM(700); - AMS_VALIDATE_TARGET_FIRMWARE_ENUM(800); - AMS_VALIDATE_TARGET_FIRMWARE_ENUM(810); - AMS_VALIDATE_TARGET_FIRMWARE_ENUM(900); - AMS_VALIDATE_TARGET_FIRMWARE_ENUM(910); - -#undef AMS_VALIDATE_TARGET_FIRMWARE_ENUM - -#endif - - constexpr inline u32 GetVersion(u32 major, u32 minor, u32 micro) { - return (major << 16) | (minor << 8) | (micro); - } - - struct ApiInfo { - u32 major_version; - u32 minor_version; - u32 micro_version; - TargetFirmware target_firmware; - u32 master_key_revision; - - constexpr u32 GetVersion() const { - return ::ams::exosphere::GetVersion(this->major_version, this->minor_version, this->micro_version); - } - - constexpr TargetFirmware GetTargetFirmware() const { - return this->target_firmware; - } - - constexpr u32 GetMasterKeyRevision() const { - return this->master_key_revision; - } - }; - -} - -namespace ams { - - struct FatalErrorContext : sf::LargeData, sf::PrefersMapAliasTransferMode { - static constexpr size_t MaxStackTrace = 0x20; - static constexpr size_t MaxStackDumpSize = 0x100; - static constexpr size_t NumGprs = 29; - static constexpr uintptr_t StdAbortMagicAddress = 0x8; - static constexpr u64 StdAbortMagicValue = 0xA55AF00DDEADCAFEul; - static constexpr u32 StdAbortErrorDesc = 0xFFE; - static constexpr u32 DataAbortErrorDesc = 0x101; - static constexpr u32 Magic = 0x31454641; - - u32 magic; - u32 error_desc; - u64 program_id; - union { - u64 gprs[32]; - struct { - u64 _gprs[29]; - u64 fp; - u64 lr; - u64 sp; - }; - }; - u64 pc; - u64 module_base; - u32 pstate; - u32 afsr0; - u32 afsr1; - u32 esr; - u64 far; - u64 report_identifier; /* Normally just system tick. */ - u64 stack_trace_size; - u64 stack_dump_size; - u64 stack_trace[MaxStackTrace]; - u8 stack_dump[MaxStackDumpSize]; - }; - - static_assert(sizeof(FatalErrorContext) == 0x350, "sizeof(FatalErrorContext)"); - static_assert(std::is_pod::value, "FatalErrorContext"); - -#ifdef ATMOSPHERE_GIT_BRANCH - NX_CONSTEXPR const char *GetGitBranch() { - return ATMOSPHERE_GIT_BRANCH; - } -#endif - -#ifdef ATMOSPHERE_GIT_REV - NX_CONSTEXPR const char *GetGitRevision() { - return ATMOSPHERE_GIT_REV; - } -#endif - -} diff --git a/stratosphere/libstratosphere/include/stratosphere/boot2.hpp b/stratosphere/libstratosphere/include/stratosphere/boot2.hpp deleted file mode 100644 index f75afe4b1..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/boot2.hpp +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once - -#include "boot2/boot2_api.hpp" diff --git a/stratosphere/libstratosphere/include/stratosphere/boot2/boot2_api.hpp b/stratosphere/libstratosphere/include/stratosphere/boot2/boot2_api.hpp deleted file mode 100644 index f23925864..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/boot2/boot2_api.hpp +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include - -namespace ams::boot2 { - - /* Boot2 API. */ - - /* Normally invoked by PM. */ - void LaunchPreSdCardBootProgramsAndBoot2(); - - /* Normally invoked by boot2. */ - void LaunchPostSdCardBootPrograms(); - -} diff --git a/stratosphere/libstratosphere/include/stratosphere/cfg.hpp b/stratosphere/libstratosphere/include/stratosphere/cfg.hpp deleted file mode 100644 index 6c9f85bfe..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/cfg.hpp +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once - -#include "cfg/cfg_api.hpp" diff --git a/stratosphere/libstratosphere/include/stratosphere/cfg/cfg_api.hpp b/stratosphere/libstratosphere/include/stratosphere/cfg/cfg_api.hpp deleted file mode 100644 index e111164a8..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/cfg/cfg_api.hpp +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -#pragma once -#include "cfg_types.hpp" -#include "cfg_locale_types.hpp" -#include "../sm/sm_types.hpp" - -namespace ams::cfg { - - /* Privileged Process configuration. */ - bool IsInitialProcess(); - void GetInitialProcessRange(os::ProcessId *out_min, os::ProcessId *out_max); - - /* SD card configuration. */ - bool IsSdCardRequiredServicesReady(); - void WaitSdCardRequiredServicesReady(); - bool IsSdCardInitialized(); - void WaitSdCardInitialized(); - - /* Override key utilities. */ - OverrideStatus CaptureOverrideStatus(ncm::ProgramId program_id); - - /* Locale utilities. */ - OverrideLocale GetOverrideLocale(ncm::ProgramId program_id); - - /* Flag utilities. */ - bool HasFlag(const sm::MitmProcessInfo &process_info, const char *flag); - bool HasContentSpecificFlag(ncm::ProgramId program_id, const char *flag); - bool HasGlobalFlag(const char *flag); - - /* HBL Configuration utilities. */ - bool IsHblProgramId(ncm::ProgramId program_id); - bool HasHblFlag(const char *flag); - const char *GetHblPath(); - -} diff --git a/stratosphere/libstratosphere/include/stratosphere/cfg/cfg_locale_types.hpp b/stratosphere/libstratosphere/include/stratosphere/cfg/cfg_locale_types.hpp deleted file mode 100644 index d281c6cfa..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/cfg/cfg_locale_types.hpp +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -#pragma once -#include "cfg_types.hpp" -#include "../settings/settings_types.hpp" - -namespace ams::cfg { - - struct OverrideLocale { - settings::LanguageCode language_code; - settings::RegionCode region_code; - }; - -} diff --git a/stratosphere/libstratosphere/include/stratosphere/cfg/cfg_types.hpp b/stratosphere/libstratosphere/include/stratosphere/cfg/cfg_types.hpp deleted file mode 100644 index 71cf7e20a..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/cfg/cfg_types.hpp +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include "../os/os_common_types.hpp" -#include "../ncm/ncm_types.hpp" - -namespace ams::cfg { - - namespace impl { - - enum OverrideStatusFlag : u64 { - OverrideStatusFlag_Hbl = BIT(0), - OverrideStatusFlag_ProgramSpecific = BIT(1), - OverrideStatusFlag_CheatEnabled = BIT(2), - }; - - } - - struct OverrideStatus { - u64 keys_held; - u64 flags; - - constexpr inline u64 GetKeysHeld() const { return this->keys_held; } - - #define DEFINE_FLAG_ACCESSORS(flag) \ - constexpr inline bool Is##flag() const { return this->flags & impl::OverrideStatusFlag_##flag; } \ - constexpr inline void Set##flag() { this->flags |= impl::OverrideStatusFlag_##flag; } \ - constexpr inline void Clear##flag() { this->flags &= ~u64(impl::OverrideStatusFlag_##flag); } - - DEFINE_FLAG_ACCESSORS(Hbl) - DEFINE_FLAG_ACCESSORS(ProgramSpecific) - DEFINE_FLAG_ACCESSORS(CheatEnabled) - - #undef DEFINE_FLAG_ACCESSORS - }; - - static_assert(sizeof(OverrideStatus) == 0x10, "sizeof(OverrideStatus)"); - static_assert(std::is_pod::value, "std::is_pod::value"); - - constexpr inline bool operator==(const OverrideStatus &lhs, const OverrideStatus &rhs) { - return std::memcmp(&lhs, &rhs, sizeof(lhs)) == 0; - } - - constexpr inline bool operator!=(const OverrideStatus &lhs, const OverrideStatus &rhs) { - return !(lhs == rhs); - } - -} diff --git a/stratosphere/libstratosphere/include/stratosphere/dd.hpp b/stratosphere/libstratosphere/include/stratosphere/dd.hpp deleted file mode 100644 index d82cd8740..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/dd.hpp +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once - -#include "dd/dd_io_mappings.hpp" -#include "dd/dd_process_handle.hpp" diff --git a/stratosphere/libstratosphere/include/stratosphere/dd/dd_io_mappings.hpp b/stratosphere/libstratosphere/include/stratosphere/dd/dd_io_mappings.hpp deleted file mode 100644 index 22f3db412..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/dd/dd_io_mappings.hpp +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include - -namespace ams::dd { - - uintptr_t QueryIoMapping(uintptr_t phys_addr, size_t size); - - u32 ReadRegister(uintptr_t phys_addr); - void WriteRegister(uintptr_t phys_addr, u32 value); - u32 ReadWriteRegister(uintptr_t phys_addr, u32 value, u32 mask); - - /* Convenience Helper. */ - - inline uintptr_t GetIoMapping(uintptr_t phys_addr, size_t size) { - const uintptr_t io_mapping = QueryIoMapping(phys_addr, size); - AMS_ASSERT(io_mapping); - return io_mapping; - } - -} diff --git a/stratosphere/libstratosphere/include/stratosphere/dd/dd_process_handle.hpp b/stratosphere/libstratosphere/include/stratosphere/dd/dd_process_handle.hpp deleted file mode 100644 index a3e7f8c04..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/dd/dd_process_handle.hpp +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include - -namespace ams::dd { - - ::Handle GetCurrentProcessHandle(); - -} diff --git a/stratosphere/libstratosphere/include/stratosphere/dmnt.hpp b/stratosphere/libstratosphere/include/stratosphere/dmnt.hpp deleted file mode 100644 index a0d421b4b..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/dmnt.hpp +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once - -#include "dmnt/dmnt_cheat_types.hpp" diff --git a/stratosphere/libstratosphere/include/stratosphere/dmnt/dmnt_cheat_types.hpp b/stratosphere/libstratosphere/include/stratosphere/dmnt/dmnt_cheat_types.hpp deleted file mode 100644 index 82062af91..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/dmnt/dmnt_cheat_types.hpp +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include "../os/os_common_types.hpp" -#include "../ncm/ncm_types.hpp" -#include "../sf/sf_buffer_tags.hpp" - -namespace ams::dmnt::cheat { - - struct CheatProcessMetadata { - struct MemoryRegionExtents { - u64 base; - u64 size; - }; - - os::ProcessId process_id; - ncm::ProgramId program_id; - MemoryRegionExtents main_nso_extents; - MemoryRegionExtents heap_extents; - MemoryRegionExtents alias_extents; - MemoryRegionExtents aslr_extents; - u8 main_nso_build_id[0x20]; - }; - - static_assert(std::is_pod::value && sizeof(CheatProcessMetadata) == 0x70, "CheatProcessMetadata definition!"); - - struct CheatDefinition : sf::LargeData, sf::PrefersMapAliasTransferMode { - char readable_name[0x40]; - uint32_t num_opcodes; - uint32_t opcodes[0x100]; - }; - - struct CheatEntry : sf::LargeData, sf::PrefersMapAliasTransferMode { - bool enabled; - uint32_t cheat_id; - CheatDefinition definition; - }; - - static_assert(std::is_pod::value, "CheatDefinition"); - static_assert(std::is_pod::value, "CheatEntry"); - - struct FrozenAddressValue { - u64 value; - u8 width; - }; - - struct FrozenAddressEntry { - u64 address; - FrozenAddressValue value; - }; - -} diff --git a/stratosphere/libstratosphere/include/stratosphere/fatal.hpp b/stratosphere/libstratosphere/include/stratosphere/fatal.hpp deleted file mode 100644 index de81dacf3..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/fatal.hpp +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once - -#include "fatal/fatal_types.hpp" diff --git a/stratosphere/libstratosphere/include/stratosphere/fatal/fatal_types.hpp b/stratosphere/libstratosphere/include/stratosphere/fatal/fatal_types.hpp deleted file mode 100644 index cec496a75..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/fatal/fatal_types.hpp +++ /dev/null @@ -1,348 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include -#include "../ncm/ncm_types.hpp" -#include "../sf/sf_buffer_tags.hpp" - -namespace ams::fatal { - - namespace aarch64 { - - enum RegisterName { - RegisterName_X0 = 0, - RegisterName_X1 = 1, - RegisterName_X2 = 2, - RegisterName_X3 = 3, - RegisterName_X4 = 4, - RegisterName_X5 = 5, - RegisterName_X6 = 6, - RegisterName_X7 = 7, - RegisterName_X8 = 8, - RegisterName_X9 = 9, - RegisterName_X10 = 10, - RegisterName_X11 = 11, - RegisterName_X12 = 12, - RegisterName_X13 = 13, - RegisterName_X14 = 14, - RegisterName_X15 = 15, - RegisterName_X16 = 16, - RegisterName_X17 = 17, - RegisterName_X18 = 18, - RegisterName_X19 = 19, - RegisterName_X20 = 20, - RegisterName_X21 = 21, - RegisterName_X22 = 22, - RegisterName_X23 = 23, - RegisterName_X24 = 24, - RegisterName_X25 = 25, - RegisterName_X26 = 26, - RegisterName_X27 = 27, - RegisterName_X28 = 28, - RegisterName_FP = 29, - RegisterName_LR = 30, - - RegisterName_SP = 31, - RegisterName_PC = 32, - - RegisterName_GeneralPurposeCount, - - RegisterName_PState = 33, - RegisterName_Afsr0 = 34, - RegisterName_Afsr1 = 35, - RegisterName_Esr = 36, - RegisterName_Far = 37, - - RegisterName_Count, - }; - - struct CpuContext { - using RegisterType = u64; - static constexpr size_t MaxStackTraceDepth = 0x20; - - static constexpr const char *RegisterNameStrings[RegisterName_Count] = { - u8"X0", - u8"X1", - u8"X2", - u8"X3", - u8"X4", - u8"X5", - u8"X6", - u8"X7", - u8"X8", - u8"X9", - u8"X10", - u8"X11", - u8"X12", - u8"X13", - u8"X14", - u8"X15", - u8"X16", - u8"X17", - u8"X18", - u8"X19", - u8"X20", - u8"X21", - u8"X22", - u8"X23", - u8"X24", - u8"X25", - u8"X26", - u8"X27", - u8"X28", - u8"FP", - u8"LR", - u8"SP", - u8"PC", - u8"PState", - u8"Afsr0", - u8"Afsr1", - u8"Esr", - u8"Far", - }; - - /* Registers, exception context. N left names for these fields in fatal .rodata. */ - union { - struct { - union { - RegisterType x[RegisterName_GeneralPurposeCount]; - struct { - RegisterType _x[RegisterName_FP]; - RegisterType fp; - RegisterType lr; - RegisterType sp; - RegisterType pc; - }; - }; - RegisterType pstate; - RegisterType afsr0; - RegisterType afsr1; - RegisterType esr; - RegisterType far; - }; - RegisterType registers[RegisterName_Count]; - }; - - /* Misc. */ - RegisterType stack_trace[MaxStackTraceDepth]; - RegisterType base_address; - RegisterType register_set_flags; - u32 stack_trace_size; - - void ClearState() { - std::memset(this, 0, sizeof(*this)); - } - - void SetProgramIdForAtmosphere(ncm::ProgramId program_id) { - /* Right now, we mux program ID in through afsr when creport. */ - /* TODO: Better way to do this? */ - this->afsr0 = static_cast(program_id); - } - - ncm::ProgramId GetProgramIdForAtmosphere() const { - return ncm::ProgramId{this->afsr0}; - } - - void SetRegisterValue(RegisterName name, RegisterType value) { - this->registers[name] = value; - this->register_set_flags |= (RegisterType(1) << name); - } - - bool HasRegisterValue(RegisterName name) const { - return this->register_set_flags & (RegisterType(1) << name); - } - - void SetBaseAddress(RegisterType base_addr) { - this->base_address = base_addr; - } - }; - - } - - namespace aarch32 { - - enum RegisterName { - RegisterName_R0 = 0, - RegisterName_R1 = 1, - RegisterName_R2 = 2, - RegisterName_R3 = 3, - RegisterName_R4 = 4, - RegisterName_R5 = 5, - RegisterName_R6 = 6, - RegisterName_R7 = 7, - RegisterName_R8 = 8, - RegisterName_R9 = 9, - RegisterName_R10 = 10, - RegisterName_FP = 11, - RegisterName_IP = 12, - RegisterName_LR = 13, - RegisterName_SP = 14, - RegisterName_PC = 15, - - RegisterName_GeneralPurposeCount, - - RegisterName_PState = 16, - RegisterName_Afsr0 = 17, - RegisterName_Afsr1 = 18, - RegisterName_Esr = 29, - RegisterName_Far = 20, - - RegisterName_Count, - }; - - struct CpuContext { - using RegisterType = u32; - static constexpr size_t MaxStackTraceDepth = 0x20; - - static constexpr const char *RegisterNameStrings[RegisterName_Count] = { - u8"R0", - u8"R1", - u8"R2", - u8"R3", - u8"R4", - u8"R5", - u8"R6", - u8"R7", - u8"R8", - u8"R9", - u8"R10", - u8"FP", - u8"IP", - u8"LR", - u8"SP", - u8"PC", - u8"PState", - u8"Afsr0", - u8"Afsr1", - u8"Esr", - u8"Far", - }; - - /* Registers, exception context. N left names for these fields in fatal .rodata. */ - union { - struct { - union { - RegisterType r[RegisterName_GeneralPurposeCount]; - struct { - RegisterType _x[RegisterName_FP]; - RegisterType fp; - RegisterType ip; - RegisterType lr; - RegisterType sp; - RegisterType pc; - }; - }; - RegisterType pstate; - RegisterType afsr0; - RegisterType afsr1; - RegisterType esr; - RegisterType far; - }; - RegisterType registers[RegisterName_Count]; - }; - - /* Misc. Yes, stack_trace_size is really laid out differently than aarch64... */ - RegisterType stack_trace[MaxStackTraceDepth]; - u32 stack_trace_size; - RegisterType base_address; - RegisterType register_set_flags; - - void ClearState() { - std::memset(this, 0, sizeof(*this)); - } - - void SetProgramIdForAtmosphere(ncm::ProgramId program_id) { - /* Right now, we mux program ID in through afsr when creport. */ - /* TODO: Better way to do this? */ - this->afsr0 = static_cast(static_cast(program_id) >> 0); - this->afsr1 = static_cast(static_cast(program_id) >> 32); - } - - ncm::ProgramId GetProgramIdForAtmosphere() const { - return ncm::ProgramId{(static_cast(this->afsr1) << 32ul) | (static_cast(this->afsr0) << 0ul)}; - } - - void SetRegisterValue(RegisterName name, RegisterType value) { - this->registers[name] = value; - this->register_set_flags |= (RegisterType(1) << name); - } - - bool HasRegisterValue(RegisterName name) const { - return this->register_set_flags & (RegisterType(1) << name); - } - - void SetBaseAddress(RegisterType base_addr) { - this->base_address = base_addr; - } - }; - - } - - struct CpuContext : sf::LargeData, sf::PrefersMapAliasTransferMode { - enum Architecture { - Architecture_Aarch64 = 0, - Architecture_Aarch32 = 1, - }; - - union { - aarch64::CpuContext aarch64_ctx; - aarch32::CpuContext aarch32_ctx; - }; - - Architecture architecture; - u32 type; - - void ClearState() { - std::memset(this, 0, sizeof(*this)); - } - }; - - static_assert(std::is_pod::value && sizeof(aarch64::CpuContext) == 0x248, "aarch64::CpuContext definition!"); - static_assert(std::is_pod::value && sizeof(aarch32::CpuContext) == 0xE0, "aarch32::CpuContext definition!"); - static_assert(std::is_pod::value && sizeof(CpuContext) == 0x250, "CpuContext definition!"); - - namespace srv { - - struct ThrowContext { - Result result; - ncm::ProgramId program_id; - char proc_name[0xD]; - bool is_creport; - CpuContext cpu_ctx; - bool generate_error_report; - Event erpt_event; - Event battery_event; - size_t stack_dump_size; - u8 stack_dump[0x100]; - - void ClearState() { - this->result = ResultSuccess(); - this->program_id = ncm::ProgramId::Invalid; - std::memset(this->proc_name, 0, sizeof(this->proc_name)); - this->is_creport = false; - std::memset(&this->cpu_ctx, 0, sizeof(this->cpu_ctx)); - this->generate_error_report = false; - std::memset(&this->erpt_event, 0, sizeof(this->erpt_event)); - std::memset(&this->battery_event, 0, sizeof(this->battery_event)); - this->stack_dump_size = 0; - std::memset(this->stack_dump, 0, sizeof(this->stack_dump)); - } - }; - - } - -} diff --git a/stratosphere/libstratosphere/include/stratosphere/fs.hpp b/stratosphere/libstratosphere/include/stratosphere/fs.hpp deleted file mode 100644 index 2e417f1a4..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/fs.hpp +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include "fs/fs_common.hpp" -#include "fs/fsa/fs_ifile.hpp" -#include "fs/fsa/fs_idirectory.hpp" -#include "fs/fsa/fs_ifilesystem.hpp" -#include "fs/fs_remote_filesystem.hpp" -#include "fs/fs_istorage.hpp" -#include "fs/fs_remote_storage.hpp" -#include "fs/fs_file_storage.hpp" -#include "fs/fs_query_range.hpp" -#include "fs/fs_path_tool.hpp" -#include "fs/fs_path_utils.hpp" diff --git a/stratosphere/libstratosphere/include/stratosphere/fs/fs_common.hpp b/stratosphere/libstratosphere/include/stratosphere/fs/fs_common.hpp deleted file mode 100644 index 7e0eaa651..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/fs/fs_common.hpp +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -#pragma once -#include -#include "../os.hpp" -#include "../ncm.hpp" -#include "../sf.hpp" - -namespace ams::fs { - - /* TODO: Better place for this? */ - constexpr inline size_t MountNameLengthMax = 15; - -} diff --git a/stratosphere/libstratosphere/include/stratosphere/fs/fs_directory.hpp b/stratosphere/libstratosphere/include/stratosphere/fs/fs_directory.hpp deleted file mode 100644 index 723f0c9f9..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/fs/fs_directory.hpp +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -#pragma once -#include "fs_common.hpp" - -namespace ams::fs { - - constexpr inline size_t EntryNameLengthMax = 0x300; - - using DirectoryEntry = ::FsDirectoryEntry; - -} diff --git a/stratosphere/libstratosphere/include/stratosphere/fs/fs_file.hpp b/stratosphere/libstratosphere/include/stratosphere/fs/fs_file.hpp deleted file mode 100644 index f7872f512..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/fs/fs_file.hpp +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -#pragma once -#include "fs_common.hpp" - -namespace ams::fs { - - struct ReadOption { - u32 value; - - static const ReadOption None; - }; - - inline constexpr const ReadOption ReadOption::None = {FsReadOption_None}; - - inline constexpr bool operator==(const ReadOption &lhs, const ReadOption &rhs) { - return lhs.value == rhs.value; - } - - inline constexpr bool operator!=(const ReadOption &lhs, const ReadOption &rhs) { - return !(lhs == rhs); - } - - static_assert(std::is_pod::value && sizeof(ReadOption) == sizeof(u32)); - - struct WriteOption { - u32 value; - - constexpr inline bool HasFlushFlag() const { - return this->value & FsWriteOption_Flush; - } - - static const WriteOption None; - static const WriteOption Flush; - }; - - inline constexpr const WriteOption WriteOption::None = {FsWriteOption_None}; - inline constexpr const WriteOption WriteOption::Flush = {FsWriteOption_Flush}; - - inline constexpr bool operator==(const WriteOption &lhs, const WriteOption &rhs) { - return lhs.value == rhs.value; - } - - inline constexpr bool operator!=(const WriteOption &lhs, const WriteOption &rhs) { - return !(lhs == rhs); - } - - static_assert(std::is_pod::value && sizeof(WriteOption) == sizeof(u32)); - -} diff --git a/stratosphere/libstratosphere/include/stratosphere/fs/fs_file_storage.hpp b/stratosphere/libstratosphere/include/stratosphere/fs/fs_file_storage.hpp deleted file mode 100644 index 892d3d3b4..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/fs/fs_file_storage.hpp +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -#pragma once -#include "fs_common.hpp" -#include "fs_istorage.hpp" -#include "fsa/fs_ifile.hpp" - -namespace ams::fs { - - class FileStorage : public IStorage { - private: - static constexpr s64 InvalidSize = -1; - private: - std::unique_ptr unique_file; - std::shared_ptr shared_file; - fsa::IFile *base_file; - s64 size; - public: - FileStorage(fsa::IFile *f) : unique_file(f), size(InvalidSize) { - this->base_file = this->unique_file.get(); - } - - FileStorage(std::unique_ptr f) : unique_file(std::move(f)), size(InvalidSize) { - this->base_file = this->unique_file.get(); - } - - FileStorage(std::shared_ptr f) : shared_file(f), size(InvalidSize) { - this->base_file = this->shared_file.get(); - } - - virtual ~FileStorage() { /* ... */ } - protected: - Result UpdateSize(); - public: - 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 GetSize(s64 *out_size) override; - virtual Result SetSize(s64 size) override; - virtual Result OperateRange(void *dst, size_t dst_size, OperationId op_id, s64 offset, s64 size, const void *src, size_t src_size) override; - }; - -} diff --git a/stratosphere/libstratosphere/include/stratosphere/fs/fs_filesystem.hpp b/stratosphere/libstratosphere/include/stratosphere/fs/fs_filesystem.hpp deleted file mode 100644 index e905d3743..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/fs/fs_filesystem.hpp +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -#pragma once -#include "fs_common.hpp" - -namespace ams::fs { - - enum OpenMode { - OpenMode_Read = ::FsOpenMode_Read, - OpenMode_Write = ::FsOpenMode_Write, - OpenMode_Append = ::FsOpenMode_Append, - - OpenMode_ReadWrite = (OpenMode_Read | OpenMode_Write), - OpenMode_All = (OpenMode_ReadWrite | OpenMode_Append), - }; - - enum OpenDirectoryMode { - OpenDirectoryMode_Directory = ::FsDirOpenMode_ReadDirs, - OpenDirectoryMode_File = ::FsDirOpenMode_ReadFiles, - - OpenDirectoryMode_All = (OpenDirectoryMode_Directory | OpenDirectoryMode_File), - - /* TODO: Separate enum, like N? */ - OpenDirectoryMode_NotRequireFileSize = ::FsDirOpenMode_NoFileSize, - }; - - enum DirectoryEntryType { - DirectoryEntryType_Directory = ::FsDirEntryType_Dir, - DirectoryEntryType_File = ::FsDirEntryType_File, - }; - - enum CreateOption { - CreateOption_None = 0, - CreateOption_BigFile = ::FsCreateOption_BigFile, - }; - - using FileTimeStampRaw = ::FsTimeStampRaw; - -} diff --git a/stratosphere/libstratosphere/include/stratosphere/fs/fs_istorage.hpp b/stratosphere/libstratosphere/include/stratosphere/fs/fs_istorage.hpp deleted file mode 100644 index 8a462582f..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/fs/fs_istorage.hpp +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -#pragma once -#include "fs_common.hpp" -#include "fs_file.hpp" -#include "fs_operate_range.hpp" - -namespace ams::fs { - - class IStorage { - public: - virtual ~IStorage() { /* ... */ } - - virtual Result Read(s64 offset, void *buffer, size_t size) = 0; - - virtual Result Write(s64 offset, const void *buffer, size_t size) { - return fs::ResultUnsupportedOperation(); - } - - virtual Result Flush() = 0; - - virtual Result SetSize(s64 size) { - return fs::ResultUnsupportedOperation(); - } - - virtual Result GetSize(s64 *out) = 0; - - virtual Result OperateRange(void *dst, size_t dst_size, OperationId op_id, s64 offset, s64 size, const void *src, size_t src_size) { - return fs::ResultUnsupportedOperation(); - } - - virtual Result OperateRange(OperationId op_id, s64 offset, s64 size) { - return this->OperateRange(nullptr, 0, op_id, offset, size, nullptr, 0); - } - public: - static inline bool IsRangeValid(s64 offset, s64 size, s64 total_size) { - return offset >= 0 && - size >= 0 && - size <= total_size && - offset <= (total_size - size); - } - - static inline bool IsRangeValid(s64 offset, size_t size, s64 total_size) { - return IsRangeValid(offset, static_cast(size), total_size); - } - - static inline bool IsOffsetAndSizeValid(s64 offset, s64 size) { - return offset >= 0 && - size >= 0 && - offset <= (offset + size); - } - - static inline bool IsOffsetAndSizeValid(s64 offset, size_t size) { - return IsOffsetAndSizeValid(offset, static_cast(size)); - } - }; - - class ReadOnlyStorageAdapter : public IStorage { - private: - std::shared_ptr shared_storage; - std::unique_ptr unique_storage; - IStorage *storage; - public: - ReadOnlyStorageAdapter(IStorage *s) : unique_storage(s) { - this->storage = this->unique_storage.get(); - } - ReadOnlyStorageAdapter(std::shared_ptr s) : shared_storage(s) { - this->storage = this->shared_storage.get(); - } - ReadOnlyStorageAdapter(std::unique_ptr s) : unique_storage(std::move(s)) { - this->storage = this->unique_storage.get(); - } - - virtual ~ReadOnlyStorageAdapter() { /* ... */ } - public: - virtual Result Read(s64 offset, void *buffer, size_t size) { - return this->storage->Read(offset, buffer, size); - } - - virtual Result Flush() { - return this->storage->Flush(); - } - - virtual Result GetSize(s64 *out) { - return this->storage->GetSize(out); - } - - virtual Result OperateRange(void *dst, size_t dst_size, OperationId op_id, s64 offset, s64 size, const void *src, size_t src_size) override { - return this->storage->OperateRange(dst, dst_size, op_id, offset, size, src, src_size); - } - }; - -} diff --git a/stratosphere/libstratosphere/include/stratosphere/fs/fs_operate_range.hpp b/stratosphere/libstratosphere/include/stratosphere/fs/fs_operate_range.hpp deleted file mode 100644 index 3896da2e2..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/fs/fs_operate_range.hpp +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -#pragma once -#include "fs_common.hpp" - -namespace ams::fs { - - enum class OperationId : u64 { - Clear = ::FsOperationId_Clear, - ClearSignature = ::FsOperationId_ClearSignature, - InvalidateCache = ::FsOperationId_InvalidateCache, - QueryRange = ::FsOperationId_QueryRange, - }; - -} diff --git a/stratosphere/libstratosphere/include/stratosphere/fs/fs_path_tool.hpp b/stratosphere/libstratosphere/include/stratosphere/fs/fs_path_tool.hpp deleted file mode 100644 index 3143ca65d..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/fs/fs_path_tool.hpp +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -#pragma once -#include "fs_common.hpp" -#include "../fssrv/fssrv_sf_path.hpp" - -namespace ams::fs { - - namespace StringTraits { - - constexpr inline char DirectorySeparator = '/'; - constexpr inline char DriveSeparator = ':'; - constexpr inline char Dot = '.'; - constexpr inline char NullTerminator = '\x00'; - - } - - class PathTool { - public: - static constexpr const char RootPath[] = "/"; - public: - static constexpr inline bool IsSeparator(char c) { - return c == StringTraits::DirectorySeparator; - } - - static constexpr inline bool IsNullTerminator(char c) { - return c == StringTraits::NullTerminator; - } - - static constexpr inline bool IsDot(char c) { - return c == StringTraits::Dot; - } - - static constexpr inline bool IsWindowsDriveCharacter(char c) { - return ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z'); - } - - static constexpr inline bool IsDriveSeparator(char c) { - return c == StringTraits::DriveSeparator; - } - - static constexpr inline bool IsWindowsAbsolutePath(const char *p) { - return IsWindowsDriveCharacter(p[0]) && IsDriveSeparator(p[1]); - } - - static constexpr inline bool IsCurrentDirectory(const char *p) { - return IsDot(p[0]) && (IsSeparator(p[1]) || IsNullTerminator(p[1])); - } - - static constexpr inline bool IsParentDirectory(const char *p) { - return IsDot(p[0]) && IsDot(p[1]) && (IsSeparator(p[2]) || IsNullTerminator(p[2])); - } - - static Result Normalize(char *out, size_t *out_len, const char *src, size_t max_out_size, bool unc_preserved = false); - static Result IsNormalized(bool *out, const char *path); - - static bool IsSubPath(const char *lhs, const char *rhs); - }; - -} diff --git a/stratosphere/libstratosphere/include/stratosphere/fs/fs_path_utils.hpp b/stratosphere/libstratosphere/include/stratosphere/fs/fs_path_utils.hpp deleted file mode 100644 index f4598eb9d..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/fs/fs_path_utils.hpp +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -#pragma once -#include "fs_common.hpp" -#include "../fssrv/fssrv_sf_path.hpp" - -namespace ams::fs { - - inline void Replace(char *dst, size_t dst_size, char old_char, char new_char) { - for (char *cur = dst; cur < dst + dst_size && *cur != '\x00'; cur++) { - if (*cur == old_char) { - *cur = new_char; - } - } - } - - inline Result FspPathPrintf(fssrv::sf::FspPath *dst, const char *format, ...) { - /* Format the path. */ - std::va_list va_list; - va_start(va_list, format); - const size_t len = std::vsnprintf(dst->str, sizeof(dst->str), format, va_list); - va_end(va_list); - - /* Validate length. */ - R_UNLESS(len < sizeof(dst->str), fs::ResultTooLongPath()); - - /* Fix slashes. */ - Replace(dst->str, sizeof(dst->str) - 1, '\\', '/'); - - return ResultSuccess(); - } - - Result VerifyPath(const char *path, size_t max_path_len, size_t max_name_len); - -} diff --git a/stratosphere/libstratosphere/include/stratosphere/fs/fs_query_range.hpp b/stratosphere/libstratosphere/include/stratosphere/fs/fs_query_range.hpp deleted file mode 100644 index 9bab0e67d..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/fs/fs_query_range.hpp +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -#pragma once -#include "fs_common.hpp" - -namespace ams::fs { - - struct QueryRangeInfo { - u32 aes_ctr_key_type; - u32 speed_emulation_type; - u32 reserved[0x38 / sizeof(u32)]; - - void Clear() { - this->aes_ctr_key_type = 0; - this->speed_emulation_type = 0; - std::memset(this->reserved, 0, sizeof(this->reserved)); - } - - void Merge(const QueryRangeInfo &rhs) { - this->aes_ctr_key_type |= rhs.aes_ctr_key_type; - this->speed_emulation_type |= rhs.speed_emulation_type; - } - }; - - static_assert(std::is_pod::value); - static_assert(sizeof(QueryRangeInfo) == 0x40); - static_assert(sizeof(QueryRangeInfo) == sizeof(::FsRangeInfo)); - - using FileQueryRangeInfo = QueryRangeInfo; - using StorageQueryRangeInfo = QueryRangeInfo; - -} diff --git a/stratosphere/libstratosphere/include/stratosphere/fs/fs_remote_filesystem.hpp b/stratosphere/libstratosphere/include/stratosphere/fs/fs_remote_filesystem.hpp deleted file mode 100644 index c5b2942f9..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/fs/fs_remote_filesystem.hpp +++ /dev/null @@ -1,179 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -#pragma once -#include "fs_common.hpp" -#include "fsa/fs_ifile.hpp" -#include "fsa/fs_idirectory.hpp" -#include "fsa/fs_ifilesystem.hpp" - -namespace ams::fs { - - class RemoteFile : public fsa::IFile { - private: - std::unique_ptr<::FsFile> base_file; - public: - RemoteFile(::FsFile *f) : base_file(f) { /* ... */ } - RemoteFile(std::unique_ptr<::FsFile> f) : base_file(std::move(f)) { /* ... */ } - RemoteFile(::FsFile f) { - this->base_file = std::make_unique<::FsFile>(f); - } - - virtual ~RemoteFile() { fsFileClose(this->base_file.get()); } - public: - virtual Result ReadImpl(size_t *out, s64 offset, void *buffer, size_t size, const fs::ReadOption &option) override final { - return fsFileRead(this->base_file.get(), offset, buffer, size, option.value, out); - } - - virtual Result GetSizeImpl(s64 *out) override final { - return fsFileGetSize(this->base_file.get(), out); - } - - virtual Result FlushImpl() override final { - return fsFileFlush(this->base_file.get()); - } - - virtual Result WriteImpl(s64 offset, const void *buffer, size_t size, const fs::WriteOption &option) override final { - return fsFileWrite(this->base_file.get(), offset, buffer, size, option.value); - } - - virtual Result SetSizeImpl(s64 size) override final { - return fsFileSetSize(this->base_file.get(), size); - } - - virtual Result OperateRangeImpl(void *dst, size_t dst_size, fs::OperationId op_id, s64 offset, s64 size, const void *src, size_t src_size) override final { - /* TODO: How should this be handled? */ - return fs::ResultNotImplemented(); - } - public: - virtual sf::cmif::DomainObjectId GetDomainObjectId() const override { - return sf::cmif::DomainObjectId{serviceGetObjectId(&this->base_file->s)}; - } - }; - - class RemoteDirectory : public fsa::IDirectory { - private: - std::unique_ptr<::FsDir> base_dir; - public: - RemoteDirectory(::FsDir *d) : base_dir(d) { /* ... */ } - RemoteDirectory(std::unique_ptr<::FsDir> d) : base_dir(std::move(d)) { /* ... */ } - RemoteDirectory(::FsDir d) { - this->base_dir = std::make_unique<::FsDir>(d); - } - - virtual ~RemoteDirectory() { fsDirClose(this->base_dir.get()); } - public: - virtual Result ReadImpl(s64 *out_count, DirectoryEntry *out_entries, s64 max_entries) override final { - return fsDirRead(this->base_dir.get(), out_count, max_entries, out_entries); - } - - virtual Result GetEntryCountImpl(s64 *out) override final { - return fsDirGetEntryCount(this->base_dir.get(), out); - } - public: - virtual sf::cmif::DomainObjectId GetDomainObjectId() const override { - return sf::cmif::DomainObjectId{serviceGetObjectId(&this->base_dir->s)}; - } - }; - - class RemoteFileSystem : public fsa::IFileSystem { - private: - std::unique_ptr<::FsFileSystem> base_fs; - public: - RemoteFileSystem(::FsFileSystem *fs) : base_fs(fs) { /* ... */ } - RemoteFileSystem(std::unique_ptr<::FsFileSystem> fs) : base_fs(std::move(fs)) { /* ... */ } - RemoteFileSystem(::FsFileSystem fs) { - this->base_fs = std::make_unique<::FsFileSystem>(fs); - } - - virtual ~RemoteFileSystem() { fsFsClose(this->base_fs.get()); } - public: - virtual Result CreateFileImpl(const char *path, s64 size, int flags) override final { - return fsFsCreateFile(this->base_fs.get(), path, size, flags); - } - - virtual Result DeleteFileImpl(const char *path) override final { - return fsFsDeleteFile(this->base_fs.get(), path); - } - - virtual Result CreateDirectoryImpl(const char *path) override final { - return fsFsCreateDirectory(this->base_fs.get(), path); - } - - virtual Result DeleteDirectoryImpl(const char *path) override final { - return fsFsDeleteDirectory(this->base_fs.get(), path); - } - - virtual Result DeleteDirectoryRecursivelyImpl(const char *path) override final { - return fsFsDeleteDirectoryRecursively(this->base_fs.get(), path); - } - - virtual Result RenameFileImpl(const char *old_path, const char *new_path) override final { - return fsFsRenameFile(this->base_fs.get(), old_path, new_path); - } - - virtual Result RenameDirectoryImpl(const char *old_path, const char *new_path) override final { - return fsFsRenameDirectory(this->base_fs.get(), old_path, new_path); - } - - virtual Result GetEntryTypeImpl(DirectoryEntryType *out, const char *path) override final { - static_assert(sizeof(::FsDirEntryType) == sizeof(DirectoryEntryType)); - return fsFsGetEntryType(this->base_fs.get(), path, reinterpret_cast<::FsDirEntryType *>(out)); - } - - virtual Result OpenFileImpl(std::unique_ptr *out_file, const char *path, OpenMode mode) override final { - FsFile f; - R_TRY(fsFsOpenFile(this->base_fs.get(), path, mode, &f)); - - *out_file = std::make_unique(f); - return ResultSuccess(); - } - - virtual Result OpenDirectoryImpl(std::unique_ptr *out_dir, const char *path, OpenDirectoryMode mode) override final { - FsDir d; - R_TRY(fsFsOpenDirectory(this->base_fs.get(), path, mode, &d)); - - *out_dir = std::make_unique(d); - return ResultSuccess(); - } - - virtual Result CommitImpl() override final { - return fsFsCommit(this->base_fs.get()); - } - - - virtual Result GetFreeSpaceSizeImpl(s64 *out, const char *path) { - return fsFsGetFreeSpace(this->base_fs.get(), path, out); - } - - virtual Result GetTotalSpaceSizeImpl(s64 *out, const char *path) { - return fsFsGetTotalSpace(this->base_fs.get(), path, out); - } - - virtual Result CleanDirectoryRecursivelyImpl(const char *path) { - return fsFsCleanDirectoryRecursively(this->base_fs.get(), path); - } - - virtual Result GetFileTimeStampRawImpl(FileTimeStampRaw *out, const char *path) { - static_assert(sizeof(FileTimeStampRaw) == sizeof(::FsTimeStampRaw)); - return fsFsGetFileTimeStampRaw(this->base_fs.get(), path, reinterpret_cast<::FsTimeStampRaw *>(out)); - } - - virtual Result QueryEntryImpl(char *dst, size_t dst_size, const char *src, size_t src_size, fsa::QueryId query, const char *path) { - return fsFsQueryEntry(this->base_fs.get(), dst, dst_size, src, src_size, path, static_cast(query)); - } - }; - -} diff --git a/stratosphere/libstratosphere/include/stratosphere/fs/fs_remote_storage.hpp b/stratosphere/libstratosphere/include/stratosphere/fs/fs_remote_storage.hpp deleted file mode 100644 index 2eb580f93..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/fs/fs_remote_storage.hpp +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -#pragma once -#include "fs_common.hpp" -#include "fs_istorage.hpp" - -namespace ams::fs { - - class RemoteStorage : public IStorage { - private: - std::unique_ptr<::FsStorage> base_storage; - public: - RemoteStorage(::FsStorage *s) : base_storage(s) { /* ... */ } - RemoteStorage(std::unique_ptr<::FsStorage> s) : base_storage(std::move(s)) { /* ... */ } - RemoteStorage(::FsStorage s) { - this->base_storage = std::make_unique<::FsStorage>(s); - } - - virtual ~RemoteStorage() { fsStorageClose(this->base_storage.get()); } - public: - virtual Result Read(s64 offset, void *buffer, size_t size) override { - return fsStorageRead(this->base_storage.get(), offset, buffer, size); - }; - - virtual Result Write(s64 offset, const void *buffer, size_t size) override { - return fsStorageWrite(this->base_storage.get(), offset, buffer, size); - }; - - virtual Result Flush() override { - return fsStorageFlush(this->base_storage.get()); - }; - - virtual Result GetSize(s64 *out_size) override { - return fsStorageGetSize(this->base_storage.get(), out_size); - }; - - virtual Result SetSize(s64 size) override { - return fsStorageSetSize(this->base_storage.get(), size); - }; - - virtual Result OperateRange(void *dst, size_t dst_size, OperationId op_id, s64 offset, s64 size, const void *src, size_t src_size) override { - /* TODO: How to deal with this? */ - return fs::ResultUnsupportedOperation(); - }; - }; - -} diff --git a/stratosphere/libstratosphere/include/stratosphere/fs/fsa/fs_idirectory.hpp b/stratosphere/libstratosphere/include/stratosphere/fs/fsa/fs_idirectory.hpp deleted file mode 100644 index 335d7717f..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/fs/fsa/fs_idirectory.hpp +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include "../fs_common.hpp" -#include "../fs_directory.hpp" - -namespace ams::fs::fsa { - - class IDirectory { - public: - virtual ~IDirectory() { /* ... */ } - - Result Read(s64 *out_count, DirectoryEntry *out_entries, s64 max_entries) { - R_UNLESS(out_count != nullptr, fs::ResultNullptrArgument()); - if (max_entries == 0) { - *out_count = 0; - return ResultSuccess(); - } - R_UNLESS(out_entries != nullptr, fs::ResultNullptrArgument()); - R_UNLESS(max_entries > 0, fs::ResultInvalidArgument()); - return this->ReadImpl(out_count, out_entries, max_entries); - } - - Result GetEntryCount(s64 *out) { - R_UNLESS(out != nullptr, fs::ResultNullptrArgument()); - return this->GetEntryCountImpl(out); - } - public: - /* TODO: This is a hack to allow the mitm API to work. Find a better way? */ - virtual sf::cmif::DomainObjectId GetDomainObjectId() const = 0; - protected: - /* ...? */ - private: - virtual Result ReadImpl(s64 *out_count, DirectoryEntry *out_entries, s64 max_entries) = 0; - virtual Result GetEntryCountImpl(s64 *out) = 0; - }; - -} diff --git a/stratosphere/libstratosphere/include/stratosphere/fs/fsa/fs_ifile.hpp b/stratosphere/libstratosphere/include/stratosphere/fs/fsa/fs_ifile.hpp deleted file mode 100644 index 3cafb2769..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/fs/fsa/fs_ifile.hpp +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -#pragma once -#include "../fs_common.hpp" -#include "../fs_file.hpp" -#include "../fs_operate_range.hpp" - -namespace ams::fs::fsa { - - class IFile { - public: - virtual ~IFile() { /* ... */ } - - Result Read(size_t *out, s64 offset, void *buffer, size_t size, const fs::ReadOption &option) { - R_UNLESS(out != nullptr, fs::ResultNullptrArgument()); - if (size == 0) { - *out = 0; - return ResultSuccess(); - } - R_UNLESS(buffer != nullptr, fs::ResultNullptrArgument()); - R_UNLESS(offset >= 0, fs::ResultOutOfRange()); - const s64 signed_size = static_cast(size); - R_UNLESS(signed_size >= 0, fs::ResultOutOfRange()); - R_UNLESS((std::numeric_limits::max() - offset) >= signed_size, fs::ResultOutOfRange()); - return this->ReadImpl(out, offset, buffer, size, option); - } - - Result Read(size_t *out, s64 offset, void *buffer, size_t size) { - return this->Read(out, offset, buffer, size, ReadOption::None); - } - - Result GetSize(s64 *out) { - R_UNLESS(out != nullptr, fs::ResultNullptrArgument()); - return this->GetSizeImpl(out); - } - - Result Flush() { - return this->FlushImpl(); - } - - Result Write(s64 offset, const void *buffer, size_t size, const fs::WriteOption &option) { - if (size == 0) { - if (option.HasFlushFlag()) { - R_TRY(this->Flush()); - } - return ResultSuccess(); - } - R_UNLESS(buffer != nullptr, fs::ResultNullptrArgument()); - R_UNLESS(offset >= 0, fs::ResultOutOfRange()); - const s64 signed_size = static_cast(size); - R_UNLESS(signed_size >= 0, fs::ResultOutOfRange()); - R_UNLESS((std::numeric_limits::max() - offset) >= signed_size, fs::ResultOutOfRange()); - return this->WriteImpl(offset, buffer, size, option); - } - - Result SetSize(s64 size) { - R_UNLESS(size >= 0, fs::ResultOutOfRange()); - return this->SetSizeImpl(size); - } - - Result OperateRange(void *dst, size_t dst_size, fs::OperationId op_id, s64 offset, s64 size, const void *src, size_t src_size) { - return this->OperateRangeImpl(dst, dst_size, op_id, offset, size, src, src_size); - } - - Result OperateRange(fs::OperationId op_id, s64 offset, s64 size) { - return this->OperateRangeImpl(nullptr, 0, op_id, offset, size, nullptr, 0); - } - public: - /* TODO: This is a hack to allow the mitm API to work. Find a better way? */ - virtual sf::cmif::DomainObjectId GetDomainObjectId() const = 0; - protected: - /* ...? */ - private: - virtual Result ReadImpl(size_t *out, s64 offset, void *buffer, size_t size, const fs::ReadOption &option) = 0; - virtual Result GetSizeImpl(s64 *out) = 0; - virtual Result FlushImpl() = 0; - virtual Result WriteImpl(s64 offset, const void *buffer, size_t size, const fs::WriteOption &option) = 0; - virtual Result SetSizeImpl(s64 size) = 0; - virtual Result OperateRangeImpl(void *dst, size_t dst_size, fs::OperationId op_id, s64 offset, s64 size, const void *src, size_t src_size) = 0; - }; - -} diff --git a/stratosphere/libstratosphere/include/stratosphere/fs/fsa/fs_ifilesystem.hpp b/stratosphere/libstratosphere/include/stratosphere/fs/fsa/fs_ifilesystem.hpp deleted file mode 100644 index 815cc159b..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/fs/fsa/fs_ifilesystem.hpp +++ /dev/null @@ -1,191 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include "../fs_common.hpp" -#include "../fs_filesystem.hpp" - -namespace ams::fs::fsa { - - class IFile; - class IDirectory; - - enum class QueryId { - SetConcatenationFileAttribute = FsFileSystemQueryId_SetConcatenationFileAttribute - }; - - class IFileSystem { - public: - virtual ~IFileSystem() { /* ... */ } - - Result CreateFile(const char *path, s64 size, int option) { - R_UNLESS(path != nullptr, fs::ResultInvalidPath()); - R_UNLESS(size >= 0, fs::ResultOutOfRange()); - return this->CreateFileImpl(path, size, option); - } - - Result CreateFile(const char *path, s64 size) { - return this->CreateFile(path, size, 0); - } - - Result DeleteFile(const char *path) { - R_UNLESS(path != nullptr, fs::ResultInvalidPath()); - return this->DeleteFileImpl(path); - } - - Result CreateDirectory(const char *path) { - R_UNLESS(path != nullptr, fs::ResultInvalidPath()); - return this->CreateDirectoryImpl(path); - } - - Result DeleteDirectory(const char *path) { - R_UNLESS(path != nullptr, fs::ResultInvalidPath()); - return this->DeleteDirectoryImpl(path); - } - - Result DeleteDirectoryRecursively(const char *path) { - R_UNLESS(path != nullptr, fs::ResultInvalidPath()); - return this->DeleteDirectoryRecursivelyImpl(path); - } - - Result RenameFile(const char *old_path, const char *new_path) { - R_UNLESS(old_path != nullptr, fs::ResultInvalidPath()); - R_UNLESS(new_path != nullptr, fs::ResultInvalidPath()); - return this->RenameFileImpl(old_path, new_path); - } - - Result RenameDirectory(const char *old_path, const char *new_path) { - R_UNLESS(old_path != nullptr, fs::ResultInvalidPath()); - R_UNLESS(new_path != nullptr, fs::ResultInvalidPath()); - return this->RenameDirectoryImpl(old_path, new_path); - } - - Result GetEntryType(DirectoryEntryType *out, const char *path) { - R_UNLESS(path != nullptr, fs::ResultInvalidPath()); - R_UNLESS(out != nullptr, fs::ResultNullptrArgument()); - return this->GetEntryTypeImpl(out, path); - } - - Result OpenFile(std::unique_ptr *out_file, const char *path, OpenMode mode) { - R_UNLESS(path != nullptr, fs::ResultInvalidPath()); - R_UNLESS(out_file != nullptr, fs::ResultNullptrArgument()); - R_UNLESS((mode & OpenMode_ReadWrite) != 0, fs::ResultInvalidArgument()); - R_UNLESS((mode & ~OpenMode_All) == 0, fs::ResultInvalidArgument()); - return this->OpenFileImpl(out_file, path, mode); - } - - Result OpenDirectory(std::unique_ptr *out_dir, const char *path, OpenDirectoryMode mode) { - R_UNLESS(path != nullptr, fs::ResultInvalidPath()); - R_UNLESS(out_dir != nullptr, fs::ResultNullptrArgument()); - R_UNLESS((mode & OpenDirectoryMode_All) != 0, fs::ResultInvalidArgument()); - R_UNLESS((mode & ~OpenDirectoryMode_All) == 0, fs::ResultInvalidArgument()); - return this->OpenDirectoryImpl(out_dir, path, mode); - } - - Result Commit() { - return this->CommitImpl(); - } - - Result GetFreeSpaceSize(s64 *out, const char *path) { - R_UNLESS(path != nullptr, fs::ResultInvalidPath()); - R_UNLESS(out != nullptr, fs::ResultNullptrArgument()); - return this->GetFreeSpaceSizeImpl(out, path); - } - - Result GetTotalSpaceSize(s64 *out, const char *path) { - R_UNLESS(path != nullptr, fs::ResultInvalidPath()); - R_UNLESS(out != nullptr, fs::ResultNullptrArgument()); - return this->GetTotalSpaceSizeImpl(out, path); - } - - Result CleanDirectoryRecursively(const char *path) { - R_UNLESS(path != nullptr, fs::ResultInvalidPath()); - return this->CleanDirectoryRecursivelyImpl(path); - } - - Result GetFileTimeStampRaw(FileTimeStampRaw *out, const char *path) { - R_UNLESS(path != nullptr, fs::ResultInvalidPath()); - R_UNLESS(out != nullptr, fs::ResultNullptrArgument()); - return this->GetFileTimeStampRawImpl(out, path); - } - - Result QueryEntry(char *dst, size_t dst_size, const char *src, size_t src_size, QueryId query, const char *path) { - R_UNLESS(path != nullptr, fs::ResultInvalidPath()); - return this->QueryEntryImpl(dst, dst_size, src, src_size, query, path); - } - - /* These aren't accessible as commands. */ - - Result CommitProvisionally(s64 counter) { - return this->CommitProvisionallyImpl(counter); - } - - Result Rollback() { - return this->RollbackImpl(); - } - - Result Flush() { - return this->FlushImpl(); - } - - protected: - /* ...? */ - private: - virtual Result CreateFileImpl(const char *path, s64 size, int flags) = 0; - virtual Result DeleteFileImpl(const char *path) = 0; - virtual Result CreateDirectoryImpl(const char *path) = 0; - virtual Result DeleteDirectoryImpl(const char *path) = 0; - virtual Result DeleteDirectoryRecursivelyImpl(const char *path) = 0; - virtual Result RenameFileImpl(const char *old_path, const char *new_path) = 0; - virtual Result RenameDirectoryImpl(const char *old_path, const char *new_path) = 0; - virtual Result GetEntryTypeImpl(fs::DirectoryEntryType *out, const char *path) = 0; - virtual Result OpenFileImpl(std::unique_ptr *out_file, const char *path, fs::OpenMode mode) = 0; - virtual Result OpenDirectoryImpl(std::unique_ptr *out_dir, const char *path, fs::OpenDirectoryMode mode) = 0; - virtual Result CommitImpl() = 0; - - virtual Result GetFreeSpaceSizeImpl(s64 *out, const char *path) { - return fs::ResultNotImplemented(); - } - - virtual Result GetTotalSpaceSizeImpl(s64 *out, const char *path) { - return fs::ResultNotImplemented(); - } - - virtual Result CleanDirectoryRecursivelyImpl(const char *path) = 0; - - virtual Result GetFileTimeStampRawImpl(fs::FileTimeStampRaw *out, const char *path) { - return fs::ResultNotImplemented(); - } - - virtual Result QueryEntryImpl(char *dst, size_t dst_size, const char *src, size_t src_size, fs::fsa::QueryId query, const char *path) { - return fs::ResultNotImplemented(); - } - - /* These aren't accessible as commands. */ - virtual Result CommitProvisionallyImpl(s64 counter) { - return fs::ResultNotImplemented(); - } - - virtual Result RollbackImpl() { - return fs::ResultNotImplemented(); - } - - virtual Result FlushImpl() { - return fs::ResultNotImplemented(); - } - }; - -} diff --git a/stratosphere/libstratosphere/include/stratosphere/fssrv.hpp b/stratosphere/libstratosphere/include/stratosphere/fssrv.hpp deleted file mode 100644 index 3f72bb4a9..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/fssrv.hpp +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include "fssrv/fssrv_sf_path.hpp" -#include "fssrv/fssrv_path_normalizer.hpp" diff --git a/stratosphere/libstratosphere/include/stratosphere/fssrv/fssrv_interface_adapters.hpp b/stratosphere/libstratosphere/include/stratosphere/fssrv/fssrv_interface_adapters.hpp deleted file mode 100644 index 52fbb7180..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/fssrv/fssrv_interface_adapters.hpp +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -#pragma once -#include "interface_adapters/fssrv_storage_interface_adapter.hpp" -#include "interface_adapters/fssrv_filesystem_interface_adapter.hpp" diff --git a/stratosphere/libstratosphere/include/stratosphere/fssrv/fssrv_path_normalizer.hpp b/stratosphere/libstratosphere/include/stratosphere/fssrv/fssrv_path_normalizer.hpp deleted file mode 100644 index 3411d9611..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/fssrv/fssrv_path_normalizer.hpp +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -#pragma once -#include "../fs/fs_common.hpp" - -namespace ams::fssrv { - - /* This is in fssrv::detail in official code. */ - /* TODO: Consider moving to ::impl? */ - - class PathNormalizer { - public: - enum Option : u32 { - Option_None = BIT(0), - Option_PreserveUnc = BIT(1), - Option_PreserveTailSeparator = BIT(2), - Option_HasMountName = BIT(3), - Option_AcceptEmpty = BIT(4), - }; - private: - using Buffer = std::unique_ptr; - private: - Buffer buffer; - const char *path; - Result result; - private: - static Result Normalize(const char **out_path, Buffer *out_buf, const char *path, bool preserve_unc, bool preserve_tail_sep, bool has_mount_name); - public: - explicit PathNormalizer(const char *p) : buffer(), path(nullptr), result(ResultSuccess()) { - this->result = Normalize(&this->path, &this->buffer, p, false, false, false); - } - - PathNormalizer(const char *p, u32 option) : buffer(), path(nullptr), result(ResultSuccess()) { - if ((option & Option_AcceptEmpty) && p[0] == '\x00') { - this->path = path; - } else { - const bool preserve_unc = (option & Option_PreserveUnc); - const bool preserve_tail_sep = (option & Option_PreserveTailSeparator); - const bool has_mount_name = (option & Option_HasMountName); - this->result = Normalize(&this->path, &this->buffer, p, preserve_unc, preserve_tail_sep, has_mount_name); - } - } - - inline Result GetResult() const { - return this->result; - } - - inline const char * GetPath() const { - return this->path; - } - }; - -} diff --git a/stratosphere/libstratosphere/include/stratosphere/fssrv/fssrv_sf_path.hpp b/stratosphere/libstratosphere/include/stratosphere/fssrv/fssrv_sf_path.hpp deleted file mode 100644 index a15c3fa55..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/fssrv/fssrv_sf_path.hpp +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -#pragma once -#include "../fs/fs_common.hpp" -#include "../fs/fs_directory.hpp" -#include "../sf/sf_buffer_tags.hpp" - -namespace ams::fssrv::sf { - - struct Path : ams::sf::LargeData { - char str[fs::EntryNameLengthMax + 1]; - - static constexpr Path Encode(const char *p) { - Path path = {}; - for (size_t i = 0; i < sizeof(path) - 1; i++) { - path.str[i] = p[i]; - if (p[i] == '\x00') { - break; - } - } - return path; - } - - static constexpr size_t GetPathLength(const Path &path) { - size_t len = 0; - for (size_t i = 0; i < sizeof(path) - 1 && path.str[i] != '\x00'; i++) { - len++; - } - return len; - } - }; - - static_assert(std::is_pod::value && sizeof(Path) == FS_MAX_PATH); - - using FspPath = Path; - -} diff --git a/stratosphere/libstratosphere/include/stratosphere/fssrv/interface_adapters/fssrv_filesystem_interface_adapter.hpp b/stratosphere/libstratosphere/include/stratosphere/fssrv/interface_adapters/fssrv_filesystem_interface_adapter.hpp deleted file mode 100644 index 06f7b87f6..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/fssrv/interface_adapters/fssrv_filesystem_interface_adapter.hpp +++ /dev/null @@ -1,192 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -#pragma once -#include "../../fs/fs_common.hpp" -#include "../../fs/fs_file.hpp" -#include "../../fs/fs_directory.hpp" -#include "../../fs/fs_filesystem.hpp" -#include "../../fs/fs_query_range.hpp" -#include "../../fssrv/fssrv_sf_path.hpp" -#include "../../fssystem/fssystem_utility.hpp" - -namespace ams::fs::fsa { - - class IFile; - class IDirectory; - class IFileSystem; - -} - -namespace ams::fssrv::impl { - - class FileSystemInterfaceAdapter; - - class FileInterfaceAdapter final : public ams::sf::IServiceObject { - NON_COPYABLE(FileInterfaceAdapter); - public: - enum class CommandId { - Read = 0, - Write = 1, - Flush = 2, - SetSize = 3, - GetSize = 4, - OperateRange = 5, - }; - private: - std::shared_ptr parent_filesystem; - std::unique_ptr base_file; - std::unique_lock open_count_semaphore; - public: - FileInterfaceAdapter(std::unique_ptr &&file, std::shared_ptr &&parent, std::unique_lock &&sema); - ~FileInterfaceAdapter(); - private: - void InvalidateCache(); - public: - /* Command API. */ - Result Read(ams::sf::Out out, s64 offset, const ams::sf::OutNonSecureBuffer &buffer, s64 size, fs::ReadOption option); - Result Write(s64 offset, const ams::sf::InNonSecureBuffer &buffer, s64 size, fs::WriteOption option); - Result Flush(); - Result SetSize(s64 size); - Result GetSize(ams::sf::Out out); - Result OperateRange(ams::sf::Out out, s32 op_id, s64 offset, s64 size); - public: - DEFINE_SERVICE_DISPATCH_TABLE { - /* 1.0.0- */ - MAKE_SERVICE_COMMAND_META(Read), - MAKE_SERVICE_COMMAND_META(Write), - MAKE_SERVICE_COMMAND_META(Flush), - MAKE_SERVICE_COMMAND_META(SetSize), - MAKE_SERVICE_COMMAND_META(GetSize), - - /* 4.0.0- */ - MAKE_SERVICE_COMMAND_META(OperateRange, hos::Version_400), - }; - }; - - class DirectoryInterfaceAdapter final : public ams::sf::IServiceObject { - NON_COPYABLE(DirectoryInterfaceAdapter); - public: - enum class CommandId { - Read = 0, - GetEntryCount = 1, - }; - private: - std::shared_ptr parent_filesystem; - std::unique_ptr base_dir; - std::unique_lock open_count_semaphore; - public: - DirectoryInterfaceAdapter(std::unique_ptr &&dir, std::shared_ptr &&parent, std::unique_lock &&sema); - ~DirectoryInterfaceAdapter(); - public: - /* Command API */ - Result Read(ams::sf::Out out, const ams::sf::OutBuffer &out_entries); - Result GetEntryCount(ams::sf::Out out); - public: - DEFINE_SERVICE_DISPATCH_TABLE { - MAKE_SERVICE_COMMAND_META(Read), - MAKE_SERVICE_COMMAND_META(GetEntryCount), - }; - }; - - class FileSystemInterfaceAdapter final : public std::enable_shared_from_this, public ams::sf::IServiceObject { - NON_COPYABLE(FileSystemInterfaceAdapter); - public: - enum class CommandId { - /* 1.0.0+ */ - CreateFile = 0, - DeleteFile = 1, - CreateDirectory = 2, - DeleteDirectory = 3, - DeleteDirectoryRecursively = 4, - RenameFile = 5, - RenameDirectory = 6, - GetEntryType = 7, - OpenFile = 8, - OpenDirectory = 9, - Commit = 10, - GetFreeSpaceSize = 11, - GetTotalSpaceSize = 12, - - /* 3.0.0+ */ - CleanDirectoryRecursively = 13, - GetFileTimeStampRaw = 14, - - /* 4.0.0+ */ - QueryEntry = 15, - }; - private: - std::shared_ptr base_fs; - std::unique_lock mount_count_semaphore; - os::ReadWriteLock invalidation_lock; - bool open_count_limited; - bool deep_retry_enabled = false; - public: - FileSystemInterfaceAdapter(std::shared_ptr &&fs, bool open_limited); - /* TODO: Other constructors. */ - - ~FileSystemInterfaceAdapter(); - public: - bool IsDeepRetryEnabled() const; - bool IsAccessFailureDetectionObserved() const; - std::optional> AcquireCacheInvalidationReadLock(); - os::ReadWriteLock &GetReadWriteLockForCacheInvalidation(); - public: - /* Command API. */ - Result CreateFile(const fssrv::sf::Path &path, s64 size, s32 option); - Result DeleteFile(const fssrv::sf::Path &path); - Result CreateDirectory(const fssrv::sf::Path &path); - Result DeleteDirectory(const fssrv::sf::Path &path); - Result DeleteDirectoryRecursively(const fssrv::sf::Path &path); - Result RenameFile(const fssrv::sf::Path &old_path, const fssrv::sf::Path &new_path); - Result RenameDirectory(const fssrv::sf::Path &old_path, const fssrv::sf::Path &new_path); - Result GetEntryType(ams::sf::Out out, const fssrv::sf::Path &path); - Result OpenFile(ams::sf::Out> out, const fssrv::sf::Path &path, u32 mode); - Result OpenDirectory(ams::sf::Out> out, const fssrv::sf::Path &path, u32 mode); - Result Commit(); - Result GetFreeSpaceSize(ams::sf::Out out, const fssrv::sf::Path &path); - Result GetTotalSpaceSize(ams::sf::Out out, const fssrv::sf::Path &path); - - Result CleanDirectoryRecursively(const fssrv::sf::Path &path); - Result GetFileTimeStampRaw(ams::sf::Out out, const fssrv::sf::Path &path); - - Result QueryEntry(const ams::sf::OutBuffer &out_buf, const ams::sf::InBuffer &in_buf, s32 query_id, const fssrv::sf::Path &path); - public: - DEFINE_SERVICE_DISPATCH_TABLE { - /* 1.0.0- */ - MAKE_SERVICE_COMMAND_META(CreateFile), - MAKE_SERVICE_COMMAND_META(DeleteFile), - MAKE_SERVICE_COMMAND_META(CreateDirectory), - MAKE_SERVICE_COMMAND_META(DeleteDirectory), - MAKE_SERVICE_COMMAND_META(DeleteDirectoryRecursively), - MAKE_SERVICE_COMMAND_META(RenameFile), - MAKE_SERVICE_COMMAND_META(RenameDirectory), - MAKE_SERVICE_COMMAND_META(GetEntryType), - MAKE_SERVICE_COMMAND_META(OpenFile), - MAKE_SERVICE_COMMAND_META(OpenDirectory), - MAKE_SERVICE_COMMAND_META(Commit), - MAKE_SERVICE_COMMAND_META(GetFreeSpaceSize), - MAKE_SERVICE_COMMAND_META(GetTotalSpaceSize), - - /* 3.0.0- */ - MAKE_SERVICE_COMMAND_META(CleanDirectoryRecursively, hos::Version_300), - MAKE_SERVICE_COMMAND_META(GetFileTimeStampRaw, hos::Version_300), - - /* 4.0.0- */ - MAKE_SERVICE_COMMAND_META(QueryEntry, hos::Version_400), - }; - }; - -} diff --git a/stratosphere/libstratosphere/include/stratosphere/fssrv/interface_adapters/fssrv_storage_interface_adapter.hpp b/stratosphere/libstratosphere/include/stratosphere/fssrv/interface_adapters/fssrv_storage_interface_adapter.hpp deleted file mode 100644 index dc404085e..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/fssrv/interface_adapters/fssrv_storage_interface_adapter.hpp +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -#pragma once -#include "../../fs/fs_common.hpp" -#include "../../fs/fs_query_range.hpp" -#include "../../fssystem/fssystem_utility.hpp" - -namespace ams::fs { - - class IStorage; - -} - -namespace ams::fssrv::impl { - - class StorageInterfaceAdapter final : public ams::sf::IServiceObject { - NON_COPYABLE(StorageInterfaceAdapter); - public: - enum class CommandId { - Read = 0, - Write = 1, - Flush = 2, - SetSize = 3, - GetSize = 4, - OperateRange = 5, - }; - private: - /* TODO: Nintendo uses fssystem::AsynchronousAccessStorage here. */ - std::shared_ptr base_storage; - std::unique_lock open_count_semaphore; - os::ReadWriteLock invalidation_lock; - /* TODO: DataStorageContext. */ - bool deep_retry_enabled = false; - public: - StorageInterfaceAdapter(fs::IStorage *storage); - StorageInterfaceAdapter(std::unique_ptr storage); - explicit StorageInterfaceAdapter(std::shared_ptr &&storage); - /* TODO: Other constructors. */ - - ~StorageInterfaceAdapter(); - private: - std::optional> AcquireCacheInvalidationReadLock(); - private: - /* Command API. */ - Result Read(s64 offset, const ams::sf::OutNonSecureBuffer &buffer, s64 size); - Result Write(s64 offset, const ams::sf::InNonSecureBuffer &buffer, s64 size); - Result Flush(); - Result SetSize(s64 size); - Result GetSize(ams::sf::Out out); - Result OperateRange(ams::sf::Out out, s32 op_id, s64 offset, s64 size); - public: - DEFINE_SERVICE_DISPATCH_TABLE { - /* 1.0.0- */ - MAKE_SERVICE_COMMAND_META(Read), - MAKE_SERVICE_COMMAND_META(Write), - MAKE_SERVICE_COMMAND_META(Flush), - MAKE_SERVICE_COMMAND_META(SetSize), - MAKE_SERVICE_COMMAND_META(GetSize), - - /* 4.0.0- */ - MAKE_SERVICE_COMMAND_META(OperateRange, hos::Version_400), - }; - }; - -} diff --git a/stratosphere/libstratosphere/include/stratosphere/fssystem.hpp b/stratosphere/libstratosphere/include/stratosphere/fssystem.hpp deleted file mode 100644 index d786b2e96..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/fssystem.hpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include "fssystem/fssystem_utility.hpp" -#include "fssystem/fssystem_path_tool.hpp" -#include "fssystem/fssystem_subdirectory_filesystem.hpp" -#include "fssystem/fssystem_directory_redirection_filesystem.hpp" -#include "fssystem/fssystem_directory_savedata_filesystem.hpp" diff --git a/stratosphere/libstratosphere/include/stratosphere/fssystem/fssystem_directory_redirection_filesystem.hpp b/stratosphere/libstratosphere/include/stratosphere/fssystem/fssystem_directory_redirection_filesystem.hpp deleted file mode 100644 index 80c1d1e36..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/fssystem/fssystem_directory_redirection_filesystem.hpp +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -#pragma once -#include "impl/fssystem_path_resolution_filesystem.hpp" - -namespace ams::fssystem { - - class DirectoryRedirectionFileSystem : public impl::IPathResolutionFileSystem { - NON_COPYABLE(DirectoryRedirectionFileSystem); - private: - using PathResolutionFileSystem = impl::IPathResolutionFileSystem; - friend class impl::IPathResolutionFileSystem; - private: - char *before_dir; - size_t before_dir_len; - char *after_dir; - size_t after_dir_len; - public: - DirectoryRedirectionFileSystem(std::shared_ptr fs, const char *before, const char *after, bool unc = false); - DirectoryRedirectionFileSystem(std::unique_ptr fs, const char *before, const char *after, bool unc = false); - - virtual ~DirectoryRedirectionFileSystem(); - protected: - inline std::optional> GetAccessorLock() const { - /* No accessor lock is needed. */ - return std::nullopt; - } - private: - Result GetNormalizedDirectoryPath(char **out, size_t *out_size, const char *dir); - Result Initialize(const char *before, const char *after); - Result ResolveFullPath(char *out, size_t out_size, const char *relative_path); - }; - -} diff --git a/stratosphere/libstratosphere/include/stratosphere/fssystem/fssystem_directory_savedata_filesystem.hpp b/stratosphere/libstratosphere/include/stratosphere/fssystem/fssystem_directory_savedata_filesystem.hpp deleted file mode 100644 index 2014ea43d..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/fssystem/fssystem_directory_savedata_filesystem.hpp +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -#pragma once -#include "impl/fssystem_path_resolution_filesystem.hpp" - -namespace ams::fssystem { - - class DirectorySaveDataFileSystem : public impl::IPathResolutionFileSystem { - NON_COPYABLE(DirectorySaveDataFileSystem); - private: - using PathResolutionFileSystem = impl::IPathResolutionFileSystem; - friend class impl::IPathResolutionFileSystem; - private: - os::Mutex accessor_mutex; - s32 open_writable_files; - public: - DirectorySaveDataFileSystem(std::shared_ptr fs); - DirectorySaveDataFileSystem(std::unique_ptr fs); - Result Initialize(); - - virtual ~DirectorySaveDataFileSystem(); - protected: - inline std::optional> GetAccessorLock() { - /* We have a real accessor lock that we want to use. */ - return std::make_optional>(this->accessor_mutex); - } - private: - Result AllocateWorkBuffer(std::unique_ptr *out, size_t *out_size, size_t ideal_size); - Result SynchronizeDirectory(const char *dst, const char *src); - Result ResolveFullPath(char *out, size_t out_size, const char *relative_path); - public: - void OnWritableFileClose(); - Result CopySaveFromFileSystem(fs::fsa::IFileSystem *save_fs); - public: - /* Overridden from IPathResolutionFileSystem */ - virtual Result OpenFileImpl(std::unique_ptr *out_file, const char *path, fs::OpenMode mode) override; - virtual Result CommitImpl() override; - - /* Overridden from IPathResolutionFileSystem but not commands. */ - virtual Result CommitProvisionallyImpl(s64 counter) override; - virtual Result RollbackImpl() override; - - /* Explicitly overridden to be not implemented. */ - virtual Result GetFreeSpaceSizeImpl(s64 *out, const char *path) override; - virtual Result GetTotalSpaceSizeImpl(s64 *out, const char *path) override; - virtual Result GetFileTimeStampRawImpl(fs::FileTimeStampRaw *out, const char *path) override; - virtual Result QueryEntryImpl(char *dst, size_t dst_size, const char *src, size_t src_size, fs::fsa::QueryId query, const char *path) override; - virtual Result FlushImpl() override; - }; - -} diff --git a/stratosphere/libstratosphere/include/stratosphere/fssystem/fssystem_path_tool.hpp b/stratosphere/libstratosphere/include/stratosphere/fssystem/fssystem_path_tool.hpp deleted file mode 100644 index 2e50cce9b..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/fssystem/fssystem_path_tool.hpp +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -#pragma once -#include "../fs/fs_common.hpp" -#include "../fs/fs_path_tool.hpp" - -namespace ams::fssystem { - - namespace StringTraits = ::ams::fs::StringTraits; - - using PathTool = ::ams::fs::PathTool; - -} diff --git a/stratosphere/libstratosphere/include/stratosphere/fssystem/fssystem_subdirectory_filesystem.hpp b/stratosphere/libstratosphere/include/stratosphere/fssystem/fssystem_subdirectory_filesystem.hpp deleted file mode 100644 index 549ceac6e..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/fssystem/fssystem_subdirectory_filesystem.hpp +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -#pragma once -#include "impl/fssystem_path_resolution_filesystem.hpp" - -namespace ams::fssystem { - - class SubDirectoryFileSystem : public impl::IPathResolutionFileSystem { - NON_COPYABLE(SubDirectoryFileSystem); - private: - using PathResolutionFileSystem = impl::IPathResolutionFileSystem; - friend class impl::IPathResolutionFileSystem; - private: - char *base_path; - size_t base_path_len; - public: - SubDirectoryFileSystem(std::shared_ptr fs, const char *bp, bool unc = false); - SubDirectoryFileSystem(std::unique_ptr fs, const char *bp, bool unc = false); - - virtual ~SubDirectoryFileSystem(); - protected: - inline std::optional> GetAccessorLock() const { - /* No accessor lock is needed. */ - return std::nullopt; - } - private: - Result Initialize(const char *bp); - Result ResolveFullPath(char *out, size_t out_size, const char *relative_path); - }; - -} diff --git a/stratosphere/libstratosphere/include/stratosphere/fssystem/fssystem_utility.hpp b/stratosphere/libstratosphere/include/stratosphere/fssystem/fssystem_utility.hpp deleted file mode 100644 index 62aa3bf5d..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/fssystem/fssystem_utility.hpp +++ /dev/null @@ -1,169 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -#pragma once -#include "../fs/fs_common.hpp" -#include "../fs/fs_file.hpp" -#include "../fs/fs_directory.hpp" -#include "../fs/fs_filesystem.hpp" -#include "fssystem_path_tool.hpp" - -namespace ams::fssystem { - - namespace impl { - - /* Iteration. */ - template - Result IterateDirectoryRecursivelyImpl(fs::fsa::IFileSystem *fs, char *work_path, size_t work_path_size, fs::DirectoryEntry *dir_ent, OnEnterDir on_enter_dir, OnExitDir on_exit_dir, OnFile on_file) { - /* Open the directory. */ - std::unique_ptr dir; - R_TRY(fs->OpenDirectory(&dir, work_path, fs::OpenDirectoryMode_All)); - - const size_t parent_len = strnlen(work_path, work_path_size - 1); - - /* Read and handle entries. */ - while (true) { - /* Read a single entry. */ - s64 read_count = 0; - R_TRY(dir->Read(&read_count, dir_ent, 1)); - - /* If we're out of entries, we're done. */ - if (read_count == 0) { - break; - } - - /* Validate child path size. */ - const size_t child_name_len = strnlen(dir_ent->name, sizeof(dir_ent->name) - 1); - const bool is_dir = dir_ent->type == fs::DirectoryEntryType_Directory; - const size_t separator_size = is_dir ? 1 : 0; - R_UNLESS(parent_len + child_name_len + separator_size < work_path_size, fs::ResultTooLongPath()); - - /* Set child path. */ - std::strncat(work_path, dir_ent->name, work_path_size - parent_len - 1); - { - if (is_dir) { - /* Enter directory. */ - R_TRY(on_enter_dir(work_path, *dir_ent)); - - /* Append separator, recurse. */ - std::strncat(work_path, "/", work_path_size - (parent_len + child_name_len) - 1); - R_TRY(IterateDirectoryRecursivelyImpl(fs, work_path, work_path_size, 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)); - } - } - - /* Restore parent path. */ - work_path[parent_len] = StringTraits::NullTerminator; - } - - return ResultSuccess(); - } - - /* TODO: Cleanup. */ - - } - - /* Iteration API */ - template - Result IterateDirectoryRecursively(fs::fsa::IFileSystem *fs, const char *root_path, char *work_path, size_t work_path_size, fs::DirectoryEntry *dir_ent_buf, OnEnterDir on_enter_dir, OnExitDir on_exit_dir, OnFile on_file) { - AMS_ASSERT(work_path_size >= fs::EntryNameLengthMax + 1); - - /* Get size of the root path. */ - size_t root_path_len = strnlen(root_path, fs::EntryNameLengthMax + 1); - R_UNLESS(root_path_len <= fs::EntryNameLengthMax, fs::ResultTooLongPath()); - - /* Copy root path in, add a / if necessary. */ - std::memcpy(work_path, root_path, root_path_len); - if (!PathTool::IsSeparator(work_path[root_path_len - 1])) { - work_path[root_path_len++] = StringTraits::DirectorySeparator; - } - - /* Make sure the result path is still valid. */ - R_UNLESS(root_path_len <= fs::EntryNameLengthMax, fs::ResultTooLongPath()); - work_path[root_path_len] = StringTraits::NullTerminator; - - return impl::IterateDirectoryRecursivelyImpl(fs, work_path, work_path_size, dir_ent_buf, on_enter_dir, on_exit_dir, on_file); - } - - template - Result IterateDirectoryRecursively(fs::fsa::IFileSystem *fs, const char *root_path, OnEnterDir on_enter_dir, OnExitDir on_exit_dir, OnFile on_file) { - fs::DirectoryEntry dir_entry = {}; - char work_path[fs::EntryNameLengthMax + 1] = {}; - return IterateDirectoryRecursively(fs, root_path, work_path, sizeof(work_path), &dir_entry, on_enter_dir, on_exit_dir, on_file); - } - - template - Result IterateDirectoryRecursively(fs::fsa::IFileSystem *fs, OnEnterDir on_enter_dir, OnExitDir on_exit_dir, OnFile on_file) { - return IterateDirectoryRecursively(fs, PathTool::RootPath, 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 char *dst_parent_path, const char *src_path, const fs::DirectoryEntry *dir_ent, void *work_buf, size_t work_buf_size); - NX_INLINE Result CopyFile(fs::fsa::IFileSystem *fs, const char *dst_parent_path, const char *src_path, const fs::DirectoryEntry *dir_ent, void *work_buf, size_t work_buf_size) { - return CopyFile(fs, fs, dst_parent_path, src_path, dir_ent, work_buf, work_buf_size); - } - - Result CopyDirectoryRecursively(fs::fsa::IFileSystem *dst_fs, fs::fsa::IFileSystem *src_fs, const char *dst_path, const char *src_path, void *work_buf, size_t work_buf_size); - NX_INLINE Result CopyDirectoryRecursively(fs::fsa::IFileSystem *fs, const char *dst_path, const char *src_path, void *work_buf, size_t work_buf_size) { - return CopyDirectoryRecursively(fs, fs, dst_path, src_path, work_buf, work_buf_size); - } - - /* Semaphore adapter class. */ - class SemaphoreAdapter : public os::Semaphore { - public: - SemaphoreAdapter(int c, int mc) : os::Semaphore(c, mc) { /* ... */ } - - bool try_lock() { - return this->TryAcquire(); - } - - void unlock() { - this->Release(); - } - }; - - /* Other utility. */ - Result EnsureDirectoryExistsRecursively(fs::fsa::IFileSystem *fs, const char *path); - - template - NX_INLINE Result RetryFinitelyForTargetLocked(F f) { - /* Retry up to 10 times, 100ms between retries. */ - constexpr s32 MaxRetryCount = 10; - constexpr u64 RetryWaitTime = 100'000'000ul; - - s32 remaining_retries = MaxRetryCount; - while (true) { - R_TRY_CATCH(f()) { - R_CATCH(fs::ResultTargetLocked) { - R_UNLESS(remaining_retries > 0, fs::ResultTargetLocked()); - - remaining_retries--; - svcSleepThread(RetryWaitTime); - continue; - } - } R_END_TRY_CATCH; - - return ResultSuccess(); - } - } - -} diff --git a/stratosphere/libstratosphere/include/stratosphere/fssystem/impl/fssystem_path_resolution_filesystem.hpp b/stratosphere/libstratosphere/include/stratosphere/fssystem/impl/fssystem_path_resolution_filesystem.hpp deleted file mode 100644 index 1ba6a388d..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/fssystem/impl/fssystem_path_resolution_filesystem.hpp +++ /dev/null @@ -1,194 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -#pragma once -#include "../../fs/fs_common.hpp" -#include "../../fs/fsa/fs_ifile.hpp" -#include "../../fs/fsa/fs_idirectory.hpp" -#include "../../fs/fsa/fs_ifilesystem.hpp" - -namespace ams::fssystem::impl { - - template - class IPathResolutionFileSystem : public fs::fsa::IFileSystem { - NON_COPYABLE(IPathResolutionFileSystem); - private: - std::shared_ptr shared_fs; - std::unique_ptr unique_fs; - bool unc_preserved; - protected: - fs::fsa::IFileSystem * const base_fs; - public: - IPathResolutionFileSystem(std::shared_ptr fs, bool unc = false) : shared_fs(std::move(fs)), unc_preserved(unc), base_fs(shared_fs.get()) { - /* ... */ - } - - IPathResolutionFileSystem(std::unique_ptr fs, bool unc = false) : unique_fs(std::move(fs)), unc_preserved(unc), base_fs(unique_fs.get()) { - /* ... */ - } - - virtual ~IPathResolutionFileSystem() { /* ... */ } - protected: - constexpr inline bool IsUncPreserved() const { - return this->unc_preserved; - } - public: - virtual Result CreateFileImpl(const char *path, s64 size, int option) override { - char full_path[fs::EntryNameLengthMax + 1]; - R_TRY(static_cast(this)->ResolveFullPath(full_path, sizeof(full_path), path)); - - std::optional optional_lock = static_cast(this)->GetAccessorLock(); - return this->base_fs->CreateFile(full_path, size, option); - } - - virtual Result DeleteFileImpl(const char *path) override { - char full_path[fs::EntryNameLengthMax + 1]; - R_TRY(static_cast(this)->ResolveFullPath(full_path, sizeof(full_path), path)); - - std::optional optional_lock = static_cast(this)->GetAccessorLock(); - return this->base_fs->DeleteFile(full_path); - } - - virtual Result CreateDirectoryImpl(const char *path) override { - char full_path[fs::EntryNameLengthMax + 1]; - R_TRY(static_cast(this)->ResolveFullPath(full_path, sizeof(full_path), path)); - - std::optional optional_lock = static_cast(this)->GetAccessorLock(); - return this->base_fs->CreateDirectory(full_path); - } - - virtual Result DeleteDirectoryImpl(const char *path) override { - char full_path[fs::EntryNameLengthMax + 1]; - R_TRY(static_cast(this)->ResolveFullPath(full_path, sizeof(full_path), path)); - - std::optional optional_lock = static_cast(this)->GetAccessorLock(); - return this->base_fs->DeleteDirectory(full_path); - } - - virtual Result DeleteDirectoryRecursivelyImpl(const char *path) override { - char full_path[fs::EntryNameLengthMax + 1]; - R_TRY(static_cast(this)->ResolveFullPath(full_path, sizeof(full_path), path)); - - std::optional optional_lock = static_cast(this)->GetAccessorLock(); - return this->base_fs->DeleteDirectoryRecursively(full_path); - } - - virtual Result RenameFileImpl(const char *old_path, const char *new_path) override { - char old_full_path[fs::EntryNameLengthMax + 1]; - char new_full_path[fs::EntryNameLengthMax + 1]; - R_TRY(static_cast(this)->ResolveFullPath(old_full_path, sizeof(old_full_path), old_path)); - R_TRY(static_cast(this)->ResolveFullPath(new_full_path, sizeof(new_full_path), new_path)); - - std::optional optional_lock = static_cast(this)->GetAccessorLock(); - return this->base_fs->RenameFile(old_full_path, new_full_path); - } - - virtual Result RenameDirectoryImpl(const char *old_path, const char *new_path) override { - char old_full_path[fs::EntryNameLengthMax + 1]; - char new_full_path[fs::EntryNameLengthMax + 1]; - R_TRY(static_cast(this)->ResolveFullPath(old_full_path, sizeof(old_full_path), old_path)); - R_TRY(static_cast(this)->ResolveFullPath(new_full_path, sizeof(new_full_path), new_path)); - - std::optional optional_lock = static_cast(this)->GetAccessorLock(); - return this->base_fs->RenameDirectory(old_full_path, new_full_path); - } - - virtual Result GetEntryTypeImpl(fs::DirectoryEntryType *out, const char *path) override { - char full_path[fs::EntryNameLengthMax + 1]; - R_TRY(static_cast(this)->ResolveFullPath(full_path, sizeof(full_path), path)); - - std::optional optional_lock = static_cast(this)->GetAccessorLock(); - return this->base_fs->GetEntryType(out, full_path); - } - - virtual Result OpenFileImpl(std::unique_ptr *out_file, const char *path, fs::OpenMode mode) override { - char full_path[fs::EntryNameLengthMax + 1]; - R_TRY(static_cast(this)->ResolveFullPath(full_path, sizeof(full_path), path)); - - std::optional optional_lock = static_cast(this)->GetAccessorLock(); - return this->base_fs->OpenFile(out_file, full_path, mode); - } - - virtual Result OpenDirectoryImpl(std::unique_ptr *out_dir, const char *path, fs::OpenDirectoryMode mode) override { - char full_path[fs::EntryNameLengthMax + 1]; - R_TRY(static_cast(this)->ResolveFullPath(full_path, sizeof(full_path), path)); - - std::optional optional_lock = static_cast(this)->GetAccessorLock(); - return this->base_fs->OpenDirectory(out_dir, full_path, mode); - } - - virtual Result CommitImpl() override { - std::optional optional_lock = static_cast(this)->GetAccessorLock(); - return this->base_fs->Commit(); - } - - virtual Result GetFreeSpaceSizeImpl(s64 *out, const char *path) override { - char full_path[fs::EntryNameLengthMax + 1]; - R_TRY(static_cast(this)->ResolveFullPath(full_path, sizeof(full_path), path)); - - std::optional optional_lock = static_cast(this)->GetAccessorLock(); - return this->base_fs->GetFreeSpaceSize(out, full_path); - } - - virtual Result GetTotalSpaceSizeImpl(s64 *out, const char *path) override { - char full_path[fs::EntryNameLengthMax + 1]; - R_TRY(static_cast(this)->ResolveFullPath(full_path, sizeof(full_path), path)); - - std::optional optional_lock = static_cast(this)->GetAccessorLock(); - return this->base_fs->GetTotalSpaceSize(out, full_path); - } - - virtual Result CleanDirectoryRecursivelyImpl(const char *path) override { - char full_path[fs::EntryNameLengthMax + 1]; - R_TRY(static_cast(this)->ResolveFullPath(full_path, sizeof(full_path), path)); - - std::optional optional_lock = static_cast(this)->GetAccessorLock(); - return this->base_fs->CleanDirectoryRecursively(full_path); - } - - virtual Result GetFileTimeStampRawImpl(fs::FileTimeStampRaw *out, const char *path) override { - char full_path[fs::EntryNameLengthMax + 1]; - R_TRY(static_cast(this)->ResolveFullPath(full_path, sizeof(full_path), path)); - - std::optional optional_lock = static_cast(this)->GetAccessorLock(); - return this->base_fs->GetFileTimeStampRaw(out, full_path); - } - - virtual Result QueryEntryImpl(char *dst, size_t dst_size, const char *src, size_t src_size, fs::fsa::QueryId query, const char *path) override { - char full_path[fs::EntryNameLengthMax + 1]; - R_TRY(static_cast(this)->ResolveFullPath(full_path, sizeof(full_path), path)); - - std::optional optional_lock = static_cast(this)->GetAccessorLock(); - return this->base_fs->QueryEntry(dst, dst_size, src, src_size, query, full_path); - } - - /* These aren't accessible as commands. */ - virtual Result CommitProvisionallyImpl(s64 counter) override { - std::optional optional_lock = static_cast(this)->GetAccessorLock(); - return this->base_fs->CommitProvisionally(counter); - } - - virtual Result RollbackImpl() override { - std::optional optional_lock = static_cast(this)->GetAccessorLock(); - return this->base_fs->Rollback(); - } - - virtual Result FlushImpl() override { - std::optional optional_lock = static_cast(this)->GetAccessorLock(); - return this->base_fs->Flush(); - } - }; - -} diff --git a/stratosphere/libstratosphere/include/stratosphere/hid.hpp b/stratosphere/libstratosphere/include/stratosphere/hid.hpp deleted file mode 100644 index 6f6c15244..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/hid.hpp +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once - -#include "hid/hid_api.hpp" \ No newline at end of file diff --git a/stratosphere/libstratosphere/include/stratosphere/hid/hid_api.hpp b/stratosphere/libstratosphere/include/stratosphere/hid/hid_api.hpp deleted file mode 100644 index b9cb82516..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/hid/hid_api.hpp +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once - -namespace ams::hid { - - /* Key API. */ - Result GetKeysHeld(u64 *out); - -} diff --git a/stratosphere/libstratosphere/include/stratosphere/hos.hpp b/stratosphere/libstratosphere/include/stratosphere/hos.hpp deleted file mode 100644 index 530989193..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/hos.hpp +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once - -#include "hos/hos_types.hpp" -#include "hos/hos_version_api.hpp" diff --git a/stratosphere/libstratosphere/include/stratosphere/hos/hos_types.hpp b/stratosphere/libstratosphere/include/stratosphere/hos/hos_types.hpp deleted file mode 100644 index 158310ba7..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/hos/hos_types.hpp +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include - -namespace ams::hos { - - enum Version : u16 { - Version_Min = 0, - Version_100 = Version_Min, - Version_200 = 1, - Version_300 = 2, - Version_400 = 3, - Version_500 = 4, - Version_600 = 5, - Version_700 = 6, - Version_800 = 7, - Version_810 = 8, - Version_900 = 9, - Version_910 = 10, - Version_Current = Version_910, - Version_Max = 32, - }; - -} diff --git a/stratosphere/libstratosphere/include/stratosphere/hos/hos_version_api.hpp b/stratosphere/libstratosphere/include/stratosphere/hos/hos_version_api.hpp deleted file mode 100644 index 3ccd99ac2..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/hos/hos_version_api.hpp +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include "hos_types.hpp" - -namespace ams::hos { - - ::ams::hos::Version GetVersion(); - void SetVersionForLibnx(); - -} diff --git a/stratosphere/libstratosphere/include/stratosphere/kvdb.hpp b/stratosphere/libstratosphere/include/stratosphere/kvdb.hpp deleted file mode 100644 index f600cdbe7..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/kvdb.hpp +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once - -#include "kvdb/kvdb_auto_buffer.hpp" -#include "kvdb/kvdb_bounded_string.hpp" -#include "kvdb/kvdb_archive.hpp" -#include "kvdb/kvdb_memory_key_value_store.hpp" -#include "kvdb/kvdb_file_key_value_store.hpp" -#include "kvdb/kvdb_file_key_value_cache.hpp" diff --git a/stratosphere/libstratosphere/include/stratosphere/kvdb/kvdb_archive.hpp b/stratosphere/libstratosphere/include/stratosphere/kvdb/kvdb_archive.hpp deleted file mode 100644 index b315de8cf..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/kvdb/kvdb_archive.hpp +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include "kvdb_auto_buffer.hpp" - -namespace ams::kvdb { - - /* Functionality for parsing/generating a key value archive. */ - class ArchiveReader { - private: - AutoBuffer &buffer; - size_t offset; - public: - ArchiveReader(AutoBuffer &b) : buffer(b), offset(0) { /* ... */ } - private: - Result Peek(void *dst, size_t size); - Result Read(void *dst, size_t size); - public: - Result ReadEntryCount(size_t *out); - Result GetEntrySize(size_t *out_key_size, size_t *out_value_size); - Result ReadEntry(void *out_key, size_t key_size, void *out_value, size_t value_size); - }; - - class ArchiveWriter { - private: - AutoBuffer &buffer; - size_t offset; - public: - ArchiveWriter(AutoBuffer &b) : buffer(b), offset(0) { /* ... */ } - private: - Result Write(const void *src, size_t size); - public: - void WriteHeader(size_t entry_count); - void WriteEntry(const void *key, size_t key_size, const void *value, size_t value_size); - }; - - class ArchiveSizeHelper { - private: - size_t size; - public: - ArchiveSizeHelper(); - - void AddEntry(size_t key_size, size_t value_size); - - size_t GetSize() const { - return this->size; - } - }; - -} \ No newline at end of file diff --git a/stratosphere/libstratosphere/include/stratosphere/kvdb/kvdb_auto_buffer.hpp b/stratosphere/libstratosphere/include/stratosphere/kvdb/kvdb_auto_buffer.hpp deleted file mode 100644 index 0950c9141..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/kvdb/kvdb_auto_buffer.hpp +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include - -namespace ams::kvdb { - - class AutoBuffer { - NON_COPYABLE(AutoBuffer); - private: - u8 *buffer; - size_t size; - public: - AutoBuffer() : buffer(nullptr), size(0) { /* ... */ } - - ~AutoBuffer() { - this->Reset(); - } - - AutoBuffer(AutoBuffer &&rhs) { - this->buffer = rhs.buffer; - this->size = rhs.size; - rhs.buffer = nullptr; - rhs.size = 0; - } - - AutoBuffer& operator=(AutoBuffer &&rhs) { - rhs.Swap(*this); - return *this; - } - - void Swap(AutoBuffer &rhs) { - std::swap(this->buffer, rhs.buffer); - std::swap(this->size, rhs.size); - } - - void Reset() { - if (this->buffer != nullptr) { - std::free(this->buffer); - this->buffer = nullptr; - this->size = 0; - } - } - - u8 *Get() const { - return this->buffer; - } - - size_t GetSize() const { - return this->size; - } - - Result Initialize(size_t size) { - /* Check that we're not already initialized. */ - AMS_ASSERT(this->buffer == nullptr); - - /* Allocate a buffer. */ - this->buffer = static_cast(std::malloc(size)); - if (this->buffer == nullptr) { - return ResultAllocationFailed(); - } - this->size = size; - return ResultSuccess(); - } - - Result Initialize(const void *buf, size_t size) { - /* Create a new buffer of the right size. */ - R_TRY(this->Initialize(size)); - - /* Copy the input data in. */ - std::memcpy(this->buffer, buf, size); - - return ResultSuccess(); - } - }; -} \ No newline at end of file diff --git a/stratosphere/libstratosphere/include/stratosphere/kvdb/kvdb_bounded_string.hpp b/stratosphere/libstratosphere/include/stratosphere/kvdb/kvdb_bounded_string.hpp deleted file mode 100644 index 16b4b4393..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/kvdb/kvdb_bounded_string.hpp +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include - -namespace ams::kvdb { - - /* Represents a string with a backing buffer of N bytes. */ - template - class BoundedString { - static_assert(N > 0, "BoundedString requires non-zero backing buffer!"); - private: - char buffer[N]; - private: - /* Utility. */ - static inline void CheckLength(size_t len) { - AMS_ASSERT(len < N); - } - public: - /* Constructors. */ - constexpr BoundedString() { - buffer[0] = 0; - } - - explicit constexpr BoundedString(const char *s) { - this->Set(s); - } - - /* Static constructors. */ - static constexpr BoundedString Make(const char *s) { - return BoundedString(s); - } - - static constexpr BoundedString MakeFormat(const char *format, ...) __attribute__((format (printf, 1, 2))) { - BoundedString string; - - std::va_list args; - va_start(args, format); - CheckLength(std::vsnprintf(string.buffer, N, format, args)); - va_end(args); - - return string; - } - - /* Getters. */ - size_t GetLength() const { - return strnlen(this->buffer, N); - } - - const char *Get() const { - return this->buffer; - } - - operator const char *() const { - return this->buffer; - } - - /* Setters. */ - void Set(const char *s) { - /* Ensure string can fit in our buffer. */ - CheckLength(strnlen(s, N)); - std::strncpy(this->buffer, s, N); - } - - void SetFormat(const char *format, ...) __attribute__((format (printf, 2, 3))) { - /* Format into the buffer, abort if too large. */ - std::va_list args; - va_start(args, format); - CheckLength(std::vsnprintf(this->buffer, N, format, args)); - va_end(args); - } - - /* Append to existing. */ - void Append(const char *s) { - const size_t length = GetLength(); - CheckLength(length + strnlen(s, N)); - std::strncat(this->buffer, s, N - length - 1); - } - - void Append(char c) { - const size_t length = GetLength(); - CheckLength(length + 1); - this->buffer[length] = c; - this->buffer[length + 1] = 0; - } - - void AppendFormat(const char *format, ...) __attribute__((format (printf, 2, 3))) { - const size_t length = GetLength(); - std::va_list args; - va_start(args, format); - CheckLength(std::vsnprintf(this->buffer + length, N - length, format, args) + length); - va_end(args); - } - - /* Substring utilities. */ - void GetSubstring(char *dst, size_t dst_size, size_t offset, size_t length) const { - /* Make sure output buffer can hold the substring. */ - AMS_ASSERT(offset + length <= GetLength()); - AMS_ASSERT(dst_size > length); - /* Copy substring to dst. */ - std::strncpy(dst, this->buffer + offset, length); - dst[length] = 0; - } - - BoundedString GetSubstring(size_t offset, size_t length) const { - BoundedString string; - GetSubstring(string.buffer, N, offset, length); - return string; - } - - /* Comparison. */ - constexpr bool operator==(const BoundedString &rhs) const { - return std::strncmp(this->buffer, rhs.buffer, N) == 0; - } - - constexpr bool operator!=(const BoundedString &rhs) const { - return !(*this == rhs); - } - - bool EndsWith(const char *s, size_t offset) const { - return std::strncmp(this->buffer + offset, s, N - offset) == 0; - } - - bool EndsWith(const char *s) const { - const size_t suffix_length = strnlen(s, N); - const size_t length = GetLength(); - return suffix_length <= length && EndsWith(s, length - suffix_length); - } - }; - -} \ No newline at end of file diff --git a/stratosphere/libstratosphere/include/stratosphere/kvdb/kvdb_file_key_value_cache.hpp b/stratosphere/libstratosphere/include/stratosphere/kvdb/kvdb_file_key_value_cache.hpp deleted file mode 100644 index d37c4710d..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/kvdb/kvdb_file_key_value_cache.hpp +++ /dev/null @@ -1,391 +0,0 @@ -/* - * Copyright (c) 2018-2019 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 . - */ -#include -#include "kvdb_bounded_string.hpp" -#include "kvdb_file_key_value_store.hpp" - -namespace ams::kvdb { - - namespace impl { - - template - class LruList { - private: - /* Subtypes. */ - struct LruHeader { - u32 entry_count; - }; - public: - static constexpr size_t BufferSize = sizeof(Key) * Capacity; - static constexpr size_t FileSize = sizeof(LruHeader) + BufferSize; - using Path = FileKeyValueStore::Path; - private: - Path file_path; - Key *keys; - LruHeader header; - public: - static Result CreateNewList(const char *path) { - /* Create new lru_list.dat. */ - R_TRY(fsdevCreateFile(path, FileSize, 0)); - - /* Open the file. */ - FILE *fp = fopen(path, "r+b"); - R_UNLESS(fp != nullptr, fsdevGetLastResult()); - ON_SCOPE_EXIT { fclose(fp); }; - - /* Write new header with zero entries to the file. */ - LruHeader new_header = { .entry_count = 0, }; - R_UNLESS(fwrite(&new_header, sizeof(new_header), 1, fp) == 1, fsdevGetLastResult()); - - return ResultSuccess(); - } - private: - void RemoveIndex(size_t i) { - AMS_ASSERT(i < this->GetCount()); - std::memmove(this->keys + i, this->keys + i + 1, sizeof(*this->keys) * (this->GetCount() - (i + 1))); - this->DecrementCount(); - } - - void IncrementCount() { - this->header.entry_count++; - } - - void DecrementCount() { - this->header.entry_count--; - } - public: - LruList() : keys(nullptr), header({}) { /* ... */ } - - Result Initialize(const char *path, void *buf, size_t size) { - /* Only initialize once, and ensure we have sufficient memory. */ - AMS_ASSERT(this->keys == nullptr); - AMS_ASSERT(size >= BufferSize); - - /* Setup member variables. */ - this->keys = static_cast(buf); - this->file_path.Set(path); - std::memset(this->keys, 0, BufferSize); - - /* Open file. */ - FILE *fp = fopen(this->file_path, "rb"); - R_UNLESS(fp != nullptr, fsdevGetLastResult()); - ON_SCOPE_EXIT { fclose(fp); }; - - /* Read header. */ - R_UNLESS(fread(&this->header, sizeof(this->header), 1, fp) == 1, fsdevGetLastResult()); - - /* Read entries. */ - const size_t count = this->GetCount(); - if (count > 0) { - R_UNLESS(fread(this->keys, std::min(BufferSize, sizeof(Key) * count), 1, fp) == 1, fsdevGetLastResult()); - } - - return ResultSuccess(); - } - - Result Save() { - /* Open file. */ - FILE *fp = fopen(this->file_path, "r+b"); - R_UNLESS(fp != nullptr, fsdevGetLastResult()); - ON_SCOPE_EXIT { fclose(fp); }; - - /* Write header. */ - R_UNLESS(fwrite(&this->header, sizeof(this->header), 1, fp) == 1, fsdevGetLastResult()); - - /* Write entries. */ - R_UNLESS(fwrite(this->keys, BufferSize, 1, fp) == 1, fsdevGetLastResult()); - - /* Flush. */ - fflush(fp); - - return ResultSuccess(); - } - - size_t GetCount() const { - return this->header.entry_count; - } - - bool IsEmpty() const { - return this->GetCount() == 0; - } - - bool IsFull() const { - return this->GetCount() >= Capacity; - } - - Key Get(size_t i) const { - AMS_ASSERT(i < this->GetCount()); - return this->keys[i]; - } - - Key Peek() const { - AMS_ASSERT(!this->IsEmpty()); - return this->Get(0); - } - - void Push(const Key &key) { - AMS_ASSERT(!this->IsFull()); - this->keys[this->GetCount()] = key; - this->IncrementCount(); - } - - Key Pop() { - AMS_ASSERT(!this->IsEmpty()); - this->RemoveIndex(0); - } - - bool Remove(const Key &key) { - const size_t count = this->GetCount(); - - /* Iterate over the list, removing the last entry that matches the key. */ - for (size_t i = 0; i < count; i++) { - if (this->keys[count - 1 - i] == key) { - this->RemoveIndex(count - 1 - i); - return true; - } - } - - return false; - } - - bool Contains(const Key &key) const { - const size_t count = this->GetCount(); - - /* Iterate over the list, checking to see if we have the key. */ - for (size_t i = 0; i < count; i++) { - if (this->keys[count - 1 - i] == key) { - return true; - } - } - - return false; - } - - bool Update(const Key &key) { - if (this->Remove(key)) { - this->Push(key); - return true; - } - - return false; - } - }; - - } - - template - class FileKeyValueCache { - static_assert(std::is_pod::value, "FileKeyValueCache Key must be pod!"); - static_assert(sizeof(Key) <= FileKeyValueStore::MaxKeySize, "FileKeyValueCache Key is too big!"); - public: - using LeastRecentlyUsedList = impl::LruList; - /* Note: Nintendo code in NS uses Path = BoundedString<0x180> here. */ - /* It's unclear why, since they use 0x300 everywhere else. */ - /* We'll just use 0x300, since it shouldn't make a difference, */ - /* as FileKeyValueStore paths are limited to 0x100 anyway. */ - using Path = typename LeastRecentlyUsedList::Path; - private: - FileKeyValueStore kvs; - LeastRecentlyUsedList lru_list; - private: - static constexpr Path GetLeastRecentlyUsedListPath(const char *dir) { - return Path::MakeFormat("%s/%s", dir, "lru_list.dat"); - } - - static constexpr Path GetFileKeyValueStorePath(const char *dir) { - return Path::MakeFormat("%s/%s", dir, "kvs"); - } - - static Result Exists(bool *out, const char *path, bool is_dir) { - /* Set out to false initially. */ - *out = false; - - /* Check that the path exists, and that our entry type is correct. */ - { - struct stat st; - - if (stat(path, &st) != 0) { - R_TRY_CATCH(fsdevGetLastResult()) { - /* If the path doesn't exist, nothing has gone wrong. */ - R_CONVERT(fs::ResultPathNotFound, ResultSuccess()); - } R_END_TRY_CATCH; - } - - if (is_dir) { - R_UNLESS((S_ISDIR(st.st_mode)), ResultInvalidFilesystemState()); - } else { - R_UNLESS((S_ISREG(st.st_mode)), ResultInvalidFilesystemState()); - } - } - - *out = true; - return ResultSuccess(); - } - - static Result DirectoryExists(bool *out, const char *path) { - return Exists(out, path, true); - } - - static Result FileExists(bool *out, const char *path) { - return Exists(out, path, false); - } - public: - static Result CreateNewCache(const char *dir) { - /* Make a new key value store filesystem, and a new lru_list.dat. */ - R_TRY(LeastRecentlyUsedList::CreateNewList(GetLeastRecentlyUsedListPath(dir))); - R_UNLESS(mkdir(GetFileKeyValueStorePath(dir), 0) == 0, fsdevGetLastResult()); - - return ResultSuccess(); - } - - static Result ValidateExistingCache(const char *dir) { - /* Check for existence. */ - bool has_lru = false, has_kvs = false; - R_TRY(FileExists(&has_lru, GetLeastRecentlyUsedListPath(dir))); - R_TRY(DirectoryExists(&has_kvs, GetFileKeyValueStorePath(dir))); - - /* If neither exists, CreateNewCache was never called. */ - R_UNLESS(has_lru || has_kvs, ResultNotCreated()); - - /* If one exists but not the other, we have an invalid state. */ - R_UNLESS(has_lru && has_kvs, ResultInvalidFilesystemState()); - - return ResultSuccess(); - } - private: - void RemoveOldestKey() { - const Key &oldest_key = this->lru_list.Peek(); - this->lru_list.Pop(); - this->kvs.Remove(oldest_key); - } - public: - Result Initialize(const char *dir, void *buf, size_t size) { - /* Initialize list. */ - R_TRY(this->lru_list.Initialize(GetLeastRecentlyUsedListPath(dir), buf, size)); - - /* Initialize kvs. */ - /* NOTE: Despite creating the kvs folder and returning an error if it does not exist, */ - /* Nintendo does not use the kvs folder, and instead uses the passed dir. */ - /* This causes lru_list.dat to be in the same directory as the store's .val files */ - /* instead of in the same directory as a folder containing the store's .val files. */ - /* This is probably a Nintendo bug, but because system saves contain data in the wrong */ - /* layout it can't really be fixed without breaking existing devices... */ - R_TRY(this->kvs.Initialize(dir)); - - return ResultSuccess(); - } - - size_t GetCount() const { - return this->lru_list.GetCount(); - } - - size_t GetCapacity() const { - return Capacity; - } - - Key GetKey(size_t i) const { - return this->lru_list.Get(i); - } - - bool Contains(const Key &key) const { - return this->lru_list.Contains(key); - } - - Result Get(size_t *out_size, void *out_value, size_t max_out_size, const Key &key) { - /* Note that we accessed the key. */ - this->lru_list.Update(key); - return this->kvs.Get(out_size, out_value, max_out_size, key); - } - - template - Result Get(Value *out_value, const Key &key) { - /* Note that we accessed the key. */ - this->lru_list.Update(key); - return this->kvs.Get(out_value, key); - } - - Result GetSize(size_t *out_size, const Key &key) { - return this->kvs.GetSize(out_size, key); - } - - Result Set(const Key &key, const void *value, size_t value_size) { - if (this->lru_list.Update(key)) { - /* If an entry for the key exists, delete the existing value file. */ - this->kvs.Remove(key); - } else { - /* If the list is full, we need to remove the oldest key. */ - if (this->lru_list.IsFull()) { - this->RemoveOldestKey(); - } - - /* Add the key to the list. */ - this->lru_list.Push(key); - } - - /* Loop, trying to save the new value to disk. */ - while (true) { - /* Try to set the key. */ - R_TRY_CATCH(this->kvs.Set(key, value, value_size)) { - R_CATCH(fs::ResultNotEnoughFreeSpace) { - /* If our entry is the only thing in the Lru list, remove it. */ - if (this->lru_list.GetCount() == 1) { - this->lru_list.Pop(); - R_TRY(this->lru_list.Save()); - return fs::ResultNotEnoughFreeSpace(); - } - - /* Otherwise, remove the oldest element from the cache and try again. */ - this->RemoveOldestKey(); - continue; - } - } R_END_TRY_CATCH; - - /* If we got here, we succeeded. */ - break; - } - - /* Save the list. */ - R_TRY(this->lru_list.Save()); - - return ResultSuccess(); - } - - template - Result Set(const Key &key, const Value &value) { - return this->Set(key, &value, sizeof(Value)); - } - - Result Remove(const Key &key) { - /* Remove the key. */ - this->lru_list.Remove(key); - R_TRY(this->kvs.Remove(key)); - R_TRY(this->lru_list.Save()); - - return ResultSuccess(); - } - - Result RemoveAll() { - /* TODO: Nintendo doesn't check errors here. Should we? */ - while (!this->lru_list.IsEmpty()) { - this->RemoveOldestKey(); - } - R_TRY(this->lru_list.Save()); - - return ResultSuccess(); - } - }; - -} diff --git a/stratosphere/libstratosphere/include/stratosphere/kvdb/kvdb_file_key_value_store.hpp b/stratosphere/libstratosphere/include/stratosphere/kvdb/kvdb_file_key_value_store.hpp deleted file mode 100644 index a53fca9f9..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/kvdb/kvdb_file_key_value_store.hpp +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -#pragma once -#include "../os.hpp" -#include "kvdb_bounded_string.hpp" - -namespace ams::kvdb { - - class FileKeyValueStore { - NON_COPYABLE(FileKeyValueStore); - NON_MOVEABLE(FileKeyValueStore); - public: - static constexpr size_t MaxPathLength = 0x300; /* TODO: FS_MAX_PATH - 1? */ - static constexpr size_t MaxFileLength = 0xFF; - static constexpr char FileExtension[5] = ".val"; - static constexpr size_t FileExtensionLength = sizeof(FileExtension) - 1; - static constexpr size_t MaxKeySize = (MaxFileLength - FileExtensionLength) / 2; - using Path = kvdb::BoundedString; - using FileName = kvdb::BoundedString; - private: - /* Subtypes. */ - struct Entry { - u8 key[MaxKeySize]; - void *value; - size_t key_size; - size_t value_size; - }; - static_assert(std::is_pod::value, "FileKeyValueStore::Entry definition!"); - - class Cache { - private: - u8 *backing_buffer = nullptr; - size_t backing_buffer_size = 0; - size_t backing_buffer_free_offset = 0; - Entry *entries = nullptr; - size_t count = 0; - size_t capacity = 0; - private: - void *Allocate(size_t size); - - bool HasEntries() const { - return this->entries != nullptr && this->capacity != 0; - } - public: - Result Initialize(void *buffer, size_t buffer_size, size_t capacity); - void Invalidate(); - std::optional TryGet(void *out_value, size_t max_out_size, const void *key, size_t key_size); - std::optional TryGetSize(const void *key, size_t key_size); - void Set(const void *key, size_t key_size, const void *value, size_t value_size); - bool Contains(const void *key, size_t key_size); - }; - private: - os::Mutex lock; - Path dir_path; - Cache cache; - private: - Path GetPath(const void *key, size_t key_size); - Result GetKey(size_t *out_size, void *out_key, size_t max_out_size, const FileName &file_name); - public: - FileKeyValueStore() { /* ... */ } - - /* Basic accessors. */ - Result Initialize(const char *dir); - Result InitializeWithCache(const char *dir, void *cache_buffer, size_t cache_buffer_size, size_t cache_capacity); - Result Get(size_t *out_size, void *out_value, size_t max_out_size, const void *key, size_t key_size); - Result GetSize(size_t *out_size, const void *key, size_t key_size); - Result Set(const void *key, size_t key_size, const void *value, size_t value_size); - Result Remove(const void *key, size_t key_size); - - /* Niceties. */ - template - Result Get(size_t *out_size, void *out_value, size_t max_out_size, const Key &key) { - static_assert(std::is_pod::value && sizeof(Key) <= MaxKeySize, "Invalid FileKeyValueStore Key!"); - return this->Get(out_size, out_value, max_out_size, &key, sizeof(Key)); - } - - template - Result Get(Value *out_value, const Key &key) { - static_assert(std::is_pod::value && !std::is_pointer::value, "Invalid FileKeyValueStore Value!"); - size_t size = 0; - R_TRY(this->Get(&size, out_value, sizeof(Value), key)); - AMS_ASSERT(size >= sizeof(Value)); - return ResultSuccess(); - } - - template - Result GetSize(size_t *out_size, const Key &key) { - return this->GetSize(out_size, &key, sizeof(Key)); - } - - template - Result Set(const Key &key, const void *value, size_t value_size) { - static_assert(std::is_pod::value && sizeof(Key) <= MaxKeySize, "Invalid FileKeyValueStore Key!"); - return this->Set(&key, sizeof(Key), value, value_size); - } - - template - Result Set(const Key &key, const Value &value) { - static_assert(std::is_pod::value && !std::is_pointer::value, "Invalid FileKeyValueStore Value!"); - return this->Set(key, &value, sizeof(Value)); - } - - template - Result Remove(const Key &key) { - return this->Remove(&key, sizeof(Key)); - } - }; - -} \ No newline at end of file diff --git a/stratosphere/libstratosphere/include/stratosphere/kvdb/kvdb_memory_key_value_store.hpp b/stratosphere/libstratosphere/include/stratosphere/kvdb/kvdb_memory_key_value_store.hpp deleted file mode 100644 index 8627f3451..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/kvdb/kvdb_memory_key_value_store.hpp +++ /dev/null @@ -1,525 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include -#include "kvdb_auto_buffer.hpp" -#include "kvdb_archive.hpp" -#include "kvdb_bounded_string.hpp" - -namespace ams::kvdb { - - template - class MemoryKeyValueStore { - static_assert(std::is_pod::value, "KeyValueStore Keys must be pod!"); - NON_COPYABLE(MemoryKeyValueStore); - NON_MOVEABLE(MemoryKeyValueStore); - public: - /* Subtypes. */ - class Entry { - private: - Key key; - void *value; - size_t value_size; - public: - constexpr Entry(const Key &k, void *v, size_t s) : key(k), value(v), value_size(s) { /* ... */ } - - const Key &GetKey() const { - return this->key; - } - - template - Value *GetValuePointer() { - /* Size check. Note: Nintendo does not size check. */ - if constexpr (!std::is_same::value) { - AMS_ASSERT(sizeof(Value) <= this->value_size); - /* Ensure we only get pod. */ - static_assert(std::is_pod::value, "KeyValueStore Values must be pod"); - } - return reinterpret_cast(this->value); - } - - template - const Value *GetValuePointer() const { - /* Size check. Note: Nintendo does not size check. */ - if constexpr (!std::is_same::value) { - AMS_ASSERT(sizeof(Value) <= this->value_size); - /* Ensure we only get pod. */ - static_assert(std::is_pod::value, "KeyValueStore Values must be pod"); - } - return reinterpret_cast(this->value); - } - - template - Value &GetValue() { - return *(this->GetValuePointer()); - } - - template - const Value &GetValue() const { - return *(this->GetValuePointer()); - } - - size_t GetValueSize() const { - return this->value_size; - } - - constexpr inline bool operator<(const Key &rhs) const { - return key < rhs; - } - - constexpr inline bool operator==(const Key &rhs) const { - return key == rhs; - } - }; - - class Index { - private: - size_t count; - size_t capacity; - Entry *entries; - public: - Index() : count(0), capacity(0), entries(nullptr) { /* ... */ } - - ~Index() { - if (this->entries != nullptr) { - this->ResetEntries(); - std::free(this->entries); - this->entries = nullptr; - } - } - - size_t GetCount() const { - return this->count; - } - - size_t GetCapacity() const { - return this->capacity; - } - - void ResetEntries() { - for (size_t i = 0; i < this->count; i++) { - std::free(this->entries[i].GetValuePointer()); - } - this->count = 0; - } - - Result Initialize(size_t capacity) { - this->entries = reinterpret_cast(std::malloc(sizeof(Entry) * capacity)); - R_UNLESS(this->entries != nullptr, ResultAllocationFailed()); - this->capacity = capacity; - return ResultSuccess(); - } - - Result Set(const Key &key, const void *value, size_t value_size) { - /* Allocate new value. */ - void *new_value = std::malloc(value_size); - R_UNLESS(new_value != nullptr, ResultAllocationFailed()); - auto value_guard = SCOPE_GUARD { std::free(new_value); }; - std::memcpy(new_value, value, value_size); - - /* Find entry for key. */ - Entry *it = this->lower_bound(key); - if (it != this->end() && it->GetKey() == key) { - /* Entry already exists. Free old value. */ - std::free(it->GetValuePointer()); - } else { - /* We need to add a new entry. Check we have room, move future keys forward. */ - R_UNLESS(this->count < this->capacity, ResultOutOfKeyResource()); - std::memmove(it + 1, it, sizeof(*it) * (this->end() - it)); - this->count++; - } - - /* Save the new Entry in the map. */ - value_guard.Cancel(); - *it = Entry(key, new_value, value_size); - return ResultSuccess(); - } - - Result AddUnsafe(const Key &key, void *value, size_t value_size) { - R_UNLESS(this->count < this->capacity, ResultOutOfKeyResource()); - - this->entries[this->count++] = Entry(key, value, value_size); - return ResultSuccess(); - } - - Result Remove(const Key &key) { - /* Find entry for key. */ - Entry *it = this->find(key); - R_UNLESS(it != this->end(), ResultKeyNotFound()); - - /* Free the value, move entries back. */ - std::free(it->GetValuePointer()); - std::memmove(it, it + 1, sizeof(*it) * (this->end() - (it + 1))); - this->count--; - return ResultSuccess(); - } - - Entry *begin() { - return this->GetBegin(); - } - - const Entry *begin() const { - return this->GetBegin(); - } - - Entry *end() { - return this->GetEnd(); - } - - const Entry *end() const { - return this->GetEnd(); - } - - const Entry *cbegin() const { - return this->begin(); - } - - const Entry *cend() const { - return this->end(); - } - - Entry *lower_bound(const Key &key) { - return this->GetLowerBound(key); - } - - const Entry *lower_bound(const Key &key) const { - return this->GetLowerBound(key); - } - - Entry *find(const Key &key) { - return this->Find(key); - } - - const Entry *find(const Key &key) const { - return this->Find(key); - } - private: - Entry *GetBegin() { - return this->entries; - } - - const Entry *GetBegin() const { - return this->entries; - } - - Entry *GetEnd() { - return this->GetBegin() + this->count; - } - - const Entry *GetEnd() const { - return this->GetBegin() + this->count; - } - - Entry *GetLowerBound(const Key &key) { - return std::lower_bound(this->GetBegin(), this->GetEnd(), key); - } - - const Entry *GetLowerBound(const Key &key) const { - return std::lower_bound(this->GetBegin(), this->GetEnd(), key); - } - - Entry *Find(const Key &key) { - auto it = this->GetLowerBound(key); - auto end = this->GetEnd(); - if (it != end && it->GetKey() == key) { - return it; - } - return end; - } - - const Entry *Find(const Key &key) const { - auto it = this->GetLowerBound(key); - auto end = this->GetEnd(); - if (it != end && it->GetKey() == key) { - return it; - } - return end; - } - }; - private: - static constexpr size_t MaxPathLen = 0x300; /* TODO: FS_MAX_PATH - 1? */ - using Path = kvdb::BoundedString; - private: - Index index; - Path path; - Path temp_path; - public: - MemoryKeyValueStore() { /* ... */ } - - Result Initialize(const char *dir, size_t capacity) { - /* Ensure that the passed path is a directory. */ - { - struct stat st; - R_UNLESS(stat(dir, &st) == 0, fs::ResultPathNotFound()); - R_UNLESS((S_ISDIR(st.st_mode)), fs::ResultPathNotFound()); - } - - /* Set paths. */ - this->path.SetFormat("%s%s", dir, "/imkvdb.arc"); - this->temp_path.SetFormat("%s%s", dir, "/imkvdb.tmp"); - - /* Initialize our index. */ - R_TRY(this->index.Initialize(capacity)); - return ResultSuccess(); - } - - Result Initialize(size_t capacity) { - /* This initializes without an archive file. */ - /* A store initialized this way cannot have its contents loaded from or flushed to disk. */ - this->path.Set(""); - this->temp_path.Set(""); - - /* Initialize our index. */ - R_TRY(this->index.Initialize(capacity)); - return ResultSuccess(); - } - - size_t GetCount() const { - return this->index.GetCount(); - } - - size_t GetCapacity() const { - return this->index.GetCapacity(); - } - - Result Load() { - /* Reset any existing entries. */ - this->index.ResetEntries(); - - /* Try to read the archive -- note, path not found is a success condition. */ - /* This is because no archive file = no entries, so we're in the right state. */ - AutoBuffer buffer; - R_TRY_CATCH(this->ReadArchiveFile(&buffer)) { - R_CONVERT(fs::ResultPathNotFound, ResultSuccess()); - } R_END_TRY_CATCH; - - /* Parse entries from the buffer. */ - { - ArchiveReader reader(buffer); - - size_t entry_count = 0; - R_TRY(reader.ReadEntryCount(&entry_count)); - - for (size_t i = 0; i < entry_count; i++) { - /* Get size of key/value. */ - size_t key_size = 0, value_size = 0; - R_TRY(reader.GetEntrySize(&key_size, &value_size)); - - /* Allocate memory for value. */ - void *new_value = std::malloc(value_size); - R_UNLESS(new_value != nullptr, ResultAllocationFailed()); - auto value_guard = SCOPE_GUARD { std::free(new_value); }; - - /* Read key and value. */ - Key key; - R_TRY(reader.ReadEntry(&key, sizeof(key), new_value, value_size)); - R_TRY(this->index.AddUnsafe(key, new_value, value_size)); - - /* We succeeded, so cancel the value guard to prevent deallocation. */ - value_guard.Cancel(); - } - } - - return ResultSuccess(); - } - - Result Save() { - /* Create a buffer to hold the archive. */ - AutoBuffer buffer; - R_TRY(buffer.Initialize(this->GetArchiveSize())); - - /* Write the archive to the buffer. */ - { - ArchiveWriter writer(buffer); - writer.WriteHeader(this->GetCount()); - for (const auto &it : this->index) { - const auto &key = it.GetKey(); - writer.WriteEntry(&key, sizeof(Key), it.GetValuePointer(), it.GetValueSize()); - } - } - - /* Save the buffer to disk. */ - return this->Commit(buffer); - } - - Result Set(const Key &key, const void *value, size_t value_size) { - return this->index.Set(key, value, value_size); - } - - template - Result Set(const Key &key, const Value &value) { - /* Only allow setting pod. */ - static_assert(std::is_pod::value, "KeyValueStore Values must be pod"); - return this->Set(key, &value, sizeof(Value)); - } - - template - Result Set(const Key &key, const Value *value) { - /* Only allow setting pod. */ - static_assert(std::is_pod::value, "KeyValueStore Values must be pod"); - return this->Set(key, value, sizeof(Value)); - } - - Result Get(size_t *out_size, void *out_value, size_t max_out_size, const Key &key) { - /* Find entry. */ - auto it = this->find(key); - R_UNLESS(it != this->end(), ResultKeyNotFound()); - - size_t size = std::min(max_out_size, it->GetValueSize()); - std::memcpy(out_value, it->GetValuePointer(), size); - *out_size = size; - return ResultSuccess(); - } - - template - Result GetValuePointer(Value **out_value, const Key &key) { - /* Find entry. */ - auto it = this->find(key); - R_UNLESS(it != this->end(), ResultKeyNotFound()); - - *out_value = it->template GetValuePointer(); - return ResultSuccess(); - } - - template - Result GetValuePointer(const Value **out_value, const Key &key) const { - /* Find entry. */ - auto it = this->find(key); - R_UNLESS(it != this->end(), ResultKeyNotFound()); - - *out_value = it->template GetValuePointer(); - return ResultSuccess(); - } - - template - Result GetValue(Value *out_value, const Key &key) const { - /* Find entry. */ - auto it = this->find(key); - R_UNLESS(it != this->end(), ResultKeyNotFound()); - - *out_value = it->template GetValue(); - return ResultSuccess(); - } - - Result GetValueSize(size_t *out_size, const Key &key) const { - /* Find entry. */ - auto it = this->find(key); - R_UNLESS(it != this->end(), ResultKeyNotFound()); - - *out_size = it->GetValueSize(); - return ResultSuccess(); - } - - Result Remove(const Key &key) { - return this->index.Remove(key); - } - - Entry *begin() { - return this->index.begin(); - } - - const Entry *begin() const { - return this->index.begin(); - } - - Entry *end() { - return this->index.end(); - } - - const Entry *end() const { - return this->index.end(); - } - - const Entry *cbegin() const { - return this->index.cbegin(); - } - - const Entry *cend() const { - return this->index.cend(); - } - - Entry *lower_bound(const Key &key) { - return this->index.lower_bound(key); - } - - const Entry *lower_bound(const Key &key) const { - return this->index.lower_bound(key); - } - - Entry *find(const Key &key) { - return this->index.find(key); - } - - const Entry *find(const Key &key) const { - return this->index.find(key); - } - private: - Result Commit(const AutoBuffer &buffer) { - /* Try to delete temporary archive, but allow deletion failure (it may not exist). */ - std::remove(this->temp_path.Get()); - - /* Create new temporary archive. */ - R_TRY(fsdevCreateFile(this->temp_path.Get(), buffer.GetSize(), 0)); - - /* Write data to the temporary archive. */ - { - FILE *f = fopen(this->temp_path, "r+b"); - R_UNLESS(f != nullptr, fsdevGetLastResult()); - ON_SCOPE_EXIT { fclose(f); }; - - R_UNLESS(fwrite(buffer.Get(), buffer.GetSize(), 1, f) == 1, fsdevGetLastResult()); - } - - /* Try to delete the saved archive, but allow deletion failure. */ - std::remove(this->path.Get()); - - /* Rename the path. */ - R_UNLESS(std::rename(this->temp_path.Get(), this->path.Get()) == 0, fsdevGetLastResult()); - - return ResultSuccess(); - } - - size_t GetArchiveSize() const { - ArchiveSizeHelper size_helper; - - for (const auto &it : this->index) { - size_helper.AddEntry(sizeof(Key), it.GetValueSize()); - } - - return size_helper.GetSize(); - } - - Result ReadArchiveFile(AutoBuffer *dst) const { - /* Open the file. */ - FILE *f = fopen(this->path, "rb"); - R_UNLESS(f != nullptr, fsdevGetLastResult()); - ON_SCOPE_EXIT { fclose(f); }; - - /* Get the archive file size. */ - fseek(f, 0, SEEK_END); - const size_t archive_size = ftell(f); - fseek(f, 0, SEEK_SET); - - /* Make a new buffer, read the file. */ - R_TRY(dst->Initialize(archive_size)); - R_UNLESS(fread(dst->Get(), archive_size, 1, f) == 1, fsdevGetLastResult()); - - return ResultSuccess(); - } - }; - -} \ No newline at end of file diff --git a/stratosphere/libstratosphere/include/stratosphere/ldr.hpp b/stratosphere/libstratosphere/include/stratosphere/ldr.hpp deleted file mode 100644 index 5a4d6552f..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/ldr.hpp +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once - -#include "ldr/ldr_types.hpp" -#include "ldr/ldr_pm_api.hpp" diff --git a/stratosphere/libstratosphere/include/stratosphere/ldr/ldr_pm_api.hpp b/stratosphere/libstratosphere/include/stratosphere/ldr/ldr_pm_api.hpp deleted file mode 100644 index 1eb6418d7..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/ldr/ldr_pm_api.hpp +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include "ldr_types.hpp" - -namespace ams::ldr::pm { - - /* Process Manager API. */ - Result CreateProcess(Handle *out, PinId pin_id, u32 flags, Handle reslimit); - Result GetProgramInfo(ProgramInfo *out, const ncm::ProgramLocation &loc); - Result PinProgram(PinId *out, const ncm::ProgramLocation &loc); - Result UnpinProgram(PinId pin_id); - Result HasLaunchedProgram(bool *out, ncm::ProgramId program_id); - - /* Atmosphere extension API. */ - Result AtmosphereGetProgramInfo(ProgramInfo *out, cfg::OverrideStatus *out_status, const ncm::ProgramLocation &loc); - Result AtmospherePinProgram(PinId *out, const ncm::ProgramLocation &loc, const cfg::OverrideStatus &status); - -} diff --git a/stratosphere/libstratosphere/include/stratosphere/ldr/ldr_types.hpp b/stratosphere/libstratosphere/include/stratosphere/ldr/ldr_types.hpp deleted file mode 100644 index 4d7ebe23c..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/ldr/ldr_types.hpp +++ /dev/null @@ -1,242 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include -#include "../ncm/ncm_types.hpp" -#include "../sf/sf_buffer_tags.hpp" - -namespace ams::ldr { - - /* General types. */ - struct ProgramInfo : sf::LargeData { - u8 main_thread_priority; - u8 default_cpu_id; - u16 flags; - u32 main_thread_stack_size; - ncm::ProgramId program_id; - u32 acid_sac_size; - u32 aci_sac_size; - u32 acid_fac_size; - u32 aci_fah_size; - u8 ac_buffer[0x3E0]; - }; - static_assert(std::is_pod::value && sizeof(ProgramInfo) == 0x400, "ProgramInfo definition!"); - - enum ProgramInfoFlag { - ProgramInfoFlag_SystemModule = (0 << 0), - ProgramInfoFlag_Application = (1 << 0), - ProgramInfoFlag_Applet = (2 << 0), - ProgramInfoFlag_InvalidType = (3 << 0), - ProgramInfoFlag_ApplicationTypeMask = (3 << 0), - - ProgramInfoFlag_AllowDebug = (1 << 2), - }; - - enum CreateProcessFlag { - CreateProcessFlag_EnableDebug = (1 << 0), - CreateProcessFlag_DisableAslr = (1 << 1), - }; - - struct ProgramArguments { - u32 allocated_size; - u32 arguments_size; - u8 reserved[0x18]; - u8 arguments[]; - }; - static_assert(sizeof(ProgramArguments) == 0x20, "ProgramArguments definition!"); - - struct PinId { - u64 value; - }; - - inline bool operator==(const PinId &lhs, const PinId &rhs) { - return lhs.value == rhs.value; - } - - inline bool operator!=(const PinId &lhs, const PinId &rhs) { - return lhs.value != rhs.value; - } - static_assert(sizeof(PinId) == sizeof(u64) && std::is_pod::value, "PinId definition!"); - - /* Import ModuleInfo from libnx. */ - using ModuleInfo = ::LoaderModuleInfo; - - /* NSO types. */ - struct NsoHeader { - static constexpr u32 Magic = 0x304F534E; - enum Segment : size_t { - Segment_Text = 0, - Segment_Ro = 1, - Segment_Rw = 2, - Segment_Count, - }; - - enum Flag : u32 { - Flag_CompressedText = (1 << 0), - Flag_CompressedRo = (1 << 1), - Flag_CompressedRw = (1 << 2), - Flag_CheckHashText = (1 << 3), - Flag_CheckHashRo = (1 << 4), - Flag_CheckHashRw = (1 << 5), - }; - - struct SegmentInfo { - u32 file_offset; - u32 dst_offset; - u32 size; - u32 reserved; - }; - - u32 magic; - u32 version; - u32 reserved_08; - u32 flags; - union { - struct { - u32 text_file_offset; - u32 text_dst_offset; - u32 text_size; - u32 unk_file_offset; - u32 ro_file_offset; - u32 ro_dst_offset; - u32 ro_size; - u32 unk_size; - u32 rw_file_offset; - u32 rw_dst_offset; - u32 rw_size; - u32 bss_size; - }; - SegmentInfo segments[Segment_Count]; - }; - u8 build_id[sizeof(ModuleInfo::build_id)]; - union { - u32 compressed_sizes[Segment_Count]; - struct { - u32 text_compressed_size; - u32 ro_compressed_size; - u32 rw_compressed_size; - }; - }; - u8 reserved_6C[0x34]; - union { - u8 segment_hashes[Segment_Count][SHA256_HASH_SIZE]; - struct { - u8 text_hash[SHA256_HASH_SIZE]; - u8 ro_hash[SHA256_HASH_SIZE]; - u8 rw_hash[SHA256_HASH_SIZE]; - }; - }; - }; - static_assert(sizeof(NsoHeader) == 0x100 && std::is_pod::value, "NsoHeader definition!"); - - /* NPDM types. */ - struct Aci { - static constexpr u32 Magic = 0x30494341; - - u32 magic; - u8 reserved_04[0xC]; - ncm::ProgramId program_id; - u8 reserved_18[0x8]; - u32 fah_offset; - u32 fah_size; - u32 sac_offset; - u32 sac_size; - u32 kac_offset; - u32 kac_size; - u8 reserved_38[0x8]; - }; - static_assert(sizeof(Aci) == 0x40 && std::is_pod::value, "Aci definition!"); - - struct Acid { - static constexpr u32 Magic = 0x44494341; - - enum AcidFlag { - AcidFlag_Production = (1 << 0), - AcidFlag_UnqualifiedApproval = (1 << 1), - - AcidFlag_DeprecatedUseSecureMemory = (1 << 2), - - AcidFlag_PoolPartitionShift = 2, - AcidFlag_PoolPartitionMask = (3 << AcidFlag_PoolPartitionShift), - }; - - enum PoolPartition { - PoolPartition_Application = (svc::CreateProcessFlag_PoolPartitionApplication >> svc::CreateProcessFlag_PoolPartitionShift), - PoolPartition_Applet = (svc::CreateProcessFlag_PoolPartitionApplet >> svc::CreateProcessFlag_PoolPartitionShift), - PoolPartition_System = (svc::CreateProcessFlag_PoolPartitionSystem >> svc::CreateProcessFlag_PoolPartitionShift), - PoolPartition_SystemNonSecure = (svc::CreateProcessFlag_PoolPartitionSystemNonSecure >> svc::CreateProcessFlag_PoolPartitionShift), - }; - - u8 signature[0x100]; - u8 modulus[0x100]; - u32 magic; - u32 size; - u8 version; - u8 reserved_209[3]; - u32 flags; - ncm::ProgramId program_id_min; - ncm::ProgramId program_id_max; - u32 fac_offset; - u32 fac_size; - u32 sac_offset; - u32 sac_size; - u32 kac_offset; - u32 kac_size; - u8 reserved_238[0x8]; - }; - static_assert(sizeof(Acid) == 0x240 && std::is_pod::value, "Acid definition!"); - - struct Npdm { - static constexpr u32 Magic = 0x4154454D; - - enum MetaFlag { - MetaFlag_Is64Bit = (1 << 0), - - MetaFlag_AddressSpaceTypeShift = 1, - MetaFlag_AddressSpaceTypeMask = (7 << MetaFlag_AddressSpaceTypeShift), - - MetaFlag_OptimizeMemoryAllocation = (1 << 4), - }; - - enum AddressSpaceType { - AddressSpaceType_32Bit = (svc::CreateProcessFlag_AddressSpace32Bit >> svc::CreateProcessFlag_AddressSpaceShift), - AddressSpaceType_64BitDeprecated = (svc::CreateProcessFlag_AddressSpace64BitDeprecated >> svc::CreateProcessFlag_AddressSpaceShift), - AddressSpaceType_32BitWithoutAlias = (svc::CreateProcessFlag_AddressSpace32BitWithoutAlias >> svc::CreateProcessFlag_AddressSpaceShift), - AddressSpaceType_64Bit = (svc::CreateProcessFlag_AddressSpace64Bit >> svc::CreateProcessFlag_AddressSpaceShift), - }; - - u32 magic; - u8 reserved_04[8]; - u8 flags; - u8 reserved_0D; - u8 main_thread_priority; - u8 default_cpu_id; - u8 reserved_10[4]; - u32 system_resource_size; - u32 version; - u32 main_thread_stack_size; - char program_name[0x10]; - char product_code[0x10]; - u8 reserved_40[0x30]; - u32 aci_offset; - u32 aci_size; - u32 acid_offset; - u32 acid_size; - }; - static_assert(sizeof(Npdm) == 0x80 && std::is_pod::value, "Npdm definition!"); - -} diff --git a/stratosphere/libstratosphere/include/stratosphere/map.hpp b/stratosphere/libstratosphere/include/stratosphere/map.hpp deleted file mode 100644 index 3b34b2346..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/map.hpp +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once - -#include "map/map_types.hpp" -#include "map/map_api.hpp" diff --git a/stratosphere/libstratosphere/include/stratosphere/map/map_api.hpp b/stratosphere/libstratosphere/include/stratosphere/map/map_api.hpp deleted file mode 100644 index 89f04b507..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/map/map_api.hpp +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include "map_types.hpp" - -namespace ams::map { - - /* Public API. */ - Result GetProcessAddressSpaceInfo(AddressSpaceInfo *out, Handle process_h); - Result LocateMappableSpace(uintptr_t *out_address, size_t size); - Result MapCodeMemoryInProcess(MappedCodeMemory &out_mcm, Handle process_handle, uintptr_t base_address, size_t size); - bool CanAddGuardRegionsInProcess(Handle process_handle, uintptr_t address, size_t size); - -} diff --git a/stratosphere/libstratosphere/include/stratosphere/map/map_types.hpp b/stratosphere/libstratosphere/include/stratosphere/map/map_types.hpp deleted file mode 100644 index 41127e87c..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/map/map_types.hpp +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include - -namespace ams::map { - - /* Types. */ - struct AddressSpaceInfo { - uintptr_t heap_base; - size_t heap_size; - uintptr_t heap_end; - uintptr_t alias_base; - size_t alias_size; - uintptr_t alias_end; - uintptr_t aslr_base; - size_t aslr_size; - uintptr_t aslr_end; - }; - - static constexpr uintptr_t AslrBase32Bit = 0x0000200000ul; - static constexpr size_t AslrSize32Bit = 0x003FE00000ul; - static constexpr uintptr_t AslrBase64BitDeprecated = 0x0008000000ul; - static constexpr size_t AslrSize64BitDeprecated = 0x0078000000ul; - static constexpr uintptr_t AslrBase64Bit = 0x0008000000ul; - static constexpr size_t AslrSize64Bit = 0x7FF8000000ul; - - class AutoCloseMap { - private: - Handle process_handle; - Result result; - void *mapped_address; - uintptr_t base_address; - size_t size; - public: - AutoCloseMap(uintptr_t mp, Handle p_h, uintptr_t ba, size_t sz) : process_handle(p_h), mapped_address(reinterpret_cast(mp)), base_address(ba), size(sz) { - this->result = svcMapProcessMemory(this->mapped_address, this->process_handle, this->base_address, this->size); - } - - ~AutoCloseMap() { - if (this->process_handle != INVALID_HANDLE && R_SUCCEEDED(this->result)) { - R_ASSERT(svcUnmapProcessMemory(this->mapped_address, this->process_handle, this->base_address, this->size)); - } - } - - Result GetResult() const { - return this->result; - } - - bool IsSuccess() const { - return R_SUCCEEDED(this->result); - } - - void Invalidate() { - this->process_handle = INVALID_HANDLE; - } - }; - - class MappedCodeMemory { - private: - Handle process_handle; - Result result; - uintptr_t dst_address; - uintptr_t src_address; - size_t size; - public: - MappedCodeMemory(Result init_res) : process_handle(INVALID_HANDLE), result(init_res), dst_address(0), src_address(0), size(0) { - /* ... */ - } - - MappedCodeMemory(Handle p_h, uintptr_t dst, uintptr_t src, size_t sz) : process_handle(p_h), dst_address(dst), src_address(src), size(sz) { - this->result = svcMapProcessCodeMemory(this->process_handle, this->dst_address, this->src_address, this->size); - } - - ~MappedCodeMemory() { - if (this->process_handle != INVALID_HANDLE && R_SUCCEEDED(this->result) && this->size > 0) { - R_ASSERT(svcUnmapProcessCodeMemory(this->process_handle, this->dst_address, this->src_address, this->size)); - } - } - - uintptr_t GetDstAddress() const { - return this->dst_address; - } - - Result GetResult() const { - return this->result; - } - - bool IsSuccess() const { - return R_SUCCEEDED(this->result); - } - - void Invalidate() { - this->process_handle = INVALID_HANDLE; - } - - MappedCodeMemory &operator=(MappedCodeMemory &&o) { - this->process_handle = o.process_handle; - this->result = o.result; - this->dst_address = o.dst_address; - this->src_address = o.src_address; - this->size = o.size; - o.Invalidate(); - return *this; - } - }; - -} diff --git a/stratosphere/libstratosphere/include/stratosphere/ncm.hpp b/stratosphere/libstratosphere/include/stratosphere/ncm.hpp deleted file mode 100644 index 8f2d1084a..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/ncm.hpp +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once - -#include "ncm/ncm_types.hpp" diff --git a/stratosphere/libstratosphere/include/stratosphere/ncm/ncm_types.hpp b/stratosphere/libstratosphere/include/stratosphere/ncm/ncm_types.hpp deleted file mode 100644 index b21adb947..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/ncm/ncm_types.hpp +++ /dev/null @@ -1,447 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include - -namespace ams::ncm { - - /* Storage IDs. */ - enum class StorageId : u8 { - #define DEFINE_ENUM_MEMBER(nm) nm = NcmStorageId_##nm - DEFINE_ENUM_MEMBER(None), - DEFINE_ENUM_MEMBER(Host), - DEFINE_ENUM_MEMBER(GameCard), - DEFINE_ENUM_MEMBER(BuiltInSystem), - DEFINE_ENUM_MEMBER(BuiltInUser), - DEFINE_ENUM_MEMBER(SdCard), - DEFINE_ENUM_MEMBER(Any), - #undef DEFINE_ENUM_MEMBER - }; - - /* Program IDs (Formerly: Title IDs). */ - struct ProgramId { - u64 value; - - inline explicit operator u64() const { - return this->value; - } - - /* Invalid Program ID. */ - static const ProgramId Invalid; - - /* System Modules. */ - static const ProgramId SystemStart; - - static const ProgramId Fs; - static const ProgramId Loader; - static const ProgramId Ncm; - static const ProgramId Pm; - static const ProgramId Sm; - static const ProgramId Boot; - static const ProgramId Usb; - static const ProgramId Tma; - static const ProgramId Boot2; - static const ProgramId Settings; - static const ProgramId Bus; - static const ProgramId Bluetooth; - static const ProgramId Bcat; - static const ProgramId Dmnt; - static const ProgramId Friends; - static const ProgramId Nifm; - static const ProgramId Ptm; - static const ProgramId Shell; - static const ProgramId BsdSockets; - static const ProgramId Hid; - static const ProgramId Audio; - static const ProgramId LogManager; - static const ProgramId Wlan; - static const ProgramId Cs; - static const ProgramId Ldn; - static const ProgramId NvServices; - static const ProgramId Pcv; - static const ProgramId Ppc; - static const ProgramId NvnFlinger; - static const ProgramId Pcie; - static const ProgramId Account; - static const ProgramId Ns; - static const ProgramId Nfc; - static const ProgramId Psc; - static const ProgramId CapSrv; - static const ProgramId Am; - static const ProgramId Ssl; - static const ProgramId Nim; - static const ProgramId Cec; - static const ProgramId Tspm; - static const ProgramId Spl; - static const ProgramId Lbl; - static const ProgramId Btm; - static const ProgramId Erpt; - static const ProgramId Time; - static const ProgramId Vi; - static const ProgramId Pctl; - static const ProgramId Npns; - static const ProgramId Eupld; - static const ProgramId Arp; - static const ProgramId Glue; - static const ProgramId Eclct; - static const ProgramId Es; - static const ProgramId Fatal; - static const ProgramId Grc; - static const ProgramId Creport; - static const ProgramId Ro; - static const ProgramId Profiler; - static const ProgramId Sdb; - static const ProgramId Migration; - static const ProgramId Jit; - static const ProgramId JpegDec; - static const ProgramId SafeMode; - static const ProgramId Olsc; - static const ProgramId Dt; - static const ProgramId Nd; - static const ProgramId Ngct; - - static const ProgramId SystemEnd; - - /* System Data Archives. */ - static const ProgramId ArchiveStart; - static const ProgramId ArchiveCertStore; - static const ProgramId ArchiveErrorMessage; - static const ProgramId ArchiveMiiModel; - static const ProgramId ArchiveBrowserDll; - static const ProgramId ArchiveHelp; - static const ProgramId ArchiveSharedFont; - static const ProgramId ArchiveNgWord; - static const ProgramId ArchiveSsidList; - static const ProgramId ArchiveDictionary; - static const ProgramId ArchiveSystemVersion; - static const ProgramId ArchiveAvatarImage; - static const ProgramId ArchiveLocalNews; - static const ProgramId ArchiveEula; - static const ProgramId ArchiveUrlBlackList; - static const ProgramId ArchiveTimeZoneBinar; - static const ProgramId ArchiveCertStoreCruiser; - static const ProgramId ArchiveFontNintendoExtension; - static const ProgramId ArchiveFontStandard; - static const ProgramId ArchiveFontKorean; - static const ProgramId ArchiveFontChineseTraditional; - static const ProgramId ArchiveFontChineseSimple; - static const ProgramId ArchiveFontBfcpx; - static const ProgramId ArchiveSystemUpdate; - - static const ProgramId ArchiveFirmwareDebugSettings; - static const ProgramId ArchiveBootImagePackage; - static const ProgramId ArchiveBootImagePackageSafe; - static const ProgramId ArchiveBootImagePackageExFat; - static const ProgramId ArchiveBootImagePackageExFatSafe; - static const ProgramId ArchiveFatalMessage; - static const ProgramId ArchiveControllerIcon; - static const ProgramId ArchivePlatformConfigIcosa; - static const ProgramId ArchivePlatformConfigCopper; - static const ProgramId ArchivePlatformConfigHoag; - static const ProgramId ArchiveControllerFirmware; - static const ProgramId ArchiveNgWord2; - static const ProgramId ArchivePlatformConfigIcosaMariko; - static const ProgramId ArchiveApplicationBlackList; - static const ProgramId ArchiveRebootlessSystemUpdateVersion; - static const ProgramId ArchiveContentActionTable; - - static const ProgramId ArchiveEnd; - - /* System Applets. */ - static const ProgramId AppletStart; - - static const ProgramId AppletQlaunch; - static const ProgramId AppletAuth; - static const ProgramId AppletCabinet; - static const ProgramId AppletController; - static const ProgramId AppletDataErase; - static const ProgramId AppletError; - static const ProgramId AppletNetConnect; - static const ProgramId AppletPlayerSelect; - static const ProgramId AppletSwkbd; - static const ProgramId AppletMiiEdit; - static const ProgramId AppletWeb; - static const ProgramId AppletShop; - static const ProgramId AppletOverlayDisp; - static const ProgramId AppletPhotoViewer; - static const ProgramId AppletSet; - static const ProgramId AppletOfflineWeb; - static const ProgramId AppletLoginShare; - static const ProgramId AppletWifiWebAuth; - static const ProgramId AppletStarter; - static const ProgramId AppletMyPage; - static const ProgramId AppletPlayReport; - static const ProgramId AppletMaintenanceMenu; - - static const ProgramId AppletGift; - static const ProgramId AppletDummyShop; - static const ProgramId AppletUserMigration; - static const ProgramId AppletEncounter; - - static const ProgramId AppletStory; - - static const ProgramId AppletEnd; - - /* Debug Applets. */ - - /* Debug Modules. */ - - /* Factory Setup. */ - - /* Applications. */ - static const ProgramId ApplicationStart; - static const ProgramId ApplicationEnd; - - /* Atmosphere Extensions. */ - static const ProgramId AtmosphereMitm; - }; - - /* Invalid Program ID. */ - inline constexpr const ProgramId ProgramId::Invalid = {}; - - inline constexpr const ProgramId InvalidProgramId = ProgramId::Invalid; - - /* System Modules. */ - inline constexpr const ProgramId ProgramId::SystemStart = { 0x0100000000000000ul }; - - inline constexpr const ProgramId ProgramId::Fs = { 0x0100000000000000ul }; - inline constexpr const ProgramId ProgramId::Loader = { 0x0100000000000001ul }; - inline constexpr const ProgramId ProgramId::Ncm = { 0x0100000000000002ul }; - inline constexpr const ProgramId ProgramId::Pm = { 0x0100000000000003ul }; - inline constexpr const ProgramId ProgramId::Sm = { 0x0100000000000004ul }; - inline constexpr const ProgramId ProgramId::Boot = { 0x0100000000000005ul }; - inline constexpr const ProgramId ProgramId::Usb = { 0x0100000000000006ul }; - inline constexpr const ProgramId ProgramId::Tma = { 0x0100000000000007ul }; - inline constexpr const ProgramId ProgramId::Boot2 = { 0x0100000000000008ul }; - inline constexpr const ProgramId ProgramId::Settings = { 0x0100000000000009ul }; - inline constexpr const ProgramId ProgramId::Bus = { 0x010000000000000Aul }; - inline constexpr const ProgramId ProgramId::Bluetooth = { 0x010000000000000Bul }; - inline constexpr const ProgramId ProgramId::Bcat = { 0x010000000000000Cul }; - inline constexpr const ProgramId ProgramId::Dmnt = { 0x010000000000000Dul }; - inline constexpr const ProgramId ProgramId::Friends = { 0x010000000000000Eul }; - inline constexpr const ProgramId ProgramId::Nifm = { 0x010000000000000Ful }; - inline constexpr const ProgramId ProgramId::Ptm = { 0x0100000000000010ul }; - inline constexpr const ProgramId ProgramId::Shell = { 0x0100000000000011ul }; - inline constexpr const ProgramId ProgramId::BsdSockets = { 0x0100000000000012ul }; - inline constexpr const ProgramId ProgramId::Hid = { 0x0100000000000013ul }; - inline constexpr const ProgramId ProgramId::Audio = { 0x0100000000000014ul }; - inline constexpr const ProgramId ProgramId::LogManager = { 0x0100000000000015ul }; - inline constexpr const ProgramId ProgramId::Wlan = { 0x0100000000000016ul }; - inline constexpr const ProgramId ProgramId::Cs = { 0x0100000000000017ul }; - inline constexpr const ProgramId ProgramId::Ldn = { 0x0100000000000018ul }; - inline constexpr const ProgramId ProgramId::NvServices = { 0x0100000000000019ul }; - inline constexpr const ProgramId ProgramId::Pcv = { 0x010000000000001Aul }; - inline constexpr const ProgramId ProgramId::Ppc = { 0x010000000000001Bul }; - inline constexpr const ProgramId ProgramId::NvnFlinger = { 0x010000000000001Cul }; - inline constexpr const ProgramId ProgramId::Pcie = { 0x010000000000001Dul }; - inline constexpr const ProgramId ProgramId::Account = { 0x010000000000001Eul }; - inline constexpr const ProgramId ProgramId::Ns = { 0x010000000000001Ful }; - inline constexpr const ProgramId ProgramId::Nfc = { 0x0100000000000020ul }; - inline constexpr const ProgramId ProgramId::Psc = { 0x0100000000000021ul }; - inline constexpr const ProgramId ProgramId::CapSrv = { 0x0100000000000022ul }; - inline constexpr const ProgramId ProgramId::Am = { 0x0100000000000023ul }; - inline constexpr const ProgramId ProgramId::Ssl = { 0x0100000000000024ul }; - inline constexpr const ProgramId ProgramId::Nim = { 0x0100000000000025ul }; - inline constexpr const ProgramId ProgramId::Cec = { 0x0100000000000026ul }; - inline constexpr const ProgramId ProgramId::Tspm = { 0x0100000000000027ul }; - inline constexpr const ProgramId ProgramId::Spl = { 0x0100000000000028ul }; - inline constexpr const ProgramId ProgramId::Lbl = { 0x0100000000000029ul }; - inline constexpr const ProgramId ProgramId::Btm = { 0x010000000000002Aul }; - inline constexpr const ProgramId ProgramId::Erpt = { 0x010000000000002Bul }; - inline constexpr const ProgramId ProgramId::Time = { 0x010000000000002Cul }; - inline constexpr const ProgramId ProgramId::Vi = { 0x010000000000002Dul }; - inline constexpr const ProgramId ProgramId::Pctl = { 0x010000000000002Eul }; - inline constexpr const ProgramId ProgramId::Npns = { 0x010000000000002Ful }; - inline constexpr const ProgramId ProgramId::Eupld = { 0x0100000000000030ul }; - inline constexpr const ProgramId ProgramId::Arp = { 0x0100000000000031ul }; - inline constexpr const ProgramId ProgramId::Glue = { 0x0100000000000031ul }; - inline constexpr const ProgramId ProgramId::Eclct = { 0x0100000000000032ul }; - inline constexpr const ProgramId ProgramId::Es = { 0x0100000000000033ul }; - inline constexpr const ProgramId ProgramId::Fatal = { 0x0100000000000034ul }; - inline constexpr const ProgramId ProgramId::Grc = { 0x0100000000000035ul }; - inline constexpr const ProgramId ProgramId::Creport = { 0x0100000000000036ul }; - inline constexpr const ProgramId ProgramId::Ro = { 0x0100000000000037ul }; - inline constexpr const ProgramId ProgramId::Profiler = { 0x0100000000000038ul }; - inline constexpr const ProgramId ProgramId::Sdb = { 0x0100000000000039ul }; - inline constexpr const ProgramId ProgramId::Migration = { 0x010000000000003Aul }; - inline constexpr const ProgramId ProgramId::Jit = { 0x010000000000003Bul }; - inline constexpr const ProgramId ProgramId::JpegDec = { 0x010000000000003Cul }; - inline constexpr const ProgramId ProgramId::SafeMode = { 0x010000000000003Dul }; - inline constexpr const ProgramId ProgramId::Olsc = { 0x010000000000003Eul }; - inline constexpr const ProgramId ProgramId::Dt = { 0x010000000000003Ful }; - inline constexpr const ProgramId ProgramId::Nd = { 0x0100000000000040ul }; - inline constexpr const ProgramId ProgramId::Ngct = { 0x0100000000000041ul }; - - inline constexpr const ProgramId ProgramId::SystemEnd = { 0x01000000000007FFul }; - - /* System Data Archives. */ - inline constexpr const ProgramId ProgramId::ArchiveStart = { 0x0100000000000800ul }; - inline constexpr const ProgramId ProgramId::ArchiveCertStore = { 0x0100000000000800ul }; - inline constexpr const ProgramId ProgramId::ArchiveErrorMessage = { 0x0100000000000801ul }; - inline constexpr const ProgramId ProgramId::ArchiveMiiModel = { 0x0100000000000802ul }; - inline constexpr const ProgramId ProgramId::ArchiveBrowserDll = { 0x0100000000000803ul }; - inline constexpr const ProgramId ProgramId::ArchiveHelp = { 0x0100000000000804ul }; - inline constexpr const ProgramId ProgramId::ArchiveSharedFont = { 0x0100000000000805ul }; - inline constexpr const ProgramId ProgramId::ArchiveNgWord = { 0x0100000000000806ul }; - inline constexpr const ProgramId ProgramId::ArchiveSsidList = { 0x0100000000000807ul }; - inline constexpr const ProgramId ProgramId::ArchiveDictionary = { 0x0100000000000808ul }; - inline constexpr const ProgramId ProgramId::ArchiveSystemVersion = { 0x0100000000000809ul }; - inline constexpr const ProgramId ProgramId::ArchiveAvatarImage = { 0x010000000000080Aul }; - inline constexpr const ProgramId ProgramId::ArchiveLocalNews = { 0x010000000000080Bul }; - inline constexpr const ProgramId ProgramId::ArchiveEula = { 0x010000000000080Cul }; - inline constexpr const ProgramId ProgramId::ArchiveUrlBlackList = { 0x010000000000080Dul }; - inline constexpr const ProgramId ProgramId::ArchiveTimeZoneBinar = { 0x010000000000080Eul }; - inline constexpr const ProgramId ProgramId::ArchiveCertStoreCruiser = { 0x010000000000080Ful }; - inline constexpr const ProgramId ProgramId::ArchiveFontNintendoExtension = { 0x0100000000000810ul }; - inline constexpr const ProgramId ProgramId::ArchiveFontStandard = { 0x0100000000000811ul }; - inline constexpr const ProgramId ProgramId::ArchiveFontKorean = { 0x0100000000000812ul }; - inline constexpr const ProgramId ProgramId::ArchiveFontChineseTraditional = { 0x0100000000000813ul }; - inline constexpr const ProgramId ProgramId::ArchiveFontChineseSimple = { 0x0100000000000814ul }; - inline constexpr const ProgramId ProgramId::ArchiveFontBfcpx = { 0x0100000000000815ul }; - inline constexpr const ProgramId ProgramId::ArchiveSystemUpdate = { 0x0100000000000816ul }; - - inline constexpr const ProgramId ProgramId::ArchiveFirmwareDebugSettings = { 0x0100000000000818ul }; - inline constexpr const ProgramId ProgramId::ArchiveBootImagePackage = { 0x0100000000000819ul }; - inline constexpr const ProgramId ProgramId::ArchiveBootImagePackageSafe = { 0x010000000000081Aul }; - inline constexpr const ProgramId ProgramId::ArchiveBootImagePackageExFat = { 0x010000000000081Bul }; - inline constexpr const ProgramId ProgramId::ArchiveBootImagePackageExFatSafe = { 0x010000000000081Cul }; - inline constexpr const ProgramId ProgramId::ArchiveFatalMessage = { 0x010000000000081Dul }; - inline constexpr const ProgramId ProgramId::ArchiveControllerIcon = { 0x010000000000081Eul }; - inline constexpr const ProgramId ProgramId::ArchivePlatformConfigIcosa = { 0x010000000000081Ful }; - inline constexpr const ProgramId ProgramId::ArchivePlatformConfigCopper = { 0x0100000000000820ul }; - inline constexpr const ProgramId ProgramId::ArchivePlatformConfigHoag = { 0x0100000000000821ul }; - inline constexpr const ProgramId ProgramId::ArchiveControllerFirmware = { 0x0100000000000822ul }; - inline constexpr const ProgramId ProgramId::ArchiveNgWord2 = { 0x0100000000000823ul }; - inline constexpr const ProgramId ProgramId::ArchivePlatformConfigIcosaMariko = { 0x0100000000000824ul }; - inline constexpr const ProgramId ProgramId::ArchiveApplicationBlackList = { 0x0100000000000825ul }; - inline constexpr const ProgramId ProgramId::ArchiveRebootlessSystemUpdateVersion = { 0x0100000000000826ul }; - inline constexpr const ProgramId ProgramId::ArchiveContentActionTable = { 0x0100000000000827ul }; - - inline constexpr const ProgramId ProgramId::ArchiveEnd = { 0x0100000000000FFFul }; - - /* System Applets. */ - inline constexpr const ProgramId ProgramId::AppletStart = { 0x0100000000001000ul }; - - inline constexpr const ProgramId ProgramId::AppletQlaunch = { 0x0100000000001000ul }; - inline constexpr const ProgramId ProgramId::AppletAuth = { 0x0100000000001001ul }; - inline constexpr const ProgramId ProgramId::AppletCabinet = { 0x0100000000001002ul }; - inline constexpr const ProgramId ProgramId::AppletController = { 0x0100000000001003ul }; - inline constexpr const ProgramId ProgramId::AppletDataErase = { 0x0100000000001004ul }; - inline constexpr const ProgramId ProgramId::AppletError = { 0x0100000000001005ul }; - inline constexpr const ProgramId ProgramId::AppletNetConnect = { 0x0100000000001006ul }; - inline constexpr const ProgramId ProgramId::AppletPlayerSelect = { 0x0100000000001007ul }; - inline constexpr const ProgramId ProgramId::AppletSwkbd = { 0x0100000000001008ul }; - inline constexpr const ProgramId ProgramId::AppletMiiEdit = { 0x0100000000001009ul }; - inline constexpr const ProgramId ProgramId::AppletWeb = { 0x010000000000100Aul }; - inline constexpr const ProgramId ProgramId::AppletShop = { 0x010000000000100Bul }; - inline constexpr const ProgramId ProgramId::AppletOverlayDisp = { 0x010000000000100Cul }; - inline constexpr const ProgramId ProgramId::AppletPhotoViewer = { 0x010000000000100Dul }; - inline constexpr const ProgramId ProgramId::AppletSet = { 0x010000000000100Eul }; - inline constexpr const ProgramId ProgramId::AppletOfflineWeb = { 0x010000000000100Ful }; - inline constexpr const ProgramId ProgramId::AppletLoginShare = { 0x0100000000001010ul }; - inline constexpr const ProgramId ProgramId::AppletWifiWebAuth = { 0x0100000000001011ul }; - inline constexpr const ProgramId ProgramId::AppletStarter = { 0x0100000000001012ul }; - inline constexpr const ProgramId ProgramId::AppletMyPage = { 0x0100000000001013ul }; - inline constexpr const ProgramId ProgramId::AppletPlayReport = { 0x0100000000001014ul }; - inline constexpr const ProgramId ProgramId::AppletMaintenanceMenu = { 0x0100000000001015ul }; - - inline constexpr const ProgramId ProgramId::AppletGift = { 0x010000000000101Aul }; - inline constexpr const ProgramId ProgramId::AppletDummyShop = { 0x010000000000101Bul }; - inline constexpr const ProgramId ProgramId::AppletUserMigration = { 0x010000000000101Cul }; - inline constexpr const ProgramId ProgramId::AppletEncounter = { 0x010000000000101Dul }; - - inline constexpr const ProgramId ProgramId::AppletStory = { 0x0100000000001020ul }; - - inline constexpr const ProgramId ProgramId::AppletEnd = { 0x0100000000001FFFul }; - - /* Debug Applets. */ - - /* Debug Modules. */ - - /* Factory Setup. */ - - /* Applications. */ - inline constexpr const ProgramId ProgramId::ApplicationStart = { 0x0100000000010000ul }; - inline constexpr const ProgramId ProgramId::ApplicationEnd = { 0x01FFFFFFFFFFFFFFul }; - - /* Atmosphere Extensions. */ - inline constexpr const ProgramId ProgramId::AtmosphereMitm = { 0x010041544D530000ul }; - - inline constexpr bool operator==(const ProgramId &lhs, const ProgramId &rhs) { - return lhs.value == rhs.value; - } - - inline constexpr bool operator!=(const ProgramId &lhs, const ProgramId &rhs) { - return lhs.value != rhs.value; - } - - inline constexpr bool operator<(const ProgramId &lhs, const ProgramId &rhs) { - return lhs.value < rhs.value; - } - - inline constexpr bool operator<=(const ProgramId &lhs, const ProgramId &rhs) { - return lhs.value <= rhs.value; - } - - inline constexpr bool operator>(const ProgramId &lhs, const ProgramId &rhs) { - return lhs.value > rhs.value; - } - - inline constexpr bool operator>=(const ProgramId &lhs, const ProgramId &rhs) { - return lhs.value >= rhs.value; - } - - inline constexpr bool IsSystemProgramId(const ProgramId &program_id) { - return ProgramId::SystemStart <= program_id && program_id <= ProgramId::SystemEnd; - } - - inline constexpr bool IsArchiveProgramId(const ProgramId &program_id) { - return ProgramId::ArchiveStart <= program_id && program_id <= ProgramId::ArchiveEnd; - } - - inline constexpr bool IsAppletProgramId(const ProgramId &program_id) { - return ProgramId::AppletStart <= program_id && program_id <= ProgramId::AppletEnd; - } - - inline constexpr bool IsApplicationProgramId(const ProgramId &program_id) { - return ProgramId::ApplicationStart <= program_id && program_id <= ProgramId::ApplicationEnd; - } - - inline constexpr bool IsWebAppletProgramId(const ProgramId &program_id) { - return program_id == ProgramId::AppletWeb || - program_id == ProgramId::AppletShop || - program_id == ProgramId::AppletOfflineWeb || - program_id == ProgramId::AppletLoginShare || - program_id == ProgramId::AppletWifiWebAuth; - } - - static_assert(sizeof(ProgramId) == sizeof(u64) && std::is_pod::value, "ProgramId definition!"); - - /* Program Location. */ - struct ProgramLocation { - ProgramId program_id; - u8 storage_id; - - static constexpr ProgramLocation Make(ProgramId program_id, StorageId storage_id) { - return { .program_id = program_id, .storage_id = static_cast(storage_id), }; - } - }; - - static_assert(sizeof(ProgramLocation) == 0x10 && std::is_pod::value, "ProgramLocation definition!"); - static_assert(sizeof(ProgramLocation) == sizeof(::NcmProgramLocation) && alignof(ProgramLocation) == alignof(::NcmProgramLocation), "ProgramLocation Libnx Compatibility"); - -} diff --git a/stratosphere/libstratosphere/include/stratosphere/os.hpp b/stratosphere/libstratosphere/include/stratosphere/os.hpp deleted file mode 100644 index 21e54e43d..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/os.hpp +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once - -#include "os/os_common_types.hpp" -#include "os/os_memory_common.hpp" -#include "os/os_managed_handle.hpp" -#include "os/os_process_handle.hpp" -#include "os/os_mutex.hpp" -#include "os/os_condvar.hpp" -#include "os/os_rw_lock.hpp" -#include "os/os_semaphore.hpp" -#include "os/os_timeout_helper.hpp" -#include "os/os_event.hpp" -#include "os/os_system_event.hpp" -#include "os/os_interrupt_event.hpp" -#include "os/os_thread.hpp" -#include "os/os_message_queue.hpp" -#include "os/os_waitable_holder.hpp" -#include "os/os_waitable_manager.hpp" diff --git a/stratosphere/libstratosphere/include/stratosphere/os/os_common_types.hpp b/stratosphere/libstratosphere/include/stratosphere/os/os_common_types.hpp deleted file mode 100644 index dc10018a2..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/os/os_common_types.hpp +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -#pragma once -#include - -namespace ams::os { - - enum class TriBool { - False = 0, - True = 1, - Undefined = 2, - }; - - enum class MessageQueueWaitKind { - ForNotEmpty, - ForNotFull, - }; - - struct ProcessId { - u64 value; - - inline constexpr explicit operator u64() const { - return this->value; - } - - /* Invalid Process ID. */ - static const ProcessId Invalid; - }; - - inline constexpr const ProcessId ProcessId::Invalid = {static_cast(-1ull)}; - - inline constexpr const ProcessId InvalidProcessId = ProcessId::Invalid; - - NX_INLINE Result TryGetProcessId(os::ProcessId *out, ::Handle process_handle) { - return svcGetProcessId(&out->value, process_handle); - } - - NX_INLINE os::ProcessId GetProcessId(::Handle process_handle) { - os::ProcessId process_id; - R_ASSERT(TryGetProcessId(&process_id, process_handle)); - return process_id; - } - - inline constexpr bool operator==(const ProcessId &lhs, const ProcessId &rhs) { - return lhs.value == rhs.value; - } - - inline constexpr bool operator!=(const ProcessId &lhs, const ProcessId &rhs) { - return lhs.value != rhs.value; - } - - inline constexpr bool operator<(const ProcessId &lhs, const ProcessId &rhs) { - return lhs.value < rhs.value; - } - - inline constexpr bool operator<=(const ProcessId &lhs, const ProcessId &rhs) { - return lhs.value <= rhs.value; - } - - inline constexpr bool operator>(const ProcessId &lhs, const ProcessId &rhs) { - return lhs.value > rhs.value; - } - - inline constexpr bool operator>=(const ProcessId &lhs, const ProcessId &rhs) { - return lhs.value >= rhs.value; - } - -} diff --git a/stratosphere/libstratosphere/include/stratosphere/os/os_condvar.hpp b/stratosphere/libstratosphere/include/stratosphere/os/os_condvar.hpp deleted file mode 100644 index 26b18bf5c..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/os/os_condvar.hpp +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include "os_mutex.hpp" - -namespace ams::os { - - enum class ConditionVariableStatus { - TimedOut = 0, - Success = 1, - }; - - class ConditionVariable { - NON_COPYABLE(ConditionVariable); - NON_MOVEABLE(ConditionVariable); - private: - CondVar cv; - public: - ConditionVariable() { - condvarInit(&cv); - } - - ConditionVariableStatus TimedWait(::Mutex *m, u64 timeout) { - if (timeout > 0) { - /* Abort on any error other than timed out/success. */ - R_TRY_CATCH(condvarWaitTimeout(&this->cv, m, timeout)) { - R_CATCH(svc::ResultTimedOut) { return ConditionVariableStatus::TimedOut; } - } R_END_TRY_CATCH_WITH_ASSERT; - - return ConditionVariableStatus::Success; - } - return ConditionVariableStatus::TimedOut; - } - - void Wait(::Mutex *m) { - R_ASSERT(condvarWait(&this->cv, m)); - } - - ConditionVariableStatus TimedWait(os::Mutex *m, u64 timeout) { - return this->TimedWait(m->GetMutex(), timeout); - } - - void Wait(os::Mutex *m) { - return this->Wait(m->GetMutex()); - } - - void Signal() { - condvarWakeOne(&this->cv); - } - - void Broadcast() { - condvarWakeAll(&this->cv); - } - }; - -} \ No newline at end of file diff --git a/stratosphere/libstratosphere/include/stratosphere/os/os_event.hpp b/stratosphere/libstratosphere/include/stratosphere/os/os_event.hpp deleted file mode 100644 index b19ce3a69..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/os/os_event.hpp +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include "os_mutex.hpp" -#include "os_condvar.hpp" -#include "os_timeout_helper.hpp" - -namespace ams::os { - - namespace impl { - - class WaitableObjectList; - class WaitableHolderOfEvent; - - } - - class Event { - friend class impl::WaitableHolderOfEvent; - NON_COPYABLE(Event); - NON_MOVEABLE(Event); - private: - util::TypedStorage waitable_object_list_storage; - Mutex lock; - ConditionVariable cv; - u64 counter = 0; - bool auto_clear; - bool signaled; - public: - Event(bool a = true, bool s = false); - ~Event(); - - void Signal(); - void Reset(); - void Wait(); - bool TryWait(); - bool TimedWait(u64 ns); - }; - -} diff --git a/stratosphere/libstratosphere/include/stratosphere/os/os_interrupt_event.hpp b/stratosphere/libstratosphere/include/stratosphere/os/os_interrupt_event.hpp deleted file mode 100644 index ccfd97910..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/os/os_interrupt_event.hpp +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include "os_managed_handle.hpp" - -namespace ams::os { - - namespace impl { - - class WaitableHolderOfInterruptEvent; - - } - - class InterruptEvent { - friend class impl::WaitableHolderOfInterruptEvent; - NON_COPYABLE(InterruptEvent); - NON_MOVEABLE(InterruptEvent); - private: - ManagedHandle handle; - bool auto_clear; - bool is_initialized; - public: - InterruptEvent() : auto_clear(true), is_initialized(false) { } - InterruptEvent(u32 interrupt_id, bool autoclear = true); - - Result Initialize(u32 interrupt_id, bool autoclear = true); - void Finalize(); - - void Reset(); - void Wait(); - bool TryWait(); - bool TimedWait(u64 ns); - }; - -} diff --git a/stratosphere/libstratosphere/include/stratosphere/os/os_managed_handle.hpp b/stratosphere/libstratosphere/include/stratosphere/os/os_managed_handle.hpp deleted file mode 100644 index 72ecda111..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/os/os_managed_handle.hpp +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include "os_common_types.hpp" - -namespace ams::os { - - class ManagedHandle { - NON_COPYABLE(ManagedHandle); - private: - Handle hnd; - public: - ManagedHandle() : hnd(INVALID_HANDLE) { /* ... */ } - ManagedHandle(Handle h) : hnd(h) { /* ... */ } - ~ManagedHandle() { - if (this->hnd != INVALID_HANDLE) { - R_ASSERT(svcCloseHandle(this->hnd)); - this->hnd = INVALID_HANDLE; - } - } - - ManagedHandle(ManagedHandle&& rhs) { - this->hnd = rhs.hnd; - rhs.hnd = INVALID_HANDLE; - } - - ManagedHandle& operator=(ManagedHandle&& rhs) { - rhs.Swap(*this); - return *this; - } - - explicit operator bool() const { - return this->hnd != INVALID_HANDLE; - } - - void Swap(ManagedHandle& rhs) { - std::swap(this->hnd, rhs.hnd); - } - - Handle Get() const { - return this->hnd; - } - - Handle *GetPointer() { - return &this->hnd; - } - - Handle *GetPointerAndClear() { - this->Clear(); - return this->GetPointer(); - } - - Handle Move() { - const Handle h = this->hnd; - this->hnd = INVALID_HANDLE; - return h; - } - - void Reset(Handle h) { - ManagedHandle(h).Swap(*this); - } - - void Clear() { - this->Reset(INVALID_HANDLE); - } - }; - -} diff --git a/stratosphere/libstratosphere/include/stratosphere/os/os_memory_common.hpp b/stratosphere/libstratosphere/include/stratosphere/os/os_memory_common.hpp deleted file mode 100644 index d267cbb65..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/os/os_memory_common.hpp +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -#pragma once -#include - -namespace ams::os { - - constexpr inline size_t MemoryPageSize = 0x1000; - - constexpr inline size_t MemoryBlockUnitSize = 0x200000; - -} diff --git a/stratosphere/libstratosphere/include/stratosphere/os/os_message_queue.hpp b/stratosphere/libstratosphere/include/stratosphere/os/os_message_queue.hpp deleted file mode 100644 index ab0733e34..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/os/os_message_queue.hpp +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include "os_mutex.hpp" -#include "os_condvar.hpp" - -namespace ams::os { - - namespace impl { - - class WaitableObjectList; - - template - class WaitableHolderOfMessageQueue; - - } - - class MessageQueue { - template - friend class impl::WaitableHolderOfMessageQueue; - NON_COPYABLE(MessageQueue); - NON_MOVEABLE(MessageQueue); - private: - util::TypedStorage waitlist_not_empty; - util::TypedStorage waitlist_not_full; - Mutex queue_lock; - ConditionVariable cv_not_full; - ConditionVariable cv_not_empty; - std::unique_ptr buffer; - size_t capacity; - - size_t count; - size_t offset; - private: - constexpr inline bool IsFull() const { - return this->count >= this->capacity; - } - - constexpr inline bool IsEmpty() const { - return this->count == 0; - } - - void SendInternal(uintptr_t data); - void SendNextInternal(uintptr_t data); - uintptr_t ReceiveInternal(); - uintptr_t PeekInternal(); - public: - MessageQueue(std::unique_ptr buf, size_t c); - ~MessageQueue(); - - /* For convenience. */ - MessageQueue(size_t c) : MessageQueue(std::make_unique(c), c) { /* ... */ } - - /* Sending (FIFO functionality) */ - void Send(uintptr_t data); - bool TrySend(uintptr_t data); - bool TimedSend(uintptr_t data, u64 timeout); - - /* Sending (LIFO functionality) */ - void SendNext(uintptr_t data); - bool TrySendNext(uintptr_t data); - bool TimedSendNext(uintptr_t data, u64 timeout); - - /* Receive functionality */ - void Receive(uintptr_t *out); - bool TryReceive(uintptr_t *out); - bool TimedReceive(uintptr_t *out, u64 timeout); - - /* Peek functionality */ - void Peek(uintptr_t *out); - bool TryPeek(uintptr_t *out); - bool TimedPeek(uintptr_t *out, u64 timeout); - }; - -} diff --git a/stratosphere/libstratosphere/include/stratosphere/os/os_mutex.hpp b/stratosphere/libstratosphere/include/stratosphere/os/os_mutex.hpp deleted file mode 100644 index 26ba66c2e..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/os/os_mutex.hpp +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include "os_common_types.hpp" - -namespace ams::os { - - class ConditionVariable; - - class Mutex { - NON_COPYABLE(Mutex); - NON_MOVEABLE(Mutex); - friend class ams::os::ConditionVariable; - private: - ::Mutex m; - private: - ::Mutex *GetMutex() { - return &this->m; - } - public: - Mutex() { - mutexInit(GetMutex()); - } - - void lock() { - mutexLock(GetMutex()); - } - - void unlock() { - mutexUnlock(GetMutex()); - } - - bool try_lock() { - return mutexTryLock(GetMutex()); - } - - void Lock() { - lock(); - } - - void Unlock() { - unlock(); - } - - bool TryLock() { - return try_lock(); - } - }; - - class RecursiveMutex { - private: - ::RMutex m; - private: - ::RMutex *GetMutex() { - return &this->m; - } - public: - RecursiveMutex() { - rmutexInit(GetMutex()); - } - - void lock() { - rmutexLock(GetMutex()); - } - - void unlock() { - rmutexUnlock(GetMutex()); - } - - bool try_lock() { - return rmutexTryLock(GetMutex()); - } - - void Lock() { - lock(); - } - - void Unlock() { - unlock(); - } - - bool TryLock() { - return try_lock(); - } - }; - -} \ No newline at end of file diff --git a/stratosphere/libstratosphere/include/stratosphere/os/os_process_handle.hpp b/stratosphere/libstratosphere/include/stratosphere/os/os_process_handle.hpp deleted file mode 100644 index 1b5eac0a6..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/os/os_process_handle.hpp +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include "os_managed_handle.hpp" - -namespace ams::os { - - ::Handle GetCurrentProcessHandle(); - - NX_INLINE ProcessId GetCurrentProcessId() { - return GetProcessId(GetCurrentProcessHandle()); - } - -} diff --git a/stratosphere/libstratosphere/include/stratosphere/os/os_rw_lock.hpp b/stratosphere/libstratosphere/include/stratosphere/os/os_rw_lock.hpp deleted file mode 100644 index 674d056ee..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/os/os_rw_lock.hpp +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include "os_common_types.hpp" - -namespace ams::os { - - class ReadWriteLock { - NON_COPYABLE(ReadWriteLock); - NON_MOVEABLE(ReadWriteLock); - private: - ::RwLock r; - public: - ReadWriteLock() { - rwlockInit(&this->r); - } - - bool IsWriteLockHeldByCurrentThread() const { - return rwlockIsWriteLockHeldByCurrentThread(const_cast<::RwLock *>(&this->r)); - } - - bool IsLockOwner() const { - return rwlockIsOwnedByCurrentThread(const_cast<::RwLock *>(&this->r)); - } - - void AcquireReadLock() { - rwlockReadLock(&this->r); - } - - void ReleaseReadLock() { - rwlockReadUnlock(&this->r); - } - - bool TryAcquireReadLock() { - return rwlockTryReadLock(&this->r); - } - - void AcquireWriteLock() { - rwlockWriteLock(&this->r); - } - - void ReleaseWriteLock() { - rwlockWriteUnlock(&this->r); - } - - bool TryAcquireWriteLock() { - return rwlockTryWriteLock(&this->r); - } - - void lock_shared() { - this->AcquireReadLock(); - } - - void unlock_shared() { - this->ReleaseReadLock(); - } - - bool try_lock_shared() { - return this->TryAcquireReadLock(); - } - - void lock() { - this->AcquireWriteLock(); - } - - void unlock() { - this->ReleaseWriteLock(); - } - - bool try_lock() { - return this->TryAcquireWriteLock(); - } - }; - -} \ No newline at end of file diff --git a/stratosphere/libstratosphere/include/stratosphere/os/os_semaphore.hpp b/stratosphere/libstratosphere/include/stratosphere/os/os_semaphore.hpp deleted file mode 100644 index 0941ce5cb..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/os/os_semaphore.hpp +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include "os_mutex.hpp" -#include "os_condvar.hpp" - -namespace ams::os { - - namespace impl { - - class WaitableObjectList; - class WaitableHolderOfSemaphore; - - } - - class Semaphore { - friend class impl::WaitableHolderOfSemaphore; - NON_COPYABLE(Semaphore); - NON_MOVEABLE(Semaphore); - private: - util::TypedStorage waitlist; - os::Mutex mutex; - os::ConditionVariable condvar; - int count; - int max_count; - public: - explicit Semaphore(int c, int mc); - ~Semaphore(); - - void Acquire(); - bool TryAcquire(); - bool TimedAcquire(u64 timeout); - - void Release(); - void Release(int count); - - constexpr inline int GetCurrentCount() const { - return this->count; - } - }; - -} diff --git a/stratosphere/libstratosphere/include/stratosphere/os/os_system_event.hpp b/stratosphere/libstratosphere/include/stratosphere/os/os_system_event.hpp deleted file mode 100644 index 290bfe52c..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/os/os_system_event.hpp +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include "os_event.hpp" - -namespace ams::os { - - class WaitableHolder; - - namespace impl { - - class InterProcessEvent; - - } - - enum class SystemEventState { - Uninitialized, - Event, - InterProcessEvent, - }; - - class SystemEvent { - friend class WaitableHolder; - NON_COPYABLE(SystemEvent); - NON_MOVEABLE(SystemEvent); - private: - union { - util::TypedStorage storage_for_event; - util::TypedStorage storage_for_inter_process_event; - }; - SystemEventState state; - private: - Event &GetEvent(); - const Event &GetEvent() const; - impl::InterProcessEvent &GetInterProcessEvent(); - const impl::InterProcessEvent &GetInterProcessEvent() const; - public: - SystemEvent() : state(SystemEventState::Uninitialized) { /* ... */ } - SystemEvent(bool inter_process, bool autoclear = true); - SystemEvent(Handle read_handle, bool manage_read_handle, Handle write_handle, bool manage_write_handle, bool autoclear = true); - SystemEvent(Handle read_handle, bool manage_read_handle, bool autoclear = true) : SystemEvent(read_handle, manage_read_handle, INVALID_HANDLE, false, autoclear) { /* ... */ } - ~SystemEvent(); - - Result InitializeAsEvent(bool autoclear = true); - Result InitializeAsInterProcessEvent(bool autoclear = true); - void AttachHandles(Handle read_handle, bool manage_read_handle, Handle write_handle, bool manage_write_handle, bool autoclear = true); - void AttachReadableHandle(Handle read_handle, bool manage_read_handle, bool autoclear = true); - void AttachWritableHandle(Handle write_handle, bool manage_write_handle, bool autoclear = true); - Handle DetachReadableHandle(); - Handle DetachWritableHandle(); - Handle GetReadableHandle() const; - Handle GetWritableHandle() const; - void Finalize(); - - SystemEventState GetState() const { - return this->state; - } - - void Signal(); - void Reset(); - void Wait(); - bool TryWait(); - bool TimedWait(u64 ns); - }; - -} diff --git a/stratosphere/libstratosphere/include/stratosphere/os/os_thread.hpp b/stratosphere/libstratosphere/include/stratosphere/os/os_thread.hpp deleted file mode 100644 index a3e809e0b..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/os/os_thread.hpp +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include "os_common_types.hpp" -#include "os_memory_common.hpp" - -namespace ams::os { - - class Thread { - NON_COPYABLE(Thread); - NON_MOVEABLE(Thread); - private: - ::Thread thr; - public: - constexpr Thread() : thr{} { /* ... */ } - - Result Initialize(ThreadFunc entry, void *arg, void *stack_mem, size_t stack_sz, int prio, int cpuid = -2) { - return threadCreate(&this->thr, entry, arg, stack_mem, stack_sz, prio, cpuid); - } - - Result Initialize(ThreadFunc entry, void *arg, size_t stack_sz, int prio, int cpuid = -2) { - return threadCreate(&this->thr, entry, arg, nullptr, stack_sz, prio, cpuid); - } - - Handle GetHandle() const { - return this->thr.handle; - } - - Result Start() { - return threadStart(&this->thr); - } - - Result Wait() { - return threadWaitForExit(&this->thr); - } - - Result Join() { - R_TRY(threadWaitForExit(&this->thr)); - R_TRY(threadClose(&this->thr)); - return ResultSuccess(); - } - - Result CancelSynchronization() { - return svcCancelSynchronization(this->thr.handle); - } - }; - - template - class StaticThread { - NON_COPYABLE(StaticThread); - NON_MOVEABLE(StaticThread); - static_assert(util::IsAligned(StackSize, os::MemoryPageSize), "StaticThread must have aligned resource size"); - private: - alignas(os::MemoryPageSize) u8 stack_mem[StackSize]; - ::Thread thr; - public: - constexpr StaticThread() : stack_mem{}, thr{} { /* ... */ } - - constexpr StaticThread(ThreadFunc entry, void *arg, int prio, int cpuid = -2) : StaticThread() { - R_ASSERT(this->Initialize(entry, arg, prio, cpuid)); - } - - Result Initialize(ThreadFunc entry, void *arg, int prio, int cpuid = -2) { - return threadCreate(&this->thr, entry, arg, this->stack_mem, StackSize, prio, cpuid); - } - - Handle GetHandle() const { - return this->thr.handle; - } - - Result Start() { - return threadStart(&this->thr); - } - - Result Wait() { - return threadWaitForExit(&this->thr); - } - - Result Join() { - R_TRY(threadWaitForExit(&this->thr)); - R_TRY(threadClose(&this->thr)); - return ResultSuccess(); - } - - Result CancelSynchronization() { - return svcCancelSynchronization(this->thr.handle); - } - }; - - NX_INLINE u32 GetCurrentThreadPriority() { - u32 prio; - R_ASSERT(svcGetThreadPriority(&prio, CUR_THREAD_HANDLE)); - return prio; - } - -} diff --git a/stratosphere/libstratosphere/include/stratosphere/os/os_timeout_helper.hpp b/stratosphere/libstratosphere/include/stratosphere/os/os_timeout_helper.hpp deleted file mode 100644 index 5f5bf408e..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/os/os_timeout_helper.hpp +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -#pragma once -#include "os_common_types.hpp" - -namespace ams::os { - - class TimeoutHelper { - private: - u64 end_tick; - public: - TimeoutHelper(u64 ns) { - /* Special case zero-time timeouts. */ - if (ns == 0) { - end_tick = 0; - return; - } - - u64 cur_tick = armGetSystemTick(); - this->end_tick = cur_tick + NsToTick(ns) + 1; - } - - static constexpr inline u64 NsToTick(u64 ns) { - return (ns * 12) / 625; - } - - static constexpr inline u64 TickToNs(u64 tick) { - return (tick * 625) / 12; - } - - inline bool TimedOut() const { - if (this->end_tick == 0) { - return true; - } - - return armGetSystemTick() >= this->end_tick; - } - - inline u64 NsUntilTimeout() const { - u64 diff = TickToNs(this->end_tick - armGetSystemTick()); - - if (this->TimedOut()) { - return 0; - } - - return diff; - } - }; - -} diff --git a/stratosphere/libstratosphere/include/stratosphere/os/os_waitable_holder.hpp b/stratosphere/libstratosphere/include/stratosphere/os/os_waitable_holder.hpp deleted file mode 100644 index 03c9dcf0e..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/os/os_waitable_holder.hpp +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -#pragma once -#include "os_common_types.hpp" - -namespace ams::os { - - class WaitableManager; - - class Event; - class SystemEvent; - class InterruptEvent; - class Thread; - class MessageQueue; - class Semaphore; - - namespace impl { - - class WaitableHolderImpl; - - } - - class WaitableHolder { - friend class WaitableManager; - NON_COPYABLE(WaitableHolder); - NON_MOVEABLE(WaitableHolder); - private: - util::TypedStorage impl_storage; - uintptr_t user_data; - public: - static constexpr size_t ImplStorageSize = sizeof(impl_storage); - public: - WaitableHolder(Handle handle); - WaitableHolder(Event *event); - WaitableHolder(SystemEvent *event); - WaitableHolder(InterruptEvent *event); - WaitableHolder(Thread *thread); - WaitableHolder(Semaphore *semaphore); - WaitableHolder(MessageQueue *message_queue, MessageQueueWaitKind wait_kind); - - ~WaitableHolder(); - - void SetUserData(uintptr_t data) { - this->user_data = data; - } - - uintptr_t GetUserData() const { - return this->user_data; - } - - void UnlinkFromWaitableManager(); - }; - -} diff --git a/stratosphere/libstratosphere/include/stratosphere/os/os_waitable_manager.hpp b/stratosphere/libstratosphere/include/stratosphere/os/os_waitable_manager.hpp deleted file mode 100644 index 90e912e14..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/os/os_waitable_manager.hpp +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -#pragma once -#include "os_mutex.hpp" - -namespace ams::os { - - class WaitableHolder; - - namespace impl { - - class WaitableManagerImpl; - - } - - class WaitableManager { - NON_COPYABLE(WaitableManager); - NON_MOVEABLE(WaitableManager); - private: - util::TypedStorage impl_storage; - public: - static constexpr size_t ImplStorageSize = sizeof(impl_storage); - public: - WaitableManager(); - ~WaitableManager(); - - /* Wait. */ - WaitableHolder *WaitAny(); - WaitableHolder *TryWaitAny(); - WaitableHolder *TimedWaitAny(u64 timeout); - - /* Link. */ - void LinkWaitableHolder(WaitableHolder *holder); - void UnlinkAll(); - void MoveAllFrom(WaitableManager *other); - }; - -} diff --git a/stratosphere/libstratosphere/include/stratosphere/patcher.hpp b/stratosphere/libstratosphere/include/stratosphere/patcher.hpp deleted file mode 100644 index deafa05cd..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/patcher.hpp +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once - -#include "patcher/patcher_api.hpp" diff --git a/stratosphere/libstratosphere/include/stratosphere/patcher/patcher_api.hpp b/stratosphere/libstratosphere/include/stratosphere/patcher/patcher_api.hpp deleted file mode 100644 index 16735500f..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/patcher/patcher_api.hpp +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once - -#include "../ro/ro_types.hpp" - -namespace ams::patcher { - - /* Helper for applying to code binaries. */ - void LocateAndApplyIpsPatchesToModule(const char *patch_dir, size_t protected_size, size_t offset, const ro::ModuleId *module_id, u8 *mapped_module, size_t mapped_size); - -} diff --git a/stratosphere/libstratosphere/include/stratosphere/pm.hpp b/stratosphere/libstratosphere/include/stratosphere/pm.hpp deleted file mode 100644 index 7593c5b69..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/pm.hpp +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once - -#include "pm/pm_types.hpp" -#include "pm/pm_boot_mode_api.hpp" -#include "pm/pm_info_api.hpp" -#include "pm/pm_shell_api.hpp" -#include "pm/pm_dmnt_api.hpp" \ No newline at end of file diff --git a/stratosphere/libstratosphere/include/stratosphere/pm/pm_boot_mode_api.hpp b/stratosphere/libstratosphere/include/stratosphere/pm/pm_boot_mode_api.hpp deleted file mode 100644 index 326dc12ee..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/pm/pm_boot_mode_api.hpp +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once - -#include "pm_types.hpp" - -namespace ams::pm::bm { - - /* Boot Mode API. */ - BootMode GetBootMode(); - void SetMaintenanceBoot(); - -} diff --git a/stratosphere/libstratosphere/include/stratosphere/pm/pm_dmnt_api.hpp b/stratosphere/libstratosphere/include/stratosphere/pm/pm_dmnt_api.hpp deleted file mode 100644 index 616e4d9c1..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/pm/pm_dmnt_api.hpp +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once - -#include "../ldr.hpp" -#include "pm_types.hpp" - -namespace ams::pm::dmnt { - - /* Debug Monitor API. */ - Result StartProcess(os::ProcessId process_id); - Result GetProcessId(os::ProcessId *out_process_id, const ncm::ProgramId program_id); - Result GetApplicationProcessId(os::ProcessId *out_process_id); - Result HookToCreateApplicationProcess(Handle *out_handle); - Result AtmosphereGetProcessInfo(Handle *out_handle, ncm::ProgramLocation *out_loc, cfg::OverrideStatus *out_status, os::ProcessId process_id); - Result AtmosphereGetCurrentLimitInfo(u64 *out_current_value, u64 *out_limit_value, ResourceLimitGroup group, LimitableResource resource); - -} diff --git a/stratosphere/libstratosphere/include/stratosphere/pm/pm_info_api.hpp b/stratosphere/libstratosphere/include/stratosphere/pm/pm_info_api.hpp deleted file mode 100644 index 6a56b13df..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/pm/pm_info_api.hpp +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once - -#include "pm_types.hpp" -#include "../ncm/ncm_types.hpp" - -namespace ams::pm::info { - - /* Information API. */ - Result GetProgramId(ncm::ProgramId *out_program_id, os::ProcessId process_id); - Result GetProcessId(os::ProcessId *out_process_id, ncm::ProgramId program_id); - Result HasLaunchedProgram(bool *out, ncm::ProgramId program_id); - - Result GetProcessInfo(ncm::ProgramLocation *out_loc, cfg::OverrideStatus *out_status, os::ProcessId process_id); - - /* Information convenience API. */ - bool HasLaunchedProgram(ncm::ProgramId program_id); - - Result IsHblProcessId(bool *out, os::ProcessId process_id); - Result IsHblProgramId(bool *out, ncm::ProgramId program_id); - -} diff --git a/stratosphere/libstratosphere/include/stratosphere/pm/pm_shell_api.hpp b/stratosphere/libstratosphere/include/stratosphere/pm/pm_shell_api.hpp deleted file mode 100644 index 72ff790ca..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/pm/pm_shell_api.hpp +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once - -#include "../ldr.hpp" -#include "pm_types.hpp" - -namespace ams::pm::shell { - - /* Shell API. */ - Result LaunchProgram(os::ProcessId *out_process_id, const ncm::ProgramLocation &loc, u32 launch_flags); - -} diff --git a/stratosphere/libstratosphere/include/stratosphere/pm/pm_types.hpp b/stratosphere/libstratosphere/include/stratosphere/pm/pm_types.hpp deleted file mode 100644 index a40eee8f3..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/pm/pm_types.hpp +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include "../os/os_common_types.hpp" - -namespace ams::pm { - - enum class BootMode { - Normal = 0, - Maintenance = 1, - SafeMode = 2, - }; - - enum ResourceLimitGroup { - ResourceLimitGroup_System = 0, - ResourceLimitGroup_Application = 1, - ResourceLimitGroup_Applet = 2, - ResourceLimitGroup_Count, - }; - - using LimitableResource = ::LimitableResource; - - struct ProcessEventInfo { - u32 event; - os::ProcessId process_id; - }; - static_assert(sizeof(ProcessEventInfo) == 0x10 && std::is_pod::value, "ProcessEventInfo definition!"); - -} diff --git a/stratosphere/libstratosphere/include/stratosphere/reg.hpp b/stratosphere/libstratosphere/include/stratosphere/reg.hpp deleted file mode 100644 index 001c62827..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/reg.hpp +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include - -namespace ams::reg { - - inline void Write(volatile u32 *reg, u32 val) { - *reg = val; - } - - inline void Write(uintptr_t reg, u32 val) { - Write(reinterpret_cast(reg), val); - } - - inline u32 Read(volatile u32 *reg) { - return *reg; - } - - inline u32 Read(uintptr_t reg) { - return Read(reinterpret_cast(reg)); - } - - inline void SetBits(volatile u32 *reg, u32 mask) { - *reg |= mask; - } - - inline void SetBits(uintptr_t reg, u32 mask) { - SetBits(reinterpret_cast(reg), mask); - } - - inline void ClearBits(volatile u32 *reg, u32 mask) { - *reg &= ~mask; - } - - inline void ClearBits(uintptr_t reg, u32 mask) { - ClearBits(reinterpret_cast(reg), mask); - } - - inline void MaskBits(volatile u32 *reg, u32 mask) { - *reg &= mask; - } - - inline void MaskBits(uintptr_t reg, u32 mask) { - MaskBits(reinterpret_cast(reg), mask); - } - - inline void ReadWrite(volatile u32 *reg, u32 val, u32 mask) { - *reg = (*reg & (~mask)) | (val & mask); - } - - inline void ReadWrite(uintptr_t reg, u32 val, u32 mask) { - ReadWrite(reinterpret_cast(reg), val, mask); - } - -} \ No newline at end of file diff --git a/stratosphere/libstratosphere/include/stratosphere/rnd.hpp b/stratosphere/libstratosphere/include/stratosphere/rnd.hpp deleted file mode 100644 index a11eba7b2..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/rnd.hpp +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once - -#include "rnd/rnd_api.hpp" diff --git a/stratosphere/libstratosphere/include/stratosphere/rnd/rnd_api.hpp b/stratosphere/libstratosphere/include/stratosphere/rnd/rnd_api.hpp deleted file mode 100644 index dcea365cc..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/rnd/rnd_api.hpp +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include - -namespace ams::rnd { - - /* Random utilities. */ - void GenerateRandomBytes(void* out, size_t size); - u32 GenerateRandomU32(u32 max = std::numeric_limits::max()); - u64 GenerateRandomU64(u64 max = std::numeric_limits::max()); - -} diff --git a/stratosphere/libstratosphere/include/stratosphere/ro.hpp b/stratosphere/libstratosphere/include/stratosphere/ro.hpp deleted file mode 100644 index c5835d46a..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/ro.hpp +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once - -#include "ro/ro_types.hpp" diff --git a/stratosphere/libstratosphere/include/stratosphere/ro/ro_types.hpp b/stratosphere/libstratosphere/include/stratosphere/ro/ro_types.hpp deleted file mode 100644 index 4259585e7..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/ro/ro_types.hpp +++ /dev/null @@ -1,150 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include -#include "../ncm/ncm_types.hpp" - -namespace ams::ro { - - enum class ModuleType : u8 { - ForSelf = 0, - ForOthers = 1, - Count - }; - - struct ModuleId { - u8 build_id[0x20]; - }; - static_assert(sizeof(ModuleId) == sizeof(LoaderModuleInfo::build_id), "ModuleId definition!"); - - class NrrHeader { - public: - static constexpr u32 Magic = 0x3052524E; - private: - u32 magic; - u8 reserved_04[0xC]; - u64 program_id_mask; - u64 program_id_pattern; - u8 reserved_20[0x10]; - u8 modulus[0x100]; - u8 fixed_key_signature[0x100]; - u8 nrr_signature[0x100]; - ncm::ProgramId program_id; - u32 size; - u8 type; /* 7.0.0+ */ - u8 reserved_33D[3]; - u32 hashes_offset; - u32 num_hashes; - u8 reserved_348[8]; - public: - bool IsMagicValid() const { - return this->magic == Magic; - } - - bool IsProgramIdValid() const { - return (static_cast(this->program_id) & this->program_id_mask) == this->program_id_pattern; - } - - ModuleType GetType() const { - const ModuleType type = static_cast(this->type); - AMS_ASSERT(type < ModuleType::Count); - return type; - } - - ncm::ProgramId GetProgramId() const { - return this->program_id; - } - - u32 GetSize() const { - return this->size; - } - - u32 GetNumHashes() const { - return this->num_hashes; - } - - uintptr_t GetHashes() const { - return reinterpret_cast(this) + this->hashes_offset; - } - }; - static_assert(sizeof(NrrHeader) == 0x350, "NrrHeader definition!"); - - class NroHeader { - public: - static constexpr u32 Magic = 0x304F524E; - private: - u32 entrypoint_insn; - u32 mod_offset; - u8 reserved_08[0x8]; - u32 magic; - u8 reserved_14[0x4]; - u32 size; - u8 reserved_1C[0x4]; - u32 text_offset; - u32 text_size; - u32 ro_offset; - u32 ro_size; - u32 rw_offset; - u32 rw_size; - u32 bss_size; - u8 reserved_3C[0x4]; - ModuleId module_id; - u8 reserved_60[0x20]; - public: - bool IsMagicValid() const { - return this->magic == Magic; - } - - u32 GetSize() const { - return this->size; - } - - u32 GetTextOffset() const { - return this->text_offset; - } - - u32 GetTextSize() const { - return this->text_size; - } - - u32 GetRoOffset() const { - return this->ro_offset; - } - - u32 GetRoSize() const { - return this->ro_size; - } - - u32 GetRwOffset() const { - return this->rw_offset; - } - - u32 GetRwSize() const { - return this->rw_size; - } - - u32 GetBssSize() const { - return this->bss_size; - } - - const ModuleId *GetModuleId() const { - return &this->module_id; - } - }; - static_assert(sizeof(NroHeader) == 0x80, "NroHeader definition!"); - -} diff --git a/stratosphere/libstratosphere/include/stratosphere/settings.hpp b/stratosphere/libstratosphere/include/stratosphere/settings.hpp deleted file mode 100644 index 66b9bf023..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/settings.hpp +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once - -#include "settings/settings_types.hpp" -#include "settings/settings_fwdbg_types.hpp" -#include "settings/settings_fwdbg_api.hpp" diff --git a/stratosphere/libstratosphere/include/stratosphere/settings/settings_fwdbg_api.hpp b/stratosphere/libstratosphere/include/stratosphere/settings/settings_fwdbg_api.hpp deleted file mode 100644 index 22f118359..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/settings/settings_fwdbg_api.hpp +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include -#include "settings_fwdbg_types.hpp" - -namespace ams::settings::fwdbg { - - bool IsDebugModeEnabled(); - - size_t GetSettingsItemValueSize(const char *name, const char *key); - size_t GetSettingsItemValue(void *dst, size_t dst_size, const char *name, const char *key); - -} diff --git a/stratosphere/libstratosphere/include/stratosphere/settings/settings_fwdbg_types.hpp b/stratosphere/libstratosphere/include/stratosphere/settings/settings_fwdbg_types.hpp deleted file mode 100644 index 0440d5a3f..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/settings/settings_fwdbg_types.hpp +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include -#include "../sf/sf_buffer_tags.hpp" - -namespace ams::settings::fwdbg { - - constexpr size_t SettingsNameLengthMax = 0x40; - constexpr size_t SettingsItemKeyLengthMax = 0x40; - - struct SettingsName : sf::LargeData { - char value[util::AlignUp(SettingsNameLengthMax + 1, alignof(u64))]; - }; - - static_assert(std::is_pod::value && sizeof(SettingsName) > SettingsNameLengthMax); - - struct SettingsItemKey : sf::LargeData { - char value[util::AlignUp(SettingsItemKeyLengthMax + 1, alignof(u64))]; - }; - - static_assert(std::is_pod::value && sizeof(SettingsItemKey) > SettingsItemKeyLengthMax); - -} diff --git a/stratosphere/libstratosphere/include/stratosphere/settings/settings_types.hpp b/stratosphere/libstratosphere/include/stratosphere/settings/settings_types.hpp deleted file mode 100644 index 155a4ce7f..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/settings/settings_types.hpp +++ /dev/null @@ -1,223 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include - -namespace ams::settings { - - enum Language { - Language_Japanese, - Language_AmericanEnglish, - Language_French, - Language_German, - Language_Italian, - Language_Spanish, - Language_Chinese, - Language_Korean, - Language_Dutch, - Language_Portuguese, - Language_Russian, - Language_Taiwanese, - Language_BritishEnglish, - Language_CanadianFrench, - Language_LatinAmericanSpanish, - /* 4.0.0+ */ - Language_SimplifiedChinese, - Language_TraditionalChinese, - - Language_Count, - }; - - struct LanguageCode { - static constexpr size_t MaxLength = 8; - - char name[MaxLength]; - - static constexpr LanguageCode Encode(const char *name, size_t name_size) { - LanguageCode out{}; - for (size_t i = 0; i < MaxLength && i < name_size; i++) { - out.name[i] = name[i]; - } - return out; - } - - static constexpr LanguageCode Encode(const char *name) { - return Encode(name, std::strlen(name)); - } - - template - static constexpr inline LanguageCode EncodeLanguage = [] { - if constexpr (false) { /* ... */ } - #define AMS_MATCH_LANGUAGE(lang, enc) else if constexpr (Lang == Language_##lang) { return LanguageCode::Encode(enc); } - AMS_MATCH_LANGUAGE(Japanese, "ja") - AMS_MATCH_LANGUAGE(AmericanEnglish, "en-US") - AMS_MATCH_LANGUAGE(French, "fr") - AMS_MATCH_LANGUAGE(German, "de") - AMS_MATCH_LANGUAGE(Italian, "it") - AMS_MATCH_LANGUAGE(Spanish, "es") - AMS_MATCH_LANGUAGE(Chinese, "zh-CN") - AMS_MATCH_LANGUAGE(Korean, "ko") - AMS_MATCH_LANGUAGE(Dutch, "nl") - AMS_MATCH_LANGUAGE(Portuguese, "pt") - AMS_MATCH_LANGUAGE(Russian, "ru") - AMS_MATCH_LANGUAGE(Taiwanese, "zh-TW") - AMS_MATCH_LANGUAGE(BritishEnglish, "en-GB") - AMS_MATCH_LANGUAGE(CanadianFrench, "fr-CA") - AMS_MATCH_LANGUAGE(LatinAmericanSpanish, "es-419") - /* 4.0.0+ */ - AMS_MATCH_LANGUAGE(SimplifiedChinese, "zh-Hans") - AMS_MATCH_LANGUAGE(TraditionalChinese, "zh-Hant") - #undef AMS_MATCH_LANGUAGE - else { static_assert(Lang != Language_Japanese); } - }(); - - static constexpr inline LanguageCode Encode(const Language language) { - constexpr LanguageCode EncodedLanguages[Language_Count] = { - EncodeLanguage, - EncodeLanguage, - EncodeLanguage, - EncodeLanguage, - EncodeLanguage, - EncodeLanguage, - EncodeLanguage, - EncodeLanguage, - EncodeLanguage, - EncodeLanguage, - EncodeLanguage, - EncodeLanguage, - EncodeLanguage, - EncodeLanguage, - EncodeLanguage, - /* 4.0.0+ */ - EncodeLanguage, - EncodeLanguage, - }; - return EncodedLanguages[language]; - } - - }; - - constexpr inline bool operator==(const LanguageCode &lhs, const LanguageCode &rhs) { - return std::strncmp(lhs.name, rhs.name, sizeof(lhs)) == 0; - } - - constexpr inline bool operator!=(const LanguageCode &lhs, const LanguageCode &rhs) { - return !(lhs == rhs); - } - - constexpr inline bool operator==(const LanguageCode &lhs, const Language &rhs) { - return lhs == LanguageCode::Encode(rhs); - } - - constexpr inline bool operator!=(const LanguageCode &lhs, const Language &rhs) { - return !(lhs == rhs); - } - - constexpr inline bool operator==(const Language &lhs, const LanguageCode &rhs) { - return rhs == lhs; - } - - constexpr inline bool operator!=(const Language &lhs, const LanguageCode &rhs) { - return !(lhs == rhs); - } - - namespace impl { - - template - constexpr inline bool IsValidLanguageCode(const LanguageCode &lc, std::index_sequence) { - return ((lc == LanguageCode::Encode(static_cast(Is))) || ...); - } - - } - - constexpr inline bool IsValidLanguageCodeDeprecated(const LanguageCode &lc) { - return impl::IsValidLanguageCode(lc, std::make_index_sequence{}); - } - - constexpr inline bool IsValidLanguageCode(const LanguageCode &lc) { - return impl::IsValidLanguageCode(lc, std::make_index_sequence{}); - } - - static_assert(std::is_pod::value); - static_assert(sizeof(LanguageCode) == sizeof(u64)); - - /* Not an official type, but convenient. */ - enum RegionCode : s32 { - RegionCode_Japan, - RegionCode_America, - RegionCode_Europe, - RegionCode_Australia, - RegionCode_China, - RegionCode_Korea, - RegionCode_Taiwan, - - RegionCode_Count, - }; - - constexpr inline bool IsValidRegionCode(const RegionCode rc) { - return 0 <= rc && rc < RegionCode_Count; - } - - /* This needs to be defined separately from libnx's so that it can inherit from sf::LargeData. */ - - struct FirmwareVersion : public sf::LargeData { - u8 major; - u8 minor; - u8 micro; - u8 padding1; - u8 revision_major; - u8 revision_minor; - u8 padding2; - u8 padding3; - char platform[0x20]; - char version_hash[0x40]; - char display_version[0x18]; - char display_title[0x80]; - - constexpr inline u32 GetVersion() const { - return (static_cast(major) << 16) | (static_cast(minor) << 8) | (static_cast(micro) << 0); - } - }; - - static_assert(std::is_pod::value); - static_assert(sizeof(FirmwareVersion) == sizeof(::SetSysFirmwareVersion)); - - constexpr inline bool operator==(const FirmwareVersion &lhs, const FirmwareVersion &rhs) { - return lhs.GetVersion() == rhs.GetVersion(); - } - - constexpr inline bool operator!=(const FirmwareVersion &lhs, const FirmwareVersion &rhs) { - return !(lhs == rhs); - } - - constexpr inline bool operator<(const FirmwareVersion &lhs, const FirmwareVersion &rhs) { - return lhs.GetVersion() < rhs.GetVersion(); - } - - constexpr inline bool operator>=(const FirmwareVersion &lhs, const FirmwareVersion &rhs) { - return !(lhs < rhs); - } - - constexpr inline bool operator<=(const FirmwareVersion &lhs, const FirmwareVersion &rhs) { - return lhs.GetVersion() <= rhs.GetVersion(); - } - - constexpr inline bool operator>(const FirmwareVersion &lhs, const FirmwareVersion &rhs) { - return !(lhs <= rhs); - } - -} diff --git a/stratosphere/libstratosphere/include/stratosphere/sf.hpp b/stratosphere/libstratosphere/include/stratosphere/sf.hpp deleted file mode 100644 index c37ef3aad..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/sf.hpp +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once - -#include "sf/sf_common.hpp" -#include "sf/sf_service_object.hpp" -#include "sf/hipc/sf_hipc_server_session_manager.hpp" - -#include "sf/sf_out.hpp" -#include "sf/sf_buffers.hpp" -#include "sf/impl/sf_impl_command_serialization.hpp" - -#include "sf/hipc/sf_hipc_server_manager.hpp" - -#include "sf/sf_mitm_dispatch.h" diff --git a/stratosphere/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_domain_api.hpp b/stratosphere/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_domain_api.hpp deleted file mode 100644 index 9e792d1b0..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_domain_api.hpp +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include "../sf_common.hpp" -#include "sf_cmif_service_object_holder.hpp" - -namespace ams::sf::cmif { - - struct DomainObjectId { - u32 value; - - constexpr void SetValue(u32 new_value) { this->value = new_value; } - }; - - static_assert(std::is_trivial::value && sizeof(DomainObjectId) == sizeof(u32), "DomainObjectId"); - - inline constexpr bool operator==(const DomainObjectId &lhs, const DomainObjectId &rhs) { - return lhs.value == rhs.value; - } - - inline constexpr bool operator!=(const DomainObjectId &lhs, const DomainObjectId &rhs) { - return lhs.value != rhs.value; - } - - inline constexpr bool operator<(const DomainObjectId &lhs, const DomainObjectId &rhs) { - return lhs.value < rhs.value; - } - - inline constexpr bool operator<=(const DomainObjectId &lhs, const DomainObjectId &rhs) { - return lhs.value <= rhs.value; - } - - inline constexpr bool operator>(const DomainObjectId &lhs, const DomainObjectId &rhs) { - return lhs.value > rhs.value; - } - - inline constexpr bool operator>=(const DomainObjectId &lhs, const DomainObjectId &rhs) { - return lhs.value >= rhs.value; - } - - constexpr inline const DomainObjectId InvalidDomainObjectId = { .value = 0 }; - - class ServerDomainBase { - public: - virtual Result ReserveIds(DomainObjectId *out_ids, size_t count) = 0; - virtual void ReserveSpecificIds(const DomainObjectId *ids, size_t count) = 0; - virtual void UnreserveIds(const DomainObjectId *ids, size_t count) = 0; - virtual void RegisterObject(DomainObjectId id, ServiceObjectHolder &&obj) = 0; - - virtual ServiceObjectHolder UnregisterObject(DomainObjectId id) = 0; - virtual ServiceObjectHolder GetObject(DomainObjectId id) = 0; - }; - -} diff --git a/stratosphere/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_domain_manager.hpp b/stratosphere/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_domain_manager.hpp deleted file mode 100644 index 0627aed2c..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_domain_manager.hpp +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include "../sf_common.hpp" -#include "sf_cmif_domain_api.hpp" -#include "sf_cmif_domain_service_object.hpp" - -namespace ams::sf::cmif { - - class ServerDomainManager { - NON_COPYABLE(ServerDomainManager); - NON_MOVEABLE(ServerDomainManager); - private: - class Domain; - - struct Entry { - NON_COPYABLE(Entry); - NON_MOVEABLE(Entry); - - util::IntrusiveListNode free_list_node; - util::IntrusiveListNode domain_list_node; - Domain *owner; - ServiceObjectHolder object; - - explicit Entry() : owner(nullptr) { /* ... */ } - }; - - class Domain final : public DomainServiceObject { - NON_COPYABLE(Domain); - NON_MOVEABLE(Domain); - private: - using EntryList = typename util::IntrusiveListMemberTraits<&Entry::domain_list_node>::ListType; - private: - ServerDomainManager *manager; - EntryList entries; - public: - explicit Domain(ServerDomainManager *m) : manager(m) { /* ... */ } - ~Domain(); - - void DestroySelf(); - - virtual ServerDomainBase *GetServerDomain() override final { - return static_cast(this); - } - - virtual Result ReserveIds(DomainObjectId *out_ids, size_t count) override final; - virtual void ReserveSpecificIds(const DomainObjectId *ids, size_t count) override final; - virtual void UnreserveIds(const DomainObjectId *ids, size_t count) override final; - virtual void RegisterObject(DomainObjectId id, ServiceObjectHolder &&obj) override final; - - virtual ServiceObjectHolder UnregisterObject(DomainObjectId id) override final; - virtual ServiceObjectHolder GetObject(DomainObjectId id) override final; - }; - public: - using DomainEntryStorage = TYPED_STORAGE(Entry); - using DomainStorage = TYPED_STORAGE(Domain); - private: - class EntryManager { - private: - using EntryList = typename util::IntrusiveListMemberTraits<&Entry::free_list_node>::ListType; - private: - os::Mutex lock; - EntryList free_list; - Entry *entries; - size_t num_entries; - public: - EntryManager(DomainEntryStorage *entry_storage, size_t entry_count); - ~EntryManager(); - Entry *AllocateEntry(); - void FreeEntry(Entry *); - - void AllocateSpecificEntries(const DomainObjectId *ids, size_t count); - - inline DomainObjectId GetId(Entry *e) { - const size_t index = e - this->entries; - AMS_ASSERT(index < this->num_entries); - return DomainObjectId{ u32(index + 1) }; - } - - inline Entry *GetEntry(DomainObjectId id) { - if (id == InvalidDomainObjectId) { - return nullptr; - } - const size_t index = id.value - 1; - if (!(index < this->num_entries)) { - return nullptr; - } - return this->entries + index; - } - }; - private: - os::Mutex entry_owner_lock; - EntryManager entry_manager; - private: - virtual void *AllocateDomain() = 0; - virtual void FreeDomain(void *) = 0; - protected: - ServerDomainManager(DomainEntryStorage *entry_storage, size_t entry_count) : entry_manager(entry_storage, entry_count) { /* ... */ } - - inline DomainServiceObject *AllocateDomainServiceObject() { - void *storage = this->AllocateDomain(); - if (storage == nullptr) { - return nullptr; - } - return new (storage) Domain(this); - } - public: - static void DestroyDomainServiceObject(DomainServiceObject *obj) { - static_cast(obj)->DestroySelf(); - } - }; - - -} diff --git a/stratosphere/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_domain_service_object.hpp b/stratosphere/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_domain_service_object.hpp deleted file mode 100644 index d5f86dd28..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_domain_service_object.hpp +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include "sf_cmif_service_dispatch.hpp" -#include "sf_cmif_domain_api.hpp" -#include "sf_cmif_server_message_processor.hpp" - -namespace ams::sf::cmif { - - class DomainServiceObjectDispatchTable : public impl::ServiceDispatchTableBase { - private: - Result ProcessMessageImpl(ServiceDispatchContext &ctx, ServerDomainBase *domain, const cmif::PointerAndSize &in_raw_data) const; - Result ProcessMessageForMitmImpl(ServiceDispatchContext &ctx, ServerDomainBase *domain, const cmif::PointerAndSize &in_raw_data) const; - public: - Result ProcessMessage(ServiceDispatchContext &ctx, const cmif::PointerAndSize &in_raw_data) const; - Result ProcessMessageForMitm(ServiceDispatchContext &ctx, const cmif::PointerAndSize &in_raw_data) const; - }; - - - class DomainServiceObjectProcessor : public ServerMessageProcessor { - private: - ServerMessageProcessor *impl_processor; - ServerDomainBase *domain; - DomainObjectId *in_object_ids; - DomainObjectId *out_object_ids; - size_t num_in_objects; - ServerMessageRuntimeMetadata impl_metadata; - public: - DomainServiceObjectProcessor(ServerDomainBase *d, DomainObjectId *in_obj_ids, size_t num_in_objs) : domain(d), in_object_ids(in_obj_ids), num_in_objects(num_in_objs) { - AMS_ASSERT(this->domain != nullptr); - AMS_ASSERT(this->in_object_ids != nullptr); - this->impl_processor = nullptr; - this->out_object_ids = nullptr; - this->impl_metadata = {}; - } - - constexpr size_t GetInObjectCount() const { - return this->num_in_objects; - } - - constexpr size_t GetOutObjectCount() const { - return this->impl_metadata.GetOutObjectCount(); - } - - constexpr size_t GetImplOutHeadersSize() const { - return this->impl_metadata.GetOutHeadersSize(); - } - - constexpr size_t GetImplOutDataTotalSize() const { - return this->impl_metadata.GetOutDataSize() + this->impl_metadata.GetOutHeadersSize(); - } - public: - /* Used to enabled templated message processors. */ - virtual void SetImplementationProcessor(ServerMessageProcessor *impl) override final { - if (this->impl_processor == nullptr) { - this->impl_processor = impl; - } else { - this->impl_processor->SetImplementationProcessor(impl); - } - - this->impl_metadata = this->impl_processor->GetRuntimeMetadata(); - } - - virtual const ServerMessageRuntimeMetadata GetRuntimeMetadata() const override final { - const auto runtime_metadata = this->impl_processor->GetRuntimeMetadata(); - - return ServerMessageRuntimeMetadata { - .in_data_size = static_cast(runtime_metadata.GetInDataSize() + runtime_metadata.GetInObjectCount() * sizeof(DomainObjectId)), - .out_data_size = static_cast(runtime_metadata.GetOutDataSize() + runtime_metadata.GetOutObjectCount() * sizeof(DomainObjectId)), - .in_headers_size = static_cast(runtime_metadata.GetInHeadersSize() + sizeof(CmifDomainInHeader)), - .out_headers_size = static_cast(runtime_metadata.GetOutHeadersSize() + sizeof(CmifDomainOutHeader)), - .in_object_count = 0, - .out_object_count = 0, - }; - } - - virtual Result PrepareForProcess(const ServiceDispatchContext &ctx, const ServerMessageRuntimeMetadata runtime_metadata) const override final; - virtual Result GetInObjects(ServiceObjectHolder *in_objects) const override final; - virtual HipcRequest PrepareForReply(const cmif::ServiceDispatchContext &ctx, PointerAndSize &out_raw_data, const ServerMessageRuntimeMetadata runtime_metadata) override final; - virtual void PrepareForErrorReply(const cmif::ServiceDispatchContext &ctx, PointerAndSize &out_raw_data, const ServerMessageRuntimeMetadata runtime_metadata) override final; - virtual void SetOutObjects(const cmif::ServiceDispatchContext &ctx, const HipcRequest &response, ServiceObjectHolder *out_objects, DomainObjectId *ids) override final; - }; - - class DomainServiceObject : public IServiceObject, public ServerDomainBase { - friend class DomainServiceObjectDispatchTable; - public: - static constexpr inline DomainServiceObjectDispatchTable s_CmifServiceDispatchTable{}; - private: - virtual ServerDomainBase *GetServerDomain() = 0; - public: - /* TODO: Implement to use domain object processor. */ - }; - - class MitmDomainServiceObject : public DomainServiceObject{}; - - static_assert(sizeof(DomainServiceObject) == sizeof(MitmDomainServiceObject)); - - template<> - struct ServiceDispatchTraits { - static_assert(std::is_base_of::value, "DomainServiceObject must derive from sf::IServiceObject"); - static_assert(!std::is_base_of::value, "DomainServiceObject must not derive from sf::IMitmServiceObject"); - using ProcessHandlerType = decltype(ServiceDispatchMeta::ProcessHandler); - - using DispatchTableType = DomainServiceObjectDispatchTable; - static constexpr ProcessHandlerType ProcessHandlerImpl = &impl::ServiceDispatchTableBase::ProcessMessage; - - static constexpr inline ServiceDispatchMeta Meta{&DomainServiceObject::s_CmifServiceDispatchTable, ProcessHandlerImpl}; - }; - - template<> - struct ServiceDispatchTraits { - static_assert(std::is_base_of::value, "MitmDomainServiceObject must derive from DomainServiceObject"); - using ProcessHandlerType = decltype(ServiceDispatchMeta::ProcessHandler); - - using DispatchTableType = DomainServiceObjectDispatchTable; - static constexpr ProcessHandlerType ProcessHandlerImpl = &impl::ServiceDispatchTableBase::ProcessMessageForMitm; - - static constexpr inline ServiceDispatchMeta Meta{&DomainServiceObject::s_CmifServiceDispatchTable, ProcessHandlerImpl}; - }; - - -} diff --git a/stratosphere/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_pointer_and_size.hpp b/stratosphere/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_pointer_and_size.hpp deleted file mode 100644 index e957b1942..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_pointer_and_size.hpp +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include "../sf_common.hpp" - -namespace ams::sf::cmif { - - class PointerAndSize { - private: - uintptr_t pointer; - size_t size; - public: - constexpr PointerAndSize() : pointer(0), size(0) { /* ... */ } - constexpr PointerAndSize(uintptr_t ptr, size_t sz) : pointer(ptr), size(sz) { /* ... */ } - constexpr PointerAndSize(void *ptr, size_t sz) : PointerAndSize(reinterpret_cast(ptr), sz) { /* ... */ } - - constexpr void *GetPointer() const { - return reinterpret_cast(this->pointer); - } - - constexpr uintptr_t GetAddress() const { - return this->pointer; - } - - constexpr size_t GetSize() const { - return this->size; - } - }; - -} diff --git a/stratosphere/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_server_message_processor.hpp b/stratosphere/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_server_message_processor.hpp deleted file mode 100644 index 4f97cf448..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_server_message_processor.hpp +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include "../sf_service_object.hpp" -#include "sf_cmif_pointer_and_size.hpp" - -namespace ams::sf::cmif { - - /* Forward declare ServiceDispatchContext, ServiceObjectHolder. */ - struct ServiceDispatchContext; - class ServiceObjectHolder; - struct DomainObjectId; - - /* This is needed for non-templated domain message processing. */ - struct ServerMessageRuntimeMetadata { - u16 in_data_size; - u16 out_data_size; - u8 in_headers_size; - u8 out_headers_size; - u8 in_object_count; - u8 out_object_count; - - constexpr size_t GetInDataSize() const { - return size_t(this->in_data_size); - } - - constexpr size_t GetOutDataSize() const { - return size_t(this->out_data_size); - } - - constexpr size_t GetInHeadersSize() const { - return size_t(this->in_headers_size); - } - - constexpr size_t GetOutHeadersSize() const { - return size_t(this->out_headers_size); - } - - constexpr size_t GetInObjectCount() const { - return size_t(this->in_object_count); - } - - constexpr size_t GetOutObjectCount() const { - return size_t(this->out_object_count); - } - - constexpr size_t GetUnfixedOutPointerSizeOffset() const { - return this->GetInDataSize() + this->GetInHeadersSize() + 0x10 /* padding. */; - } - }; - - static_assert(std::is_pod::value, "std::is_pod::value"); - static_assert(sizeof(ServerMessageRuntimeMetadata) == sizeof(u64), "sizeof(ServerMessageRuntimeMetadata)"); - - class ServerMessageProcessor { - public: - /* Used to enabled templated message processors. */ - virtual void SetImplementationProcessor(ServerMessageProcessor *impl) = 0; - virtual const ServerMessageRuntimeMetadata GetRuntimeMetadata() const = 0; - - virtual Result PrepareForProcess(const ServiceDispatchContext &ctx, const ServerMessageRuntimeMetadata runtime_metadata) const = 0; - virtual Result GetInObjects(ServiceObjectHolder *in_objects) const = 0; - virtual HipcRequest PrepareForReply(const cmif::ServiceDispatchContext &ctx, PointerAndSize &out_raw_data, const ServerMessageRuntimeMetadata runtime_metadata) = 0; - virtual void PrepareForErrorReply(const cmif::ServiceDispatchContext &ctx, PointerAndSize &out_raw_data, const ServerMessageRuntimeMetadata runtime_metadata) = 0; - virtual void SetOutObjects(const cmif::ServiceDispatchContext &ctx, const HipcRequest &response, ServiceObjectHolder *out_objects, DomainObjectId *ids) = 0; - }; -} diff --git a/stratosphere/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_service_dispatch.hpp b/stratosphere/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_service_dispatch.hpp deleted file mode 100644 index c146d8aa5..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_service_dispatch.hpp +++ /dev/null @@ -1,150 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include "../sf_service_object.hpp" -#include "sf_cmif_pointer_and_size.hpp" -#include "sf_cmif_server_message_processor.hpp" - -namespace ams::sf::hipc { - - class ServerSessionManager; - class ServerSession; - -} - -namespace ams::sf::cmif { - - class ServerMessageProcessor; - - struct HandlesToClose { - Handle handles[8]; - size_t num_handles; - }; - - struct ServiceDispatchContext { - sf::IServiceObject *srv_obj; - hipc::ServerSessionManager *manager; - hipc::ServerSession *session; - ServerMessageProcessor *processor; - HandlesToClose *handles_to_close; - const PointerAndSize pointer_buffer; - const PointerAndSize in_message_buffer; - const PointerAndSize out_message_buffer; - const HipcParsedRequest request; - }; - - struct ServiceCommandMeta { - hos::Version hosver_low; - hos::Version hosver_high; - u32 cmd_id; - Result (*handler)(CmifOutHeader **out_header_ptr, ServiceDispatchContext &ctx, const cmif::PointerAndSize &in_raw_data); - - constexpr inline bool Matches(u32 cmd_id, hos::Version hosver) const { - return this->cmd_id == cmd_id && this->hosver_low <= hosver && hosver <= this->hosver_high; - } - - constexpr inline decltype(handler) GetHandler() const { - return this->handler; - } - }; - static_assert(std::is_pod::value && sizeof(ServiceCommandMeta) == 0x10, "sizeof(ServiceCommandMeta)"); - - namespace impl { - - class ServiceDispatchTableBase { - protected: - Result ProcessMessageImpl(ServiceDispatchContext &ctx, const cmif::PointerAndSize &in_raw_data, const ServiceCommandMeta *entries, const size_t entry_count) const; - Result ProcessMessageForMitmImpl(ServiceDispatchContext &ctx, const cmif::PointerAndSize &in_raw_data, const ServiceCommandMeta *entries, const size_t entry_count) const; - public: - /* CRTP. */ - template - Result ProcessMessage(ServiceDispatchContext &ctx, const cmif::PointerAndSize &in_raw_data) const { - static_assert(std::is_base_of::value, "ServiceDispatchTableBase::Process"); - return static_cast(this)->ProcessMessage(ctx, in_raw_data); - } - - template - Result ProcessMessageForMitm(ServiceDispatchContext &ctx, const cmif::PointerAndSize &in_raw_data) const { - static_assert(std::is_base_of::value, "ServiceDispatchTableBase::ProcessForMitm"); - return static_cast(this)->ProcessMessageForMitm(ctx, in_raw_data); - } - }; - - template> - class ServiceDispatchTableImpl; - - template - class ServiceDispatchTableImpl> : public ServiceDispatchTableBase { - private: - template - using EntryType = ServiceCommandMeta; - private: - const std::array entries; - public: - explicit constexpr ServiceDispatchTableImpl(EntryType... args) : entries { args... } { /* ... */ } - - Result ProcessMessage(ServiceDispatchContext &ctx, const cmif::PointerAndSize &in_raw_data) const { - return this->ProcessMessageImpl(ctx, in_raw_data, this->entries.data(), this->entries.size()); - } - - Result ProcessMessageForMitm(ServiceDispatchContext &ctx, const cmif::PointerAndSize &in_raw_data) const { - return this->ProcessMessageForMitmImpl(ctx, in_raw_data, this->entries.data(), this->entries.size()); - } - }; - - } - - template - class ServiceDispatchTable : public impl::ServiceDispatchTableImpl { - public: - explicit constexpr ServiceDispatchTable(Entries... entries) : impl::ServiceDispatchTableImpl(entries...) { /* ... */ } - }; - - #define DEFINE_SERVICE_DISPATCH_TABLE \ - template \ - static constexpr inline ::ams::sf::cmif::ServiceDispatchTable s_CmifServiceDispatchTable - - struct ServiceDispatchMeta { - const impl::ServiceDispatchTableBase *DispatchTable; - Result (impl::ServiceDispatchTableBase::*ProcessHandler)(ServiceDispatchContext &, const cmif::PointerAndSize &) const; - - constexpr uintptr_t GetServiceId() const { - return reinterpret_cast(this->DispatchTable); - } - }; - - template - struct ServiceDispatchTraits { - static_assert(std::is_base_of::value, "ServiceObjects must derive from sf::IServiceObject"); - - using ProcessHandlerType = decltype(ServiceDispatchMeta::ProcessHandler); - - static constexpr inline auto DispatchTable = T::template s_CmifServiceDispatchTable; - using DispatchTableType = decltype(DispatchTable); - - static constexpr ProcessHandlerType ProcessHandlerImpl = ServiceObjectTraits::IsMitmServiceObject ? (&impl::ServiceDispatchTableBase::ProcessMessageForMitm) - : (&impl::ServiceDispatchTableBase::ProcessMessage); - - static constexpr inline ServiceDispatchMeta Meta{&DispatchTable, ProcessHandlerImpl}; - }; - - template - NX_CONSTEXPR const ServiceDispatchMeta *GetServiceDispatchMeta() { - return &ServiceDispatchTraits::Meta; - } - -} diff --git a/stratosphere/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_service_object_holder.hpp b/stratosphere/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_service_object_holder.hpp deleted file mode 100644 index 12c8969b9..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/sf/cmif/sf_cmif_service_object_holder.hpp +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include "../sf_service_object.hpp" -#include "sf_cmif_service_dispatch.hpp" - -namespace ams::sf::cmif { - - class ServiceObjectHolder { - private: - std::shared_ptr srv; - const ServiceDispatchMeta *dispatch_meta; - private: - /* Copy constructor. */ - ServiceObjectHolder(const ServiceObjectHolder &o) : srv(o.srv), dispatch_meta(o.dispatch_meta) { /* ... */ } - ServiceObjectHolder &operator=(const ServiceObjectHolder &o) = delete; - public: - /* Default constructor, null all members. */ - ServiceObjectHolder() : srv(nullptr), dispatch_meta(nullptr) { /* ... */ } - - ~ServiceObjectHolder() { - this->dispatch_meta = nullptr; - } - - /* Ensure correct type id at runtime through template constructor. */ - template - constexpr explicit ServiceObjectHolder(std::shared_ptr &&s) { - this->srv = std::move(s); - this->dispatch_meta = GetServiceDispatchMeta(); - } - - /* Move constructor, assignment operator. */ - ServiceObjectHolder(ServiceObjectHolder &&o) : srv(std::move(o.srv)), dispatch_meta(std::move(o.dispatch_meta)) { - o.dispatch_meta = nullptr; - } - - ServiceObjectHolder &operator=(ServiceObjectHolder &&o) { - ServiceObjectHolder tmp(std::move(o)); - tmp.Swap(*this); - return *this; - } - - /* State management. */ - void Swap(ServiceObjectHolder &o) { - std::swap(this->srv, o.srv); - std::swap(this->dispatch_meta, o.dispatch_meta); - } - - void Reset() { - this->srv = nullptr; - this->dispatch_meta = nullptr; - } - - ServiceObjectHolder Clone() const { - return ServiceObjectHolder(*this); - } - - /* Boolean operators. */ - explicit constexpr operator bool() const { - return this->dispatch_meta != nullptr; - } - - constexpr bool operator!() const { - return this->dispatch_meta == nullptr; - } - - /* Getters. */ - constexpr uintptr_t GetServiceId() const { - if (this->dispatch_meta) { - return this->dispatch_meta->GetServiceId(); - } - return 0; - } - - template - constexpr inline bool IsServiceObjectValid() const { - return this->GetServiceId() == GetServiceDispatchMeta()->GetServiceId(); - } - - template - inline std::shared_ptr GetServiceObject() const { - if (this->GetServiceId() == GetServiceDispatchMeta()->GetServiceId()) { - return std::static_pointer_cast(this->srv); - } - return nullptr; - } - - inline sf::IServiceObject *GetServiceObjectUnsafe() const { - return this->srv.get(); - } - - /* Processing. */ - Result ProcessMessage(ServiceDispatchContext &ctx, const cmif::PointerAndSize &in_raw_data) const; - }; - -} diff --git a/stratosphere/libstratosphere/include/stratosphere/sf/hipc/sf_hipc_api.hpp b/stratosphere/libstratosphere/include/stratosphere/sf/hipc/sf_hipc_api.hpp deleted file mode 100644 index cd4b3535f..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/sf/hipc/sf_hipc_api.hpp +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include "../sf_common.hpp" -#include "../cmif/sf_cmif_pointer_and_size.hpp" - -namespace ams::sf::hipc { - - constexpr size_t TlsMessageBufferSize = 0x100; - - enum class ReceiveResult { - Success, - Closed, - NeedsRetry, - }; - - Result Receive(ReceiveResult *out_recv_result, Handle session_handle, const cmif::PointerAndSize &message_buffer); - Result Receive(bool *out_closed, Handle session_handle, const cmif::PointerAndSize &message_buffer); - Result Reply(Handle session_handle, const cmif::PointerAndSize &message_buffer); - - Result CreateSession(Handle *out_server_handle, Handle *out_client_handle); - -} diff --git a/stratosphere/libstratosphere/include/stratosphere/sf/hipc/sf_hipc_server_domain_session_manager.hpp b/stratosphere/libstratosphere/include/stratosphere/sf/hipc/sf_hipc_server_domain_session_manager.hpp deleted file mode 100644 index 38cdd574c..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/sf/hipc/sf_hipc_server_domain_session_manager.hpp +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include "sf_hipc_server_session_manager.hpp" -#include "../cmif/sf_cmif_domain_manager.hpp" - -namespace ams::sf::hipc { - - class ServerDomainSessionManager : public ServerSessionManager, private cmif::ServerDomainManager { - protected: - using cmif::ServerDomainManager::DomainEntryStorage; - using cmif::ServerDomainManager::DomainStorage; - protected: - virtual Result DispatchManagerRequest(ServerSession *session, const cmif::PointerAndSize &in_message, const cmif::PointerAndSize &out_message) override final; - public: - ServerDomainSessionManager(DomainEntryStorage *entry_storage, size_t entry_count) : ServerDomainManager(entry_storage, entry_count) { /* ... */ } - - inline cmif::DomainServiceObject *AllocateDomainServiceObject() { - return cmif::ServerDomainManager::AllocateDomainServiceObject(); - } - }; - -} diff --git a/stratosphere/libstratosphere/include/stratosphere/sf/hipc/sf_hipc_server_manager.hpp b/stratosphere/libstratosphere/include/stratosphere/sf/hipc/sf_hipc_server_manager.hpp deleted file mode 100644 index 04cbd79c4..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/sf/hipc/sf_hipc_server_manager.hpp +++ /dev/null @@ -1,394 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include "sf_hipc_server_domain_session_manager.hpp" -#include "../../sm.hpp" - -namespace ams::sf::hipc { - - struct DefaultServerManagerOptions { - static constexpr size_t PointerBufferSize = 0; - static constexpr size_t MaxDomains = 0; - static constexpr size_t MaxDomainObjects = 0; - }; - - static constexpr size_t ServerSessionCountMax = 0x40; - static_assert(ServerSessionCountMax == 0x40, "ServerSessionCountMax isn't 0x40 somehow, this assert is a reminder that this will break lots of things"); - - template - class ServerManager; - - class ServerManagerBase : public ServerDomainSessionManager { - NON_COPYABLE(ServerManagerBase); - NON_MOVEABLE(ServerManagerBase); - public: - using MitmQueryFunction = bool (*)(const sm::MitmProcessInfo &); - private: - enum class UserDataTag : uintptr_t { - Server = 1, - Session = 2, - MitmServer = 3, - }; - protected: - using ServerDomainSessionManager::DomainEntryStorage; - using ServerDomainSessionManager::DomainStorage; - private: - class ServerBase : public os::WaitableHolder { - friend class ServerManagerBase; - template - friend class ServerManager; - NON_COPYABLE(ServerBase); - NON_MOVEABLE(ServerBase); - protected: - cmif::ServiceObjectHolder static_object; - ::Handle port_handle; - sm::ServiceName service_name; - bool service_managed; - public: - ServerBase(Handle ph, sm::ServiceName sn, bool m, cmif::ServiceObjectHolder &&sh) : - os::WaitableHolder(ph), static_object(std::move(sh)), port_handle(ph), service_name(sn), service_managed(m) - { - /* ... */ - } - - virtual ~ServerBase() = 0; - virtual void CreateSessionObjectHolder(cmif::ServiceObjectHolder *out_obj, std::shared_ptr<::Service> *out_fsrv) const = 0; - }; - - template> - class Server : public ServerBase { - NON_COPYABLE(Server); - NON_MOVEABLE(Server); - private: - static constexpr bool IsMitmServer = ServiceObjectTraits::IsMitmServiceObject; - public: - Server(Handle ph, sm::ServiceName sn, bool m, cmif::ServiceObjectHolder &&sh) : ServerBase(ph, sn, m, std::forward(sh)) { - /* ... */ - } - - virtual ~Server() override { - if (this->service_managed) { - if constexpr (IsMitmServer) { - R_ASSERT(sm::mitm::UninstallMitm(this->service_name)); - } else { - R_ASSERT(sm::UnregisterService(this->service_name)); - } - R_ASSERT(svcCloseHandle(this->port_handle)); - } - } - - virtual void CreateSessionObjectHolder(cmif::ServiceObjectHolder *out_obj, std::shared_ptr<::Service> *out_fsrv) const override final { - /* If we're serving a static object, use it. */ - if (this->static_object) { - *out_obj = std::move(this->static_object.Clone()); - *out_fsrv = nullptr; - return; - } - - /* Otherwise, we're either a mitm session or a non-mitm session. */ - if constexpr (IsMitmServer) { - /* Custom deleter ensures that nothing goes awry. */ - /* TODO: Should this just be a custom wrapper object? */ - std::shared_ptr<::Service> forward_service = std::move(ServerSession::CreateForwardService()); - - /* Get mitm forward session. */ - sm::MitmProcessInfo client_info; - R_ASSERT(sm::mitm::AcknowledgeSession(forward_service.get(), &client_info, this->service_name)); - - *out_obj = std::move(cmif::ServiceObjectHolder(std::move(MakeShared(std::shared_ptr<::Service>(forward_service), client_info)))); - *out_fsrv = std::move(forward_service); - } else { - *out_obj = std::move(cmif::ServiceObjectHolder(std::move(MakeShared()))); - *out_fsrv = nullptr; - } - } - }; - private: - /* Management of waitables. */ - os::WaitableManager waitable_manager; - os::Event request_stop_event; - os::WaitableHolder request_stop_event_holder; - os::Event notify_event; - os::WaitableHolder notify_event_holder; - - os::Mutex waitable_selection_mutex; - - os::Mutex waitlist_mutex; - os::WaitableManager waitlist; - - os::Mutex deferred_session_mutex; - using DeferredSessionList = typename util::IntrusiveListMemberTraits<&ServerSession::deferred_list_node>::ListType; - DeferredSessionList deferred_session_list; - private: - virtual void RegisterSessionToWaitList(ServerSession *session) override final; - void RegisterToWaitList(os::WaitableHolder *holder); - void ProcessWaitList(); - - bool WaitAndProcessImpl(); - - Result ProcessForServer(os::WaitableHolder *holder); - Result ProcessForMitmServer(os::WaitableHolder *holder); - Result ProcessForSession(os::WaitableHolder *holder); - - void ProcessDeferredSessions(); - - template> - void RegisterServerImpl(Handle port_handle, sm::ServiceName service_name, bool managed, cmif::ServiceObjectHolder &&static_holder) { - /* Allocate server memory. */ - auto *server = this->AllocateServer(); - AMS_ASSERT(server != nullptr); - new (server) Server(port_handle, service_name, managed, std::forward(static_holder)); - - if constexpr (!ServiceObjectTraits::IsMitmServiceObject) { - /* Non-mitm server. */ - server->SetUserData(static_cast(UserDataTag::Server)); - } else { - /* Mitm server. */ - server->SetUserData(static_cast(UserDataTag::MitmServer)); - } - - this->waitable_manager.LinkWaitableHolder(server); - } - - template - static constexpr inline std::shared_ptr MakeSharedMitm(std::shared_ptr<::Service> &&s, const sm::MitmProcessInfo &client_info) { - return std::make_shared(std::forward>(s), client_info); - } - - Result InstallMitmServerImpl(Handle *out_port_handle, sm::ServiceName service_name, MitmQueryFunction query_func); - protected: - virtual ServerBase *AllocateServer() = 0; - virtual void DestroyServer(ServerBase *server) = 0; - public: - ServerManagerBase(DomainEntryStorage *entry_storage, size_t entry_count) : - ServerDomainSessionManager(entry_storage, entry_count), - request_stop_event(false), request_stop_event_holder(&request_stop_event), - notify_event(false), notify_event_holder(¬ify_event) - { - /* Link waitables. */ - this->waitable_manager.LinkWaitableHolder(&this->request_stop_event_holder); - this->waitable_manager.LinkWaitableHolder(&this->notify_event_holder); - } - - template> - void RegisterServer(Handle port_handle, std::shared_ptr static_object = nullptr) { - static_assert(!ServiceObjectTraits::IsMitmServiceObject, "RegisterServer requires non-mitm object. Use RegisterMitmServer instead."); - /* Register server. */ - cmif::ServiceObjectHolder static_holder; - if (static_object != nullptr) { - static_holder = cmif::ServiceObjectHolder(std::move(static_object)); - } - this->RegisterServerImpl(port_handle, sm::InvalidServiceName, false, std::move(static_holder)); - } - - template> - Result RegisterServer(sm::ServiceName service_name, size_t max_sessions, std::shared_ptr static_object = nullptr) { - static_assert(!ServiceObjectTraits::IsMitmServiceObject, "RegisterServer requires non-mitm object. Use RegisterMitmServer instead."); - - /* Register service. */ - Handle port_handle; - R_TRY(sm::RegisterService(&port_handle, service_name, max_sessions, false)); - - /* Register server. */ - cmif::ServiceObjectHolder static_holder; - if (static_object != nullptr) { - static_holder = cmif::ServiceObjectHolder(std::move(static_object)); - } - this->RegisterServerImpl(port_handle, service_name, true, std::move(static_holder)); - return ResultSuccess(); - } - - template> - Result RegisterMitmServer(sm::ServiceName service_name) { - static_assert(ServiceObjectTraits::IsMitmServiceObject, "RegisterMitmServer requires mitm object. Use RegisterServer instead."); - - /* Install mitm service. */ - Handle port_handle; - R_TRY(this->InstallMitmServerImpl(&port_handle, service_name, &ServiceImpl::ShouldMitm)); - - this->RegisterServerImpl(port_handle, service_name, true, cmif::ServiceObjectHolder()); - return ResultSuccess(); - } - - /* Processing. */ - os::WaitableHolder *WaitSignaled(); - - void ResumeProcessing(); - void RequestStopProcessing(); - void AddUserWaitableHolder(os::WaitableHolder *waitable); - - Result Process(os::WaitableHolder *waitable); - void WaitAndProcess(); - void LoopProcess(); - }; - - template - class ServerManager : public ServerManagerBase { - NON_COPYABLE(ServerManager); - NON_MOVEABLE(ServerManager); - static_assert(MaxServers <= ServerSessionCountMax, "MaxServers can never be larger than ServerSessionCountMax (0x40)."); - static_assert(MaxSessions <= ServerSessionCountMax, "MaxSessions can never be larger than ServerSessionCountMax (0x40)."); - static_assert(MaxServers + MaxSessions <= ServerSessionCountMax, "MaxServers + MaxSessions can never be larger than ServerSessionCountMax (0x40)."); - private: - static constexpr inline bool DomainCountsValid = [] { - if constexpr (ManagerOptions::MaxDomains > 0) { - return ManagerOptions::MaxDomainObjects > 0; - } else { - return ManagerOptions::MaxDomainObjects == 0; - } - }(); - static_assert(DomainCountsValid, "Invalid Domain Counts"); - protected: - using ServerManagerBase::DomainEntryStorage; - using ServerManagerBase::DomainStorage; - private: - /* Resource storage. */ - os::Mutex resource_mutex; - TYPED_STORAGE(ServerBase) server_storages[MaxServers]; - bool server_allocated[MaxServers]; - TYPED_STORAGE(ServerSession) session_storages[MaxSessions]; - bool session_allocated[MaxSessions]; - u8 pointer_buffer_storage[0x10 + (MaxSessions * ManagerOptions::PointerBufferSize)]; - u8 saved_message_storage[0x10 + (MaxSessions * hipc::TlsMessageBufferSize)]; - uintptr_t pointer_buffers_start; - uintptr_t saved_messages_start; - - /* Domain resources. */ - DomainStorage domain_storages[ManagerOptions::MaxDomains]; - bool domain_allocated[ManagerOptions::MaxDomains]; - DomainEntryStorage domain_entry_storages[ManagerOptions::MaxDomainObjects]; - private: - constexpr inline size_t GetServerIndex(const ServerBase *server) const { - const size_t i = server - GetPointer(this->server_storages[0]); - AMS_ASSERT(i < MaxServers); - return i; - } - - constexpr inline size_t GetSessionIndex(const ServerSession *session) const { - const size_t i = session - GetPointer(this->session_storages[0]); - AMS_ASSERT(i < MaxSessions); - return i; - } - - constexpr inline cmif::PointerAndSize GetObjectBySessionIndex(const ServerSession *session, uintptr_t start, size_t size) const { - return cmif::PointerAndSize(start + this->GetSessionIndex(session) * size, size); - } - protected: - virtual ServerSession *AllocateSession() override final { - std::scoped_lock lk(this->resource_mutex); - for (size_t i = 0; i < MaxSessions; i++) { - if (!this->session_allocated[i]) { - this->session_allocated[i] = true; - return GetPointer(this->session_storages[i]); - } - } - return nullptr; - } - - virtual void FreeSession(ServerSession *session) override final { - std::scoped_lock lk(this->resource_mutex); - const size_t index = this->GetSessionIndex(session); - AMS_ASSERT(this->session_allocated[index]); - this->session_allocated[index] = false; - } - - virtual ServerBase *AllocateServer() override final { - std::scoped_lock lk(this->resource_mutex); - for (size_t i = 0; i < MaxServers; i++) { - if (!this->server_allocated[i]) { - this->server_allocated[i] = true; - return GetPointer(this->server_storages[i]); - } - } - return nullptr; - } - - virtual void DestroyServer(ServerBase *server) override final { - std::scoped_lock lk(this->resource_mutex); - const size_t index = this->GetServerIndex(server); - AMS_ASSERT(this->server_allocated[index]); - server->~ServerBase(); - this->server_allocated[index] = false; - } - - virtual void *AllocateDomain() override final { - std::scoped_lock lk(this->resource_mutex); - for (size_t i = 0; i < ManagerOptions::MaxDomains; i++) { - if (!this->domain_allocated[i]) { - this->domain_allocated[i] = true; - return GetPointer(this->domain_storages[i]); - } - } - return nullptr; - } - - virtual void FreeDomain(void *domain) override final { - std::scoped_lock lk(this->resource_mutex); - DomainStorage *ptr = static_cast(domain); - const size_t index = ptr - this->domain_storages; - AMS_ASSERT(index < ManagerOptions::MaxDomains); - AMS_ASSERT(this->domain_allocated[index]); - this->domain_allocated[index] = false; - } - - virtual cmif::PointerAndSize GetSessionPointerBuffer(const ServerSession *session) const override final { - if constexpr (ManagerOptions::PointerBufferSize > 0) { - return this->GetObjectBySessionIndex(session, this->pointer_buffers_start, ManagerOptions::PointerBufferSize); - } else { - return cmif::PointerAndSize(); - } - } - - virtual cmif::PointerAndSize GetSessionSavedMessageBuffer(const ServerSession *session) const override final { - return this->GetObjectBySessionIndex(session, this->saved_messages_start, hipc::TlsMessageBufferSize); - } - public: - ServerManager() : ServerManagerBase(this->domain_entry_storages, ManagerOptions::MaxDomainObjects) { - /* Clear storages. */ - #define SF_SM_MEMCLEAR(obj) if constexpr (sizeof(obj) > 0) { std::memset(obj, 0, sizeof(obj)); } - SF_SM_MEMCLEAR(this->server_storages); - SF_SM_MEMCLEAR(this->server_allocated); - SF_SM_MEMCLEAR(this->session_storages); - SF_SM_MEMCLEAR(this->session_allocated); - SF_SM_MEMCLEAR(this->pointer_buffer_storage); - SF_SM_MEMCLEAR(this->saved_message_storage); - SF_SM_MEMCLEAR(this->domain_allocated); - #undef SF_SM_MEMCLEAR - - /* Set resource starts. */ - this->pointer_buffers_start = util::AlignUp(reinterpret_cast(this->pointer_buffer_storage), 0x10); - this->saved_messages_start = util::AlignUp(reinterpret_cast(this->saved_message_storage), 0x10); - } - - ~ServerManager() { - /* Close all sessions. */ - for (size_t i = 0; i < MaxSessions; i++) { - if (this->session_allocated[i]) { - this->CloseSessionImpl(GetPointer(this->session_storages[i])); - } - } - - /* Close all servers. */ - for (size_t i = 0; i < MaxServers; i++) { - if (this->server_allocated[i]) { - this->DestroyServer(GetPointer(this->server_storages[i])); - } - } - } - }; - -} diff --git a/stratosphere/libstratosphere/include/stratosphere/sf/hipc/sf_hipc_server_session_manager.hpp b/stratosphere/libstratosphere/include/stratosphere/sf/hipc/sf_hipc_server_session_manager.hpp deleted file mode 100644 index bc3da6fa6..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/sf/hipc/sf_hipc_server_session_manager.hpp +++ /dev/null @@ -1,182 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include "../sf_common.hpp" -#include "../sf_service_object.hpp" -#include "../cmif/sf_cmif_pointer_and_size.hpp" -#include "../cmif/sf_cmif_service_object_holder.hpp" -#include "sf_hipc_api.hpp" - -namespace ams::sf::cmif { - - struct ServiceDispatchContext; - -} - -namespace ams::sf::hipc { - - class ServerSessionManager; - class ServerManagerBase; - - namespace impl { - - class HipcManager; - - } - - class ServerSession : public os::WaitableHolder { - friend class ServerSessionManager; - friend class ServerManagerBase; - friend class impl::HipcManager; - NON_COPYABLE(ServerSession); - NON_MOVEABLE(ServerSession); - private: - util::IntrusiveListNode deferred_list_node; - cmif::ServiceObjectHolder srv_obj_holder; - cmif::PointerAndSize pointer_buffer; - cmif::PointerAndSize saved_message; - std::shared_ptr<::Service> forward_service; - Handle session_handle; - bool is_closed; - bool has_received; - public: - ServerSession(Handle h, cmif::ServiceObjectHolder &&obj) : WaitableHolder(h), srv_obj_holder(std::move(obj)), session_handle(h) { - this->is_closed = false; - this->has_received = false; - this->forward_service = nullptr; - AMS_ASSERT(!this->IsMitmSession()); - } - - ServerSession(Handle h, cmif::ServiceObjectHolder &&obj, std::shared_ptr<::Service> &&fsrv) : WaitableHolder(h), srv_obj_holder(std::move(obj)), session_handle(h) { - this->is_closed = false; - this->has_received = false; - this->forward_service = std::move(fsrv); - AMS_ASSERT(this->IsMitmSession()); - } - - bool IsMitmSession() const { - return this->forward_service != nullptr; - } - - Result ForwardRequest(const cmif::ServiceDispatchContext &ctx) const; - - static inline void ForwardServiceDeleter(Service *srv) { - serviceClose(srv); - delete srv; - } - - static inline std::shared_ptr<::Service> CreateForwardService() { - return std::shared_ptr<::Service>(new ::Service(), ForwardServiceDeleter); - } - }; - - class ServerSessionManager { - private: - template - Result CreateSessionImpl(ServerSession **out, const Constructor &ctor) { - /* Allocate session. */ - ServerSession *session_memory = this->AllocateSession(); - R_UNLESS(session_memory != nullptr, sf::hipc::ResultOutOfSessionMemory()); - /* Register session. */ - bool succeeded = false; - ON_SCOPE_EXIT { - if (!succeeded) { - this->DestroySession(session_memory); - } - }; - R_TRY(ctor(session_memory)); - /* Save new session to output. */ - succeeded = true; - *out = session_memory; - return ResultSuccess(); - } - void DestroySession(ServerSession *session); - - Result ProcessRequestImpl(ServerSession *session, const cmif::PointerAndSize &in_message, const cmif::PointerAndSize &out_message); - virtual void RegisterSessionToWaitList(ServerSession *session) = 0; - protected: - Result DispatchRequest(cmif::ServiceObjectHolder &&obj, ServerSession *session, const cmif::PointerAndSize &in_message, const cmif::PointerAndSize &out_message); - virtual Result DispatchManagerRequest(ServerSession *session, const cmif::PointerAndSize &in_message, const cmif::PointerAndSize &out_message); - protected: - virtual ServerSession *AllocateSession() = 0; - virtual void FreeSession(ServerSession *session) = 0; - virtual cmif::PointerAndSize GetSessionPointerBuffer(const ServerSession *session) const = 0; - virtual cmif::PointerAndSize GetSessionSavedMessageBuffer(const ServerSession *session) const = 0; - - Result ReceiveRequestImpl(ServerSession *session, const cmif::PointerAndSize &message); - void CloseSessionImpl(ServerSession *session); - Result RegisterSessionImpl(ServerSession *session_memory, Handle session_handle, cmif::ServiceObjectHolder &&obj); - Result AcceptSessionImpl(ServerSession *session_memory, Handle port_handle, cmif::ServiceObjectHolder &&obj); - Result RegisterMitmSessionImpl(ServerSession *session_memory, Handle mitm_session_handle, cmif::ServiceObjectHolder &&obj, std::shared_ptr<::Service> &&fsrv); - Result AcceptMitmSessionImpl(ServerSession *session_memory, Handle mitm_port_handle, cmif::ServiceObjectHolder &&obj, std::shared_ptr<::Service> &&fsrv); - - Result ReceiveRequest(ServerSession *session, const cmif::PointerAndSize &message) { - return this->ReceiveRequestImpl(session, message); - } - - Result RegisterSession(ServerSession **out, Handle session_handle, cmif::ServiceObjectHolder &&obj) { - auto ctor = [&](ServerSession *session_memory) -> Result { - return this->RegisterSessionImpl(session_memory, session_handle, std::forward(obj)); - }; - return this->CreateSessionImpl(out, ctor); - } - - Result AcceptSession(ServerSession **out, Handle port_handle, cmif::ServiceObjectHolder &&obj) { - auto ctor = [&](ServerSession *session_memory) -> Result { - return this->AcceptSessionImpl(session_memory, port_handle, std::forward(obj)); - }; - return this->CreateSessionImpl(out, ctor); - } - - Result RegisterMitmSession(ServerSession **out, Handle mitm_session_handle, cmif::ServiceObjectHolder &&obj, std::shared_ptr<::Service> &&fsrv) { - auto ctor = [&](ServerSession *session_memory) -> Result { - return this->RegisterMitmSessionImpl(session_memory, mitm_session_handle, std::forward(obj), std::forward>(fsrv)); - }; - return this->CreateSessionImpl(out, ctor); - } - - Result AcceptMitmSession(ServerSession **out, Handle mitm_port_handle, cmif::ServiceObjectHolder &&obj, std::shared_ptr<::Service> &&fsrv) { - auto ctor = [&](ServerSession *session_memory) -> Result { - return this->AcceptMitmSessionImpl(session_memory, mitm_port_handle, std::forward(obj), std::forward>(fsrv)); - }; - return this->CreateSessionImpl(out, ctor); - } - public: - Result RegisterSession(Handle session_handle, cmif::ServiceObjectHolder &&obj); - Result AcceptSession(Handle port_handle, cmif::ServiceObjectHolder &&obj); - Result RegisterMitmSession(Handle session_handle, cmif::ServiceObjectHolder &&obj, std::shared_ptr<::Service> &&fsrv); - Result AcceptMitmSession(Handle mitm_port_handle, cmif::ServiceObjectHolder &&obj, std::shared_ptr<::Service> &&fsrv); - - template - Result AcceptSession(Handle port_handle, std::shared_ptr obj) { - return this->AcceptSession(port_handle, cmif::ServiceObjectHolder(std::move(obj))); - } - - template - Result AcceptMitmSession(Handle mitm_port_handle, std::shared_ptr obj, std::shared_ptr<::Service> &&fsrv) { - return this->AcceptMitmSession(mitm_port_handle, cmif::ServiceObjectHolder(std::move(obj)), std::forward>(fsrv)); - } - - Result ProcessRequest(ServerSession *session, const cmif::PointerAndSize &message); - - virtual ServerSessionManager *GetSessionManagerByTag(u32 tag) { - /* This is unused. */ - return this; - } - }; - -} diff --git a/stratosphere/libstratosphere/include/stratosphere/sf/impl/sf_impl_command_serialization.hpp b/stratosphere/libstratosphere/include/stratosphere/sf/impl/sf_impl_command_serialization.hpp deleted file mode 100644 index 794aae6df..000000000 --- a/stratosphere/libstratosphere/include/stratosphere/sf/impl/sf_impl_command_serialization.hpp +++ /dev/null @@ -1,1161 +0,0 @@ -/* - * Copyright (c) 2018-2019 Atmosphère-NX - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once -#include "../sf_common.hpp" -#include "../sf_service_object.hpp" -#include "../sf_out.hpp" -#include "../sf_buffers.hpp" -#include "../sf_handles.hpp" -#include "../cmif/sf_cmif_pointer_and_size.hpp" -#include "../cmif/sf_cmif_service_dispatch.hpp" -#include "../cmif/sf_cmif_service_object_holder.hpp" -#include "../cmif/sf_cmif_domain_api.hpp" -#include "../hipc/sf_hipc_api.hpp" -#include "../hipc/sf_hipc_server_session_manager.hpp" - -/* Serialization classes. */ -namespace ams::sf { - - namespace impl { - - struct ProcessIdHolder { - os::ProcessId process_id; - - constexpr explicit operator os::ProcessId() const { return this->process_id; } - constexpr os::ProcessId GetValue() const { return this->process_id; } - constexpr void SetValue(const os::ProcessId &p) { this->process_id = p; } - }; - - } - - struct ClientProcessId : public impl::ProcessIdHolder {}; - static_assert(std::is_trivial::value && sizeof(ClientProcessId) == sizeof(os::ProcessId), "ClientProcessId"); - - struct ClientAppletResourceUserId : public impl::ProcessIdHolder {}; - static_assert(std::is_trivial::value && sizeof(ClientAppletResourceUserId ) == sizeof(os::ProcessId), "ClientAppletResourceUserId"); - - namespace impl { - - constexpr inline Result MarshalProcessId(ClientProcessId &client, const os::ProcessId &client_process_id) { - client.SetValue(client_process_id); - return ResultSuccess(); - } - - constexpr inline Result MarshalProcessId(ClientAppletResourceUserId &client, const os::ProcessId &client_process_id) { - if (client.GetValue() != client_process_id && client.GetValue() != os::ProcessId{}) { - return sf::ResultPreconditionViolation(); - } - return ResultSuccess(); - } - - } - - namespace impl { - - struct OutObjectTag{}; - - } - - template - class IsOutForceEnabled> : public std::true_type{}; - - template - class Out> : public impl::OutObjectTag { - static_assert(std::is_base_of::value, "Out> requires ServiceObject base."); - - template - friend class Out; - - public: - using ServiceImplType = ServiceImpl; - private: - cmif::ServiceObjectHolder *srv; - cmif::DomainObjectId *object_id; - public: - Out(cmif::ServiceObjectHolder *s, cmif::DomainObjectId *o) : srv(s), object_id(o) { /* ... */ } - - void SetValue(std::shared_ptr &&s, cmif::DomainObjectId new_object_id = cmif::InvalidDomainObjectId) { - *this->srv = cmif::ServiceObjectHolder(std::move(s)); - if (new_object_id != cmif::InvalidDomainObjectId) { - *this->object_id = new_object_id; - } - } - }; - -} - - -namespace ams::sf::impl { - - /* Machinery for filtering type lists. */ - template - struct TupleCat; - - template - struct TupleCat, std::tuple> { - using type = std::tuple; - }; - - template