diff --git a/app/src/main/cpp/skyline/audio.cpp b/app/src/main/cpp/skyline/audio.cpp index 63bb212f..f28eb4bb 100644 --- a/app/src/main/cpp/skyline/audio.cpp +++ b/app/src/main/cpp/skyline/audio.cpp @@ -46,7 +46,7 @@ namespace skyline::audio { std::lock_guard bufferGuard(track->bufferLock); - auto trackSamples{track->samples.Read(destBuffer, streamSamples, [](i16 *source, i16 *destination) { + auto trackSamples{track->samples.Read(span(destBuffer, streamSamples), [](i16 *source, i16 *destination) { *destination = Saturate(static_cast(*destination) + static_cast(*source)); }, writtenSamples)}; diff --git a/app/src/main/cpp/skyline/audio.h b/app/src/main/cpp/skyline/audio.h index 638120af..5c2fcf6f 100644 --- a/app/src/main/cpp/skyline/audio.h +++ b/app/src/main/cpp/skyline/audio.h @@ -11,10 +11,10 @@ namespace skyline::audio { */ class Audio : public oboe::AudioStreamCallback { private: - oboe::AudioStreamBuilder builder; //!< The audio stream builder, used to open - oboe::ManagedStream outputStream; //!< The output oboe audio stream - std::vector> audioTracks; //!< A vector of shared_ptr to every open audio track - Mutex trackLock; //!< This mutex is used to ensure that audioTracks isn't modified while it is being used + oboe::AudioStreamBuilder builder; + oboe::ManagedStream outputStream; + std::vector> audioTracks; + Mutex trackLock; //!< Synchronizes modifications to the audio tracks public: Audio(const DeviceState &state); @@ -30,7 +30,6 @@ namespace skyline::audio { /** * @brief Closes a track and frees its data - * @param track The track to close */ void CloseTrack(std::shared_ptr &track); diff --git a/app/src/main/cpp/skyline/audio/adpcm_decoder.h b/app/src/main/cpp/skyline/audio/adpcm_decoder.h index e460ca90..b671ecb7 100644 --- a/app/src/main/cpp/skyline/audio/adpcm_decoder.h +++ b/app/src/main/cpp/skyline/audio/adpcm_decoder.h @@ -7,13 +7,10 @@ namespace skyline::audio { /** - * @brief The AdpcmDecoder class handles decoding single channel adaptive differential PCM data + * @brief The AdpcmDecoder class handles decoding single channel ADPCM (Adaptive Differential Pulse-Code Modulation) data */ class AdpcmDecoder { private: - /** - * @brief This struct holds a single ADPCM frame header - */ union FrameHeader { u8 raw; @@ -25,16 +22,14 @@ namespace skyline::audio { }; static_assert(sizeof(FrameHeader) == 0x1); - std::array history{}; //!< This contains the history for decoding the ADPCM stream - std::vector> coefficients; //!< This contains the coefficients for decoding the ADPCM stream + std::array history{}; //!< The previous samples for decoding the ADPCM stream + std::vector> coefficients; //!< The coefficients for decoding the ADPCM stream public: AdpcmDecoder(const std::vector> &coefficients); /** - * @brief This decodes a buffer of ADPCM data into I16 PCM - * @param adpcmData A buffer containing the raw ADPCM data - * @return A buffer containing decoded single channel I16 PCM data + * @brief Decodes a buffer of ADPCM data into I16 PCM */ std::vector Decode(span adpcmData); }; diff --git a/app/src/main/cpp/skyline/audio/circular_buffer.h b/app/src/main/cpp/skyline/audio/circular_buffer.h index 58063bf6..2ea64fb2 100644 --- a/app/src/main/cpp/skyline/audio/circular_buffer.h +++ b/app/src/main/cpp/skyline/audio/circular_buffer.h @@ -7,9 +7,10 @@ namespace skyline::audio { /** - * @brief This class is used to abstract an array into a circular buffer + * @brief An abstraction of an array into a circular buffer * @tparam Type The type of elements stored in the buffer * @tparam Size The maximum size of the circular buffer + * @url https://en.wikipedia.org/wiki/Circular_buffer */ template class CircularBuffer { @@ -17,24 +18,25 @@ namespace skyline::audio { std::array array{}; //!< The internal array holding the circular buffer Type *start{array.begin()}; //!< The start/oldest element of the internal array Type *end{array.begin()}; //!< The end/newest element of the internal array - bool empty{true}; //!< This boolean is used to differentiate between the buffer being full or empty - Mutex mtx; //!< The mutex ensures that the buffer operations don't overlap + bool empty{true}; //!< If the buffer is full or empty, as start == end can mean either + Mutex mtx; //!< Synchronizes buffer operations so they don't overlap public: /** - * @brief This reads data from this buffer into the specified buffer + * @brief Reads data from this buffer into the specified buffer * @param address The address to write buffer data into * @param maxSize The maximum amount of data to write in units of Type * @param copyFunction If this is specified, then this is called rather than memcpy * @return The amount of data written into the input buffer in units of Type */ - inline size_t Read(Type *address, ssize_t maxSize, void copyFunction(Type *, Type *) = {}, ssize_t copyOffset = -1) { + inline size_t Read(span buffer, void copyFunction(Type *, Type *) = {}, ssize_t copyOffset = -1) { std::lock_guard guard(mtx); if (empty) return 0; - ssize_t size{}, sizeBegin{}, sizeEnd{}; + Type* pointer{buffer.data()}; + ssize_t maxSize{static_cast(buffer.size())}, size{}, sizeBegin{}, sizeEnd{}; if (start < end) { sizeEnd = std::min(end - start, maxSize); @@ -50,30 +52,30 @@ namespace skyline::audio { if (copyFunction && copyOffset) { auto sourceEnd{start + ((copyOffset != -1) ? copyOffset : sizeEnd)}; - for (auto source{start}, destination{address}; source < sourceEnd; source++, destination++) + for (auto source{start}, destination{pointer}; source < sourceEnd; source++, destination++) copyFunction(source, destination); if (copyOffset != -1) { - std::memcpy(address + copyOffset, start + copyOffset, (sizeEnd - copyOffset) * sizeof(Type)); + std::memcpy(pointer + copyOffset, start + copyOffset, (sizeEnd - copyOffset) * sizeof(Type)); copyOffset -= sizeEnd; } } else { - std::memcpy(address, start, sizeEnd * sizeof(Type)); + std::memcpy(pointer, start, sizeEnd * sizeof(Type)); } - address += sizeEnd; + pointer += sizeEnd; if (sizeBegin) { if (copyFunction && copyOffset) { auto sourceEnd{array.begin() + ((copyOffset != -1) ? copyOffset : sizeBegin)}; - for (auto source{array.begin()}, destination{address}; source < sourceEnd; source++, destination++) + for (auto source{array.begin()}, destination{pointer}; source < sourceEnd; source++, destination++) copyFunction(source, destination); if (copyOffset != -1) - std::memcpy(array.begin() + copyOffset, address + copyOffset, (sizeBegin - copyOffset) * sizeof(Type)); + std::memcpy(array.begin() + copyOffset, pointer + copyOffset, (sizeBegin - copyOffset) * sizeof(Type)); } else { - std::memcpy(address, array.begin(), sizeBegin * sizeof(Type)); + std::memcpy(pointer, array.begin(), sizeBegin * sizeof(Type)); } start = array.begin() + sizeBegin; @@ -88,19 +90,19 @@ namespace skyline::audio { } /** - * @brief This appends data from the specified buffer into this buffer - * @param address The address of the buffer - * @param size The size of the buffer in units of Type + * @brief Appends data from the specified buffer into this buffer */ - inline void Append(Type *address, ssize_t size) { + inline void Append(span buffer) { std::lock_guard guard(mtx); + Type* pointer{buffer.data()}; + ssize_t size{static_cast(buffer.size())}; while (size) { if (start <= end && end != array.end()) { auto sizeEnd{std::min(array.end() - end, size)}; - std::memcpy(end, address, sizeEnd * sizeof(Type)); + std::memcpy(end, pointer, sizeEnd * sizeof(Type)); - address += sizeEnd; + pointer += sizeEnd; size -= sizeEnd; end += sizeEnd; @@ -109,18 +111,18 @@ namespace skyline::audio { auto sizePostStart{std::min(array.end() - start, size - sizePreStart)}; if (sizePreStart) - std::memcpy((end == array.end()) ? array.begin() : end, address, sizePreStart * sizeof(Type)); + std::memcpy((end == array.end()) ? array.begin() : end, pointer, sizePreStart * sizeof(Type)); if (end == array.end()) end = array.begin() + sizePreStart; else end += sizePreStart; - address += sizePreStart; + pointer += sizePreStart; size -= sizePreStart; if (sizePostStart) - std::memcpy(end, address, sizePostStart * sizeof(Type)); + std::memcpy(end, pointer, sizePostStart * sizeof(Type)); if (start == array.end()) start = array.begin() + sizePostStart; @@ -132,20 +134,12 @@ namespace skyline::audio { else end += sizePostStart; - address += sizePostStart; + pointer += sizePostStart; size -= sizePostStart; } empty = false; } } - - /** - * @brief This appends data from a span to the buffer - * @param data A span containing the data to be appended - */ - inline void Append(span data) { - Append(data.data(), data.size()); - } }; } diff --git a/app/src/main/cpp/skyline/audio/common.h b/app/src/main/cpp/skyline/audio/common.h index 0ed79cc6..6cb9a6bc 100644 --- a/app/src/main/cpp/skyline/audio/common.h +++ b/app/src/main/cpp/skyline/audio/common.h @@ -15,31 +15,22 @@ namespace skyline { }; namespace audio { - /** - * @brief The available PCM stream formats - */ enum class AudioFormat : u8 { Invalid = 0, //!< An invalid PCM format - Int8 = 1, //!< 8 bit integer PCM - Int16 = 2, //!< 16 bit integer PCM - Int24 = 3, //!< 24 bit integer PCM - Int32 = 4, //!< 32 bit integer PCM - Float = 5, //!< Floating point PCM - ADPCM = 6 //!< Adaptive differential PCM + Int8 = 1, //!< 8 bit integer PCM + Int16 = 2, //!< 16 bit integer PCM + Int24 = 3, //!< 24 bit integer PCM + Int32 = 4, //!< 32 bit integer PCM + Float = 5, //!< Floating point PCM + ADPCM = 6, //!< Adaptive differential PCM }; - /** - * @brief The state of an audio track - */ enum class AudioOutState : u8 { Started = 0, //!< Stream is started and is playing Stopped = 1, //!< Stream is stopped, there are no samples left to play - Paused = 2 //!< Stream is paused, some samples may not have been played yet + Paused = 2, //!< Stream is paused, some samples may not have been played yet }; - /** - * @brief This stores information about pushed buffers - */ struct BufferIdentifier { u64 tag; u64 finalSample; //!< The final sample this buffer will be played in, after that the buffer can be safely released @@ -47,12 +38,9 @@ namespace skyline { }; /** - * @brief This saturates the specified value according to the numeric limits of Out + * @brief Saturates the specified value according to the numeric limits of Out * @tparam Out The return value type and the numeric limit clamp * @tparam Intermediate The intermediate type that is converted to from In before clamping - * @tparam In The input value type - * @param value The value to saturate - * @return The saturated value */ template inline Out Saturate(In value) { diff --git a/app/src/main/cpp/skyline/audio/resampler.cpp b/app/src/main/cpp/skyline/audio/resampler.cpp index 2d5e0bac..c34db304 100644 --- a/app/src/main/cpp/skyline/audio/resampler.cpp +++ b/app/src/main/cpp/skyline/audio/resampler.cpp @@ -6,7 +6,7 @@ namespace skyline::audio { /** - * @brief This holds the coefficients for each index of a single output frame + * @brief The coefficients for each index of a single output frame */ struct LutEntry { i32 a; @@ -16,7 +16,7 @@ namespace skyline::audio { }; // @fmt:off - constexpr std::array CurveLut0 = {{ + constexpr std::array CurveLut0{{ {6600, 19426, 6722, 3}, {6479, 19424, 6845, 9}, {6359, 19419, 6968, 15}, {6239, 19412, 7093, 22}, {6121, 19403, 7219, 28}, {6004, 19391, 7345, 34}, {5888, 19377, 7472, 41}, {5773, 19361, 7600, 48}, {5659, 19342, 7728, 55}, {5546, 19321, 7857, 62}, {5434, 19298, 7987, 69}, {5323, 19273, 8118, 77}, diff --git a/app/src/main/cpp/skyline/audio/track.h b/app/src/main/cpp/skyline/audio/track.h index b9ba4a0f..0041df2b 100644 --- a/app/src/main/cpp/skyline/audio/track.h +++ b/app/src/main/cpp/skyline/audio/track.h @@ -20,7 +20,7 @@ namespace skyline::audio { public: CircularBuffer samples; //!< A circular buffer with all appended audio samples - Mutex bufferLock; //!< This mutex ensures that appending to buffers doesn't overlap + Mutex bufferLock; //!< Synchronizes appending to audio buffers AudioOutState playbackState{AudioOutState::Stopped}; //!< The current state of playback u64 sampleCounter{}; //!< A counter used for tracking when buffers have been played and can be released @@ -40,7 +40,7 @@ namespace skyline::audio { } /** - * @brief Stops audio playback. This waits for audio playback to finish before returning. + * @brief Stops audio playback, this waits for audio playback to finish before returning */ void Stop(); diff --git a/app/src/main/cpp/skyline/common.cpp b/app/src/main/cpp/skyline/common.cpp index 7b67cd46..8882e130 100644 --- a/app/src/main/cpp/skyline/common.cpp +++ b/app/src/main/cpp/skyline/common.cpp @@ -146,7 +146,7 @@ namespace skyline { character = '\\'; std::lock_guard guard(mtx); - logFile << "1|" << levelStr[static_cast(level)] << "|" << str << "\n"; + logFile << "1|" << levelCharacter[static_cast(level)] << "|" << str << "\n"; } DeviceState::DeviceState(kernel::OS *os, std::shared_ptr &process, std::shared_ptr jvmManager, std::shared_ptr settings, std::shared_ptr logger) diff --git a/app/src/main/cpp/skyline/common.h b/app/src/main/cpp/skyline/common.h index f47b55b4..0d05ea0a 100644 --- a/app/src/main/cpp/skyline/common.h +++ b/app/src/main/cpp/skyline/common.h @@ -65,11 +65,11 @@ namespace skyline { constexpr u16 DockedResolutionW{1920}; //!< The width component of the docked resolution constexpr u16 DockedResolutionH{1080}; //!< The height component of the docked resolution // Time - constexpr u64 NsInSecond{1000000000}; //!< This is the amount of nanoseconds in a second + constexpr u64 NsInSecond{1000000000}; //!< The amount of nanoseconds in a second } /** - * @brief This is a std::runtime_error with libfmt formatting + * @brief A wrapper over std::runtime_error with libfmt formatting */ class exception : public std::runtime_error { public: @@ -110,7 +110,7 @@ namespace skyline { * @note The multiple needs to be a power of 2 */ template - constexpr inline TypeVal AlignUp(TypeVal value, TypeMul multiple) { + constexpr TypeVal AlignUp(TypeVal value, TypeMul multiple) { multiple--; return (value + multiple) & ~(multiple); } @@ -120,7 +120,7 @@ namespace skyline { * @note The multiple needs to be a power of 2 */ template - constexpr inline TypeVal AlignDown(TypeVal value, TypeMul multiple) { + constexpr TypeVal AlignDown(TypeVal value, TypeMul multiple) { return value & ~(multiple - 1); } @@ -128,7 +128,7 @@ namespace skyline { * @return If the address is aligned with the multiple */ template - constexpr inline bool IsAligned(TypeVal value, TypeMul multiple) { + constexpr bool IsAligned(TypeVal value, TypeMul multiple) { if ((multiple & (multiple - 1)) == 0) return !(value & (multiple - 1U)); else @@ -138,14 +138,14 @@ namespace skyline { /** * @return If the value is page aligned */ - constexpr inline bool PageAligned(u64 value) { + constexpr bool PageAligned(u64 value) { return IsAligned(value, PAGE_SIZE); } /** * @return If the value is word aligned */ - constexpr inline bool WordAligned(u64 value) { + constexpr bool WordAligned(u64 value) { return IsAligned(value, WORD_BIT / 8); } @@ -301,7 +301,7 @@ namespace skyline { span(const Container &) -> span; /** - * @brief The Mutex class is a wrapper around an atomic bool used for synchronization + * @brief The Mutex class is a wrapper around an atomic bool used for low-contention synchronization */ class Mutex { std::atomic_flag flag = ATOMIC_FLAG_INIT; //!< An atomic flag to hold the state of the mutex @@ -334,12 +334,12 @@ namespace skyline { class GroupMutex { public: /** - * @brief This enumeration holds all the possible owners of the mutex + * @brief All the possible owners of the mutex */ enum class Group : u8 { - None = 0, //!< No group owns this mutex + None = 0, //!< No group owns this mutex Group1 = 1, //!< Group 1 owns this mutex - Group2 = 2 //!< Group 2 owns this mutex + Group2 = 2, //!< Group 2 owns this mutex }; /** @@ -366,13 +366,18 @@ namespace skyline { class Logger { private: std::ofstream logFile; //!< An output stream to the log file - const char *levelStr[4] = {"0", "1", "2", "3"}; //!< This is used to denote the LogLevel when written out to a file - static constexpr int levelSyslog[4] = {LOG_ERR, LOG_WARNING, LOG_INFO, LOG_DEBUG}; //!< This corresponds to LogLevel and provides it's equivalent for syslog + std::array levelCharacter{'0', '1', '2', '3'}; //!< The LogLevel as written out to a file + static constexpr std::array levelSyslog{LOG_ERR, LOG_WARNING, LOG_INFO, LOG_DEBUG}; //!< This corresponds to LogLevel and provides it's equivalent for syslog Mutex mtx; //!< A mutex to lock before logging anything public: - enum class LogLevel { Error, Warn, Info, Debug }; //!< The level of a particular log - LogLevel configLevel; //!< The level of logs to write + enum class LogLevel { + Error, + Warn, + Info, + Debug, + }; + LogLevel configLevel; //!< The minimum level of logs to write /** * @param path The path of the log file @@ -484,7 +489,7 @@ namespace skyline { int GetInt(const std::string &key); /** - * @brief Writes all settings keys and values to syslog. This function is for development purposes. + * @brief Writes all settings keys and values to syslog, this function is for development purposes */ void List(const std::shared_ptr &logger); }; @@ -512,22 +517,22 @@ namespace skyline { } /** - * @brief This struct is used to hold the state of a device + * @brief The state of the entire emulator is contained within this class, all objects related to emulation are tied into it */ struct DeviceState { DeviceState(kernel::OS *os, std::shared_ptr &process, std::shared_ptr jvmManager, std::shared_ptr settings, std::shared_ptr logger); - kernel::OS *os; //!< This holds a reference to the OS class - std::shared_ptr &process; //!< This holds a reference to the process object - thread_local static std::shared_ptr thread; //!< This holds a reference to the current thread object - thread_local static ThreadContext *ctx; //!< This holds the context of the thread - std::shared_ptr nce; //!< This holds a reference to the NCE class - std::shared_ptr gpu; //!< This holds a reference to the GPU class - std::shared_ptr audio; //!< This holds a reference to the Audio class - std::shared_ptr input; //!< This holds a reference to the Input class - std::shared_ptr loader; //!< This holds a reference to the Loader class - std::shared_ptr jvm; //!< This holds a reference to the JvmManager class - std::shared_ptr settings; //!< This holds a reference to the Settings class - std::shared_ptr logger; //!< This holds a reference to the Logger class + kernel::OS *os; + std::shared_ptr &process; + thread_local static std::shared_ptr thread; //!< The KThread of the thread which accesses this object + thread_local static ThreadContext *ctx; //!< The context of the guest thread for the corresponding host thread + std::shared_ptr nce; + std::shared_ptr gpu; + std::shared_ptr audio; + std::shared_ptr input; + std::shared_ptr loader; + std::shared_ptr jvm; + std::shared_ptr settings; + std::shared_ptr logger; }; } diff --git a/app/src/main/cpp/skyline/crypto/aes_cipher.h b/app/src/main/cpp/skyline/crypto/aes_cipher.h index 80a8c18d..5ad1fdf9 100644 --- a/app/src/main/cpp/skyline/crypto/aes_cipher.h +++ b/app/src/main/cpp/skyline/crypto/aes_cipher.h @@ -13,14 +13,10 @@ namespace skyline::crypto { class AesCipher { private: mbedtls_cipher_context_t decryptContext; + std::vector buffer; //!< A buffer used to avoid constant memory allocation /** - * @brief Buffer declared as class variable to avoid constant memory allocation - */ - std::vector buffer; - - /** - * @brief Calculates IV for XTS, basically just big to little endian conversion. + * @brief Calculates IV for XTS, basically just big to little endian conversion */ inline static std::array GetTweak(size_t sector) { std::array tweak{}; @@ -35,24 +31,25 @@ namespace skyline::crypto { ~AesCipher(); /** - * @brief Sets initilization vector + * @brief Sets the Initialization Vector */ void SetIV(const std::array &iv); /** - * @note destination and source can be the same + * @brief Decrypts the supplied buffer and outputs the result into the destination buffer + * @note The destination and source buffers can be the same */ void Decrypt(u8 *destination, u8 *source, size_t size); /** - * @brief Decrypts data and writes back to it + * @brief Decrypts the supplied data in-place */ inline void Decrypt(span data) { Decrypt(data.data(), data.data(), data.size()); } /** - * @brief Decrypts data with XTS. IV will get calculated with the given sector + * @brief Decrypts data with XTS, IV will get calculated with the given sector */ void XtsDecrypt(u8 *destination, u8 *source, size_t size, size_t sector, size_t sectorSize); diff --git a/app/src/main/cpp/skyline/gpu.h b/app/src/main/cpp/skyline/gpu.h index 7838f52a..c781e8cf 100644 --- a/app/src/main/cpp/skyline/gpu.h +++ b/app/src/main/cpp/skyline/gpu.h @@ -4,22 +4,19 @@ #pragma once #include -#include -#include -#include "gpu/memory_manager.h" +#include "services/nvdrv/devices/nvmap.h" #include "gpu/gpfifo.h" #include "gpu/syncpoint.h" #include "gpu/engines/maxwell_3d.h" namespace skyline::gpu { /** - * @brief This is used to converge all of the interfaces to the GPU and send the results to a GPU API - * @note We opted for just supporting a single layer and display as it's what basically all games use and wasting cycles on it is pointless + * @brief A common interfaces to the GPU where all objects relevant to it are present */ class GPU { private: - ANativeWindow *window; //!< The ANativeWindow to render to - const DeviceState &state; //!< The state of the device + ANativeWindow *window; //!< The ANativeWindow that is presented to + const DeviceState &state; bool surfaceUpdate{}; //!< If the surface needs to be updated u64 frameTimestamp{}; //!< The timestamp of the last frame being shown @@ -38,19 +35,10 @@ namespace skyline::gpu { gpfifo::GPFIFO gpfifo; std::array syncpoints{}; - /** - * @param window The ANativeWindow to render to - */ GPU(const DeviceState &state); - /** - * @brief The destructor for the GPU class - */ ~GPU(); - /** - * @brief The loop that executes routine GPU functions - */ void Loop(); }; } diff --git a/app/src/main/cpp/skyline/gpu/engines/engine.h b/app/src/main/cpp/skyline/gpu/engines/engine.h index 77906e83..778bb951 100644 --- a/app/src/main/cpp/skyline/gpu/engines/engine.h +++ b/app/src/main/cpp/skyline/gpu/engines/engine.h @@ -8,9 +8,6 @@ #define U32_OFFSET(regs, field) (offsetof(regs, field) / sizeof(u32)) namespace skyline::gpu { - /** - * @brief This enumerates the identifiers used to label a specific engine - */ enum class EngineID { Fermi2D = 0x902D, KeplerMemory = 0xA140, @@ -20,7 +17,7 @@ namespace skyline::gpu { }; /** - * @brief This holds the parameters of a GPU engine method call + * @brief The parameters of a GPU engine method call */ struct MethodParams { u16 method; @@ -31,8 +28,8 @@ namespace skyline::gpu { namespace engine { /** - * @brief The Engine class provides an interface that can be used to communicate with the GPU's internal engines - */ + * @brief The Engine class provides an interface that can be used to communicate with the GPU's internal engines + */ class Engine { protected: const DeviceState &state; @@ -43,8 +40,8 @@ namespace skyline::gpu { virtual ~Engine() = default; /** - * @brief Calls an engine method with the given parameters - */ + * @brief Calls an engine method with the given parameters + */ virtual void CallMethod(MethodParams params) { state.logger->Warn("Called method in unimplemented engine: 0x{:X} args: 0x{:X}", params.method, params.argument); }; diff --git a/app/src/main/cpp/skyline/gpu/engines/gpfifo.h b/app/src/main/cpp/skyline/gpu/engines/gpfifo.h index 56dae9f3..95aa0630 100644 --- a/app/src/main/cpp/skyline/gpu/engines/gpfifo.h +++ b/app/src/main/cpp/skyline/gpu/engines/gpfifo.h @@ -18,9 +18,8 @@ namespace skyline { class GPFIFO : public Engine { private: /** - * @brief This holds the GPFIFO engine's registers - * @url https://github.com/NVIDIA/open-gpu-doc/blob/ab27fc22db5de0d02a4cabe08e555663b62db4d4/classes/host/clb06f.h#L65 - */ + * @url https://github.com/NVIDIA/open-gpu-doc/blob/ab27fc22db5de0d02a4cabe08e555663b62db4d4/classes/host/clb06f.h#L65 + */ #pragma pack(push, 1) union Registers { std::array raw; @@ -30,22 +29,22 @@ namespace skyline { Release = 2, AcqGeq = 4, AcqAnd = 8, - Reduction = 16 + Reduction = 16, }; enum class SemaphoreAcquireSwitch : u8 { Disabled = 0, - Enabled = 1 + Enabled = 1, }; enum class SemaphoreReleaseWfi : u8 { En = 0, - Dis = 1 + Dis = 1, }; enum class SemaphoreReleaseSize : u8 { SixteenBytes = 0, - FourBytes = 1 + FourBytes = 1, }; enum class SemaphoreReduction : u8 { @@ -56,39 +55,39 @@ namespace skyline { Or = 4, Add = 5, Inc = 6, - Dec = 7 + Dec = 7, }; enum class SemaphoreFormat : u8 { Signed = 0, - Unsigned = 1 + Unsigned = 1, }; enum class MemOpTlbInvalidatePdb : u8 { One = 0, - All = 1 + All = 1, }; enum class SyncpointOperation : u8 { Wait = 0, - Incr = 1 + Incr = 1, }; enum class SyncpointWaitSwitch : u8 { Dis = 0, - En = 1 + En = 1, }; enum class WfiScope : u8 { CurrentScgType = 0, - All = 1 + All = 1, }; enum class YieldOp : u8 { Nop = 0, PbdmaTimeslice = 1, RunlistTimeslice = 2, - Tsg = 3 + Tsg = 3, }; struct { diff --git a/app/src/main/cpp/skyline/gpu/engines/maxwell_3d.h b/app/src/main/cpp/skyline/gpu/engines/maxwell_3d.h index 63f27951..6b2423d9 100644 --- a/app/src/main/cpp/skyline/gpu/engines/maxwell_3d.h +++ b/app/src/main/cpp/skyline/gpu/engines/maxwell_3d.h @@ -16,16 +16,16 @@ namespace skyline { namespace gpu::engine { /** - * @brief The Maxwell 3D engine handles processing 3D graphics - */ + * @brief The Maxwell 3D engine handles processing 3D graphics + */ class Maxwell3D : public Engine { private: - std::array macroPositions{}; //!< This holds the positions of each individual macro in macro memory, there can be a maximum of 0x80 macros at any one time + std::array macroPositions{}; //!< The positions of each individual macro in macro memory, there can be a maximum of 0x80 macros at any one time struct { u32 index; std::vector arguments; - } macroInvocation{}; //!< This hold the index and arguments of the macro that is pending execution + } macroInvocation{}; //!< Data for a macro that is pending execution MacroInterpreter macroInterpreter; @@ -35,9 +35,8 @@ namespace skyline { public: /** - * @brief This holds the Maxwell3D engine's register space - * @url https://github.com/devkitPro/deko3d/blob/master/source/maxwell/engine_3d.def#L478 - */ + * @url https://github.com/devkitPro/deko3d/blob/master/source/maxwell/engine_3d.def#L478 + */ #pragma pack(push, 1) union Registers { std::array raw; @@ -56,7 +55,7 @@ namespace skyline { MethodTrack = 0, MethodTrackWithFilter = 1, MethodPassthrough = 2, - MethodReplay = 3 + MethodReplay = 3, }; struct ViewportTransform { @@ -196,7 +195,7 @@ namespace skyline { SubtractGL = 0x8007, ReverseSubtractGL = 0x8008, MinimumGL = 0x800A, - MaximumGL = 0x800B + MaximumGL = 0x800B, }; enum class Factor : u32 { @@ -293,7 +292,7 @@ namespace skyline { Release = 0, Acquire = 1, Counter = 2, - Trap = 3 + Trap = 3, }; enum class ReductionOp : u8 { @@ -348,7 +347,7 @@ namespace skyline { TransformFeedbackOffset = 0x1A, TessControlShaderInvocations = 0x1B, TessEvaluationShaderInvocations = 0x1D, - TessEvaluationShaderPrimitives = 0x1F + TessEvaluationShaderPrimitives = 0x1F, }; enum class StructureSize : u8 { @@ -375,7 +374,7 @@ namespace skyline { enum class CoordOrigin : u8 { LowerLeft = 0, - UpperLeft = 1 + UpperLeft = 1, }; struct { @@ -559,10 +558,10 @@ namespace skyline { static_assert(sizeof(Registers) == (constant::Maxwell3DRegisterCounter * sizeof(u32))); #pragma pack(pop) - Registers registers{}; //!< The Maxwell 3D register space + Registers registers{}; Registers shadowRegisters{}; //!< The shadow registers, their function is controlled by the 'shadowRamControl' register - std::array macroCode{}; //!< This is used to store GPU macros, the 256kb size is from Ryujinx + std::array macroCode{}; //!< This stores GPU macros, the 256kb size is from Ryujinx Maxwell3D(const DeviceState &state); diff --git a/app/src/main/cpp/skyline/gpu/gpfifo.h b/app/src/main/cpp/skyline/gpu/gpfifo.h index 49c73d7b..cb4c6195 100644 --- a/app/src/main/cpp/skyline/gpu/gpfifo.h +++ b/app/src/main/cpp/skyline/gpu/gpfifo.h @@ -4,14 +4,13 @@ #pragma once #include -#include "engines/engine.h" #include "engines/gpfifo.h" #include "memory_manager.h" namespace skyline::gpu { namespace gpfifo { /** - * @brief This contains a single GPFIFO entry that is submitted through 'SubmitGpfifo' + * @brief A GPFIFO entry as submitted through 'SubmitGpfifo' * @url https://nvidia.github.io/open-gpu-doc/manuals/volta/gv100/dev_pbdma.ref.txt * @url https://github.com/NVIDIA/open-gpu-doc/blob/ab27fc22db5de0d02a4cabe08e555663b62db4d4/classes/host/clb06f.h#L155 */ @@ -72,7 +71,7 @@ namespace skyline::gpu { static_assert(sizeof(GpEntry) == sizeof(u64)); /** - * @brief This holds a single pushbuffer method header that describes a compressed method sequence + * @brief A single pushbuffer method header that describes a compressed method sequence * @url https://github.com/NVIDIA/open-gpu-doc/blob/ab27fc22db5de0d02a4cabe08e555663b62db4d4/manuals/volta/gv100/dev_ram.ref.txt#L850 * @url https://github.com/NVIDIA/open-gpu-doc/blob/ab27fc22db5de0d02a4cabe08e555663b62db4d4/classes/host/clb06f.h#L179 */ @@ -84,7 +83,7 @@ namespace skyline::gpu { Grp0SetSubDevMask = 1, Grp0StoreSubDevMask = 2, Grp0UseSubDevMask = 3, - Grp2NonIncMethod = 0 + Grp2NonIncMethod = 0, }; enum class SecOp : u8 { @@ -95,7 +94,7 @@ namespace skyline::gpu { ImmdDataMethod = 4, OneInc = 5, Reserved6 = 6, - EndPbSegment = 7 + EndPbSegment = 7, }; u16 methodAddress : 12; @@ -128,7 +127,7 @@ namespace skyline::gpu { class GPFIFO { private: /** - * @brief This is used to hold a pushbuffer's GPFIFO entry and contents, pushbuffers are made up of several 32-bit words + * @brief A pushbuffer is a descriptor of tasks that need to be executed for a specific client */ struct PushBuffer { GpEntry gpEntry; @@ -149,7 +148,7 @@ namespace skyline::gpu { engine::GPFIFO gpfifoEngine; //!< The engine for processing GPFIFO method calls std::array, 8> subchannels; std::queue pushBufferQueue; - skyline::Mutex pushBufferQueueLock; //!< This is used to lock pushbuffer queue insertions as the GPU runs on a seperate thread + skyline::Mutex pushBufferQueueLock; //!< Synchronizes pushbuffer queue insertions as the GPU is multi-threaded /** * @brief Processes a pushbuffer segment, calling methods as needed @@ -157,7 +156,7 @@ namespace skyline::gpu { void Process(const std::vector &segment); /** - * @brief This sends a method call to the GPU hardware + * @brief Sends a method call to the GPU hardware */ void Send(MethodParams params); diff --git a/app/src/main/cpp/skyline/gpu/macro_interpreter.h b/app/src/main/cpp/skyline/gpu/macro_interpreter.h index 9555bdfd..10207ff8 100644 --- a/app/src/main/cpp/skyline/gpu/macro_interpreter.h +++ b/app/src/main/cpp/skyline/gpu/macro_interpreter.h @@ -15,9 +15,6 @@ namespace skyline::gpu { */ class MacroInterpreter { private: - /** - * @brief This holds a single macro opcode - */ #pragma pack(push, 1) union Opcode { u32 raw; @@ -98,11 +95,10 @@ namespace skyline::gpu { static_assert(sizeof(Opcode) == sizeof(u32)); /** - * @brief This holds information about the Maxwell 3D method to be called in 'Send' + * @brief Metadata about the Maxwell 3D method to be called in 'Send' */ union MethodAddress { u32 raw; - struct { u16 address : 12; u8 increment : 6; diff --git a/app/src/main/cpp/skyline/gpu/memory_manager.cpp b/app/src/main/cpp/skyline/gpu/memory_manager.cpp index 0e02ae4a..ec54ad3a 100644 --- a/app/src/main/cpp/skyline/gpu/memory_manager.cpp +++ b/app/src/main/cpp/skyline/gpu/memory_manager.cpp @@ -11,23 +11,23 @@ namespace skyline::gpu::vmm { // Create the initial chunk that will be split to create new chunks ChunkDescriptor baseChunk(GpuAddressSpaceBase, GpuAddressSpaceSize, 0, ChunkState::Unmapped); - chunkList.push_back(baseChunk); + chunks.push_back(baseChunk); } std::optional MemoryManager::FindChunk(u64 size, ChunkState state) { - auto chunk{std::find_if(chunkList.begin(), chunkList.end(), [size, state](const ChunkDescriptor &chunk) -> bool { + auto chunk{std::find_if(chunks.begin(), chunks.end(), [size, state](const ChunkDescriptor &chunk) -> bool { return chunk.size > size && chunk.state == state; })}; - if (chunk != chunkList.end()) + if (chunk != chunks.end()) return *chunk; return std::nullopt; } u64 MemoryManager::InsertChunk(const ChunkDescriptor &newChunk) { - auto chunkEnd{chunkList.end()}; - for (auto chunk{chunkList.begin()}; chunk != chunkEnd; chunk++) { + auto chunkEnd{chunks.end()}; + for (auto chunk{chunks.begin()}; chunk != chunkEnd; chunk++) { if (chunk->CanContain(newChunk)) { auto oldChunk{*chunk}; u64 newSize{newChunk.address - chunk->address}; @@ -38,11 +38,11 @@ namespace skyline::gpu::vmm { } else { chunk->size = newSize; - chunk = chunkList.insert(std::next(chunk), newChunk); + chunk = chunks.insert(std::next(chunk), newChunk); } if (extension) - chunkList.insert(std::next(chunk), ChunkDescriptor(newChunk.address + newChunk.size, extension, (oldChunk.state == ChunkState::Mapped) ? (oldChunk.cpuAddress + newSize + newChunk.size) : 0, oldChunk.state)); + chunks.insert(std::next(chunk), ChunkDescriptor(newChunk.address + newChunk.size, extension, (oldChunk.state == ChunkState::Mapped) ? (oldChunk.cpuAddress + newSize + newChunk.size) : 0, oldChunk.state)); return newChunk.address; } else if (chunk->address + chunk->size > newChunk.address) { @@ -54,8 +54,8 @@ namespace skyline::gpu::vmm { if (tailChunk->address + tailChunk->size >= newChunk.address + newChunk.size) break; - tailChunk = chunkList.erase(tailChunk); - chunkEnd = chunkList.end(); + tailChunk = chunks.erase(tailChunk); + chunkEnd = chunks.end(); } // The given chunk is too large to fit into existing chunks @@ -74,7 +74,7 @@ namespace skyline::gpu::vmm { if (headChunk->size == 0) *headChunk = newChunk; else - chunkList.insert(std::next(headChunk), newChunk); + chunks.insert(std::next(headChunk), newChunk); return newChunk.address; } @@ -132,11 +132,11 @@ namespace skyline::gpu::vmm { if (!util::IsAligned(address, constant::GpuPageSize)) return false; - auto chunk{std::find_if(chunkList.begin(), chunkList.end(), [address](const ChunkDescriptor &chunk) -> bool { + auto chunk{std::find_if(chunks.begin(), chunks.end(), [address](const ChunkDescriptor &chunk) -> bool { return chunk.address == address; })}; - if (chunk == chunkList.end()) + if (chunk == chunks.end()) return false; chunk->state = ChunkState::Reserved; @@ -146,11 +146,11 @@ namespace skyline::gpu::vmm { } void MemoryManager::Read(u8 *destination, u64 address, u64 size) const { - auto chunk{std::upper_bound(chunkList.begin(), chunkList.end(), address, [](const u64 address, const ChunkDescriptor &chunk) -> bool { + auto chunk{std::upper_bound(chunks.begin(), chunks.end(), address, [](const u64 address, const ChunkDescriptor &chunk) -> bool { return address < chunk.address; })}; - if (chunk == chunkList.end() || chunk->state != ChunkState::Mapped) + if (chunk == chunks.end() || chunk->state != ChunkState::Mapped) throw exception("Failed to read region in GPU address space: Address: 0x{:X}, Size: 0x{:X}", address, size); chunk--; @@ -166,7 +166,7 @@ namespace skyline::gpu::vmm { size -= readSize; if (size) { - if (++chunk == chunkList.end() || chunk->state != ChunkState::Mapped) + if (++chunk == chunks.end() || chunk->state != ChunkState::Mapped) throw exception("Failed to read region in GPU address space: Address: 0x{:X}, Size: 0x{:X}", address, size); readAddress = chunk->cpuAddress; @@ -176,11 +176,11 @@ namespace skyline::gpu::vmm { } void MemoryManager::Write(u8 *source, u64 address, u64 size) const { - auto chunk{std::upper_bound(chunkList.begin(), chunkList.end(), address, [](const u64 address, const ChunkDescriptor &chunk) -> bool { + auto chunk{std::upper_bound(chunks.begin(), chunks.end(), address, [](const u64 address, const ChunkDescriptor &chunk) -> bool { return address < chunk.address; })}; - if (chunk == chunkList.end() || chunk->state != ChunkState::Mapped) + if (chunk == chunks.end() || chunk->state != ChunkState::Mapped) throw exception("Failed to write region in GPU address space: Address: 0x{:X}, Size: 0x{:X}", address, size); chunk--; @@ -196,7 +196,7 @@ namespace skyline::gpu::vmm { size -= writeSize; if (size) { - if (++chunk == chunkList.end() || chunk->state != ChunkState::Mapped) + if (++chunk == chunks.end() || chunk->state != ChunkState::Mapped) throw exception("Failed to write region in GPU address space: Address: 0x{:X}, Size: 0x{:X}", address, size); writeAddress = chunk->cpuAddress; diff --git a/app/src/main/cpp/skyline/gpu/memory_manager.h b/app/src/main/cpp/skyline/gpu/memory_manager.h index 476e32d2..68740015 100644 --- a/app/src/main/cpp/skyline/gpu/memory_manager.h +++ b/app/src/main/cpp/skyline/gpu/memory_manager.h @@ -11,44 +11,38 @@ namespace skyline { } namespace gpu::vmm { - /** - * @brief This enumerates the possible states of a memory chunk - */ enum ChunkState { Unmapped, //!< The chunk is unmapped Reserved, //!< The chunk is reserved Mapped //!< The chunk is mapped and a CPU side address is present }; - /** - * @brief This describes a chunk of memory and all of it's individual attributes - */ struct ChunkDescriptor { u64 address; //!< The address of the chunk in the GPU address space u64 size; //!< The size of the chunk in bytes u64 cpuAddress; //!< The address of the chunk in the CPU address space (if mapped) - ChunkState state; //!< The state of the chunk + ChunkState state; ChunkDescriptor(u64 address, u64 size, u64 cpuAddress, ChunkState state) : address(address), size(size), cpuAddress(cpuAddress), state(state) {} /** - * @param chunk The chunk to check - * @return If the given chunk can be contained wholly within this chunk - */ + * @return If the given chunk can be contained wholly within this chunk + */ inline bool CanContain(const ChunkDescriptor &chunk) { return (chunk.address >= this->address) && ((this->size + this->address) >= (chunk.size + chunk.address)); } }; /** - * @brief The MemoryManager class handles the mapping of the GPU address space - */ + * @brief The MemoryManager class handles the mapping of the GPU address space + */ class MemoryManager { private: const DeviceState &state; + std::vector chunks; /** - * @brief This finds a chunk of the specified type in the GPU address space that is larger than the given size + * @brief Finds a chunk of the specified type in the GPU address space that is larger than the given size * @param size The minimum size of the chunk to find * @param state The state desired state of the chunk to find * @return The first unmapped chunk in the GPU address space that fits the requested size @@ -56,7 +50,7 @@ namespace skyline { std::optional FindChunk(u64 size, ChunkState state); /** - * @brief This inserts a chunk into the chunk list, resizing and splitting as necessary + * @brief Inserts a chunk into the chunk list, resizing and splitting as necessary * @param newChunk The chunk to insert * @return The base virtual GPU address of the inserted chunk */ @@ -64,17 +58,16 @@ namespace skyline { public: MemoryManager(const DeviceState &state); - std::vector chunkList; //!< This vector holds all the chunk descriptors /** - * @brief This reserves a region of the GPU address space so it will not be chosen automatically when mapping + * @brief Reserves a region of the GPU address space so it will not be chosen automatically when mapping * @param size The size of the region to reserve * @return The virtual GPU base address of the region base */ u64 ReserveSpace(u64 size); /** - * @brief This reserves a fixed region of the GPU address space so it will not be chosen automatically when mapping + * @brief Reserves a fixed region of the GPU address space so it will not be chosen automatically when mapping * @param address The virtual base address of the region to allocate * @param size The size of the region to allocate * @return The virtual address of the region base @@ -82,7 +75,7 @@ namespace skyline { u64 ReserveFixed(u64 address, u64 size); /** - * @brief This maps a physical CPU memory region to an automatically chosen virtual memory region + * @brief Maps a physical CPU memory region to an automatically chosen virtual memory region * @param address The physical CPU address of the region to be mapped into the GPU's address space * @param size The size of the region to map * @return The virtual address of the region base @@ -90,7 +83,7 @@ namespace skyline { u64 MapAllocate(u64 address, u64 size); /** - * @brief This maps a physical CPU memory region to a fixed virtual memory region + * @brief Maps a physical CPU memory region to a fixed virtual memory region * @param address The target virtual address of the region * @param cpuAddress The physical CPU address of the region to be mapped into the GPU's address space * @param size The size of the region to map @@ -99,7 +92,7 @@ namespace skyline { u64 MapFixed(u64 address, u64 cpuAddress, u64 size); /** - * @brief This unmaps the chunk that starts at 'offset' from the GPU address space + * @brief Unmaps the chunk that starts at 'offset' from the GPU address space * @return Whether the operation succeeded */ bool Unmap(u64 address); @@ -108,7 +101,6 @@ namespace skyline { /** * @brief Reads in a span from a region of the GPU virtual address space - * @tparam T The type of span to read into */ template void Read(span destination, u64 address) const { @@ -138,7 +130,6 @@ namespace skyline { /** * @brief Reads in an object from a region of the GPU virtual address space - * @tparam T The type of object to return */ template void Write(T source, u64 address) const { diff --git a/app/src/main/cpp/skyline/gpu/syncpoint.h b/app/src/main/cpp/skyline/gpu/syncpoint.h index 3ee0ec17..702eb609 100644 --- a/app/src/main/cpp/skyline/gpu/syncpoint.h +++ b/app/src/main/cpp/skyline/gpu/syncpoint.h @@ -16,15 +16,12 @@ namespace skyline { */ class Syncpoint { private: - /** - * @brief This holds information about a single waiter on a syncpoint - */ struct Waiter { - u32 threshold; - std::function callback; + u32 threshold; //!< The syncpoint value to wait on to be reached + std::function callback; //!< The callback to do after the wait has ended }; - Mutex waiterLock; //!< Locks insertions and deletions of waiters + Mutex waiterLock; //!< Synchronizes insertions and deletions of waiters std::map waiterMap; u64 nextWaiterId{1}; diff --git a/app/src/main/cpp/skyline/gpu/texture.cpp b/app/src/main/cpp/skyline/gpu/texture.cpp index 0f73329e..0feaba0b 100644 --- a/app/src/main/cpp/skyline/gpu/texture.cpp +++ b/app/src/main/cpp/skyline/gpu/texture.cpp @@ -9,6 +9,22 @@ namespace skyline::gpu { GuestTexture::GuestTexture(const DeviceState &state, u64 address, texture::Dimensions dimensions, texture::Format format, texture::TileMode tiling, texture::TileConfig layout) : state(state), address(address), dimensions(dimensions), format(format), tileMode(tiling), tileConfig(layout) {} + std::shared_ptr GuestTexture::InitializeTexture(std::optional format, std::optional dimensions, texture::Swizzle swizzle) { + if (!host.expired()) + throw exception("Trying to create multiple Texture objects from a single GuestTexture"); + auto sharedHost{std::make_shared(state, shared_from_this(), dimensions ? *dimensions : this->dimensions, format ? *format : this->format, swizzle)}; + host = sharedHost; + return sharedHost; + } + + std::shared_ptr GuestTexture::InitializePresentationTexture() { + if (!host.expired()) + throw exception("Trying to create multiple PresentationTexture objects from a single GuestTexture"); + auto presentation{std::make_shared(state, shared_from_this(), dimensions, format)}; + host = std::static_pointer_cast(presentation); + return presentation; + } + Texture::Texture(const DeviceState &state, std::shared_ptr guest, texture::Dimensions dimensions, texture::Format format, texture::Swizzle swizzle) : state(state), guest(guest), dimensions(dimensions), format(format), swizzle(swizzle) { SynchronizeHost(); } diff --git a/app/src/main/cpp/skyline/gpu/texture.h b/app/src/main/cpp/skyline/gpu/texture.h index 7559af52..cdd8a778 100644 --- a/app/src/main/cpp/skyline/gpu/texture.h +++ b/app/src/main/cpp/skyline/gpu/texture.h @@ -12,13 +12,10 @@ namespace skyline { } namespace gpu { namespace texture { - /* - * @brief This is used to hold the dimensions of a surface - */ struct Dimensions { - u32 width; //!< The width of the surface - u32 height; //!< The height of the surface - u32 depth; //!< The depth of the surface + u32 width; + u32 height; + u32 depth; constexpr Dimensions() : width(0), height(0), depth(0) {} @@ -26,34 +23,25 @@ namespace skyline { constexpr Dimensions(u32 width, u32 height, u32 depth) : width(width), height(height), depth(depth) {} - /** - * @return If the specified dimension is equal to this one - */ - constexpr inline bool operator==(const Dimensions &dimensions) { + constexpr bool operator==(const Dimensions &dimensions) { return (width == dimensions.width) && (height == dimensions.height) && (depth == dimensions.depth); } - /** - * @return If the specified dimension is not equal to this one - */ - constexpr inline bool operator!=(const Dimensions &dimensions) { + constexpr bool operator!=(const Dimensions &dimensions) { return (width != dimensions.width) || (height != dimensions.height) || (depth != dimensions.depth); } }; /** - * @brief This is used to hold the attributes of a texture format + * @note Blocks refers to the atomic unit of a compressed format (IE: The minimum amount of data that can be decompressed) */ struct Format { - u8 bpb; //!< Bytes Per Block, this is to accommodate compressed formats - u16 blockHeight; //!< The height of a single block - u16 blockWidth; //!< The width of a single block - vk::Format vkFormat; //!< The underlying Vulkan type of the format + u8 bpb; //!< Bytes Per Block, this is used instead of bytes per pixel as that might not be a whole number for compressed formats + u16 blockHeight; //!< The height of a block in pixels + u16 blockWidth; //!< The width of a block in pixels + vk::Format vkFormat; - /** - * @return If this is a compressed texture format or not - */ - inline constexpr bool IsCompressed() { + constexpr bool IsCompressed() { return (blockHeight != 1) || (blockWidth != 1); } @@ -63,42 +51,32 @@ namespace skyline { * @param depth The depth of the texture in layers * @return The size of the texture in bytes */ - inline constexpr size_t GetSize(u32 width, u32 height, u32 depth = 1) { + constexpr size_t GetSize(u32 width, u32 height, u32 depth = 1) { return (((width / blockWidth) * (height / blockHeight)) * bpb) * depth; } - /** - * @param dimensions The dimensions of a texture - * @return The size of the texture in bytes - */ - inline constexpr size_t GetSize(Dimensions dimensions) { + constexpr size_t GetSize(Dimensions dimensions) { return GetSize(dimensions.width, dimensions.height, dimensions.depth); } - /** - * @return If the specified format is equal to this one - */ - inline constexpr bool operator==(const Format &format) { + constexpr bool operator==(const Format &format) { return vkFormat == format.vkFormat; } - /** - * @return If the specified format is not equal to this one - */ - inline constexpr bool operator!=(const Format &format) { + constexpr bool operator!=(const Format &format) { return vkFormat != format.vkFormat; } /** * @return If this format is actually valid or not */ - inline constexpr operator bool() { + constexpr operator bool() { return bpb; } }; /** - * @brief This describes the linearity of a texture. Refer to Chapter 20.1 of the Tegra X1 TRM for information. + * @brief The linearity of a texture, refer to Chapter 20.1 of the Tegra X1 TRM for information */ enum class TileMode { Linear, //!< This is a purely linear texture @@ -107,7 +85,7 @@ namespace skyline { }; /** - * @brief This holds the parameters of the tiling mode, covered in Table 76 in the Tegra X1 TRM + * @brief The parameters of the tiling mode, covered in Table 76 in the Tegra X1 TRM */ union TileConfig { struct { @@ -118,9 +96,6 @@ namespace skyline { u32 pitch; //!< The pitch of the texture if it's pitch linear }; - /** - * @brief This enumerates all of the channel swizzle options - */ enum class SwizzleChannel { Zero, //!< Write 0 to the channel One, //!< Write 1 to the channel @@ -130,9 +105,6 @@ namespace skyline { Alpha, //!< Alpha channel }; - /** - * @brief This holds all of the texture swizzles on each color channel - */ struct Swizzle { SwizzleChannel red{SwizzleChannel::Red}; //!< Swizzle for the red channel SwizzleChannel green{SwizzleChannel::Green}; //!< Swizzle for the green channel @@ -145,109 +117,95 @@ namespace skyline { class PresentationTexture; /** - * @brief This class is used to hold metadata about a guest texture and can be used to create a host Texture object + * @brief A texture present in guest memory, it can be used to create a corresponding Texture object for usage on the host */ class GuestTexture : public std::enable_shared_from_this { private: - const DeviceState &state; //!< The state of the device + const DeviceState &state; public: u64 address; //!< The address of the texture in guest memory - std::shared_ptr host; //!< The corresponding host texture object - texture::Dimensions dimensions; //!< The dimensions of the texture - texture::Format format; //!< The format of the texture - texture::TileMode tileMode; //!< The tiling mode of the texture - texture::TileConfig tileConfig; //!< The tiling configuration of the texture + std::weak_ptr host; //!< A host texture (if any) that was created from this guest texture + texture::Dimensions dimensions; + texture::Format format; + texture::TileMode tileMode; + texture::TileConfig tileConfig; GuestTexture(const DeviceState &state, u64 address, texture::Dimensions dimensions, texture::Format format, texture::TileMode tileMode = texture::TileMode::Linear, texture::TileConfig tileConfig = {}); - inline constexpr size_t Size() { + constexpr size_t Size() { return format.GetSize(dimensions); } /** - * @brief This creates a corresponding host texture object for this guest texture + * @brief Creates a corresponding host texture object for this guest texture * @param format The format of the host texture (Defaults to the format of the guest texture) * @param dimensions The dimensions of the host texture (Defaults to the dimensions of the host texture) * @param swizzle The channel swizzle of the host texture (Defaults to no channel swizzling) * @return A shared pointer to the host texture object * @note There can only be one host texture for a corresponding guest texture */ - std::shared_ptr InitializeTexture(std::optional format = std::nullopt, std::optional dimensions = std::nullopt, texture::Swizzle swizzle = {}) { - if (host) - throw exception("Trying to create multiple Texture objects from a single GuestTexture"); - host = std::make_shared(state, shared_from_this(), dimensions ? *dimensions : this->dimensions, format ? *format : this->format, swizzle); - return host; - } + std::shared_ptr InitializeTexture(std::optional format = std::nullopt, std::optional dimensions = std::nullopt, texture::Swizzle swizzle = {}); protected: - std::shared_ptr InitializePresentationTexture() { - if (host) - throw exception("Trying to create multiple PresentationTexture objects from a single GuestTexture"); - auto presentation{std::make_shared(state, shared_from_this(), dimensions, format)}; - host = std::static_pointer_cast(presentation); - return presentation; - } + std::shared_ptr InitializePresentationTexture(); friend service::hosbinder::GraphicBufferProducer; }; /** - * @brief This class is used to store a texture which is backed by host objects + * @brief A texture which is backed by host constructs while being synchronized with the underlying guest texture */ class Texture { private: - const DeviceState &state; //!< The state of the device + const DeviceState &state; public: std::vector backing; //!< The object that holds a host copy of the guest texture (Will be replaced with a vk::Image) - std::shared_ptr guest; //!< The corresponding guest texture object - texture::Dimensions dimensions; //!< The dimensions of the texture - texture::Format format; //!< The format of the host texture - texture::Swizzle swizzle; //!< The swizzle of the host texture + std::shared_ptr guest; //!< The guest texture from which this was created, it is required for syncing + texture::Dimensions dimensions; + texture::Format format; + texture::Swizzle swizzle; public: Texture(const DeviceState &state, std::shared_ptr guest, texture::Dimensions dimensions, texture::Format format, texture::Swizzle swizzle); public: /** - * @brief This convert this texture to the specified tiling mode + * @brief Convert this texture to the specified tiling mode * @param tileMode The tiling mode to convert it to * @param tileConfig The configuration for the tiling mode (Can be default argument for Linear) */ void ConvertTileMode(texture::TileMode tileMode, texture::TileConfig tileConfig = {}); /** - * @brief This sets the texture dimensions to the specified ones (As long as they are within the GuestTexture's range) - * @param dimensions The dimensions to adjust the texture to + * @brief Converts the texture dimensions to the specified ones (As long as they are within the GuestTexture's range) */ void SetDimensions(texture::Dimensions dimensions); /** - * @brief This sets the format to the specified one - * @param format The format to change the texture to + * @brief Converts the texture to have the specified format */ void SetFormat(texture::Format format); /** - * @brief This sets the channel swizzle to the specified one - * @param swizzle The channel swizzle to the change the texture to + * @brief Change the texture channel swizzle to the specified one */ void SetSwizzle(texture::Swizzle swizzle); /** - * @brief This synchronizes the host texture with the guest after it has been modified + * @brief Synchronizes the host texture with the guest after it has been modified */ void SynchronizeHost(); /** - * @brief This synchronizes the guest texture with the host texture after it has been modified + * @brief Synchronizes the guest texture with the host texture after it has been modified */ void SynchronizeGuest(); }; /** - * @brief This class is used to hold a texture object alongside a release callback used for display presentation + * @brief A texture object alongside a release callback used for display presentation */ class PresentationTexture : public Texture { public: diff --git a/app/src/main/cpp/skyline/input.h b/app/src/main/cpp/skyline/input.h index fbd2b75b..bf3f94dc 100644 --- a/app/src/main/cpp/skyline/input.h +++ b/app/src/main/cpp/skyline/input.h @@ -11,7 +11,7 @@ namespace skyline::input { /** - * @brief The Input class manages translating host input to guest input + * @brief The Input class manages components responsible for translating host input to guest input */ class Input { private: diff --git a/app/src/main/cpp/skyline/input/npad.h b/app/src/main/cpp/skyline/input/npad.h index f7e8a4a1..c8477db9 100644 --- a/app/src/main/cpp/skyline/input/npad.h +++ b/app/src/main/cpp/skyline/input/npad.h @@ -16,7 +16,7 @@ namespace skyline::input { }; /** - * @brief This class is used to manage all NPad devices and their allocations to Player objects + * @brief All NPad devices and their allocations to Player objects are managed by this class */ class NpadManager { private: @@ -26,11 +26,11 @@ namespace skyline::input { friend NpadDevice; /** - * @brief This translates an NPad's ID into it's index in the array + * @brief Translates an NPad's ID into it's index in the array * @param id The ID of the NPad to translate * @return The corresponding index of the NPad in the array */ - static constexpr inline size_t Translate(NpadId id) { + static constexpr size_t Translate(NpadId id) { switch (id) { case NpadId::Handheld: return 8; @@ -45,7 +45,7 @@ namespace skyline::input { std::recursive_mutex mutex; //!< This mutex must be locked before any modifications to class members std::array npads; std::array controllers; - std::vector supportedIds; //!< The NpadId(s) that are supported by the application + std::vector supportedIds; //!< The NPadId(s) that are supported by the application NpadStyleSet styles; //!< The styles that are supported by the application NpadJoyOrientation orientation{}; //!< The orientation all of Joy-Cons are in (This affects stick transformation for them) @@ -57,30 +57,30 @@ namespace skyline::input { /** * @return A reference to the NPad with the specified ID */ - constexpr inline NpadDevice &at(NpadId id) { + constexpr NpadDevice &at(NpadId id) { return npads.at(Translate(id)); } /** * @return A reference to the NPad with the specified ID */ - constexpr inline NpadDevice &operator[](NpadId id) noexcept { + constexpr NpadDevice &operator[](NpadId id) noexcept { return npads.operator[](Translate(id)); } /** - * @brief This deduces all the mappings from guest controllers -> players based on the configuration supplied by HID services and available controllers + * @brief Deduces all the mappings from guest controllers -> players based on the configuration supplied by HID services and available controllers * @note If any class members were edited, the mutex shouldn't be released till this is called */ void Update(); /** - * @brief This activates the mapping between guest controllers -> players, a call to this is required for function + * @brief Activates the mapping between guest controllers -> players, a call to this is required for function */ void Activate(); /** - * @brief This disables any activate mappings from guest controllers -> players till Activate has been called + * @brief Disables any activate mappings from guest controllers -> players till Activate has been called */ void Deactivate(); }; diff --git a/app/src/main/cpp/skyline/input/npad_device.h b/app/src/main/cpp/skyline/input/npad_device.h index 69377ec3..3a06aa03 100644 --- a/app/src/main/cpp/skyline/input/npad_device.h +++ b/app/src/main/cpp/skyline/input/npad_device.h @@ -14,7 +14,7 @@ namespace skyline::constant { namespace skyline::input { /** - * @brief This enumerates the orientations the Joy-Con(s) can be held in + * @brief The orientations the Joy-Con(s) can be held in */ enum class NpadJoyOrientation : i64 { Vertical = 0, @@ -22,7 +22,7 @@ namespace skyline::input { }; /** - * @brief A union of all the NPad styles (https://switchbrew.org/wiki/HID_services#NpadStyleTag) + * @url https://switchbrew.org/wiki/HID_services#NpadStyleTag */ union NpadStyleSet { u32 raw; @@ -41,9 +41,6 @@ namespace skyline::input { }; static_assert(sizeof(NpadStyleSet) == 0x4); - /** - * @brief This enumerates all of the axis on NPads - */ enum class NpadAxisId { LX, //!< Left Stick X LY, //!< Left Stick Y @@ -52,7 +49,7 @@ namespace skyline::input { }; /** - * @brief This enumerates all the possible IDs for an NPad (https://switchbrew.org/wiki/HID_services#NpadIdType) + * @url https://switchbrew.org/wiki/HID_services#NpadIdType */ enum class NpadId : u32 { Player1 = 0x0, @@ -114,7 +111,7 @@ namespace skyline::input { class NpadManager; /** - * @brief This class abstracts a single NPad device that controls it's own state and shared memory section + * @brief An easy to use interface for a NPad which abstracts away the complicated details */ class NpadDevice { private: @@ -124,15 +121,15 @@ namespace skyline::input { u64 globalTimestamp{}; //!< An incrementing timestamp that's common across all sections /** - * @brief This updates the headers and creates a new entry in HID Shared Memory + * @brief Updates the headers and creates a new entry in HID Shared Memory * @param info The controller info of the NPad that needs to be updated * @return The next entry that has been created with values from the last entry */ NpadControllerState &GetNextEntry(NpadControllerInfo &info); /** - * @return The NpadControllerInfo for this controller based on it's type - */ + * @return The NpadControllerInfo for this controller based on it's type + */ NpadControllerInfo &GetControllerInfo(); public: @@ -147,41 +144,33 @@ namespace skyline::input { NpadDevice(NpadManager &manager, NpadSection §ion, NpadId id); - /** - * @brief This sets a Joy-Con's Assignment Mode - * @param assignment The assignment mode to set this controller to - */ inline void SetAssignment(NpadJoyAssignment assignment) { section.header.assignment = assignment; } - /** - * @return The assignment mode of this Joy-Con - */ inline NpadJoyAssignment GetAssignment() { return section.header.assignment; } /** - * @brief This connects this controller to the guest - * @param newType The type of controller to connect as + * @brief Connects this controller to the guest */ void Connect(NpadControllerType newType); /** - * @brief This disconnects this controller from the guest + * @brief Disconnects this controller from the guest */ void Disconnect(); /** - * @brief This changes the state of buttons to the specified state + * @brief Changes the state of buttons to the specified state * @param mask A bit-field mask of all the buttons to change * @param pressed If the buttons were pressed or released */ void SetButtonState(NpadButton mask, bool pressed); /** - * @brief This sets the value of an axis to the specified value + * @brief Sets the value of an axis to the specified value * @param axis The axis to set the value of * @param value The value to set */ diff --git a/app/src/main/cpp/skyline/input/sections/BasicXpad.h b/app/src/main/cpp/skyline/input/sections/BasicXpad.h index 5da1ba73..ec39b5d2 100644 --- a/app/src/main/cpp/skyline/input/sections/BasicXpad.h +++ b/app/src/main/cpp/skyline/input/sections/BasicXpad.h @@ -7,7 +7,7 @@ namespace skyline::input { /** - * @brief The structure of an entry for BasicXpad (https://switchbrew.org/wiki/HID_Shared_Memory#BasicXpadState) + * @url https://switchbrew.org/wiki/HID_Shared_Memory#BasicXpadState */ struct BasicXpadState { u64 globalTimestamp; //!< The global timestamp in samples @@ -16,7 +16,7 @@ namespace skyline::input { static_assert(sizeof(BasicXpadState) == 0x28); /** - * @brief The structure of the BasicXpad section (https://switchbrew.org/wiki/HID_Shared_Memory#BasicXpad) + * @url https://switchbrew.org/wiki/HID_Shared_Memory#BasicXpad */ struct BasicXpadSection { CommonHeader header; diff --git a/app/src/main/cpp/skyline/input/sections/Button.h b/app/src/main/cpp/skyline/input/sections/Button.h index 64ddc6f0..8ab5a3ab 100644 --- a/app/src/main/cpp/skyline/input/sections/Button.h +++ b/app/src/main/cpp/skyline/input/sections/Button.h @@ -7,7 +7,9 @@ namespace skyline::input { /** - * @brief The state structure for all Button sections (HomeButton, SleepButton, CaptureButton) + * @url https://switchbrew.org/wiki/HID_Shared_Memory#HomeButtonState + * @url https://switchbrew.org/wiki/HID_Shared_Memory#SleepButtonState + * @url https://switchbrew.org/wiki/HID_Shared_Memory#CaptureButtonState */ struct ButtonState { u64 globalTimestamp; //!< The global timestamp in samples @@ -16,7 +18,9 @@ namespace skyline::input { static_assert(sizeof(ButtonState) == 0x18); /** - * @brief The section structure for all Button sections (HomeButton, SleepButton, CaptureButton) + * @url https://switchbrew.org/wiki/HID_Shared_Memory#HomeButton + * @url https://switchbrew.org/wiki/HID_Shared_Memory#SleepButton + * @url https://switchbrew.org/wiki/HID_Shared_Memory#CaptureButton */ struct ButtonSection { CommonHeader header; diff --git a/app/src/main/cpp/skyline/input/sections/ConsoleSixAxisSensor.h b/app/src/main/cpp/skyline/input/sections/ConsoleSixAxisSensor.h index fbc00589..2aeed69d 100644 --- a/app/src/main/cpp/skyline/input/sections/ConsoleSixAxisSensor.h +++ b/app/src/main/cpp/skyline/input/sections/ConsoleSixAxisSensor.h @@ -7,7 +7,8 @@ namespace skyline::input { /** - * @brief The structure of the ConsoleSixAxisSensor (SevenSixAxisSensor) section (https://switchbrew.org/wiki/HID_Shared_Memory#ConsoleSixAxisSensor) + * @url https://switchbrew.org/wiki/HID_Shared_Memory#ConsoleSixAxisSensor + * @note Referred to as SevenSixAxisSensor in HID Services * @note This is seemingly used to calibrate the gyroscope bias values over time */ struct ConsoleSixAxisSensorSection { diff --git a/app/src/main/cpp/skyline/input/sections/DebugPad.h b/app/src/main/cpp/skyline/input/sections/DebugPad.h index 86179ba7..4b1049de 100644 --- a/app/src/main/cpp/skyline/input/sections/DebugPad.h +++ b/app/src/main/cpp/skyline/input/sections/DebugPad.h @@ -7,7 +7,7 @@ namespace skyline::input { /** - * @brief The structure of an entry for DebugPad (https://switchbrew.org/wiki/HID_Shared_Memory#DebugPadState) + * @url https://switchbrew.org/wiki/HID_Shared_Memory#DebugPadState */ struct DebugPadState { u64 timestamp; //!< The total timestamp in ticks @@ -16,7 +16,7 @@ namespace skyline::input { static_assert(sizeof(DebugPadState) == 0x28); /** - * @brief The structure of the DebugPad section (https://switchbrew.org/wiki/HID_Shared_Memory#DebugPad) + * @url https://switchbrew.org/wiki/HID_Shared_Memory#DebugPad */ struct DebugPadSection { CommonHeader header; diff --git a/app/src/main/cpp/skyline/input/sections/Gesture.h b/app/src/main/cpp/skyline/input/sections/Gesture.h index 3d3bca60..4a95715a 100644 --- a/app/src/main/cpp/skyline/input/sections/Gesture.h +++ b/app/src/main/cpp/skyline/input/sections/Gesture.h @@ -7,7 +7,7 @@ namespace skyline::input { /** - * @brief The structure of an entry for Gesture (https://switchbrew.org/wiki/HID_Shared_Memory#GestureState) + * @url https://switchbrew.org/wiki/HID_Shared_Memory#GestureState */ struct GestureState { u64 globalTimestamp; //!< The global timestamp in samples @@ -16,7 +16,7 @@ namespace skyline::input { static_assert(sizeof(GestureState) == 0x68); /** - * @brief The structure of the Gesture section (https://switchbrew.org/wiki/HID_Shared_Memory#Gesture) + * @url https://switchbrew.org/wiki/HID_Shared_Memory#Gesture */ struct GestureSection { CommonHeader header; diff --git a/app/src/main/cpp/skyline/input/sections/InputDetector.h b/app/src/main/cpp/skyline/input/sections/InputDetector.h index 890ea4a0..d45ae642 100644 --- a/app/src/main/cpp/skyline/input/sections/InputDetector.h +++ b/app/src/main/cpp/skyline/input/sections/InputDetector.h @@ -7,7 +7,7 @@ namespace skyline::input { /** - * @brief The structure of an entry for InputDetector (https://switchbrew.org/wiki/HID_Shared_Memory#InputDetectorState) + * @url https://switchbrew.org/wiki/HID_Shared_Memory#InputDetectorState */ struct InputDetectorState { u64 globalTimestamp; //!< The global timestamp in samples @@ -16,7 +16,7 @@ namespace skyline::input { static_assert(sizeof(InputDetectorState) == 0x18); /** - * @brief The structure of the InputDetector section (https://switchbrew.org/wiki/HID_Shared_Memory#InputDetector) + * @url https://switchbrew.org/wiki/HID_Shared_Memory#InputDetector */ struct InputDetectorSection { CommonHeader header; diff --git a/app/src/main/cpp/skyline/input/sections/Keyboard.h b/app/src/main/cpp/skyline/input/sections/Keyboard.h index 6e29424d..a23500ad 100644 --- a/app/src/main/cpp/skyline/input/sections/Keyboard.h +++ b/app/src/main/cpp/skyline/input/sections/Keyboard.h @@ -6,9 +6,6 @@ #include "common.h" namespace skyline::input { - /** - * @brief This enumerates all the modifier keys that can be used - */ union ModifierKey { u64 raw; struct { @@ -27,7 +24,7 @@ namespace skyline::input { }; /** - * @brief The structure of an entry for Keyboard (https://switchbrew.org/wiki/HID_Shared_Memory#KeyboardState) + * @url https://switchbrew.org/wiki/HID_Shared_Memory#KeyboardState */ struct KeyboardState { u64 globalTimestamp; //!< The global timestamp in samples @@ -39,7 +36,7 @@ namespace skyline::input { static_assert(sizeof(KeyboardState) == 0x38); /** - * @brief The structure of the Keyboard section (https://switchbrew.org/wiki/HID_Shared_Memory#Keyboard) + * @url https://switchbrew.org/wiki/HID_Shared_Memory#Keyboard */ struct KeyboardSection { CommonHeader header; diff --git a/app/src/main/cpp/skyline/input/sections/Mouse.h b/app/src/main/cpp/skyline/input/sections/Mouse.h index a0514fb7..8d321773 100644 --- a/app/src/main/cpp/skyline/input/sections/Mouse.h +++ b/app/src/main/cpp/skyline/input/sections/Mouse.h @@ -7,7 +7,7 @@ namespace skyline::input { /** - * @brief The structure of an entry for Mouse (https://switchbrew.org/wiki/HID_Shared_Memory#MouseState) + * @url https://switchbrew.org/wiki/HID_Shared_Memory#MouseState */ struct MouseState { u64 globalTimestamp; //!< The global timestamp in samples @@ -27,7 +27,7 @@ namespace skyline::input { static_assert(sizeof(MouseState) == 0x30); /** - * @brief The structure of the Mouse section (https://switchbrew.org/wiki/HID_Shared_Memory#Mouse) + * @url https://switchbrew.org/wiki/HID_Shared_Memory#Mouse */ struct MouseSection { CommonHeader header; diff --git a/app/src/main/cpp/skyline/input/sections/Npad.h b/app/src/main/cpp/skyline/input/sections/Npad.h index 22b473a7..82b7a1df 100644 --- a/app/src/main/cpp/skyline/input/sections/Npad.h +++ b/app/src/main/cpp/skyline/input/sections/Npad.h @@ -7,9 +7,6 @@ namespace skyline::input { // @fmt:off - /** - * @brief This enumerates all of the types of an NPad controller - */ enum class NpadControllerType : u32 { None = 0, ProController = 0b1, @@ -20,26 +17,17 @@ namespace skyline::input { }; // @fmt:on - /** - * @brief This enumerates all the possible assignments of the Joy-Con(s) - */ enum class NpadJoyAssignment : u32 { Dual = 0, //!< Dual Joy-Cons (A pair of Joy-Cons are combined into a single player, if possible) Single = 1, //!< Single Joy-Con (A single Joy-Con translates into a single player) }; - /** - * @brief This enumerates the status codes for reading NPad colors - */ enum class NpadColorReadStatus : u32 { Success = 0, //!< The color was read successfully Invalid = 1, //!< The color read in wasn't valid - Disconnected = 2 //!< The controller isn't connected + Disconnected = 2, //!< The controller isn't connected }; - /** - * @brief This structure stores the color of a controller - */ struct NpadColor { u32 bodyColor; //!< The color of the controller's body (This isn't always accurate and sometimes has magic values, especially with the Pro Controller) u32 buttonColor; //!< The color of the controller's buttons (Same as above) @@ -47,8 +35,8 @@ namespace skyline::input { static_assert(sizeof(NpadColor) == 0x8); /** - * @brief The structure of the NPad headers (https://switchbrew.org/wiki/HID_Shared_Memory#NpadStateHeader) - */ + * @url https://switchbrew.org/wiki/HID_Shared_Memory#NpadStateHeader + */ struct NpadHeader { NpadControllerType type; NpadJoyAssignment assignment; @@ -63,7 +51,7 @@ namespace skyline::input { static_assert(sizeof(NpadHeader) == 0x28); /** - * @brief This is a bit-field of all the buttons on an NPad (https://switchbrew.org/wiki/HID_Shared_Memory#NpadButton) + * @url https://switchbrew.org/wiki/HID_Shared_Memory#NpadButton */ union NpadButton { u64 raw; @@ -100,9 +88,6 @@ namespace skyline::input { }; static_assert(sizeof(NpadButton) == 0x8); - /** - * @brief This structure holds data about the state of the connection with the controller - */ union NpadConnectionState { u64 raw; struct { @@ -117,8 +102,8 @@ namespace skyline::input { static_assert(sizeof(NpadConnectionState) == 0x8); /** - * @brief This structure contains data about the controller's current state (https://switchbrew.org/wiki/HID_Shared_Memory#NpadHandheldState) - */ + * @url https://switchbrew.org/wiki/HID_Shared_Memory#NpadHandheldState + */ struct NpadControllerState { u64 globalTimestamp; //!< The global timestamp in samples u64 localTimestamp; //!< The local timestamp in samples @@ -135,9 +120,6 @@ namespace skyline::input { }; static_assert(sizeof(NpadControllerState) == 0x30); - /** - * @brief This structure contains the header and entries for the controller input - */ struct NpadControllerInfo { CommonHeader header; std::array state; @@ -145,7 +127,7 @@ namespace skyline::input { static_assert(sizeof(NpadControllerInfo) == 0x350); /** - * @brief This structure is used to hold a single sample of 3D data from the IMU + * @brief A single sample of 3D data from the IMU */ struct SixAxisVector { float x; //!< The data in the X-axis @@ -155,8 +137,8 @@ namespace skyline::input { static_assert(sizeof(SixAxisVector) == 0xC); /** - * @brief This structure contains data about the state of the controller's IMU (Six-Axis) (https://switchbrew.org/wiki/HID_Shared_Memory#NpadSixAxisSensorHandheldState) - */ + * @url https://switchbrew.org/wiki/HID_Shared_Memory#NpadSixAxisSensorHandheldState + */ struct NpadSixAxisState { u64 globalTimestamp; //!< The global timestamp in samples u64 _unk0_; @@ -167,13 +149,10 @@ namespace skyline::input { SixAxisVector rotation; std::array orientation; //!< The orientation basis data as a matrix - u64 _unk2_; //!< This is always 1 + u64 _unk2_; //!< Always 1 }; static_assert(sizeof(NpadSixAxisState) == 0x68); - /** - * @brief This structure contains header and entries for the IMU (Six-Axis) data - */ struct NpadSixAxisInfo { CommonHeader header; std::array state; @@ -181,8 +160,8 @@ namespace skyline::input { static_assert(sizeof(NpadSixAxisInfo) == 0x708); /** - * @brief This is a bit-field of all the device types (https://switchbrew.org/wiki/HID_services#DeviceType) - */ + * @url https://switchbrew.org/wiki/HID_services#DeviceType + */ union NpadDeviceType { u32 raw; struct { @@ -209,8 +188,8 @@ namespace skyline::input { static_assert(sizeof(NpadDeviceType) == 0x4); /** - * @brief This structure holds the system properties of this NPad (https://switchbrew.org/wiki/HID_Shared_Memory#NpadSystemProperties) - */ + * @url https://switchbrew.org/wiki/HID_Shared_Memory#NpadSystemProperties + */ union NpadSystemProperties { u64 raw; struct { @@ -233,7 +212,8 @@ namespace skyline::input { static_assert(sizeof(NpadSystemProperties) == 0x8); /** - * @brief This structure holds properties regarding the System Buttons (Home, Sleep and Capture) on an NPad (https://switchbrew.org/wiki/HID_Shared_Memory#NpadSystemButtonProperties) + * @url https://switchbrew.org/wiki/HID_Shared_Memory#NpadSystemButtonProperties + * @note System Buttons = Home + Capture */ union NpadSystemButtonProperties { u32 raw; @@ -243,9 +223,6 @@ namespace skyline::input { }; static_assert(sizeof(NpadSystemButtonProperties) == 0x4); - /** - * @brief This enumerates all the possible values for the NPad's battery level - */ enum class NpadBatteryLevel : u32 { Empty = 0, Low = 1, @@ -255,8 +232,8 @@ namespace skyline::input { }; /** - * @brief The structure of the Npad section (https://switchbrew.org/wiki/HID_Shared_Memory#NpadState) - */ + * @url https://switchbrew.org/wiki/HID_Shared_Memory#NpadState + */ struct NpadSection { NpadHeader header; diff --git a/app/src/main/cpp/skyline/input/sections/TouchScreen.h b/app/src/main/cpp/skyline/input/sections/TouchScreen.h index 015aa0b9..c3c8ee6a 100644 --- a/app/src/main/cpp/skyline/input/sections/TouchScreen.h +++ b/app/src/main/cpp/skyline/input/sections/TouchScreen.h @@ -7,7 +7,8 @@ namespace skyline::input { /** - * @brief This structure holds information about a single touch point + * @brief A descriptor for a single point on the touch screen + * @url https://switchbrew.org/wiki/HID_Shared_Memory#TouchScreenStateData */ struct TouchScreenStateData { u64 timestamp; //!< The timestamp in samples @@ -21,13 +22,13 @@ namespace skyline::input { u32 minorAxis; //!< The diameter of the touch cross-section on the minor-axis in pixels u32 majorAxis; //!< The diameter of the touch cross-section on the major-axis in pixels - i32 angle; //!< The angle of the touch in degrees (from -89 to 90 [-90 and 90 aren't distinguishable]. On the Switch, this has limited resolution with only 90, -67, -45, 0, 45, 67, 90 being values) + i32 angle; //!< The angle of the touch in degrees (from -89 to 90 [-90 and 90 aren't distinguishable], while on the Switch this has limited resolution with only 90, -67, -45, 0, 45, 67, 90 being values) u32 _pad1_; }; static_assert(sizeof(TouchScreenStateData) == 0x28); /** - * @brief The structure of an entry for TouchScreen (https://switchbrew.org/wiki/HID_Shared_Memory#TouchScreenState) + * @url https://switchbrew.org/wiki/HID_Shared_Memory#TouchScreenState */ struct TouchScreenState { u64 globalTimestamp; //!< The global timestamp in samples @@ -39,7 +40,7 @@ namespace skyline::input { static_assert(sizeof(TouchScreenState) == 0x298); /** - * @brief The structure of the TouchScreen section (https://switchbrew.org/wiki/HID_Shared_Memory#TouchScreen) + * @url https://switchbrew.org/wiki/HID_Shared_Memory#TouchScreen */ struct TouchScreenSection { CommonHeader header; diff --git a/app/src/main/cpp/skyline/input/sections/common.h b/app/src/main/cpp/skyline/input/sections/common.h index 8ba2f64f..8aa3c25b 100644 --- a/app/src/main/cpp/skyline/input/sections/common.h +++ b/app/src/main/cpp/skyline/input/sections/common.h @@ -15,7 +15,7 @@ namespace skyline { namespace input { /** - * @brief This is the common part of the header for all sections + * @brief A common part of the header for all sections */ struct CommonHeader { u64 timestamp; //!< The timestamp of the latest entry in ticks diff --git a/app/src/main/cpp/skyline/input/shared_mem.h b/app/src/main/cpp/skyline/input/shared_mem.h index 4d8cd1a4..a33d2abf 100644 --- a/app/src/main/cpp/skyline/input/shared_mem.h +++ b/app/src/main/cpp/skyline/input/shared_mem.h @@ -17,7 +17,7 @@ namespace skyline { namespace input { /** - * @brief This encapsulates HID Shared Memory (https://switchbrew.org/wiki/HID_Shared_Memory) + * @url https://switchbrew.org/wiki/HID_Shared_Memory */ struct HidSharedMemory { DebugPadSection debugPad; //!< The DebugPad section (https://switchbrew.org/wiki/HID_Shared_Memory#DebugPad) diff --git a/app/src/main/cpp/skyline/kernel/ipc.h b/app/src/main/cpp/skyline/kernel/ipc.h index 45913c31..99e42bdf 100644 --- a/app/src/main/cpp/skyline/kernel/ipc.h +++ b/app/src/main/cpp/skyline/kernel/ipc.h @@ -13,21 +13,31 @@ namespace skyline { namespace kernel::ipc { /** - * @brief This reflects the value in CommandStruct::type + * @url https://switchbrew.org/wiki/IPC_Marshalling#Type */ enum class CommandType : u16 { - Invalid = 0, LegacyRequest = 1, Close = 2, LegacyControl = 3, Request = 4, Control = 5, RequestWithContext = 6, ControlWithContext = 7 + Invalid = 0, + LegacyRequest = 1, + Close = 2, //!< Closes the IPC Session + LegacyControl = 3, + Request = 4, //!< A normal IPC transaction between the server and client process + Control = 5, //!< A transaction between the client and IPC Manager + RequestWithContext = 6, //!< Request with Token + ControlWithContext = 7, //!< Control with Token }; /** - * @brief This reflects the value in CommandStruct::c_flags + * @url https://switchbrew.org/wiki/IPC_Marshalling#Buffer_descriptor_C_.22ReceiveList.22 + * @note Any values beyond this are the amount of C-Buffers present (Which is calculated as value - 2) */ enum class BufferCFlag : u8 { - None = 0, InlineDescriptor = 1, SingleDescriptor = 2 + None = 0, //!< No C-Buffers present + InlineDescriptor = 1, //!< An inlined C-Buffer which is written after the raw data section + SingleDescriptor = 2, //!< A single C-Buffer }; /** - * @brief This bit-field structure holds the header of an IPC command. (https://switchbrew.org/wiki/IPC_Marshalling#IPC_Command_Structure) + * @url https://switchbrew.org/wiki/IPC_Marshalling#IPC_Command_Structure */ struct CommandHeader { CommandType type : 16; @@ -43,7 +53,7 @@ namespace skyline { static_assert(sizeof(CommandHeader) == 8); /** - * @brief This bit-field structure holds the handle descriptor of a received IPC command. (https://switchbrew.org/wiki/IPC_Marshalling#Handle_descriptor) + * @url https://switchbrew.org/wiki/IPC_Marshalling#Handle_descriptor */ struct HandleDescriptor { bool sendPid : 1; @@ -54,10 +64,18 @@ namespace skyline { static_assert(sizeof(HandleDescriptor) == 4); /** - * @brief This bit-field structure holds the domain's header of an IPC request command. (https://switchbrew.org/wiki/IPC_Marshalling#Domains) + * @brief Commands which can be issued via a domain request + */ + enum class DomainCommand : u8 { + SendMessage = 1, + CloseVHandle = 2, + }; + + /** + * @url https://switchbrew.org/wiki/IPC_Marshalling#Domains */ struct DomainHeaderRequest { - u8 command; + DomainCommand command; u8 inputCount; u16 payloadSz; u32 objectId; @@ -67,14 +85,7 @@ namespace skyline { static_assert(sizeof(DomainHeaderRequest) == 16); /** - * @brief This reflects the value of DomainHeaderRequest::command - */ - enum class DomainCommand : u8 { - SendMessage = 1, CloseVHandle = 2 - }; - - /** - * @brief This bit-field structure holds the domain's header of an IPC response command. (https://switchbrew.org/wiki/IPC_Marshalling#Domains) + * @url https://switchbrew.org/wiki/IPC_Marshalling#Domains */ struct DomainHeaderResponse { u32 outputCount; @@ -84,7 +95,7 @@ namespace skyline { static_assert(sizeof(DomainHeaderResponse) == 16); /** - * @brief This bit-field structure holds the data payload of an IPC command. (https://switchbrew.org/wiki/IPC_Marshalling#Data_payload) + * @url https://switchbrew.org/wiki/IPC_Marshalling#Data_payload */ struct PayloadHeader { u32 magic; @@ -96,14 +107,19 @@ namespace skyline { /** - * @brief This reflects which function PayloadHeader::value refers to when a control request is sent (https://switchbrew.org/wiki/IPC_Marshalling#Control) + * @brief The IPC Control commands as encoded into the payload value + * @url https://switchbrew.org/wiki/IPC_Marshalling#Control */ enum class ControlCommand : u32 { - ConvertCurrentObjectToDomain = 0, CopyFromCurrentDomain = 1, CloneCurrentObject = 2, QueryPointerBufferSize = 3, CloneCurrentObjectEx = 4 + ConvertCurrentObjectToDomain = 0, //!< Converts a regular IPC session into a domain session + CopyFromCurrentDomain = 1, + CloneCurrentObject = 2, //!< Creates a duplicate of the current session + QueryPointerBufferSize = 3, //!< The size of the X buffers written by the servers (and by extension C-buffers supplied by the client) + CloneCurrentObjectEx = 4, //!< Same as CloneCurrentObject }; /** - * @brief This is a buffer descriptor for X buffers: https://switchbrew.org/wiki/IPC_Marshalling#Buffer_descriptor_X_.22Pointer.22 + * @url https://switchbrew.org/wiki/IPC_Marshalling#Buffer_descriptor_X_.22Pointer.22 */ struct BufferDescriptorX { u16 counter0_5 : 6; //!< The first 5 bits of the counter @@ -121,16 +137,10 @@ namespace skyline { counter9_11 = static_cast(address & 0x38); } - /** - * @return The address of the buffer - */ inline u64 Address() { return static_cast(address0_31) | static_cast(address32_35) << 32 | static_cast(address36_38) << 36; } - /** - * @return The counter index of the buffer - */ inline u16 Counter() { return static_cast(counter0_5) | static_cast(counter9_11) << 9; } @@ -138,7 +148,7 @@ namespace skyline { static_assert(sizeof(BufferDescriptorX) == 8); /** - * @brief This is a buffer descriptor for A/B/W buffers: https://switchbrew.org/wiki/IPC_Marshalling#Buffer_descriptor_A.2FB.2FW_.22Send.22.2F.22Receive.22.2F.22Exchange.22 + * @url https://switchbrew.org/wiki/IPC_Marshalling#Buffer_descriptor_A.2FB.2FW_.22Send.22.2F.22Receive.22.2F.22Exchange.22 */ struct BufferDescriptorABW { u32 size0_31 : 32; //!< The first 32 bits of the size @@ -157,16 +167,10 @@ namespace skyline { size32_35 = static_cast(size & 0x78000000); } - /** - * @return The address of the buffer - */ inline u64 Address() { return static_cast(address0_31) | static_cast(address32_35) << 32 | static_cast(address36_38) << 36; } - /** - * @return The size of the buffer - */ inline u64 Size() { return static_cast(size0_31) | static_cast(size32_35) << 32; } @@ -174,7 +178,7 @@ namespace skyline { static_assert(sizeof(BufferDescriptorABW) == 12); /** - * @brief This is a buffer descriptor for C buffers: https://switchbrew.org/wiki/IPC_Marshalling#Buffer_descriptor_C_.22ReceiveList.22 + * @url https://switchbrew.org/wiki/IPC_Marshalling#Buffer_descriptor_C_.22ReceiveList.22 */ struct BufferDescriptorC { u64 address : 48; //!< The 48-bit address of the buffer @@ -184,47 +188,40 @@ namespace skyline { }; static_assert(sizeof(BufferDescriptorC) == 8); - /** - * @brief This enumerates the types of IPC buffers - */ enum class IpcBufferType { - X, //!< This is a type-X buffer - A, //!< This is a type-A buffer - B, //!< This is a type-B buffer - W, //!< This is a type-W buffer - C //!< This is a type-C buffer + X, //!< Type-X buffer (BufferDescriptorX) + A, //!< Type-A buffer (BufferDescriptorABW) + B, //!< Type-B buffer (BufferDescriptorABW) + W, //!< Type-W buffer (BufferDescriptorABW) + C, //!< Type-C buffer (BufferDescriptorC) }; /** - * @brief This class encapsulates an IPC Request (https://switchbrew.org/wiki/IPC_Marshalling) + * @brief A wrapper over an IPC Request which allows it to be parsed and used effectively + * @url https://switchbrew.org/wiki/IPC_Marshalling */ class IpcRequest { private: - u8 *payloadOffset; //!< This is the offset of the data read from the payload + u8 *payloadOffset; //!< The offset of the data read from the payload public: - CommandHeader *header{}; //!< The header of the request - HandleDescriptor *handleDesc{}; //!< The handle descriptor in case CommandHeader::handle_desc is true in the header + CommandHeader *header{}; + HandleDescriptor *handleDesc{}; bool isDomain{}; //!< If this is a domain request - DomainHeaderRequest *domain{}; //!< In case this is a domain request, this holds data regarding it - PayloadHeader *payload{}; //!< This is the header of the payload - u8 *cmdArg{}; //!< This is a pointer to the data payload (End of PayloadHeader) - u64 cmdArgSz{}; //!< This is the size of the data payload - std::vector copyHandles; //!< A vector of handles that should be copied from the server to the client process (The difference is just to match application expectations, there is no real difference b/w copying and moving handles) - std::vector moveHandles; //!< A vector of handles that should be moved from the server to the client process rather than copied - std::vector domainObjects; //!< A vector of all input domain objects - std::vector> inputBuf; //!< This is a vector of input buffers - std::vector> outputBuf; //!< This is a vector of output buffers + DomainHeaderRequest *domain{}; + PayloadHeader *payload{}; + u8 *cmdArg{}; //!< A pointer to the data payload + u64 cmdArgSz{}; //!< The size of the data payload + std::vector copyHandles; //!< The handles that should be copied from the server to the client process (The difference is just to match application expectations, there is no real difference b/w copying and moving handles) + std::vector moveHandles; //!< The handles that should be moved from the server to the client process rather than copied + std::vector domainObjects; + std::vector> inputBuf; + std::vector> outputBuf; - /** - * @param isDomain If the following request is a domain request - * @param state The state of the device - */ IpcRequest(bool isDomain, const DeviceState &state); /** - * @brief This returns a reference to an item from the top of the payload - * @tparam ValueType The type of the object to read + * @brief Returns a reference to an item from the top of the payload */ template inline ValueType &Pop() { @@ -234,7 +231,7 @@ namespace skyline { } /** - * @brief This returns a std::string_view from the payload + * @brief Returns a std::string_view from the payload * @param size The length of the string (0 means the string is null terminated) */ inline std::string_view PopString(size_t size = 0) { @@ -244,8 +241,7 @@ namespace skyline { } /** - * @brief This skips an object to pop off the top - * @tparam ValueType The type of the object to skip + * @brief Skips an object to pop off the top */ template inline void Skip() { @@ -254,23 +250,20 @@ namespace skyline { }; /** - * @brief This class encapsulates an IPC Response (https://switchbrew.org/wiki/IPC_Marshalling) + * @brief A wrapper over an IPC Response which allows it to be defined and serialized efficiently + * @url https://switchbrew.org/wiki/IPC_Marshalling */ class IpcResponse { private: - const DeviceState &state; //!< The state of the device - std::vector payload; //!< This holds all of the contents to be pushed to the payload + const DeviceState &state; + std::vector payload; //!< The contents to be pushed to the data payload public: Result errorCode{}; //!< The error code to respond with, it is 0 (Success) by default - std::vector copyHandles; //!< A vector of handles to copy - std::vector moveHandles; //!< A vector of handles to move - std::vector domainObjects; //!< A vector of domain objects to write + std::vector copyHandles; + std::vector moveHandles; + std::vector domainObjects; - /** - * @param isDomain If the following request is a domain request - * @param state The state of the device - */ IpcResponse(const DeviceState &state); /** @@ -282,7 +275,6 @@ namespace skyline { inline void Push(const ValueType &value) { auto size{payload.size()}; payload.resize(size + sizeof(ValueType)); - std::memcpy(payload.data() + size, reinterpret_cast(&value), sizeof(ValueType)); } @@ -290,11 +282,9 @@ namespace skyline { * @brief Writes a string to the payload * @param string The string to write to the payload */ - template<> - inline void Push(const std::string &string) { + inline void Push(std::string_view string) { auto size{payload.size()}; payload.resize(size + string.size()); - std::memcpy(payload.data() + size, string.data(), string.size()); } diff --git a/app/src/main/cpp/skyline/kernel/memory.cpp b/app/src/main/cpp/skyline/kernel/memory.cpp index 5dc10fe7..46c594c7 100644 --- a/app/src/main/cpp/skyline/kernel/memory.cpp +++ b/app/src/main/cpp/skyline/kernel/memory.cpp @@ -6,11 +6,11 @@ namespace skyline::kernel { ChunkDescriptor *MemoryManager::GetChunk(u64 address) { - auto chunk{std::upper_bound(chunkList.begin(), chunkList.end(), address, [](const u64 address, const ChunkDescriptor &chunk) -> bool { + auto chunk{std::upper_bound(chunks.begin(), chunks.end(), address, [](const u64 address, const ChunkDescriptor &chunk) -> bool { return address < chunk.address; })}; - if (chunk-- != chunkList.begin()) { + if (chunk-- != chunks.begin()) { if ((chunk->address + chunk->size) > address) return chunk.base(); } @@ -37,24 +37,24 @@ namespace skyline::kernel { } void MemoryManager::InsertChunk(const ChunkDescriptor &chunk) { - auto upperChunk{std::upper_bound(chunkList.begin(), chunkList.end(), chunk.address, [](const u64 address, const ChunkDescriptor &chunk) -> bool { + auto upperChunk{std::upper_bound(chunks.begin(), chunks.end(), chunk.address, [](const u64 address, const ChunkDescriptor &chunk) -> bool { return address < chunk.address; })}; - if (upperChunk != chunkList.begin()) { + if (upperChunk != chunks.begin()) { auto lowerChunk{std::prev(upperChunk)}; if (lowerChunk->address + lowerChunk->size > chunk.address) throw exception("InsertChunk: Descriptors are colliding: 0x{:X} - 0x{:X} and 0x{:X} - 0x{:X}", lowerChunk->address, lowerChunk->address + lowerChunk->size, chunk.address, chunk.address + chunk.size); } - chunkList.insert(upperChunk, chunk); + chunks.insert(upperChunk, chunk); } void MemoryManager::DeleteChunk(u64 address) { - for (auto chunk{chunkList.begin()}, end{chunkList.end()}; chunk != end;) { + for (auto chunk{chunks.begin()}, end{chunks.end()}; chunk != end;) { if (chunk->address <= address && (chunk->address + chunk->size) > address) - chunk = chunkList.erase(chunk); + chunk = chunks.erase(chunk); else chunk++; } @@ -176,17 +176,17 @@ namespace skyline::kernel { // If the requested address is in the address space but no chunks are present then we return a new unmapped region if (addressSpace.IsInside(address) && !requireMapped) { - auto upperChunk{std::upper_bound(chunkList.begin(), chunkList.end(), address, [](const u64 address, const ChunkDescriptor &chunk) -> bool { + auto upperChunk{std::upper_bound(chunks.begin(), chunks.end(), address, [](const u64 address, const ChunkDescriptor &chunk) -> bool { return address < chunk.address; })}; u64 upperAddress{}; u64 lowerAddress{}; - if (upperChunk != chunkList.end()) { + if (upperChunk != chunks.end()) { upperAddress = upperChunk->address; - if (upperChunk == chunkList.begin()) { + if (upperChunk == chunks.begin()) { lowerAddress = addressSpace.address; } else { upperChunk--; @@ -194,7 +194,7 @@ namespace skyline::kernel { } } else { upperAddress = addressSpace.address + addressSpace.size; - lowerAddress = chunkList.back().address + chunkList.back().size; + lowerAddress = chunks.back().address + chunks.back().size; } u64 size{upperAddress - lowerAddress}; @@ -217,7 +217,7 @@ namespace skyline::kernel { size_t MemoryManager::GetProgramSize() { size_t size{}; - for (const auto &chunk : chunkList) + for (const auto &chunk : chunks) size += chunk.size; return size; } diff --git a/app/src/main/cpp/skyline/kernel/memory.h b/app/src/main/cpp/skyline/kernel/memory.h index 2f57d023..9e1d4bfe 100644 --- a/app/src/main/cpp/skyline/kernel/memory.h +++ b/app/src/main/cpp/skyline/kernel/memory.h @@ -53,7 +53,7 @@ namespace skyline { }; /** - * @brief This holds certain attributes of a chunk of memory: https://switchbrew.org/wiki/SVC#MemoryAttribute + * @url https://switchbrew.org/wiki/SVC#MemoryAttribute */ union MemoryAttribute { struct { @@ -66,7 +66,7 @@ namespace skyline { }; /** - * @brief This contains information about a chunk of memory: https://switchbrew.org/wiki/SVC#MemoryInfo + * @url https://switchbrew.org/wiki/SVC#MemoryInfo */ struct MemoryInfo { u64 address; //!< The base address of the mapping @@ -74,14 +74,15 @@ namespace skyline { u32 type; //!< The MemoryType of the mapping u32 attributes; //!< The attributes of the mapping u32 permissions; //!< The permissions of the mapping - u32 ipcRefCount; //!< The IPC reference count (This is always 0) - u32 deviceRefCount; //!< The device reference count (This is always 0) + u32 ipcRefCount; //!< The IPC reference count (Always 0) + u32 deviceRefCount; //!< The device reference count (Always 0) u32 _pad0_; }; static_assert(sizeof(MemoryInfo) == 0x28); /** - * @brief These are specific markers for the type of a memory region (https://switchbrew.org/wiki/SVC#MemoryType) + * @brief These are specific markers for the type of a memory region + * @url https://switchbrew.org/wiki/SVC#MemoryType */ enum class MemoryType : u8 { Unmapped = 0x0, @@ -105,11 +106,12 @@ namespace skyline { NonDeviceIpc = 0x12, KernelStack = 0x13, CodeReadOnly = 0x14, - CodeWritable = 0x15 + CodeWritable = 0x15, }; /** - * @brief This structure is used to hold the state of a certain block of memory (https://switchbrew.org/wiki/SVC#MemoryState) + * @brief The state of a certain block of memory + * @url https://switchbrew.org/wiki/SVC#MemoryState */ union MemoryState { constexpr MemoryState(const u32 value) : value(value) {} @@ -142,7 +144,8 @@ namespace skyline { static_assert(sizeof(MemoryState) == sizeof(u32)); /** - * @brief The preset states that different regions are set to (https://switchbrew.org/wiki/SVC#MemoryType) + * @brief The preset states that different regions are set to + * @url https://switchbrew.org/wiki/SVC#MemoryType */ namespace states { constexpr MemoryState Unmapped{0x00000000}; @@ -168,9 +171,6 @@ namespace skyline { constexpr MemoryState CodeWritable{0x00402015}; }; - /** - * @brief This struct is used to hold the location and size of a memory region - */ struct Region { u64 address; //!< The base address of the region u64 size; //!< The size of the region in bytes @@ -215,7 +215,7 @@ namespace skyline { } /** - * @brief This describes a single block of memory and all of it's individual attributes + * @brief A single block of memory and all of it's individual attributes */ struct BlockDescriptor { u64 address; //!< The address of the current block @@ -225,18 +225,18 @@ namespace skyline { }; /** - * @brief This describes a single chunk of memory, this is owned by a memory backing + * @brief A single chunk of memory, this is owned by a memory backing */ struct ChunkDescriptor { u64 address; //!< The address of the current chunk u64 size; //!< The size of the current chunk in bytes u64 host; //!< The address of the chunk in the host memory::MemoryState state; //!< The MemoryState for the current block - std::vector blockList; //!< This vector holds the block descriptors for all the children blocks of this Chunk + std::vector blockList; //!< The block descriptors for all the children blocks of this Chunk }; /** - * @brief This contains both of the descriptors for a specific address + * @brief A pack of both the descriptors for a specific address */ struct DescriptorPack { const BlockDescriptor block; //!< The block descriptor at the address @@ -248,8 +248,8 @@ namespace skyline { */ class MemoryManager { private: - const DeviceState &state; //!< The state of the device - std::vector chunkList; //!< This vector holds all the chunk descriptors + const DeviceState &state; + std::vector chunks; /** * @param address The address to find a chunk at @@ -290,7 +290,7 @@ namespace skyline { static void InsertBlock(ChunkDescriptor *chunk, BlockDescriptor block); /** - * @brief This initializes all of the regions in the address space + * @brief Initializes all of the regions in the address space * @param address The starting address of the code region * @param size The size of the code region * @param type The type of the address space @@ -322,7 +322,7 @@ namespace skyline { /** * @param address The address to query in the memory map - * @param requireMapped This specifies if only mapped regions should be returned otherwise unmapped but valid regions will also be returned + * @param requireMapped If only mapped regions should be returned otherwise unmapped but valid regions will also be returned * @return A DescriptorPack retrieved from the memory map */ std::optional Get(u64 address, bool requireMapped = true); diff --git a/app/src/main/cpp/skyline/kernel/svc.cpp b/app/src/main/cpp/skyline/kernel/svc.cpp index 533a27db..e02365fa 100644 --- a/app/src/main/cpp/skyline/kernel/svc.cpp +++ b/app/src/main/cpp/skyline/kernel/svc.cpp @@ -2,6 +2,7 @@ // Copyright © 2020 Skyline Team and Contributors (https://github.com/skyline-emu/) #include +#include #include "results.h" #include "svc.h" @@ -170,7 +171,7 @@ namespace skyline::kernel::svc { if (!sourceObject) throw exception("svcUnmapMemory: Cannot find source memory object in handle table for address 0x{:X}", source); - state.process->DeleteHandle(sourceObject->handle); + state.process->CloseHandle(sourceObject->handle); state.logger->Debug("svcUnmapMemory: Unmapped range 0x{:X} - 0x{:X} to 0x{:X} - 0x{:X} (Size: 0x{:X} bytes)", source, source + size, destination, destination + size, size); state.ctx->registers.w0 = Result{}; @@ -375,7 +376,7 @@ namespace skyline::kernel::svc { void CloseHandle(DeviceState &state) { auto handle{static_cast(state.ctx->registers.w0)}; try { - state.process->DeleteHandle(handle); + state.process->CloseHandle(handle); state.logger->Debug("svcCloseHandle: Closing handle: 0x{:X}", handle); state.ctx->registers.w0 = Result{}; } catch (const std::exception &) { @@ -583,8 +584,7 @@ namespace skyline::kernel::svc { } void ConnectToNamedPort(DeviceState &state) { - constexpr u8 portSize{0x8}; //!< The size of a port name string - std::string_view port(state.process->GetPointer(state.ctx->registers.x1), portSize); + std::string_view port(state.process->GetPointer(state.ctx->registers.x1), sizeof(service::ServiceName)); KHandle handle{}; if (port.compare("sm:") >= 0) { @@ -607,7 +607,7 @@ namespace skyline::kernel::svc { } void GetThreadId(DeviceState &state) { - constexpr KHandle threadSelf{0xFFFF8000}; // This is the handle used by threads to refer to themselves + constexpr KHandle threadSelf{0xFFFF8000}; // The handle used by threads to refer to themselves auto handle{state.ctx->registers.w1}; pid_t pid{}; diff --git a/app/src/main/cpp/skyline/kernel/svc.h b/app/src/main/cpp/skyline/kernel/svc.h index 1649e07b..d5b9e307 100644 --- a/app/src/main/cpp/skyline/kernel/svc.h +++ b/app/src/main/cpp/skyline/kernel/svc.h @@ -40,147 +40,176 @@ namespace skyline { namespace kernel::svc { /** - * @brief Sets the process heap to a given Size. It can both extend and shrink the heap. (https://switchbrew.org/wiki/SVC#SetHeapSize) + * @brief Sets the process heap to a given size, it can both extend and shrink the heap + * @url https://switchbrew.org/wiki/SVC#SetHeapSize */ void SetHeapSize(DeviceState &state); /** - * @brief Change attribute of page-aligned memory region. This is used to turn on/off caching for a given memory area. (https://switchbrew.org/wiki/SVC#SetMemoryAttribute) + * @brief Change attribute of page-aligned memory region, this is used to turn on/off caching for a given memory area + * @url https://switchbrew.org/wiki/SVC#SetMemoryAttribute */ void SetMemoryAttribute(DeviceState &state); /** - * @brief Maps a memory range into a different range. Mainly used for adding guard pages around stack. (https://switchbrew.org/wiki/SVC#SetMemoryAttribute) + * @brief Maps a memory range into a different range, mainly used for adding guard pages around stack + * @url https://switchbrew.org/wiki/SVC#SetMemoryAttribute */ void MapMemory(DeviceState &state); /** - * @brief Unmaps a region that was previously mapped with #MapMemory. (https://switchbrew.org/wiki/SVC#UnmapMemory) + * @brief Unmaps a region that was previously mapped with #MapMemory + * @url https://switchbrew.org/wiki/SVC#UnmapMemory */ void UnmapMemory(DeviceState &state); /** - * @brief Query information about an address (https://switchbrew.org/wiki/SVC#QueryMemory) + * @brief Query information about an address + * @url https://switchbrew.org/wiki/SVC#QueryMemory */ void QueryMemory(DeviceState &state); /** - * @brief Exits the current process (https://switchbrew.org/wiki/SVC#ExitProcess) + * @brief Exits the current process + * @url https://switchbrew.org/wiki/SVC#ExitProcess */ void ExitProcess(DeviceState &state); /** - * @brief Create a thread in the current process (https://switchbrew.org/wiki/SVC#CreateThread) + * @brief Create a thread in the current process + * @url https://switchbrew.org/wiki/SVC#CreateThread */ void CreateThread(DeviceState &state); /** - * @brief Starts the thread for the provided handle (https://switchbrew.org/wiki/SVC#StartThread) + * @brief Starts the thread for the provided handle + * @url https://switchbrew.org/wiki/SVC#StartThread */ void StartThread(DeviceState &state); /** - * @brief Exits the current thread (https://switchbrew.org/wiki/SVC#ExitThread) + * @brief Exits the current thread + * @url https://switchbrew.org/wiki/SVC#ExitThread */ void ExitThread(DeviceState &state); /** - * @brief Sleep for a specified amount of time, or yield thread (https://switchbrew.org/wiki/SVC#SleepThread) + * @brief Sleep for a specified amount of time, or yield thread + * @url https://switchbrew.org/wiki/SVC#SleepThread */ void SleepThread(DeviceState &state); /** - * @brief Get priority of provided thread handle (https://switchbrew.org/wiki/SVC#GetThreadPriority) + * @brief Get priority of provided thread handle + * @url https://switchbrew.org/wiki/SVC#GetThreadPriority */ void GetThreadPriority(DeviceState &state); /** - * @brief Set priority of provided thread handle (https://switchbrew.org/wiki/SVC#SetThreadPriority) + * @brief Set priority of provided thread handle + * @url https://switchbrew.org/wiki/SVC#SetThreadPriority */ void SetThreadPriority(DeviceState &state); /** - * @brief Clears a KEvent of it's signal (https://switchbrew.org/wiki/SVC#ClearEvent) + * @brief Clears a KEvent of it's signal + * @url https://switchbrew.org/wiki/SVC#ClearEvent */ void ClearEvent(DeviceState &state); /** - * @brief Maps the block supplied by the handle (https://switchbrew.org/wiki/SVC#MapSharedMemory) + * @brief Maps the block supplied by the handle + * @url https://switchbrew.org/wiki/SVC#MapSharedMemory */ void MapSharedMemory(DeviceState &state); /** - * @brief Returns a handle to a KSharedMemory object (https://switchbrew.org/wiki/SVC#CreateTransferMemory) + * @brief Returns a handle to a KSharedMemory object + * @url https://switchbrew.org/wiki/SVC#CreateTransferMemory */ void CreateTransferMemory(DeviceState &state); /** - * @brief Closes the specified handle (https://switchbrew.org/wiki/SVC#CloseHandle) + * @brief Closes the specified handle + * @url https://switchbrew.org/wiki/SVC#CloseHandle */ void CloseHandle(DeviceState &state); /** - * @brief This resets a particular KEvent or KProcess which is signalled (https://switchbrew.org/wiki/SVC#ResetSignal) + * @brief Resets a particular KEvent or KProcess which is signalled + * @url https://switchbrew.org/wiki/SVC#ResetSignal */ void ResetSignal(DeviceState &state); /** - * @brief Stalls a thread till a KSyncObject signals or the timeout has ended (https://switchbrew.org/wiki/SVC#WaitSynchronization) + * @brief Stalls a thread till a KSyncObject signals or the timeout has ended + * @url https://switchbrew.org/wiki/SVC#WaitSynchronization */ void WaitSynchronization(DeviceState &state); /** - * @brief If the referenced thread is currently in a synchronization call, that call will be interrupted (https://switchbrew.org/wiki/SVC#CancelSynchronization) + * @brief If the referenced thread is currently in a synchronization call, that call will be interrupted + * @url https://switchbrew.org/wiki/SVC#CancelSynchronization */ void CancelSynchronization(DeviceState &state); /** - * @brief Locks a specified mutex (https://switchbrew.org/wiki/SVC#ArbitrateLock) + * @brief Locks a specified mutex + * @url https://switchbrew.org/wiki/SVC#ArbitrateLock */ void ArbitrateLock(DeviceState &state); /** - * @brief Unlocks a specified mutex (https://switchbrew.org/wiki/SVC#ArbitrateUnlock) + * @brief Unlocks a specified mutex + * @url https://switchbrew.org/wiki/SVC#ArbitrateUnlock */ void ArbitrateUnlock(DeviceState &state); /** - * @brief Waits on a process-wide key (Conditional-Variable) (https://switchbrew.org/wiki/SVC#WaitProcessWideKeyAtomic) + * @brief Waits on a process-wide key (Conditional-Variable) + * @url https://switchbrew.org/wiki/SVC#WaitProcessWideKeyAtomic */ void WaitProcessWideKeyAtomic(DeviceState &state); /** - * @brief Signals a process-wide key (Conditional-Variable) (https://switchbrew.org/wiki/SVC#SignalProcessWideKey) + * @brief Signals a process-wide key (Conditional-Variable) + * @url https://switchbrew.org/wiki/SVC#SignalProcessWideKey */ void SignalProcessWideKey(DeviceState &state); /** - * @brief This returns the value of CNTPCT_EL0 on the Switch (https://switchbrew.org/wiki/SVC#GetSystemTick) + * @brief Returns the value of CNTPCT_EL0 on the Switch + * @url https://switchbrew.org/wiki/SVC#GetSystemTick */ void GetSystemTick(DeviceState &state); /** - * @brief Connects to a named IPC port (https://switchbrew.org/wiki/SVC#ConnectToNamedPort) + * @brief Connects to a named IPC port + * @url https://switchbrew.org/wiki/SVC#ConnectToNamedPort */ void ConnectToNamedPort(DeviceState &state); /** - * @brief Send a synchronous IPC request to a service (https://switchbrew.org/wiki/SVC#SendSyncRequest) + * @brief Send a synchronous IPC request to a service + * @url https://switchbrew.org/wiki/SVC#SendSyncRequest */ void SendSyncRequest(DeviceState &state); /** - * @brief Retrieves the PID of a specific thread (https://switchbrew.org/wiki/SVC#GetThreadId) + * @brief Retrieves the PID of a specific thread + * @url https://switchbrew.org/wiki/SVC#GetThreadId */ void GetThreadId(DeviceState &state); /** - * @brief Outputs a debug string (https://switchbrew.org/wiki/SVC#OutputDebugString) + * @brief Outputs a debug string + * @url https://switchbrew.org/wiki/SVC#OutputDebugString */ void OutputDebugString(DeviceState &state); /** - * @brief Retrieves a piece of information (https://switchbrew.org/wiki/SVC#GetInfo) + * @brief Retrieves a piece of information + * @url https://switchbrew.org/wiki/SVC#GetInfo */ void GetInfo(DeviceState &state); diff --git a/app/src/main/cpp/skyline/kernel/types/KEvent.h b/app/src/main/cpp/skyline/kernel/types/KEvent.h index 11be413a..164447ca 100644 --- a/app/src/main/cpp/skyline/kernel/types/KEvent.h +++ b/app/src/main/cpp/skyline/kernel/types/KEvent.h @@ -7,13 +7,11 @@ namespace skyline::kernel::type { /** - * @brief KEvent is an object that's signalled on an repeatable event occurring (https://switchbrew.org/wiki/Kernel_objects#KEvent) + * @brief KEvent is an object that's signalled on an repeatable event occurring + * @url https://switchbrew.org/wiki/Kernel_objects#KEvent */ class KEvent : public KSyncObject { public: - /** - * @param state The state of the device - */ KEvent(const DeviceState &state) : KSyncObject(state, KType::KEvent) {} /** diff --git a/app/src/main/cpp/skyline/kernel/types/KObject.h b/app/src/main/cpp/skyline/kernel/types/KObject.h index bc99517a..674579b9 100644 --- a/app/src/main/cpp/skyline/kernel/types/KObject.h +++ b/app/src/main/cpp/skyline/kernel/types/KObject.h @@ -10,7 +10,13 @@ namespace skyline::kernel::type { * @brief These types are used to perform runtime evaluation of a kernel object's type when converting from base class */ enum class KType { - KThread, KProcess, KSharedMemory, KTransferMemory, KPrivateMemory, KSession, KEvent + KThread, + KProcess, + KSharedMemory, + KTransferMemory, + KPrivateMemory, + KSession, + KEvent, }; /** @@ -18,13 +24,9 @@ namespace skyline::kernel::type { */ class KObject { public: - const DeviceState &state; //!< The state of the device - KType objectType; //!< The type of this object + const DeviceState &state; + KType objectType; - /** - * @param state The state of the device - * @param objectType The type of the object - */ KObject(const DeviceState &state, KType objectType) : state(state), objectType(objectType) {} }; } diff --git a/app/src/main/cpp/skyline/kernel/types/KPrivateMemory.h b/app/src/main/cpp/skyline/kernel/types/KPrivateMemory.h index c5f2a27c..ce557992 100644 --- a/app/src/main/cpp/skyline/kernel/types/KPrivateMemory.h +++ b/app/src/main/cpp/skyline/kernel/types/KPrivateMemory.h @@ -18,7 +18,6 @@ namespace skyline::kernel::type { size_t size{}; //!< The size of the allocated memory /** - * @param state The state of the device * @param address The address to map to (If NULL then an arbitrary address is picked) * @param size The size of the allocation * @param permission The permissions for the allocated memory diff --git a/app/src/main/cpp/skyline/kernel/types/KProcess.h b/app/src/main/cpp/skyline/kernel/types/KProcess.h index de053c89..930bcc72 100644 --- a/app/src/main/cpp/skyline/kernel/types/KProcess.h +++ b/app/src/main/cpp/skyline/kernel/types/KProcess.h @@ -14,24 +14,23 @@ namespace skyline { namespace constant { constexpr u16 TlsSlotSize{0x200}; //!< The size of a single TLS slot constexpr u8 TlsSlots{PAGE_SIZE / TlsSlotSize}; //!< The amount of TLS slots in a single page - constexpr KHandle BaseHandleIndex{0xD000}; // The index of the base handle + constexpr KHandle BaseHandleIndex{0xD000}; //!< The index of the base handle constexpr u32 MtxOwnerMask{0xBFFFFFFF}; //!< The mask of values which contain the owner of a mutex } namespace kernel::type { /** - * @brief The KProcess class is responsible for holding the state of a process - */ + * @brief The KProcess class is responsible for holding the state of a process + */ class KProcess : public KSyncObject { private: - KHandle handleIndex{constant::BaseHandleIndex}; //!< This is used to keep track of what to map as an handle + KHandle handleIndex{constant::BaseHandleIndex}; //!< The index of the handle that will be allocated next /** - * @brief This class holds a single TLS page's status - * @details tls_page_t holds the status of a single TLS page (A page is 4096 bytes on ARMv8). - * Each TLS page has 8 slots, each 0x200 (512) bytes in size. - * The first slot of the first page is reserved for user-mode exception handling. - * Read more about TLS here: https://switchbrew.org/wiki/Thread_Local_Storage + * @brief The status of a single TLS page (A page is 4096 bytes on ARMv8) + * Each TLS page has 8 slots, each 0x200 (512) bytes in size + * The first slot of the first page is reserved for user-mode exception handling + * @url https://switchbrew.org/wiki/Thread_Local_Storage */ struct TlsPage { u64 address; //!< The address of the page allocated for TLS @@ -39,8 +38,8 @@ namespace skyline { bool slot[constant::TlsSlots]{}; //!< An array of booleans denoting which TLS slots are reserved /** - * @param address The address of the allocated page - */ + * @param address The address of the allocated page + */ TlsPage(u64 address); /** @@ -64,21 +63,20 @@ namespace skyline { }; /** - * @brief Returns a TLS slot from an arbitrary TLS page - * @return The address of a free TLS slot - */ + * @return The address of a free TLS slot + */ u64 GetTlsSlot(); /** - * @brief This initializes heap and the initial TLS page - */ + * @brief Initializes heap and the initial TLS page + */ void InitializeMemory(); public: friend OS; /** - * @brief This is used as the output for functions that return created kernel objects + * @brief The output for functions that return created kernel objects * @tparam objectClass The class of the kernel object */ template @@ -87,18 +85,15 @@ namespace skyline { KHandle handle; //!< The handle of the object in the process }; - /** - * @brief This enum is used to describe the current status of the process - */ enum class Status { Created, //!< The process was created but the main thread has not started yet Started, //!< The process has been started - Exiting //!< The process is exiting - } status = Status::Created; //!< The state of the process + Exiting, //!< The process is exiting + } status = Status::Created; /** - * @brief This is used to hold information about a single waiting thread for mutexes and conditional variables - */ + * @brief Metadata on a thread waiting for mutexes or conditional variables + */ struct WaitStatus { std::atomic_bool flag{false}; //!< The underlying atomic flag of the thread u8 priority; //!< The priority of the thread @@ -119,12 +114,11 @@ namespace skyline { std::vector> tlsPages; //!< A vector of all allocated TLS pages std::shared_ptr stack; //!< The shared memory used to hold the stack of the main thread std::shared_ptr heap; //!< The kernel memory object backing the allocated heap - Mutex mutexLock; //!< This mutex is to prevent concurrent mutex operations to happen at once - Mutex conditionalLock; //!< This mutex is to prevent concurrent conditional variable operations to happen at once + Mutex mutexLock; //!< Synchronizes all concurrent guest mutex operations + Mutex conditionalLock; //!< Synchronizes all concurrent guest conditional variable operations /** * @brief Creates a KThread object for the main thread and opens the process's memory file - * @param state The state of the device * @param pid The PID of the main thread * @param entryPoint The address to start execution at * @param stack The KSharedMemory object for Stack memory allocated by the guest process @@ -133,8 +127,8 @@ namespace skyline { KProcess(const DeviceState &state, pid_t pid, u64 entryPoint, std::shared_ptr &stack, std::shared_ptr &tlsMemory); /** - * Close the file descriptor to the process's memory - */ + * Close the file descriptor to the process's memory + */ ~KProcess(); /** @@ -148,7 +142,7 @@ namespace skyline { std::shared_ptr CreateThread(u64 entryPoint, u64 entryArg, u64 stackTop, i8 priority); /** - * @brief This returns the host address for a specific address in guest memory + * @brief Returns the host address for a specific address in guest memory * @param address The corresponding guest address * @return The corresponding host address */ @@ -158,7 +152,7 @@ namespace skyline { * @tparam Type The type of the pointer to return * @param address The address on the guest * @return A pointer corresponding to a certain address on the guest - * @note This can return a nullptr if the address is invalid + * @note If the address is invalid then nullptr will be returned */ template inline Type *GetPointer(u64 address) { @@ -166,11 +160,8 @@ namespace skyline { } /** - * @brief Returns a reference to an object from guest memory - * @tparam Type The type of the object to be read - * @param address The address of the object - * @return A reference to object with type T - */ + * @brief Returns a reference to an object from guest memory + */ template inline Type &GetReference(u64 address) { auto source{GetPointer(address)}; @@ -250,7 +241,7 @@ namespace skyline { * @param destination The address to the location where the process memory is written * @param offset The address to read from in process memory * @param size The amount of memory to be read - * @param forceGuest This flag forces the write to be performed in guest address space + * @param forceGuest Forces the write to be performed in guest address space */ void ReadMemory(void *destination, u64 offset, size_t size, bool forceGuest = false); @@ -259,7 +250,7 @@ namespace skyline { * @param source The address of where the data to be written is present * @param offset The address to write to in process memory * @param size The amount of memory to be written - * @param forceGuest This flag forces the write to be performed in guest address space + * @param forceGuest Forces the write to be performed in guest address space */ void WriteMemory(const void *source, u64 offset, size_t size, bool forceGuest = false); @@ -345,15 +336,14 @@ namespace skyline { std::optional> GetMemoryObject(u64 address); /** - * @brief This deletes a certain handle from the handle table - * @param handle The handle to delete - */ - inline void DeleteHandle(KHandle handle) { + * @brief Closes a handle in the handle table + */ + inline void CloseHandle(KHandle handle) { handles.at(handle - constant::BaseHandleIndex) = nullptr; } /** - * @brief This locks the Mutex at the specified address + * @brief Locks the Mutex at the specified address * @param address The address of the mutex * @param owner The handle of the current mutex owner * @return If the mutex was successfully locked @@ -361,7 +351,7 @@ namespace skyline { bool MutexLock(u64 address, KHandle owner); /** - * @brief This unlocks the Mutex at the specified address + * @brief Unlocks the Mutex at the specified address * @param address The address of the mutex * @return If the mutex was successfully unlocked */ @@ -376,15 +366,15 @@ namespace skyline { bool ConditionalVariableWait(u64 conditionalAddress, u64 mutexAddress, u64 timeout); /** - * @brief This signals a number of conditional variable waiters + * @brief Signals a number of conditional variable waiters * @param address The address of the conditional variable * @param amount The amount of waiters to signal */ void ConditionalVariableSignal(u64 address, u64 amount); /** - * @brief This resets the object to an unsignalled state - */ + * @brief Resets the object to an unsignalled state + */ inline void ResetSignal() { signalled = false; } diff --git a/app/src/main/cpp/skyline/kernel/types/KSession.h b/app/src/main/cpp/skyline/kernel/types/KSession.h index 5636ce7c..99209af5 100644 --- a/app/src/main/cpp/skyline/kernel/types/KSession.h +++ b/app/src/main/cpp/skyline/kernel/types/KSession.h @@ -15,20 +15,20 @@ namespace skyline::kernel::type { */ class KSession : public KSyncObject { public: - std::shared_ptr serviceObject; //!< A shared pointer to the service class - std::unordered_map> domainTable; //!< This maps from a virtual handle to it's service + std::shared_ptr serviceObject; + std::unordered_map> domainTable; //!< A map from a virtual handle to it's service KHandle handleIndex{0x1}; //!< The currently allocated handle index - enum class ServiceStatus { Open, Closed } serviceStatus{ServiceStatus::Open}; //!< If the session is open or closed - bool isDomain{}; //!< Holds if this is a domain session or not + bool isOpen{true}; //!< If the session is open or not + bool isDomain{}; //!< If this is a domain session or not /** - * @param state The state of the device * @param serviceObject A shared pointer to the service class */ KSession(const DeviceState &state, std::shared_ptr &serviceObject) : serviceObject(serviceObject), KSyncObject(state, KType::KSession) {} /** - * This converts this session into a domain session (https://switchbrew.org/wiki/IPC_Marshalling#Domains) + * @brief Converts this session into a domain session + * @url https://switchbrew.org/wiki/IPC_Marshalling#Domains * @return The virtual handle of this service in the domain */ KHandle ConvertDomain() { diff --git a/app/src/main/cpp/skyline/kernel/types/KSharedMemory.h b/app/src/main/cpp/skyline/kernel/types/KSharedMemory.h index 15aa056b..7016ed05 100644 --- a/app/src/main/cpp/skyline/kernel/types/KSharedMemory.h +++ b/app/src/main/cpp/skyline/kernel/types/KSharedMemory.h @@ -12,26 +12,20 @@ namespace skyline::kernel::type { class KSharedMemory : public KMemory { private: int fd; //!< A file descriptor to the underlying shared memory - memory::MemoryState initialState; //!< This is to hold the initial state for the Map call + memory::MemoryState initialState; //!< The initial state is stored for the Map call public: - /** - * @brief This holds the address and size of a process's mapping - */ struct MapInfo { u64 address; size_t size; memory::Permission permission; - /** - * @brief Returns if the object is valid - * @return If the MapInfo object is valid - */ - inline bool Valid() { return address && size && permission.Get(); } + constexpr bool Valid() { + return address && size && permission.Get(); + } } kernel, guest; /** - * @param state The state of the device * @param address The address of the allocation on the kernel (If NULL then an arbitrary address is picked) * @param size The size of the allocation on the kernel * @param permission The permission of the kernel process diff --git a/app/src/main/cpp/skyline/kernel/types/KSyncObject.h b/app/src/main/cpp/skyline/kernel/types/KSyncObject.h index 67456331..4dbc50c3 100644 --- a/app/src/main/cpp/skyline/kernel/types/KSyncObject.h +++ b/app/src/main/cpp/skyline/kernel/types/KSyncObject.h @@ -13,10 +13,6 @@ namespace skyline::kernel::type { public: std::atomic signalled{false}; //!< If the current object is signalled (Used as object stays signalled till the signal is consumed) - /** - * @param state The state of the device - * @param type The type of the object - */ KSyncObject(const DeviceState &state, skyline::kernel::type::KType type) : KObject(state, type) {}; /** diff --git a/app/src/main/cpp/skyline/kernel/types/KThread.h b/app/src/main/cpp/skyline/kernel/types/KThread.h index 7be65d58..dc19e8b0 100644 --- a/app/src/main/cpp/skyline/kernel/types/KThread.h +++ b/app/src/main/cpp/skyline/kernel/types/KThread.h @@ -17,7 +17,7 @@ namespace skyline::kernel::type { u64 entryArg; //!< An argument to pass to the process on entry /** - * @brief This holds a range of priorities for a corresponding system + * @brief A range of priorities for a corresponding system */ struct Priority { i8 low; //!< The low range of priority @@ -28,7 +28,7 @@ namespace skyline::kernel::type { * @param value The priority value to rescale * @return The rescaled priority value according to this range */ - constexpr inline i8 Rescale(const Priority &priority, i8 value) { + constexpr i8 Rescale(const Priority &priority, i8 value) { return static_cast(priority.low + ((static_cast(priority.high - priority.low) / static_cast(priority.low - priority.high)) * (static_cast(value) - priority.low))); } @@ -36,7 +36,7 @@ namespace skyline::kernel::type { * @param value The priority value to check for validity * @return If the supplied priority value is valid */ - constexpr inline bool Valid(i8 value) { + constexpr bool Valid(i8 value) { return (value >= low) && (value <= high); } }; @@ -45,12 +45,12 @@ namespace skyline::kernel::type { enum class Status { Created, //!< The thread has been created but has not been started yet Running, //!< The thread is running currently - Dead //!< The thread is dead and not running - } status = Status::Created; //!< The state of the thread + Dead, //!< The thread is dead and not running + } status = Status::Created; std::atomic cancelSync{false}; //!< This is to flag to a thread to cancel a synchronization call it currently is in std::shared_ptr ctxMemory; //!< The KSharedMemory of the shared memory allocated by the guest process TLS KHandle handle; // The handle of the object in the handle table - pid_t tid; //!< The TID of the current thread + pid_t tid; //!< The Linux Thread ID of the current thread u64 stackTop; //!< The top of the stack (Where it starts growing downwards from) u64 tls; //!< The address of TLS (Thread Local Storage) slot assigned to the current thread i8 priority; //!< The priority of a thread in Nintendo format @@ -59,7 +59,6 @@ namespace skyline::kernel::type { Priority switchPriority{0, 63}; //!< The range of priorities for the Nintendo Switch /** - * @param state The state of the device * @param handle The handle of the current thread * @param selfTid The TID of this thread * @param entryPoint The address to start execution at @@ -78,12 +77,12 @@ namespace skyline::kernel::type { ~KThread(); /** - * @brief This starts this thread process + * @brief Starts this thread process */ void Start(); /** - * @brief This kills the thread + * @brief Kills the thread process */ void Kill(); diff --git a/app/src/main/cpp/skyline/kernel/types/KTransferMemory.cpp b/app/src/main/cpp/skyline/kernel/types/KTransferMemory.cpp index 761f21c3..e27e67b2 100644 --- a/app/src/main/cpp/skyline/kernel/types/KTransferMemory.cpp +++ b/app/src/main/cpp/skyline/kernel/types/KTransferMemory.cpp @@ -4,6 +4,7 @@ #include #include #include +#include "KProcess.h" #include "KTransferMemory.h" namespace skyline::kernel::type { diff --git a/app/src/main/cpp/skyline/kernel/types/KTransferMemory.h b/app/src/main/cpp/skyline/kernel/types/KTransferMemory.h index dfdc0e11..eb132fc3 100644 --- a/app/src/main/cpp/skyline/kernel/types/KTransferMemory.h +++ b/app/src/main/cpp/skyline/kernel/types/KTransferMemory.h @@ -18,7 +18,6 @@ namespace skyline::kernel::type { size_t size; //!< The current size of the allocated memory /** - * @param state The state of the device * @param host If to map the memory on host or guest * @param address The address to map to (If NULL an arbitrary address is picked) * @param size The size of the allocation diff --git a/app/src/main/cpp/skyline/loader/executable.h b/app/src/main/cpp/skyline/loader/executable.h index 3725d365..aec9e796 100644 --- a/app/src/main/cpp/skyline/loader/executable.h +++ b/app/src/main/cpp/skyline/loader/executable.h @@ -7,11 +7,11 @@ namespace skyline::loader { /** - * @brief The Executable struct encapsulates the segments of an executable + * @brief The contents of an executable binary abstracted away from the derivatives of Loader */ struct Executable { /** - * @brief This holds the contents and offset of an executable segment + * @brief The contents and offset of an executable segment */ struct Segment { std::vector contents; //!< The raw contents of the segment diff --git a/app/src/main/cpp/skyline/loader/loader.cpp b/app/src/main/cpp/skyline/loader/loader.cpp index 89e7c3f6..297900c5 100644 --- a/app/src/main/cpp/skyline/loader/loader.cpp +++ b/app/src/main/cpp/skyline/loader/loader.cpp @@ -3,6 +3,7 @@ #include #include +#include #include #include "loader.h" diff --git a/app/src/main/cpp/skyline/loader/loader.h b/app/src/main/cpp/skyline/loader/loader.h index 47c354c5..4cd431a2 100644 --- a/app/src/main/cpp/skyline/loader/loader.h +++ b/app/src/main/cpp/skyline/loader/loader.h @@ -8,7 +8,7 @@ namespace skyline::loader { /** - * @brief This enumerates the types of ROM files + * @brief The types of ROM files * @note This needs to be synchronized with emu.skyline.loader.BaseLoader.RomFormat */ enum class RomFormat { @@ -20,7 +20,7 @@ namespace skyline::loader { }; /** - * @brief This enumerates all possible results when parsing ROM files + * @brief All possible results when parsing ROM files * @note This needs to be synchronized with emu.skyline.loader.LoaderResult */ enum class LoaderResult : int8_t { @@ -29,7 +29,7 @@ namespace skyline::loader { MissingHeaderKey, MissingTitleKey, MissingTitleKek, - MissingKeyArea + MissingKeyArea, }; /** @@ -48,7 +48,7 @@ namespace skyline::loader { class Loader { protected: /** - * @brief This contains information about the placement of an executable in memory + * @brief Information about the placement of an executable in memory */ struct ExecutableLoadInfo { size_t base; //!< The base of the loaded executable @@ -56,7 +56,7 @@ namespace skyline::loader { }; /** - * @brief This loads an executable into memory + * @brief Loads an executable into memory * @param process The process to load the executable into * @param executable The executable itself * @param offset The offset from the base address that the executable should be placed at @@ -78,9 +78,8 @@ namespace skyline::loader { } /** - * @brief This loads in the data of the main process + * @brief Loads in the data of the main process * @param process The process to load in the data - * @param state The state of the device */ virtual void LoadProcessData(const std::shared_ptr process, const DeviceState &state) = 0; }; diff --git a/app/src/main/cpp/skyline/loader/nca.h b/app/src/main/cpp/skyline/loader/nca.h index a4814495..b1d4854f 100644 --- a/app/src/main/cpp/skyline/loader/nca.h +++ b/app/src/main/cpp/skyline/loader/nca.h @@ -8,7 +8,8 @@ namespace skyline::loader { /** - * @brief The NcaLoader class allows loading an NCA's ExeFS through the Loader interface (https://switchbrew.org/wiki/NSO) + * @brief The NcaLoader class allows loading an NCA's ExeFS through the Loader interface + * @url https://switchbrew.org/wiki/NSO */ class NcaLoader : public Loader { private: @@ -18,7 +19,7 @@ namespace skyline::loader { NcaLoader(const std::shared_ptr &backing, const std::shared_ptr &keyStore); /** - * @brief This loads an ExeFS into memory + * @brief Loads an ExeFS into memory * @param exefs A filesystem object containing the ExeFS filesystem to load into memory * @param process The process to load the ExeFS into */ diff --git a/app/src/main/cpp/skyline/loader/nro.h b/app/src/main/cpp/skyline/loader/nro.h index ddb952f0..0ed2ff3d 100644 --- a/app/src/main/cpp/skyline/loader/nro.h +++ b/app/src/main/cpp/skyline/loader/nro.h @@ -7,21 +7,16 @@ namespace skyline::loader { /** - * @brief The NroLoader class abstracts access to an NRO file through the Loader interface (https://switchbrew.org/wiki/NRO) + * @brief The NroLoader class abstracts access to an NRO file through the Loader interface + * @url https://switchbrew.org/wiki/NRO */ class NroLoader : public Loader { private: - /** - * @brief This holds a single data segment's offset and size - */ struct NroSegmentHeader { - u32 offset; //!< The offset of the region - u32 size; //!< The size of the region + u32 offset; + u32 size; }; - /** - * @brief This holds the header of an NRO file - */ struct NroHeader { u32 _pad0_; u32 modOffset; //!< The offset of the MOD metadata @@ -38,7 +33,7 @@ namespace skyline::loader { u32 bssSize; //!< The size of the bss segment u32 _pad2_; - u64 buildId[4]; //!< The build ID of the NRO + std::array buildId; //!< The build ID of the NRO u64 _pad3_; NroSegmentHeader apiInfo; //!< The .apiInfo segment header @@ -46,29 +41,27 @@ namespace skyline::loader { NroSegmentHeader dynsym; //!< The .dynsym segment header } header{}; - /** - * @brief This holds a single asset section's offset and size - */ struct NroAssetSection { - u64 offset; //!< The offset of the region - u64 size; //!< The size of the region + u64 offset; + u64 size; }; /** - * @brief This holds various metadata about an NRO, it is only used by homebrew - */ + * @brief The asset section was created by homebrew developers to store additional data for their applications to use + * @note This would actually be retrieved by NRO homebrew by reading the NRO file itself (reading it's own binary) but libnx homebrew wrongly detects the images to be running in NSO mode where the RomFS is handled by HOS, this allows us to just provide the parsed data from the asset section to it directly + */ struct NroAssetHeader { - u32 magic; //!< The asset section magic "ASET" - u32 version; //!< The format version - NroAssetSection icon; //!< The header describing the location of the icon - NroAssetSection nacp; //!< The header describing the location of the NACP - NroAssetSection romFs; //!< The header describing the location of the RomFS + u32 magic; //!< "ASET" + u32 version; + NroAssetSection icon; + NroAssetSection nacp; + NroAssetSection romFs; } assetHeader{}; - std::shared_ptr backing; //!< The backing of the NRO loader + std::shared_ptr backing; /** - * @brief This reads the data of the specified segment + * @brief Reads the data of the specified segment * @param segment The header of the segment to read * @return A buffer containing the data of the requested segment */ diff --git a/app/src/main/cpp/skyline/loader/nso.h b/app/src/main/cpp/skyline/loader/nso.h index b6d59f1f..6dd689c8 100644 --- a/app/src/main/cpp/skyline/loader/nso.h +++ b/app/src/main/cpp/skyline/loader/nso.h @@ -7,10 +7,13 @@ namespace skyline::loader { /** - * @brief The NsoLoader class abstracts access to an NSO file through the Loader interface (https://switchbrew.org/wiki/NSO) + * @brief The NsoLoader class abstracts access to an NSO file through the Loader interface + * @url https://switchbrew.org/wiki/NSO */ class NsoLoader : public Loader { private: + std::shared_ptr backing; + union NsoFlags { struct { bool textCompressed : 1; //!< .text is compressed @@ -20,13 +23,10 @@ namespace skyline::loader { bool roHash : 1; //!< .rodata hash should be checked before loading bool dataHash : 1; //!< .data hash should be checked before loading }; - u32 raw; //!< The raw value of the flags + u32 raw; }; static_assert(sizeof(NsoFlags) == 0x4); - /** - * @brief This holds a single data segment's offset, loading offset and size - */ struct NsoSegmentHeader { u32 fileOffset; //!< The offset of the segment in the NSO u32 memoryOffset; //!< The memory offset where the region should be loaded @@ -34,9 +34,6 @@ namespace skyline::loader { }; static_assert(sizeof(NsoSegmentHeader) == 0xC); - /** - * @brief This holds the header of an NSO file - */ struct NsoHeader { u32 magic; //!< The NSO magic "NSO0" u32 version; //!< The version of the application @@ -50,7 +47,7 @@ namespace skyline::loader { NsoSegmentHeader data; //!< The .data segment header u32 bssSize; //!< The size of the .bss segment - u64 buildId[4]; //!< The build ID of the NSO + std::array buildId; //!< The build ID of the NSO u32 textCompressedSize; //!< The size of the compressed .text segment u32 roCompressedSize; //!< The size of the compressed .rodata segment @@ -62,14 +59,12 @@ namespace skyline::loader { u64 dynstr; //!< The .rodata-relative offset of .dynstr u64 dynsym; //!< The .rodata-relative offset of .dynsym - u64 segmentHashes[3][4]; //!< The SHA256 checksums of the .text, .rodata and .data segments + std::array, 3> segmentHashes; //!< The SHA256 checksums of the .text, .rodata and .data segments }; static_assert(sizeof(NsoHeader) == 0x100); - std::shared_ptr backing; //!< The backing of the NSO loader - /** - * @brief This reads the specified segment from the backing and decompresses it if needed + * @brief Reads the specified segment from the backing and decompresses it if needed * @param segment The header of the segment to read * @param compressedSize The compressed size of the segment, 0 if the segment is not compressed * @return A buffer containing the data of the requested segment @@ -80,7 +75,7 @@ namespace skyline::loader { NsoLoader(const std::shared_ptr &backing); /** - * @brief This loads an NSO into memory, offset by the given amount + * @brief Loads an NSO into memory, offset by the given amount * @param backing The backing of the NSO * @param process The process to load the NSO into * @param offset The offset from the base address to place the NSO diff --git a/app/src/main/cpp/skyline/loader/nsp.h b/app/src/main/cpp/skyline/loader/nsp.h index bb497119..b50d0a6b 100644 --- a/app/src/main/cpp/skyline/loader/nsp.h +++ b/app/src/main/cpp/skyline/loader/nsp.h @@ -11,12 +11,13 @@ namespace skyline::loader { /** - * @brief The NspLoader class consolidates all the data in an NSP providing a simple way to load an application and access its metadata (https://switchbrew.org/wiki/NCA_Format#PFS0) + * @brief The NspLoader class consolidates all the data in an NSP providing a simple way to load an application and access its metadata + * @url https://switchbrew.org/wiki/NCA_Format#PFS0 */ class NspLoader : public Loader { private: std::shared_ptr nsp; //!< A shared pointer to the NSP's PFS0 - std::shared_ptr controlRomFs; //!< A pointer to the control NCA's RomFS + std::shared_ptr controlRomFs; //!< A shared pointer to the control NCA's RomFS std::optional programNca; //!< The main program NCA within the NSP std::optional controlNca; //!< The main control NCA within the NSP diff --git a/app/src/main/cpp/skyline/nce.cpp b/app/src/main/cpp/skyline/nce.cpp index b6c19072..2be83a84 100644 --- a/app/src/main/cpp/skyline/nce.cpp +++ b/app/src/main/cpp/skyline/nce.cpp @@ -4,10 +4,12 @@ #include #include #include "os.h" +#include "gpu.h" #include "jvm.h" +#include "kernel/types/KProcess.h" +#include "kernel/svc.h" #include "nce/guest.h" #include "nce/instructions.h" -#include "kernel/svc.h" #include "nce.h" extern bool Halt; @@ -194,7 +196,6 @@ namespace skyline { regStr += fmt::format("\nStack Pointer: 0x{:X}", ctx->sp); constexpr u8 numRegisters{31}; //!< The amount of general-purpose registers in ARMv8 - for (u8 index{}; index < numRegisters - 2; index += 2) { auto xStr{index < 10 ? " X" : "X"}; regStr += fmt::format("\n{}{}: 0x{:<16X} {}{}: 0x{:X}", xStr, index, ctx->registers.regs[index], xStr, index + 1, ctx->registers.regs[index + 1]); diff --git a/app/src/main/cpp/skyline/nce.h b/app/src/main/cpp/skyline/nce.h index a7f3d0c6..0e48c9ab 100644 --- a/app/src/main/cpp/skyline/nce.h +++ b/app/src/main/cpp/skyline/nce.h @@ -3,8 +3,8 @@ #pragma once +#include "common.h" #include -#include "kernel/types/KSharedMemory.h" namespace skyline { /** @@ -12,11 +12,11 @@ namespace skyline { */ class NCE { private: - DeviceState &state; //!< The state of the device + DeviceState &state; std::unordered_map> threadMap; //!< This maps all of the host threads to their corresponding kernel thread /** - * @brief This function is the event loop of a kernel thread managing a guest thread + * @brief The event loop of a kernel thread managing a guest thread * @param thread The PID of the thread to manage */ void KernelThread(pid_t thread); @@ -30,7 +30,7 @@ namespace skyline { ~NCE(); /** - * @brief This function is the main event loop of the program + * @brief The main event loop of the program */ void Execute(); @@ -65,14 +65,14 @@ namespace skyline { void StartThread(u64 entryArg, u32 handle, std::shared_ptr &thread); /** - * @brief This prints out a trace and the CPU context + * @brief Prints out a trace and the CPU context * @param numHist The amount of previous instructions to print (Can be 0) * @param ctx The ThreadContext of the thread to log */ void ThreadTrace(u16 numHist = 10, ThreadContext *ctx = nullptr); /** - * @brief This patches specific parts of the code + * @brief Patches specific parts of the code * @param code A vector with the code to be patched * @param baseAddress The address at which the code is mapped * @param offset The offset of the code block from the base address diff --git a/app/src/main/cpp/skyline/nce/guest.h b/app/src/main/cpp/skyline/nce/guest.h index 15917a84..d41592f1 100644 --- a/app/src/main/cpp/skyline/nce/guest.h +++ b/app/src/main/cpp/skyline/nce/guest.h @@ -17,28 +17,28 @@ namespace skyline { #endif /** - * @brief This is the entry point for all guest threads + * @brief The entry point for all guest threads * @param address The address of the actual thread entry point */ void GuestEntry(u64 address); /** - * @brief This saves the context from CPU registers into TLS + * @brief Saves the context from CPU registers into TLS */ extern "C" void SaveCtx(void); /** - * @brief This loads the context from TLS into CPU registers + * @brief Loads the context from TLS into CPU registers */ extern "C" void LoadCtx(void); /** - * @brief This rescales the clock to Tegra X1 levels and puts the output on stack + * @brief Rescales the clock to Tegra X1 levels and puts the output on stack */ extern "C" __noreturn void RescaleClock(void); /** - * @brief This is used to handle all SVC calls + * @brief Handles all SVC calls * @param pc The address of PC when the call was being done * @param svc The SVC ID of the SVC being called */ diff --git a/app/src/main/cpp/skyline/nce/guest_common.h b/app/src/main/cpp/skyline/nce/guest_common.h index 03e2ab18..49e47374 100644 --- a/app/src/main/cpp/skyline/nce/guest_common.h +++ b/app/src/main/cpp/skyline/nce/guest_common.h @@ -20,7 +20,7 @@ namespace skyline { using i8 = __int8_t; //!< Signed 8-bit integer /** - * @brief This union holds the state of all the general purpose registers in the guest + * @brief The state of all the general purpose registers in the guest * @note Read about ARMv8 registers here: https://developer.arm.com/docs/100878/latest/registers * @note X30 or LR is not provided as it is reserved for other uses */ @@ -122,9 +122,6 @@ namespace skyline { }; }; - /** - * @brief This enumeration is used to convey the state of a thread to the kernel - */ enum class ThreadState : u8 { NotReady = 0, //!< The thread hasn't yet entered the entry handler Running = 1, //!< The thread is currently executing code @@ -136,7 +133,7 @@ namespace skyline { }; /** - * @brief This enumeration holds the functions that can be run on the guest process + * @brief The functions that can be run on the guest process */ enum class ThreadCall : u8 { Syscall = 1, //!< A linux syscall needs to be called from the guest @@ -145,7 +142,7 @@ namespace skyline { }; /** - * @brief This structure holds the context of a thread during kernel calls + * @brief The context of a thread during kernel calls, it is stored in TLS on each guest thread */ struct ThreadContext { ThreadState state; //!< The state of the guest diff --git a/app/src/main/cpp/skyline/nce/instructions.h b/app/src/main/cpp/skyline/nce/instructions.h index a97032f4..78befbff 100644 --- a/app/src/main/cpp/skyline/nce/instructions.h +++ b/app/src/main/cpp/skyline/nce/instructions.h @@ -7,29 +7,24 @@ namespace skyline { namespace regs { enum X { X0, X1, X2, X3, X4, X5, X6, X7, X8, X9, X10, X11, X12, X13, X14, X15, X16, X17, X18, X19, X20, X21, X22, X23, X24, X25, X26, X27, X28, X29, X30 }; enum W { W0, W1, W2, W3, W4, W5, W6, W7, W8, W9, W10, W11, W12, W13, W14, W15, W16, W17, W18, W19, W20, W21, W22, W23, W24, W25, W26, W27, W28, W29, W30 }; - enum S { Sp, Pc }; } namespace instr { /** - * @brief A bit-field struct that encapsulates a BRK instruction. See https://developer.arm.com/docs/ddi0596/latest/base-instructions-alphabetic-order/brk-breakpoint-instruction. + * @url https://developer.arm.com/docs/ddi0596/latest/base-instructions-alphabetic-order/brk-breakpoint-instruction */ struct Brk { /** * @brief Creates a BRK instruction with a specific immediate value, used for generating BRK opcodes * @param value The immediate value of the instruction */ - inline constexpr Brk(u16 value) { + constexpr Brk(u16 value) { sig0 = 0x0; this->value = value; sig1 = 0x6A1; } - /** - * @brief Returns if the opcode is valid or not - * @return If the opcode represents a valid BRK instruction - */ - inline constexpr bool Verify() { + constexpr bool Verify() { return (sig0 == 0x0 && sig1 == 0x6A1); } @@ -39,20 +34,16 @@ namespace skyline { u32 value : 16; //!< 16-bit immediate value u16 sig1 : 11; //!< 11-bit signature (0x6A1) }; - u32 raw{}; //!< The raw value of the instruction + u32 raw{}; }; }; static_assert(sizeof(Brk) == sizeof(u32)); /** - * @brief A bit-field struct that encapsulates a SVC instruction. See https://developer.arm.com/docs/ddi0596/latest/base-instructions-alphabetic-order/svc-supervisor-call. + * @url https://developer.arm.com/docs/ddi0596/latest/base-instructions-alphabetic-order/svc-supervisor-call */ struct Svc { - /** - * @brief Returns if the opcode is valid or not - * @return If the opcode represents a valid SVC instruction - */ - inline constexpr bool Verify() { + constexpr bool Verify() { return (sig0 == 0x1 && sig1 == 0x6A0); } @@ -62,31 +53,26 @@ namespace skyline { u32 value : 16; //!< 16-bit immediate value u16 sig1 : 11; //!< 11-bit signature (0x6A1) }; - u32 raw{}; //!< The raw value of the instruction + u32 raw{}; }; }; static_assert(sizeof(Svc) == sizeof(u32)); /** - * @brief A bit-field struct that encapsulates a MRS instruction. See https://developer.arm.com/docs/ddi0596/latest/base-instructions-alphabetic-order/mrs-move-system-register. + * @url https://developer.arm.com/docs/ddi0596/latest/base-instructions-alphabetic-order/mrs-move-system-register */ struct Mrs { /** - * @brief Creates a MRS instruction, used for generating BRK opcodes * @param srcReg The source system register * @param dstReg The destination Xn register */ - inline constexpr Mrs(u32 srcReg, regs::X dstReg) { + constexpr Mrs(u32 srcReg, regs::X dstReg) { this->srcReg = srcReg; this->destReg = dstReg; sig = 0xD53; } - /** - * @brief Returns if the opcode is valid or not - * @return If the opcode represents a valid MRS instruction - */ - inline constexpr bool Verify() { + constexpr bool Verify() { return (sig == 0xD53); } @@ -96,20 +82,16 @@ namespace skyline { u32 srcReg : 15; //!< 15-bit source register u16 sig : 12; //!< 16-bit signature (0xD53) }; - u32 raw{}; //!< The raw value of the instruction + u32 raw{}; }; }; static_assert(sizeof(Mrs) == sizeof(u32)); /** - * @brief A bit-field struct that encapsulates a MSR instruction. See https://developer.arm.com/docs/ddi0596/g/base-instructions-alphabetic-order/msr-register-move-general-purpose-register-to-system-register. + * @url https://developer.arm.com/docs/ddi0596/g/base-instructions-alphabetic-order/msr-register-move-general-purpose-register-to-system-register */ struct Msr { - /** - * @brief Returns if the opcode is valid or not - * @return If the opcode represents a valid MSR instruction - */ - inline constexpr bool Verify() { + constexpr bool Verify() { return (sig == 0xD51); } @@ -119,38 +101,32 @@ namespace skyline { u32 destReg : 15; //!< 15-bit source register u16 sig : 12; //!< 16-bit signature (0xD51) }; - u32 raw{}; //!< The raw value of the instruction + u32 raw{}; }; }; static_assert(sizeof(Msr) == sizeof(u32)); /** - * @brief A bit-field struct that encapsulates a B instruction. See https://developer.arm.com/docs/ddi0596/latest/base-instructions-alphabetic-order/b-branch. + * @url https://developer.arm.com/docs/ddi0596/latest/base-instructions-alphabetic-order/b-branch */ struct B { public: /** - * @brief Creates a B instruction with a specific offset - * @param offset The offset to encode in the instruction (Should be 32-bit aligned) + * @param offset The relative offset to branch to (Should be 32-bit aligned) */ - inline constexpr B(i64 offset) { - this->offset = static_cast(offset / 4); + constexpr B(i64 offset) { + this->offset = static_cast(offset / sizeof(u32)); sig = 0x5; } /** - * @brief Returns the offset of the instruction - * @return The offset encoded within the instruction + * @return The offset encoded within the instruction in bytes */ - inline constexpr i32 Offset() { - return offset * 4; + constexpr i32 Offset() { + return offset * sizeof(u32); } - /** - * @brief Returns if the opcode is valid or not - * @return If the opcode represents a valid Branch instruction - */ - inline constexpr bool Verify() { + constexpr bool Verify() { return (sig == 0x5); } @@ -159,38 +135,32 @@ namespace skyline { i32 offset : 26; //!< 26-bit branch offset u8 sig : 6; //!< 6-bit signature (0x5) }; - u32 raw{}; //!< The raw value of the instruction + u32 raw{}; }; }; static_assert(sizeof(B) == sizeof(u32)); /** - * @brief A bit-field struct that encapsulates a BL instruction. See https://developer.arm.com/docs/ddi0596/latest/base-instructions-alphabetic-order/b-branch. + * @url https://developer.arm.com/docs/ddi0596/h/base-instructions-alphabetic-order/bl-branch-with-link */ struct BL { public: /** - * @brief Creates a BL instruction with a specific offset - * @param offset The offset to encode in the instruction (Should be 32-bit aligned) + * @param offset The relative offset to branch to (Should be 32-bit aligned) */ - inline constexpr BL(i64 offset) { - this->offset = static_cast(offset / 4); + constexpr BL(i64 offset) { + this->offset = static_cast(offset / sizeof(u32)); sig = 0x25; } /** - * @brief Returns the offset of the instruction - * @return The offset encoded within the instruction + * @return The offset encoded within the instruction in bytes */ - inline constexpr i32 Offset() { - return offset * 4; + constexpr i32 Offset() { + return offset * sizeof(u32); } - /** - * @brief Returns if the opcode is valid or not - * @return If the opcode represents a valid Branch Linked instruction - */ - inline constexpr bool Verify() { + constexpr bool Verify() { return (sig == 0x25); } @@ -199,23 +169,22 @@ namespace skyline { i32 offset : 26; //!< 26-bit branch offset u8 sig : 6; //!< 6-bit signature (0x25) }; - u32 raw{}; //!< The raw value of the instruction + u32 raw{}; }; }; static_assert(sizeof(BL) == sizeof(u32)); /** - * @brief A bit-field struct that encapsulates a MOVZ instruction. See https://developer.arm.com/docs/ddi0596/e/base-instructions-alphabetic-order/movz-move-wide-with-zero. + * @url https://developer.arm.com/docs/ddi0596/e/base-instructions-alphabetic-order/movz-move-wide-with-zero */ struct Movz { public: /** - * @brief Creates a MOVZ instruction * @param destReg The destination Xn register to store the value in * @param imm16 The 16-bit value to store * @param shift The offset (in units of 16-bits) in the register to store the value at */ - inline constexpr Movz(regs::X destReg, u16 imm16, u8 shift = 0) { + constexpr Movz(regs::X destReg, u16 imm16, u8 shift = 0) { this->destReg = static_cast(destReg); this->imm16 = imm16; hw = shift; @@ -224,12 +193,11 @@ namespace skyline { } /** - * @brief Creates a MOVZ instruction * @param destReg The destination Wn register to store the value in * @param imm16 The 16-bit value to store * @param shift The offset (in units of 16-bits) in the register to store the value at */ - inline constexpr Movz(regs::W destReg, u16 imm16, u8 shift = 0) { + constexpr Movz(regs::W destReg, u16 imm16, u8 shift = 0) { this->destReg = static_cast(destReg); this->imm16 = imm16; hw = shift; @@ -238,18 +206,13 @@ namespace skyline { } /** - * @brief Returns the offset of the instruction - * @return The offset encoded within the instruction (In Bytes) + * @return The shift encoded within the instruction in bytes */ - inline constexpr u8 Shift() { + constexpr u8 Shift() { return static_cast(hw * sizeof(u16)); } - /** - * @brief Returns if the opcode is valid or not - * @return If the opcode represents a valid MOVZ instruction - */ - inline constexpr bool Verify() { + constexpr bool Verify() { return (sig == 0xA5); } @@ -261,23 +224,22 @@ namespace skyline { u8 sig : 8; //!< 8-bit signature (0xA5) u8 sf : 1; //!< 1-bit register type }; - u32 raw{}; //!< The raw value of the instruction + u32 raw{}; }; }; static_assert(sizeof(Movz) == sizeof(u32)); /** - * @brief A bit-field struct that encapsulates a MOVK instruction. See https://developer.arm.com/docs/ddi0596/e/base-instructions-alphabetic-order/movk-move-wide-with-keep. + * @url https://developer.arm.com/docs/ddi0596/e/base-instructions-alphabetic-order/movk-move-wide-with-keep */ struct Movk { public: /** - * @brief Creates a MOVK instruction * @param destReg The destination Xn register to store the value in * @param imm16 The 16-bit value to store * @param shift The offset (in units of 16-bits) in the register to store the value at */ - inline constexpr Movk(regs::X destReg, u16 imm16, u8 shift = 0) { + constexpr Movk(regs::X destReg, u16 imm16, u8 shift = 0) { this->destReg = static_cast(destReg); this->imm16 = imm16; hw = shift; @@ -286,12 +248,11 @@ namespace skyline { } /** - * @brief Creates a MOVK instruction * @param destReg The destination Wn register to store the value in * @param imm16 The 16-bit value to store * @param shift The offset (in units of 16-bits) in the register to store the value at */ - inline constexpr Movk(regs::W destReg, u16 imm16, u8 shift = 0) { + constexpr Movk(regs::W destReg, u16 imm16, u8 shift = 0) { this->destReg = static_cast(destReg); this->imm16 = imm16; hw = shift; @@ -300,18 +261,13 @@ namespace skyline { } /** - * @brief Returns the offset of the instruction - * @return The offset encoded within the instruction (In Bytes) + * @return The shift encoded within the instruction in bytes */ - inline constexpr u8 Shift() { + constexpr u8 Shift() { return static_cast(hw * sizeof(u16)); } - /** - * @brief Returns if the opcode is valid or not - * @return If the opcode represents a valid MOVK instruction - */ - inline constexpr bool Verify() { + constexpr bool Verify() { return (sig == 0xE5); } @@ -323,7 +279,7 @@ namespace skyline { u8 sig : 8; //!< 8-bit signature (0xA5) u8 sf : 1; //!< 1-bit register type }; - u32 raw{}; //!< The raw value of the instruction + u32 raw{}; }; }; static_assert(sizeof(Movk) == sizeof(u32)); @@ -334,7 +290,7 @@ namespace skyline { * @return A array with the instructions to insert the value */ template - inline constexpr std::array MoveRegister(regs::X destination, Type value) { + constexpr std::array MoveRegister(regs::X destination, Type value) { std::array instructions; auto valuePointer{reinterpret_cast(&value)}; @@ -353,7 +309,7 @@ namespace skyline { } /** - * @brief A bit-field struct that encapsulates a MOV (Register) instruction. See https://developer.arm.com/docs/ddi0596/e/base-instructions-alphabetic-order/mov-register-move-register-an-alias-of-orr-shifted-register. + * @url https://developer.arm.com/docs/ddi0596/e/base-instructions-alphabetic-order/mov-register-move-register-an-alias-of-orr-shifted-register */ struct Mov { public: @@ -362,10 +318,10 @@ namespace skyline { * @param destReg The destination Xn register to store the value in * @param srcReg The source Xn register to retrieve the value from */ - inline constexpr Mov(regs::X destReg, regs::X srcReg) { + constexpr Mov(regs::X destReg, regs::X srcReg) { this->destReg = static_cast(destReg); sig0 = 0x1F; - imm6 = 0; + imm = 0; this->srcReg = static_cast(srcReg); sig1 = 0x150; sf = 1; @@ -376,20 +332,16 @@ namespace skyline { * @param destReg The destination Wn register to store the value in * @param srcReg The source Wn register to retrieve the value from */ - inline constexpr Mov(regs::W destReg, regs::W srcReg) { + constexpr Mov(regs::W destReg, regs::W srcReg) { this->destReg = static_cast(destReg); sig0 = 0x1F; - imm6 = 0; + imm = 0; this->srcReg = static_cast(srcReg); sig1 = 0x150; sf = 0; } - /** - * @brief Returns if the opcode is valid or not - * @return If the opcode represents a valid MOVZ instruction - */ - inline constexpr bool Verify() { + constexpr bool Verify() { return (sig0 == 0x1F) && (sig1 == 0x150); } @@ -397,32 +349,27 @@ namespace skyline { struct __attribute__((packed)) { u8 destReg : 5; //!< 5-bit destination register u8 sig0 : 5; //!< 5-bit signature (0x1F) - u8 imm6 : 6; //!< 6-bit immediate value + u8 imm : 6; //!< 6-bit immediate value u8 srcReg : 5; //!< 5-bit source register u16 sig1 : 10; //!< 10-bit signature (0x150) u8 sf : 1; //!< 1-bit register type }; - u32 raw{}; //!< The raw value of the instruction + u32 raw{}; }; }; static_assert(sizeof(Mov) == sizeof(u32)); /** - * @brief A bit-field struct that encapsulates a LDR (immediate) instruction. See https://developer.arm.com/docs/ddi0596/e/base-instructions-alphabetic-order/ldr-immediate-load-register-immediate. + * @url https://developer.arm.com/docs/ddi0596/e/base-instructions-alphabetic-order/ldr-immediate-load-register-immediate */ struct Ldr { public: /** - * @brief Creates a LDR (immediate) instruction * @param raw The raw value of the whole instruction */ - inline constexpr Ldr(u32 raw) : raw(raw) {} + constexpr Ldr(u32 raw) : raw(raw) {} - /** - * @brief Returns if the opcode is valid or not - * @return If the opcode represents a valid FCVTZU instruction - */ - inline constexpr bool Verify() { + constexpr bool Verify() { return (sig0 == 0x0 && sig1 == 0x1CA && sig2 == 0x1); } @@ -436,7 +383,7 @@ namespace skyline { u8 sf : 1; //!< 1-bit register type u8 sig2 : 1; //!< 1-bit signature (0x1) }; - u32 raw{}; //!< The raw value of the instruction + u32 raw{}; }; }; static_assert(sizeof(Ldr) == sizeof(u32)); diff --git a/app/src/main/cpp/skyline/os.cpp b/app/src/main/cpp/skyline/os.cpp index 21400906..cc693bd8 100644 --- a/app/src/main/cpp/skyline/os.cpp +++ b/app/src/main/cpp/skyline/os.cpp @@ -1,13 +1,15 @@ // SPDX-License-Identifier: MPL-2.0 // Copyright © 2020 Skyline Team and Contributors (https://github.com/skyline-emu/) +#include "nce.h" +#include "nce/guest.h" +#include "kernel/memory.h" +#include "kernel/types/KProcess.h" #include "vfs/os_backing.h" #include "loader/nro.h" #include "loader/nso.h" #include "loader/nca.h" #include "loader/nsp.h" -#include "nce.h" -#include "nce/guest.h" #include "os.h" namespace skyline::kernel { diff --git a/app/src/main/cpp/skyline/os.h b/app/src/main/cpp/skyline/os.h index a03e1a4a..142d7c28 100644 --- a/app/src/main/cpp/skyline/os.h +++ b/app/src/main/cpp/skyline/os.h @@ -3,24 +3,20 @@ #pragma once -#include "common.h" +#include "kernel/memory.h" #include "loader/loader.h" -#include "kernel/ipc.h" -#include "kernel/types/KProcess.h" -#include "kernel/types/KThread.h" #include "services/serviceman.h" -#include "gpu.h" namespace skyline::kernel { /** - * @brief The OS class manages the interaction between Skyline components and the underlying OS in NCE + * @brief The OS class manages the interaction between the various Skyline components */ class OS { public: - DeviceState state; //!< The state of the device - std::shared_ptr process; //!< The KProcess object for the emulator, representing the guest process - service::ServiceManager serviceManager; //!< This manages all of the service functions - MemoryManager memory; //!< The MemoryManager object for this process + DeviceState state; + std::shared_ptr process; + service::ServiceManager serviceManager; + MemoryManager memory; std::string appFilesPath; //!< The full path to the app's files directory /** diff --git a/app/src/main/cpp/skyline/services/account/IAccountServiceForApplication.h b/app/src/main/cpp/skyline/services/account/IAccountServiceForApplication.h index a0e0d464..b2f86bbb 100644 --- a/app/src/main/cpp/skyline/services/account/IAccountServiceForApplication.h +++ b/app/src/main/cpp/skyline/services/account/IAccountServiceForApplication.h @@ -21,17 +21,18 @@ namespace skyline { u64 upper; //!< The upper 64 bits of the user ID u64 lower; //!< The lower 64 bits of the user ID - inline constexpr bool operator==(const UserId &userId) { + constexpr bool operator==(const UserId &userId) { return upper == userId.upper && lower == userId.lower; } - inline constexpr bool operator!=(const UserId &userId) { + constexpr bool operator!=(const UserId &userId) { return !(*this == userId); } }; /** - * @brief IAccountServiceForApplication or acc:u0 provides functions for reading user information (https://switchbrew.org/wiki/Account_services#acc:u0) + * @brief IAccountServiceForApplication or acc:u0 provides functions for reading user information + * @url https://switchbrew.org/wiki/Account_services#acc:u0 */ class IAccountServiceForApplication : public BaseService { private: @@ -44,38 +45,39 @@ namespace skyline { IAccountServiceForApplication(const DeviceState &state, ServiceManager &manager); /** - * @brief This checks if the given user ID exists - */ + * @brief Checks if the given user ID exists + */ Result GetUserExistence(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This returns a list of all user accounts on the console - */ + * @brief Returns a list of all user accounts on the console + */ Result ListAllUsers(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This returns a list of all open user accounts on the console - */ + * @brief Returns a list of all open user accounts on the console + */ Result ListOpenUsers(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This returns the user ID of the last active user on the console - */ + * @brief Returns the user ID of the last active user on the console + */ Result GetLastOpenedUser(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This provides information about the running application for account services to use (https://switchbrew.org/wiki/Account_services#InitializeApplicationInfoV0) + * @brief Provides information about the running application for account services to use + * @url https://switchbrew.org/wiki/Account_services#InitializeApplicationInfoV0 */ Result InitializeApplicationInfoV0(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This returns a handle to an IProfile which can be used for reading user information + * @brief Returns a handle to an IProfile which can be used for reading user information */ Result GetProfile(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This returns a handle to an IManagerForApplication which can be used for reading Nintendo Online info - */ + * @brief Returns a handle to an IManagerForApplication which can be used for reading Nintendo Online info + */ Result GetBaasAccountManagerForApplication(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); SERVICE_DECL( diff --git a/app/src/main/cpp/skyline/services/account/IManagerForApplication.h b/app/src/main/cpp/skyline/services/account/IManagerForApplication.h index a42fca27..0d188a7b 100644 --- a/app/src/main/cpp/skyline/services/account/IManagerForApplication.h +++ b/app/src/main/cpp/skyline/services/account/IManagerForApplication.h @@ -7,7 +7,8 @@ namespace skyline::service::account { /** - * @brief IManagerForApplication provides functions for reading Nintendo Online user information (https://switchbrew.org/wiki/Account_services#IManagerForApplication) + * @brief IManagerForApplication provides functions for reading Nintendo Online user information + * @url https://switchbrew.org/wiki/Account_services#IManagerForApplication */ class IManagerForApplication : public BaseService { public: diff --git a/app/src/main/cpp/skyline/services/account/IProfile.cpp b/app/src/main/cpp/skyline/services/account/IProfile.cpp index b9db8d0d..13b0a5f5 100644 --- a/app/src/main/cpp/skyline/services/account/IProfile.cpp +++ b/app/src/main/cpp/skyline/services/account/IProfile.cpp @@ -27,7 +27,7 @@ namespace skyline::service::account { u64 lastEditTimestamp; //!< A POSIX UTC timestamp denoting the last account edit std::array nickname; //!< UTF-8 Nickname } accountProfileBase = { - .uid = userId + .uid = userId, }; auto username{state.settings->GetString("username_value")}; diff --git a/app/src/main/cpp/skyline/services/account/IProfile.h b/app/src/main/cpp/skyline/services/account/IProfile.h index cd07f303..38e7ed3a 100644 --- a/app/src/main/cpp/skyline/services/account/IProfile.h +++ b/app/src/main/cpp/skyline/services/account/IProfile.h @@ -8,7 +8,8 @@ namespace skyline::service::account { /** - * @brief IProfile provides functions for reading user profile (https://switchbrew.org/wiki/Account_services#IProfile) + * @brief IProfile provides functions for reading user profile + * @url https://switchbrew.org/wiki/Account_services#IProfile */ class IProfile : public BaseService { public: @@ -18,12 +19,12 @@ namespace skyline::service::account { UserId userId; /** - * @brief This returns AccountUserData and AccountProfileBase objects that describe the user's information + * @brief Returns AccountUserData and AccountProfileBase objects that describe the user's information */ Result Get(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This returns an AccountProfileBase object that describe the user's information + * @brief Returns an AccountProfileBase object that describe the user's information */ Result GetBase(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); diff --git a/app/src/main/cpp/skyline/services/am/IAllSystemAppletProxiesService.h b/app/src/main/cpp/skyline/services/am/IAllSystemAppletProxiesService.h index aad6d8d3..239a2646 100644 --- a/app/src/main/cpp/skyline/services/am/IAllSystemAppletProxiesService.h +++ b/app/src/main/cpp/skyline/services/am/IAllSystemAppletProxiesService.h @@ -7,29 +7,34 @@ namespace skyline::service::am { /** - * @brief IAllSystemAppletProxiesService is used to open proxies (https://switchbrew.org/wiki/Applet_Manager_services#appletAE) + * @brief IAllSystemAppletProxiesService is used to open proxies + * @url https://switchbrew.org/wiki/Applet_Manager_services#appletAE */ class IAllSystemAppletProxiesService : public BaseService { public: IAllSystemAppletProxiesService(const DeviceState &state, ServiceManager &manager); /** - * @brief This returns #ILibraryAppletProxy (https://switchbrew.org/wiki/Applet_Manager_services#OpenLibraryAppletProxy) + * @brief Returns #ILibraryAppletProxy + * @url https://switchbrew.org/wiki/Applet_Manager_services#OpenLibraryAppletProxy */ Result OpenLibraryAppletProxy(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This returns #IApplicationProxy (https://switchbrew.org/wiki/Applet_Manager_services#OpenApplicationProxy) + * @brief Returns #IApplicationProxy + * @url https://switchbrew.org/wiki/Applet_Manager_services#OpenApplicationProxy */ Result OpenApplicationProxy(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This returns #IOverlayAppletProxy (https://switchbrew.org/wiki/Applet_Manager_services#OpenOverlayAppletProxy) + * @brief Returns #IOverlayAppletProxy + * @url https://switchbrew.org/wiki/Applet_Manager_services#OpenOverlayAppletProxy */ Result OpenOverlayAppletProxy(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This returns #ISystemAppletProxy (https://switchbrew.org/wiki/Applet_Manager_services#OpenSystemAppletProxy) + * @brief Returns #ISystemAppletProxy + * @url https://switchbrew.org/wiki/Applet_Manager_services#OpenSystemAppletProxy */ Result OpenSystemAppletProxy(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); diff --git a/app/src/main/cpp/skyline/services/am/IApplicationProxyService.h b/app/src/main/cpp/skyline/services/am/IApplicationProxyService.h index 20a6c2ff..a6d8d431 100644 --- a/app/src/main/cpp/skyline/services/am/IApplicationProxyService.h +++ b/app/src/main/cpp/skyline/services/am/IApplicationProxyService.h @@ -7,14 +7,16 @@ namespace skyline::service::am { /** - * @brief IApplicationProxyService is used to open an application proxy (https://switchbrew.org/wiki/Applet_Manager_services#appletOE) + * @brief IApplicationProxyService is used to open an application proxy + * @url https://switchbrew.org/wiki/Applet_Manager_services#appletOE */ class IApplicationProxyService : public BaseService { public: IApplicationProxyService(const DeviceState &state, ServiceManager &manager); /** - * @brief This returns #IApplicationProxy (https://switchbrew.org/wiki/Applet_Manager_services#OpenApplicationProxy) + * @brief Returns #IApplicationProxy + * @url https://switchbrew.org/wiki/Applet_Manager_services#OpenApplicationProxy */ Result OpenApplicationProxy(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); diff --git a/app/src/main/cpp/skyline/services/am/applet/ILibraryAppletAccessor.cpp b/app/src/main/cpp/skyline/services/am/applet/ILibraryAppletAccessor.cpp index fc6dd693..d9584392 100644 --- a/app/src/main/cpp/skyline/services/am/applet/ILibraryAppletAccessor.cpp +++ b/app/src/main/cpp/skyline/services/am/applet/ILibraryAppletAccessor.cpp @@ -32,8 +32,8 @@ namespace skyline::service::am { } Result ILibraryAppletAccessor::PopOutData(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { - constexpr u32 LaunchParameterMagic{0xC79497CA}; //!< This is the magic of the application launch parameters - constexpr size_t LaunchParameterSize{0x88}; //!< This is the size of the launch parameter IStorage + constexpr u32 LaunchParameterMagic{0xC79497CA}; //!< The magic of the application launch parameters + constexpr size_t LaunchParameterSize{0x88}; //!< The size of the launch parameter IStorage auto storageService{std::make_shared(state, manager, LaunchParameterSize)}; diff --git a/app/src/main/cpp/skyline/services/am/applet/ILibraryAppletAccessor.h b/app/src/main/cpp/skyline/services/am/applet/ILibraryAppletAccessor.h index 4e75a530..072921ed 100644 --- a/app/src/main/cpp/skyline/services/am/applet/ILibraryAppletAccessor.h +++ b/app/src/main/cpp/skyline/services/am/applet/ILibraryAppletAccessor.h @@ -8,7 +8,8 @@ namespace skyline::service::am { /** - * @brief ILibraryAppletAccessor is used to communicate with the library applet (https://switchbrew.org/wiki/Applet_Manager_services#ILibraryAppletAccessor) + * @brief ILibraryAppletAccessor is used to communicate with the library applet + * @url https://switchbrew.org/wiki/Applet_Manager_services#ILibraryAppletAccessor */ class ILibraryAppletAccessor : public BaseService { private: @@ -18,27 +19,31 @@ namespace skyline::service::am { ILibraryAppletAccessor(const DeviceState &state, ServiceManager &manager); /** - * @brief This function returns a handle to the library applet state change event + * @brief Returns a handle to the library applet state change event */ Result GetAppletStateChangedEvent(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This function starts the library applet (https://switchbrew.org/wiki/Applet_Manager_services#Start) + * @brief Starts the library applet + * @url https://switchbrew.org/wiki/Applet_Manager_services#Start */ Result Start(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This function returns the exit code of the library applet (https://switchbrew.org/wiki/Applet_Manager_services#GetResult) + * @brief Returns the exit code of the library applet + * @url https://switchbrew.org/wiki/Applet_Manager_services#GetResult */ Result GetResult(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This function pushes in data to the library applet (https://switchbrew.org/wiki/Applet_Manager_services#PushInData) + * @brief Pushes in data to the library applet + * @url https://switchbrew.org/wiki/Applet_Manager_services#PushInData */ Result PushInData(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This function receives data from the library applet (https://switchbrew.org/wiki/Applet_Manager_services#PopOutData) + * @brief Receives data from the library applet + * @url https://switchbrew.org/wiki/Applet_Manager_services#PopOutData */ Result PopOutData(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); diff --git a/app/src/main/cpp/skyline/services/am/controller/IAppletCommonFunctions.h b/app/src/main/cpp/skyline/services/am/controller/IAppletCommonFunctions.h index 42321747..72e4a290 100644 --- a/app/src/main/cpp/skyline/services/am/controller/IAppletCommonFunctions.h +++ b/app/src/main/cpp/skyline/services/am/controller/IAppletCommonFunctions.h @@ -7,7 +7,8 @@ namespace skyline::service::am { /** - * @brief This contains common various functions (https://switchbrew.org/wiki/Applet_Manager_services#IAppletCommonFunctions) + * @brief This contains common various functions + * @url https://switchbrew.org/wiki/Applet_Manager_services#IAppletCommonFunctions */ class IAppletCommonFunctions : public BaseService { public: diff --git a/app/src/main/cpp/skyline/services/am/controller/IApplicationFunctions.cpp b/app/src/main/cpp/skyline/services/am/controller/IApplicationFunctions.cpp index 453b4aff..ab13988e 100644 --- a/app/src/main/cpp/skyline/services/am/controller/IApplicationFunctions.cpp +++ b/app/src/main/cpp/skyline/services/am/controller/IApplicationFunctions.cpp @@ -10,8 +10,8 @@ namespace skyline::service::am { IApplicationFunctions::IApplicationFunctions(const DeviceState &state, ServiceManager &manager) : gpuErrorEvent(std::make_shared(state)), BaseService(state, manager) {} Result IApplicationFunctions::PopLaunchParameter(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { - constexpr u32 LaunchParameterMagic{0xC79497CA}; //!< This is the magic of the application launch parameters - constexpr size_t LaunchParameterSize{0x88}; //!< This is the size of the launch parameter IStorage + constexpr u32 LaunchParameterMagic{0xC79497CA}; //!< The magic of the application launch parameters + constexpr size_t LaunchParameterSize{0x88}; //!< The size of the launch parameter IStorage auto storageService{std::make_shared(state, manager, LaunchParameterSize)}; diff --git a/app/src/main/cpp/skyline/services/am/controller/IApplicationFunctions.h b/app/src/main/cpp/skyline/services/am/controller/IApplicationFunctions.h index 84a73b0b..035c3c0e 100644 --- a/app/src/main/cpp/skyline/services/am/controller/IApplicationFunctions.h +++ b/app/src/main/cpp/skyline/services/am/controller/IApplicationFunctions.h @@ -8,7 +8,8 @@ namespace skyline::service::am { /** - * @brief This has functions that are used to notify an application about it's state (https://switchbrew.org/wiki/Applet_Manager_services#IApplicationFunctions) + * @brief This is used to notify an application about it's own state + * @url https://switchbrew.org/wiki/Applet_Manager_services#IApplicationFunctions */ class IApplicationFunctions : public BaseService { private: @@ -18,42 +19,50 @@ namespace skyline::service::am { IApplicationFunctions(const DeviceState &state, ServiceManager &manager); /** - * @brief This returns an Applet Manager IStorage containing the application's launch parameters (https://switchbrew.org/wiki/Applet_Manager_services#PopLaunchParameter) + * @brief Returns an Applet Manager IStorage containing the application's launch parameters + * @url https://switchbrew.org/wiki/Applet_Manager_services#PopLaunchParameter */ Result PopLaunchParameter(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This creates a save data folder for the requesting application (https://switchbrew.org/wiki/Applet_Manager_services#EnsureSaveData) + * @brief Creates a save data folder for the requesting application + * @url https://switchbrew.org/wiki/Applet_Manager_services#EnsureSaveData */ Result EnsureSaveData(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This returns the desired language for the application (https://switchbrew.org/wiki/Applet_Manager_services#GetDesiredLanguage) + * @brief Returns the desired language for the application + * @url https://switchbrew.org/wiki/Applet_Manager_services#GetDesiredLanguage */ Result GetDesiredLanguage(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This returns if the application is running or not, always returns true (https://switchbrew.org/wiki/Applet_Manager_services#NotifyRunning) + * @brief Returns if the application is running or not, always returns true + * @url https://switchbrew.org/wiki/Applet_Manager_services#NotifyRunning */ Result NotifyRunning(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This returns a UUID, however what it refers to is currently unknown (https://switchbrew.org/wiki/Applet_Manager_services#GetPseudoDeviceId) + * @brief Returns a UUID, however what it refers to is currently unknown + * @url https://switchbrew.org/wiki/Applet_Manager_services#GetPseudoDeviceId */ Result GetPseudoDeviceId(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This initializes gameplay recording (https://switchbrew.org/wiki/Applet_Manager_services#InitializeGamePlayRecording) + * @brief Initializes gameplay recording + * @url https://switchbrew.org/wiki/Applet_Manager_services#InitializeGamePlayRecording */ Result InitializeGamePlayRecording(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This controls the gameplay recording state (https://switchbrew.org/wiki/Applet_Manager_services#SetGamePlayRecordingState) + * @brief Sets the gameplay recording state + * @url https://switchbrew.org/wiki/Applet_Manager_services#SetGamePlayRecordingState */ Result SetGamePlayRecordingState(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This obtains a handle to the system GPU error KEvent (https://switchbrew.org/wiki/Applet_Manager_services#GetGpuErrorDetectedSystemEvent) + * @brief Obtains a handle to the system GPU error KEvent + * @url https://switchbrew.org/wiki/Applet_Manager_services#GetGpuErrorDetectedSystemEvent */ Result GetGpuErrorDetectedSystemEvent(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); diff --git a/app/src/main/cpp/skyline/services/am/controller/IAudioController.h b/app/src/main/cpp/skyline/services/am/controller/IAudioController.h index 2cb95201..48a88d8b 100644 --- a/app/src/main/cpp/skyline/services/am/controller/IAudioController.h +++ b/app/src/main/cpp/skyline/services/am/controller/IAudioController.h @@ -7,7 +7,8 @@ namespace skyline::service::am { /** - * @brief This has functions relating to volume control (https://switchbrew.org/wiki/Applet_Manager_services#IAudioController) + * @brief This is used to control the audio's volume + * @url https://switchbrew.org/wiki/Applet_Manager_services#IAudioController */ class IAudioController : public BaseService { private: @@ -18,17 +19,20 @@ namespace skyline::service::am { IAudioController(const DeviceState &state, ServiceManager &manager); /** - * @brief This sets the expected volumes for an application (https://switchbrew.org/wiki/Applet_Manager_services#SetExpectedMasterVolume) + * @brief Sets the expected volumes for an application + * @url https://switchbrew.org/wiki/Applet_Manager_services#SetExpectedMasterVolume */ Result SetExpectedMasterVolume(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This returns the main applet volume that is expected by the application (https://switchbrew.org/wiki/Applet_Manager_services#GetMainAppletExpectedMasterVolume) + * @brief Returns the main applet volume that is expected by the application + * @url https://switchbrew.org/wiki/Applet_Manager_services#GetMainAppletExpectedMasterVolume */ Result GetMainAppletExpectedMasterVolume(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This returns the library applet volume that is expected by the application (https://switchbrew.org/wiki/Applet_Manager_services#GetLibraryAppletExpectedMasterVolume) + * @brief Returns the library applet volume that is expected by the application + * @url https://switchbrew.org/wiki/Applet_Manager_services#GetLibraryAppletExpectedMasterVolume */ Result GetLibraryAppletExpectedMasterVolume(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); diff --git a/app/src/main/cpp/skyline/services/am/controller/ICommonStateGetter.h b/app/src/main/cpp/skyline/services/am/controller/ICommonStateGetter.h index c6e6a58c..9636bed6 100644 --- a/app/src/main/cpp/skyline/services/am/controller/ICommonStateGetter.h +++ b/app/src/main/cpp/skyline/services/am/controller/ICommonStateGetter.h @@ -18,34 +18,35 @@ namespace skyline::service::am { class ICommonStateGetter : public BaseService { private: /** - * @brief This enumerates all the possible contents of a #AppletMessage (https://switchbrew.org/wiki/Applet_Manager_services#AppletMessage) + * @brief All the possible contents of a #AppletMessage + * @url https://switchbrew.org/wiki/Applet_Manager_services#AppletMessage */ enum class Message : u32 { - ExitRequested = 0x4, //!< The applet has been requested to exit - FocusStateChange = 0xF, //!< There was a change in the focus state of the applet - ExecutionResumed = 0x10, //!< The execution of the applet has resumed - OperationModeChange = 0x1E, //!< There was a change in the operation mode - PerformanceModeChange = 0x1F, //!< There was a change in the performance mode - RequestToDisplay = 0x33, //!< This indicates that ApproveToDisplay should be used + ExitRequested = 0x4, //!< The applet has been requested to exit + FocusStateChange = 0xF, //!< There was a change in the focus state of the applet + ExecutionResumed = 0x10, //!< The execution of the applet has resumed + OperationModeChange = 0x1E, //!< There was a change in the operation mode + PerformanceModeChange = 0x1F, //!< There was a change in the performance mode + RequestToDisplay = 0x33, //!< Indicates that ApproveToDisplay should be used CaptureButtonShortPressed = 0x5A, //!< The Capture button was short pressed - ScreenshotTaken = 0x5C //!< A screenshot was taken + ScreenshotTaken = 0x5C, //!< A screenshot was taken }; std::shared_ptr messageEvent; //!< The event signalled when there is a message available std::queue messageQueue; //!< A queue of all the messages that the program is yet to consume enum class FocusState : u8 { - InFocus = 1, //!< The application is in foreground - OutOfFocus = 2 //!< The application is in the background + InFocus = 1, //!< The application is in foreground + OutOfFocus = 2, //!< The application is in the background } focusState{FocusState::InFocus}; enum class OperationMode : u8 { Handheld = 0, //!< The device is in handheld mode - Docked = 1 //!< The device is in docked mode + Docked = 1, //!< The device is in docked mode } operationMode; /** - * @brief This queues a message for the application to read via ReceiveMessage + * @brief Queues a message for the application to read via ReceiveMessage * @param message The message to queue */ void QueueMessage(Message message); @@ -54,32 +55,38 @@ namespace skyline::service::am { ICommonStateGetter(const DeviceState &state, ServiceManager &manager); /** - * @brief This returns the handle to a KEvent object that is signalled whenever RecieveMessage has a message (https://switchbrew.org/wiki/Applet_Manager_services#GetEventHandle) + * @brief Returns the handle to a KEvent object that is signalled whenever RecieveMessage has a message + * @url https://switchbrew.org/wiki/Applet_Manager_services#GetEventHandle */ Result GetEventHandle(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This returns an #AppletMessage or 0x680 to indicate the lack of a message (https://switchbrew.org/wiki/Applet_Manager_services#ReceiveMessage) + * @brief Returns an #AppletMessage or 0x680 to indicate the lack of a message + * @url https://switchbrew.org/wiki/Applet_Manager_services#ReceiveMessage */ Result ReceiveMessage(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This returns if an application is in focus or not. It always returns in focus on the emulator (https://switchbrew.org/wiki/Applet_Manager_services#GetCurrentFocusState) + * @brief Returns if an application is in focus or not. It always returns in focus on the emulator + * @url https://switchbrew.org/wiki/Applet_Manager_services#GetCurrentFocusState */ Result GetCurrentFocusState(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This returns the current OperationMode (https://switchbrew.org/wiki/Applet_Manager_services#GetOperationMode) + * @brief Returns the current OperationMode + * @url https://switchbrew.org/wiki/Applet_Manager_services#GetOperationMode */ Result GetOperationMode(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This returns the current PerformanceMode (Same as operationMode but u32) (https://switchbrew.org/wiki/Applet_Manager_services#GetPerformanceMode) + * @brief Returns the current PerformanceMode (Same as operationMode but u32) + * @url https://switchbrew.org/wiki/Applet_Manager_services#GetPerformanceMode */ Result GetPerformanceMode(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This returns the current display width and height in two u32s (https://switchbrew.org/wiki/Applet_Manager_services#GetDefaultDisplayResolution) + * @brief Returns the current display width and height in two u32s + * @url https://switchbrew.org/wiki/Applet_Manager_services#GetDefaultDisplayResolution */ Result GetDefaultDisplayResolution(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); diff --git a/app/src/main/cpp/skyline/services/am/controller/IDebugFunctions.h b/app/src/main/cpp/skyline/services/am/controller/IDebugFunctions.h index 7d4ab831..1f5b6fc8 100644 --- a/app/src/main/cpp/skyline/services/am/controller/IDebugFunctions.h +++ b/app/src/main/cpp/skyline/services/am/controller/IDebugFunctions.h @@ -7,7 +7,8 @@ namespace skyline::service::am { /** - * @brief This has functions that are used for debugging purposes (https://switchbrew.org/wiki/Applet_Manager_services#IDebugFunctions) + * @brief This is used for debugging purposes + * @url https://switchbrew.org/wiki/Applet_Manager_services#IDebugFunctions */ class IDebugFunctions : public BaseService { public: diff --git a/app/src/main/cpp/skyline/services/am/controller/IDisplayController.h b/app/src/main/cpp/skyline/services/am/controller/IDisplayController.h index 99a9f4e9..59d7e406 100644 --- a/app/src/main/cpp/skyline/services/am/controller/IDisplayController.h +++ b/app/src/main/cpp/skyline/services/am/controller/IDisplayController.h @@ -7,7 +7,8 @@ namespace skyline::service::am { /** - * @brief This has functions used to capture the contents of a display (https://switchbrew.org/wiki/Applet_Manager_services#IDisplayController) + * @brief This is used to capture the contents of a display + * @url https://switchbrew.org/wiki/Applet_Manager_services#IDisplayController */ class IDisplayController : public BaseService { public: diff --git a/app/src/main/cpp/skyline/services/am/controller/ILibraryAppletCreator.h b/app/src/main/cpp/skyline/services/am/controller/ILibraryAppletCreator.h index f1a44e2c..75263675 100644 --- a/app/src/main/cpp/skyline/services/am/controller/ILibraryAppletCreator.h +++ b/app/src/main/cpp/skyline/services/am/controller/ILibraryAppletCreator.h @@ -14,12 +14,14 @@ namespace skyline::service::am { ILibraryAppletCreator(const DeviceState &state, ServiceManager &manager); /** - * @brief This function returns a handle to a library applet accessor (https://switchbrew.org/wiki/Applet_Manager_services#CreateLibraryApplet) + * @brief Returns a handle to a library applet accessor + * @url https://switchbrew.org/wiki/Applet_Manager_services#CreateLibraryApplet */ Result CreateLibraryApplet(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This function creates an IStorage that can be used by the application (https://switchbrew.org/wiki/Applet_Manager_services#CreateStorage) + * @brief Creates an IStorage that can be used by the application + * @url https://switchbrew.org/wiki/Applet_Manager_services#CreateStorage */ Result CreateStorage(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); diff --git a/app/src/main/cpp/skyline/services/am/controller/ISelfController.h b/app/src/main/cpp/skyline/services/am/controller/ISelfController.h index 7820b81a..d9f36efe 100644 --- a/app/src/main/cpp/skyline/services/am/controller/ISelfController.h +++ b/app/src/main/cpp/skyline/services/am/controller/ISelfController.h @@ -7,7 +7,8 @@ namespace skyline::service::am { /** - * @brief This has functions relating to an application's own current status (https://switchbrew.org/wiki/Applet_Manager_services#ISelfController) + * @brief This has functions relating to an application's own current status + * @url https://switchbrew.org/wiki/Applet_Manager_services#ISelfController */ class ISelfController : public BaseService { private: @@ -18,52 +19,62 @@ namespace skyline::service::am { ISelfController(const DeviceState &state, ServiceManager &manager); /** - * @brief This function prevents the running application from being quit via the home button (https://switchbrew.org/wiki/Applet_Manager_services#LockExit) + * @brief Function prevents the running application from being quit via the home button + * @url https://switchbrew.org/wiki/Applet_Manager_services#LockExit */ Result LockExit(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This function allows the running application to be quit via the home button (https://switchbrew.org/wiki/Applet_Manager_services#UnlockExit) + * @brief Function allows the running application to be quit via the home button + * @url https://switchbrew.org/wiki/Applet_Manager_services#UnlockExit */ Result UnlockExit(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This function obtains a handle to the library applet launchable event (https://switchbrew.org/wiki/Applet_Manager_services#GetLibraryAppletLaunchableEvent) + * @brief Function obtains a handle to the library applet launchable event + * @url https://switchbrew.org/wiki/Applet_Manager_services#GetLibraryAppletLaunchableEvent */ Result GetLibraryAppletLaunchableEvent(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This function takes a u8 bool flag and no output (Stubbed) (https://switchbrew.org/wiki/Applet_Manager_services#SetOperationModeChangedNotification) + * @brief This function takes a u8 bool flag and no output (Stubbed) + * @url https://switchbrew.org/wiki/Applet_Manager_services#SetOperationModeChangedNotification */ Result SetOperationModeChangedNotification(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This function takes a u8 bool flag and no output (Stubbed) (https://switchbrew.org/wiki/Applet_Manager_services#SetPerformanceModeChangedNotification) + * @brief This function takes a u8 bool flag and no output (Stubbed) + * @url https://switchbrew.org/wiki/Applet_Manager_services#SetPerformanceModeChangedNotification */ Result SetPerformanceModeChangedNotification(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This function takes 3 unknown u8 values and has no output (Stubbed) (https://switchbrew.org/wiki/Applet_Manager_services#GetCurrentFocusState) + * @brief This function takes 3 unknown u8 values and has no output (Stubbed) + * @url https://switchbrew.org/wiki/Applet_Manager_services#GetCurrentFocusState */ Result SetFocusHandlingMode(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This function toggles whether a restart message should be sent (https://switchbrew.org/wiki/Applet_Manager_services#SetRestartMessageEnabled) + * @brief Toggles whether a restart message should be sent or not + * @url https://switchbrew.org/wiki/Applet_Manager_services#SetRestartMessageEnabled */ Result SetRestartMessageEnabled(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This function takes a u8 bool flag and has no output (Stubbed) (https://switchbrew.org/wiki/Applet_Manager_services#SetOutOfFocusSuspendingEnabled) + * @brief This function takes a u8 bool flag and has no output (Stubbed) + * @url https://switchbrew.org/wiki/Applet_Manager_services#SetOutOfFocusSuspendingEnabled */ Result SetOutOfFocusSuspendingEnabled(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This function returns an output u64 LayerId (https://switchbrew.org/wiki/Applet_Manager_services#CreateManagedDisplayLayer) + * @brief Returns an output u64 LayerId + * @url https://switchbrew.org/wiki/Applet_Manager_services#CreateManagedDisplayLayer */ Result CreateManagedDisplayLayer(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This obtains a handle to the system sleep time change KEvent (https://switchbrew.org/wiki/Applet_Manager_services#GetAccumulatedSuspendedTickChangedEvent) + * @brief Returns a handle to the system sleep time change KEvent + * @url https://switchbrew.org/wiki/Applet_Manager_services#GetAccumulatedSuspendedTickChangedEvent */ Result GetAccumulatedSuspendedTickChangedEvent(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); diff --git a/app/src/main/cpp/skyline/services/am/controller/IWindowController.h b/app/src/main/cpp/skyline/services/am/controller/IWindowController.h index 9afdabfc..e31236f5 100644 --- a/app/src/main/cpp/skyline/services/am/controller/IWindowController.h +++ b/app/src/main/cpp/skyline/services/am/controller/IWindowController.h @@ -7,19 +7,22 @@ namespace skyline::service::am { /** - * @brief This has functions used to retrieve the status of the application's window (https://switchbrew.org/wiki/Applet_Manager_services#IWindowController) + * @brief This has functions used to retrieve the status of the application's window + * @url https://switchbrew.org/wiki/Applet_Manager_services#IWindowController */ class IWindowController : public BaseService { public: IWindowController(const DeviceState &state, ServiceManager &manager); /** - * @brief This returns the PID of the current application (https://switchbrew.org/wiki/Applet_Manager_services#GetAppletResourceUserId) + * @brief Returns the PID of the current application + * @url https://switchbrew.org/wiki/Applet_Manager_services#GetAppletResourceUserId */ Result GetAppletResourceUserId(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This function has mo inputs or outputs (Stubbed) (https://switchbrew.org/wiki/Applet_Manager_services#AcquireForegroundRights) + * @brief This function has no inputs or outputs (Stubbed) + * @url https://switchbrew.org/wiki/Applet_Manager_services#AcquireForegroundRights */ Result AcquireForegroundRights(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); diff --git a/app/src/main/cpp/skyline/services/am/proxy/IApplicationProxy.h b/app/src/main/cpp/skyline/services/am/proxy/IApplicationProxy.h index e7602fe4..47b713f3 100644 --- a/app/src/main/cpp/skyline/services/am/proxy/IApplicationProxy.h +++ b/app/src/main/cpp/skyline/services/am/proxy/IApplicationProxy.h @@ -7,14 +7,16 @@ namespace skyline::service::am { /** - * @brief IApplicationProxy returns handles to various services (https://switchbrew.org/wiki/Applet_Manager_services#IApplicationProxy) + * @brief IApplicationProxy returns handles to various services + * @url https://switchbrew.org/wiki/Applet_Manager_services#IApplicationProxy */ class IApplicationProxy : public BaseProxy { public: IApplicationProxy(const DeviceState &state, ServiceManager &manager); /** - * @brief This returns #IApplicationFunctions (https://switchbrew.org/wiki/Applet_Manager_services#IApplicationFunctions) + * @brief Returns #IApplicationFunctions + * @url https://switchbrew.org/wiki/Applet_Manager_services#IApplicationFunctions */ Result GetApplicationFunctions(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); diff --git a/app/src/main/cpp/skyline/services/am/proxy/ILibraryAppletProxy.h b/app/src/main/cpp/skyline/services/am/proxy/ILibraryAppletProxy.h index 8c0f3e1a..fba5dfe6 100644 --- a/app/src/main/cpp/skyline/services/am/proxy/ILibraryAppletProxy.h +++ b/app/src/main/cpp/skyline/services/am/proxy/ILibraryAppletProxy.h @@ -7,7 +7,8 @@ namespace skyline::service::am { /** - * @brief ILibraryAppletProxy returns handles to various services (https://switchbrew.org/wiki/Applet_Manager_services#ILibraryAppletProxy) + * @brief ILibraryAppletProxy returns handles to various services + * @url https://switchbrew.org/wiki/Applet_Manager_services#ILibraryAppletProxy */ class ILibraryAppletProxy : public BaseProxy { public: diff --git a/app/src/main/cpp/skyline/services/am/proxy/IOverlayAppletProxy.h b/app/src/main/cpp/skyline/services/am/proxy/IOverlayAppletProxy.h index ec10a43b..aac3ee7a 100644 --- a/app/src/main/cpp/skyline/services/am/proxy/IOverlayAppletProxy.h +++ b/app/src/main/cpp/skyline/services/am/proxy/IOverlayAppletProxy.h @@ -7,7 +7,8 @@ namespace skyline::service::am { /** - * @brief IOverlayAppletProxy returns handles to various services (https://switchbrew.org/wiki/Applet_Manager_services#IOverlayAppletProxy) + * @brief IOverlayAppletProxy returns handles to various services + * @url https://switchbrew.org/wiki/Applet_Manager_services#IOverlayAppletProxy */ class IOverlayAppletProxy : public BaseProxy { public: diff --git a/app/src/main/cpp/skyline/services/am/proxy/ISystemAppletProxy.h b/app/src/main/cpp/skyline/services/am/proxy/ISystemAppletProxy.h index 0be48e79..0d71bb5c 100644 --- a/app/src/main/cpp/skyline/services/am/proxy/ISystemAppletProxy.h +++ b/app/src/main/cpp/skyline/services/am/proxy/ISystemAppletProxy.h @@ -7,7 +7,8 @@ namespace skyline::service::am { /** - * @brief ISystemAppletProxy returns handles to various services (https://switchbrew.org/wiki/Applet_Manager_services#ISystemAppletProxy) + * @brief ISystemAppletProxy returns handles to various services + * @url https://switchbrew.org/wiki/Applet_Manager_services#ISystemAppletProxy */ class ISystemAppletProxy : public BaseProxy { public: diff --git a/app/src/main/cpp/skyline/services/am/proxy/base_proxy.h b/app/src/main/cpp/skyline/services/am/proxy/base_proxy.h index 2e7956e0..2fa4a36e 100644 --- a/app/src/main/cpp/skyline/services/am/proxy/base_proxy.h +++ b/app/src/main/cpp/skyline/services/am/proxy/base_proxy.h @@ -14,42 +14,50 @@ namespace skyline::service::am { BaseProxy(const DeviceState &state, ServiceManager &manager); /** - * @brief This returns #ICommonStateGetter (https://switchbrew.org/wiki/Applet_Manager_services#ICommonStateGetter) + * @brief Returns #ICommonStateGetter + * @url https://switchbrew.org/wiki/Applet_Manager_services#ICommonStateGetter */ Result GetCommonStateGetter(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This returns #ISelfController (https://switchbrew.org/wiki/Applet_Manager_services#ISelfController) + * @brief Returns #ISelfController + * @url https://switchbrew.org/wiki/Applet_Manager_services#ISelfController */ Result GetSelfController(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This returns #IWindowController (https://switchbrew.org/wiki/Applet_Manager_services#IWindowController) + * @brief Returns #IWindowController + * @url https://switchbrew.org/wiki/Applet_Manager_services#IWindowController */ Result GetWindowController(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This returns #IAudioController (https://switchbrew.org/wiki/Applet_Manager_services#IAudioController) + * @brief Returns #IAudioController + * @url https://switchbrew.org/wiki/Applet_Manager_services#IAudioController */ Result GetAudioController(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This returns #IDisplayController (https://switchbrew.org/wiki/Applet_Manager_services#IDisplayController) + * @brief Returns #IDisplayController + * @url https://switchbrew.org/wiki/Applet_Manager_services#IDisplayController */ Result GetDisplayController(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This returns #ILibraryAppletCreator (https://switchbrew.org/wiki/Applet_Manager_services#ILibraryAppletCreator) + * @brief Returns #ILibraryAppletCreator + * @url https://switchbrew.org/wiki/Applet_Manager_services#ILibraryAppletCreator */ Result GetLibraryAppletCreator(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This returns #IDebugFunctions (https://switchbrew.org/wiki/Applet_Manager_services#IDebugFunctions) + * @brief Returns #IDebugFunctions + * @url https://switchbrew.org/wiki/Applet_Manager_services#IDebugFunctions */ Result GetDebugFunctions(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This returns #IAppletCommonFunctions (https://switchbrew.org/wiki/Applet_Manager_services#IAppletCommonFunctions) + * @brief Returns #IAppletCommonFunctions + * @url https://switchbrew.org/wiki/Applet_Manager_services#IAppletCommonFunctions */ Result GetAppletCommonFunctions(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); }; diff --git a/app/src/main/cpp/skyline/services/am/storage/IStorage.h b/app/src/main/cpp/skyline/services/am/storage/IStorage.h index 4fff6018..e815e2a5 100644 --- a/app/src/main/cpp/skyline/services/am/storage/IStorage.h +++ b/app/src/main/cpp/skyline/services/am/storage/IStorage.h @@ -7,7 +7,8 @@ namespace skyline::service::am { /** - * @brief IStorage is used to open an IStorageAccessor to access a region of memory (https://switchbrew.org/wiki/Applet_Manager_services#IStorage) + * @brief IStorage is used to open an IStorageAccessor to access a region of memory + * @url https://switchbrew.org/wiki/Applet_Manager_services#IStorage */ class IStorage : public BaseService, public std::enable_shared_from_this { private: @@ -19,14 +20,12 @@ namespace skyline::service::am { IStorage(const DeviceState &state, ServiceManager &manager, size_t size); /** - * @brief This returns an IStorageAccessor that can read and write data to an IStorage + * @brief Returns an IStorageAccessor that can read and write data to an IStorage */ Result Open(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This function writes an object to the storage - * @tparam ValueType The type of the object to write - * @param value A reference to the object to be written + * @brief Writes an object to the storage */ template inline void Push(const ValueType &value) { diff --git a/app/src/main/cpp/skyline/services/am/storage/IStorageAccessor.h b/app/src/main/cpp/skyline/services/am/storage/IStorageAccessor.h index 5cf6b27e..d4a26820 100644 --- a/app/src/main/cpp/skyline/services/am/storage/IStorageAccessor.h +++ b/app/src/main/cpp/skyline/services/am/storage/IStorageAccessor.h @@ -13,7 +13,8 @@ namespace skyline::service::am { class IStorage; /** - * @brief IStorageAccessor is used read and write to an IStorage (https://switchbrew.org/wiki/Applet_Manager_services#IStorageAccessor) + * @brief IStorageAccessor is used read and write to an IStorage + * @url https://switchbrew.org/wiki/Applet_Manager_services#IStorageAccessor */ class IStorageAccessor : public BaseService { private: @@ -23,17 +24,17 @@ namespace skyline::service::am { IStorageAccessor(const DeviceState &state, ServiceManager &manager, std::shared_ptr parent); /** - * @brief This returns the size of the storage in bytes + * @brief Returns the size of the storage in bytes */ Result GetSize(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This writes a buffer to the storage at the specified offset + * @brief Writes a buffer to the storage at the specified offset */ Result Write(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This returns a buffer containing the contents of the storage at the specified offset + * @brief Returns a buffer containing the contents of the storage at the specified offset */ Result Read(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); diff --git a/app/src/main/cpp/skyline/services/aocsrv/IAddOnContentManager.h b/app/src/main/cpp/skyline/services/aocsrv/IAddOnContentManager.h index 87d239ee..1ba9eb8e 100644 --- a/app/src/main/cpp/skyline/services/aocsrv/IAddOnContentManager.h +++ b/app/src/main/cpp/skyline/services/aocsrv/IAddOnContentManager.h @@ -7,7 +7,8 @@ namespace skyline::service::aocsrv { /** - * @brief IAddOnContentManager or aoc:u is used by applications to access add-on content information (https://switchbrew.org/wiki/NS_Services#aoc:u) + * @brief IAddOnContentManager or aoc:u is used by applications to access add-on content information + * @url https://switchbrew.org/wiki/NS_Services#aoc:u */ class IAddOnContentManager : public BaseService { public: diff --git a/app/src/main/cpp/skyline/services/apm/IManager.h b/app/src/main/cpp/skyline/services/apm/IManager.h index b2cee803..e7186cd0 100644 --- a/app/src/main/cpp/skyline/services/apm/IManager.h +++ b/app/src/main/cpp/skyline/services/apm/IManager.h @@ -7,14 +7,15 @@ namespace skyline::service::apm { /** - * @brief IManager is mostly only used to open an ISession (https://switchbrew.org/wiki/PPC_services#apm) + * @brief IManager is mostly only used to open an ISession + * @url https://switchbrew.org/wiki/PPC_services#apm */ class IManager : public BaseService { public: IManager(const DeviceState &state, ServiceManager &manager); /** - * @brief This returns an handle to ISession + * @brief Returns an handle to ISession */ Result OpenSession(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); diff --git a/app/src/main/cpp/skyline/services/apm/ISession.h b/app/src/main/cpp/skyline/services/apm/ISession.h index bc19b9a0..3e467874 100644 --- a/app/src/main/cpp/skyline/services/apm/ISession.h +++ b/app/src/main/cpp/skyline/services/apm/ISession.h @@ -11,18 +11,20 @@ namespace skyline::service::apm { */ class ISession : public BaseService { private: - std::array performanceConfig = {0x00010000, 0x00020001}; //!< This holds the performance config for both handheld(0) and docked(1) mode + std::array performanceConfig{0x00010000, 0x00020001}; //!< The performance config for both handheld(0) and docked(1) mode public: ISession(const DeviceState &state, ServiceManager &manager); /** - * @brief This sets performanceConfig to the given arguments, it doesn't affect anything else (https://switchbrew.org/wiki/PPC_services#SetPerformanceConfiguration) + * @brief Sets PerformanceConfig to the given arguments, it doesn't affect anything else + * @url https://switchbrew.org/wiki/PPC_services#SetPerformanceConfiguration */ Result SetPerformanceConfiguration(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This retrieves the particular performanceConfig for a mode and returns it to the client (https://switchbrew.org/wiki/PPC_services#SetPerformanceConfiguration) + * @brief Retrieves the particular PerformanceConfig for a mode and returns it to the client + * @url https://switchbrew.org/wiki/PPC_services#SetPerformanceConfiguration */ Result GetPerformanceConfiguration(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); diff --git a/app/src/main/cpp/skyline/services/audio/IAudioDevice.h b/app/src/main/cpp/skyline/services/audio/IAudioDevice.h index 65174156..27a4f4f8 100644 --- a/app/src/main/cpp/skyline/services/audio/IAudioDevice.h +++ b/app/src/main/cpp/skyline/services/audio/IAudioDevice.h @@ -7,7 +7,8 @@ namespace skyline::service::audio { /** - * @brief IAudioDevice is used by applications to query audio device info (https://switchbrew.org/wiki/Audio_services#IAudioDevice) + * @brief IAudioDevice is used by applications to query audio device info + * @url https://switchbrew.org/wiki/Audio_services#IAudioDevice */ class IAudioDevice : public BaseService { private: @@ -17,27 +18,29 @@ namespace skyline::service::audio { IAudioDevice(const DeviceState &state, ServiceManager &manager); /** - * @brief This returns a list of the available audio devices (https://switchbrew.org/wiki/Audio_services#ListAudioDeviceName) + * @brief Returns a list of the available audio devices + * @url https://switchbrew.org/wiki/Audio_services#ListAudioDeviceName */ Result ListAudioDeviceName(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This sets the volume of an audio output (https://switchbrew.org/wiki/Audio_services#SetAudioDeviceOutputVolume) + * @brief Sets the volume of an audio output + * @url https://switchbrew.org/wiki/Audio_services#SetAudioDeviceOutputVolume */ Result SetAudioDeviceOutputVolume(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This returns the active audio output device + * @brief Returns the active audio output device */ Result GetActiveAudioDeviceName(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This returns the audio device system event + * @brief Returns the audio device system event */ Result QueryAudioDeviceSystemEvent(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This returns the current output devices channel count + * @brief Returns the current output devices channel count */ Result GetActiveChannelCount(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); diff --git a/app/src/main/cpp/skyline/services/audio/IAudioOut.h b/app/src/main/cpp/skyline/services/audio/IAudioOut.h index ea196d99..9bb01a6e 100644 --- a/app/src/main/cpp/skyline/services/audio/IAudioOut.h +++ b/app/src/main/cpp/skyline/services/audio/IAudioOut.h @@ -9,7 +9,8 @@ namespace skyline::service::audio { /** - * @brief IAudioOut is a service opened when OpenAudioOut is called by IAudioOutManager (https://switchbrew.org/wiki/Audio_services#IAudioOut) + * @brief IAudioOut is a service opened when OpenAudioOut is called by IAudioOutManager + * @url https://switchbrew.org/wiki/Audio_services#IAudioOut */ class IAudioOut : public BaseService { private: @@ -33,37 +34,44 @@ namespace skyline::service::audio { ~IAudioOut(); /** - * @brief Returns the playback state of the audio output (https://switchbrew.org/wiki/Audio_services#GetAudioOutState) + * @brief Returns the playback state of the audio output + * @url https://switchbrew.org/wiki/Audio_services#GetAudioOutState */ Result GetAudioOutState(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief Starts playback using data from appended samples (https://switchbrew.org/wiki/Audio_services#StartAudioOut) + * @brief Starts playback using data from appended samples + * @url https://switchbrew.org/wiki/Audio_services#StartAudioOut */ Result StartAudioOut(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief Stops playback of audio, waits for all samples to be released (https://switchbrew.org/wiki/Audio_services#StartAudioOut) + * @brief Stops playback of audio, waits for all samples to be released + * @url https://switchbrew.org/wiki/Audio_services#StartAudioOut */ Result StopAudioOut(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief Appends sample data to the output buffer (https://switchbrew.org/wiki/Audio_services#AppendAudioOutBuffer) + * @brief Appends sample data to the output buffer + * @url https://switchbrew.org/wiki/Audio_services#AppendAudioOutBuffer */ Result AppendAudioOutBuffer(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief Returns a handle to the sample release KEvent (https://switchbrew.org/wiki/Audio_services#AppendAudioOutBuffer) + * @brief Returns a handle to the sample release KEvent + * @url https://switchbrew.org/wiki/Audio_services#AppendAudioOutBuffer */ Result RegisterBufferEvent(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief Returns the IDs of all pending released buffers (https://switchbrew.org/wiki/Audio_services#GetReleasedAudioOutBuffer) + * @brief Returns the IDs of all pending released buffers + * @url https://switchbrew.org/wiki/Audio_services#GetReleasedAudioOutBuffer */ Result GetReleasedAudioOutBuffer(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief Checks if the given buffer ID is in the playback queue (https://switchbrew.org/wiki/Audio_services#ContainsAudioOutBuffer) + * @brief Checks if the given buffer ID is in the playback queue + * @url https://switchbrew.org/wiki/Audio_services#ContainsAudioOutBuffer */ Result ContainsAudioOutBuffer(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); diff --git a/app/src/main/cpp/skyline/services/audio/IAudioOutManager.h b/app/src/main/cpp/skyline/services/audio/IAudioOutManager.h index c82e211f..80438533 100644 --- a/app/src/main/cpp/skyline/services/audio/IAudioOutManager.h +++ b/app/src/main/cpp/skyline/services/audio/IAudioOutManager.h @@ -13,19 +13,22 @@ namespace skyline { namespace service::audio { /** - * @brief IAudioOutManager or audout:u is used to manage audio outputs (https://switchbrew.org/wiki/Audio_services#audout:u) + * @brief IAudioOutManager or audout:u is used to manage audio outputs + * @url https://switchbrew.org/wiki/Audio_services#audout:u */ class IAudioOutManager : public BaseService { public: IAudioOutManager(const DeviceState &state, ServiceManager &manager); /** - * @brief Returns a list of all available audio outputs (https://switchbrew.org/wiki/Audio_services#ListAudioOuts) + * @brief Returns a list of all available audio outputs + * @url https://switchbrew.org/wiki/Audio_services#ListAudioOuts */ Result ListAudioOuts(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief Creates a new audoutU::IAudioOut object and returns a handle to it (https://switchbrew.org/wiki/Audio_services#OpenAudioOut) + * @brief Creates a new audoutU::IAudioOut object and returns a handle to it + * @url https://switchbrew.org/wiki/Audio_services#OpenAudioOut */ Result OpenAudioOut(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); diff --git a/app/src/main/cpp/skyline/services/audio/IAudioRenderer/IAudioRenderer.h b/app/src/main/cpp/skyline/services/audio/IAudioRenderer/IAudioRenderer.h index 87e75cce..f9f2d539 100644 --- a/app/src/main/cpp/skyline/services/audio/IAudioRenderer/IAudioRenderer.h +++ b/app/src/main/cpp/skyline/services/audio/IAudioRenderer/IAudioRenderer.h @@ -57,7 +57,8 @@ namespace skyline { static_assert(sizeof(UpdateDataHeader) == 0x40); /** - * @brief IAudioRenderer is used to control an audio renderer output (https://switchbrew.org/wiki/Audio_services#IAudioRenderer) + * @brief IAudioRenderer is used to control an audio renderer output + * @url https://switchbrew.org/wiki/Audio_services#IAudioRenderer */ class IAudioRenderer : public BaseService { private: @@ -94,43 +95,47 @@ namespace skyline { ~IAudioRenderer(); /** - * @brief Returns the sample rate (https://switchbrew.org/wiki/Audio_services#GetSampleRate) + * @brief Returns the sample rate + * @url https://switchbrew.org/wiki/Audio_services#GetSampleRate */ Result GetSampleRate(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief Returns the sample count (https://switchbrew.org/wiki/Audio_services#GetSampleCount) + * @brief Returns the sample count + * @url https://switchbrew.org/wiki/Audio_services#GetSampleCount */ Result GetSampleCount(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief Returns the number of mix buffers (https://switchbrew.org/wiki/Audio_services#GetMixBufferCount) + * @brief Returns the number of mix buffers + * @url https://switchbrew.org/wiki/Audio_services#GetMixBufferCount */ Result GetMixBufferCount(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief Returns the state of the renderer (https://switchbrew.org/wiki/Audio_services#GetAudioRendererState) (stubbed)? + * @brief Returns the state of the renderer + * @url https://switchbrew.org/wiki/Audio_services#GetAudioRendererState (stubbed)? */ Result GetState(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief Updates the audio renderer state and appends new data to playback buffers - */ + * @brief Updates the audio renderer state and appends new data to playback buffers + */ Result RequestUpdate(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief Start the audio stream from the renderer - */ + * @brief Start the audio stream from the renderer + */ Result Start(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief Stop the audio stream from the renderer - */ + * @brief Stop the audio stream from the renderer + */ Result Stop(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief Returns a handle to the sample release KEvent - */ + * @brief Returns a handle to the sample release KEvent + */ Result QuerySystemEvent(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); SERVICE_DECL( diff --git a/app/src/main/cpp/skyline/services/audio/IAudioRenderer/effect.h b/app/src/main/cpp/skyline/services/audio/IAudioRenderer/effect.h index 9f9dfccd..190ae1b3 100644 --- a/app/src/main/cpp/skyline/services/audio/IAudioRenderer/effect.h +++ b/app/src/main/cpp/skyline/services/audio/IAudioRenderer/effect.h @@ -6,16 +6,13 @@ #include namespace skyline::service::audio::IAudioRenderer { - /** - * @brief This enumerates various states an effect can be in - */ enum class EffectState : u8 { None = 0, //!< The effect isn't being used New = 1, }; /** - * @brief This is in input containing information on what effects to use on an audio stream + * @brief Input containing information on what effects to use on an audio stream */ struct EffectIn { u8 _unk0_; @@ -25,7 +22,7 @@ namespace skyline::service::audio::IAudioRenderer { static_assert(sizeof(EffectIn) == 0xC0); /** - * @brief This is returned to inform the guest of the state of an effect + * @brief Returned to inform the guest of the state of an effect */ struct EffectOut { EffectState state; @@ -34,8 +31,8 @@ namespace skyline::service::audio::IAudioRenderer { static_assert(sizeof(EffectOut) == 0x10); /** - * @brief The Effect class stores the state of audio post processing effects - */ + * @brief The Effect class stores the state of audio post processing effects + */ class Effect { public: EffectOut output{}; diff --git a/app/src/main/cpp/skyline/services/audio/IAudioRenderer/memory_pool.h b/app/src/main/cpp/skyline/services/audio/IAudioRenderer/memory_pool.h index c4522078..77a632c5 100644 --- a/app/src/main/cpp/skyline/services/audio/IAudioRenderer/memory_pool.h +++ b/app/src/main/cpp/skyline/services/audio/IAudioRenderer/memory_pool.h @@ -6,9 +6,6 @@ #include namespace skyline::service::audio::IAudioRenderer { - /** - * @brief This enumerates various states a memory pool can be in - */ enum class MemoryPoolState : u32 { Invalid = 0, Unknown = 1, @@ -19,9 +16,6 @@ namespace skyline::service::audio::IAudioRenderer { Released = 6, }; - /** - * @brief This is in input containing information about a memory pool for use by the dsp - */ struct MemoryPoolIn { u64 address; u64 size; @@ -31,9 +25,6 @@ namespace skyline::service::audio::IAudioRenderer { }; static_assert(sizeof(MemoryPoolIn) == 0x20); - /** - * @brief This is returned to inform the guest of the state of a memory pool - */ struct MemoryPoolOut { MemoryPoolState state{MemoryPoolState::Detached}; u32 _unk0_; @@ -42,8 +33,8 @@ namespace skyline::service::audio::IAudioRenderer { static_assert(sizeof(MemoryPoolOut) == 0x10); /** - * @brief The MemoryPool class stores the state of a memory pool - */ + * @brief The MemoryPool class stores the state of a memory pool + */ class MemoryPool { public: MemoryPoolOut output{}; diff --git a/app/src/main/cpp/skyline/services/audio/IAudioRenderer/revision_info.h b/app/src/main/cpp/skyline/services/audio/IAudioRenderer/revision_info.h index 130de0ff..772ce979 100644 --- a/app/src/main/cpp/skyline/services/audio/IAudioRenderer/revision_info.h +++ b/app/src/main/cpp/skyline/services/audio/IAudioRenderer/revision_info.h @@ -31,8 +31,8 @@ namespace skyline { } /** - * @brief The RevisionInfo class is used to query the supported features of various audren revisions - */ + * @brief The RevisionInfo class is used to query the supported features of various audren revisions + */ class RevisionInfo { private: u32 userRevision; //!< The current audren revision of the guest diff --git a/app/src/main/cpp/skyline/services/audio/IAudioRenderer/voice.h b/app/src/main/cpp/skyline/services/audio/IAudioRenderer/voice.h index 8856e27a..97857687 100644 --- a/app/src/main/cpp/skyline/services/audio/IAudioRenderer/voice.h +++ b/app/src/main/cpp/skyline/services/audio/IAudioRenderer/voice.h @@ -8,9 +8,6 @@ #include namespace skyline::service::audio::IAudioRenderer { - /** - * @brief This stores data for configuring a biquadratic filter - */ struct BiquadFilter { u8 enable; u8 _pad0_; @@ -22,9 +19,6 @@ namespace skyline::service::audio::IAudioRenderer { }; static_assert(sizeof(BiquadFilter) == 0xC); - /** - * @brief This stores information of a wave buffer of samples - */ struct WaveBuffer { u64 address; u64 size; @@ -40,9 +34,6 @@ namespace skyline::service::audio::IAudioRenderer { }; static_assert(sizeof(WaveBuffer) == 0x38); - /** - * @brief This is in input containing the configuration of a voice - */ struct VoiceIn { u32 slot; u32 nodeId; @@ -71,9 +62,6 @@ namespace skyline::service::audio::IAudioRenderer { static_assert(sizeof(VoiceIn) == 0x170); - /** - * @brief This is returned to inform the guest of the state of a voice - */ struct VoiceOut { u64 playedSamplesCount; u32 playedWaveBuffersCount; @@ -82,8 +70,8 @@ namespace skyline::service::audio::IAudioRenderer { static_assert(sizeof(VoiceOut) == 0x10); /** - * @brief The Voice class manages an audio voice - */ + * @brief The Voice class manages an audio voice + */ class Voice { private: const DeviceState &state; @@ -102,7 +90,7 @@ namespace skyline::service::audio::IAudioRenderer { skyline::audio::AudioFormat format{skyline::audio::AudioFormat::Invalid}; /** - * @brief This updates the sample buffer with data from the current wave buffer and processes it + * @brief Updates the sample buffer with data from the current wave buffer and processes it */ void UpdateBuffers(); @@ -119,13 +107,13 @@ namespace skyline::service::audio::IAudioRenderer { Voice(const DeviceState &state); /** - * @brief This reads the input voice data from the guest and sets internal data based off it + * @brief Reads the input voice data from the guest and sets internal data based off it * @param input The input data struct from guest */ void ProcessInput(const VoiceIn &input); /** - * @brief This obtains the voices audio sample data, updating it if required + * @brief Obtains the voices audio sample data, updating it if required * @param maxSamples The maximum amount of samples the output buffer should contain * @return A vector of I16 PCM sample data */ diff --git a/app/src/main/cpp/skyline/services/audio/IAudioRendererManager.h b/app/src/main/cpp/skyline/services/audio/IAudioRendererManager.h index 51f70a02..0423cd12 100644 --- a/app/src/main/cpp/skyline/services/audio/IAudioRendererManager.h +++ b/app/src/main/cpp/skyline/services/audio/IAudioRendererManager.h @@ -7,7 +7,8 @@ namespace skyline::service::audio { /** - * @brief IAudioRendererManager or audren:u is used to manage audio renderer outputs (https://switchbrew.org/wiki/Audio_services#audren:u) + * @brief IAudioRendererManager or audren:u is used to manage audio renderer outputs + * @url https://switchbrew.org/wiki/Audio_services#audren:u */ class IAudioRendererManager : public BaseService { public: @@ -24,7 +25,8 @@ namespace skyline::service::audio { Result GetAudioRendererWorkBufferSize(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This returns a handle to an instance of an IAudioDevice (https://switchbrew.org/wiki/Audio_services#GetAudioDeviceService) + * @brief Returns a handle to an instance of an IAudioDevice + * @url https://switchbrew.org/wiki/Audio_services#GetAudioDeviceService */ Result GetAudioDeviceService(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); diff --git a/app/src/main/cpp/skyline/services/base_service.h b/app/src/main/cpp/skyline/services/base_service.h index bbed80c8..a0f13b4f 100644 --- a/app/src/main/cpp/skyline/services/base_service.h +++ b/app/src/main/cpp/skyline/services/base_service.h @@ -22,20 +22,20 @@ namespace skyline::kernel::type { namespace skyline::service { using namespace kernel; - using ServiceName = u64; //!< Service names are a maximum of 8 bytes so we use a u64 to reference them + using ServiceName = u64; //!< Service names are a maximum of 8 bytes so we use a u64 to store them class ServiceManager; /** - * @brief The base class for all service interfaces hosted by sysmodules + * @brief The base class for the HOS service interfaces hosted by sysmodules */ class BaseService { private: - std::string name; //!< The name of the service + std::string name; //!< The name of the service, it is only assigned after GetName is called and shouldn't be used directly protected: - const DeviceState &state; //!< The state of the device - ServiceManager &manager; //!< A reference to the service manager + const DeviceState &state; + ServiceManager &manager; template static constexpr Result CallBaseFunction(Class* clazz, type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { @@ -43,10 +43,6 @@ namespace skyline::service { } public: - /** - * @param state The state of the device - * @param vTable The functions of the service - */ BaseService(const DeviceState &state, ServiceManager &manager) : state(state), manager(manager) {} /** @@ -65,9 +61,7 @@ namespace skyline::service { const std::string &GetName(); /** - * @brief This handles all IPC commands with type request to a service - * @param request The corresponding IpcRequest object - * @param response The corresponding IpcResponse object + * @brief Handles an IPC Request to a service */ Result HandleRequest(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response);; }; diff --git a/app/src/main/cpp/skyline/services/common/fence.h b/app/src/main/cpp/skyline/services/common/fence.h index 7ca7f71a..28aab664 100644 --- a/app/src/main/cpp/skyline/services/common/fence.h +++ b/app/src/main/cpp/skyline/services/common/fence.h @@ -7,11 +7,11 @@ namespace skyline::service::nvdrv { /** - * @brief This holds information about a fence + * @brief A Fence is a synchronization primitive that describes a point in a Syncpoint to synchronize at */ struct Fence { - u32 id{}; - u32 value{}; + u32 id{}; //!< The ID of the underlying syncpoint + u32 value{}; //!< The value of the syncpoint at which the fence is passed /** * @brief Synchronizes the fence's value with its underlying syncpoint diff --git a/app/src/main/cpp/skyline/services/common/parcel.h b/app/src/main/cpp/skyline/services/common/parcel.h index 5b2fdbb5..b0ac06a7 100644 --- a/app/src/main/cpp/skyline/services/common/parcel.h +++ b/app/src/main/cpp/skyline/services/common/parcel.h @@ -7,13 +7,11 @@ namespace skyline::service { /** - * @brief This class encapsulates a Parcel object (https://switchbrew.org/wiki/Display_services#Parcel) + * @brief This allows easy access and efficient serialization of an Android Parcel object + * @url https://switchbrew.org/wiki/Display_services#Parcel */ class Parcel { private: - /** - * @brief The header of an Android Parcel structure - */ struct ParcelHeader { u32 dataSize; u32 dataOffset; @@ -22,24 +20,22 @@ namespace skyline::service { } header{}; static_assert(sizeof(ParcelHeader) == 0x10); - const DeviceState &state; //!< The state of the device + const DeviceState &state; public: - std::vector data; //!< A vector filled with data in the parcel - std::vector objects; //!< A vector filled with objects in the parcel - size_t dataOffset{}; //!< This is the offset of the data read from the parcel + std::vector data; + std::vector objects; + size_t dataOffset{}; //!< The offset of the data read from the parcel /** * @brief This constructor fills in the Parcel object with data from a IPC buffer * @param buffer The buffer that contains the parcel - * @param state The state of the device * @param hasToken If the parcel starts with a token, it is skipped if this flag is true */ Parcel(span buffer, const DeviceState &state, bool hasToken = false); /** * @brief This constructor is used to create an empty parcel then write to a process - * @param state The state of the device */ Parcel(const DeviceState &state); @@ -54,9 +50,7 @@ namespace skyline::service { } /** - * @brief Writes some data to the Parcel - * @tparam ValueType The type of the object to write - * @param value The object to be written + * @brief Writes a value to the Parcel */ template void Push(const ValueType &value) { @@ -70,15 +64,13 @@ namespace skyline::service { /** * @brief Writes an object to the Parcel - * @tparam ValueType The type of the object to write - * @param value The object to be written */ - template - void PushObject(const ValueType &value) { - objects.reserve(objects.size() + sizeof(ValueType)); - auto item{reinterpret_cast(&value)}; - for (size_t index{}; sizeof(ValueType) > index; index++) { - objects.push_back(*item); + template + void PushObject(const ObjectType &object) { + objects.reserve(objects.size() + sizeof(ObjectType)); + auto item{reinterpret_cast(&object)}; + for (size_t index{}; sizeof(ObjectType) > index; index++) { + objects.push_back(*object); item++; } } diff --git a/app/src/main/cpp/skyline/services/fatalsrv/IService.h b/app/src/main/cpp/skyline/services/fatalsrv/IService.h index 84753807..58b025e1 100644 --- a/app/src/main/cpp/skyline/services/fatalsrv/IService.h +++ b/app/src/main/cpp/skyline/services/fatalsrv/IService.h @@ -7,14 +7,15 @@ namespace skyline::service::fatalsrv { /** - * @brief IService or fatal:u is used by applications to throw errors (https://switchbrew.org/wiki/Fatal_services#fatal:u) + * @brief IService or fatal:u is used by applications to throw errors + * @url https://switchbrew.org/wiki/Fatal_services#fatal:u */ class IService : public BaseService { public: IService(const DeviceState &state, ServiceManager &manager); /** - * @brief This throws an exception that causes emulation to quit + * @brief Throws an exception that causes emulation to quit */ Result ThrowFatal(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); diff --git a/app/src/main/cpp/skyline/services/friends/IFriendService.h b/app/src/main/cpp/skyline/services/friends/IFriendService.h index babb0ea9..273e22f7 100644 --- a/app/src/main/cpp/skyline/services/friends/IFriendService.h +++ b/app/src/main/cpp/skyline/services/friends/IFriendService.h @@ -7,7 +7,8 @@ namespace skyline::service::friends { /** - * @brief IFriendService is used by applications to access information about a user's friends (https://switchbrew.org/wiki/Friend_services#IFriendService) + * @brief IFriendService is used by applications to access information about a user's friends + * @url https://switchbrew.org/wiki/Friend_services#IFriendService */ class IFriendService : public BaseService { public: diff --git a/app/src/main/cpp/skyline/services/friends/INotificationService.h b/app/src/main/cpp/skyline/services/friends/INotificationService.h index 79c31e20..2759feab 100644 --- a/app/src/main/cpp/skyline/services/friends/INotificationService.h +++ b/app/src/main/cpp/skyline/services/friends/INotificationService.h @@ -8,7 +8,8 @@ namespace skyline::service::friends { /** - * @brief INotificationService is used by applications to receive notifications (https://switchbrew.org/wiki/Friend_services#INotificationService) + * @brief INotificationService is used by applications to receive notifications + * @url https://switchbrew.org/wiki/Friend_services#INotificationService */ class INotificationService : public BaseService { private: @@ -18,7 +19,7 @@ namespace skyline::service::friends { INotificationService(const DeviceState &state, ServiceManager &manager); /** - * @brief This returns a handle to the notification event + * @brief Returns a handle to the notification event */ Result GetEvent(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); diff --git a/app/src/main/cpp/skyline/services/friends/IServiceCreator.h b/app/src/main/cpp/skyline/services/friends/IServiceCreator.h index 5053c6ce..013d999f 100644 --- a/app/src/main/cpp/skyline/services/friends/IServiceCreator.h +++ b/app/src/main/cpp/skyline/services/friends/IServiceCreator.h @@ -7,19 +7,20 @@ namespace skyline::service::friends { /** - * @brief IServiceCreator or friend:u is used by applications to open an IFriendService instance for accessing user friend info (https://switchbrew.org/wiki/Friend_services#friend:u.2C_friend:v.2C_friend:m.2C_friend:s.2C_friend:a) + * @brief IServiceCreator or friend:u is used by applications to open an IFriendService instance for accessing user friend info + * @url https://switchbrew.org/wiki/Friend_services#friend:u.2C_friend:v.2C_friend:m.2C_friend:s.2C_friend:a */ class IServiceCreator : public BaseService { public: IServiceCreator(const DeviceState &state, ServiceManager &manager); /** - * @brief This opens an IFriendService that can be used by applications to access user friend info + * @brief Opens an IFriendService that can be used by applications to access user friend info */ Result CreateFriendService(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This opens an INotificationService that can be used by applications to receive notifications + * @brief Opens an INotificationService that can be used by applications to receive notifications */ Result CreateNotificationService(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); diff --git a/app/src/main/cpp/skyline/services/fssrv/IFile.h b/app/src/main/cpp/skyline/services/fssrv/IFile.h index 6ca03271..5742fc42 100644 --- a/app/src/main/cpp/skyline/services/fssrv/IFile.h +++ b/app/src/main/cpp/skyline/services/fssrv/IFile.h @@ -8,37 +8,38 @@ namespace skyline::service::fssrv { /** - * @brief IFile is an interface for accessing files (https://switchbrew.org/wiki/Filesystem_services#IFile) + * @brief IFile is an interface for accessing files + * @url https://switchbrew.org/wiki/Filesystem_services#IFile */ class IFile : public BaseService { private: - std::shared_ptr backing; //!< The backing of the IFile + std::shared_ptr backing; public: IFile(std::shared_ptr &backing, const DeviceState &state, ServiceManager &manager); /** - * @brief This reads a buffer from a region of an IFile + * @brief Reads a buffer from a region of an IFile */ Result Read(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This writes a buffer to a region of an IFile + * @brief Writes a buffer to a region of an IFile */ Result Write(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This flushes any written data to the IFile on the Switch, however the emulator processes any FS event immediately so this does nothing + * @brief Flushes any written data to the IFile on the Switch, however the emulator processes any FS event immediately so this does nothing */ Result Flush(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This sets the size of an IFile + * @brief Sets the size of an IFile */ Result SetSize(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This obtains the size of an IFile + * @brief Obtains the size of an IFile */ Result GetSize(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); diff --git a/app/src/main/cpp/skyline/services/fssrv/IFileSystem.h b/app/src/main/cpp/skyline/services/fssrv/IFileSystem.h index ce3137d7..f4925944 100644 --- a/app/src/main/cpp/skyline/services/fssrv/IFileSystem.h +++ b/app/src/main/cpp/skyline/services/fssrv/IFileSystem.h @@ -8,7 +8,8 @@ namespace skyline::service::fssrv { /** - * @brief IFileSystem is used to interact with a filesystem (https://switchbrew.org/wiki/Filesystem_services#IFileSystem) + * @brief IFileSystem is used to interact with a filesystem + * @url https://switchbrew.org/wiki/Filesystem_services#IFileSystem */ class IFileSystem : public BaseService { private: @@ -18,22 +19,25 @@ namespace skyline::service::fssrv { IFileSystem(std::shared_ptr backing, const DeviceState &state, ServiceManager &manager); /** - * @brief This creates a file at the specified path in the filesystem + * @brief Creates a file at the specified path in the filesystem */ Result CreateFile(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This queries the DirectoryEntryType of the given path (https://switchbrew.org/wiki/Filesystem_services#GetEntryType) + * @brief Queries the DirectoryEntryType of the given path + * @url https://switchbrew.org/wiki/Filesystem_services#GetEntryType */ Result GetEntryType(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This returns an IFile handle for the requested path (https://switchbrew.org/wiki/Filesystem_services#OpenFile) + * @brief Returns an IFile handle for the requested path + * @url https://switchbrew.org/wiki/Filesystem_services#OpenFile */ Result OpenFile(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This commits all changes to the filesystem (https://switchbrew.org/wiki/Filesystem_services#Commit) + * @brief Commits all changes to the filesystem + * @url https://switchbrew.org/wiki/Filesystem_services#Commit */ Result Commit(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); diff --git a/app/src/main/cpp/skyline/services/fssrv/IFileSystemProxy.h b/app/src/main/cpp/skyline/services/fssrv/IFileSystemProxy.h index 42c83b94..c55a1897 100644 --- a/app/src/main/cpp/skyline/services/fssrv/IFileSystemProxy.h +++ b/app/src/main/cpp/skyline/services/fssrv/IFileSystemProxy.h @@ -7,9 +7,6 @@ #include "IFileSystem.h" namespace skyline::service::fssrv { - /** - * @brief This enumerates the possible locations savedata can be stored in - */ enum class SaveDataSpaceId : u64 { System = 0, //!< Savedata should be stored in the EMMC system folder User = 1, //!< Savedata should be stored in the EMMC user folder @@ -19,30 +16,21 @@ namespace skyline::service::fssrv { ProperSystem = 100, //!< Savedata should be stored in the system partition }; - /** - * @brief This enumerates the types of savedata - */ enum class SaveDataType : u8 { - System = 0, //!< This is system savedata - Account = 1, //!< This is user game savedata - Bcat = 2, //!< This is user bcat savedata - Device = 3, //!< This is device-wide savedata - Temporary = 4, //!< This is temporary savedata - Cache = 5, //!< This is cache savedata - SystemBcat = 6, //!< This is device-wide bcat savedata + System = 0, //!< System savedata + Account = 1, //!< User game savedata + Bcat = 2, //!< User BCAT savedata + Device = 3, //!< Device-wide savedata + Temporary = 4, //!< Temporary savedata + Cache = 5, //!< Cache savedata + SystemBcat = 6, //!< Device-wide BCAT savedata }; - /** - * @brief This enumerates the ranks of savedata - */ enum class SaveDataRank : u8 { - Primary, //!< This is primary savedata - Secondary, //!< This is secondary savedata + Primary, + Secondary, }; - /** - * @brief This stores the attributes of a savedata entry - */ struct SaveDataAttribute { u64 programId; //!< The program ID to store the savedata contents under account::UserId userId; //!< The user ID of whom the applications savedata contents should be stored under @@ -55,36 +43,42 @@ namespace skyline::service::fssrv { static_assert(sizeof(SaveDataAttribute) == 0x40); /** - * @brief IFileSystemProxy or fsp-srv is responsible for providing handles to file systems (https://switchbrew.org/wiki/Filesystem_services#fsp-srv) + * @brief IFileSystemProxy or fsp-srv is responsible for providing handles to file systems + * @url https://switchbrew.org/wiki/Filesystem_services#fsp-srv */ class IFileSystemProxy : public BaseService { public: - pid_t process{}; //!< This holds the PID set by SetCurrentProcess + pid_t process{}; //!< The PID as set by SetCurrentProcess IFileSystemProxy(const DeviceState &state, ServiceManager &manager); /** - * @brief This sets the PID of the process using FS currently (https://switchbrew.org/wiki/Filesystem_services#SetCurrentProcess) + * @brief Sets the PID of the process using FS currently + * @url https://switchbrew.org/wiki/Filesystem_services#SetCurrentProcess */ Result SetCurrentProcess(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This returns a handle to an instance of #IFileSystem (https://switchbrew.org/wiki/Filesystem_services#IFileSystem) with type SDCard + * @brief Returns a handle to an instance of #IFileSystem + * @url https://switchbrew.org/wiki/Filesystem_services#IFileSystem with type SDCard */ Result OpenSdCardFileSystem(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This returns a handle to an instance of #IFileSystem (https://switchbrew.org/wiki/Filesystem_services#IFileSystem) for the requested save data area + * @brief Returns a handle to an instance of #IFileSystem + * @url https://switchbrew.org/wiki/Filesystem_services#IFileSystem for the requested save data area */ Result OpenSaveDataFileSystem(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This returns a handle to an instance of #IStorage (https://switchbrew.org/wiki/Filesystem_services#IStorage) for the application's data storage + * @brief Returns a handle to an instance of #IStorage + * @url https://switchbrew.org/wiki/Filesystem_services#IStorage for the application's data storage */ Result OpenDataStorageByCurrentProcess(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This returns the filesystem log access mode (https://switchbrew.org/wiki/Filesystem_services#GetGlobalAccessLogMode) + * @brief Returns the filesystem log access mode + * @url https://switchbrew.org/wiki/Filesystem_services#GetGlobalAccessLogMode */ Result GetGlobalAccessLogMode(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); diff --git a/app/src/main/cpp/skyline/services/fssrv/IStorage.h b/app/src/main/cpp/skyline/services/fssrv/IStorage.h index 5f9d5a0b..866a480b 100644 --- a/app/src/main/cpp/skyline/services/fssrv/IStorage.h +++ b/app/src/main/cpp/skyline/services/fssrv/IStorage.h @@ -8,22 +8,25 @@ namespace skyline::service::fssrv { /** - * @brief IStorage is an interface to a raw backing device (https://switchbrew.org/wiki/Filesystem_services#IStorage) + * @brief IStorage is an interface to a raw backing device + * @url https://switchbrew.org/wiki/Filesystem_services#IStorage */ class IStorage : public BaseService { private: - std::shared_ptr backing; //!< The backing of the IStorage + std::shared_ptr backing; public: IStorage(std::shared_ptr &backing, const DeviceState &state, ServiceManager &manager); /** - * @brief This reads a buffer from a region of an IStorage (https://switchbrew.org/wiki/Filesystem_services#Read) + * @brief Reads a buffer from a region of an IStorage + * @url https://switchbrew.org/wiki/Filesystem_services#Read */ Result Read(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This obtains the size of an IStorage (https://switchbrew.org/wiki/Filesystem_services#GetSize) + * @brief Obtains the size of an IStorage + * @url https://switchbrew.org/wiki/Filesystem_services#GetSize */ Result GetSize(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); diff --git a/app/src/main/cpp/skyline/services/hid/IActiveVibrationDeviceList.h b/app/src/main/cpp/skyline/services/hid/IActiveVibrationDeviceList.h index 8224ae93..1b8dfa47 100644 --- a/app/src/main/cpp/skyline/services/hid/IActiveVibrationDeviceList.h +++ b/app/src/main/cpp/skyline/services/hid/IActiveVibrationDeviceList.h @@ -7,14 +7,16 @@ namespace skyline::service::hid { /** - * @brief IActiveVibrationDeviceList is used to activate vibration on certain HID devices (https://switchbrew.org/wiki/HID_services#IActiveVibrationDeviceList) + * @brief IActiveVibrationDeviceList is used to activate vibration on certain HID devices + * @url https://switchbrew.org/wiki/HID_services#IActiveVibrationDeviceList */ class IActiveVibrationDeviceList : public BaseService { public: IActiveVibrationDeviceList(const DeviceState &state, ServiceManager &manager); /** - * @brief Activates a vibration device with the specified #VibrationDeviceHandle (https://switchbrew.org/wiki/HID_services#ActivateVibrationDevice) + * @brief Activates a vibration device with the specified #VibrationDeviceHandle + * @url https://switchbrew.org/wiki/HID_services#ActivateVibrationDevice */ Result ActivateVibrationDevice(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); diff --git a/app/src/main/cpp/skyline/services/hid/IAppletResource.h b/app/src/main/cpp/skyline/services/hid/IAppletResource.h index 14d97785..ee381df9 100644 --- a/app/src/main/cpp/skyline/services/hid/IAppletResource.h +++ b/app/src/main/cpp/skyline/services/hid/IAppletResource.h @@ -7,14 +7,16 @@ namespace skyline::service::hid { /** - * @brief IAppletResource is used to get a handle to the HID shared memory (https://switchbrew.org/wiki/HID_services#IAppletResource) + * @brief IAppletResource is used to get a handle to the HID shared memory + * @url https://switchbrew.org/wiki/HID_services#IAppletResource */ class IAppletResource : public BaseService { public: IAppletResource(const DeviceState &state, ServiceManager &manager); /** - * @brief This opens a handle to HID shared memory (https://switchbrew.org/wiki/HID_services#GetSharedMemoryHandle) + * @brief Opens a handle to HID shared memory + * @url https://switchbrew.org/wiki/HID_services#GetSharedMemoryHandle */ Result GetSharedMemoryHandle(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); diff --git a/app/src/main/cpp/skyline/services/hid/IHidServer.cpp b/app/src/main/cpp/skyline/services/hid/IHidServer.cpp index 766d3635..91261e9d 100644 --- a/app/src/main/cpp/skyline/services/hid/IHidServer.cpp +++ b/app/src/main/cpp/skyline/services/hid/IHidServer.cpp @@ -2,6 +2,7 @@ // Copyright © 2020 Skyline Team and Contributors (https://github.com/skyline-emu/) #include +#include #include #include "IHidServer.h" #include "IActiveVibrationDeviceList.h" diff --git a/app/src/main/cpp/skyline/services/hid/IHidServer.h b/app/src/main/cpp/skyline/services/hid/IHidServer.h index a105aaba..981ef2c2 100644 --- a/app/src/main/cpp/skyline/services/hid/IHidServer.h +++ b/app/src/main/cpp/skyline/services/hid/IHidServer.h @@ -8,14 +8,16 @@ namespace skyline::service::hid { /** - * @brief IHidServer or hid service is used to access input devices (https://switchbrew.org/wiki/HID_services#hid) + * @brief IHidServer or hid service is used to access input devices + * @url https://switchbrew.org/wiki/HID_services#hid */ class IHidServer : public BaseService { public: IHidServer(const DeviceState &state, ServiceManager &manager); /** - * @brief This returns an IAppletResource (https://switchbrew.org/wiki/HID_services#CreateAppletResource) + * @brief Returns an IAppletResource + * @url https://switchbrew.org/wiki/HID_services#CreateAppletResource */ Result CreateAppletResource(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); @@ -25,82 +27,96 @@ namespace skyline::service::hid { Result ActivateDebugPad(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This activates the touch screen (if it's disabled, it is enabled by default) + * @brief Activates the touch screen (if it's disabled, it is enabled by default) */ Result ActivateTouchScreen(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This sets the style of controllers supported (https://switchbrew.org/wiki/HID_services#SetSupportedNpadStyleSet) + * @brief Sets the style of controllers supported + * @url https://switchbrew.org/wiki/HID_services#SetSupportedNpadStyleSet */ Result SetSupportedNpadStyleSet(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This gets the style of controllers supported (https://switchbrew.org/wiki/HID_services#GetSupportedNpadStyleSet) + * @brief Returns the style of controllers supported + * @url https://switchbrew.org/wiki/HID_services#GetSupportedNpadStyleSet */ Result GetSupportedNpadStyleSet(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This sets the NpadIds which are supported (https://switchbrew.org/wiki/HID_services#SetSupportedNpadIdType) + * @brief Sets the NpadIds which are supported + * @url https://switchbrew.org/wiki/HID_services#SetSupportedNpadIdType */ Result SetSupportedNpadIdType(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This requests the activation of controllers (https://switchbrew.org/wiki/HID_services#ActivateNpad) + * @brief Activates the Npads in HID Shared Memory + * @url https://switchbrew.org/wiki/HID_services#ActivateNpad */ Result ActivateNpad(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This requests the deactivation of controllers (https://switchbrew.org/wiki/HID_services#DeactivateNpad) + * @brief Deactivates the Npads in HID Shared Memory + * @url https://switchbrew.org/wiki/HID_services#DeactivateNpad */ Result DeactivateNpad(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This requests an event that's signalled on a specific NpadId changing (https://switchbrew.org/wiki/HID_services#AcquireNpadStyleSetUpdateEventHandle) + * @brief Requests an event that's signalled on a specific NpadId changing + * @url https://switchbrew.org/wiki/HID_services#AcquireNpadStyleSetUpdateEventHandle */ Result AcquireNpadStyleSetUpdateEventHandle(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This requests the LED pattern which represents a particular Player + * @brief Requests the LED pattern which represents a particular Player */ Result GetPlayerLedPattern(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This requests the activation of controllers with a specific HID revision (https://switchbrew.org/wiki/HID_services#ActivateNpadWithRevision) + * @brief Activates the Npads in HID Shared Memory with a specific HID revision + * @url https://switchbrew.org/wiki/HID_services#ActivateNpadWithRevision */ Result ActivateNpadWithRevision(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief Sets the Joy-Con hold mode (https://switchbrew.org/wiki/HID_services#SetNpadJoyHoldType) + * @brief Sets the Joy-Con hold mode + * @url https://switchbrew.org/wiki/HID_services#SetNpadJoyHoldType */ Result SetNpadJoyHoldType(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief Sets the Joy-Con hold mode (https://switchbrew.org/wiki/HID_services#GetNpadJoyHoldType) + * @brief Sets the Joy-Con hold mode + * @url https://switchbrew.org/wiki/HID_services#GetNpadJoyHoldType */ Result GetNpadJoyHoldType(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief Sets the Joy-Con assignment mode to Single by default (https://switchbrew.org/wiki/HID_services#SetNpadJoyAssignmentModeSingleByDefault) + * @brief Sets the Joy-Con assignment mode to Single by default + * @url https://switchbrew.org/wiki/HID_services#SetNpadJoyAssignmentModeSingleByDefault */ Result SetNpadJoyAssignmentModeSingleByDefault(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief Sets the Joy-Con assignment mode to Single (https://switchbrew.org/wiki/HID_services#SetNpadJoyAssignmentModeSingle) + * @brief Sets the Joy-Con assignment mode to Single + * @url https://switchbrew.org/wiki/HID_services#SetNpadJoyAssignmentModeSingle */ Result SetNpadJoyAssignmentModeSingle(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief Sets the Joy-Con assignment mode to Dual (https://switchbrew.org/wiki/HID_services#SetNpadJoyAssignmentModeDual) + * @brief Sets the Joy-Con assignment mode to Dual + * @url https://switchbrew.org/wiki/HID_services#SetNpadJoyAssignmentModeDual */ Result SetNpadJoyAssignmentModeDual(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief Returns an instance of #IActiveVibrationDeviceList (https://switchbrew.org/wiki/HID_services#CreateActiveVibrationDeviceList) + * @brief Returns an instance of #IActiveVibrationDeviceList + * @url https://switchbrew.org/wiki/HID_services#CreateActiveVibrationDeviceList */ Result CreateActiveVibrationDeviceList(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief Send vibration values to an NPad (https://switchbrew.org/wiki/HID_services#SendVibrationValues) + * @brief Send vibration values to an NPad + * @url https://switchbrew.org/wiki/HID_services#SendVibrationValues */ Result SendVibrationValues(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); diff --git a/app/src/main/cpp/skyline/services/hosbinder/GraphicBufferProducer.cpp b/app/src/main/cpp/skyline/services/hosbinder/GraphicBufferProducer.cpp index c94b6f17..24511edb 100644 --- a/app/src/main/cpp/skyline/services/hosbinder/GraphicBufferProducer.cpp +++ b/app/src/main/cpp/skyline/services/hosbinder/GraphicBufferProducer.cpp @@ -58,7 +58,7 @@ namespace skyline::service::hosbinder { u32 stickyTransform; u64 _unk0_; u32 swapInterval; - nvdrv::Fence fence[4]; + std::array fence; } &data = in.Pop(); auto buffer{queue.at(data.slot)}; diff --git a/app/src/main/cpp/skyline/services/hosbinder/GraphicBufferProducer.h b/app/src/main/cpp/skyline/services/hosbinder/GraphicBufferProducer.h index a8211634..8260b114 100644 --- a/app/src/main/cpp/skyline/services/hosbinder/GraphicBufferProducer.h +++ b/app/src/main/cpp/skyline/services/hosbinder/GraphicBufferProducer.h @@ -11,7 +11,8 @@ namespace skyline::gpu { namespace skyline::service::hosbinder { /** - * @brief This internal struct contains all data about the graphics buffer (https://github.com/reswitched/libtransistor/blob/0f0c36227842c344d163922fc98ee76229e9f0ee/lib/display/graphic_buffer_queue.c#L66) + * @brief A descriptor for the surfaceflinger graphics buffer + * @url https://github.com/reswitched/libtransistor/blob/0f0c36227842c344d163922fc98ee76229e9f0ee/lib/display/graphic_buffer_queue.c#L66 */ struct GbpBuffer { u32 magic; //!< The magic of the graphics buffer: 0x47424652 @@ -28,7 +29,7 @@ namespace skyline::service::hosbinder { u32 size; //!< The size of the buffer u32 _pad3_[8]; u32 nvmapHandle; //!< The handle of the buffer in regards to /dev/nvmap - u32 offset; //!< This is the offset of the pixel data in the GPU Buffer + u32 offset; //!< The offset of the pixel data in the GPU Buffer u32 _pad4_; u32 blockHeightLog2; //!< The log2 of the block height u32 _pad5_[58]; @@ -53,7 +54,8 @@ namespace skyline::service::hosbinder { }; /** - * @brief An enumeration of all the possible display IDs (https://switchbrew.org/wiki/Display_services#DisplayName) + * @brief An enumeration of all the possible display IDs + * @url https://switchbrew.org/wiki/Display_services#DisplayName */ enum class DisplayId : u64 { Default, //!< Refers to the default display used by most applications @@ -70,7 +72,8 @@ namespace skyline::service::hosbinder { }; /** - * @brief IGraphicBufferProducer is responsible for presenting buffers to the display as well as compositing and frame pacing (https://android.googlesource.com/platform/frameworks/native/+/8dc5539/libs/gui/IGraphicBufferProducer.cpp) + * @brief IGraphicBufferProducer is responsible for presenting buffers to the display as well as compositing and frame pacing + * @url https://android.googlesource.com/platform/frameworks/native/+/8dc5539/libs/gui/IGraphicBufferProducer.cpp */ class GraphicBufferProducer { private: @@ -109,10 +112,10 @@ namespace skyline::service::hosbinder { public: DisplayId displayId{DisplayId::Null}; //!< The ID of this display - LayerStatus layerStatus{LayerStatus::Uninitialized}; //!< This is the status of the single layer the display has + LayerStatus layerStatus{LayerStatus::Uninitialized}; //!< The status of the single layer the display has /** - * @brief This enumerates the functions called by TransactParcel for android.gui.IGraphicBufferProducer + * @brief The functions called by TransactParcel for android.gui.IGraphicBufferProducer * @refitem https://android.googlesource.com/platform/frameworks/native/+/8dc5539/libs/gui/IGraphicBufferProducer.cpp#35 */ enum class TransactionCode : u32 { @@ -135,19 +138,20 @@ namespace skyline::service::hosbinder { GraphicBufferProducer(const DeviceState &state); /** - * @brief The handler for Binder IPC transactions with IGraphicBufferProducer (https://android.googlesource.com/platform/frameworks/native/+/8dc5539/libs/gui/IGraphicBufferProducer.cpp#277) + * @brief The handler for Binder IPC transactions with IGraphicBufferProducer + * @url https://android.googlesource.com/platform/frameworks/native/+/8dc5539/libs/gui/IGraphicBufferProducer.cpp#277 */ void OnTransact(TransactionCode code, Parcel &in, Parcel &out); /** - * @brief This sets displayId to a specific display type + * @brief Sets displayId to a specific display type * @param name The name of the display * @note displayId has to be DisplayId::Null or this will throw an exception */ void SetDisplay(const std::string &name); /** - * @brief This closes the display by setting displayId to DisplayId::Null + * @brief Closes the display by setting displayId to DisplayId::Null */ void CloseDisplay(); }; diff --git a/app/src/main/cpp/skyline/services/hosbinder/IHOSBinderDriver.cpp b/app/src/main/cpp/skyline/services/hosbinder/IHOSBinderDriver.cpp index 407dfd27..e8b20bce 100644 --- a/app/src/main/cpp/skyline/services/hosbinder/IHOSBinderDriver.cpp +++ b/app/src/main/cpp/skyline/services/hosbinder/IHOSBinderDriver.cpp @@ -19,6 +19,10 @@ namespace skyline::service::hosbinder { Parcel in(request.inputBuf.at(0), state, true); Parcel out(state); + // We opted for just supporting a single layer and display as it's what basically all games use and wasting cycles on it is pointless + // If this was not done then we would need to maintain an array of GraphicBufferProducer objects for each layer and send the request it specifically + // There would also need to be an external compositor which composites all the graphics buffers submitted to every GraphicBufferProducer + state.logger->Debug("TransactParcel: Layer ID: {}, Code: {}", layerId, code); producer->OnTransact(code, in, out); diff --git a/app/src/main/cpp/skyline/services/hosbinder/IHOSBinderDriver.h b/app/src/main/cpp/skyline/services/hosbinder/IHOSBinderDriver.h index 3705a8a3..c3339491 100644 --- a/app/src/main/cpp/skyline/services/hosbinder/IHOSBinderDriver.h +++ b/app/src/main/cpp/skyline/services/hosbinder/IHOSBinderDriver.h @@ -19,17 +19,20 @@ namespace skyline::service::hosbinder { IHOSBinderDriver(const DeviceState &state, ServiceManager &manager); /** - * @brief This emulates the transaction of parcels between a IGraphicBufferProducer and the application (https://switchbrew.org/wiki/Nvnflinger_services#TransactParcel) + * @brief Emulates the transaction of parcels between a IGraphicBufferProducer and the application + * @url https://switchbrew.org/wiki/Nvnflinger_services#TransactParcel */ Result TransactParcel(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This adjusts the reference counts to the underlying binder, it is stubbed as we aren't using the real symbols (https://switchbrew.org/wiki/Nvnflinger_services#AdjustRefcount) + * @brief Adjusts the reference counts to the underlying binder, it is stubbed as we aren't using the real symbols + * @url https://switchbrew.org/wiki/Nvnflinger_services#AdjustRefcount */ Result AdjustRefcount(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This adjusts the reference counts to the underlying binder, it is stubbed as we aren't using the real symbols (https://switchbrew.org/wiki/Nvnflinger_services#GetNativeHandle) + * @brief Adjusts the reference counts to the underlying binder, it is stubbed as we aren't using the real symbols + * @url https://switchbrew.org/wiki/Nvnflinger_services#GetNativeHandle */ Result GetNativeHandle(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); diff --git a/app/src/main/cpp/skyline/services/lm/ILogService.h b/app/src/main/cpp/skyline/services/lm/ILogService.h index d59b31ed..ab683b9c 100644 --- a/app/src/main/cpp/skyline/services/lm/ILogService.h +++ b/app/src/main/cpp/skyline/services/lm/ILogService.h @@ -7,14 +7,16 @@ namespace skyline::service::lm { /** - * @brief ILogService is used by applications to open an ILogger for printing log messages (https://switchbrew.org/wiki/Log_services#lm) + * @brief ILogService is used by applications to open an ILogger for printing log messages + * @url https://switchbrew.org/wiki/Log_services#lm */ class ILogService : public BaseService { public: ILogService(const DeviceState &state, ServiceManager &manager); /** - * @brief This opens an ILogger that can be used by applications to print log messages (https://switchbrew.org/wiki/Log_services#OpenLogger) + * @brief Opens an ILogger that can be used by applications to print log messages + * @url https://switchbrew.org/wiki/Log_services#OpenLogger */ Result OpenLogger(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); diff --git a/app/src/main/cpp/skyline/services/lm/ILogger.h b/app/src/main/cpp/skyline/services/lm/ILogger.h index e9620443..77d590a3 100644 --- a/app/src/main/cpp/skyline/services/lm/ILogger.h +++ b/app/src/main/cpp/skyline/services/lm/ILogger.h @@ -7,36 +7,31 @@ namespace skyline::service::lm { /** - * @brief ILogger is used by applications to print messages to the system log (https://switchbrew.org/wiki/Log_services#ILogger) + * @brief ILogger is used by applications to print messages to the system log + * @url https://switchbrew.org/wiki/Log_services#ILogger */ class ILogger : public BaseService { private: - /** - * @brief This enumerates the field types in a log message - */ enum class LogFieldType : u8 { - Start = 0, //!< This is the first log message in the stream - Stop = 1, //!< This is the final log message in the stream - Message = 2, //!< This log field contains a general message - Line = 3, //!< This log field contains a line number - Filename = 4, //!< This log field contains a filename - Function = 5, //!< This log field contains a function name - Module = 6, //!< This log field contains a module name - Thread = 7, //!< This log field contains a thread name - DropCount = 8, //!< This log field contains the number of dropped messages - Time = 9, //!< This log field contains a timestamp - ProgramName = 10, //!< This log field contains the program's name + Start = 0, //!< The first log message in the stream + Stop = 1, //!< The final log message in the stream + Message = 2, //!< A log field with a general message + Line = 3, //!< A log field with a line number + Filename = 4, //!< A log field with a filename + Function = 5, //!< A log field with a function name + Module = 6, //!< A log field with a module name + Thread = 7, //!< A log field with a thread name + DropCount = 8, //!< A log field with the number of dropped messages + Time = 9, //!< A log field with a timestamp + ProgramName = 10, //!< A log field with the program's name }; - /** - * @brief This enumerates the log levels for log messages - */ enum class LogLevel : u8 { - Trace, //!< This is a trace log - Info, //!< This is an info log - Warning, //!< This is a warning log - Error, //!< This is an error log - Critical //!< This is a critical log + Trace, + Info, + Warning, + Error, + Critical, }; /** @@ -50,12 +45,14 @@ namespace skyline::service::lm { ILogger(const DeviceState &state, ServiceManager &manager); /** - * @brief This prints a message to the log (https://switchbrew.org/wiki/Log_services#Log) + * @brief Prints a message to the log + * @url https://switchbrew.org/wiki/Log_services#Log */ Result Log(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This sets the log destination (https://switchbrew.org/wiki/Log_services#SetDestination) + * @brief Sets the log destination + * @url https://switchbrew.org/wiki/Log_services#SetDestination */ Result SetDestination(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); diff --git a/app/src/main/cpp/skyline/services/nfp/IUser.h b/app/src/main/cpp/skyline/services/nfp/IUser.h index e53b544b..6ca0c276 100644 --- a/app/src/main/cpp/skyline/services/nfp/IUser.h +++ b/app/src/main/cpp/skyline/services/nfp/IUser.h @@ -7,14 +7,15 @@ namespace skyline::service::nfp { /** - * @brief IUser is used by applications to access NFC devices (https://switchbrew.org/wiki/NFC_services#IUser) + * @brief IUser is used by applications to access NFC devices + * @url https://switchbrew.org/wiki/NFC_services#IUser */ class IUser : public BaseService { public: IUser(const DeviceState &state, ServiceManager &manager); /** - * @brief This initializes an NFP session + * @brief Initializes an NFP session */ Result Initialize(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); diff --git a/app/src/main/cpp/skyline/services/nfp/IUserManager.h b/app/src/main/cpp/skyline/services/nfp/IUserManager.h index 026d64d7..fd323ca7 100644 --- a/app/src/main/cpp/skyline/services/nfp/IUserManager.h +++ b/app/src/main/cpp/skyline/services/nfp/IUserManager.h @@ -7,14 +7,15 @@ namespace skyline::service::nfp { /** - * @brief IUserManager or nfp:user is used by applications to open an IUser instance for accessing NFC devices (https://switchbrew.org/wiki/NFC_services#nfp:user) + * @brief IUserManager or nfp:user is used by applications to open an IUser instance for accessing NFC devices + * @url https://switchbrew.org/wiki/NFC_services#nfp:user */ class IUserManager : public BaseService { public: IUserManager(const DeviceState &state, ServiceManager &manager); /** - * @brief This opens an IUser that can be used by applications to access NFC devices + * @brief Opens an IUser that can be used by applications to access NFC devices */ Result CreateUserInterface(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); diff --git a/app/src/main/cpp/skyline/services/nifm/IGeneralService.h b/app/src/main/cpp/skyline/services/nifm/IGeneralService.h index 95cb7d25..c23536cc 100644 --- a/app/src/main/cpp/skyline/services/nifm/IGeneralService.h +++ b/app/src/main/cpp/skyline/services/nifm/IGeneralService.h @@ -7,14 +7,16 @@ namespace skyline::service::nifm { /** - * @brief IGeneralService is used by applications to control the network connection (https://switchbrew.org/wiki/Network_Interface_services#IGeneralService) + * @brief IGeneralService is used by applications to control the network connection + * @url https://switchbrew.org/wiki/Network_Interface_services#IGeneralService */ class IGeneralService : public BaseService { public: IGeneralService(const DeviceState &state, ServiceManager &manager); /** - * @brief This creates an IRequest instance that can be used to bring up the network (https://switchbrew.org/wiki/Network_Interface_services#CreateRequest) + * @brief Creates an IRequest instance that can be used to bring up the network + * @url https://switchbrew.org/wiki/Network_Interface_services#CreateRequest */ Result CreateRequest(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); diff --git a/app/src/main/cpp/skyline/services/nifm/IRequest.h b/app/src/main/cpp/skyline/services/nifm/IRequest.h index fe36fe7e..7f3cafcb 100644 --- a/app/src/main/cpp/skyline/services/nifm/IRequest.h +++ b/app/src/main/cpp/skyline/services/nifm/IRequest.h @@ -8,7 +8,8 @@ namespace skyline::service::nifm { /** - * @brief IRequest is used by applications to bring up a network (https://switchbrew.org/wiki/Network_Interface_services#IRequest) + * @brief IRequest is used by applications to bring up a network + * @url https://switchbrew.org/wiki/Network_Interface_services#IRequest */ class IRequest : public BaseService { private: @@ -19,22 +20,26 @@ namespace skyline::service::nifm { IRequest(const DeviceState &state, ServiceManager &manager); /** - * @brief This returns the current state of the request (https://switchbrew.org/wiki/Network_Interface_services#GetRequestState) + * @brief Returns the current state of the request + * @url https://switchbrew.org/wiki/Network_Interface_services#GetRequestState */ Result GetRequestState(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This returns the error code if a network bring up request fails (https://switchbrew.org/wiki/Network_Interface_services#GetResult) + * @brief Returns the error code if a network bring up request fails + * @url https://switchbrew.org/wiki/Network_Interface_services#GetResult */ Result GetResult(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This returns two KEvent handles that signal request on request updates (https://switchbrew.org/wiki/Network_Interface_services#GetSystemEventReadableHandles) + * @brief Returns two KEvent handles that signal request on request updates + * @url https://switchbrew.org/wiki/Network_Interface_services#GetSystemEventReadableHandles */ Result GetSystemEventReadableHandles(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This submits a request to bring up a network (https://switchbrew.org/wiki/Network_Interface_services#Submit) + * @brief Submits a request to bring up a network + * @url https://switchbrew.org/wiki/Network_Interface_services#Submit */ Result Submit(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); diff --git a/app/src/main/cpp/skyline/services/nifm/IStaticService.h b/app/src/main/cpp/skyline/services/nifm/IStaticService.h index 44f03089..3df5b481 100644 --- a/app/src/main/cpp/skyline/services/nifm/IStaticService.h +++ b/app/src/main/cpp/skyline/services/nifm/IStaticService.h @@ -7,14 +7,16 @@ namespace skyline::service::nifm { /** - * @brief IStaticService or nifm:u is used by applications to open an IGeneralService instance for controlling the network connection (https://switchbrew.org/wiki/Network_Interface_services#IGeneralService) + * @brief IStaticService or nifm:u is used by applications to open an IGeneralService instance for controlling the network connection + * @url https://switchbrew.org/wiki/Network_Interface_services#IGeneralService */ class IStaticService : public BaseService { public: IStaticService(const DeviceState &state, ServiceManager &manager); /** - * @brief This opens an IGeneralService that can be used by applications to control the network connection (https://switchbrew.org/wiki/Network_Interface_services#CreateGeneralServiceOld) + * @brief Opens an IGeneralService that can be used by applications to control the network connection + * @url https://switchbrew.org/wiki/Network_Interface_services#CreateGeneralServiceOld */ Result CreateGeneralService(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); diff --git a/app/src/main/cpp/skyline/services/nvdrv/INvDrvServices.h b/app/src/main/cpp/skyline/services/nvdrv/INvDrvServices.h index ac87c287..eaf101cb 100644 --- a/app/src/main/cpp/skyline/services/nvdrv/INvDrvServices.h +++ b/app/src/main/cpp/skyline/services/nvdrv/INvDrvServices.h @@ -9,7 +9,8 @@ namespace skyline::service::nvdrv { class Driver; /** - * @brief nvdrv or INvDrvServices is used to access the Nvidia GPU inside the Switch (https://switchbrew.org/wiki/NV_services#nvdrv.2C_nvdrv:a.2C_nvdrv:s.2C_nvdrv:t) + * @brief nvdrv or INvDrvServices is used to access the Nvidia GPU inside the Switch + * @url https://switchbrew.org/wiki/NV_services#nvdrv.2C_nvdrv:a.2C_nvdrv:s.2C_nvdrv:t */ class INvDrvServices : public BaseService { private: @@ -19,47 +20,56 @@ namespace skyline::service::nvdrv { INvDrvServices(const DeviceState &state, ServiceManager &manager); /** - * @brief Open a specific device and return a FD (https://switchbrew.org/wiki/NV_services#Open) + * @brief Open a specific device and return a FD + * @url https://switchbrew.org/wiki/NV_services#Open */ Result Open(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief Perform an IOCTL on the specified FD (https://switchbrew.org/wiki/NV_services#Ioctl) + * @brief Perform an IOCTL on the specified FD + * @url https://switchbrew.org/wiki/NV_services#Ioctl */ Result Ioctl(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief Close the specified FD (https://switchbrew.org/wiki/NV_services#Close) + * @brief Close the specified FD + * @url https://switchbrew.org/wiki/NV_services#Close */ Result Close(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This initializes the driver (https://switchbrew.org/wiki/NV_services#Initialize) + * @brief Initializes the driver + * @url https://switchbrew.org/wiki/NV_services#Initialize */ Result Initialize(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This returns a specific event from a device (https://switchbrew.org/wiki/NV_services#QueryEvent) + * @brief Returns a specific event from a device + * @url https://switchbrew.org/wiki/NV_services#QueryEvent */ Result QueryEvent(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This sets the AppletResourceUserId which matches the PID (https://switchbrew.org/wiki/NV_services#SetAruid) + * @brief Sets the AppletResourceUserId which matches the PID + * @url https://switchbrew.org/wiki/NV_services#SetAruid */ Result SetAruid(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief Perform an IOCTL on the specified FD with an extra input buffer (https://switchbrew.org/wiki/NV_services#Ioctl2) + * @brief Perform an IOCTL on the specified FD with an extra input buffer + * @url https://switchbrew.org/wiki/NV_services#Ioctl2 */ Result Ioctl2(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief Perform an IOCTL on the specified FD with an extra output buffer (https://switchbrew.org/wiki/NV_services#Ioctl3) + * @brief Perform an IOCTL on the specified FD with an extra output buffer + * @url https://switchbrew.org/wiki/NV_services#Ioctl3 */ Result Ioctl3(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This enables the graphics firmware memory margin (https://switchbrew.org/wiki/NV_services#SetGraphicsFirmwareMemoryMarginEnabled) + * @brief Enables the graphics firmware memory margin + * @url https://switchbrew.org/wiki/NV_services#SetGraphicsFirmwareMemoryMarginEnabled */ Result SetGraphicsFirmwareMemoryMarginEnabled(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); diff --git a/app/src/main/cpp/skyline/services/nvdrv/devices/nvdevice.h b/app/src/main/cpp/skyline/services/nvdrv/devices/nvdevice.h index b20d9f5e..170a6cb6 100644 --- a/app/src/main/cpp/skyline/services/nvdrv/devices/nvdevice.h +++ b/app/src/main/cpp/skyline/services/nvdrv/devices/nvdevice.h @@ -19,7 +19,8 @@ namespace skyline::service::nvdrv::device { using namespace kernel; /** - * @brief This enumerates all the possible error codes returned by the Nvidia driver (https://switchbrew.org/wiki/NV_services#Errors) + * @brief All the possible error codes returned by the Nvidia driver + * @url https://switchbrew.org/wiki/NV_services#Errors */ enum class NvStatus : u32 { Success = 0x0, //!< The operation has succeeded @@ -64,7 +65,7 @@ namespace skyline::service::nvdrv::device { std::string name; //!< The name of the device protected: - const DeviceState &state; //!< The state of the device + const DeviceState &state; public: inline NvDevice(const DeviceState &state) : state(state) {} @@ -80,7 +81,7 @@ namespace skyline::service::nvdrv::device { const std::string& GetName(); /** - * @brief This handles IOCTL calls for devices + * @brief Handles IOCTL calls for devices * @param cmd The IOCTL command that was called */ NvStatus HandleIoctl(u32 cmd, IoctlType type, span buffer, span inlineBuffer); diff --git a/app/src/main/cpp/skyline/services/nvdrv/devices/nvhost_as_gpu.h b/app/src/main/cpp/skyline/services/nvdrv/devices/nvhost_as_gpu.h index 38c3ffa3..8425eedb 100644 --- a/app/src/main/cpp/skyline/services/nvdrv/devices/nvhost_as_gpu.h +++ b/app/src/main/cpp/skyline/services/nvdrv/devices/nvhost_as_gpu.h @@ -7,44 +7,52 @@ namespace skyline::service::nvdrv::device { /** - * @brief NvHostAsGpu (/dev/nvhost-as-gpu) is used to access GPU virtual address spaces (https://switchbrew.org/wiki/NV_services#.2Fdev.2Fnvhost-as-gpu) + * @brief NvHostAsGpu (/dev/nvhost-as-gpu) is used to access GPU virtual address spaces + * @url https://switchbrew.org/wiki/NV_services#.2Fdev.2Fnvhost-as-gpu */ class NvHostAsGpu : public NvDevice { public: NvHostAsGpu(const DeviceState &state); /** - * @brief This binds a channel to the address space (https://switchbrew.org/wiki/NV_services#NVGPU_AS_IOCTL_BIND_CHANNEL) + * @brief Binds a channel to the address space + * @url https://switchbrew.org/wiki/NV_services#NVGPU_AS_IOCTL_BIND_CHANNEL */ NvStatus BindChannel(IoctlType type, span buffer, span inlineBuffer); /** - * @brief This reserves a region in the GPU address space (https://switchbrew.org/wiki/NV_services#NVGPU_AS_IOCTL_ALLOC_SPACE) + * @brief Reserves a region in the GPU address space + * @url https://switchbrew.org/wiki/NV_services#NVGPU_AS_IOCTL_ALLOC_SPACE */ NvStatus AllocSpace(IoctlType type, span buffer, span inlineBuffer); /** - * @brief This unmaps a region in the GPU address space (https://switchbrew.org/wiki/NV_services#NVGPU_AS_IOCTL_UNMAP_BUFFER) + * @brief Unmaps a region in the GPU address space + * @url https://switchbrew.org/wiki/NV_services#NVGPU_AS_IOCTL_UNMAP_BUFFER */ NvStatus UnmapBuffer(IoctlType type, span buffer, span inlineBuffer); /** - * @brief This maps a region in the GPU address space (https://switchbrew.org/wiki/NV_services#NVGPU_AS_IOCTL_MODIFY) + * @brief Maps a region in the GPU address space + * @url https://switchbrew.org/wiki/NV_services#NVGPU_AS_IOCTL_MODIFY */ NvStatus Modify(IoctlType type, span buffer, span inlineBuffer); /** - * @brief This returns the application's GPU address space (https://switchbrew.org/wiki/NV_services#NVGPU_AS_IOCTL_GET_VA_REGIONS) + * @brief Returns the application's GPU address space + * @url https://switchbrew.org/wiki/NV_services#NVGPU_AS_IOCTL_GET_VA_REGIONS */ NvStatus GetVaRegions(IoctlType type, span buffer, span inlineBuffer); /** - * @brief This initializes the application's GPU address space (https://switchbrew.org/wiki/NV_services#NVGPU_AS_IOCTL_ALLOC_AS_EX) + * @brief Initializes the application's GPU address space + * @url https://switchbrew.org/wiki/NV_services#NVGPU_AS_IOCTL_ALLOC_AS_EX */ NvStatus AllocAsEx(IoctlType type, span buffer, span inlineBuffer); /** - * @brief Remaps a region of the GPU address space (https://switchbrew.org/wiki/NV_services#NVGPU_AS_IOCTL_REMAP) + * @brief Remaps a region of the GPU address space + * @url https://switchbrew.org/wiki/NV_services#NVGPU_AS_IOCTL_REMAP */ NvStatus Remap(IoctlType type, span buffer, span inlineBuffer); diff --git a/app/src/main/cpp/skyline/services/nvdrv/devices/nvhost_channel.cpp b/app/src/main/cpp/skyline/services/nvdrv/devices/nvhost_channel.cpp index cc9037bc..4d994fa5 100644 --- a/app/src/main/cpp/skyline/services/nvdrv/devices/nvhost_channel.cpp +++ b/app/src/main/cpp/skyline/services/nvdrv/devices/nvhost_channel.cpp @@ -3,7 +3,7 @@ #include #include -#include +#include #include #include "nvhost_channel.h" diff --git a/app/src/main/cpp/skyline/services/nvdrv/devices/nvhost_channel.h b/app/src/main/cpp/skyline/services/nvdrv/devices/nvhost_channel.h index 1b4acf45..ea65abfa 100644 --- a/app/src/main/cpp/skyline/services/nvdrv/devices/nvhost_channel.h +++ b/app/src/main/cpp/skyline/services/nvdrv/devices/nvhost_channel.h @@ -8,14 +8,15 @@ namespace skyline::service::nvdrv::device { /** - * @brief NvHostChannel is used as a common interface for all Channel devices (https://switchbrew.org/wiki/NV_services#Channels) + * @brief NvHostChannel is used as a common interface for all Channel devices + * @url https://switchbrew.org/wiki/NV_services#Channels */ class NvHostChannel : public NvDevice { private: enum class NvChannelPriority : u32 { Low = 0x32, Medium = 0x64, - High = 0x94 + High = 0x94, }; Fence channelFence{}; @@ -28,47 +29,56 @@ namespace skyline::service::nvdrv::device { NvHostChannel(const DeviceState &state); /** - * @brief This sets the nvmap file descriptor (https://switchbrew.org/wiki/NV_services#NVGPU_IOCTL_CHANNEL_SET_NVMAP_FD) + * @brief Sets the nvmap file descriptor + * @url https://switchbrew.org/wiki/NV_services#NVGPU_IOCTL_CHANNEL_SET_NVMAP_FD */ NvStatus SetNvmapFd(IoctlType type, span buffer, span inlineBuffer); /** - * @brief This sets the timeout for the channel (https://switchbrew.org/wiki/NV_services#NVHOST_IOCTL_CHANNEL_SET_SUBMIT_TIMEOUT) + * @brief Sets the timeout for the channel + * @url https://switchbrew.org/wiki/NV_services#NVHOST_IOCTL_CHANNEL_SET_SUBMIT_TIMEOUT */ NvStatus SetSubmitTimeout(IoctlType type, span buffer, span inlineBuffer); /** - * @brief This submits a command to the GPFIFO (https://switchbrew.org/wiki/NV_services#NVGPU_IOCTL_CHANNEL_SUBMIT_GPFIFO) + * @brief Submits a command to the GPFIFO + * @url https://switchbrew.org/wiki/NV_services#NVGPU_IOCTL_CHANNEL_SUBMIT_GPFIFO */ NvStatus SubmitGpfifo(IoctlType type, span buffer, span inlineBuffer); /** - * @brief This allocates a graphic context object (https://switchbrew.org/wiki/NV_services#NVGPU_IOCTL_CHANNEL_ALLOC_OBJ_CTX) + * @brief Allocates a graphic context object + * @url https://switchbrew.org/wiki/NV_services#NVGPU_IOCTL_CHANNEL_ALLOC_OBJ_CTX */ NvStatus AllocObjCtx(IoctlType type, span buffer, span inlineBuffer); /** - * @brief This initializes the error notifier for this channel (https://switchbrew.org/wiki/NV_services#NVGPU_IOCTL_CHANNEL_ZCULL_BIND) + * @brief Initializes the error notifier for this channel + * @url https://switchbrew.org/wiki/NV_services#NVGPU_IOCTL_CHANNEL_ZCULL_BIND */ NvStatus ZcullBind(IoctlType type, span buffer, span inlineBuffer); /** - * @brief This initializes the error notifier for this channel (https://switchbrew.org/wiki/NV_services#NVGPU_IOCTL_CHANNEL_SET_ERROR_NOTIFIER) + * @brief Initializes the error notifier for this channel + * @url https://switchbrew.org/wiki/NV_services#NVGPU_IOCTL_CHANNEL_SET_ERROR_NOTIFIER */ NvStatus SetErrorNotifier(IoctlType type, span buffer, span inlineBuffer); /** - * @brief This sets the priority of the channel (https://switchbrew.org/wiki/NV_services#NVGPU_IOCTL_CHANNEL_SET_PRIORITY) + * @brief Sets the priority of the channel + * @url https://switchbrew.org/wiki/NV_services#NVGPU_IOCTL_CHANNEL_SET_PRIORITY */ NvStatus SetPriority(IoctlType type, span buffer, span inlineBuffer); /** - * @brief This allocates a GPFIFO entry (https://switchbrew.org/wiki/NV_services#NVGPU_IOCTL_CHANNEL_ALLOC_GPFIFO_EX2) + * @brief Allocates a GPFIFO entry + * @url https://switchbrew.org/wiki/NV_services#NVGPU_IOCTL_CHANNEL_ALLOC_GPFIFO_EX2 */ NvStatus AllocGpfifoEx2(IoctlType type, span buffer, span inlineBuffer); /** - * @brief This sets the user specific data (https://switchbrew.org/wiki/NV_services#NVGPU_IOCTL_CHANNEL_SET_USER_DATA) + * @brief Sets the user specific data + * @url https://switchbrew.org/wiki/NV_services#NVGPU_IOCTL_CHANNEL_SET_USER_DATA */ NvStatus SetUserData(IoctlType type, span buffer, span inlineBuffer); diff --git a/app/src/main/cpp/skyline/services/nvdrv/devices/nvhost_ctrl.h b/app/src/main/cpp/skyline/services/nvdrv/devices/nvhost_ctrl.h index fad6474c..d7d4d4e0 100644 --- a/app/src/main/cpp/skyline/services/nvdrv/devices/nvhost_ctrl.h +++ b/app/src/main/cpp/skyline/services/nvdrv/devices/nvhost_ctrl.h @@ -13,7 +13,7 @@ namespace skyline { namespace service::nvdrv::device { /** - * @brief This represents a single registered event with an attached fence + * @brief Events are used to expose fences to the userspace, they can be waited on using an IOCTL or be converted into a native HOS KEvent object that can be waited on just like any other KEvent on the guest */ class NvHostEvent { private: @@ -22,9 +22,6 @@ namespace skyline { void Signal(); public: - /** - * @brief This enumerates the possible states of an event - */ enum class State { Available = 0, Waiting = 1, @@ -52,12 +49,13 @@ namespace skyline { }; /** - * @brief NvHostCtrl (/dev/nvhost-ctrl) is used for GPU synchronization (https://switchbrew.org/wiki/NV_services#.2Fdev.2Fnvhost-ctrl) + * @brief NvHostCtrl (/dev/nvhost-ctrl) is used for GPU synchronization + * @url https://switchbrew.org/wiki/NV_services#.2Fdev.2Fnvhost-ctrl */ class NvHostCtrl : public NvDevice { private: /** - * @brief This holds metadata about an event, it is used by QueryEvent and EventWait + * @brief Metadata about an event, it is used by QueryEvent and EventWait */ union EventValue { u32 val; @@ -93,27 +91,32 @@ namespace skyline { NvHostCtrl(const DeviceState &state); /** - * @brief This gets the value of an nvdrv setting, it returns an error code on production switches (https://switchbrew.org/wiki/NV_services#NVHOST_IOCTL_CTRL_GET_CONFIG) + * @brief Gets the value of an nvdrv setting, it returns an error code on production switches + * @url https://switchbrew.org/wiki/NV_services#NVHOST_IOCTL_CTRL_GET_CONFIG */ NvStatus GetConfig(IoctlType type, span buffer, span inlineBuffer); /** - * @brief This signals an NvHost event (https://switchbrew.org/wiki/NV_services#NVHOST_IOCTL_CTRL_EVENT_SIGNAL) + * @brief Signals an NvHost event + * @url https://switchbrew.org/wiki/NV_services#NVHOST_IOCTL_CTRL_EVENT_SIGNAL */ NvStatus EventSignal(IoctlType type, span buffer, span inlineBuffer); /** - * @brief This synchronously waits on an NvHost event (https://switchbrew.org/wiki/NV_services#NVHOST_IOCTL_CTRL_EVENT_WAIT) + * @brief Synchronously waits on an NvHost event + * @url https://switchbrew.org/wiki/NV_services#NVHOST_IOCTL_CTRL_EVENT_WAIT */ NvStatus EventWait(IoctlType type, span buffer, span inlineBuffer); /** - * @brief This asynchronously waits on an NvHost event (https://switchbrew.org/wiki/NV_services#NVHOST_IOCTL_CTRL_EVENT_WAIT_ASYNC) + * @brief Asynchronously waits on an NvHost event + * @url https://switchbrew.org/wiki/NV_services#NVHOST_IOCTL_CTRL_EVENT_WAIT_ASYNC */ NvStatus EventWaitAsync(IoctlType type, span buffer, span inlineBuffer); /** - * @brief This registers an NvHost event (https://switchbrew.org/wiki/NV_services#NVHOST_IOCTL_CTRL_EVENT_REGISTER) + * @brief Registers an NvHost event + * @url https://switchbrew.org/wiki/NV_services#NVHOST_IOCTL_CTRL_EVENT_REGISTER */ NvStatus EventRegister(IoctlType type, span buffer, span inlineBuffer); diff --git a/app/src/main/cpp/skyline/services/nvdrv/devices/nvhost_ctrl_gpu.h b/app/src/main/cpp/skyline/services/nvdrv/devices/nvhost_ctrl_gpu.h index 26670d0c..ff7009f2 100644 --- a/app/src/main/cpp/skyline/services/nvdrv/devices/nvhost_ctrl_gpu.h +++ b/app/src/main/cpp/skyline/services/nvdrv/devices/nvhost_ctrl_gpu.h @@ -7,7 +7,8 @@ namespace skyline::service::nvdrv::device { /** - * @brief NvHostCtrlGpu (/dev/nvhost-ctrl-gpu) is used for context independent operations on the underlying GPU (https://switchbrew.org/wiki/NV_services#.2Fdev.2Fnvhost-ctrl-gpu) + * @brief NvHostCtrlGpu (/dev/nvhost-ctrl-gpu) is used for context independent operations on the underlying GPU + * @url https://switchbrew.org/wiki/NV_services#.2Fdev.2Fnvhost-ctrl-gpu */ class NvHostCtrlGpu : public NvDevice { private: @@ -18,27 +19,32 @@ namespace skyline::service::nvdrv::device { NvHostCtrlGpu(const DeviceState &state); /** - * @brief This returns a u32 GPU ZCULL Context Size (https://switchbrew.org/wiki/NV_services#NVGPU_GPU_IOCTL_ZCULL_GET_CTX_SIZE) + * @brief Returns a u32 GPU ZCULL Context Size + * @url https://switchbrew.org/wiki/NV_services#NVGPU_GPU_IOCTL_ZCULL_GET_CTX_SIZE */ NvStatus ZCullGetCtxSize(IoctlType type, span buffer, span inlineBuffer); /** - * @brief This returns a the GPU ZCULL Information (https://switchbrew.org/wiki/NV_services#NVGPU_GPU_IOCTL_ZCULL_GET_INFO) + * @brief Returns a the GPU ZCULL Information + * @url https://switchbrew.org/wiki/NV_services#NVGPU_GPU_IOCTL_ZCULL_GET_INFO */ NvStatus ZCullGetInfo(IoctlType type, span buffer, span inlineBuffer); /** - * @brief This returns a struct with certain GPU characteristics (https://switchbrew.org/wiki/NV_services#NVGPU_GPU_IOCTL_GET_CHARACTERISTICS) + * @brief Returns a struct with certain GPU characteristics + * @url https://switchbrew.org/wiki/NV_services#NVGPU_GPU_IOCTL_GET_CHARACTERISTICS */ NvStatus GetCharacteristics(IoctlType type, span buffer, span inlineBuffer); /** - * @brief This returns the TPC mask value for each GPC (https://switchbrew.org/wiki/NV_services#NVGPU_GPU_IOCTL_GET_TPC_MASKS) + * @brief Returns the TPC mask value for each GPC + * @url https://switchbrew.org/wiki/NV_services#NVGPU_GPU_IOCTL_GET_TPC_MASKS */ NvStatus GetTpcMasks(IoctlType type, span buffer, span inlineBuffer); /** - * @brief This returns the mask value for a ZBC slot (https://switchbrew.org/wiki/NV_services#NVGPU_GPU_IOCTL_ZBC_GET_ACTIVE_SLOT_MASK) + * @brief Returns the mask value for a ZBC slot + * @url https://switchbrew.org/wiki/NV_services#NVGPU_GPU_IOCTL_ZBC_GET_ACTIVE_SLOT_MASK */ NvStatus GetActiveSlotMask(IoctlType type, span buffer, span inlineBuffer); diff --git a/app/src/main/cpp/skyline/services/nvdrv/devices/nvhost_syncpoint.h b/app/src/main/cpp/skyline/services/nvdrv/devices/nvhost_syncpoint.h index d77816c5..a20c9e76 100644 --- a/app/src/main/cpp/skyline/services/nvdrv/devices/nvhost_syncpoint.h +++ b/app/src/main/cpp/skyline/services/nvdrv/devices/nvhost_syncpoint.h @@ -13,13 +13,10 @@ namespace skyline::service::nvdrv { */ class NvHostSyncpoint { private: - /** - * @brief This holds information about a single syncpoint - */ struct SyncpointInfo { - std::atomic counterMin; - std::atomic counterMax; - bool clientManaged; + std::atomic counterMin; //!< The least value the syncpoint can be (The value it was when it was last synchronized with the GPU for host managed syncpoints) + std::atomic counterMax; //!< The maximum value the syncpoint can reach according to the current usage + bool clientManaged; //!< If the syncpoint is managed by the client (CPU) or host (GPU), it determines if the value is absolute or not bool reserved; }; diff --git a/app/src/main/cpp/skyline/services/nvdrv/devices/nvmap.cpp b/app/src/main/cpp/skyline/services/nvdrv/devices/nvmap.cpp index d192e865..63913006 100644 --- a/app/src/main/cpp/skyline/services/nvdrv/devices/nvmap.cpp +++ b/app/src/main/cpp/skyline/services/nvdrv/devices/nvmap.cpp @@ -98,7 +98,16 @@ namespace skyline::service::nvdrv::device { } NvStatus NvMap::Param(IoctlType type, span buffer, span inlineBuffer) { - enum class Parameter : u32 { Size = 1, Alignment = 2, Base = 3, HeapMask = 4, Kind = 5, Compr = 6 }; // https://android.googlesource.com/kernel/tegra/+/refs/heads/android-tegra-flounder-3.10-marshmallow/include/linux/nvmap.h#102 + // https://android.googlesource.com/kernel/tegra/+/refs/heads/android-tegra-flounder-3.10-marshmallow/include/linux/nvmap.h#102 + enum class Parameter : u32 { + Size = 1, + Alignment = 2, + Base = 3, + HeapMask = 4, + Kind = 5, + Compr = 6, + }; + struct Data { u32 handle; // In Parameter parameter; // In diff --git a/app/src/main/cpp/skyline/services/nvdrv/devices/nvmap.h b/app/src/main/cpp/skyline/services/nvdrv/devices/nvmap.h index 0883b882..b68db2ed 100644 --- a/app/src/main/cpp/skyline/services/nvdrv/devices/nvmap.h +++ b/app/src/main/cpp/skyline/services/nvdrv/devices/nvmap.h @@ -7,7 +7,8 @@ namespace skyline::service::nvdrv::device { /** - * @brief NvMap (/dev/nvmap) is used to map certain CPU memory as GPU memory (https://switchbrew.org/wiki/NV_services) (https://android.googlesource.com/kernel/tegra/+/refs/heads/android-tegra-flounder-3.10-marshmallow/include/linux/nvmap.h) + * @brief NvMap (/dev/nvmap) is used to map certain CPU memory as GPU memory (https://switchbrew.org/wiki/NV_services) + * @url https://android.googlesource.com/kernel/tegra/+/refs/heads/android-tegra-flounder-3.10-marshmallow/include/linux/nvmap.h */ class NvMap : public NvDevice { public: @@ -28,10 +29,6 @@ namespace skyline::service::nvdrv::device { Allocated //!< The object has been allocated } status{Status::Created}; //!< This holds the status of the object - /** - * @param handle The ID of this object - * @param size The size of the object in bytes - */ NvMapObject(u32 id, u32 size); }; @@ -42,32 +39,38 @@ namespace skyline::service::nvdrv::device { NvMap(const DeviceState &state); /** - * @brief This creates an NvMapObject and returns an handle to it (https://switchbrew.org/wiki/NV_services#NVMAP_IOC_CREATE) + * @brief Creates an NvMapObject and returns an handle to it + * @url https://switchbrew.org/wiki/NV_services#NVMAP_IOC_CREATE */ NvStatus Create(IoctlType type, span buffer, span inlineBuffer); /** - * @brief This returns the handle of an NvMapObject from it's ID (https://switchbrew.org/wiki/NV_services#NVMAP_IOC_FROM_ID) + * @brief Returns the handle of an NvMapObject from it's ID + * @url https://switchbrew.org/wiki/NV_services#NVMAP_IOC_FROM_ID */ NvStatus FromId(IoctlType type, span buffer, span inlineBuffer); /** - * @brief This allocates memory for an NvMapObject (https://switchbrew.org/wiki/NV_services#NVMAP_IOC_ALLOC) + * @brief Allocates memory for an NvMapObject + * @url https://switchbrew.org/wiki/NV_services#NVMAP_IOC_ALLOC */ NvStatus Alloc(IoctlType type, span buffer, span inlineBuffer); /** - * @brief This frees previously allocated memory (https://switchbrew.org/wiki/NV_services#NVMAP_IOC_FREE) + * @brief Frees previously allocated memory + * @url https://switchbrew.org/wiki/NV_services#NVMAP_IOC_FREE */ NvStatus Free(IoctlType type, span buffer, span inlineBuffer); /** - * @brief This returns a particular parameter from an NvMapObject (https://switchbrew.org/wiki/NV_services#NVMAP_IOC_PARAM) + * @brief Returns a particular parameter from an NvMapObject + * @url https://switchbrew.org/wiki/NV_services#NVMAP_IOC_PARAM */ NvStatus Param(IoctlType type, span buffer, span inlineBuffer); /** - * @brief This returns the ID of an NvMapObject from it's handle (https://switchbrew.org/wiki/NV_services#NVMAP_IOC_GET_ID) + * @brief Returns the ID of an NvMapObject from it's handle + * @url https://switchbrew.org/wiki/NV_services#NVMAP_IOC_GET_ID */ NvStatus GetId(IoctlType type, span buffer, span inlineBuffer); diff --git a/app/src/main/cpp/skyline/services/pctl/IParentalControlService.h b/app/src/main/cpp/skyline/services/pctl/IParentalControlService.h index d390458f..db4949ba 100644 --- a/app/src/main/cpp/skyline/services/pctl/IParentalControlService.h +++ b/app/src/main/cpp/skyline/services/pctl/IParentalControlService.h @@ -7,7 +7,8 @@ namespace skyline::service::pctl { /** - * @brief IParentalControlService is used to access parental control configuration (https://switchbrew.org/wiki/Parental_Control_services#IParentalControlService) + * @brief IParentalControlService is used to access parental control configuration + * @url https://switchbrew.org/wiki/Parental_Control_services#IParentalControlService */ class IParentalControlService : public BaseService { public: diff --git a/app/src/main/cpp/skyline/services/pctl/IParentalControlServiceFactory.h b/app/src/main/cpp/skyline/services/pctl/IParentalControlServiceFactory.h index da2d2fd7..0effddd9 100644 --- a/app/src/main/cpp/skyline/services/pctl/IParentalControlServiceFactory.h +++ b/app/src/main/cpp/skyline/services/pctl/IParentalControlServiceFactory.h @@ -7,14 +7,15 @@ namespace skyline::service::pctl { /** - * @brief IParentalControlServiceFactory is used to open a parental controls instance (https://switchbrew.org/wiki/Parental_Control_services#pctl:s.2C_pctl:r.2C_pctl:a.2C_pctl) + * @brief IParentalControlServiceFactory is used to open a parental controls instance + * @url https://switchbrew.org/wiki/Parental_Control_services#pctl:s.2C_pctl:r.2C_pctl:a.2C_pctl */ class IParentalControlServiceFactory : public BaseService { public: IParentalControlServiceFactory(const DeviceState &state, ServiceManager &manager); /** - * @brief This creates and initializes an IParentalControlService instance that can be used to read parental control configuration + * @brief Creates and initializes an IParentalControlService instance that can be used to read parental control configuration */ Result CreateService(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); diff --git a/app/src/main/cpp/skyline/services/pl/IPlatformServiceManager.cpp b/app/src/main/cpp/skyline/services/pl/IPlatformServiceManager.cpp index 504167b1..819588dc 100644 --- a/app/src/main/cpp/skyline/services/pl/IPlatformServiceManager.cpp +++ b/app/src/main/cpp/skyline/services/pl/IPlatformServiceManager.cpp @@ -11,28 +11,25 @@ #include "IPlatformServiceManager.h" namespace skyline::service::pl { - /** - * @brief This holds an entry in the the font table - */ struct FontEntry { u8 *data; //!< The font TTF data size_t length; //!< The length of the font TTF data size_t offset; //!< The offset of the font in shared memory }; - std::array fontTable = {{ - {FontChineseSimplified, FontExtendedChineseSimplifiedLength}, - {FontChineseTraditional, FontChineseTraditionalLength}, - {FontExtendedChineseSimplified, FontExtendedChineseSimplifiedLength}, - {FontKorean, FontKoreanLength}, - {FontNintendoExtended, FontNintendoExtendedLength}, - {FontStandard, FontStandardLength} - }}; + std::array fontTable{{ + {FontChineseSimplified, FontExtendedChineseSimplifiedLength}, + {FontChineseTraditional, FontChineseTraditionalLength}, + {FontExtendedChineseSimplified, FontExtendedChineseSimplifiedLength}, + {FontKorean, FontKoreanLength}, + {FontNintendoExtended, FontNintendoExtendedLength}, + {FontStandard, FontStandardLength} + }}; IPlatformServiceManager::IPlatformServiceManager(const DeviceState &state, ServiceManager &manager) : fontSharedMem(std::make_shared(state, NULL, constant::FontSharedMemSize, memory::Permission{true, false, false})), BaseService(state, manager) { - constexpr u32 SharedFontResult{0x7F9A0218}; //!< This is the decrypted magic for a single font in the shared font data - constexpr u32 SharedFontMagic{0x36F81A1E}; //!< This is the encrypted magic for a single font in the shared font data - constexpr u32 SharedFontKey{SharedFontMagic ^SharedFontResult}; //!< This is the XOR key for encrypting the font size + constexpr u32 SharedFontResult{0x7F9A0218}; //!< The decrypted magic for a single font in the shared font data + constexpr u32 SharedFontMagic{0x36F81A1E}; //!< The encrypted magic for a single font in the shared font data + constexpr u32 SharedFontKey{SharedFontMagic ^ SharedFontResult}; //!< The XOR key for encrypting the font size auto pointer{reinterpret_cast(fontSharedMem->kernel.address)}; for (auto &font : fontTable) { @@ -46,7 +43,7 @@ namespace skyline::service::pl { } Result IPlatformServiceManager::GetLoadState(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response) { - constexpr u32 FontLoaded{1}; //!< This is returned to show that all fonts have been loaded into memory + constexpr u32 FontLoaded{1}; //!< "All fonts have been loaded into memory" response.Push(FontLoaded); return {}; } diff --git a/app/src/main/cpp/skyline/services/pl/IPlatformServiceManager.h b/app/src/main/cpp/skyline/services/pl/IPlatformServiceManager.h index 187cad3e..00ec6427 100644 --- a/app/src/main/cpp/skyline/services/pl/IPlatformServiceManager.h +++ b/app/src/main/cpp/skyline/services/pl/IPlatformServiceManager.h @@ -8,37 +8,42 @@ namespace skyline { namespace constant { - constexpr u32 FontSharedMemSize{0x1100000}; //!< This is the total size of the font shared memory + constexpr u32 FontSharedMemSize{0x1100000}; //!< The total size of the font shared memory } namespace service::pl { /** - * @brief IPlatformServiceManager is used to access shared fonts (https://switchbrew.org/wiki/Shared_Database_services#pl:u.2C_pl:s) + * @brief IPlatformServiceManager is used to access shared fonts + * @url https://switchbrew.org/wiki/Shared_Database_services#pl:u.2C_pl:s */ class IPlatformServiceManager : public BaseService { private: - std::shared_ptr fontSharedMem; //!< This shared memory stores the TTF data of all shared fonts + std::shared_ptr fontSharedMem; //!< The KSharedMemory that stores the TTF data of all shared fonts public: IPlatformServiceManager(const DeviceState &state, ServiceManager &manager); /** - * @brief This returns the loading state of the requested font (https://switchbrew.org/wiki/Shared_Database_services#GetLoadState) + * @brief Returns the loading state of the requested font + * @url https://switchbrew.org/wiki/Shared_Database_services#GetLoadState */ Result GetLoadState(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This returns the size of the requested font (https://switchbrew.org/wiki/Shared_Database_services#GetSize) + * @brief Returns the size of the requested font + * @url https://switchbrew.org/wiki/Shared_Database_services#GetSize */ Result GetSize(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This returns the offset in shared memory of the requested font (https://switchbrew.org/wiki/Shared_Database_services#GetSharedMemoryAddressOffset) + * @brief Returns the offset in shared memory of the requested font + * @url https://switchbrew.org/wiki/Shared_Database_services#GetSharedMemoryAddressOffset */ Result GetSharedMemoryAddressOffset(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This returns a handle to the whole font shared memory (https://switchbrew.org/wiki/Shared_Database_services#GetSharedMemoryNativeHandle) + * @brief Returns a handle to the whole font shared memory + * @url https://switchbrew.org/wiki/Shared_Database_services#GetSharedMemoryNativeHandle */ Result GetSharedMemoryNativeHandle(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); diff --git a/app/src/main/cpp/skyline/services/prepo/IPrepoService.h b/app/src/main/cpp/skyline/services/prepo/IPrepoService.h index cdca3ccb..3b1cf9fb 100644 --- a/app/src/main/cpp/skyline/services/prepo/IPrepoService.h +++ b/app/src/main/cpp/skyline/services/prepo/IPrepoService.h @@ -7,14 +7,15 @@ namespace skyline::service::prepo { /** - * @brief IPrepoService or prepo:u is used by applications to store statistics (https://switchbrew.org/wiki/BCAT_services#prepo:a.2C_prepo:a2.2C_prepo:m.2C_prepo:u.2C_prepo:s) + * @brief IPrepoService or prepo:u is used by applications to store statistics + * @url https://switchbrew.org/wiki/BCAT_services#prepo:a.2C_prepo:a2.2C_prepo:m.2C_prepo:u.2C_prepo:s */ class IPrepoService : public BaseService { public: IPrepoService(const DeviceState &state, ServiceManager &manager); /** - * @brief This saves a play report for the given user + * @brief Saves a play report for the given user */ Result SaveReportWithUser(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); diff --git a/app/src/main/cpp/skyline/services/serviceman.cpp b/app/src/main/cpp/skyline/services/serviceman.cpp index e88dfaea..5a7cb412 100644 --- a/app/src/main/cpp/skyline/services/serviceman.cpp +++ b/app/src/main/cpp/skyline/services/serviceman.cpp @@ -119,7 +119,7 @@ namespace skyline::service { void ServiceManager::CloseSession(KHandle handle) { std::lock_guard serviceGuard(mutex); auto session{state.process->GetHandle(handle)}; - if (session->serviceStatus == type::KSession::ServiceStatus::Open) { + if (session->isOpen) { if (session->isDomain) { for (const auto &domainEntry : session->domainTable) std::erase_if(serviceMap, [domainEntry](const auto &entry) { @@ -130,7 +130,7 @@ namespace skyline::service { return entry.second == session->serviceObject; }); } - session->serviceStatus = type::KSession::ServiceStatus::Closed; + session->isOpen = false; } } @@ -139,7 +139,7 @@ namespace skyline::service { state.logger->Debug("----Start----"); state.logger->Debug("Handle is 0x{:X}", handle); - if (session->serviceStatus == type::KSession::ServiceStatus::Open) { + if (session->isOpen) { ipc::IpcRequest request(session->isDomain, state); ipc::IpcResponse response(state); @@ -149,10 +149,11 @@ namespace skyline::service { if (session->isDomain) { try { auto service{session->domainTable.at(request.domain->objectId)}; - switch (static_cast(request.domain->command)) { + switch (request.domain->command) { case ipc::DomainCommand::SendMessage: response.errorCode = service->HandleRequest(*session, request, response); break; + case ipc::DomainCommand::CloseVHandle: std::erase_if(serviceMap, [service](const auto &entry) { return entry.second == service; @@ -168,6 +169,7 @@ namespace skyline::service { } response.WriteResponse(session->isDomain); break; + case ipc::CommandType::Control: case ipc::CommandType::ControlWithContext: state.logger->Debug("Control IPC Message: 0x{:X}", request.payload->value); @@ -175,18 +177,22 @@ namespace skyline::service { case ipc::ControlCommand::ConvertCurrentObjectToDomain: response.Push(session->ConvertDomain()); break; + case ipc::ControlCommand::CloneCurrentObject: case ipc::ControlCommand::CloneCurrentObjectEx: response.moveHandles.push_back(state.process->InsertItem(session)); break; + case ipc::ControlCommand::QueryPointerBufferSize: response.Push(0x1000); break; + default: throw exception("Unknown Control Command: {}", request.payload->value); } response.WriteResponse(false); break; + case ipc::CommandType::Close: state.logger->Debug("Closing Session"); CloseSession(handle); diff --git a/app/src/main/cpp/skyline/services/serviceman.h b/app/src/main/cpp/skyline/services/serviceman.h index 30d34f2f..da76ae16 100644 --- a/app/src/main/cpp/skyline/services/serviceman.h +++ b/app/src/main/cpp/skyline/services/serviceman.h @@ -9,13 +9,12 @@ namespace skyline::service { /** * @brief The ServiceManager class manages passing IPC requests to the right Service and running event loops of Services - * @todo This implementation varies significantly from HOS, this should be rectified much later on */ class ServiceManager { private: - const DeviceState &state; //!< The state of the device + const DeviceState &state; std::unordered_map> serviceMap; //!< A mapping from a Service to the underlying object - Mutex mutex; //!< This mutex is used to ensure concurrent access to services doesn't cause crashes + Mutex mutex; //!< Synchronizes concurrent access to services to prevent crashes /** * @brief Creates an instance of the service if it doesn't already exist, otherwise returns an existing instance @@ -25,11 +24,8 @@ namespace skyline::service { std::shared_ptr CreateService(ServiceName name); public: - std::shared_ptr smUserInterface; //!< This is used by applications to open connections to services + std::shared_ptr smUserInterface; //!< Used by applications to open connections to services - /** - * @param state The state of the device - */ ServiceManager(const DeviceState &state); /** diff --git a/app/src/main/cpp/skyline/services/settings/ISettingsServer.h b/app/src/main/cpp/skyline/services/settings/ISettingsServer.h index 4ecd7596..36a437ea 100644 --- a/app/src/main/cpp/skyline/services/settings/ISettingsServer.h +++ b/app/src/main/cpp/skyline/services/settings/ISettingsServer.h @@ -13,24 +13,25 @@ namespace skyline::service { namespace settings { /** - * @brief ISettingsServer or 'set' provides access to user settings (https://switchbrew.org/wiki/Settings_services#set) + * @brief ISettingsServer or 'set' provides access to user settings + * @url https://switchbrew.org/wiki/Settings_services#set */ class ISettingsServer : public BaseService { public: ISettingsServer(const DeviceState &state, ServiceManager &manager); /** - * @brief This reads the available language codes that an application can use (pre 4.0.0) + * @brief Reads the available language codes that an application can use (pre 4.0.0) */ Result GetAvailableLanguageCodes(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This converts a language code list index to it's corresponding language code + * @brief Converts a language code list index to it's corresponding language code */ Result MakeLanguageCode(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This reads the available language codes that an application can use (post 4.0.0) + * @brief Reads the available language codes that an application can use (post 4.0.0) */ Result GetAvailableLanguageCodes2(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); diff --git a/app/src/main/cpp/skyline/services/settings/ISystemSettingsServer.h b/app/src/main/cpp/skyline/services/settings/ISystemSettingsServer.h index 5403c8ec..58a19ea1 100644 --- a/app/src/main/cpp/skyline/services/settings/ISystemSettingsServer.h +++ b/app/src/main/cpp/skyline/services/settings/ISystemSettingsServer.h @@ -12,7 +12,8 @@ namespace skyline::service::settings { class ISystemSettingsServer : public BaseService { private: /** - * @brief Encapsulates the system version, this is sent to the application in GetFirmwareVersion (https://switchbrew.org/wiki/System_Version_Title) + * @brief Encapsulates the system version, this is sent to the application in GetFirmwareVersion + * @url https://switchbrew.org/wiki/System_Version_Title */ struct SysVerTitle { u8 major; //!< The major version @@ -23,7 +24,7 @@ namespace skyline::service::settings { u8 revMinor; //!< The major revision u16 _pad1_; u8 platform[0x20]; //!< "NX" - u8 verHash[0x40]; //!< This is the hash of the version string + u8 verHash[0x40]; //!< The hash of the version string u8 dispVer[0x18]; //!< The version number string u8 dispTitle[0x80]; //!< The version title string }; @@ -33,7 +34,8 @@ namespace skyline::service::settings { ISystemSettingsServer(const DeviceState &state, ServiceManager &manager); /** - * @brief Writes the Firmware version to a 0xA buffer (https://switchbrew.org/wiki/Settings_services#GetFirmwareVersion) + * @brief Writes the Firmware version to a 0xA buffer + * @url https://switchbrew.org/wiki/Settings_services#GetFirmwareVersion */ Result GetFirmwareVersion(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); diff --git a/app/src/main/cpp/skyline/services/sm/IUserInterface.h b/app/src/main/cpp/skyline/services/sm/IUserInterface.h index 47dc6422..e6de8341 100644 --- a/app/src/main/cpp/skyline/services/sm/IUserInterface.h +++ b/app/src/main/cpp/skyline/services/sm/IUserInterface.h @@ -19,19 +19,22 @@ namespace skyline::service::sm { } /** - * @brief IUserInterface or sm: is responsible for providing handles to services (https://switchbrew.org/wiki/Services_API) + * @brief IUserInterface or sm: is responsible for providing handles to services + * @url https://switchbrew.org/wiki/Services_API */ class IUserInterface : public BaseService { public: IUserInterface(const DeviceState &state, ServiceManager &manager); /** - * @brief This initializes the sm: service. (https://switchbrew.org/wiki/Services_API#Initialize) + * @brief Initializes the sm: service. + * @url https://switchbrew.org/wiki/Services_API#Initialize */ Result Initialize(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This returns a handle to a service with it's name passed in as an argument (https://switchbrew.org/wiki/Services_API#GetService) + * @brief Returns a handle to a service with it's name passed in as an argument + * @url https://switchbrew.org/wiki/Services_API#GetService */ Result GetService(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); diff --git a/app/src/main/cpp/skyline/services/socket/bsd/IClient.h b/app/src/main/cpp/skyline/services/socket/bsd/IClient.h index c214b10e..d9a1b8f1 100644 --- a/app/src/main/cpp/skyline/services/socket/bsd/IClient.h +++ b/app/src/main/cpp/skyline/services/socket/bsd/IClient.h @@ -7,19 +7,21 @@ namespace skyline::service::socket { /** - * @brief IClient or bsd:u is used by applications create network sockets (https://switchbrew.org/wiki/Sockets_services#bsd:u.2C_bsd:s) + * @brief IClient or bsd:u is used by applications create network sockets + * @url https://switchbrew.org/wiki/Sockets_services#bsd:u.2C_bsd:s */ class IClient : public BaseService { public: IClient(const DeviceState &state, ServiceManager &manager); /** - * @brief This initializes a socket client with the given parameters (https://switchbrew.org/wiki/Sockets_services#Initialize) + * @brief Initializes a socket client with the given parameters + * @url https://switchbrew.org/wiki/Sockets_services#Initialize */ Result RegisterClient(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This starts the monitoring of the socket + * @brief Starts the monitoring of the socket */ Result StartMonitoring(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); diff --git a/app/src/main/cpp/skyline/services/ssl/ISslContext.h b/app/src/main/cpp/skyline/services/ssl/ISslContext.h index 5d84d76f..1d4eb5c4 100644 --- a/app/src/main/cpp/skyline/services/ssl/ISslContext.h +++ b/app/src/main/cpp/skyline/services/ssl/ISslContext.h @@ -7,7 +7,8 @@ namespace skyline::service::ssl { /** - * @brief ISslContext is used to manage SSL certificates (https://switchbrew.org/wiki/SSL_services#ISslContext) + * @brief ISslContext is used to manage SSL certificates + * @url https://switchbrew.org/wiki/SSL_services#ISslContext */ class ISslContext : public BaseService { public: diff --git a/app/src/main/cpp/skyline/services/ssl/ISslService.h b/app/src/main/cpp/skyline/services/ssl/ISslService.h index a4808f0d..d8b5ecf8 100644 --- a/app/src/main/cpp/skyline/services/ssl/ISslService.h +++ b/app/src/main/cpp/skyline/services/ssl/ISslService.h @@ -7,19 +7,22 @@ namespace skyline::service::ssl { /** - * @brief ISslService or ssl is used by applications to manage SSL connections (https://switchbrew.org/wiki/SSL_services#ssl) + * @brief ISslService or ssl is used by applications to manage SSL connections + * @url https://switchbrew.org/wiki/SSL_services#ssl */ class ISslService : public BaseService { public: ISslService(const DeviceState &state, ServiceManager &manager); /** - * @brief This creates an SSL context (https://switchbrew.org/wiki/SSL_services#CreateContext) + * @brief Creates an SSL context + * @url https://switchbrew.org/wiki/SSL_services#CreateContext */ Result CreateContext(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This sets the SSL interface version (https://switchbrew.org/wiki/SSL_services#SetInterfaceVersion) + * @brief Sets the SSL interface version + * @url https://switchbrew.org/wiki/SSL_services#SetInterfaceVersion */ Result SetInterfaceVersion(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); diff --git a/app/src/main/cpp/skyline/services/timesrv/IStaticService.h b/app/src/main/cpp/skyline/services/timesrv/IStaticService.h index c95baa96..e9422e10 100644 --- a/app/src/main/cpp/skyline/services/timesrv/IStaticService.h +++ b/app/src/main/cpp/skyline/services/timesrv/IStaticService.h @@ -7,34 +7,35 @@ namespace skyline::service::timesrv { /** - * @brief IStaticService (This covers time:u, time:a and time:s) is responsible for providing handles to various clock services (https://switchbrew.org/wiki/PSC_services#time:su.2C_time:s) + * @brief IStaticService (covers time:u, time:a and time:s) is responsible for providing handles to various clock services + * @url https://switchbrew.org/wiki/PSC_services#time:su.2C_time:s */ class IStaticService : public BaseService { public: IStaticService(const DeviceState &state, ServiceManager &manager); /** - * @brief This returns a handle to a ISystemClock for user time + * @brief Returns a handle to a ISystemClock for user time */ Result GetStandardUserSystemClock(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This returns a handle to a ISystemClock for network time + * @brief Returns a handle to a ISystemClock for network time */ Result GetStandardNetworkSystemClock(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This returns a handle to a ISteadyClock for a steady timepoint + * @brief Returns a handle to a ISteadyClock for a steady timepoint */ Result GetStandardSteadyClock(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This returns a handle to a ITimeZoneService for reading time zone information + * @brief Returns a handle to a ITimeZoneService for reading time zone information */ Result GetTimeZoneService(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This returns a handle to a ISystemClock for local time + * @brief Returns a handle to a ISystemClock for local time */ Result GetStandardLocalSystemClock(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); diff --git a/app/src/main/cpp/skyline/services/timesrv/ISteadyClock.h b/app/src/main/cpp/skyline/services/timesrv/ISteadyClock.h index 06953cb0..cb20757f 100644 --- a/app/src/main/cpp/skyline/services/timesrv/ISteadyClock.h +++ b/app/src/main/cpp/skyline/services/timesrv/ISteadyClock.h @@ -7,7 +7,7 @@ namespace skyline::service::timesrv { /** - * @brief This holds a steady clock timepoint (https://switchbrew.org/wiki/PSC_services#SteadyClockTimePoint) + * @url https://switchbrew.org/wiki/PSC_services#SteadyClockTimePoint */ struct SteadyClockTimePoint { u64 timepoint; //!< The point in time of this timepoint @@ -15,14 +15,15 @@ namespace skyline::service::timesrv { }; /** - * @brief ISteadyClock is used to retrieve a steady time that increments uniformly for the lifetime on an application (https://switchbrew.org/wiki/PSC_services#ISteadyClock) + * @brief ISteadyClock is used to retrieve a steady time that increments uniformly for the lifetime on an application + * @url https://switchbrew.org/wiki/PSC_services#ISteadyClock */ class ISteadyClock : public BaseService { public: ISteadyClock(const DeviceState &state, ServiceManager &manager); /** - * @brief This returns the current value of the steady clock + * @brief Returns the current value of the steady clock */ Result GetCurrentTimePoint(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); diff --git a/app/src/main/cpp/skyline/services/timesrv/ISystemClock.h b/app/src/main/cpp/skyline/services/timesrv/ISystemClock.h index 635ee920..4275f2db 100644 --- a/app/src/main/cpp/skyline/services/timesrv/ISystemClock.h +++ b/app/src/main/cpp/skyline/services/timesrv/ISystemClock.h @@ -16,21 +16,22 @@ namespace skyline::service::timesrv { }; /** - * @brief ISystemClock is used to retrieve and set time (https://switchbrew.org/wiki/PSC_services#ISystemClock) + * @brief ISystemClock is used to retrieve and set time + * @url https://switchbrew.org/wiki/PSC_services#ISystemClock */ class ISystemClock : public BaseService { public: - const SystemClockType type; //!< The type of the system clock + const SystemClockType type; ISystemClock(const SystemClockType clockType, const DeviceState &state, ServiceManager &manager); /** - * @brief This returns the amount of seconds since epoch + * @brief Returns the amount of seconds since epoch */ Result GetCurrentTime(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This returns the system clock context + * @brief Returns the system clock context */ Result GetSystemClockContext(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); diff --git a/app/src/main/cpp/skyline/services/timesrv/ITimeZoneService.h b/app/src/main/cpp/skyline/services/timesrv/ITimeZoneService.h index 1dcc2de1..2afdc075 100644 --- a/app/src/main/cpp/skyline/services/timesrv/ITimeZoneService.h +++ b/app/src/main/cpp/skyline/services/timesrv/ITimeZoneService.h @@ -7,12 +7,13 @@ namespace skyline::service::timesrv { /** - * @brief ITimeZoneService is used to retrieve and set time (https://switchbrew.org/wiki/PSC_services#ITimeZoneService) + * @brief ITimeZoneService is used to retrieve and set time + * @url https://switchbrew.org/wiki/PSC_services#ITimeZoneService */ class ITimeZoneService : public BaseService { private: /** - * @brief This holds a particular time point in calendar format + * @brief A particular time point in calendar format */ struct CalendarTime { u16 year; //!< The Year component of the date @@ -26,7 +27,7 @@ namespace skyline::service::timesrv { static_assert(sizeof(CalendarTime) == 0x8); /** - * @brief This is passed in addition to CalendarTime + * @brief Information that is packaged along with CalendarTime */ struct CalendarAdditionalInfo { u32 dayWeek; //!< The amount of days since Sunday @@ -41,7 +42,8 @@ namespace skyline::service::timesrv { ITimeZoneService(const DeviceState &state, ServiceManager &manager); /** - * @brief This receives a u64 #PosixTime (https://switchbrew.org/wiki/PSC_services#PosixTime), and returns a #CalendarTime (https://switchbrew.org/wiki/PSC_services#CalendarTime), #CalendarAdditionalInfo (https://switchbrew.org/wiki/PSC_services#CalendarAdditionalInfo) + * @brief Receives a u64 #PosixTime (https://switchbrew.org/wiki/PSC_services#PosixTime), and returns a #CalendarTime (https://switchbrew.org/wiki/PSC_services#CalendarTime), #CalendarAdditionalInfo + * @url https://switchbrew.org/wiki/PSC_services#CalendarAdditionalInfo */ Result ToCalendarTimeWithMyRule(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); diff --git a/app/src/main/cpp/skyline/services/visrv/IApplicationDisplayService.h b/app/src/main/cpp/skyline/services/visrv/IApplicationDisplayService.h index a2f30fae..172ed89e 100644 --- a/app/src/main/cpp/skyline/services/visrv/IApplicationDisplayService.h +++ b/app/src/main/cpp/skyline/services/visrv/IApplicationDisplayService.h @@ -7,59 +7,70 @@ namespace skyline::service::visrv { /** - * @brief This service is used to access the display (https://switchbrew.org/wiki/Display_services#IApplicationDisplayService) + * @brief This is used to access the display + * @url https://switchbrew.org/wiki/Display_services#IApplicationDisplayService */ class IApplicationDisplayService : public IDisplayService { public: IApplicationDisplayService(const DeviceState &state, ServiceManager &manager); /** - * @brief Returns an handle to the 'nvnflinger' service (https://switchbrew.org/wiki/Display_services#GetRelayService) + * @brief Returns an handle to the 'nvnflinger' service + * @url https://switchbrew.org/wiki/Display_services#GetRelayService */ Result GetRelayService(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief Returns an handle to the 'nvnflinger' service (https://switchbrew.org/wiki/Display_services#GetIndirectDisplayTransactionService) + * @brief Returns an handle to the 'nvnflinger' service + * @url https://switchbrew.org/wiki/Display_services#GetIndirectDisplayTransactionService */ Result GetIndirectDisplayTransactionService(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief Returns an handle to #ISystemDisplayService (https://switchbrew.org/wiki/Display_services#GetSystemDisplayService) + * @brief Returns an handle to #ISystemDisplayService + * @url https://switchbrew.org/wiki/Display_services#GetSystemDisplayService */ Result GetSystemDisplayService(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief Returns an handle to #IManagerDisplayService (https://switchbrew.org/wiki/Display_services#GetManagerDisplayService) + * @brief Returns an handle to #IManagerDisplayService + * @url https://switchbrew.org/wiki/Display_services#GetManagerDisplayService */ Result GetManagerDisplayService(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief Opens up a display using it's name as the input (https://switchbrew.org/wiki/Display_services#OpenDisplay) + * @brief Opens up a display using it's name as the input + * @url https://switchbrew.org/wiki/Display_services#OpenDisplay */ Result OpenDisplay(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief Closes an open display using it's ID (https://switchbrew.org/wiki/Display_services#CloseDisplay) + * @brief Closes an open display using it's ID + * @url https://switchbrew.org/wiki/Display_services#CloseDisplay */ Result CloseDisplay(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief Opens a specific layer on a display (https://switchbrew.org/wiki/Display_services#OpenLayer) + * @brief Opens a specific layer on a display + * @url https://switchbrew.org/wiki/Display_services#OpenLayer */ Result OpenLayer(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief Closes a specific layer on a display (https://switchbrew.org/wiki/Display_services#CloseLayer) + * @brief Closes a specific layer on a display + * @url https://switchbrew.org/wiki/Display_services#CloseLayer */ Result CloseLayer(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief Sets the scaling mode for a window, this is not required by emulators (https://switchbrew.org/wiki/Display_services#SetLayerScalingMode) + * @brief Sets the scaling mode for a window, this is not required by emulators + * @url https://switchbrew.org/wiki/Display_services#SetLayerScalingMode */ Result SetLayerScalingMode(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief Returns a handle to a KEvent which is triggered every time a frame is drawn (https://switchbrew.org/wiki/Display_services#GetDisplayVsyncEvent) + * @brief Returns a handle to a KEvent which is triggered every time a frame is drawn + * @url https://switchbrew.org/wiki/Display_services#GetDisplayVsyncEvent */ Result GetDisplayVsyncEvent(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); diff --git a/app/src/main/cpp/skyline/services/visrv/IDisplayService.h b/app/src/main/cpp/skyline/services/visrv/IDisplayService.h index 9cbdf458..a2473585 100644 --- a/app/src/main/cpp/skyline/services/visrv/IDisplayService.h +++ b/app/src/main/cpp/skyline/services/visrv/IDisplayService.h @@ -12,7 +12,7 @@ namespace skyline::service::visrv { class IDisplayService : public BaseService { protected: /** - * @brief This is the format of the parcel used in OpenLayer/CreateStrayLayer + * @brief This is the parcel used in OpenLayer/CreateStrayLayer */ struct LayerParcel { u32 type; //!< The type of the layer @@ -28,12 +28,12 @@ namespace skyline::service::visrv { IDisplayService(const DeviceState &state, ServiceManager &manager); /** - * @brief This creates a stray layer using a display's ID and returns a layer ID and the corresponding buffer ID + * @brief Creates a stray layer using a display's ID and returns a layer ID and the corresponding buffer ID */ Result CreateStrayLayer(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); /** - * @brief This takes a layer ID and destroys the corresponding stray layer + * @brief Destroys a stray layer by it's ID */ Result DestroyStrayLayer(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); }; diff --git a/app/src/main/cpp/skyline/services/visrv/IManagerDisplayService.h b/app/src/main/cpp/skyline/services/visrv/IManagerDisplayService.h index 16fd075a..e4f2b2bd 100644 --- a/app/src/main/cpp/skyline/services/visrv/IManagerDisplayService.h +++ b/app/src/main/cpp/skyline/services/visrv/IManagerDisplayService.h @@ -7,7 +7,8 @@ namespace skyline::service::visrv { /** - * @brief This service retrieves information about a display in context of the entire system (https://switchbrew.org/wiki/Display_services#IManagerDisplayService) + * @brief This service retrieves information about a display in context of the entire system + * @url https://switchbrew.org/wiki/Display_services#IManagerDisplayService */ class IManagerDisplayService : public IDisplayService { public: diff --git a/app/src/main/cpp/skyline/services/visrv/IManagerRootService.h b/app/src/main/cpp/skyline/services/visrv/IManagerRootService.h index b3f60233..a4e6f432 100644 --- a/app/src/main/cpp/skyline/services/visrv/IManagerRootService.h +++ b/app/src/main/cpp/skyline/services/visrv/IManagerRootService.h @@ -8,14 +8,16 @@ namespace skyline::service::visrv { /** - * @brief This service is used to get an handle to #IApplicationDisplayService (https://switchbrew.org/wiki/Display_services#vi:m) + * @brief This service is used to get an handle to #IApplicationDisplayService + * @url https://switchbrew.org/wiki/Display_services#vi:m */ class IManagerRootService : public BaseService { public: IManagerRootService(const DeviceState &state, ServiceManager &manager); /** - * @brief This returns an handle to #IApplicationDisplayService (https://switchbrew.org/wiki/Display_services#GetDisplayService) + * @brief Returns an handle to #IApplicationDisplayService + * @url https://switchbrew.org/wiki/Display_services#GetDisplayService */ Result GetDisplayService(type::KSession &session, ipc::IpcRequest &request, ipc::IpcResponse &response); diff --git a/app/src/main/cpp/skyline/services/visrv/ISystemDisplayService.h b/app/src/main/cpp/skyline/services/visrv/ISystemDisplayService.h index 27ddfb0f..8ffbc05d 100644 --- a/app/src/main/cpp/skyline/services/visrv/ISystemDisplayService.h +++ b/app/src/main/cpp/skyline/services/visrv/ISystemDisplayService.h @@ -7,7 +7,8 @@ namespace skyline::service::visrv { /** - * @brief This service retrieves information about a display in context of the entire system (https://switchbrew.org/wiki/Display_services#ISystemDisplayService) + * @brief This service retrieves information about a display in context of the entire system + * @url https://switchbrew.org/wiki/Display_services#ISystemDisplayService */ class ISystemDisplayService : public IDisplayService { public: diff --git a/app/src/main/cpp/skyline/vfs/backing.h b/app/src/main/cpp/skyline/vfs/backing.h index 873098ee..36bf1fe1 100644 --- a/app/src/main/cpp/skyline/vfs/backing.h +++ b/app/src/main/cpp/skyline/vfs/backing.h @@ -7,12 +7,12 @@ namespace skyline::vfs { /** - * @brief The Backing class represents an abstract region of memory + * @brief The Backing class provides abstract access to a storage device, all access can be done without using a specific backing */ class Backing { public: /** - * @brief This describes the modes that a backing is capable of + * @brief The capabilities of the Backing */ union Mode { struct { @@ -20,11 +20,10 @@ namespace skyline::vfs { bool write : 1; //!< The backing is writable bool append : 1; //!< The backing can be appended }; - u32 raw; //!< The raw value of the mode - }; + u32 raw; + } mode; static_assert(sizeof(Mode) == 0x4); - Mode mode; //!< The mode of the backing size_t size; //!< The size of the backing in bytes /** @@ -51,7 +50,6 @@ namespace skyline::vfs { /** * @brief Read bytes from the backing at a particular offset to a buffer (template version) - * @tparam T The type of object to write to * @param output The object to write to * @param offset The offset to start reading from * @param size The amount to read in bytes diff --git a/app/src/main/cpp/skyline/vfs/ctr_encrypted_backing.h b/app/src/main/cpp/skyline/vfs/ctr_encrypted_backing.h index c926e499..eb79c380 100644 --- a/app/src/main/cpp/skyline/vfs/ctr_encrypted_backing.h +++ b/app/src/main/cpp/skyline/vfs/ctr_encrypted_backing.h @@ -9,20 +9,14 @@ namespace skyline::vfs { /** - * @brief This backing is used to decrypt AES-CTR data + * @brief A backing for decrypting AES-CTR data */ class CtrEncryptedBacking : public Backing { private: crypto::KeyStore::Key128 ctr; - crypto::AesCipher cipher; - std::shared_ptr backing; - - /** - * @brief Offset of file is used to calculate the IV - */ - size_t baseOffset; + size_t baseOffset; //!< The offset of the backing into the file is used to calculate the IV /** * @brief Calculates IV based on the offset diff --git a/app/src/main/cpp/skyline/vfs/directory.h b/app/src/main/cpp/skyline/vfs/directory.h index 48943e75..50b1d223 100644 --- a/app/src/main/cpp/skyline/vfs/directory.h +++ b/app/src/main/cpp/skyline/vfs/directory.h @@ -11,35 +11,29 @@ namespace skyline::vfs { */ class Directory { public: - /** - * @brief This enumerates the types of entry a directory can contain - */ enum class EntryType : u32 { - Directory = 0x0, //!< The entry is a directory - File = 0x1, //!< The entry is a file + Directory = 0x0, + File = 0x1, }; - /** - * @brief This hold information about a single directory entry - */ struct Entry { - std::string name; //!< The name of the entry - EntryType type; //!< The type of the entry + std::string name; + EntryType type; }; /** - * @brief This describes what will be returned when reading a directories contents + * @brief A descriptor for what will be returned when reading a directories contents */ union ListMode { struct { bool directory : 1; //!< The directory listing will contain subdirectories bool file : 1; //!< The directory listing will contain files }; - u32 raw; //!< The raw value of the listing mode + u32 raw; }; static_assert(sizeof(ListMode) == 0x4); - ListMode listMode; //!< This describes what this directory will return when it is Read + ListMode listMode; Directory(ListMode listMode) : listMode(listMode) {} diff --git a/app/src/main/cpp/skyline/vfs/nacp.h b/app/src/main/cpp/skyline/vfs/nacp.h index 3a87bef7..62047448 100644 --- a/app/src/main/cpp/skyline/vfs/nacp.h +++ b/app/src/main/cpp/skyline/vfs/nacp.h @@ -7,12 +7,13 @@ namespace skyline::vfs { /** - * @brief The NACP class provides easy access to the data found in an NACP file (https://switchbrew.org/wiki/NACP_Format) + * @brief The NACP class provides easy access to the data found in an NACP file + * @url https://switchbrew.org/wiki/NACP_Format */ class NACP { private: /** - * @brief This contains the name and publisher of an application for one language + * @brief The title data of an application for one language */ struct ApplicationTitle { std::array applicationName; //!< The name of the application @@ -21,9 +22,6 @@ namespace skyline::vfs { static_assert(sizeof(ApplicationTitle) == 0x300); public: - /** - * @brief This struct encapsulates all the data within an NACP file - */ struct NacpData { std::array titleEntries; //!< Title entries for each language u8 _pad0_[0x78]; @@ -32,9 +30,6 @@ namespace skyline::vfs { } nacpContents{}; static_assert(sizeof(NacpData) == 0x4000); - /** - * @param backing The backing for the NACP - */ NACP(const std::shared_ptr &backing); std::string applicationName; //!< The name of the application in the currently selected language diff --git a/app/src/main/cpp/skyline/vfs/nca.h b/app/src/main/cpp/skyline/vfs/nca.h index 63cf7bfa..0ebe94b7 100644 --- a/app/src/main/cpp/skyline/vfs/nca.h +++ b/app/src/main/cpp/skyline/vfs/nca.h @@ -13,33 +13,28 @@ namespace skyline { } namespace vfs { - /** - * @brief This enumerates the various content types of an NCA - */ enum class NcaContentType : u8 { - Program = 0x0, //!< This is a program NCA - Meta = 0x1, //!< This is a metadata NCA - Control = 0x2, //!< This is a control NCA - Manual = 0x3, //!< This is a manual NCA - Data = 0x4, //!< This is a data NCA - PublicData = 0x5, //!< This is a public data NCA + Program = 0x0, //!< Program NCA + Meta = 0x1, //!< Metadata NCA + Control = 0x2, //!< Control NCA + Manual = 0x3, //!< Manual NCA + Data = 0x4, //!< Data NCA + PublicData = 0x5, //!< Public data NCA }; /** - * @brief The NCA class provides an easy way to access the contents of an NCA file (https://switchbrew.org/wiki/NCA_Format) + * @brief The NCA class provides an easy way to access the contents of an Nintendo Content Archive + * @url https://switchbrew.org/wiki/NCA_Format */ class NCA { private: - /** - * @brief This enumerates the distribution types of an NCA - */ enum class NcaDistributionType : u8 { System = 0x0, //!< This NCA was distributed on the EShop or is part of the system GameCard = 0x1, //!< This NCA was distributed on a GameCard }; /** - * @brief This enumerates the key generation version in NCAs before HOS 3.0.1 + * @brief The key generation version in NCAs before HOS 3.0.1 */ enum class NcaLegacyKeyGenerationType : u8 { Fw100 = 0x0, //!< 1.0.0 @@ -47,7 +42,7 @@ namespace skyline { }; /** - * @brief This enumerates the key generation version in NCAs after HOS 3.0.0 + * @brief The key generation version in NCAs after HOS 3.0.0, this is changed by Nintendo frequently */ enum class NcaKeyGenerationType : u8 { Fw301 = 0x3, //!< 3.0.1 @@ -62,43 +57,28 @@ namespace skyline { Invalid = 0xFF, //!< An invalid key generation type }; - /** - * @brief This enumerates the key area encryption key types - */ enum class NcaKeyAreaEncryptionKeyType : u8 { Application = 0x0, //!< This NCA uses the application key encryption area Ocean = 0x1, //!< This NCA uses the ocean key encryption area System = 0x2, //!< This NCA uses the system key encryption area }; - /** - * @brief This hold the entry of a single filesystem in an NCA - */ struct NcaFsEntry { u32 startOffset; //!< The start offset of the filesystem in units of 0x200 bytes u32 endOffset; //!< The start offset of the filesystem in units of 0x200 bytes u64 _pad_; }; - /** - * @brief This enumerates the possible filesystem types a section of an NCA can contain - */ enum class NcaSectionFsType : u8 { RomFs = 0x0, //!< This section contains a RomFs filesystem PFS0 = 0x1, //!< This section contains a PFS0 filesystem }; - /** - * @brief This enumerates the possible hash header types of an NCA section - */ enum class NcaSectionHashType : u8 { HierarchicalSha256 = 0x2, //!< The hash header for this section is that of a PFS0 HierarchicalIntegrity = 0x3, //!< The hash header for this section is that of a RomFS }; - /** - * @brief This enumerates the possible encryption types of an NCA section - */ enum class NcaSectionEncryptionType : u8 { None = 0x1, //!< This NCA doesn't use any encryption XTS = 0x2, //!< This NCA uses AES-XTS encryption @@ -107,7 +87,7 @@ namespace skyline { }; /** - * @brief This holds the data for a single level of the hierarchical integrity scheme + * @brief The data for a single level of the hierarchical integrity scheme */ struct HierarchicalIntegrityLevel { u64 offset; //!< The offset of the level data @@ -118,7 +98,7 @@ namespace skyline { static_assert(sizeof(HierarchicalIntegrityLevel) == 0x18); /** - * @brief This holds the hash info header of the hierarchical integrity scheme + * @brief The hash info header of the hierarchical integrity scheme */ struct HierarchicalIntegrityHashInfo { u32 magic; //!< The hierarchical integrity magic, 'IVFC' @@ -133,7 +113,7 @@ namespace skyline { static_assert(sizeof(HierarchicalIntegrityHashInfo) == 0xF8); /** - * @brief This holds the hash info header of the SHA256 hashing scheme for PFS0 + * @brief The hash info header of the SHA256 hashing scheme for PFS0 */ struct HierarchicalSha256HashInfo { std::array hashTableHash; //!< A SHA256 hash over the hash table @@ -147,9 +127,6 @@ namespace skyline { }; static_assert(sizeof(HierarchicalSha256HashInfo) == 0xF8); - /** - * @brief This holds the header of each specific section in an NCA - */ struct NcaSectionHeader { u16 version; //!< The version, always 2 NcaSectionFsType fsType; //!< The type of the filesystem in the section @@ -168,34 +145,31 @@ namespace skyline { }; static_assert(sizeof(NcaSectionHeader) == 0x200); - /** - * @brief This struct holds the header of a Nintendo Content Archive - */ struct NcaHeader { std::array fixed_key_sig; //!< An RSA-PSS signature over the header with fixed key std::array npdm_key_sig; //!< An RSA-PSS signature over header with key in NPDM u32 magic; //!< The magic of the NCA: 'NCA3' NcaDistributionType distributionType; //!< Whether this NCA is from a gamecard or the E-Shop - NcaContentType contentType; //!< The content type of the NCA + NcaContentType contentType; NcaLegacyKeyGenerationType legacyKeyGenerationType; //!< The keyblob to use for decryption NcaKeyAreaEncryptionKeyType keyAreaEncryptionKeyType; //!< The index of the key area encryption key that is needed u64 size; //!< The total size of the NCA - u64 programId; //!< The program ID of the NCA - u32 contentIndex; //!< The index of the content + u64 programId; + u32 contentIndex; u32 sdkVersion; //!< The version of the SDK the NCA was built with NcaKeyGenerationType keyGenerationType; //!< The keyblob to use for decryption u8 fixedKeyGeneration; //!< The fixed key index u8 _pad0_[0xE]; - std::array rightsId; //!< The NCA's rights ID + std::array rightsId; std::array fsEntries; //!< The filesystem entries for this NCA - std::array, 4> sectionHashes; //!< This contains SHA-256 hashes for each filesystem header + std::array, 4> sectionHashes; //!< SHA-256 hashes for each filesystem header std::array, 4> encryptedKeyArea; //!< The encrypted key area for each filesystem u8 _pad1_[0xC0]; std::array sectionHeaders; } header{}; static_assert(sizeof(NcaHeader) == 0xC00); - std::shared_ptr backing; //!< The backing for the NCA + std::shared_ptr backing; std::shared_ptr keyStore; bool encrypted{false}; bool rightsIdEmpty; diff --git a/app/src/main/cpp/skyline/vfs/partition_filesystem.h b/app/src/main/cpp/skyline/vfs/partition_filesystem.h index be5ec479..a8ff9fd7 100644 --- a/app/src/main/cpp/skyline/vfs/partition_filesystem.h +++ b/app/src/main/cpp/skyline/vfs/partition_filesystem.h @@ -11,9 +11,6 @@ namespace skyline::vfs { */ class PartitionFileSystem : public FileSystem { private: - /** - * @brief This holds the header of the filesystem - */ struct FsHeader { u32 magic; //!< The filesystem magic: 'PFS0' or 'HFS0' u32 numFiles; //!< The number of files in the filesystem @@ -22,9 +19,6 @@ namespace skyline::vfs { } header{}; static_assert(sizeof(FsHeader) == 0x10); - /** - * @brief This holds a file entry in a partition filesystem - */ struct PartitionFileEntry { u64 offset; //!< The offset of the file in the backing u64 size; //!< The size of the file @@ -33,9 +27,6 @@ namespace skyline::vfs { }; static_assert(sizeof(PartitionFileEntry) == 0x18); - /** - * @brief This holds a file entry in a hashed filesystem - */ struct HashedFileEntry { PartitionFileEntry entry; //!< The base file entry u32 _pad_; diff --git a/app/src/main/cpp/skyline/vfs/rom_filesystem.h b/app/src/main/cpp/skyline/vfs/rom_filesystem.h index f9ccf492..40d3c9b7 100644 --- a/app/src/main/cpp/skyline/vfs/rom_filesystem.h +++ b/app/src/main/cpp/skyline/vfs/rom_filesystem.h @@ -16,7 +16,7 @@ namespace skyline { */ class RomFileSystem : public FileSystem { private: - std::shared_ptr backing; //!< The backing file of the filesystem + std::shared_ptr backing; /** * @brief Traverses the sibling files of the given file and adds them to the file map @@ -33,9 +33,6 @@ namespace skyline { void TraverseDirectory(u32 offset, const std::string &path); public: - /** - * @brief This holds the header of a RomFS image - */ struct RomFsHeader { u64 headerSize; //!< The size of the header u64 dirHashTableOffset; //!< The offset of the directory hash table @@ -50,9 +47,6 @@ namespace skyline { } header{}; static_assert(sizeof(RomFsHeader) == 0x50); - /** - * @brief This holds a directory entry in a RomFS image - */ struct RomFsDirectoryEntry { u32 parentOffset; //!< The offset from the directory metadata base of the parent directory u32 siblingOffset; //!< The offset from the directory metadata base of a sibling directory @@ -62,9 +56,6 @@ namespace skyline { u32 nameSize; //!< The size of the directory's name in bytes }; - /** - * @brief This holds a file entry in a RomFS image - */ struct RomFsFileEntry { u32 parentOffset; //!< The offset from the directory metadata base of the parent directory u32 siblingOffset; //!< The offset from the file metadata base of a sibling file @@ -93,7 +84,7 @@ namespace skyline { private: RomFileSystem::RomFsDirectoryEntry ownEntry; //!< This directory's entry in the RomFS header RomFileSystem::RomFsHeader header; //!< A header of this files parent RomFS image - std::shared_ptr backing; //!< The backing of the RomFS image + std::shared_ptr backing; public: RomFileSystemDirectory(const std::shared_ptr &backing, const RomFileSystem::RomFsHeader &header, const RomFileSystem::RomFsDirectoryEntry &ownEntry, ListMode listMode);