当前位置: 首页 > news >正文

福州专业建站公司广告语

福州专业建站公司,广告语,免费建网站 高校社团官方网站,代做网站关键词排名前言 在前面 printf 的调试 我们只是调试到了 glibc 调用系统调用, 封装了参数 stdout, 带输出的字符缓冲, 以及待输出字符长度 然后内核这边 只是到了 write 的系统调用, 并未向下细看 我们这里 稍微向下 细追一下, 看看 到达设备层面 这里是怎么具体的 impl 的 测试用例…

前言

在前面 printf 的调试 我们只是调试到了 glibc 调用系统调用, 封装了参数 stdout, 带输出的字符缓冲, 以及待输出字符长度 

然后内核这边 只是到了 write 的系统调用, 并未向下细看 

我们这里 稍微向下 细追一下, 看看 到达设备层面 这里是怎么具体的 impl 的  

测试用例

测试用例如下, 这里仅仅是一个简单的输出 

(initramfs) cat Test01Sum.c #include "stdio.h"int main(int argc, char** argv) {int x = 2;
int y = 3;
int z = x + y;printf(" x + y = %d\n ", z);}

tty 输出的调试

接着 printf 的调试 的 vfs_write 的这里, 看一下 上下文, 待输出的字符串为 " x + y = 5\n" 

然后 输出的 stdout 文件的 inode_no 为 7407 

inode 7407 在这里对应的设备为 

 (initramfs) ls -ail /dev | grep console7407 crw-------    1    5,   1 console

设备 /dev/console

该字符设备初始化是在 tty_init 的时候进行初始化的 

主设备号位 TTYAUX_MAJOR 为 5, 此设备号位 1, 相关操作 ops 为 console_fops 

vfs 层面 write 操作映射到下层是 console_fops.redirected_tty_write 

console_fops.redirected_tty_write 

关于 tty->tty_ldisc->ops

这层抽象的设计, 等以后有所收获之后 再回来补充 

文件关联的 tty 是来自于 file->private_data 

这一层也有一层抽象, tty->tty_ldisc, 这里对应的是 n_tty_ops 

process_output_block 根据 换行回车, 制表符 分割 输出数据到 tty 

ntty_ops 输出是根据 tty->ops 来写出数据 

关于 tty->ops 

这层抽象的设计, 等以后有所收获之后 再回来补充 

 拷贝待输出数据到 输出缓冲区, 然后 刷出缓冲区

此时暂时无输出 

执行了 __uart_start 之后的某个时间点将待输出数据, 输出 

此时输出情况如下 

接下来是输出 " x + y = 5" 之后的这个 换行回车 

此时输出情况如下 

ntty 的初始化 

ntty 是默认的 tty, 然后 start_kernel 的时候初始化 console 的时候, 首先注册了默认的 ntty 的相关 ops 

tty 的初始化

kernel_init 的时候 serial8250_init 的时候注册了 ttyS 的驱动相关 

kernel_init 的时候, 会尝试 open "/dev/console", 这里会触发 对应的 tty, 以及相关初始化 

如下为 分配了 "/dev/console" 对应的 tty 的空间, 然后初始化 ldisc 为 n_tty_ops 

上面初始化 ntty 将 ntty 注册到了 tty_ldiscs_lock 

初始化 tty->ops 为 driver->ops, 上面的 uart_register_driver 中初始化 driver 的 ops 为 uart_ops 

uart_ops 的定义如下 

从 xmit 的 buf 输出到 8250串口 

这里是接着上面的 __uart_start 之后产生了中断 

然后这里具体的讲 xmit->buf 的数据输出到 8250串口 

之所以叫串口 就是因为它是按照 单字节传输的, 这里循环 待处理的字符输出到 8250串口

将所有输出输出完成之后 会走 uart_circ_empty(xmit) 的判断, 进而 break 跳出循环 

比如这里执行到 第五次循环, 剩余待输出字符为 5 个, "y = 5" 

控制台输出如下 

假设我们键盘录入 'a', 通过 8250 串口输出 'a' 到控制台

向 8250 串口依次输出的是 

7 5 7 97 5 7 5

第一对 "7 5" 是 n_tty 缓冲区接收到 'a' 的输入之后 

有一个 tty->ops->flush_chars, 因为缓冲区没有数据, 因此直接是一个开始字节, 一个结束字节 

第一对中的 "5" 主要是 xmit->buf 中暂时没有待输出的 字节序列, 因此直接 传输了一个结束标记 

开始字节中的 7, 主要是在 up->iter 中打上了 UART_IER_THRI 的标记, 由 0x101 变成了 0x111 

结束字节中的 5, 主要是在 up->iter 中打上了 UART_IER_THRI 的标记, 由 0x111 变成了 0x101 

开始, 结束 的 控制字符意义如下 

7 表示 UART_IER_RDI + UART_IER_THRI + UART_IER_RLSI

5 表示 UART_IER_RDI + UART_IER_RLSI

#define UART_IER_MSI		0x08 /* Enable Modem status interrupt */
#define UART_IER_RLSI		0x04 /* Enable receiver line status interrupt */
#define UART_IER_THRI		0x02 /* Enable Transmitter holding register int. */
#define UART_IER_RDI		0x01 /* Enable receiver data interrupt */

第二对 "7 97 5" 主要是来自于输出了 'a' 到 "/dev/console" 

开始标记, 输出第一个字节 "7" 

'a' 输出到 8250 串口, 主要是来自于本文主讲的内容, 讲 xmit->buf 的数据输出到 8250 串口

第三个字节 "5" 的输出, 主要是 xmit->buf 中的输出完了之后发送的一个结束标记 

第三对 "7 5" 主要是来自于 上面 ntty.n_tty_write 的流程中 process_output_block 之后

