嵌入式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/

目录
相关文章
|
5月前
|
安全 Linux iOS开发
Binary Ninja 5.1.8104 (macOS, Linux, Windows) - 反编译器、反汇编器、调试器和二进制分析平台
Binary Ninja 5.1.8104 (macOS, Linux, Windows) - 反编译器、反汇编器、调试器和二进制分析平台
532 53
Binary Ninja 5.1.8104 (macOS, Linux, Windows) - 反编译器、反汇编器、调试器和二进制分析平台
|
5月前
|
Linux API iOS开发
Binary Ninja 4.2.6455 (macOS, Linux, Windows) - 反编译器、反汇编器、调试器和二进制分析平台
Binary Ninja 4.2.6455 (macOS, Linux, Windows) - 反编译器、反汇编器、调试器和二进制分析平台
374 14
Binary Ninja 4.2.6455 (macOS, Linux, Windows) - 反编译器、反汇编器、调试器和二进制分析平台
|
5月前
|
SQL 安全 Linux
Metasploit Pro 4.22.8-20251014 (Linux, Windows) - 专业渗透测试框架
Metasploit Pro 4.22.8-20251014 (Linux, Windows) - 专业渗透测试框架
282 1
Metasploit Pro 4.22.8-20251014 (Linux, Windows) - 专业渗透测试框架
|
5月前
|
Linux 网络安全 iOS开发
Metasploit Framework 6.4.95 (macOS, Linux, Windows) - 开源渗透测试框架
Metasploit Framework 6.4.95 (macOS, Linux, Windows) - 开源渗透测试框架
496 1
Metasploit Framework 6.4.95 (macOS, Linux, Windows) - 开源渗透测试框架
|
6月前
|
安全 Linux 网络安全
Metasploit Pro 4.22.8-2025091701 (Linux, Windows) - 专业渗透测试框架
Metasploit Pro 4.22.8-2025091701 (Linux, Windows) - 专业渗透测试框架
418 2
Metasploit Pro 4.22.8-2025091701 (Linux, Windows) - 专业渗透测试框架
|
6月前
|
Linux 网络安全 iOS开发
Metasploit Framework 6.4.90 (macOS, Linux, Windows) - 开源渗透测试框架
Metasploit Framework 6.4.90 (macOS, Linux, Windows) - 开源渗透测试框架
473 1
Metasploit Framework 6.4.90 (macOS, Linux, Windows) - 开源渗透测试框架
|
6月前
|
安全 Linux 网络安全
Metasploit Framework 6.4.88 (macOS, Linux, Windows) - 开源渗透测试框架
Metasploit Framework 6.4.88 (macOS, Linux, Windows) - 开源渗透测试框架
617 0
|
6月前
|
数据管理 Linux iOS开发
Splunk Enterprise 9.4.5 (macOS, Linux, Windows) - 机器数据管理和分析
Splunk Enterprise 9.4.5 (macOS, Linux, Windows) - 机器数据管理和分析
185 0
|
6月前
|
缓存 安全 Linux
Metasploit Pro 4.22.8-2025082101 (Linux, Windows) - 专业渗透测试框架
Metasploit Pro 4.22.8-2025082101 (Linux, Windows) - 专业渗透测试框架
251 0
|
7月前
|
SQL 安全 Linux
Metasploit Pro 4.22.8-2025073001 (Linux, Windows) - 专业渗透测试框架
Metasploit Pro 4.22.8-2025073001 (Linux, Windows) - 专业渗透测试框架
211 0