MCPcopy Create free account
hub / github.com/apache/nuttx / uart_rpmsg_raw_init

Function uart_rpmsg_raw_init

drivers/serial/uart_rpmsg_raw.c:326–378  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

324 ****************************************************************************/
325
326int uart_rpmsg_raw_init(FAR const char *cpuname, FAR const char *devname,
327 int buf_size, bool isconsole)
328{
329 FAR struct uart_rpmsg_priv_s *priv;
330 FAR struct uart_dev_s *dev;
331 char name[32];
332 int ret;
333
334 dev = kmm_zalloc(sizeof(struct uart_dev_s) +
335 sizeof(struct uart_rpmsg_priv_s) +
336 buf_size * 2);
337 if (dev == NULL)
338 {
339 return -ENOMEM;
340 }
341
342 dev->ops = &g_uart_rpmsg_ops;
343 dev->isconsole = isconsole;
344 dev->recv.size = buf_size;
345 dev->xmit.size = buf_size;
346 dev->priv = dev + 1;
347 dev->recv.buffer = (FAR char *)dev->priv +
348 sizeof(struct uart_rpmsg_priv_s);
349 dev->xmit.buffer = dev->recv.buffer + buf_size;
350 priv = dev->priv;
351 priv->cpuname = cpuname;
352 priv->devname = devname;
353
354 nxmutex_init(&priv->lock);
355
356 ret = rpmsg_register_callback(dev,
357 uart_rpmsg_raw_device_created,
358 uart_rpmsg_raw_device_destroy,
359 NULL,
360 NULL);
361 if (ret < 0)
362 {
363 nxmutex_destroy(&priv->lock);
364 kmm_free(dev);
365 return ret;
366 }
367
368 snprintf(name, sizeof(name), "%s%s",
369 UART_RPMSG_DEV_PREFIX, devname);
370 uart_register(name, dev);
371
372 if (dev->isconsole)
373 {
374 uart_register(UART_RPMSG_DEV_CONSOLE, dev);
375 }
376
377 return 0;
378}

Callers 1

rpmsg_serialrawinitFunction · 0.85

Calls 7

kmm_zallocFunction · 0.85
nxmutex_initFunction · 0.85
rpmsg_register_callbackFunction · 0.85
nxmutex_destroyFunction · 0.85
kmm_freeFunction · 0.85
uart_registerFunction · 0.85
snprintfFunction · 0.50

Tested by

no test coverage detected