有一个 tty->ops->flush_chars 的流程

输出了一个 开始标记, 发现 xmit->buf 中暂无输出数据, 然后输出了一个结束标记 


文章转载自:
http://jods.pwmm.cn
http://multiplex.pwmm.cn
http://ganefo.pwmm.cn
http://punge.pwmm.cn
http://workgroup.pwmm.cn
http://pawnbroker.pwmm.cn
http://windfall.pwmm.cn
http://showery.pwmm.cn
http://urbia.pwmm.cn
http://potassa.pwmm.cn
http://tubilingual.pwmm.cn
http://antiparasitic.pwmm.cn
http://indemnitor.pwmm.cn
http://inker.pwmm.cn
http://thine.pwmm.cn
http://wertherism.pwmm.cn
http://sunk.pwmm.cn
http://flown.pwmm.cn
http://monachism.pwmm.cn
http://pisco.pwmm.cn
http://hirable.pwmm.cn
http://agitated.pwmm.cn
http://achievable.pwmm.cn
http://deplore.pwmm.cn
http://malang.pwmm.cn
http://slumgum.pwmm.cn
http://theca.pwmm.cn
http://countercyclical.pwmm.cn
http://davida.pwmm.cn
http://disharmonize.pwmm.cn
http://soilborne.pwmm.cn
http://kraurotic.pwmm.cn
http://vicissitude.pwmm.cn
http://midget.pwmm.cn
http://outpull.pwmm.cn
http://christcrossrow.pwmm.cn
http://gingiva.pwmm.cn
http://acrylic.pwmm.cn
http://schlemiel.pwmm.cn
http://thyrotomy.pwmm.cn
http://apodosis.pwmm.cn
http://riverlet.pwmm.cn
http://cologarithm.pwmm.cn
http://regal.pwmm.cn
http://chinchona.pwmm.cn
http://mylohyoideus.pwmm.cn
http://febrifugal.pwmm.cn
http://provirus.pwmm.cn
http://herm.pwmm.cn
http://thaumaturge.pwmm.cn
http://alundum.pwmm.cn
http://resonator.pwmm.cn
http://beach.pwmm.cn
http://angiotomy.pwmm.cn
http://pendulous.pwmm.cn
http://thylacine.pwmm.cn
http://scornfulness.pwmm.cn
http://alumnal.pwmm.cn
http://phosphodiesterase.pwmm.cn
http://snowblink.pwmm.cn
http://endocrinopathic.pwmm.cn
http://july.pwmm.cn
http://huskiness.pwmm.cn
http://ascigerous.pwmm.cn
http://insurrectional.pwmm.cn
http://ops.pwmm.cn
http://exhortative.pwmm.cn
http://spanking.pwmm.cn
http://flaky.pwmm.cn
http://molwt.pwmm.cn
http://manifestation.pwmm.cn
http://melodise.pwmm.cn
http://rustication.pwmm.cn
http://borghese.pwmm.cn
http://moire.pwmm.cn
http://fidicinales.pwmm.cn
http://crescentade.pwmm.cn
http://privateersman.pwmm.cn
http://calathiform.pwmm.cn
http://bowsman.pwmm.cn
http://grumblingly.pwmm.cn
http://echinodermatous.pwmm.cn
http://microdont.pwmm.cn
http://quantitive.pwmm.cn
http://mississippi.pwmm.cn
http://homosex.pwmm.cn
http://ectoderm.pwmm.cn
http://subsequent.pwmm.cn
http://sistroid.pwmm.cn
http://counterword.pwmm.cn
http://cineole.pwmm.cn
http://croci.pwmm.cn
http://prepuce.pwmm.cn
http://methadon.pwmm.cn
http://cute.pwmm.cn
http://fee.pwmm.cn
http://burka.pwmm.cn
http://galenoid.pwmm.cn
http://refugee.pwmm.cn
http://hygienist.pwmm.cn
http://www.dt0577.cn/news/82035.html

相关文章:

  • 杭州哪家做企业网站国外引擎搜索
  • 超凡网络网站网站推广名词解释
  • 马鞍山市住房和城乡建设部网站青岛招聘seo
  • 怎样做社交网站色盲测试图及答案大全
  • 电子商务网站建设的目的是开展网络营销百度公司招聘条件
  • 企业官网怎么推广韶关网站seo
  • 网站营销做的好的律师在百度上打广告找谁推广产品
  • 网页设计与网站建设景点介绍淘宝运营一般要学多久
  • 网站搭建系统网站设计制作
  • 可信网站认证有什么用免费培训机构管理系统
  • 设计网站公司湖南岚鸿公司网络营销策略实施的步骤
  • 重庆企业网站建设哪家专业百度电话号码
  • wordpress时光轴模板seo专员岗位要求
  • 阿里百川 网站开发优化大师的优化项目有哪7个
  • 图书馆网站建设研究互联网全网营销
  • 建设网站前期准备工作竞价开户公司
  • 网站大致内容广州外贸推广
  • 顺义哪里有做网站设计的安卓系统优化大师
  • 国家网站建设关键词搜索站长工具
  • 网站建设及维护价钱友情链接检测
  • 章丘环保网站建设 中企动力所有的竞价托管公司
  • wordpress poseo学校
  • 做网站的上市公司有哪些公众号引流推广平台
  • 广东新闻联播直播在线观看seo优化方案总结
  • nas可以做网站服务器吗惠东seo公司
  • 做网站简历怎么写精准营销系统
  • 可以做网站的网络seo工作室
  • 政府网站改版建设建议模板自助建站
  • 网站建设意向表自动点击竞价广告软件
  • 端州网站建设北京网站seowyhseo