mirror of
https://github.com/Lime3DS/Lime3DS.git
synced 2026-04-10 03:11:29 -06:00
Squashed commit of the following:
commitc6f34babb7Author: PTRCoder <pj.de.bruijne@gmail.com> Date: Sat Aug 24 17:04:37 2024 +0200 Undo unnecessary change to nwm_uds.cpp commit219cc83c41Author: PTRCoder <pj.de.bruijne@gmail.com> Date: Sat Aug 24 16:46:11 2024 +0200 Fixed remaining coding style errors commit5f00bb04c7Author: PTRCoder <pj.de.bruijne@gmail.com> Date: Sat Aug 24 16:43:42 2024 +0200 Removed log messages commitd469c6b583Author: PTRCoder <pj.de.bruijne@gmail.com> Date: Sat Aug 24 16:42:49 2024 +0200 Fixed coding style errors commit60f7dbd4f8Author: PTRCoder <pj.de.bruijne@gmail.com> Date: Sat Aug 24 15:18:03 2024 +0200 Potential fix for wrongly storing mac commit1ac5500fffAuthor: PTRCoder <pj.de.bruijne@gmail.com> Date: Sat Aug 24 14:58:57 2024 +0200 Fixed format error commitc2d1819609Author: PTRCoder <pj.de.bruijne@gmail.com> Date: Sat Aug 24 14:50:22 2024 +0200 Truly fixed log message this time commita36d12d3f4Author: PTRCoder <pj.de.bruijne@gmail.com> Date: Sat Aug 24 14:44:44 2024 +0200 Fixed log message error commitc00705f9a4Author: PTRCoder <pj.de.bruijne@gmail.com> Date: Sat Aug 24 14:34:38 2024 +0200 Added log message for checking MAC address commitc4f6bffd91Author: PTRCoder <pj.de.bruijne@gmail.com> Date: Sat Aug 24 14:31:31 2024 +0200 Added forgotten log message commitd461a44e8bAuthor: PTRCoder <pj.de.bruijne@gmail.com> Date: Sat Aug 24 14:14:59 2024 +0200 Added assert statement as sanity check commitc24b0c2e88Author: PTRCoder <pj.de.bruijne@gmail.com> Date: Sat Aug 24 14:14:47 2024 +0200 Added temp loggers for tracking where error occurs commit923d1d30daAuthor: PTRCoder <pj.de.bruijne@gmail.com> Date: Sat Aug 24 13:42:39 2024 +0200 Removed now-redundant log messages and updated comments commit471efa4c8cAuthor: PTRCoder <pj.de.bruijne@gmail.com> Date: Sat Aug 24 12:42:23 2024 +0200 Changed retrieval of values to be dependent on VAddr instead of pointer commitdd16c0b6a0Author: PTRCoder <pj.de.bruijne@gmail.com> Date: Sat Aug 24 00:48:49 2024 +0200 Added extra log messages for debugging commit97c856b2b5Author: PTRCoder <pj.de.bruijne@gmail.com> Date: Sat Aug 24 00:22:23 2024 +0200 Fixed casting error commit1dd28eedc5Author: PTRCoder <pj.de.bruijne@gmail.com> Date: Sat Aug 24 00:13:26 2024 +0200 Fixed missing call to Kernel() commit40ca69fafdAuthor: PTRCoder <pj.de.bruijne@gmail.com> Date: Sat Aug 24 00:01:21 2024 +0200 Fixed MemorySystem retrieval commitbb08716752Author: PTRCoder <pj.de.bruijne@gmail.com> Date: Fri Aug 23 23:57:24 2024 +0200 Fixed lingering remnant of old value commitd76311bb1bAuthor: PTRCoder <pj.de.bruijne@gmail.com> Date: Fri Aug 23 23:56:44 2024 +0200 Fixed missing argument commit01655fbbb0Author: PTRCoder <pj.de.bruijne@gmail.com> Date: Fri Aug 23 23:44:16 2024 +0200 Added retrieval of VAddr from input commit3f76dd3678Author: PTRCoder <pj.de.bruijne@gmail.com> Date: Fri Aug 23 23:42:49 2024 +0200 Revert independency of UDS commit28021f5578Author: PTRCoder <pj.de.bruijne@gmail.com> Date: Fri Aug 23 23:06:37 2024 +0200 Fixed NWM_INF implementation reference to NWM_UDS method commitca85f92e0eAuthor: PTRCoder <pj.de.bruijne@gmail.com> Date: Fri Aug 23 23:06:21 2024 +0200 Fixed debug log message commita061a3dcecAuthor: PTRCoder <pj.de.bruijne@gmail.com> Date: Fri Aug 23 22:14:36 2024 +0200 Updated include statements commit2fd28a883dAuthor: PTRCoder <pj.de.bruijne@gmail.com> Date: Fri Aug 23 21:51:02 2024 +0200 Removed dependency on NWM_UDS commitb5d616bbedAuthor: PTRCoder <pj.de.bruijne@gmail.com> Date: Fri Aug 23 21:17:13 2024 +0200 Fixed wrong dummy data commit60ee7abc38Author: PTRCoder <pj.de.bruijne@gmail.com> Date: Fri Aug 23 20:56:11 2024 +0200 Potential fix of cmd buffer header commite47d9af750Author: PTRCoder <pj.de.bruijne@gmail.com> Date: Fri Aug 23 19:54:04 2024 +0200 Additional logging commitd5d0301702Author: PTRCoder <pj.de.bruijne@gmail.com> Date: Fri Aug 23 19:36:55 2024 +0200 Added temp logging for debugging commita41fc80eabAuthor: PTRCoder <pj.de.bruijne@gmail.com> Date: Fri Aug 23 18:59:48 2024 +0200 Fixed use of mapped buffer commitf88ebb65a3Author: PTRCoder <pj.de.bruijne@gmail.com> Date: Fri Aug 23 18:51:48 2024 +0200 Reverted 4th value to unknown commitb1d1757eaaAuthor: PTRCoder <pj.de.bruijne@gmail.com> Date: Fri Aug 23 17:26:24 2024 +0200 Updated includes commit60c453b5bbAuthor: PTRCoder <pj.de.bruijne@gmail.com> Date: Fri Aug 23 17:21:11 2024 +0200 Fixed argument commitb7777a7b47Author: PTRCoder <pj.de.bruijne@gmail.com> Date: Fri Aug 23 17:00:49 2024 +0200 Added include commit4b3ac391d8Author: PTRCoder <pj.de.bruijne@gmail.com> Date: Fri Aug 23 16:53:56 2024 +0200 Fixed wrong arguments commit13f32bd384Author: PTRCoder <pj.de.bruijne@gmail.com> Date: Fri Aug 23 16:33:54 2024 +0200 Fixed call return value commit826d6bed2dAuthor: PTRCoder <pj.de.bruijne@gmail.com> Date: Fri Aug 23 16:32:37 2024 +0200 Changed implementation to rely on parser instead of raw commit5dea8a125bAuthor: PTRCoder <pj.de.bruijne@gmail.com> Date: Fri Aug 23 16:00:35 2024 +0200 Moved kernel retrieval to argument commitbb4de89652Author: PTRCoder <pj.de.bruijne@gmail.com> Date: Fri Aug 23 15:50:37 2024 +0200 Fixed method call commit8b9e04c541Author: PTRCoder <pj.de.bruijne@gmail.com> Date: Fri Aug 23 15:48:58 2024 +0200 Fixed type name commit29fc438086Author: PTRCoder <pj.de.bruijne@gmail.com> Date: Fri Aug 23 15:41:35 2024 +0200 Fixed includes commita6fe44f81fAuthor: PTRCoder <pj.de.bruijne@gmail.com> Date: Fri Aug 23 15:41:29 2024 +0200 Fixed method name commit67380edbc9Author: PTRCoder <pj.de.bruijne@gmail.com> Date: Fri Aug 23 15:41:09 2024 +0200 Fixed method call commitbabec1bb5cAuthor: PTRCoder <pj.de.bruijne@gmail.com> Date: Fri Aug 23 15:34:32 2024 +0200 Fixed kernel reference commit6238f52819Author: PTRCoder <pj.de.bruijne@gmail.com> Date: Fri Aug 23 15:30:10 2024 +0200 Fixed missing namespace commitc4a99ccbe9Author: PTRCoder <pj.de.bruijne@gmail.com> Date: Fri Aug 23 15:29:29 2024 +0200 Fixed missing argument commit916849691bAuthor: PTRCoder <pj.de.bruijne@gmail.com> Date: Fri Aug 23 15:26:39 2024 +0200 Fixed wrong mac commit7a997ea8aeAuthor: PTRCoder <pj.de.bruijne@gmail.com> Date: Fri Aug 23 15:19:13 2024 +0200 Potentially fixed calling NWM_INF commit320a82bb5dAuthor: PTRCoder <pj.de.bruijne@gmail.com> Date: Fri Aug 23 15:05:24 2024 +0200 Potential fix for calling NWM_UDS version commit0b0534400dAuthor: PTRCoder <pj.de.bruijne@gmail.com> Date: Fri Aug 23 13:56:05 2024 +0200 Added include for NWM_UDS commitd61dfdaf2eAuthor: PTRCoder <pj.de.bruijne@gmail.com> Date: Fri Aug 23 13:51:03 2024 +0200 Fixed cast to u32 and dummy value commita14e398157Author: PTRCoder <pj.de.bruijne@gmail.com> Date: Fri Aug 23 13:50:17 2024 +0200 Added correct transition from INF to UDS commit54e4da1753Author: PTRCoder <pj.de.bruijne@gmail.com> Date: Fri Aug 23 13:30:13 2024 +0200 Initial full ScanAPs implementation commitaeb1e224f3Author: PTRCoder <pj.de.bruijne@gmail.com> Date: Fri Aug 23 13:18:17 2024 +0200 Fixed member reference commitc3b1beae1cAuthor: PTRCoder <pj.de.bruijne@gmail.com> Date: Fri Aug 23 13:11:30 2024 +0200 Readded NWM_UDS header commit6b03ca58a2Author: PTRCoder <pj.de.bruijne@gmail.com> Date: Fri Aug 23 12:44:40 2024 +0200 Updated include statements commit36c4adf431Author: PTRCoder <pj.de.bruijne@gmail.com> Date: Fri Aug 23 00:58:25 2024 +0200 Potential member reference fix commit6d28737856Author: PTRCoder <pj.de.bruijne@gmail.com> Date: Fri Aug 23 00:48:51 2024 +0200 Fixed missing void return type commit14eb312678Author: PTRCoder <pj.de.bruijne@gmail.com> Date: Fri Aug 23 00:14:41 2024 +0200 Using correct way to call UDS service commit2acc2a35a9Author: PTRCoder <pj.de.bruijne@gmail.com> Date: Thu Aug 22 22:39:15 2024 +0200 Updated API commitd204bfa05cAuthor: PTRCoder <pj.de.bruijne@gmail.com> Date: Thu Aug 22 22:38:49 2024 +0200 Initial NWM_INF::RecvBeaconBroadcastData implementation commit01baadf7a4Author: PTRCoder <pj.de.bruijne@gmail.com> Date: Thu Aug 22 19:23:17 2024 +0200 Included member type commit36f416469fAuthor: PTRCoder <pj.de.bruijne@gmail.com> Date: Thu Aug 22 19:06:52 2024 +0200 Coding style fixes commit4e73a1d057Author: PTRCoder <pj.de.bruijne@gmail.com> Date: Thu Aug 22 19:02:37 2024 +0200 Starting tests
This commit is contained in:
parent
c89cdb597d
commit
f182ea3f2c
@ -24,6 +24,8 @@
|
||||
#include "network/network.h"
|
||||
#include "network/room.h"
|
||||
#include "core/memory.h"
|
||||
#include "network/network.h"
|
||||
#include "network/room.h"
|
||||
|
||||
SERIALIZE_EXPORT_IMPL(Service::AC::Module)
|
||||
SERVICE_CONSTRUCT_IMPL(Service::AC::Module)
|
||||
@ -192,65 +194,62 @@ void Module::Interface::ScanAPs(Kernel::HLERequestContext& ctx) {
|
||||
// Arg 0 is Header code, which is ignored
|
||||
// Arg 1 is Size
|
||||
const u32 size = rp.Pop<u32>();
|
||||
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<Kernel::Thread> 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
|
||||
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<u32, IPC::COMMAND_BUFFER_LENGTH + 2 * IPC::MAX_STATIC_BUFFERS> cmd_buf;
|
||||
cmd_buf[0] = 0x000603C4;
|
||||
cmd_buf[1] = size;
|
||||
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[0] = 0x000603C4; // Command header
|
||||
cmd_buf[1] = size; // size of buffer
|
||||
cmd_buf[2] = 0; // dummy data
|
||||
cmd_buf[3] = 0; // dummy data
|
||||
std::memcpy(cmd_buf.data() + 4, mac.data(), sizeof(Network::MacAddress));
|
||||
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;
|
||||
cmd_buf[19] = output_buffer; // address of output buffer
|
||||
|
||||
LOG_WARNING(Service_AC, "Finished setting up command buffer");
|
||||
|
||||
auto context =
|
||||
std::make_shared<Kernel::HLERequestContext>(Core::System::GetInstance().Kernel(),
|
||||
ctx.Session(), thread);
|
||||
LOG_WARNING(Service_AC, "Created context");
|
||||
// Create context for call to NWM_INF::RecvBeaconBroadcastData
|
||||
auto context = std::make_shared<Kernel::HLERequestContext>(Core::System::GetInstance().Kernel(),
|
||||
ctx.Session(), thread);
|
||||
context->PopulateFromIncomingCommandBuffer(cmd_buf.data(), current_process);
|
||||
|
||||
LOG_WARNING(Service_AC, "Finished setting up context");
|
||||
|
||||
auto nwm_inf =
|
||||
Core::System::GetInstance().ServiceManager().GetService<Service::NWM::NWM_INF>("nwm::INF");
|
||||
LOG_WARNING(Service_AC, "Calling NWM_INF::RecvBeaconBroadcastData");
|
||||
// Retrieve service from service manager
|
||||
auto nwm_inf =
|
||||
Core::System::GetInstance().ServiceManager().GetService<Service::NWM::NWM_INF>("nwm::INF");
|
||||
// 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<u32>());
|
||||
// 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);
|
||||
|
||||
@ -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<u32, IPC::COMMAND_BUFFER_LENGTH + 2 * IPC::MAX_STATIC_BUFFERS> cmd_buf;
|
||||
cmd_buf[0] = 0x000F0404;
|
||||
int i;
|
||||
@ -31,33 +34,28 @@ void NWM_INF::RecvBeaconBroadcastData(Kernel::HLERequestContext& ctx) {
|
||||
cmd_buf[i] = rp.Pop<u32>();
|
||||
}
|
||||
rp.Pop<u32>();
|
||||
cmd_buf[15] = 0; // dummy wlan_comm_id
|
||||
cmd_buf[16] = 0; // dummy id
|
||||
cmd_buf[15] = 0; // dummy wlan_comm_id
|
||||
cmd_buf[16] = 0; // dummy id
|
||||
for (i = 17; i <= 20; i++) {
|
||||
cmd_buf[i] = rp.Pop<u32>();
|
||||
}
|
||||
|
||||
// Prepare for call to NWM_UDS
|
||||
std::shared_ptr<Kernel::Thread> thread = ctx.ClientThread();
|
||||
auto current_process = thread->owner_process.lock();
|
||||
auto context =
|
||||
std::make_shared<Kernel::HLERequestContext>(Core::System::GetInstance().Kernel(),
|
||||
ctx.Session(), thread);
|
||||
auto context = std::make_shared<Kernel::HLERequestContext>(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<Service::NWM::NWM_UDS>("nwm::UDS");
|
||||
|
||||
LOG_WARNING(Service_NWM, "Calling NWM_UDS::RecvBeaconBroadcastData");
|
||||
auto nwm_uds =
|
||||
Core::System::GetInstance().ServiceManager().GetService<Service::NWM::NWM_UDS>("nwm::UDS");
|
||||
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<u32>());
|
||||
rb.PushMappedBuffer(rp2.PopMappedBuffer());
|
||||
|
||||
LOG_WARNING(Service_NWM, "Finished NWM_INF::RecvBeaconBroadcastData");
|
||||
}
|
||||
|
||||
NWM_INF::NWM_INF() : ServiceFramework("nwm::INF") {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user