Equipment initialization method and device, equipment, readable storage medium and vehicle

By using the device tree abstract layer to parse the device tree binary file and save the parent-child relationship of the device node during the device initialization process, the problem of inefficient device initialization in the existing technology is solved, and more efficient device driver management and loading is achieved.

CN119883384APending Publication Date: 2025-04-25BEIJING CO WHEELS TECH CO LTD
View PDF -1 Cites 0 Cited by

Patent Information

Application Number
CN202311384694.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-10-24
Publication Date
2025-04-25

Smart Images

  • Figure CN119883384A_ABST
    Figure CN119883384A_ABST
Patent Text Reader

Abstract

The invention relates to an equipment initialization method and device, equipment, a readable storage medium and a vehicle. According to the method and the device, the set membership among the device nodes is stored in the device node information, so that when the driving management process uses the interface provided by the device tree abstraction layer to analyze the device tree binary file, the device nodes can be traversed, and the device driving program can be loaded according to the set membership among the plurality of device nodes; and the management efficiency of the device driver is improved, so that the device initialization efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of computer technology, and in particular to a device initialization method, apparatus, device, readable storage medium and vehicle. Background Art

[0002] Device Tree (DT) is a data structure used to describe various hardware devices on board-level devices. Hardware devices can be understood as physical devices, such as hard disks, mice, chips, central processing units (CPUs), etc. During the boot process of the operating system, the kernel will parse the device tree and obtain the properties of each device node (such as the resources and information of the device node) to initialize the corresponding device.

[0003] Device Tree Source (DTS) is a data structure and language that describes hardware. DTS is used to pass device node properties to the operating system kernel, so the operating system does not need to describe device information through hard coding. DTS is compiled into a device tree binary file (Device Tree Blob, DTB) by DTC (Device Tree Compiler) and loaded into memory for access by the computer operating system.

[0004] In the prior art, during the device initialization process of a microkernel operating system such as seL4, the device driver directly uses the interface of the libfdt open source library to access the original DTB file. However, during the access process, it is necessary to first traverse the DTB to obtain the offset of the device node in the DTB, and then call the interface to obtain the properties of the device node. When accessing the parent node of a node, it is necessary to recursively search upward layer by layer, which is very inefficient. When there are many device nodes in the DTS, it is very time-consuming to traverse and access the parent nodes of all device nodes in the DTB. Summary of the invention

[0005] In order to solve the above technical problems, the present disclosure provides a device initialization method, apparatus, device, readable storage medium and vehicle to improve the efficiency of device initialization.

[0006] In a first aspect, an embodiment of the present disclosure provides a device initialization method, including:

[0007] In response to the kernel startup action, loading a preset driver management process;

[0008] The driver management process calls the interface provided by the device tree abstraction layer to parse the device tree binary file to obtain device node information, wherein the device node information at least includes the parent-child relationship between multiple device nodes;

[0009] Traversing the device nodes according to the parent-child relationship between the multiple device nodes through the driver management process to create a device driver list, wherein the device driver list represents the corresponding relationship between the device driver program and the device node;

[0010] Loading a target device driver that matches the target device node according to the device driver list;

[0011] Acquire a device node attribute of the target device node from the device node information through the target device driver;

[0012] An initialization operation is performed on the target device node according to the device node attribute.

[0013] In some embodiments, after the preset driver management process is loaded in response to the kernel startup action, the method further includes:

[0014] Creating a shared memory through the driver management process;

[0015] The device tree binary file is copied to the shared memory.

[0016] In some embodiments, after the driver management process calls the interface provided by the device tree abstraction layer to parse the device tree binary file and obtain the device node information, the method further includes:

[0017] The device node information is stored in the shared memory.

[0018] In some embodiments, the device node information includes at least an array of device node structures;

[0019] The driver management process calls the interface provided by the device tree abstraction layer to parse the device tree binary file to obtain device node information, including:

[0020] The driver management process calls the interface provided by the device tree abstraction layer to abstract the device tree binary file to obtain multiple device node structures;

[0021] The plurality of device node structures are organized into a device node structure array.

[0022] In some embodiments, each of the device node structures includes an array index of a parent node of the device node, and traversing the device nodes according to the parent-child relationship between the multiple device nodes through the driver management process includes:

