In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "how to define the Linux DRM kernel module". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to define the Linux DRM kernel module.
1. Module definition
List the definitions of modules in the DRM driver as follows:
Module_platform_driver (dw_hdmi_rockchip_pltfm_driver); # # dw_hdmi-rockchip.cmodule_platform_driver (vop_platform_driver); # # rockchip_vop_reg.cmodule_platform_driver (rockchip_drm_platform_driver); # # rockchip_drm_drv.c
Expand the module_platform_driver macro as follows:
Module_init (dw_hdmi_rockchip_pltfm_driver_init); module_init (vop_platform_driver_init); module_init (rockchip_drm_platform_driver_init)
Where module_init is defined as device_initcall (fn), the code is as follows:
# define module_init (x) _ initcall (x); # define_ _ initcall (fn) device_initcall (fn) # define device_initcall (fn) _ define_initcall (fn, 6)
Continue to expand, eventually defined as:
# 1.static initcall_t _ initcall_dw_hdmi_rockchip_pltfm_driver_init6 _ used\ _ attribute__ ((_ _ section__ (".initcall" # id ".init")) = dw_hdmi_rockchip_pltfm_driver_init;\ # 2.static initcall_t _ initcall_vop_platform_driver_init6 _ used\ _ attribute__ ((_ _ section__ (".initcall" # id ".init") = vop_platform_driver_init \ # 3.static initcall_t _ initcall_rockchip_drm_platform_driver_init6 _ used\ _ attribute__ ((_ _ section__ (".initcall" # id ".init")) = rockchip_drm_platform_driver_init;\
Please note the function pointer and function name defined above, and the corresponding address and loading order are described below.
Second, link location
Use the objdump command in the cross tool chain corresponding to the RockPI 4A Linux kernel to get the header information of all segments in vmliux, as follows:
/ usr/local/gcc-linaro-7.3.1-2018.05-x86_64_aarch74-linux-gnu/bin/aarch74-linux-gnu-objdump-x vmlinux > 1.txt
In the 1.txt file, you can find the location of the above three functions (in the .init.text section) and the function pointer (in the .init.data section). The details are as follows:
Ffffff8009149828 l F .init.text 0000000000000020 dw_hdmi_rockchip_pltfm_driver_initffffff80091498e8 l F .init.text 0000000000000020 vop_platform_driver_initffffff8009149908 l F .init.text 0000000000000024 rockchip_drm_platform_driver_initffffff800920f498 l O .init.data 0000000000000008 _ _ initcall_dw_hdmi_rockchip_pltfm_driver_init6ffffff800920f4c8 l O .init.data 0000000000000008 _ _ initcall_vop_platform_driver_init6ffffff800920f4d0 l O .init.data 0000000000000008 _ _ initcall_rockchip_drm_platform_driver_init6
The above is listed in the order of addresses from smallest to largest, and you can also view the link order in the System.map file.
Note: in addition to objdump, there are many useful tools in the cross-compilation tool chain, which will be introduced later.
Third, loading sequence
If the kernel module is defined using the same macro, the Linux kernel loads the kernel module in the order of the addresses in the .init.data section, that is, running the corresponding function in the corresponding .init.text. Therefore, the loading order of the three kernel modules in this paper is:
1.dw_hdmi_rockchip_pltfm_driver_init2.vop_platform_driver_init3.rockchip_drm_platform_driver_init
The position of kernel modules of the same level in the .init.data section is related to the location of the files in the Makefile.
The locations of the above three files in drivers/gpu/drm/rockchip/Makefile are as follows:
Rockchipdrm-y: = rockchip_drm_drv.o rockchip_drm_fb.o # # rockchip_drm_drv.c... obj-$ (CONFIG_ROCKCHIP_DW_HDMI) + = dw_hdmi-rockchip.o # # dw_hdmi-rockchip.c...obj-$ (CONFIG_DRM_ROCKCHIP) + = rockchip_vop_reg.o rockchipdrm.o # # rockchip_vop_reg.c
When the kernel is compiled, rockchipdrm.o is replaced with rockchip_drm_drv.o rockchip_drm_fb.o. So the compilation order of these three files is as follows:
Root@ubuntu:/home/run/code/rockchip-bsp#. / build/mk-kernel.sh rockpi4a Building kernel for rockpi4a board!4.4.154 CHK include/config/kernel.release CHK include/generated/uapi/linux/version.h CHK scripts/mod/devicetable-offsets.h CHK include/generated/utsrelease.h CHK include/generated/timeconst.h CHK include/generated/bounds.h CHK include/generated/asm-offsets.h CALL scripts/checksyscalls .shmake [1]: 'include/generated/vdso-offsets.h' is up to date. CHK include/generated/compile.h CHK kernel/config_data.h CC drivers/gpu/drm/rockchip/dw_hdmi-rockchip.o # # dw_hdmi-rockchip.c CC drivers/gpu/drm/rockchip/rockchip_vop_reg.o # # rockchip_vop_reg.c CC drivers/gpu/drm/rockchip/rockchip_drm_drv.o # # rockchip_drm_drv.c LD drivers/gpu/drm/rockchip/rockchipdrm.o LD Drivers/gpu/drm/rockchip/built-in.o LD drivers/gpu/drm/built-in.o LD drivers/gpu/built-in.o LD drivers/built-in.o LINK vmlinu has come here I believe you have a deeper understanding of "how to define the Linux DRM kernel module", so you might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.