首页 > 系统相关 >Linux 下串口驱动头文件之termios.h

Linux 下串口驱动头文件之termios.h

时间:2023-06-05 15:01:47浏览次数:32  
标签:tmp kernel 头文件 struct termios user 串口 termio


在linux-2.6.29/include/asm-generic下的termios.h

/* termios.h: generic termios/termio user copying/translation
 */#ifndef _ASM_GENERIC_TERMIOS_H
#define _ASM_GENERIC_TERMIOS_H#include <asm/uaccess.h>
#ifndef __ARCH_TERMIO_GETPUT
/*
 * Translate a "termio" structure into a "termios". Ugh.
 */
static inline int user_termio_to_kernel_termios(struct ktermios *termios,
      struct termio __user *termio)
{
 unsigned short tmp; if (get_user(tmp, &termio->c_iflag) < 0)
  goto fault;
 termios->c_iflag = (0xffff0000 & termios->c_iflag) | tmp; if (get_user(tmp, &termio->c_oflag) < 0)
  goto fault;
 termios->c_oflag = (0xffff0000 & termios->c_oflag) | tmp; if (get_user(tmp, &termio->c_cflag) < 0)
  goto fault;
 termios->c_cflag = (0xffff0000 & termios->c_cflag) | tmp; if (get_user(tmp, &termio->c_lflag) < 0)
  goto fault;
 termios->c_lflag = (0xffff0000 & termios->c_lflag) | tmp; if (get_user(termios->c_line, &termio->c_line) < 0)
  goto fault; if (copy_from_user(termios->c_cc, termio->c_cc, NCC) != 0)
  goto fault; return 0;
 fault:
 return -EFAULT;
}/*
 * Translate a "termios" structure into a "termio". Ugh.
 */
static inline int kernel_termios_to_user_termio(struct termio __user *termio,
      struct ktermios *termios)
{
 if (put_user(termios->c_iflag, &termio->c_iflag) < 0 ||
     put_user(termios->c_oflag, &termio->c_oflag) < 0 ||
     put_user(termios->c_cflag, &termio->c_cflag) < 0 ||
     put_user(termios->c_lflag, &termio->c_lflag) < 0 ||
     put_user(termios->c_line,  &termio->c_line) < 0 ||
     copy_to_user(termio->c_cc, termios->c_cc, NCC) != 0)
  return -EFAULT; return 0;
}#ifndef user_termios_to_kernel_termios
#define user_termios_to_kernel_termios(k, u) copy_from_user(k, u, sizeof(struct termios))
#endif#ifndef kernel_termios_to_user_termios
#define kernel_termios_to_user_termios(u, k) copy_to_user(u, k, sizeof(struct termios))
#endif#define user_termios_to_kernel_termios_1(k, u) copy_from_user(k, u, sizeof(struct termios))
#define kernel_termios_to_user_termios_1(u, k) copy_to_user(u, k, sizeof(struct termios))#endif /* __ARCH_TERMIO_GETPUT */
#endif /* _ASM_GENERIC_TERMIOS_H */

标签:tmp,kernel,头文件,struct,termios,user,串口,termio
From: https://blog.51cto.com/u_11860992/6416189

相关文章

  • 解决串口接收数据不完整
    C#解决串口接收数据不完整1. 使用缓存机制完成:首先通过定义一个成员变量List<byte>buffer=newList<byte>(4096);用来存放所有的数据,在接收函数里,通过buffer.AddRange()方法不断将接收到的数据加入到buffer中,并同时对buffer的数据进行校验,如果达到一定的长度并且校验结果正......
  • 串口(PL011)在Linux启动运行过程中扮演的角色
    关键词:PL011、earlyprintk、AMBA、UART、tty、console等等。串口虽然是一种简单的工具,但是在Linux启动、运行、调试中扮演了重要角色。其稳定、易用、高效(某些场景)。串口依赖的模块少,在FPGA初期调试中扮演重要角色。往往是CPU基本功能可用后,即可使能串口进行功能调试。下面记......
  • 2. 头文件和类的说明
    Cvs.C++,关于数据与函数现在我们要正式进入语言的部分,我首先拿C++语言跟它的前身C语言来做一个在函数以及数据,它们之间的一些角色的不同来做比较。在C语言、其它语言也一样,概念是一样的。那么在C语言,你在设计程序的时候,你这边会你会准备一些数据,你会准备一些函数,函数就......
  • stm32笔记[7]-串口多字节收发
    主要功能使用AliosThingsDevkit开发板实现串口多字节收发,使用内部RTC时钟和AD转换.硬件平台开发板:AliosThingsDevkit芯片:stm32l496vgt6系统时钟:80MHzLED1:PB6(低电平有效)LED2:PE3(低电平有效)LED3:PD15(低电平有效)STLK_TX:PB10(LPUART1)STLK_RX:PB11(LPUA......
  • GP232RL—UART串口芯片兼容FT232RL国产芯片
    GP232RL为接口转换芯片,可以实现USB到串行UART接口的转换,也可转换到同步、异步Bit-Bang接口模式。具备可选择的时钟产生输出,以及新的FTDIChip-ID安全加密狗功能。此外,还提供异步和同步bitbang接口模式。使用GP232RL的USB到串行设计还进一步简化集成外部EEPROM,时钟电路和USB电阻......
  • 36 KVM管理设备-配置虚拟串口
    36KVM管理设备-配置虚拟串口36.1概述在虚拟化环境下,由于管理和业务的需求,虚拟机与宿主机需要互相通信。但在云管理系统复杂的网络架构下,运行在管理平面的服务与运行在业务平面的虚拟机之间,不能简单的进行三层网络互相通信,导致服务部署和信息收集不够快速。因此需要提供虚拟串口......
  • C++控制台实现串口类似超级终端收发功能
     #include<iostream>#include<windows.h>#include<thread>classSerialPort{public://构造函数,打开串口并设置参数SerialPort(constchar*portName){hSerial=CreateFileA(portName,GENERIC_READ|GENERIC_WRITE,0,N......
  • 不使用microlib实现STM32串口printf重定向:
    不使用microlib实现STM32串口printf重定向:突然发现有一篇markdown忘记上传了,补一下注:使用的是CubeMX生成的工程文件生成后,在usart.c中添加如下代码://usercodebegin0typedefstruct__FILEFILE;struct__FILE{ inthandle;};FILE__stdout;//userco......
  • java modbus_rtu串口通讯
    基于modbus和串口通讯的Java分享本文推荐一个简单好用java实现基于modbus—rtu协议通讯方法:如果采用非标准modbus协议通讯,可以查看我的这篇博文:java实现串口通讯关于modbus的java开源库主要有以下四种:Jamod:JavaModbus实现:JavaModbus库。该库由DieterWimberger实施。Mod......
  • DPU54可替代AU9254串口USB1.1 hub芯片
    产品概述DPU54是一款高性能、低功耗4口全速USB1.1HUB控制器,上行端口兼容全速12MHz模式,4个下行端口兼容全速12MHz、低速1.5MHz两种模式。DPU54采用状态机单事务处理架构,而非单片机架构,多个事务缓冲区,这样减小了芯片的系统响应时间,用最少的硬件资源实现了USB1.1全速传......