[0023] For each device node, determine the position of the parent node of the device node in the device node structure array according to the array index of the parent node in the device node structure;

[0024] Access the parent node of the device node according to the position of the parent node in the device node structure array.

[0025] In some embodiments, obtaining the device node attribute corresponding to the target device node from the device node information through the target device driver includes:

[0026] Mapping a shared memory to a process address space of the device driver, wherein the device node information is stored in the shared memory;

[0027] The process address space is accessed through the device driver to obtain the device node attribute corresponding to the target device node.

[0028] In a second aspect, an embodiment of the present disclosure provides a device initialization apparatus, including:

[0029] A first loading module, used for loading a preset driver management process in response to a startup action of the kernel;

[0030] A parsing module, used for parsing a device tree binary file by calling an interface provided by a device tree abstraction layer through the driver management process to obtain device node information, wherein the device node information at least includes a parent-child relationship between multiple device nodes;

[0031] A first creation module, configured to traverse the device nodes according to the parent-child relationship between the plurality of device nodes through the driver management process, and create a device driver list, wherein the device driver list represents the corresponding relationship between the device driver program and the device node;

[0032] A second loading module, used for loading a target device driver matching the target device node according to the device driver list;

[0033] An acquisition module, which acquires device node attributes of the target device node from the device node information through the target device driver;

[0034] An initialization module is used to perform an initialization operation on the target device node according to the device node attributes.

[0035] In a third aspect, an embodiment of the present disclosure provides an electronic device, including:

[0036] Memory;

[0037] Processor; and

[0038] Computer programs;

[0039] The computer program is stored in the memory and is configured to be executed by the processor to implement the method as described in the first aspect.

[0040] In a fourth aspect, an embodiment of the present disclosure provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program is executed by a processor to implement the method described in the first aspect.

[0041] In a fifth aspect, an embodiment of the present disclosure provides a vehicle, comprising the device, electronic device or computer-readable storage medium as described above.

[0042] The device initialization method, apparatus, device, readable storage medium and vehicle provided by the embodiments of the present disclosure save the parent-child relationship between device nodes in the device node information, so that when the driver management process uses the interface provided by the device tree abstraction layer to parse the device tree binary file, it can traverse the device nodes and load the device driver program according to the parent-child relationship between multiple device nodes, thereby improving the management efficiency of the device driver program and thus improving the efficiency of device initialization. BRIEF DESCRIPTION OF THE DRAWINGS

[0043] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.

[0044] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0045] Figure 1 A flow chart of a device initialization method provided by an embodiment of the present disclosure;

[0046] Figure 2 A schematic diagram of an application scenario provided by an embodiment of the present disclosure;

[0047] Figure 3 A flow chart of a device initialization method provided by another embodiment of the present disclosure;

[0048] Figure 4 A signaling diagram of a device initialization method provided by another embodiment of the present disclosure;

[0049] Figure 5 A schematic diagram of the structure of a device initialization apparatus provided in an embodiment of the present disclosure;

[0050] Figure 6A schematic diagram of the structure of an electronic device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION

[0051] In order to more clearly understand the above-mentioned objectives, features and advantages of the present disclosure, the scheme of the present disclosure will be further described below. It should be noted that the embodiments of the present disclosure and the features in the embodiments can be combined with each other without conflict.

[0052] In the following description, many specific details are set forth to facilitate a full understanding of the present disclosure, but the present disclosure may also be implemented in other ways different from those described herein; it is obvious that the embodiments in the specification are only part of the embodiments of the present disclosure, rather than all of the embodiments.

[0053] The present disclosure provides a device initialization method, which is described below in conjunction with a specific embodiment.

[0054] Figure 1 A flow chart of a device initialization method provided in an embodiment of the present disclosure. The method can be applied to Figure 2 The application scenario shown includes the libfdt open source library, the device tree abstraction layer, the driver management process and several device driver processes. It can be understood that the device initialization method provided in the embodiment of the present disclosure can also be applied in other scenarios.

[0055] Combine the following Figure 2 The application scenario shown is Figure 1 The device initialization method shown in the figure is introduced, and the specific steps of the method are as follows:

[0056] S101, in response to a kernel startup action, loading a preset driver management process.

