glue_manager.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. // Copyright 2019 yuzu emulator team
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #pragma once
  5. #include <map>
  6. #include <vector>
  7. #include "common/common_types.h"
  8. #include "core/file_sys/romfs_factory.h"
  9. #include "core/hle/result.h"
  10. namespace Service::Glue {
  11. struct ApplicationLaunchProperty {
  12. u64 title_id;
  13. u32 version;
  14. FileSys::StorageId base_game_storage_id;
  15. FileSys::StorageId update_storage_id;
  16. u8 program_index;
  17. u8 reserved;
  18. };
  19. static_assert(sizeof(ApplicationLaunchProperty) == 0x10,
  20. "ApplicationLaunchProperty has incorrect size.");
  21. // A class to manage state related to the arp:w and arp:r services, specifically the registration
  22. // and unregistration of launch and control properties.
  23. class ARPManager {
  24. public:
  25. ARPManager();
  26. ~ARPManager();
  27. // Returns the ApplicationLaunchProperty corresponding to the provided title ID if it was
  28. // previously registered, otherwise ERR_NOT_REGISTERED if it was never registered or
  29. // ERR_INVALID_PROCESS_ID if the title ID is 0.
  30. ResultVal<ApplicationLaunchProperty> GetLaunchProperty(u64 title_id) const;
  31. // Returns a vector of the raw bytes of NACP data (necessarily 0x4000 in size) corresponding to
  32. // the provided title ID if it was previously registered, otherwise ERR_NOT_REGISTERED if it was
  33. // never registered or ERR_INVALID_PROCESS_ID if the title ID is 0.
  34. ResultVal<std::vector<u8>> GetControlProperty(u64 title_id) const;
  35. // Adds a new entry to the internal database with the provided parameters, returning
  36. // ERR_INVALID_ACCESS if attempting to re-register a title ID without an intermediate Unregister
  37. // step, and ERR_INVALID_PROCESS_ID if the title ID is 0.
  38. ResultCode Register(u64 title_id, ApplicationLaunchProperty launch, std::vector<u8> control);
  39. // Removes the registration for the provided title ID from the database, returning
  40. // ERR_NOT_REGISTERED if it doesn't exist in the database and ERR_INVALID_PROCESS_ID if the
  41. // title ID is 0.
  42. ResultCode Unregister(u64 title_id);
  43. // Removes all entries from the database, always succeeds. Should only be used when resetting
  44. // system state.
  45. void ResetAll();
  46. private:
  47. struct MapEntry;
  48. std::map<u64, MapEntry> entries;
  49. };
  50. } // namespace Service::Glue