Merge pull request #4158 from Morph1984/caps

caps: Use enum classes and check struct sizes on compile time
This commit is contained in:
bunnei 2020-06-27 00:09:32 -04:00 committed by GitHub
commit 6f16f54f10
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 69 additions and 57 deletions

View file

@ -1,4 +1,4 @@
// Copyright 2018 yuzu emulator team // Copyright 2018 yuzu Emulator Project
// Licensed under GPLv2 or any later version // Licensed under GPLv2 or any later version
// Refer to the license.txt file included. // Refer to the license.txt file included.

View file

@ -1,4 +1,4 @@
// Copyright 2018 yuzu emulator team // Copyright 2018 yuzu Emulator Project
// Licensed under GPLv2 or any later version // Licensed under GPLv2 or any later version
// Refer to the license.txt file included. // Refer to the license.txt file included.
@ -12,73 +12,79 @@ class ServiceManager;
namespace Service::Capture { namespace Service::Capture {
enum AlbumImageOrientation { enum class AlbumImageOrientation {
Orientation0 = 0, Orientation0 = 0,
Orientation1 = 1, Orientation1 = 1,
Orientation2 = 2, Orientation2 = 2,
Orientation3 = 3, Orientation3 = 3,
}; };
enum AlbumReportOption { enum class AlbumReportOption {
Disable = 0, Disable = 0,
Enable = 1, Enable = 1,
}; };
enum ContentType : u8 { enum class ContentType : u8 {
Screenshot = 0, Screenshot = 0,
Movie = 1, Movie = 1,
ExtraMovie = 3, ExtraMovie = 3,
}; };
enum AlbumStorage : u8 { enum class AlbumStorage : u8 {
NAND = 0, NAND = 0,
SD = 1, SD = 1,
}; };
struct AlbumFileDateTime { struct AlbumFileDateTime {
u16 year; s16 year{};
u8 month; s8 month{};
u8 day; s8 day{};
u8 hour; s8 hour{};
u8 minute; s8 minute{};
u8 second; s8 second{};
u8 uid; s8 uid{};
}; };
static_assert(sizeof(AlbumFileDateTime) == 0x8, "AlbumFileDateTime has incorrect size.");
struct AlbumEntry { struct AlbumEntry {
u64 size; u64 size{};
u64 application_id; u64 application_id{};
AlbumFileDateTime datetime; AlbumFileDateTime datetime{};
AlbumStorage storage; AlbumStorage storage{};
ContentType content; ContentType content{};
u8 padding[6]; INSERT_PADDING_BYTES(6);
}; };
static_assert(sizeof(AlbumEntry) == 0x20, "AlbumEntry has incorrect size.");
struct AlbumFileEntry { struct AlbumFileEntry {
u64 size; u64 size{}; // Size of the entry
u64 hash; u64 hash{}; // AES256 with hardcoded key over AlbumEntry
AlbumFileDateTime datetime; AlbumFileDateTime datetime{};
AlbumStorage storage; AlbumStorage storage{};
ContentType content; ContentType content{};
u8 padding[5]; INSERT_PADDING_BYTES(5);
u8 unknown; u8 unknown{1}; // Set to 1 on official SW
}; };
static_assert(sizeof(AlbumFileEntry) == 0x20, "AlbumFileEntry has incorrect size.");
struct ApplicationAlbumEntry { struct ApplicationAlbumEntry {
u64 size; u64 size{}; // Size of the entry
u64 hash; u64 hash{}; // AES256 with hardcoded key over AlbumEntry
AlbumFileDateTime datetime; AlbumFileDateTime datetime{};
AlbumStorage storage; AlbumStorage storage{};
ContentType content; ContentType content{};
u8 padding[5]; INSERT_PADDING_BYTES(5);
u8 unknown; u8 unknown{1}; // Set to 1 on official SW
}; };
static_assert(sizeof(ApplicationAlbumEntry) == 0x20, "ApplicationAlbumEntry has incorrect size.");
struct ApplicationAlbumFileEntry { struct ApplicationAlbumFileEntry {
ApplicationAlbumEntry entry; ApplicationAlbumEntry entry{};
AlbumFileDateTime datetime; AlbumFileDateTime datetime{};
u64 unknown; u64 unknown{};
}; };
static_assert(sizeof(ApplicationAlbumFileEntry) == 0x30,
"ApplicationAlbumFileEntry has incorrect size.");
/// Registers all Capture services with the specified service manager. /// Registers all Capture services with the specified service manager.
void InstallInterfaces(SM::ServiceManager& sm); void InstallInterfaces(SM::ServiceManager& sm);

View file

@ -1,4 +1,4 @@
// Copyright 2020 yuzu emulator team // Copyright 2020 yuzu Emulator Project
// Licensed under GPLv2 or any later version // Licensed under GPLv2 or any later version
// Refer to the license.txt file included. // Refer to the license.txt file included.

View file

@ -1,4 +1,4 @@
// Copyright 2020 yuzu emulator team // Copyright 2020 yuzu Emulator Project
// Licensed under GPLv2 or any later version // Licensed under GPLv2 or any later version
// Refer to the license.txt file included. // Refer to the license.txt file included.

View file

@ -1,4 +1,4 @@
// Copyright 2020 yuzu emulator team // Copyright 2020 yuzu Emulator Project
// Licensed under GPLv2 or any later version // Licensed under GPLv2 or any later version
// Refer to the license.txt file included. // Refer to the license.txt file included.

View file

@ -1,4 +1,4 @@
// Copyright 2020 yuzu emulator team // Copyright 2020 yuzu Emulator Project
// Licensed under GPLv2 or any later version // Licensed under GPLv2 or any later version
// Refer to the license.txt file included. // Refer to the license.txt file included.

View file

@ -1,4 +1,4 @@
// Copyright 2020 yuzu emulator team // Copyright 2020 yuzu Emulator Project
// Licensed under GPLv2 or any later version // Licensed under GPLv2 or any later version
// Refer to the license.txt file included. // Refer to the license.txt file included.

View file

@ -1,4 +1,4 @@
// Copyright 2020 yuzu emulator team // Copyright 2020 yuzu Emulator Project
// Licensed under GPLv2 or any later version // Licensed under GPLv2 or any later version
// Refer to the license.txt file included. // Refer to the license.txt file included.

View file

@ -1,4 +1,4 @@
// Copyright 2020 yuzu emulator team // Copyright 2020 yuzu Emulator Project
// Licensed under GPLv2 or any later version // Licensed under GPLv2 or any later version
// Refer to the license.txt file included. // Refer to the license.txt file included.

View file

@ -1,4 +1,4 @@
// Copyright 2020 yuzu emulator team // Copyright 2020 yuzu Emulator Project
// Licensed under GPLv2 or any later version // Licensed under GPLv2 or any later version
// Refer to the license.txt file included. // Refer to the license.txt file included.

View file

@ -1,4 +1,4 @@
// Copyright 2020 yuzu emulator team // Copyright 2020 yuzu Emulator Project
// Licensed under GPLv2 or any later version // Licensed under GPLv2 or any later version
// Refer to the license.txt file included. // Refer to the license.txt file included.

View file

@ -1,4 +1,4 @@
// Copyright 2020 yuzu emulator team // Copyright 2020 yuzu Emulator Project
// Licensed under GPLv2 or any later version // Licensed under GPLv2 or any later version
// Refer to the license.txt file included. // Refer to the license.txt file included.

View file

@ -1,4 +1,4 @@
// Copyright 2020 yuzu emulator team // Copyright 2020 yuzu Emulator Project
// Licensed under GPLv2 or any later version // Licensed under GPLv2 or any later version
// Refer to the license.txt file included. // Refer to the license.txt file included.
@ -58,19 +58,25 @@ void CAPS_U::GetAlbumContentsFileListForApplication(Kernel::HLERequestContext& c
// u8 ContentType, two s64s, and an u64 AppletResourceUserId. Returns an output u64 for total // u8 ContentType, two s64s, and an u64 AppletResourceUserId. Returns an output u64 for total
// output entries (which is copied to a s32 by official SW). // output entries (which is copied to a s32 by official SW).
IPC::RequestParser rp{ctx}; IPC::RequestParser rp{ctx};
[[maybe_unused]] const auto application_album_file_entries = rp.PopRaw<std::array<u8, 0x30>>(); const auto pid{rp.Pop<s32>()};
const auto pid = rp.Pop<s32>(); const auto content_type{rp.PopEnum<ContentType>()};
const auto content_type = rp.PopRaw<ContentType>(); const auto start_posix_time{rp.Pop<s64>()};
[[maybe_unused]] const auto start_datetime = rp.PopRaw<AlbumFileDateTime>(); const auto end_posix_time{rp.Pop<s64>()};
[[maybe_unused]] const auto end_datetime = rp.PopRaw<AlbumFileDateTime>(); const auto applet_resource_user_id{rp.Pop<u64>()};
const auto applet_resource_user_id = rp.Pop<u64>();
// TODO: Update this when we implement the album.
// Currently we do not have a method of accessing album entries, set this to 0 for now.
constexpr s32 total_entries{0};
LOG_WARNING(Service_Capture, LOG_WARNING(Service_Capture,
"(STUBBED) called. pid={}, content_type={}, applet_resource_user_id={}", pid, "(STUBBED) called. pid={}, content_type={}, start_posix_time={}, "
content_type, applet_resource_user_id); "end_posix_time={}, applet_resource_user_id={}, total_entries={}",
pid, content_type, start_posix_time, end_posix_time, applet_resource_user_id,
total_entries);
IPC::ResponseBuilder rb{ctx, 3}; IPC::ResponseBuilder rb{ctx, 3};
rb.Push(RESULT_SUCCESS); rb.Push(RESULT_SUCCESS);
rb.Push<s32>(0); rb.Push(total_entries);
} }
} // namespace Service::Capture } // namespace Service::Capture

View file

@ -1,4 +1,4 @@
// Copyright 2020 yuzu emulator team // Copyright 2020 yuzu Emulator Project
// Licensed under GPLv2 or any later version // Licensed under GPLv2 or any later version
// Refer to the license.txt file included. // Refer to the license.txt file included.