diff --git a/src/core/hle/service/ac/ac.cpp b/src/core/hle/service/ac/ac.cpp index eb5318da0..60507cf75 100644 --- a/src/core/hle/service/ac/ac.cpp +++ b/src/core/hle/service/ac/ac.cpp @@ -192,65 +192,68 @@ void Module::Interface::ScanAPs(Kernel::HLERequestContext& ctx) { // Arg 0 is Header code, which is ignored // Arg 1 is Size const u32 size = rp.Pop(); - LOG_WARNING(Service_AC, "Size: {}", size); // Arg 2 is CallingPID value (PID Header) // Arg 3 is PID const u32 pid = rp.PopPID(); - LOG_WARNING(Service_AC, "PID: {}", pid); std::shared_ptr thread = ctx.ClientThread(); auto current_process = Core::System::GetInstance().Kernel().GetCurrentProcess(); Memory::MemorySystem& memory = Core::System::GetInstance().Memory(); - LOG_WARNING(Service_AC, "Retrieved thread, process and memory"); // According to 3dbrew, the output structure pointer is located 0x100 bytes after the beginning // of cmd_buff VAddr cmd_addr = thread->GetCommandBufferAddress(); VAddr buffer_vaddr = cmd_addr + 0x100; const u32 descr = memory.Read32(buffer_vaddr); - LOG_WARNING(Service_AC, "Buffer descriptor: 0x{:08X}, expected: 0x{:08X}", descr, (size << 14) | 2); ASSERT(descr == ((size << 14) | 2)); // preliminary check const VAddr output_buffer = memory.Read32(buffer_vaddr + 0x4); // address to output buffer - LOG_WARNING(Service_AC, "Buffer VAddr: 0x{:08X}", output_buffer); + // At this point, we have all the input given to us + // 3dbrew stated that AC:ScanAPs relies on NWM_INF:RecvBeaconBroadcastData to obtain + // info on all nearby APs + // Thus this method prepares to call that service + // Since I do not know the proper way, I copied various pieces of code that seemed to work + // MAC address gets split, but I am not sure this is the proper way to do so Network::MacAddress mac = Network::BroadcastMac; u32 mac1 = (mac[0] << 8) | (mac[1]); u32 mac2 = (mac[2] << 24) | (mac[3] << 16) | (mac[4] << 8) | (mac[5]); std::array cmd_buf; - cmd_buf[0] = 0x000603C4; - cmd_buf[1] = size; + cmd_buf[0] = 0x000603C4; // Command header + cmd_buf[1] = size; // size of buffer cmd_buf[2] = 0; // dummy data cmd_buf[3] = 0; // dummy data cmd_buf[4] = mac1; cmd_buf[5] = mac2; - cmd_buf[16] = 0; - cmd_buf[17] = 0; // set to 0 to ignore it + cmd_buf[16] = 0; // 0x0 handle header + cmd_buf[17] = 0; // set to 0 to ignore it cmd_buf[18] = (size << 4) | 12; // should be considered correct for mapped buffer - cmd_buf[19] = output_buffer; - - LOG_WARNING(Service_AC, "Finished setting up command buffer"); + cmd_buf[19] = output_buffer; // address of output buffer + // Create context for call to NWM_INF::RecvBeaconBroadcastData auto context = std::make_shared(Core::System::GetInstance().Kernel(), ctx.Session(), thread); - LOG_WARNING(Service_AC, "Created context"); context->PopulateFromIncomingCommandBuffer(cmd_buf.data(), current_process); - LOG_WARNING(Service_AC, "Finished setting up context"); - + // Retrieve service from service manager auto nwm_inf = Core::System::GetInstance().ServiceManager().GetService("nwm::INF"); LOG_WARNING(Service_AC, "Calling NWM_INF::RecvBeaconBroadcastData"); + // Perform delegated task nwm_inf->HandleSyncRequest(*context); LOG_WARNING(Service_AC, "Returned to AC::ScanAPs"); + // Response should be // 0: Header Code (ignored) // 1: Result Code (Success/Unknown/etc.) // 2: ¿Parsed? beacon data + + // Since the way to parse is yet unknown, it is currently only passing on raw IPC::RequestBuilder rb = rp.MakeBuilder(1, 2); IPC::RequestParser rp2(*context); rb.Push(rp2.Pop()); + // Mapped buffer at virtual address output_buffer Kernel::MappedBuffer mapped_buffer = rp2.PopMappedBuffer(); rb.PushMappedBuffer(mapped_buffer); LOG_WARNING(Service_AC, "(STUBBED) called, pid={}", pid); diff --git a/src/core/hle/service/nwm/nwm_inf.cpp b/src/core/hle/service/nwm/nwm_inf.cpp index 2257b5ef1..e4e7c2c45 100644 --- a/src/core/hle/service/nwm/nwm_inf.cpp +++ b/src/core/hle/service/nwm/nwm_inf.cpp @@ -21,9 +21,12 @@ namespace Service::NWM { void NWM_INF::RecvBeaconBroadcastData(Kernel::HLERequestContext& ctx) { IPC::RequestParser rp(ctx); - LOG_WARNING(Service_NWM, "Started NWM_INF::RecvBeaconBroadcastData"); + // Using a standalone implementation requires copying private methods as well + // I am not sure if that should be done - // adding in extra context value for transition from INF to UDS + // Replacing header, + // adding in extra context value + // and replacing dummy value with 2 dummy id's std::array cmd_buf; cmd_buf[0] = 0x000F0404; int i; @@ -37,27 +40,24 @@ void NWM_INF::RecvBeaconBroadcastData(Kernel::HLERequestContext& ctx) { cmd_buf[i] = rp.Pop(); } + // Prepare for call to NWM_UDS std::shared_ptr thread = ctx.ClientThread(); auto current_process = thread->owner_process.lock(); auto context = std::make_shared(Core::System::GetInstance().Kernel(), ctx.Session(), thread); context->PopulateFromIncomingCommandBuffer(cmd_buf.data(), current_process); - LOG_WARNING(Service_NWM, "Finished converting context"); auto nwm_uds = Core::System::GetInstance().ServiceManager().GetService("nwm::UDS"); - LOG_WARNING(Service_NWM, "Calling NWM_UDS::RecvBeaconBroadcastData"); nwm_uds->HandleSyncRequest(*context); LOG_WARNING(Service_NWM, "Returned to NWM_INF::RecvBeaconBroadcastData"); + // Push results of delegated call to caller IPC::RequestParser rp2(*context); - IPC::RequestBuilder rb = rp.MakeBuilder(1, 2); rb.Push(rp2.Pop()); rb.PushMappedBuffer(rp2.PopMappedBuffer()); - - LOG_WARNING(Service_NWM, "Finished NWM_INF::RecvBeaconBroadcastData"); } NWM_INF::NWM_INF() : ServiceFramework("nwm::INF") {