固件firmware_Linux内核
1.相关函数
1.相关函数 int request_firmware_nowait( struct module *module, bool uevent, const char *name, struct device *device, gfp_t gfp, void *context, /*驱动自己可以向回调函数传递一个参数,一般指向驱动设备结构体*/ void (*cont)(const struct firmware *fw, void *context)) /*失败时传入的fw=NULL*/ int request_firmware(const struct firmware **firmware_p, const char *name, struct device *device) void release_firmware(const struct firmware *fw)
2.函数调用关系
request_firmware_nowait INIT_WORK(&fw_work->work, request_firmware_work_func); schedule_work(&fw_work->work); 这就是异步的实现方法,queue到内核线程中去执行 fw_get_filesystem_firmware kernel_read_file_from_path file = filp_open(path, O_RDONLY, 0); kernel_read_file(file, buf, size, max_size, id);
2.相关结构体
/* direct firmware loading support */ static char fw_path_para[256]; static const char * const fw_path[] = { /* 固件查找路径 */ fw_path_para, /* 模块参数,可作为启动参数 */ "/lib/firmware/updates/" UTS_RELEASE, "/lib/firmware/updates", "/lib/firmware/" UTS_RELEASE, "/lib/firmware" }; module_param_string(path, fw_path_para, sizeof(fw_path_para), 0644); /*这个还做为模块参数供用户配置*/ MODULE_PARM_DESC(path, "customized firmware image search path with a higher priority than default path");
struct firmware { size_t size; const u8 *data; /*data里面存的直接是打卡固件里面的数据*/ struct page **pages; /* firmware loader private fields */ void *priv; /*_request_firmware_prepare中指向struct firmware_buf *buf, 若驱动App这里指定为null,内核分配的buff就存在这里*/ };
3.实验测试
error = request_firmware_nowait(THIS_MODULE, true, "maxtouch.cfg", &client->dev, GFP_KERNEL, data, mxt_config_cb); mxt_config_cb(const struct firmware *cfg, void *ctx) { printk(KERN_INFO"hello: size=%d, content=%s\n", cfg->size, buff); } # mkdir -p /lib/firmware/updates # touch /lib/firmware/updates/maxtouch.cfg # ehco abcdefghijklmnopqrst > /lib/firmware/updates/maxtouch.cfg 打印: hello: size=21, content=abcdefghijklmnopqrst
好文:http://blog.chinaunix.net/uid-30512847-id-5576781.html
分类:
Linux驱动相关
posted on 2018-11-15 22:40 Hello-World3 阅读(1204) 评论(0) 编辑 收藏 举报
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 展开说说关于C#中ORM框架的用法!