[0057] The kernel is the most basic part of the operating system. It is a piece of software that provides secure access to the computer's hardware for many applications. This access is limited, and the kernel determines when and how long a program can operate on a certain piece of hardware.

[0058] In some embodiments, the kernel in this step is a microkernel or a macrokernel, and the device initialization method provided in the embodiments of the present disclosure is applicable to microkernel operating systems as well as macrokernel operating systems. A microkernel refers to a kernel that only provides the most basic functions such as process scheduling and memory management, and device drivers and file systems are all implemented in user mode. Functions in the microkernel are divided into independent processes, and processes communicate through IPC. The degree of modularization is high, and the failure of one service will not affect another service. Among them, IPC (Inter-Process Communication) refers to inter-process communication, which is different from function calls, and different processes access corresponding services by sending messages.

[0059] The driver management process is responsible for managing each driver in the system. It is specifically used to organize and manage device node information and load device driver processes. When the system kernel is started, the driver management process is first loaded and run.

[0060] S102: The driver management process calls an interface provided by a device tree abstraction layer to parse a device tree binary file to obtain device node information, wherein the device node information at least includes a parent-child relationship between a plurality of device nodes.

[0061] The device tree abstraction layer includes a shared memory area for storing abstracted device node information. The device tree abstraction layer provides an application programming interface (Application Programming Interface, API) for the driver management process to parse the device tree binary file (Device Tree Blob, DTB).

[0062] The device tree binary file is generated by compiling the source file DTS of the device tree through the DTS compilation tool DTC (DeviceTree Compiler). The device tree binary file organizes the node attributes and content described in DTS in a specific format to facilitate program parsing and access.

[0063] The following are some examples of device nodes described in DTS:

