| 133 | } |
| 134 | |
| 135 | Result SetupTargetHeap(const bool is_auto_gameplay_recording, const u64 applet_heap_size, const u64 applet_heap_reservation_size, u8 *&out_heap_addr, u64 &out_heap_size) { |
| 136 | void *heap_addr = nullptr; |
| 137 | auto heap_size = ComputeMaximumHeapSize(is_auto_gameplay_recording); |
| 138 | |
| 139 | if(SelfIsApplet()) { |
| 140 | if(applet_heap_size > 0) { |
| 141 | const auto requested_heap_size = AlignUp<2_MB>(applet_heap_size); |
| 142 | if(heap_size > requested_heap_size) { |
| 143 | heap_size = requested_heap_size; |
| 144 | } |
| 145 | } |
| 146 | else if(applet_heap_reservation_size > 0) { |
| 147 | const auto reserved_heap_size = AlignUp<2_MB>(applet_heap_reservation_size); |
| 148 | if(heap_size > reserved_heap_size) { |
| 149 | heap_size -= reserved_heap_size; |
| 150 | } |
| 151 | } |
| 152 | } |
| 153 | |
| 154 | const auto rc = svcSetHeapSize(&heap_addr, heap_size); |
| 155 | if(R_FAILED(rc) || (heap_addr == nullptr)) { |
| 156 | UL_RC_ASSERT(hbloader::ResultAllocateHeapFailure); |
| 157 | } |
| 158 | |
| 159 | out_heap_addr = reinterpret_cast<u8*>(heap_addr); |
| 160 | out_heap_size = heap_size; |
| 161 | return ResultSuccess; |
| 162 | } |
| 163 | |
| 164 | Result InitializeFsdev() { |
| 165 | UL_RC_TRY(smInitialize()); |
no test coverage detected