[知其然不知其所以然-10] linux dmi table matching
来源:互联网 发布:朋友圈算法 编辑:程序博客网 时间:2024/06/03 23:01
我们经常需要给特定的平台写Quirk,也就是新加一段代码,这段代码只能给本平台使用。实现的原理就是,获取BIOS提供的板级信息,
代码里做判断,如果当前确实是指定平台上运行,那执行回调。talk is cheap, show me the code:
static struct dmi_system_id msr_save_dmi_table[] = { { .callback = msr_initialize_bdw, .ident = "BROADWELL BDX_EP", .matches = { DMI_MATCH(DMI_PRODUCT_NAME, "GRANTLEY"), DMI_MATCH(DMI_PRODUCT_VERSION, "E63448-400"), }, }, {}};static int pm_check_save_msr(void){ dmi_check_system(msr_save_dmi_table); return 0;}
其中,dmi_check_system 函数,回遍历dmi_system_id数组的每个成员,
然后,对每个成员,都做如下判断,当所有的DMI_MATCH字段都匹配后,
执行callback(其实我写这篇文章就是为了突出“所有”这个词,写这么多像是骗稿费)。
代码很简单,直接提出来供参考:
int dmi_check_system(const struct dmi_system_id *list){ int count = 0; const struct dmi_system_id *d; for (d = list; !dmi_is_end_of_table(d); d++) if (dmi_matches(d)) { count++; if (d->callback && d->callback(d)) break; } return count;}
static bool dmi_matches(const struct dmi_system_id *dmi){ int i; WARN(!dmi_initialized, KERN_ERR "dmi check: not initialized yet.\n"); for (i = 0; i < ARRAY_SIZE(dmi->matches); i++) { int s = dmi->matches[i].slot; if (s == DMI_NONE) break; if (dmi_ident[s]) { if (!dmi->matches[i].exact_match && strstr(dmi_ident[s], dmi->matches[i].substr)) continue; else if (dmi->matches[i].exact_match && !strcmp(dmi_ident[s], dmi->matches[i].substr)) continue; } /* No match */ return false; } return true;}
0 0
- [知其然不知其所以然-10] linux dmi table matching
- linux dmi
- 知其然不知其所以然!
- DMI
- dmi
- [知其然不知其所以然-41] resource allocation in Linux
- 如何在windows下读取DMI table--原创
- linux下读取dmi信息的方法
- [知其然不知其所以然-8] linux cpufreq的sysfs文件详细解释
- Struts2(10):利用通配符实现DMI
- Linux查看BIOS信息:dmidecode命令以及SMBIOS、DMI等
- [Linux]--Pattern Matching
- DMI 用法
- [知其然不知其所以然-9] linux e820/efi memory map是如何初始化的
- bootstrap-table显示数据时显示No matching records found
- 10、Regular Expression Matching
- 10,Regular Expression Matching
- 10Regular Expression Matching
- 二分法查找和快速排序 二分法是分治算法的一种特殊形式,利用分治策略求解时,所需时间取决于分解后子问题的个数、子问题的规模大小等因素,而二分法,由于其划分的简单和均匀的特点,是查找数据时经常采用的一种有
- Metasploit入门
- oracle 10g数据库备份与还原总结(转载)
- error LNK2019: 无法解析的外部符号_cvReleaseImage,该符号在函数_main 中被引用
- android访问网络,下载图片,并设置UI
- [知其然不知其所以然-10] linux dmi table matching
- ios 常见github资料
- 《启示录》阅读笔记(六)——产品探索+产品原则
- Appium 处理滑动
- 剑指Offer-29-数组出现次数超过一半的数字-基于Partition函数的O(n)算法
- EAR项目构建的几种方式
- oracle管理归档日志文件
- PHP SAPI
- 多线程和应用