[0064] uart@43890000{

[0065] status = "okay";

[0066] compatible="snps,dw-apb-uart";

[0067] reg=<0x00 0x43b90000 0x00 0x1000>;

[0068] reg-shift = ;

[0069] reg-io-width = ;

[0070] interrupts=<0x00 0x2a 0x04>;

[0071] clock-frequency=<0xb71b000>;

[0072] clocks = <0x1d5 0x1d6>;

[0073] clock-names="baudclk\0apb_pclk";

[0074] u-boot,dm-pre-reloc;

[0075] resets = <0x1d3 0x00 0xle>;

[0076] module_index = ;

[0077] power-domains=<0x1a7 0x00>;

[0078] pinctrl-names="default";

[0079] pinctrl-θ = <0x1d7>;

[0080] hobot,skip_baudclk_set;

[0081] dmac-num = ;

[0082] linux,phandle=<0x39c>;

[0083] phandle = <0x39c>;

[0084] The driver management process calls the interface provided by the device tree abstraction layer to parse the device tree binary file and obtain the device node information. The following is an example of a portion of the device node information:

[0085] **

[0086] @brief Structure of device node share memory.

[0087] @note All device node structure and the total count of device nodeswill be stored in this share memory.

[0088] * /

[0089] struct ofw_node_shm{

[0090] uint32_t crc32;uint32_t count;

[0091] struct ofwv_node list[0];

[0092] };

[0093] / **

[0094] @brief Device node structure.

[0095] @full hame:Device node path in dts.

[0096] @ofw_phdl:A user defined phandle of device node to access it.

[0097] @dtb_phdl:The phandle value of phandle property in device node.

[0098] @parent index:The index of its parent node in device node sharememory.

[0099] @self_index:The index of the node itself in device node share memory.

[0100] * /

[0101] struct ofw_node{

[0102] char full_name[0FW_MAX_PATH_LEN];

[0103] ofw_phandle ofw_phdl;

[0104] phandledtb_phdl;

[0105] int parent index;

[0106] int self_index;

[0107] };

[0108] S103: traverse the device nodes according to the parent-child relationship between the multiple device nodes through the driver management process to create a device driver list, wherein the device driver list represents the corresponding relationship between the device driver program and the device node.

[0109] The device node information stores the parent-child relationship between device nodes. The driver management process can use the API provided by the device tree abstraction layer to traverse the device nodes and create a device driver list based on the parent-child relationship.

[0110] The device driver list stores the correspondence between preset device nodes and the device driver required by each device node. When a device node needs to be initialized, the device driver corresponding to the device node can be found according to the device driver list.

[0111] S104: Load a target device driver program that matches the target device node according to the device driver list.

[0112] S105: Acquire a target device driver matching the target device node from the device node information through the target device driver.

[0113] The target device node is a device node that needs to be initialized among the device nodes. According to the device driver list, the target device driver corresponding to the target device node can be determined.

[0114] After the target device driver is loaded and running, the device node attributes corresponding to the device driver are obtained from the device tree binary file using the interface provided by the device tree abstraction layer. Each node in the device tree has attributes that describe its node characteristics, namely, device node attributes, which consist of a name and a value. The attribute name is a string of 1 to 31 characters, and the attribute value is an array of zero or more bytes that contains information associated with the attribute.

[0115] S106: Perform an initialization operation on the target device node according to the device node attributes.

[0116] The target device driver uses the interface provided by the device tree abstraction layer to obtain device node attributes from the DTB and complete the device initialization operation for the corresponding target device node.

[0117] The disclosed embodiment loads a preset driver management process in response to a kernel startup action; the driver management process calls an interface provided by a device tree abstraction layer to parse a device tree binary file to obtain device node information, wherein the device node information at least includes a parent-child relationship between multiple device nodes; the driver management process traverses device nodes according to the parent-child relationship between the multiple device nodes to create a device driver list, wherein the device driver list represents the correspondence between device drivers and device nodes; a target device driver matching the target device node is loaded according to the device driver list; the target device driver obtains device node attributes of the target device node from the device node information through the target device driver; the target device node is initialized according to the device node attributes, and the parent-child relationship between the device nodes is saved in the device node information, so that when the driver management process uses the interface provided by the device tree abstraction layer to parse the device tree binary file, it can traverse the device nodes and load the device driver according to the parent-child relationship between multiple device nodes, thereby improving the management efficiency of the device driver and thus improving the efficiency of device initialization.

[0118] Based on the above embodiment, after the preset driver management process is loaded in response to the kernel startup action, the method further includes: creating a shared memory through the driver management process; and copying the device tree binary file to the shared memory.

[0119] Correspondingly, after the driver management process calls the interface provided by the device tree abstraction layer to parse the device tree binary file and obtain the device node information, the method further includes: storing the device node information in the shared memory.

[0120] In the prior art, the DTS mechanism is not used in microkernel operating systems such as QNX and Fuchsia. All the hardware resource information required for device driver initialization is stored in a special memory area or provided by a dedicated board driver, that is, all the hardware resource information required for device driver initialization is always provided in the operating system in a hard-coded manner, which will result in a lot of redundant code in the operating system to describe the hardware device information. At the same time, the portability and maintainability of the driver are not high. When the operating system needs to adapt to a new hardware platform, it is usually necessary to make a lot of modifications to the driver and do some repetitive work. In addition, it is inconvenient for the operating system to manage the driver.

[0121] The device initialization method provided in this embodiment manages the device driver process through the driver management process, and stores the device tree binary file and device node information in the shared memory, so as to facilitate all device driver processes to access the device tree binary file and device node information, decouple the hardware and driver program, and reduce the redundant code used to describe the hardware device information in the operating system. At the same time, when the operating system needs to adapt to a new hardware platform, only a small amount of modification or even no modification is required to the device driver process, which saves a lot of workload and effectively improves the efficiency of device initialization.

[0122] Figure 3 This is a flow chart of a device initialization method provided by another embodiment of the present disclosure. Figure 3 As shown, the method includes the following steps:

[0123] S301: In response to the kernel startup action, load a preset driver management process.

[0124] S302: Create a shared memory through the driver management process.

[0125] S303: Copy the device tree binary file to the shared memory.

[0126] Specifically, the implementation process and principle of S301 to S303 are consistent with those of the corresponding steps in the above embodiment, and will not be repeated here.

[0127] S304: abstract the device tree binary file by calling the interface provided by the device tree abstraction layer through the driver management process to obtain multiple device node structures.

[0128] S305: Organize the multiple device node structures into a device node structure array.

[0129] In a macro kernel system such as Linux, after the kernel is started, all device nodes in the DTB are abstracted into a device_node structure that is very friendly to the driver. Each member variable in the device_node structure points to the relevant fields in the DTB in the form of a pointer. After the device driver finds the device node, it can access these pointers to obtain various properties of the device node in the DTB. However, since the device drivers of the micro kernel operating system are independent user-mode processes, they cannot directly share access to the device_node structure linked list abstracted by the kernel or a management process. Even if the kernel or a driver management process stores the abstracted device_node structure linked list in shared memory, the driver management process cannot directly access the shared memory because a large number of pointer variables are used in the device_node structure.

[0130] To address this problem, the disclosed embodiment abstracts the device tree binary file into a device node structure, and further organizes multiple device node structures into a device node structure array, that is, the device node structure is saved in the form of an array. Since pointer variables are not used in the device node structure, it can be directly accessed by the driver management process and / or the device driver program.

[0131] S306: Organize the device node structure array, the number of device nodes, and the check value of each device node information into device node information and save it in the shared memory.

[0132] The device node structure array obtained in the above steps is a part of the device node information. In addition, the device node information at least includes the number of device nodes and the check value of each device node information.

[0133] The checksum of the device node information can be their CRC32 checksum. Cyclic redundancy check (CRC) is an error detection code used to detect data corruption. When sending data, a short checksum is generated based on the data content and sent together with the data. When receiving data, a checksum is generated again and compared with the sent checksum. If the two are equal, there is no data corruption. Therefore, the checksum of the device node is used to characterize whether the information of all device nodes in the device tree is complete or damaged.

[0134] S307: traverse the device nodes according to the parent-child relationship between the multiple device nodes through the driver management process to create a device driver list, where the device driver list represents the corresponding relationship between the device driver programs and the device nodes.

[0135] S308: Load a target device driver program that matches the target device node according to the device driver list.

[0136] The parent-child relationship between device nodes is stored in the device node information. The driver management process can use the API provided by the device tree abstraction layer to traverse the device nodes according to the parent-child relationship and create a device driver list, and load the device driver of the corresponding device node according to the device node information. That is, the device driver is matched and loaded by the driver management process according to the device tree.

[0137] Specifically, each of the device node structures includes an array index of the parent node of the device node, and the traversal of the device nodes according to the parent-child relationship between the multiple device nodes through the driver management process includes: for each device node, according to the array index of the parent node in the device node structure, determining the position of the parent node of the device node in the device node structure array; according to the position of the parent node in the device node structure array, accessing the parent node of the device node.

[0138] S309: Mapping a shared memory to a process address space of the device driver, wherein the device node information is stored in the shared memory.

[0139] As mentioned above, since pointer variables are not used in the device node structure, and the device node structure array and DTB are stored in shared memory, they can be directly accessed by the device driver. Specifically, the device driver maps the shared memory to its own process address space, polls all device nodes, and can also access their parent nodes.

[0140] S310: Access the process address space through the device driver to obtain device node attributes corresponding to the device driver.

[0141] The device driver process accesses the target device node in the DTB stored in the mapped shared memory in its own process address space through the API provided by the device tree abstraction layer, and obtains the device node attributes corresponding to the target device node.

[0142] S311. Perform an initialization operation on the target device node according to the device node attributes.

[0143] The disclosed embodiment abstracts the device nodes in the DTB through the driver management process and stores them in the shared memory in the form of a structure array, and there is no pointer in the structure array. Other device driver processes can directly access the shared memory by mapping it to their own process space.

[0144] The device initialization method provided by the embodiment of the present disclosure realizes the decoupling of hardware and device drivers under the microkernel architecture, reduces the redundant code used to describe hardware device information in the operating system, and improves the portability and maintainability of the device driver of the microkernel operating system. The device driver can obtain the device node attributes from the DTB through the interface provided by the device tree abstraction layer, realize automatic matching and loading according to the device tree, and make the management of the device driver by the operating system more convenient.

[0145] Figure 4 A signaling diagram of a device initialization method provided by another embodiment of the present disclosure. The method includes the following steps:

[0146] S401, after the kernel is started, the driver management process is run.

[0147] S402: The driver management process creates a shared memory and copies the device tree binary file to the shared memory.

[0148] Specifically, the driver management process copies the device tree binary file to the shared memory by calling the interface based on the libfdt open source library provided by the device tree abstraction layer through a function.

[0149] S403: The driver management process uses the interface provided by the device tree abstraction layer to parse the DTB, obtain the device node information and save it to the shared memory.

[0150] S404: The driver management process matches and loads the device driver according to the device node information.

[0151] S405 , the device driver process starts running, uses the interface provided by the device tree abstraction layer to obtain device node attributes from the DTB, and completes device initialization.

[0152] Specifically, the device driver process obtains device node attributes from the DTB through a function call to an interface based on the libfdt open source library provided by the device tree abstraction layer, and completes device initialization according to the device node attributes.

[0153] The disclosed embodiment uses the API provided by the device abstraction layer through the driver management process to abstract the device nodes in the DTB and save them in the shared memory in the form of a structure array. There are no pointers in the structure array, and other driver processes can directly access the shared memory after mapping it to their own process space. At the same time, the parent-child relationship between device nodes is saved in the device node information shared memory. Compared with directly using the libfdt interface, the driver management process uses the API provided by the device abstraction layer to traverse the device nodes and create a device driver list based on the parent-child relationship, which is more efficient. In addition, the device driver process uses the API provided by the device abstraction layer to extract device node attributes from the DTB, which is more convenient than directly using the libfdt interface to obtain.

[0154] Figure 5 The schematic diagram of the structure of the device initialization device provided in the embodiment of the present disclosure. The device initialization device may be the operating system as described in the above embodiment, or the device initialization device may be a component or assembly in the operating system. The device initialization device provided in the embodiment of the present disclosure may execute the processing flow provided in the device initialization method embodiment, such as Figure 5As shown, the device initialization device 50 includes: a first loading module 51, a parsing module 52, a first creation module 53, a second loading module 54, an acquisition module 55, and an initialization module 56; wherein the first loading module 51 is used to load a preset driver management process in response to a kernel startup action; the parsing module 52 is used to parse the device tree binary file through the driver management process by calling the interface provided by the device tree abstraction layer to obtain device node information, wherein the device node information at least includes the parent-child relationship between multiple device nodes; the first creation module 53 is used to traverse the device nodes according to the parent-child relationship between the multiple device nodes through the driver management process to create a device driver list, wherein the device driver list represents the correspondence between the device driver program and the device node; the second loading module 54 is used to load a target device driver program that matches the target device node according to the device driver list; the acquisition module 55 obtains the device node attributes of the target device node from the device node information through the target device driver program; and the initialization module 56 is used to perform an initialization operation on the target device node according to the device node attributes.

[0155] In some embodiments, the device initialization apparatus 50 further includes a second creation module 57 and a storage module 58; the second creation module 57 is used to create a shared memory through the driver management process; the storage module 58 is used to copy the device tree binary file to the shared memory;

[0156] In some embodiments, the storage module 58 is further configured to store the device node information in the shared memory.

[0157] In some embodiments, the device node information includes at least an array of device node structures; the parsing module 52 includes an abstraction unit 521 and an organization unit 522; the abstraction unit 521 is used to abstract the device tree binary file through the interface provided by the device tree abstraction layer through the driver management process to obtain multiple device node structures; the organization unit 522 is used to organize the multiple device node structures into an array of device node structures.

[0158] In some embodiments, each of the device node structures includes an array index of the parent node of the device node, and the first creation module 53 includes a determination unit 531 and an access unit 532; the determination unit 531 is used to determine, for each device node, the position of the parent node of the device node in the device node structure array according to the array index of the parent node in the device node structure; the access unit 532 is used to access the parent node of the device node according to the position of the parent node in the device node structure array.

[0159] In some embodiments, the acquisition module 55 includes a mapping unit 551 and an acquisition unit 552; the mapping unit 551 is used to map the shared memory to the process address space of the device driver, and the device node information is stored in the shared memory; the acquisition unit 552 is used to access the process address space through the device driver to obtain the device node attributes corresponding to the target device node.

[0160] Figure 5 The device initialization apparatus of the illustrated embodiment can be used to execute the technical solution of the above-mentioned method embodiment, and its implementation principle and technical effect are similar, which will not be described in detail here.

[0161] In addition, an embodiment of the present disclosure also provides a vehicle, which includes the device initialization apparatus as described in the above embodiment.

[0162] Figure 6 The electronic device provided in the embodiment of the present disclosure may be an electronic device running an operating system as described in the above embodiment. The electronic device provided in the embodiment of the present disclosure may execute the processing flow provided in the device initialization method embodiment, such as Figure 6 As shown, the electronic device 60 includes: a memory 61, a processor 62, a computer program and a communication interface 63; wherein the computer program is stored in the memory 61 and is configured so that the processor 62 executes the device initialization method as described above.

[0163] In addition, an embodiment of the present disclosure further provides a computer-readable storage medium on which a computer program is stored. The computer program is executed by a processor to implement the device initialization method described in the above embodiment.

[0164] In addition, an embodiment of the present disclosure further provides a computer program product, which includes a computer program or instructions, and when the computer program or instructions are executed by a processor, the device initialization method as described above is implemented.

[0165] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages ​​or a combination thereof, including, but not limited to, object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).

