uart registers
I/O port | Read (DLAB=0) | Write (DLAB=0) | Read (DLAB=1) | Write (DLAB=1) |
---|---|---|---|---|
base | RBR receiver buffer | THR transmitter holding | DLL divisor latch LSB | DLL divisor latch LSB |
base+1 | IER interrupt enable | IER interrupt enable | DLM divisor latch MSB | DLM divisor latch MSB |
base+2 | IIR interrupt identification | FCR FIFO control | IIR interrupt identification | FCR FIFO control |
base+3 | LCR line control | LCR line control | LCR line control | LCR line control |
base+4 | MCR modem control | MCR modem control | MCR modem control | MCR modem control |
base+5 | LSR line status | factory test | LSR line status | factory test |
base+6 | MSR modem status | not used | MSR modem status | not used |
base+7 | SCR scratch | SCR scratch | SCR scratch | SCR scratch |
*from: https://www.lammertbies.nl/comm/info/serial-uart
uart hw driver
struct uart_port setup in probe func
设置serial_in/serial_out/handle_irq/set_termios函数指针,以及其它成员,比较关键的如下:
.iotype = UPIO_MEM,//成员表示该串口接口寄存器的地址类型,8位的内存地址
.regshift = 2,//在访问该串口接口的某个寄存器时,需把该寄存器的号左移多少位然后加基地址(不管是物理或虚拟地址)才能得能到这个寄存器的址址
.mapbase
.mapsize
.membase //ioremaped
static void 8250_mem_serial_out(struct uart_port *p, int offset, int value) { offset = offset << p->regshift; writeb(value, p->membase + offset); }
tty uart misc
查看ttyS0是否有开启
cat /sys/devices/platform/uart_control/uart_switch_status
执行结果如下:
001110220330
上面第3个字元如果为0,表示ttyS0是关闭的
Android系统开机过程中按ctrl c导致后面读stdin返回errno 5(IO error)
问题原因:sh启动比较晚
问题解决方案:sh启动要早,如果没有及时将read buf内的内容读走,可能会打乱tty driver,比如如下的启动时机(Android原生)
on init && property:ro.debuggable=1 start console
标签:control,status,tty,uart,base,linux,line,modem From: https://www.cnblogs.com/aspirs/p/17590078.html