diff options
Diffstat (limited to '')
| -rw-r--r-- | src/core/hle/service/am/am.cpp | 86 |
1 files changed, 59 insertions, 27 deletions
diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp index 35481b201..a872bea0c 100644 --- a/src/core/hle/service/am/am.cpp +++ b/src/core/hle/service/am/am.cpp | |||
| @@ -516,31 +516,56 @@ void ICommonStateGetter::GetPerformanceMode(Kernel::HLERequestContext& ctx) { | |||
| 516 | LOG_DEBUG(Service_AM, "called"); | 516 | LOG_DEBUG(Service_AM, "called"); |
| 517 | } | 517 | } |
| 518 | 518 | ||
| 519 | class IStorageAccessor final : public ServiceFramework<IStorageAccessor> { | 519 | class ILibraryAppletAccessor final : public ServiceFramework<ILibraryAppletAccessor> { |
| 520 | public: | 520 | public: |
| 521 | explicit IStorageAccessor(std::vector<u8> buffer) | 521 | explicit ILibraryAppletAccessor(std::shared_ptr<Applets::Applet> applet) |
| 522 | : ServiceFramework("IStorageAccessor"), buffer(std::move(buffer)) { | 522 | : ServiceFramework("ILibraryAppletAccessor"), applet(std::move(applet)) { |
| 523 | // clang-format off | 523 | // clang-format off |
| 524 | static const FunctionInfo functions[] = { | 524 | static const FunctionInfo functions[] = { |
| 525 | {0, &IStorageAccessor::GetSize, "GetSize"}, | 525 | {0, &ILibraryAppletAccessor::GetAppletStateChangedEvent, "GetAppletStateChangedEvent"}, |
| 526 | {10, &IStorageAccessor::Write, "Write"}, | 526 | {1, nullptr, "IsCompleted"}, |
| 527 | {11, &IStorageAccessor::Read, "Read"}, | 527 | {10, &ILibraryAppletAccessor::Start, "Start"}, |
| 528 | {20, nullptr, "RequestExit"}, | ||
| 529 | {25, nullptr, "Terminate"}, | ||
| 530 | {30, &ILibraryAppletAccessor::GetResult, "GetResult"}, | ||
| 531 | {50, nullptr, "SetOutOfFocusApplicationSuspendingEnabled"}, | ||
| 532 | {100, &ILibraryAppletAccessor::PushInData, "PushInData"}, | ||
| 533 | {101, &ILibraryAppletAccessor::PopOutData, "PopOutData"}, | ||
| 534 | {102, nullptr, "PushExtraStorage"}, | ||
| 535 | {103, &ILibraryAppletAccessor::PushInteractiveInData, "PushInteractiveInData"}, | ||
| 536 | {104, &ILibraryAppletAccessor::PopInteractiveOutData, "PopInteractiveOutData"}, | ||
| 537 | {105, nullptr, "GetPopOutDataEvent"}, | ||
| 538 | {106, &ILibraryAppletAccessor::GetPopInteractiveOutDataEvent, "GetPopInteractiveOutDataEvent"}, | ||
| 539 | {110, nullptr, "NeedsToExitProcess"}, | ||
| 540 | {120, nullptr, "GetLibraryAppletInfo"}, | ||
| 541 | {150, nullptr, "RequestForAppletToGetForeground"}, | ||
| 542 | {160, nullptr, "GetIndirectLayerConsumerHandle"}, | ||
| 528 | }; | 543 | }; |
| 529 | // clang-format on | 544 | // clang-format on |
| 530 | 545 | ||
| 531 | RegisterHandlers(functions); | 546 | RegisterHandlers(functions); |
| 547 | |||
| 548 | auto& kernel = Core::System::GetInstance().Kernel(); | ||
| 549 | state_changed_event = Kernel::Event::Create(kernel, Kernel::ResetType::OneShot, | ||
| 550 | "ILibraryAppletAccessor:StateChangedEvent"); | ||
| 532 | } | 551 | } |
| 533 | 552 | ||
| 534 | private: | 553 | private: |
| 535 | std::vector<u8> buffer; | 554 | void GetAppletStateChangedEvent(Kernel::HLERequestContext& ctx) { |
| 555 | state_changed_event->Signal(); | ||
| 536 | 556 | ||
| 537 | void GetSize(Kernel::HLERequestContext& ctx) { | 557 | IPC::ResponseBuilder rb{ctx, 2, 1}; |
| 538 | IPC::ResponseBuilder rb{ctx, 4}; | 558 | rb.Push(RESULT_SUCCESS); |
| 559 | rb.PushCopyObjects(state_changed_event); | ||
| 560 | |||
| 561 | LOG_WARNING(Service_AM, "(STUBBED) called"); | ||
| 562 | } | ||
| 539 | 563 | ||
| 564 | void GetResult(Kernel::HLERequestContext& ctx) { | ||
| 565 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 540 | rb.Push(RESULT_SUCCESS); | 566 | rb.Push(RESULT_SUCCESS); |
| 541 | rb.Push(static_cast<u64>(buffer.size())); | ||
| 542 | 567 | ||
| 543 | LOG_DEBUG(Service_AM, "called"); | 568 | LOG_WARNING(Service_AM, "(STUBBED) called"); |
| 544 | } | 569 | } |
| 545 | 570 | ||
| 546 | void Write(Kernel::HLERequestContext& ctx) { | 571 | void Write(Kernel::HLERequestContext& ctx) { |
| @@ -551,21 +576,25 @@ private: | |||
| 551 | 576 | ||
| 552 | ASSERT(offset + data.size() <= buffer.size()); | 577 | ASSERT(offset + data.size() <= buffer.size()); |
| 553 | 578 | ||
| 554 | std::memcpy(&buffer[offset], data.data(), data.size()); | 579 | void PushInData(Kernel::HLERequestContext& ctx) { |
| 580 | IPC::RequestParser rp{ctx}; | ||
| 581 | storage_stack.push_back(rp.PopIpcInterface<IStorage>()); | ||
| 555 | 582 | ||
| 556 | IPC::ResponseBuilder rb{ctx, 2}; | 583 | IPC::ResponseBuilder rb{ctx, 2}; |
| 557 | rb.Push(RESULT_SUCCESS); | 584 | rb.Push(RESULT_SUCCESS); |
| 558 | 585 | ||
| 559 | LOG_DEBUG(Service_AM, "called, offset={}", offset); | 586 | LOG_DEBUG(Service_AM, "called"); |
| 560 | } | 587 | } |
| 561 | 588 | ||
| 562 | void Read(Kernel::HLERequestContext& ctx) { | 589 | void PopOutData(Kernel::HLERequestContext& ctx) { |
| 563 | IPC::RequestParser rp{ctx}; | 590 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; |
| 591 | rb.Push(RESULT_SUCCESS); | ||
| 592 | rb.PushIpcInterface<IStorage>(std::move(storage_stack.back())); | ||
| 564 | 593 | ||
| 565 | const u64 offset{rp.Pop<u64>()}; | 594 | storage_stack.pop_back(); |
| 566 | const std::size_t size{ctx.GetWriteBufferSize()}; | ||
| 567 | 595 | ||
| 568 | ASSERT(offset + size <= buffer.size()); | 596 | LOG_DEBUG(Service_AM, "called"); |
| 597 | } | ||
| 569 | 598 | ||
| 570 | ctx.WriteBuffer(buffer.data() + offset, size); | 599 | ctx.WriteBuffer(buffer.data() + offset, size); |
| 571 | 600 | ||
| @@ -590,18 +619,21 @@ public: | |||
| 590 | RegisterHandlers(functions); | 619 | RegisterHandlers(functions); |
| 591 | } | 620 | } |
| 592 | 621 | ||
| 593 | private: | 622 | std::shared_ptr<Applets::Applet> applet; |
| 594 | std::vector<u8> buffer; | 623 | std::vector<std::shared_ptr<IStorage>> storage_stack; |
| 624 | std::vector<std::shared_ptr<IStorage>> interactive_storage_stack; | ||
| 625 | Kernel::SharedPtr<Kernel::Event> state_changed_event; | ||
| 626 | Kernel::SharedPtr<Kernel::Event> pop_interactive_out_data_event; | ||
| 627 | }; | ||
| 595 | 628 | ||
| 596 | void Open(Kernel::HLERequestContext& ctx) { | 629 | void IStorage::Open(Kernel::HLERequestContext& ctx) { |
| 597 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; | 630 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; |
| 598 | 631 | ||
| 599 | rb.Push(RESULT_SUCCESS); | 632 | rb.Push(RESULT_SUCCESS); |
| 600 | rb.PushIpcInterface<AM::IStorageAccessor>(buffer); | 633 | rb.PushIpcInterface<IStorageAccessor>(*this); |
| 601 | 634 | ||
| 602 | LOG_DEBUG(Service_AM, "called"); | 635 | LOG_DEBUG(Service_AM, "called"); |
| 603 | } | 636 | } |
| 604 | }; | ||
| 605 | 637 | ||
| 606 | IStorageAccessor::IStorageAccessor(IStorage& storage) | 638 | IStorageAccessor::IStorageAccessor(IStorage& storage) |
| 607 | : ServiceFramework("IStorageAccessor"), backing(storage) { | 639 | : ServiceFramework("IStorageAccessor"), backing(storage) { |