2021-06-08 04:13:45 +01:00
|
|
|
/*
|
|
|
|
* defines.h
|
|
|
|
*
|
2024-04-12 10:47:36 +01:00
|
|
|
* Copyright (c) 2020-2024, DarkMatterCore <pabloacurielz@gmail.com>.
|
2021-06-08 04:13:45 +01:00
|
|
|
*
|
|
|
|
* This file is part of nxdumptool (https://github.com/DarkMatterCore/nxdumptool).
|
|
|
|
*
|
|
|
|
* nxdumptool 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 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* nxdumptool 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, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#ifndef __DEFINES_H__
|
|
|
|
#define __DEFINES_H__
|
|
|
|
|
|
|
|
/* Broadly useful language defines. */
|
|
|
|
|
|
|
|
#define MEMBER_SIZE(type, member) sizeof(((type*)NULL)->member)
|
|
|
|
|
|
|
|
#define MAX_ELEMENTS(x) ((sizeof((x))) / (sizeof((x)[0])))
|
|
|
|
|
|
|
|
#define ALIGN_UP(x, y) (((x) + ((y) - 1)) & ~((y) - 1))
|
|
|
|
#define ALIGN_DOWN(x, y) ((x) & ~((y) - 1))
|
|
|
|
#define IS_ALIGNED(x, y) (((x) & ((y) - 1)) == 0)
|
|
|
|
|
2022-07-02 11:09:49 +01:00
|
|
|
#define IS_POWER_OF_TWO(x) ((x) > 0 && ((x) & ((x) - 1)) == 0)
|
|
|
|
|
|
|
|
#define DIVIDE_UP(x, y) (((x) + ((y) - 1)) / (y))
|
2021-06-08 04:13:45 +01:00
|
|
|
|
|
|
|
#define CONCATENATE_IMPL(s1, s2) s1##s2
|
|
|
|
#define CONCATENATE(s1, s2) CONCATENATE_IMPL(s1, s2)
|
|
|
|
|
|
|
|
#define ANONYMOUS_VARIABLE(pref) CONCATENATE(pref, __LINE__)
|
|
|
|
|
|
|
|
#define NON_COPYABLE(cls) \
|
|
|
|
cls(const cls&) = delete; \
|
|
|
|
cls& operator=(const cls&) = delete
|
|
|
|
|
2021-07-30 22:07:26 +01:00
|
|
|
#define NON_MOVEABLE(cls) \
|
|
|
|
cls(cls&&) = delete; \
|
|
|
|
cls& operator=(cls&&) = delete
|
|
|
|
|
2021-06-08 04:13:45 +01:00
|
|
|
#define ALWAYS_INLINE inline __attribute__((always_inline))
|
|
|
|
#define ALWAYS_INLINE_LAMBDA __attribute__((always_inline))
|
|
|
|
|
2021-06-09 05:48:17 +01:00
|
|
|
#define CLEANUP(func) __attribute__((__cleanup__(func)))
|
|
|
|
|
2021-06-08 04:13:45 +01:00
|
|
|
#define NXDT_ASSERT(name, size) static_assert(sizeof(name) == (size), "Bad size for " #name "! Expected " #size ".")
|
|
|
|
|
|
|
|
/* Global constants used throughout the application. */
|
|
|
|
|
2023-11-03 01:22:47 +00:00
|
|
|
#define SHA256_HASH_STR_SIZE ((SHA256_HASH_SIZE * 2) + 1) /* Includes NULL terminator. */
|
|
|
|
|
|
|
|
#define THIRTY_FPS_DELAY (u64)33333333 /* 1 / 30 = 33.33 milliseconds. */
|
2023-10-22 23:44:40 +01:00
|
|
|
|
2021-06-08 04:13:45 +01:00
|
|
|
#define FS_SYSMODULE_TID (u64)0x0100000000000000
|
|
|
|
#define BOOT_SYSMODULE_TID (u64)0x0100000000000005
|
|
|
|
#define SPL_SYSMODULE_TID (u64)0x0100000000000028
|
|
|
|
#define ES_SYSMODULE_TID (u64)0x0100000000000033
|
2024-10-27 11:23:46 +00:00
|
|
|
#define SYSTEM_VERSION_TID (u64)0x0100000000000809
|
2021-06-08 04:13:45 +01:00
|
|
|
#define SYSTEM_UPDATE_TID (u64)0x0100000000000816
|
2021-06-23 19:27:06 +01:00
|
|
|
#define QLAUNCH_TID (u64)0x0100000000001000
|
2021-06-08 04:13:45 +01:00
|
|
|
|
2024-04-25 00:49:04 +01:00
|
|
|
#define FAT32_FILESIZE_LIMIT (u64)UINT32_MAX /* 4 GiB - 1 (4294967295 bytes). */
|
|
|
|
#define CONCATENATION_FILE_PART_SIZE (u64)0xFFFF0000 /* 4 GiB - 65536 (4294901760 bytes). */
|
2021-06-08 04:13:45 +01:00
|
|
|
|
2021-07-21 16:04:18 +01:00
|
|
|
#define UTF8_BOM "\xEF\xBB\xBF"
|
|
|
|
#define CRLF "\r\n"
|
|
|
|
|
2021-08-07 09:42:03 +01:00
|
|
|
#define DEVOPTAB_SDMC_DEVICE "sdmc:"
|
|
|
|
|
2021-07-21 16:04:18 +01:00
|
|
|
#define HBMENU_BASE_PATH "/switch/"
|
|
|
|
#define APP_BASE_PATH HBMENU_BASE_PATH APP_TITLE "/"
|
|
|
|
|
2024-04-20 22:52:56 +01:00
|
|
|
#define GAMECARD_SUBDIR "Gamecard"
|
|
|
|
#define HFS_SUBDIR "HFS"
|
|
|
|
#define NSP_SUBDIR "NSP"
|
|
|
|
#define TICKET_SUBDIR "Ticket"
|
|
|
|
#define NCA_SUBDIR "NCA"
|
|
|
|
#define NCA_FS_SUBDIR "NCA FS"
|
2021-07-21 16:04:18 +01:00
|
|
|
|
2023-05-24 20:05:34 +01:00
|
|
|
#define CONFIG_FILE_NAME APP_TITLE "_config.json"
|
2021-07-21 16:04:18 +01:00
|
|
|
#define DEFAULT_CONFIG_PATH "romfs:/default_config.json"
|
|
|
|
|
|
|
|
#define NRO_NAME APP_TITLE ".nro"
|
2021-08-07 09:42:03 +01:00
|
|
|
#define NRO_PATH DEVOPTAB_SDMC_DEVICE APP_BASE_PATH NRO_NAME
|
|
|
|
#define NRO_TMP_PATH NRO_PATH ".tmp"
|
2021-07-21 16:04:18 +01:00
|
|
|
|
2024-04-05 22:25:32 +01:00
|
|
|
#define PROD_KEYS_FILE_PATH DEVOPTAB_SDMC_DEVICE HBMENU_BASE_PATH "prod.keys" /* Retail unit keys. */
|
|
|
|
#define DEV_KEYS_FILE_PATH DEVOPTAB_SDMC_DEVICE HBMENU_BASE_PATH "dev.keys" /* Development unit keys. */
|
2021-07-21 16:04:18 +01:00
|
|
|
|
|
|
|
#define LOG_FILE_NAME APP_TITLE ".log"
|
2023-11-03 01:22:47 +00:00
|
|
|
#define LOG_BUF_SIZE 0x400000 /* 4 MiB. */
|
|
|
|
#define LOG_FORCE_FLUSH 0 /* Forces a log buffer flush each time the logfile is written to. */
|
2021-07-21 16:04:18 +01:00
|
|
|
|
2024-04-15 00:53:43 +01:00
|
|
|
/// Reference: https://docs.microsoft.com/en-us/windows/win32/fileio/filesystem-functionality-comparison#limits.
|
|
|
|
/// Reference: https://en.wikipedia.org/wiki/Comparison_of_file_systems#Limits.
|
|
|
|
/// Most modern filesystems use a 255-byte limit instead of 255-character/codepoint limit, so that's what we're gonna use.
|
|
|
|
#define FS_MAX_FILENAME_LENGTH 255
|
|
|
|
#define SDMC_MAX_FILENAME_LENGTH 128 /* Arbitrarily set, I'm tired of FS sysmodule shenanigans. */
|
|
|
|
|
2024-04-30 22:01:42 +01:00
|
|
|
#define REPEATING_TASK_INTERVAL 250 /* 250 milliseconds. */
|
2024-04-15 00:53:43 +01:00
|
|
|
#define DATA_TRANSFER_TASK_INTERVAL 100 /* 100 milliseconds. */
|
2021-07-28 00:47:12 +01:00
|
|
|
|
2021-07-25 23:23:44 +01:00
|
|
|
#define HTTP_USER_AGENT APP_TITLE "/" APP_VERSION " (Nintendo Switch)"
|
2023-11-03 01:22:47 +00:00
|
|
|
#define HTTP_CONNECT_TIMEOUT 10L /* 10 seconds. */
|
|
|
|
#define HTTP_LOW_SPEED_LIMIT 30L /* 30 bytes per second. */
|
2021-08-08 08:39:21 +01:00
|
|
|
#define HTTP_LOW_SPEED_TIME HTTP_CONNECT_TIMEOUT
|
2023-11-03 01:22:47 +00:00
|
|
|
#define HTTP_BUFFER_SIZE 131072L /* 128 KiB. */
|
2021-07-25 23:23:44 +01:00
|
|
|
|
2021-08-07 09:42:03 +01:00
|
|
|
#define GITHUB_URL "https://github.com"
|
|
|
|
#define GITHUB_API_URL "https://api.github.com"
|
|
|
|
#define GITHUB_REPOSITORY APP_AUTHOR "/" APP_TITLE
|
|
|
|
|
|
|
|
#define GITHUB_REPOSITORY_URL GITHUB_URL "/" GITHUB_REPOSITORY
|
2021-06-13 20:32:37 +01:00
|
|
|
#define GITHUB_NEW_ISSUE_URL GITHUB_REPOSITORY_URL "/issues/new/choose"
|
|
|
|
|
2021-08-07 09:42:03 +01:00
|
|
|
#define GITHUB_API_RELEASE_URL GITHUB_API_URL "/repos/" GITHUB_REPOSITORY "/releases/latest"
|
|
|
|
|
2021-06-14 21:54:33 +01:00
|
|
|
#define BOREALIS_URL "https://github.com/natinusala/borealis"
|
|
|
|
#define LIBUSBHSFS_URL "https://github.com/DarkMatterCore/libusbhsfs"
|
2021-06-17 08:55:42 +01:00
|
|
|
#define FATFS_URL "http://elm-chan.org/fsw/ff/00index_e.html"
|
|
|
|
#define LZ4_URL "https://github.com/lz4/lz4"
|
2021-07-23 08:42:26 +01:00
|
|
|
#define JSON_C_URL "https://github.com/json-c/json-c"
|
2021-06-17 08:55:42 +01:00
|
|
|
|
|
|
|
#define DISCORD_SERVER_URL "https://discord.gg/SCbbcQx"
|
2021-06-14 21:54:33 +01:00
|
|
|
|
2024-04-05 22:25:32 +01:00
|
|
|
// TODO: remove this after the PoC builds are no longer needed.
|
|
|
|
#define PRERELEASE_URL GITHUB_URL "/" APP_AUTHOR "/nxdumptool/releases/tag/rewrite-prerelease"
|
|
|
|
|
2021-06-08 04:13:45 +01:00
|
|
|
#endif /* __DEFINES_H__ */
|