mirror of
https://github.com/switchbrew/libnx.git
synced 2025-06-21 12:32:40 +02:00
bsd: allow user-specified tmem backing buffer
This commit is contained in:
parent
38ee48032f
commit
c8f8145195
@ -18,6 +18,9 @@
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
u32 version; ///< Observed 1 on [2.0.0+] LibAppletWeb, 2 on [3.0.0+].
|
u32 version; ///< Observed 1 on [2.0.0+] LibAppletWeb, 2 on [3.0.0+].
|
||||||
|
|
||||||
|
void *tmem_buffer; ///< User-provided buffer to use as backing for transfer memory. If NULL, a buffer will be allocated automatically. Must be large enough and page-aligned.
|
||||||
|
size_t tmem_buffer_size; ///< Size of the user-provided transfer memory backing buffer. Must be large enough and page-aligned.
|
||||||
|
|
||||||
u32 tcp_tx_buf_size; ///< Size of the TCP transfer (send) buffer (initial or fixed).
|
u32 tcp_tx_buf_size; ///< Size of the TCP transfer (send) buffer (initial or fixed).
|
||||||
u32 tcp_rx_buf_size; ///< Size of the TCP receive buffer (initial or fixed).
|
u32 tcp_rx_buf_size; ///< Size of the TCP receive buffer (initial or fixed).
|
||||||
u32 tcp_tx_buf_max_size; ///< Maximum size of the TCP transfer (send) buffer. If it is 0, the size of the buffer is fixed to its initial value.
|
u32 tcp_tx_buf_max_size; ///< Maximum size of the TCP transfer (send) buffer. If it is 0, the size of the buffer is fixed to its initial value.
|
||||||
|
@ -37,6 +37,9 @@ static TransferMemory g_bsdTmem;
|
|||||||
static const BsdInitConfig g_defaultBsdInitConfig = {
|
static const BsdInitConfig g_defaultBsdInitConfig = {
|
||||||
.version = 1,
|
.version = 1,
|
||||||
|
|
||||||
|
.tmem_buffer = NULL,
|
||||||
|
.tmem_buffer_size = 0,
|
||||||
|
|
||||||
.tcp_tx_buf_size = 0x8000,
|
.tcp_tx_buf_size = 0x8000,
|
||||||
.tcp_rx_buf_size = 0x10000,
|
.tcp_rx_buf_size = 0x10000,
|
||||||
.tcp_tx_buf_max_size = 0x40000,
|
.tcp_tx_buf_max_size = 0x40000,
|
||||||
@ -213,8 +216,14 @@ Result _bsdInitialize(const BsdInitConfig *config, u32 num_sessions, u32 service
|
|||||||
if (R_SUCCEEDED(rc))
|
if (R_SUCCEEDED(rc))
|
||||||
rc = smGetServiceWrapper(&g_bsdMonitor, bsd_srv);
|
rc = smGetServiceWrapper(&g_bsdMonitor, bsd_srv);
|
||||||
|
|
||||||
if (R_SUCCEEDED(rc))
|
if (R_SUCCEEDED(rc)) {
|
||||||
rc = tmemCreate(&g_bsdTmem, _bsdGetTransferMemSizeForConfig(config), 0);
|
const size_t min_tmem_size = _bsdGetTransferMemSizeForConfig(config);
|
||||||
|
|
||||||
|
if (config->tmem_buffer != NULL && config->tmem_buffer_size >= min_tmem_size)
|
||||||
|
rc = tmemCreateFromMemory(&g_bsdTmem, config->tmem_buffer, config->tmem_buffer_size, 0);
|
||||||
|
else
|
||||||
|
rc = tmemCreate(&g_bsdTmem, min_tmem_size, 0);
|
||||||
|
}
|
||||||
|
|
||||||
if (R_SUCCEEDED(rc))
|
if (R_SUCCEEDED(rc))
|
||||||
rc = _bsdRegisterClient(&g_bsdTmem, config, &g_bsdClientPid);
|
rc = _bsdRegisterClient(&g_bsdTmem, config, &g_bsdClientPid);
|
||||||
|
Loading…
Reference in New Issue
Block a user