嵌入式linux中Framebuffer 驱动程序框架分析

简介: 嵌入式linux中Framebuffer 驱动程序框架分析

1. 怎么编写字符设备驱动程序

   本文参考百问网驱动大全

  • 主设备号
  • 构造 file_operations 结构体,填充 open/read/write 等成员函数
  • 注册驱动:register_chrdev(major, name, &fops)
  • 入口函数
  • 出口函数

2. Framebuffer 驱动程序框架

分为上下两层:

  • fbmem.c:承上启下
  • 实现、注册 file_operations 结构体
  • 把 APP 的调用向下转发到具体的硬件驱动程序
  • xxx_fb.c:硬件相关的驱动程序
  • 实现、注册 fb_info 结构体
  • 实现硬件操作

调用关系:

例子1:
app:  open("/dev/fb0", ...)   主设备号: 29, 次设备号: 0
--------------------------------------------------------------
kernel:
   fb_open
    int fbidx = iminor(inode);
    struct fb_info *info = = registered_fb[0];
例子2:
app:  read()
---------------------------------------------------------------
kernel:
  fb_read
   int fbidx = iminor(inode);
   struct fb_info *info = registered_fb[fbidx];
   if (info->fbops->fb_read)
      return info->fbops->fb_read(info, buf, count, ppos);
   src = (u32 __iomem *) (info->screen_base + p);
   dst = buffer;
   *dst++ = fb_readl(src++);
   copy_to_user(buf, buffer, c)

3. 怎么编写 Framebuffer 驱动程序

核心结构体:

  • 分配 fb_info
  • framebuffer_alloc
  • 设置 fb_info
  • var
  • fbops
  • 硬件相关操作
  • 注册 fb_info
  • register_framebuffer

4. 阅读源码

阅读 Android 和 Linux kernel 源码:

http://aospxref.com/

目录
相关文章
|
11天前
|
安全 Linux 网络安全
Metasploit Framework 6.4.88 (macOS, Linux, Windows) - 开源渗透测试框架
Metasploit Framework 6.4.88 (macOS, Linux, Windows) - 开源渗透测试框架
186 0
|
20天前
|
缓存 安全 Linux
Metasploit Pro 4.22.8-2025082101 (Linux, Windows) - 专业渗透测试框架
Metasploit Pro 4.22.8-2025082101 (Linux, Windows) - 专业渗透测试框架
75 0
|
3月前
|
安全 Linux 网络安全
Metasploit Pro 4.22.7-2025061201 (Linux, Windows) - 专业渗透测试框架
Metasploit Pro 4.22.7-2025061201 (Linux, Windows) - 专业渗透测试框架
121 3
Metasploit Pro 4.22.7-2025061201 (Linux, Windows) - 专业渗透测试框架
|
1月前
|
SQL 安全 Linux
Metasploit Pro 4.22.8-2025073001 (Linux, Windows) - 专业渗透测试框架
Metasploit Pro 4.22.8-2025073001 (Linux, Windows) - 专业渗透测试框架
111 0
|
Unix Linux iOS开发
Splunk Enterprise 10.0.0 (macOS, Linux, Windows) - 搜索、分析和可视化,数据全面洞察平台
Splunk Enterprise 10.0.0 (macOS, Linux, Windows) - 搜索、分析和可视化,数据全面洞察平台
52 0
|
4月前
|
安全 Unix Linux
Metasploit Pro 4.22.7-2025052201 (Linux, Windows) - 专业渗透测试框架
Metasploit Pro 4.22.7-2025052201 (Linux, Windows) - 专业渗透测试框架
119 5
Metasploit Pro 4.22.7-2025052201 (Linux, Windows) - 专业渗透测试框架
|
4月前
|
数据采集 安全 Linux
Metasploit Pro 4.22.7-2025051201 (Linux, Windows) - 专业渗透测试框架
Metasploit Pro 4.22.7-2025051201 (Linux, Windows) - 专业渗透测试框架
101 4
Metasploit Pro 4.22.7-2025051201 (Linux, Windows) - 专业渗透测试框架
|
4月前
|
Linux 网络安全 iOS开发
Metasploit Framework 6.4.63 (macOS, Linux, Windows) - 开源渗透测试框架
Metasploit Framework 6.4.63 (macOS, Linux, Windows) - 开源渗透测试框架
119 4
Metasploit Framework 6.4.63 (macOS, Linux, Windows) - 开源渗透测试框架
|
5月前
|
存储 安全 Linux
Metasploit Pro 4.22.7-2025040601 (Linux, Windows) - 专业渗透测试框架
Metasploit Pro 4.22.7-2025040601 (Linux, Windows) - 专业渗透测试框架
209 1
Metasploit Pro 4.22.7-2025040601 (Linux, Windows) - 专业渗透测试框架
|
6月前
|
监控 Linux
Linux基础:文件和目录类命令分析。
总的来说,这些基础命令,像是Linux中藏匿的小矮人,每一次我们使用他们,他们就把我们的指令准确的传递给Linux,让我们的指令变为现实。所以,现在就开始你的Linux之旅,挥动你的命令之剑,探索这个充满神秘而又奇妙的世界吧!
143 19