[0166] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0167] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0168] The above description is only a specific embodiment of the present disclosure, so that those skilled in the art can understand or implement the present disclosure. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present disclosure. Therefore, the present disclosure will not be limited to the embodiments described herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A device initialization method, characterized in that: The method comprises: In response to the kernel startup action, loading a preset driver management process; The driver management process calls the interface provided by the device tree abstraction layer to parse the device tree binary file to obtain device node information, wherein the device node information at least includes the parent-child relationship between multiple device nodes; Traversing the device nodes according to the parent-child relationship between the multiple device nodes through the driver management process to create a device driver list, wherein the device driver list represents the corresponding relationship between the device driver program and the device node; Loading a target device driver that matches the target device node according to the device driver list; Acquire a device node attribute of the target device node from the device node information through the target device driver; An initialization operation is performed on the target device node according to the device node attribute.

2. The method according to claim 1, characterized in that After the preset driver management process is loaded in response to the kernel startup action, the method further includes: Creating a shared memory through the driver management process; The device tree binary file is copied to the shared memory.

3. The method according to claim 2, characterized in that After the driver management process calls the interface provided by the device tree abstraction layer to parse the device tree binary file and obtain the device node information, the method further includes: The device node information is stored in the shared memory.

4. The method according to claim 1, characterized in that: The device node information at least includes a device node structure array; The driver management process calls the interface provided by the device tree abstraction layer to parse the device tree binary file to obtain device node information, including: The driver management process calls the interface provided by the device tree abstraction layer to abstract the device tree binary file to obtain multiple device node structures; The plurality of device node structures are organized into a device node structure array.

