日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

[platform]新旧内核的device设备注册对比

發(fā)布時(shí)間:2025/3/15 编程问答 34 豆豆
生活随笔 收集整理的這篇文章主要介紹了 [platform]新旧内核的device设备注册对比 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

轉(zhuǎn)自:http://blog.chinaunix.net/uid-7332782-id-3268801.html

?

1. Version2.6內(nèi)核啟動(dòng)過程

????start_kernel(?)  //板子上電啟動(dòng)后進(jìn)入start_kernel( ),相當(dāng)于程序的main入口

????????-->setup_arch(&command_line) ?//command_line由內(nèi)核傳入

????????????-->mdesc?=?setup_machine(machine_arch_type);

????????????????-->list?=?lookup_machine_type(nr);?//匯編實(shí)現(xiàn)查找機(jī)器碼所定義的平臺(tái),找到后返回mdesc結(jié)構(gòu)? ? ? ? ? ? ? ?

????????????-->init_machine?=?mdesc->init_machine; ?//struct machine_desc?*mdesc;machine_desc結(jié)構(gòu)很重要,

????????-->rest_init()

????????????-->kernel_thread(kernel_init,?NULL,?CLONE_FS?|?CLONE_SIGHAND);?//定義進(jìn)程kernel_init,pid=1,在kthreadd進(jìn)程創(chuàng)建好后調(diào)度運(yùn)行? ? ? ? ??

????????????????-->kernel_init()

????????????????????-->do_basic_setup()

????????????????????????-->driver_init()

????????????????????????????-->devices_init()

????????????????????????????-->buses_init()

????????????????????????????-->classes_init()

????????????????????????????-->platform_bus_init()

????????????????????????-->do_initcalls() ?//此函數(shù)很重要,執(zhí)行了initcall表中所有的函數(shù),包含了init_machine(saar_init())函數(shù)? ? ? ? ? ? ? ? ? ? ? ?

????????????????????????????-->saar_init()

????????????????????-->init_post() ???//調(diào)度用戶空間程序,比如bash,在用戶空間死循環(huán)執(zhí)行程序?? ? ? ? ? ? ? ? ??

????????????-->pid?=?kernel_thread(kthreadd,?NULL,?CLONE_FS?|?CLONE_FILES); ?//定義進(jìn)程kthreadd

2. Version3.x內(nèi)核啟動(dòng)過程和2.6版本在init_machine加載設(shè)備資源的差異對(duì)比

  • 在2.6內(nèi)核中, 在setup_arch()中,舉個(gè)例子imx5,

-->init_machine=mdesc->init_machine;  //init/main.c->start_kernel()->setup_arch(), 將init_machine指向mdesc結(jié)構(gòu)體重的init_machine指針,而mdesc中該指針指向具體芯片對(duì)應(yīng)的設(shè)備資源函數(shù)mxc_board_init.

? -->.init_machine=mxc_board_init;    //arch/arm/mach-mx5/mx50_arm2.c->MACHINE_START()?,宏即時(shí)初始化machine_desc結(jié)構(gòu)體 ? ? ? ?

? ? -->mxc_register_device(&mxc_dma_device);  //arch/arm/mach-mx5/mx50_arm2.c->mxc_board_init(), 在mxc_board_init完成這些設(shè)備注冊(cè)

? ? -->mxc_register_device(&mxc_wdt_device);  //mxc_wdt_device這些設(shè)備資源也都申明在mach-mx50下面

? ? -->mxc_register_device(&mxci2c_devices[0]);

? ? -->..........

當(dāng)然在setup_arch()中對(duì)init_machine進(jìn)行初始化,這個(gè)時(shí)候并沒有調(diào)用init_machine函數(shù),init_machine是在代碼中被定義為arch_initcall屬性(arch/arm/kernel/setup.c), 然后在do_initcalls()中進(jìn)行遍歷調(diào)用,具體見上述的啟動(dòng)過程。

由上述可以看出,在系統(tǒng)啟動(dòng)時(shí),device設(shè)備就已經(jīng)register到總線上了,而3.x以后已經(jīng)不在mach-**中申明設(shè)備資源了,那啟動(dòng)流程如何呢,見下一節(jié)。

  • ?在3.x內(nèi)核中,在setup_arch()是這么處理的, 首先解析dtb

-->setup_arch()  //init/main.c->start_kernel()->setup_arch()

? -->mdesc=setup_machine_fdt();

? -->unflatten_device_tree()  //和2.6內(nèi)核不同,在setup_arch()中并沒有init_machine = mdesc->init_machine.那init_machine如何執(zhí)行呢?

? ? ?-->__unflatten_device_tree()

? ? ? ? -->unflatten_dt_node()  //到此基本完成dts中node到鏈表的操作

節(jié)點(diǎn)中的設(shè)備注冊(cè)

-->DT_MACHINE_START  //machine_desc結(jié)構(gòu)體賦值,在2.6內(nèi)核中宏偉MACHINE_START,文件位置:arch/arm/mach-***

? -->.init_machine=imx6sx_init_machine

? ? ?-->of_platform_populate();?  //imx6sx_init_machine()調(diào)用,在setup_arch()中解析設(shè)備數(shù),構(gòu)造設(shè)備節(jié)點(diǎn)鏈表,然后在這里進(jìn)行設(shè)備的注冊(cè),而init_machine為arch_initcall屬性,當(dāng)在setup_arch()后面代碼調(diào)用到do_initcalls()函數(shù)時(shí)調(diào)用init_machine()函數(shù)完成設(shè)備注冊(cè)

