2019-06-25 01:17:13 +02:00
|
|
|
// Copyright 2019 yuzu emulator team
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2019-06-26 04:25:10 +02:00
|
|
|
#include <map>
|
|
|
|
#include <vector>
|
|
|
|
#include "common/common_types.h"
|
2019-06-25 01:17:13 +02:00
|
|
|
#include "core/file_sys/control_metadata.h"
|
|
|
|
#include "core/file_sys/romfs_factory.h"
|
|
|
|
#include "core/hle/result.h"
|
|
|
|
|
|
|
|
namespace Service::Glue {
|
|
|
|
|
|
|
|
struct ApplicationLaunchProperty {
|
|
|
|
u64 title_id;
|
|
|
|
u32 version;
|
|
|
|
FileSys::StorageId base_game_storage_id;
|
|
|
|
FileSys::StorageId update_storage_id;
|
2019-06-26 04:25:10 +02:00
|
|
|
u8 program_index;
|
|
|
|
u8 reserved;
|
2019-06-25 01:17:13 +02:00
|
|
|
};
|
|
|
|
static_assert(sizeof(ApplicationLaunchProperty) == 0x10,
|
|
|
|
"ApplicationLaunchProperty has incorrect size.");
|
|
|
|
|
2019-06-26 04:25:10 +02:00
|
|
|
// A class to manage state related to the arp:w and arp:r services, specifically the registration
|
|
|
|
// and unregistration of launch and control properties.
|
2019-06-25 01:17:13 +02:00
|
|
|
class ARPManager {
|
|
|
|
public:
|
|
|
|
ARPManager();
|
|
|
|
~ARPManager();
|
|
|
|
|
2019-06-26 04:25:10 +02:00
|
|
|
// Returns the ApplicationLaunchProperty corresponding to the provided title ID if it was
|
|
|
|
// previously registered, otherwise ERR_NOT_REGISTERED if it was never registered or
|
|
|
|
// ERR_INVALID_PROCESS_ID if the title ID is 0.
|
2019-06-25 01:17:13 +02:00
|
|
|
ResultVal<ApplicationLaunchProperty> GetLaunchProperty(u64 title_id) const;
|
2019-06-26 04:25:10 +02:00
|
|
|
|
|
|
|
// Returns a vector of the raw bytes of NACP data (necessarily 0x4000 in size) corresponding to
|
|
|
|
// the provided title ID if it was previously registered, otherwise ERR_NOT_REGISTERED if it was
|
|
|
|
// never registered or ERR_INVALID_PROCESS_ID if the title ID is 0.
|
2019-06-25 01:17:13 +02:00
|
|
|
ResultVal<std::vector<u8>> GetControlProperty(u64 title_id) const;
|
|
|
|
|
2019-06-26 04:25:10 +02:00
|
|
|
// Adds a new entry to the internal database with the provided parameters, returning
|
|
|
|
// ERR_INVALID_ACCESS if attempting to re-register a title ID without an intermediate Unregister
|
|
|
|
// step, and ERR_INVALID_PROCESS_ID if the title ID is 0.
|
2019-06-25 01:17:13 +02:00
|
|
|
ResultCode Register(u64 title_id, ApplicationLaunchProperty launch, std::vector<u8> control);
|
|
|
|
|
2019-06-26 04:25:10 +02:00
|
|
|
// Removes the registration for the provided title ID from the database, returning
|
|
|
|
// ERR_NOT_REGISTERED if it doesn't exist in the database and ERR_INVALID_PROCESS_ID if the
|
|
|
|
// title ID is 0.
|
2019-06-25 01:17:13 +02:00
|
|
|
ResultCode Unregister(u64 title_id);
|
|
|
|
|
2019-06-26 04:25:10 +02:00
|
|
|
// Removes all entries from the database, always succeeds. Should only be used when resetting
|
|
|
|
// system state.
|
2019-06-25 01:17:13 +02:00
|
|
|
void ResetAll();
|
|
|
|
|
|
|
|
private:
|
2019-06-26 04:25:10 +02:00
|
|
|
struct MapEntry;
|
2019-06-25 01:17:13 +02:00
|
|
|
std::map<u64, MapEntry> entries;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Service::Glue
|