MCPcopy Index your code
hub / github.com/RT-Thread/rt-thread / lwp_tty_create_ext

Function lwp_tty_create_ext

components/lwp/terminal/tty_device.c:358–410  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

356}
357
358lwp_tty_t lwp_tty_create_ext(lwp_ttydevsw_t handle, void *softc,
359 rt_mutex_t custom_mtx)
360{
361 lwp_tty_t tp;
362
363 tp = rt_calloc(1, sizeof(struct lwp_tty)
364 #ifdef USING_BSD_SIGINFO
365 + LWP_TTY_PRBUF_SIZE
366 #endif
367 );
368
369 if (!tp)
370 return tp;
371
372 bsd_devsw_init(handle);
373
374#ifdef USING_BSD_SIGINFO
375 tp->t_prbufsz = LWP_TTY_PRBUF_SIZE;
376#endif
377 tp->t_devsw = handle;
378 tp->t_devswsoftc = softc;
379 tp->t_flags = handle->tsw_flags;
380 tp->t_drainwait = tty_drainwait;
381
382 tty_init_termios(tp);
383
384 cv_init(&tp->t_inwait, "ttyin");
385 cv_init(&tp->t_outwait, "ttyout");
386 cv_init(&tp->t_outserwait, "ttyosr");
387 cv_init(&tp->t_bgwait, "ttybg");
388 cv_init(&tp->t_dcdwait, "ttydcd");
389
390 rt_wqueue_init(&tp->t_inpoll);
391 rt_wqueue_init(&tp->t_outpoll);
392
393 /* Allow drivers to use a custom mutex to lock the TTY. */
394 if (custom_mtx != NULL)
395 {
396 tp->t_mtx = custom_mtx;
397 }
398 else
399 {
400 tp->t_mtx = &tp->t_mtxobj;
401 rt_mutex_init(&tp->t_mtxobj, "ttydev", RT_IPC_FLAG_PRIO);
402 }
403
404#ifdef USING_BSD_POLL
405 knlist_init_mtx(&tp->t_inpoll.si_note, tp->t_mtx);
406 knlist_init_mtx(&tp->t_outpoll.si_note, tp->t_mtx);
407#endif
408
409 return tp;
410}
411
412lwp_tty_t lwp_tty_create(lwp_ttydevsw_t handle, void *softc)
413{

Callers 1

lwp_tty_createFunction · 0.85

Calls 5

rt_callocFunction · 0.85
bsd_devsw_initFunction · 0.85
tty_init_termiosFunction · 0.85
rt_wqueue_initFunction · 0.85
rt_mutex_initFunction · 0.85

Tested by

no test coverage detected