Lines Matching +full:data +full:- +full:ready
4 * SPDX-License-Identifier: Apache-2.0
14 static int rpmsg_shell_cb(struct rpmsg_endpoint *ept, void *data, in rpmsg_shell_cb() argument
18 struct shell_rpmsg *sh_rpmsg = (struct shell_rpmsg *)transport->ctx; in rpmsg_shell_cb()
25 rx.data = data; in rpmsg_shell_cb()
27 if (k_msgq_put(&sh_rpmsg->rx_q, &rx, K_NO_WAIT) != 0) { in rpmsg_shell_cb()
31 rpmsg_hold_rx_buffer(ept, data); in rpmsg_shell_cb()
32 sh_rpmsg->shell_handler(SHELL_TRANSPORT_EVT_RX_RDY, sh_rpmsg->shell_context); in rpmsg_shell_cb()
39 struct shell_rpmsg *sh_rpmsg = (struct shell_rpmsg *)transport->ctx; in uninit()
41 if (!sh_rpmsg->ready) { in uninit()
42 return -ENODEV; in uninit()
45 rpmsg_destroy_ept(&sh_rpmsg->ept); in uninit()
46 sh_rpmsg->ready = false; in uninit()
56 struct shell_rpmsg *sh_rpmsg = (struct shell_rpmsg *)transport->ctx; in init()
60 if (sh_rpmsg->ready) { in init()
61 return -EALREADY; in init()
65 return -EINVAL; in init()
69 k_msgq_init(&sh_rpmsg->rx_q, (char *)sh_rpmsg->rx_buf, sizeof(struct shell_rpmsg_rx), in init()
72 ret = rpmsg_create_ept(&sh_rpmsg->ept, rdev, CONFIG_SHELL_RPMSG_SERVICE_NAME, in init()
79 sh_rpmsg->ept.priv = (void *)transport; in init()
81 sh_rpmsg->shell_handler = evt_handler; in init()
82 sh_rpmsg->shell_context = context; in init()
83 sh_rpmsg->ready = true; in init()
90 struct shell_rpmsg *sh_rpmsg = (struct shell_rpmsg *)transport->ctx; in enable()
92 if (!sh_rpmsg->ready) { in enable()
93 return -ENODEV; in enable()
96 sh_rpmsg->blocking = blocking; in enable()
102 const void *data, size_t length, size_t *cnt) in write() argument
104 struct shell_rpmsg *sh_rpmsg = (struct shell_rpmsg *)transport->ctx; in write()
109 if (!sh_rpmsg->ready) { in write()
110 return -ENODEV; in write()
113 if (sh_rpmsg->blocking) { in write()
114 ret = rpmsg_send(&sh_rpmsg->ept, data, (int)length); in write()
116 ret = rpmsg_trysend(&sh_rpmsg->ept, data, (int)length); in write()
119 /* Set TX ready in any case, as we have no way to recover otherwise */ in write()
120 sh_rpmsg->shell_handler(SHELL_TRANSPORT_EVT_TX_RDY, sh_rpmsg->shell_context); in write()
132 void *data, size_t length, size_t *cnt) in read() argument
134 struct shell_rpmsg *sh_rpmsg = (struct shell_rpmsg *)transport->ctx; in read()
135 struct shell_rpmsg_rx *rx = &sh_rpmsg->rx_cur; in read()
139 if (!sh_rpmsg->ready) { in read()
140 return -ENODEV; in read()
143 /* Check if we still have pending data */ in read()
144 if (rx->data == NULL) { in read()
145 int ret = k_msgq_get(&sh_rpmsg->rx_q, rx, K_NO_WAIT); in read()
148 rx->data = NULL; in read()
152 __ASSERT_NO_MSG(rx->len > 0); in read()
153 sh_rpmsg->rx_consumed = 0; in read()
156 __ASSERT_NO_MSG(rx->len > sh_rpmsg->rx_consumed); in read()
157 read_len = rx->len - sh_rpmsg->rx_consumed; in read()
164 memcpy(data, &((char *)rx->data)[sh_rpmsg->rx_consumed], read_len); in read()
167 rpmsg_release_rx_buffer(&sh_rpmsg->ept, rx->data); in read()
168 rx->data = NULL; in read()
170 sh_rpmsg->rx_consumed += read_len; in read()