5. The method according to claim 4, characterized in that Each of the device node structures includes an array index of a parent node of the device node, and traversing the device nodes according to the parent-child relationship between the multiple device nodes through the driver management process includes: For each device node, determine the position of the parent node of the device node in the device node structure array according to the array index of the parent node in the device node structure; Access the parent node of the device node according to the position of the parent node in the device node structure array.

6. The method according to claim 3, characterized in that The acquiring, from the device node information, a device node attribute corresponding to the target device node through the target device driver, comprises: Mapping a shared memory to a process address space of the device driver, wherein the device node information is stored in the shared memory; The process address space is accessed through the device driver to obtain the device node attribute corresponding to the target device node.

7. A device initialization device, characterized in that: The device comprises: A first loading module, used for loading a preset driver management process in response to a startup action of the kernel; A parsing module, used for parsing a device tree binary file by calling an interface provided by a device tree abstraction layer through the driver management process to obtain device node information, wherein the device node information at least includes a parent-child relationship between multiple device nodes; A first creation module, configured to traverse the device nodes according to the parent-child relationship between the plurality of device nodes through the driver management process, and create a device driver list, wherein the device driver list represents the corresponding relationship between the device driver program and the device node; A second loading module, used for loading a target device driver matching the target device node according to the device driver list; An acquisition module, which acquires device node attributes of the target device node from the device node information through the target device driver; An initialization module is used to perform an initialization operation on the target device node according to the device node attributes.

8. An electronic device, characterized in that: include: Memory; processor; as well as Computer programs; The computer program is stored in the memory and is configured to be executed by the processor to implement the method according to any one of claims 1 to 6.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.

10. A vehicle comprising: The device initialization device as claimed in claim 7; or the electronic device as claimed in claim 8; Or, the computer readable storage medium of claim 9.