Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Initiates an overlapped operation to indicate to a WinI3C-Target the expected maximum size of an I3C Private Read, IBI payload and IBI Auto-Command-Read. This corresponds to the I3C SETMRL and GETMRL Direct CCCs.
WinI3CSetMaxReadAndIbiLengthWithFileHandle is a Non-library-managed WinI3C API. It uses a client-supplied file handle and returns a WinI3CAsyncOperation for a client-managed overlapped operation. These APIs are intended only for advanced scenarios; this is generally not recommended. For most applications, use the library-managed WinI3CSetMaxReadAndIbiLength instead.
Syntax
_Must_inspect_result_
HRESULT WINAPI WinI3CSetMaxReadAndIbiLengthWithFileHandle(
_In_ HANDLE targetFileHandle,
_In_ UINT16 requestedMaxReadAndAutoCommandReadLength,
_In_ UINT8 requestedMaxIbiLength,
_In_ OVERLAPPED* setMrlOverlapped,
_Out_ WinI3CAsyncOperation* setMrlOperation);
Parameters
[in] targetFileHandle
The file handle associated with the WinI3C-Target to configure.
The handle shall have been opened with FILE_FLAG_OVERLAPPED in the dwFlagsAndAttributes parameter of CreateFile.
A WinI3CTarget handle cannot be passed.
[in] requestedMaxReadAndAutoCommandReadLength
The requested maximum Private Read and IBI Auto-Command-Read payload size (bytes).
[in] requestedMaxIbiLength
The requested maximum IBI payload size.
0 indicates an unlimited payload.
If IBIs are unsupported by the WinI3C-Target, this value is ignored.
[in] setMrlOverlapped
A client-allocated OVERLAPPED to supply to the underlying overlapped I/O call.
[out] setMrlOperation
Receives a library-created WinI3CAsyncOperation that represents this overlapped operation.
Valid only when the function returns S_OK.
After the operation completes, retrieve the values with WinI3CGetMaxReadAndIbiLengthFromOperation, then destroy the operation with WinI3CRelease (before destroying the associated OVERLAPPED).
Return value
On success this function returns S_OK.
On failure this function returns an appropriate HRESULT error code, including the following.
| Return code | Description |
|---|---|
| S_OK | Successfully initiated the SETMRL/GETMRL CCCs. |
| E_INVALIDARG | One or more parameters are invalid. |
| E_OUTOFMEMORY | Available memory is insufficient to execute this function. |
| HRESULT_FROM_WIN32(ERROR_INVALID_HANDLE) | targetFileHandle is invalid, or was not opened with FILE_FLAG_OVERLAPPED. |
| HRESULT_FROM_WIN32(ERROR_DEVICE_HARDWARE_ERROR) | A fatal hardware error occurred. Close targetFileHandle with CloseHandle. |
Remarks
Use the standard Win32 I/O APIs (e.g. GetOverlappedResult, CancelIo or an I/O completion port) to manage the overlapped operation.
Vendors understand the capabilities of their devices, so there is no provided mechanism to determine if SETMRL/GETMRL Direct CCCs are supported by the WinI3C-Target.
When the overlapped operation has completed, call WinI3CGetMaxReadAndIbiLengthFromOperation to inspect the values, then destroy the library-created setMrlOperation with WinI3CRelease.
If IBIs are enabled with outstanding pended reads, calling this may cause IBIs to be dropped if a pended read is too small. It is recommended to disable IBIs (WinI3CDisableIbisWithFileHandle), pend new IBI reads (WinI3CPendIbiReadWithFileHandle) with the updated buffer size before calling this function, then re-enable IBIs (WinI3CEnableIbisWithFileHandle).
This function is thread-safe.
Completion status
When the overlapped operation completes, its result (e.g. from GetOverlappedResult with HRESULT_FROM_WIN32(GetLastError())) is one of the following:
| Completion code | Description |
|---|---|
| S_OK | Successfully set the maximum read and IBI lengths for the WinI3C-Target. |
| HRESULT_FROM_WIN32(ERROR_DEVICE_NACKED) | The WinI3C-Target (passively) NACKed. Consider calling WinI3CGetStatusWithFileHandle to understand the current WinI3C-Target state. |
| HRESULT_FROM_WIN32(ERROR_DEVICE_HARDWARE_ERROR) | A fatal hardware error occurred. Close targetFileHandle with CloseHandle. |
Example
#include <wil\result.h>
#include <wil\resource.h>
#include <wini3c.h>
int main()
{
...
// Completion event.
OVERLAPPED setMrlOverlapped{};
setMrlOverlapped.hEvent = CreateEventW(nullptr, TRUE, FALSE, nullptr);
RETURN_LAST_ERROR_IF(setMrlOverlapped.hEvent == nullptr);
auto closeEventOnExit = wil::scope_exit([&]()
{
CloseHandle(setMrlOverlapped.hEvent);
});
const uint16_t maxPrivateReadLength = ...;
const uint8_t maxIbiLength = ...;
WinI3CAsyncOperation setMrlOperation;
HRESULT setMrlResult = WinI3CSetMaxReadAndIbiLengthWithFileHandle(
winI3cTargetHandle,
maxPrivateReadLength,
maxIbiLength,
&setMrlOverlapped,
&setMrlOperation);
if (FAILED(setMrlResult) && setMrlResult != HRESULT_FROM_WIN32(ERROR_IO_PENDING))
{
// Error sending the SETMRL.
return setMrlResult;
}
auto destroyOperationOnExit = wil::scope_exit([&]()
{
WinI3CRelease(setMrlOperation);
});
// Blocking, waiting for result (for demonstration purposes only).
// In a real application, would use a completion port or other async mechanism to avoid blocking the thread.
DWORD numberOfBytesTransferred;
if (!GetOverlappedResult(winI3cTargetHandle, &setMrlOverlapped, &numberOfBytesTransferred, true))
{
RETURN_LAST_ERROR();
}
...
}
Requirements
| Requirement | Value |
|---|---|
| Minimum supported client | Windows 11 25H2 October update (build 26200) |
| Target Platform | Windows |
| Header | wini3c.h |
| DLL | wini3c.dll |