? ? ? ? -->of_platform_bus_create();?  //由for_each_child_of_node()調(diào)用,遍歷device tree中每個(gè)節(jié)點(diǎn)

? ? ? ? ? ?-->of_platform_device_create_pdata()

? ? ? ? ? ? ? -->of_device_alloc()    //為每個(gè)device申請(qǐng)空間

? ? ? ? ? ? ? -->platform_device_put()

? ? ? ? ? ?-->of_platform_bus_create()

到此完成設(shè)備的注冊(cè)。

在3.x的setup.c中關(guān)于init_machine的調(diào)用是這么定義的

1 static int __init customize_machine(void) 2 { 3 /* 4 * customizes platform devices, or adds new ones 5 * On DT based machines, we fall back to populating the 6 * machine from the device tree, if no callback is provided, 7 * otherwise we would always need an init_machine callback. 8 */ 9 if (machine_desc->init_machine) 10 machine_desc->init_machine(); 11 #ifdef CONFIG_OF 12 else 13 of_platform_populate(NULL, of_default_bus_match_table, 14 NULL, NULL); 15 #endif 16 return 0; 17 }

?

關(guān)于init_machine到底會(huì)不會(huì)被執(zhí)行,在Documentation/Devicetree/usage-model.txt中有這么一段話

The most interesting hook in the DT context is .init_machine() which is primarily responsible for populating the Linux device model with data about the platform. Historically this has been implemented on embedded platforms by defining a set of static clock structures, platform_devices, and other data in the board support .c file, and registering it en-masse in .init_machine(). When DT is used, then instead of hard coding static devices for each platform, the list of devices can be obtained by parsing the DT, and allocating device structures dynamically.The simplest case is when .init_machine() is only responsible for registering a block of platform_devices. A platform_device is a concept used by Linux for memory or I/O mapped devices which cannot be detected by hardware, and for 'composite' or 'virtual' devices (more on those later). While there is no 'platform device' terminology for the DT, platform devices roughly correspond to device nodes at the root of the tree and children of simple memory mapped bus nodes.

?

轉(zhuǎn)載于:https://www.cnblogs.com/aaronLinux/p/5559721.html

總結(jié)

以上是生活随笔為你收集整理的[platform]新旧内核的device设备注册对比的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 欧美猛操 | 欧美黄色成人 | 国产精品日日摸夜夜爽 | 福利一二三区 | 国产在线一级片 | 免费男女乱淫真视频免费播放 | 日韩欧美亚洲一区二区三区 | 日本少妇高潮喷水xxxxxxx | 欧美91在线 | 韩国美女啪啪 | 无码精品人妻一区二区三区影院 | 成人ay| 欧美劲爆第一页 | 推特裸体gay猛交gay | 日日躁夜夜躁狠狠久久av | 亚洲精华国产精华精华液网站 | 97久久久| 精品无码一区二区三区免费 | 欧美成年人网站 | 国产做受高潮动漫 | 午夜在线精品 | 一边顶弄一边接吻 | 一级在线免费观看 | 三级中文字幕在线 | 亚洲激情图片区 | 日本一区不卡在线观看 | 国产高清免费在线播放 | 秋霞av鲁丝片一区二区 | 制服丝袜第二页 | 女性私密整形视频 | 亚洲制服丝袜在线播放 | 性色av一区二区三区四区 | 欲色综合| 男女精品视频 | 成人免费视频观看视频 | 少妇高潮一区二区三区在线 | xxxxhd欧美| 波多野结衣中文字幕一区二区三区 | www.国产.com| 国产精品扒开腿做爽爽爽男男 | 无码人妻精品一区二区蜜桃网站 | 蜜桃av一区二区三区 | 美女扒开让男人桶爽 | 人人妻人人澡人人爽人人精品 | 韩国伦理大片 | 日韩一级视频在线观看 | 草久影院 | 天天操天天干天天 | 国产性自拍 | 狂野欧美性猛交xxⅹ李丽珍 | 国产精品一区二区三区久久久 | 四虎永久网址 | 在线看v片| 国产一二三四在线 | 永久免费未网 | 综合xx网 | 野战少妇38p| 欧美日韩一区精品 | 老熟妇一区二区三区 | 国产日韩专区 | 亚洲AV无码成人精品区在线观 | 天堂视频一区 | 国产精品亚洲成在人线 | 天天做天天爱天天操 | 一级片在线免费播放 | 福利在线一区二区三区 | 国产日韩欧美电影 | 国产麻豆一精品一男同 | 精品免费在线 | 四虎av在线 | 日本3级网站 | 欧美大浪妇猛交饥渴大叫 | 播放黄色一级片 | 日韩香蕉网 | 成人免费网站在线观看 | 成人免费高清在线播放 | 久章草在线观看 | 女人脱下裤子让男人桶 | 三级亚洲欧美 | 中文在线a∨在线 | 国产精品99无码一区二区视频 | 天天色天天射天天干 | 色吟av| 日本一二三区在线视频 | 蜜臀av无码精品人妻色欲 | 亚洲自拍偷拍一区二区三区 | 国产精品国色综合久久 | 欧美一区二不卡视频 | 天堂在线| 国产在线视频不卡 | 日韩a级在线观看 | 综合在线观看 | 欧美一区二区高清 | 自拍偷拍欧美激情 | 国产又粗又大又爽视频 | 亚洲激情欧美色图 | 精品99久久久久成人网站免费 | 免费看黄网站在线 | 一本久道在线 |