strat: use sf::NativeHandle for ipc templating
This commit is contained in:
@@ -54,14 +54,15 @@ namespace ams::usb {
|
||||
}
|
||||
|
||||
/* Bind the client process. */
|
||||
R_TRY(m_ds_service->Bind(complex_id, dd::GetCurrentProcessHandle()));
|
||||
R_TRY(m_ds_service->Bind(complex_id, sf::CopyHandle(dd::GetCurrentProcessHandle(), false)));
|
||||
|
||||
/* Get the state change event. */
|
||||
sf::CopyHandle event_handle;
|
||||
sf::NativeHandle event_handle;
|
||||
R_TRY(m_ds_service->GetStateChangeEvent(std::addressof(event_handle)));
|
||||
|
||||
/* Attach the state change event handle to our event. */
|
||||
os::AttachReadableHandleToSystemEvent(std::addressof(m_state_change_event), event_handle.GetValue(), true, os::EventClearMode_ManualClear);
|
||||
os::AttachReadableHandleToSystemEvent(std::addressof(m_state_change_event), event_handle.GetOsHandle(), event_handle.IsManaged(), os::EventClearMode_ManualClear);
|
||||
event_handle.Detach();
|
||||
|
||||
/* Mark ourselves as initialized. */
|
||||
m_is_initialized = true;
|
||||
@@ -250,17 +251,21 @@ namespace ams::usb {
|
||||
auto intf_guard = SCOPE_GUARD { m_client->DeleteInterface(m_interface_num); m_interface = nullptr; };
|
||||
|
||||
/* Get events. */
|
||||
sf::CopyHandle setup_event_handle;
|
||||
sf::CopyHandle ctrl_in_event_handle;
|
||||
sf::CopyHandle ctrl_out_event_handle;
|
||||
sf::NativeHandle setup_event_handle;
|
||||
sf::NativeHandle ctrl_in_event_handle;
|
||||
sf::NativeHandle ctrl_out_event_handle;
|
||||
R_TRY(m_interface->GetSetupEvent(std::addressof(setup_event_handle)));
|
||||
R_TRY(m_interface->GetCtrlInCompletionEvent(std::addressof(ctrl_in_event_handle)));
|
||||
R_TRY(m_interface->GetCtrlOutCompletionEvent(std::addressof(ctrl_out_event_handle)));
|
||||
|
||||
/* Attach events. */
|
||||
os::AttachReadableHandleToSystemEvent(std::addressof(m_setup_event), setup_event_handle.GetValue(), true, os::EventClearMode_ManualClear);
|
||||
os::AttachReadableHandleToSystemEvent(std::addressof(m_ctrl_in_completion_event), ctrl_in_event_handle.GetValue(), true, os::EventClearMode_ManualClear);
|
||||
os::AttachReadableHandleToSystemEvent(std::addressof(m_ctrl_out_completion_event), ctrl_out_event_handle.GetValue(), true, os::EventClearMode_ManualClear);
|
||||
os::AttachReadableHandleToSystemEvent(std::addressof(m_setup_event), setup_event_handle.GetOsHandle(), setup_event_handle.IsManaged(), os::EventClearMode_ManualClear);
|
||||
os::AttachReadableHandleToSystemEvent(std::addressof(m_ctrl_in_completion_event), ctrl_in_event_handle.GetOsHandle(), ctrl_in_event_handle.IsManaged(), os::EventClearMode_ManualClear);
|
||||
os::AttachReadableHandleToSystemEvent(std::addressof(m_ctrl_out_completion_event), ctrl_out_event_handle.GetOsHandle(), ctrl_out_event_handle.IsManaged(), os::EventClearMode_ManualClear);
|
||||
|
||||
setup_event_handle.Detach();
|
||||
ctrl_in_event_handle.Detach();
|
||||
ctrl_out_event_handle.Detach();
|
||||
|
||||
/* Increment our client's reference count. */
|
||||
++m_client->m_reference_count;
|
||||
@@ -635,7 +640,7 @@ namespace ams::usb {
|
||||
auto ep_guard = SCOPE_GUARD { m_interface->DeleteEndpoint(m_address); m_endpoint = nullptr; };
|
||||
|
||||
/* Get completion event. */
|
||||
sf::CopyHandle event_handle;
|
||||
sf::NativeHandle event_handle;
|
||||
R_TRY(m_endpoint->GetCompletionEvent(std::addressof(event_handle)));
|
||||
|
||||
/* Increment our interface's reference count. */
|
||||
@@ -643,7 +648,8 @@ namespace ams::usb {
|
||||
++m_interface->m_client->m_reference_count;
|
||||
|
||||
/* Attach our event. */
|
||||
os::AttachReadableHandleToSystemEvent(std::addressof(m_completion_event), event_handle, true, os::EventClearMode_ManualClear);
|
||||
os::AttachReadableHandleToSystemEvent(std::addressof(m_completion_event), event_handle.GetOsHandle(), event_handle.IsManaged(), os::EventClearMode_ManualClear);
|
||||
event_handle.Detach();
|
||||
|
||||
/* Mark initialized. */
|
||||
m_is_initialized = true;
|
||||
|
||||
@@ -35,10 +35,15 @@ namespace ams::usb {
|
||||
|
||||
Result RemoteDsEndpoint::GetCompletionEvent(sf::OutCopyHandle out) {
|
||||
serviceAssumeDomain(std::addressof(m_srv));
|
||||
return serviceDispatch(std::addressof(m_srv), 2,
|
||||
|
||||
os::NativeHandle event_handle;
|
||||
R_TRY((serviceDispatch(std::addressof(m_srv), 2,
|
||||
.out_handle_attrs = { SfOutHandleAttr_HipcCopy },
|
||||
.out_handles = out.GetHandlePointer(),
|
||||
);
|
||||
.out_handles = std::addressof(event_handle),
|
||||
)));
|
||||
|
||||
out.SetValue(event_handle, true);
|
||||
return ResultSuccess();
|
||||
}
|
||||
|
||||
Result RemoteDsEndpoint::GetUrbReport(sf::Out<usb::UrbReport> out) {
|
||||
|
||||
@@ -35,10 +35,15 @@ namespace ams::usb {
|
||||
|
||||
Result RemoteDsInterface::GetSetupEvent(sf::OutCopyHandle out) {
|
||||
serviceAssumeDomain(std::addressof(m_srv));
|
||||
return serviceDispatch(std::addressof(m_srv), 1,
|
||||
|
||||
os::NativeHandle event_handle;
|
||||
R_TRY((serviceDispatch(std::addressof(m_srv), 1,
|
||||
.out_handle_attrs = { SfOutHandleAttr_HipcCopy },
|
||||
.out_handles = out.GetHandlePointer(),
|
||||
);
|
||||
.out_handles = std::addressof(event_handle),
|
||||
)));
|
||||
|
||||
out.SetValue(event_handle, true);
|
||||
return ResultSuccess();
|
||||
}
|
||||
|
||||
Result RemoteDsInterface::GetSetupPacket(const sf::OutBuffer &out) {
|
||||
@@ -71,10 +76,15 @@ namespace ams::usb {
|
||||
|
||||
Result RemoteDsInterface::GetCtrlInCompletionEvent(sf::OutCopyHandle out) {
|
||||
serviceAssumeDomain(std::addressof(m_srv));
|
||||
return serviceDispatch(std::addressof(m_srv), hos::GetVersion() >= hos::Version_11_0_0 ? 5 : 7,
|
||||
|
||||
os::NativeHandle event_handle;
|
||||
R_TRY((serviceDispatch(std::addressof(m_srv), hos::GetVersion() >= hos::Version_11_0_0 ? 5 : 7,
|
||||
.out_handle_attrs = { SfOutHandleAttr_HipcCopy },
|
||||
.out_handles = out.GetHandlePointer(),
|
||||
);
|
||||
.out_handles = std::addressof(event_handle),
|
||||
)));
|
||||
|
||||
out.SetValue(event_handle, true);
|
||||
return ResultSuccess();
|
||||
}
|
||||
|
||||
Result RemoteDsInterface::GetCtrlInUrbReport(sf::Out<usb::UrbReport> out) {
|
||||
@@ -84,10 +94,15 @@ namespace ams::usb {
|
||||
|
||||
Result RemoteDsInterface::GetCtrlOutCompletionEvent(sf::OutCopyHandle out) {
|
||||
serviceAssumeDomain(std::addressof(m_srv));
|
||||
return serviceDispatch(std::addressof(m_srv), hos::GetVersion() >= hos::Version_11_0_0 ? 7 : 9,
|
||||
|
||||
os::NativeHandle event_handle;
|
||||
R_TRY((serviceDispatch(std::addressof(m_srv), hos::GetVersion() >= hos::Version_11_0_0 ? 7 : 9,
|
||||
.out_handle_attrs = { SfOutHandleAttr_HipcCopy },
|
||||
.out_handles = out.GetHandlePointer(),
|
||||
);
|
||||
.out_handles = std::addressof(event_handle),
|
||||
)));
|
||||
|
||||
out.SetValue(event_handle, true);
|
||||
return ResultSuccess();
|
||||
}
|
||||
|
||||
Result RemoteDsInterface::GetCtrlOutUrbReport(sf::Out<usb::UrbReport> out) {
|
||||
|
||||
@@ -19,12 +19,12 @@
|
||||
|
||||
namespace ams::usb {
|
||||
|
||||
Result RemoteDsService::Bind(usb::ComplexId complex_id, sf::CopyHandle process_h) {
|
||||
Result RemoteDsService::Bind(usb::ComplexId complex_id, sf::CopyHandle &&process_h) {
|
||||
if (hos::GetVersion() >= hos::Version_11_0_0) {
|
||||
serviceAssumeDomain(std::addressof(m_srv));
|
||||
R_TRY(serviceDispatchIn(std::addressof(m_srv), 0, complex_id,
|
||||
.in_num_handles = 1,
|
||||
.in_handles = { process_h.GetValue() }
|
||||
.in_handles = { process_h.GetOsHandle() }
|
||||
));
|
||||
} else {
|
||||
serviceAssumeDomain(std::addressof(m_srv));
|
||||
@@ -33,7 +33,7 @@ namespace ams::usb {
|
||||
serviceAssumeDomain(std::addressof(m_srv));
|
||||
R_TRY(serviceDispatch(std::addressof(m_srv), 1,
|
||||
.in_num_handles = 1,
|
||||
.in_handles = { process_h.GetValue() })
|
||||
.in_handles = { process_h.GetOsHandle() })
|
||||
);
|
||||
}
|
||||
|
||||
@@ -56,10 +56,15 @@ namespace ams::usb {
|
||||
|
||||
Result RemoteDsService::GetStateChangeEvent(sf::OutCopyHandle out) {
|
||||
serviceAssumeDomain(std::addressof(m_srv));
|
||||
return serviceDispatch(std::addressof(m_srv), hos::GetVersion() >= hos::Version_11_0_0 ? 2 : 3,
|
||||
|
||||
os::NativeHandle event_handle;
|
||||
R_TRY((serviceDispatch(std::addressof(m_srv), hos::GetVersion() >= hos::Version_11_0_0 ? 2 : 3,
|
||||
.out_handle_attrs = { SfOutHandleAttr_HipcCopy },
|
||||
.out_handles = out.GetHandlePointer(),
|
||||
);
|
||||
.out_handles = std::addressof(event_handle),
|
||||
)));
|
||||
|
||||
out.SetValue(event_handle, true);
|
||||
return ResultSuccess();
|
||||
}
|
||||
|
||||
Result RemoteDsService::GetState(sf::Out<usb::UsbState> out) {
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace ams::usb {
|
||||
RemoteDsService(Service &srv, sf::ExpHeapAllocator *allocator) : m_srv(srv), m_allocator(allocator) { /* ... */ }
|
||||
virtual ~RemoteDsService() { serviceClose(std::addressof(m_srv)); }
|
||||
public:
|
||||
Result Bind(usb::ComplexId complex_id, sf::CopyHandle process_h);
|
||||
Result Bind(usb::ComplexId complex_id, sf::CopyHandle &&process_h);
|
||||
Result RegisterInterface(sf::Out<sf::SharedPointer<usb::ds::IDsInterface>> out, u8 bInterfaceNumber);
|
||||
Result GetStateChangeEvent(sf::OutCopyHandle out);
|
||||
Result GetState(sf::Out<usb::UsbState> out);
|
||||
|
||||
Reference in New Issue
Block a user