htc: implement socket driver (socket api not really impl'd yet)

This commit is contained in:
Michael Scire
2021-02-24 01:45:55 -08:00
committed by SciresM
parent b5ab491603
commit 1c974a387c
31 changed files with 1389 additions and 35 deletions

View File

@@ -39,6 +39,8 @@ namespace ams::mitm::socket::resolver {
virtual Result OnNeedsToAccept(int port_index, Server *server) override;
};
alignas(os::MemoryPageSize) constinit u8 g_resolver_allocator_buffer[16_KB];
ServerManager g_server_manager;
Result ServerManager::OnNeedsToAccept(int port_index, Server *server) {
@@ -121,6 +123,9 @@ namespace ams::mitm::socket::resolver {
return;
}
/* Initialize the socket allocator. */
ams::socket::InitializeAllocatorForInternal(g_resolver_allocator_buffer, sizeof(g_resolver_allocator_buffer));
/* Initialize debug. */
resolver::InitializeDebug(ShouldEnableDebugLog());

View File

@@ -15,7 +15,7 @@
"filesystem_access": {
"permissions": "0xFFFFFFFFFFFFFFFF"
},
"service_access": ["pcie", "psc:m", "set:cal", "set:fd", "set:sys", "usb:ds", "fsp-srv"],
"service_access": ["pcie", "psc:m", "set:cal", "set:fd", "set:sys", "usb:ds", "fsp-srv", "bsd:s"],
"service_host": ["file_io", "htc", "htcs"],
"kernel_capabilities": [{
"type": "kernel_flags",

View File

@@ -200,6 +200,10 @@ namespace ams::htc {
return htclow::impl::DriverType::HostBridge;
} else if (std::strstr(transport, "plainchannel")) {
return htclow::impl::DriverType::PlainChannel;
} else if (std::strstr(transport, "socket")) {
/* NOTE: Nintendo does not actually allow socket driver to be selected. */
/* Should we disallow this? Undesirable, because people will want to use docked tma. */
return htclow::impl::DriverType::Socket;
} else {
return DefaultHtclowDriverType;
}
@@ -230,6 +234,12 @@ namespace ams::htc {
}
namespace ams::htclow::driver {
void InitializeSocketApiForSocketDriver();
}
int main(int argc, char **argv)
{
/* Set thread name. */
@@ -240,6 +250,11 @@ int main(int argc, char **argv)
const auto driver_type = htc::GetHtclowDriverType();
htclow::HtclowManagerHolder::SetDefaultDriver(driver_type);
/* If necessary, initialize the socket driver. */
if (driver_type == htclow::impl::DriverType::Socket) {
htclow::driver::InitializeSocketApiForSocketDriver();
}
/* Initialize the htclow manager. */
htclow::HtclowManagerHolder::AddReference();
ON_SCOPE_EXIT { htclow::HtclowManagerHolder::Release(); };