diff options
| author | 2017-08-07 16:09:55 -0500 | |
|---|---|---|
| committer | 2017-08-07 16:09:55 -0500 | |
| commit | 177e8ce655953e22b5304070694f2d2d6e65dda9 (patch) | |
| tree | 280df5c3348497527bb7171aceb7fb9775c9242a /src | |
| parent | Services/APT: Use an array to hold data about the 4 possible concurrent apple... (diff) | |
| download | yuzu-177e8ce655953e22b5304070694f2d2d6e65dda9.tar.gz yuzu-177e8ce655953e22b5304070694f2d2d6e65dda9.tar.xz yuzu-177e8ce655953e22b5304070694f2d2d6e65dda9.zip | |
Services/APT: Use the AppletAttributes union directly when dealing with applet attrs.
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/hle/service/apt/apt.cpp | 34 |
1 files changed, 15 insertions, 19 deletions
diff --git a/src/core/hle/service/apt/apt.cpp b/src/core/hle/service/apt/apt.cpp index 9cfa9efde..58d94768c 100644 --- a/src/core/hle/service/apt/apt.cpp +++ b/src/core/hle/service/apt/apt.cpp | |||
| @@ -60,11 +60,20 @@ enum class AppletSlot : u8 { | |||
| 60 | Error, | 60 | Error, |
| 61 | }; | 61 | }; |
| 62 | 62 | ||
| 63 | union AppletAttributes { | ||
| 64 | u32 raw; | ||
| 65 | |||
| 66 | BitField<0, 3, u32> applet_pos; | ||
| 67 | |||
| 68 | AppletAttributes() : raw(0) {} | ||
| 69 | AppletAttributes(u32 attributes) : raw(attributes) {} | ||
| 70 | }; | ||
| 71 | |||
| 63 | struct AppletSlotData { | 72 | struct AppletSlotData { |
| 64 | AppletId applet_id; | 73 | AppletId applet_id; |
| 65 | AppletSlot slot; | 74 | AppletSlot slot; |
| 66 | bool registered; | 75 | bool registered; |
| 67 | u32 attributes; | 76 | AppletAttributes attributes; |
| 68 | Kernel::SharedPtr<Kernel::Event> notification_event; | 77 | Kernel::SharedPtr<Kernel::Event> notification_event; |
| 69 | Kernel::SharedPtr<Kernel::Event> parameter_event; | 78 | Kernel::SharedPtr<Kernel::Event> parameter_event; |
| 70 | }; | 79 | }; |
| @@ -72,19 +81,6 @@ struct AppletSlotData { | |||
| 72 | // Holds data about the concurrently running applets in the system. | 81 | // Holds data about the concurrently running applets in the system. |
| 73 | static std::array<AppletSlotData, NumAppletSlot> applet_slots = {}; | 82 | static std::array<AppletSlotData, NumAppletSlot> applet_slots = {}; |
| 74 | 83 | ||
| 75 | union AppletAttributes { | ||
| 76 | u32 raw; | ||
| 77 | |||
| 78 | BitField<0, 3, u32> applet_pos; | ||
| 79 | |||
| 80 | AppletAttributes(u32 attributes) : raw(attributes) {} | ||
| 81 | }; | ||
| 82 | |||
| 83 | // Helper function to extract the AppletPos from the lower bits of the applet attributes | ||
| 84 | static u32 GetAppletPos(AppletAttributes attributes) { | ||
| 85 | return attributes.applet_pos; | ||
| 86 | } | ||
| 87 | |||
| 88 | // This overload returns nullptr if no applet with the specified id has been started. | 84 | // This overload returns nullptr if no applet with the specified id has been started. |
| 89 | static AppletSlotData* GetAppletSlotData(AppletId id) { | 85 | static AppletSlotData* GetAppletSlotData(AppletId id) { |
| 90 | auto GetSlot = [](AppletSlot slot) -> AppletSlotData* { | 86 | auto GetSlot = [](AppletSlot slot) -> AppletSlotData* { |
| @@ -118,7 +114,7 @@ static AppletSlotData* GetAppletSlotData(AppletId id) { | |||
| 118 | if (slot->applet_id == AppletId::None) | 114 | if (slot->applet_id == AppletId::None) |
| 119 | return nullptr; | 115 | return nullptr; |
| 120 | 116 | ||
| 121 | u32 applet_pos = GetAppletPos(slot->attributes); | 117 | u32 applet_pos = slot->attributes.applet_pos; |
| 122 | 118 | ||
| 123 | if (id == AppletId::AnyLibraryApplet && applet_pos == static_cast<u32>(AppletPos::Library)) | 119 | if (id == AppletId::AnyLibraryApplet && applet_pos == static_cast<u32>(AppletPos::Library)) |
| 124 | return slot; | 120 | return slot; |
| @@ -146,13 +142,13 @@ static AppletSlotData* GetAppletSlotData(AppletId id) { | |||
| 146 | return nullptr; | 142 | return nullptr; |
| 147 | } | 143 | } |
| 148 | 144 | ||
| 149 | static AppletSlotData* GetAppletSlotData(u32 attributes) { | 145 | static AppletSlotData* GetAppletSlotData(AppletAttributes attributes) { |
| 150 | // Mapping from AppletPos to AppletSlot | 146 | // Mapping from AppletPos to AppletSlot |
| 151 | static constexpr std::array<AppletSlot, 6> applet_position_slots = { | 147 | static constexpr std::array<AppletSlot, 6> applet_position_slots = { |
| 152 | AppletSlot::Application, AppletSlot::LibraryApplet, AppletSlot::SystemApplet, | 148 | AppletSlot::Application, AppletSlot::LibraryApplet, AppletSlot::SystemApplet, |
| 153 | AppletSlot::LibraryApplet, AppletSlot::Error, AppletSlot::LibraryApplet}; | 149 | AppletSlot::LibraryApplet, AppletSlot::Error, AppletSlot::LibraryApplet}; |
| 154 | 150 | ||
| 155 | u32 applet_pos = GetAppletPos(attributes); | 151 | u32 applet_pos = attributes.applet_pos; |
| 156 | if (applet_pos >= applet_position_slots.size()) | 152 | if (applet_pos >= applet_position_slots.size()) |
| 157 | return nullptr; | 153 | return nullptr; |
| 158 | 154 | ||
| @@ -194,7 +190,7 @@ void Initialize(Service::Interface* self) { | |||
| 194 | } | 190 | } |
| 195 | 191 | ||
| 196 | slot_data->applet_id = static_cast<AppletId>(app_id); | 192 | slot_data->applet_id = static_cast<AppletId>(app_id); |
| 197 | slot_data->attributes = attributes; | 193 | slot_data->attributes.raw = attributes; |
| 198 | 194 | ||
| 199 | IPC::RequestBuilder rb = rp.MakeBuilder(1, 3); | 195 | IPC::RequestBuilder rb = rp.MakeBuilder(1, 3); |
| 200 | rb.Push(RESULT_SUCCESS); | 196 | rb.Push(RESULT_SUCCESS); |
| @@ -1020,7 +1016,7 @@ void Init() { | |||
| 1020 | auto& slot_data = applet_slots[slot]; | 1016 | auto& slot_data = applet_slots[slot]; |
| 1021 | slot_data.slot = static_cast<AppletSlot>(slot); | 1017 | slot_data.slot = static_cast<AppletSlot>(slot); |
| 1022 | slot_data.applet_id = AppletId::None; | 1018 | slot_data.applet_id = AppletId::None; |
| 1023 | slot_data.attributes = 0; | 1019 | slot_data.attributes.raw = 0; |
| 1024 | slot_data.registered = false; | 1020 | slot_data.registered = false; |
| 1025 | slot_data.notification_event = | 1021 | slot_data.notification_event = |
| 1026 | Kernel::Event::Create(Kernel::ResetType::OneShot, "APT:Notification"); | 1022 | Kernel::Event::Create(Kernel::ResetType::OneShot, "APT:Notification"); |