Equipment tree parameter transmission method and device of system on chip, electronic equipment and medium
By converting the target node into platform device information during the binary device tree parsing process of the system-on-chip, registering the driver on the virtual platform bus, obtaining the configuration information, and initializing it on the physical platform bus, the problem of the kernel being unable to recognize the internal devices of the SoC is solved, and the normal use of the target device is realized.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-30
- Publication Date
- 2026-04-10
AI Technical Summary
In a system-on-a-chip, the addresses of some devices are fixed during the chip design phase, which prevents the kernel from obtaining hardware information through device tree scanning, making them unusable and resulting in poor parameter passing.
During the binary device tree parsing process, the target node is converted into platform device information, and the driver for the target device is registered on the virtual platform bus. After obtaining the configuration information, the device structure is registered on the physical platform bus, and the target driver is used for initialization.
It ensures that the kernel can correctly identify and initialize the target device, guaranteeing the effectiveness of parameter transmission, especially for the graphics processing unit (GPU) integrated inside the SoC.
Smart Images

Figure CN121833083A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of computer technology, and in particular relates to a device tree parameter passing method, apparatus, electronic device and medium for a system-on-a-chip. Background Technology
[0002] In the field of computer technology, a System-on-Chip (SoC) often integrates a processor core along with devices such as a Graphics Processing Unit (GPU). In this case, the use of on-chip devices often relies on kernel parameter passing.
[0003] In related technologies, device trees are often used to pass parameters to the kernel. However, the addresses of some devices in some on-chip systems are fixed during the chip design phase, which makes it impossible for the kernel to obtain the hardware information of these devices through device tree scanning and drive them. As a result, these devices cannot be used normally, and the parameter passing effect is poor. Summary of the Invention
[0004] This invention provides a method, apparatus, electronic device, and medium for transmitting device tree parameters in a system-on-a-chip, in order to solve the problem of poor parameter transmission performance.
[0005] To solve the above-mentioned technical problems, the present invention is implemented as follows: In a first aspect, the present invention provides a device tree parameter passing method for a system-on-a-chip, the method comprising: During the parsing of the binary device tree of the system-on-a-chip, the target node in the binary device tree is converted into platform device information, and the driver corresponding to the target device is registered on the pre-registered virtual platform bus; the target node is the device tree node corresponding to the target device, and the target device is the integrated platform device of the system-on-a-chip. If it is determined that a driver matching the platform device information exists in the virtual platform bus, then the configuration information corresponding to the target device is obtained based on the driver. Based on the configuration information, a device structure corresponding to the target device is registered on the physical platform bus, and if a target driver matching the device structure exists in the drivers on the physical platform bus, the target device is initialized based on the target driver.
[0006] In a second aspect, the present invention provides a device tree parameter transfer device for a system-on-a-chip, the device comprising: The node conversion module is used to convert the target node in the binary device tree of the system-on-a-chip into platform device information during the parsing process of the binary device tree of the system-on-a-chip, and to register the driver corresponding to the target device on the pre-registered virtual platform bus; the target node is the device tree node corresponding to the target device, and the target device is the integrated platform device of the system-on-a-chip. The information acquisition module is used to acquire the configuration information corresponding to the target device based on the driver if it is determined that there is a driver in the virtual platform bus that matches the platform device information. The registration module is used to register the device structure corresponding to the target device on the physical platform bus based on the configuration information, and to initialize the target device based on the target driver if a target driver matching the device structure exists in the drivers on the physical platform bus.
[0007] Thirdly, the present invention provides an electronic device, comprising: a processor, a memory, and a computer program stored in the memory and executable on the processor, characterized in that the processor, when executing the program, implements the device tree parameter passing method of the above-described system-on-a-chip.
[0008] Fourthly, the present invention provides a readable storage medium that, when the instructions in the storage medium are executed by the processor of an electronic device, enables the electronic device to execute the above-described device tree parameter passing method for a system on a chip.
[0009] The device tree parameter passing method for a system-on-a-chip (SoC) provided in this embodiment of the invention converts target nodes in the binary device tree of the SoC into platform device information during the parsing process, and registers the corresponding driver for the target device on a pre-registered virtual platform bus. The target node is the device tree node corresponding to the target device, and the target device is the integrated platform device of the SoC. If a driver matching the platform device information exists on the virtual platform bus, configuration information corresponding to the target device is obtained based on the driver. Based on the configuration information, a device structure corresponding to the target device is registered on the physical platform bus. If a target driver matching the device structure exists among the drivers on the physical platform bus, the target device is initialized based on the target driver. Thus, by registering the driver corresponding to the target device on the virtual platform bus, this embodiment of the invention can match the platform device information of the target device with the corresponding driver on the virtual platform bus. Upon successful matching, the kernel can obtain the configuration information of the target device, achieving device tree parameter passing for the target device and ensuring the effective parameter passing for the target device. At the same time, after obtaining the configuration information, registering the device structure of the target device on the physical platform bus makes it easier to initialize the target device based on the target driver pre-registered on the physical platform bus, so that the target device can be used normally by the kernel. Attached Figure Description
[0010] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0011] Figure 1 This is a flowchart illustrating the steps of a device tree parameter passing method for a system-on-a-chip provided in an embodiment of the present invention; Figure 2 This is a schematic diagram of a device tree parameter passing process provided in an embodiment of the present invention; Figure 3 This is a structural diagram of a device tree parameter transfer device for a system-on-a-chip provided in an embodiment of the present invention; Figure 4 This is a structural diagram of an electronic device provided in an embodiment of the present invention. Detailed Implementation
[0012] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0013] Figure 1 This is a flowchart illustrating the steps of a device tree parameter passing method for a system-on-a-chip provided in an embodiment of the present invention, as follows: Figure 1 As shown, the method may include the following steps: Step 101: During the parsing of the binary device tree of the system-on-a-chip, the target node in the binary device tree is converted into platform device information, and the platform driver is registered on the pre-registered virtual platform bus; the target node is the device tree node corresponding to the target device, and the target device is the integrated platform device of the system-on-a-chip.
[0014] Step 102: If it is determined through the virtual platform bus that there is a target driver in the platform driver that matches the platform device information, then obtain the configuration information corresponding to the target device based on the target driver.
[0015] Step 103: Based on the configuration information, register the device structure corresponding to the target device on the physical platform bus, and if it is determined that there is a target driver matching the device structure in the driver on the physical platform bus, initialize the target device based on the target driver.
[0016] Regarding steps 101 to 103 above, the embodiments of the present invention can be applied to any on-chip system that has a device tree parameter passing requirement, for example: it can be a SoC of Loongson system using Loongson architecture (such as Loongson 2K2000 processor).
[0017] The Device Tree Source (DTS) file is a source file containing information about all hardware resources of the on-chip system. It can be pre-written by relevant personnel and typically contains extensive comments and highly readable content. This hardware resource information can include the number and type of processors, memory base addresses and sizes, buses and bridges, peripheral connections, interrupt controllers and interrupt usage, general-purpose input / output (GPIO) controllers and GPIO usage, clock controllers and clock usage, etc. Specifically, the device tree provides a standard method for describing hardware, allowing the kernel to obtain hardware configuration information by parsing the device tree on different hardware platforms without needing to write platform-specific hardware description code. However, because device tree source files are usually in text format and contain a lot of irrelevant information, their loading and parsing efficiency is relatively poor. Therefore, it is usually necessary to compile the device tree source file into a binary file (Device Tree Blob, DTB), which is the binary device tree mentioned above.
[0018] In this context, the target node refers to the device tree node corresponding to the target device, and the target device refers to the integrated platform device of the system-on-a-chip (SoC), that is, a "hard-wired" device integrated inside the SoC (e.g., the GPU in 2K2000). Specifically, the register addresses, interrupt lines, and other information of the target device are often fixed during the chip design phase and belong to the SoC address space, preventing the kernel from obtaining its attribute information when scanning the Peripheral Component Interconnect (PCI) configuration space. Furthermore, the target node in the device tree is often not mounted under the PCI bus. Therefore, when scanning the device tree, the kernel often creates the target device as a platform device on the virtual platform bus. However, the driver program used to drive the target device is often directly registered to the physical platform bus as a PCI driver, causing a mismatch between the driver and the device, thus preventing the driver from initializing the device. Therefore, this embodiment of the invention can execute the device tree parameter passing method shown in this embodiment for the above-mentioned target device.
[0019] Optionally, the target device may include a graphics processing unit.
[0020] It should be noted that GPUs can be used to perform parallel data processing operations on massive amounts of data, enabling graphics rendering, general-purpose parallel computing, and more. Therefore, the proper functioning of the GPU is crucial for the system-on-a-chip (SoC). In this embodiment of the invention, by performing the aforementioned device tree parameter passing operation on the graphics processing unit, the kernel can correctly identify the GPU through the device tree, and by initializing it, the system can run GPU rendering and other functions normally, ensuring the functional integrity of the SoC.
[0021] The aforementioned virtual platform bus (platform_bus) refers to the software virtual bus used to manage on-chip integrated peripherals, while the aforementioned physical platform bus (pci_bus) refers to the actual physical hardware bus used to manage expansion card devices. The aforementioned platform device information refers to the aforementioned platform_device, which represents an independent, discoverable hardware device. These devices are typically peripherals integrated within the SoC (System-on-a-Chip) and are not connected to a standard self-enumeration bus (such as PCI), therefore the kernel often cannot automatically discover them. Accordingly, converting the target node into platform device information means creating a device structure for the target node and registering this device structure to the virtual platform bus. Specifically, the registration operation refers to adding the created device structure to the device list managed by the bus.
[0022] Specifically, in this embodiment of the invention, after the kernel starts, it can first register the PCI bus and then parse the DTB. During the parsing process, the target node can be converted into platform device information, that is, the target node can be registered to the platform_bus.
[0023] Simultaneously, this embodiment of the invention also registers the driver corresponding to the target device to the platform_bus. Here, the driver corresponding to the target device refers to the functional driver used to support the target device. For example, when the target device is a GPU, the driver could be an NVIDIA graphics card driver (NVIDIA Linux GPU kernel driver, nvidia.ko), an AMD graphics card open-source kernel driver (amdgpu.ko), etc. Specifically, the registration operation can involve adding the structure of the driver corresponding to the target device to the driver list of the virtual platform bus.
[0024] Furthermore, embodiments of the present invention can match the driver and the aforementioned platform device information in the virtual platform bus. When a driver corresponding to the platform device information is matched, the configuration information corresponding to the target device is obtained based on the driver. This configuration information may include the device's vendor identifier (ID), device ID, device interrupt number, memory-mapped I / O address (the location of the GPU memory and control registers in the system's physical address space), the bus the device resides on, the slot number, and the PCI configuration space, etc. Specifically, this configuration information can be obtained through the target device's hardware interface.
[0025] Optionally, the above-described operation of obtaining the configuration information corresponding to the target device based on the driver may specifically include, in this embodiment of the invention: S21. Call the callback function corresponding to the driver to scan the configuration address corresponding to the target device and obtain the configuration information corresponding to the target device.
[0026] The aforementioned callback (probe) function, also known as a platform bus probe, refers to a function used to initialize the device matched by the driver. It can be an initialization function pre-set by the developer and automatically called by the kernel after a successful device-driver match. Specifically, this callback function can be called through a callback function pointer within the driver.
[0027] Furthermore, the callback function can include relevant scanning functions, such as pci_scan_slot() and pci_scan_bridge() of the PCI subsystem. By calling this callback function, the configuration address can be scanned to obtain the configuration information. The aforementioned configuration address can be an address pre-fixed for the target device during the chip design phase, or it can be a predefined, hard-coded PCI address.
[0028] In this embodiment of the invention, by calling the callback function corresponding to the driver to scan the configuration address corresponding to the target device and obtain the configuration information corresponding to the target device, the system kernel can scan the configuration information of the target device itself after successfully matching the driver with the platform device information in the virtual platform bus, so that the kernel can identify the target device through the device tree.
[0029] Optionally, before the above-described operation of converting the target node in the binary device tree into platform device information, the embodiments of the present invention may further include: S31. Receive the device tree source file of the system-on-chip.
[0030] S32. In response to the parameter transmission request for the target device, add a device tree node to the device tree source file, and configure attribute information for the device tree node based on the attributes of the target device to obtain the target node.
[0031] S33. Compile the device tree source file to obtain the binary device tree.
[0032] The aforementioned device tree source file can be obtained by receiving external input or by accessing a preset file address; this embodiment of the invention does not impose any restrictions on this.
[0033] The aforementioned parameter passing request can be triggered automatically by the target device of the on-chip system or it can be a received external request; this embodiment of the invention does not impose any restrictions on this. The attributes of the target device may include its unique identifier, as well as information such as the memory mapping address and size of its relevant registers, and the interrupt number used.
[0034] Specifically, after obtaining the device tree source file of the system-on-a-chip, a target node corresponding to the target device can be added to it. Specifically, a device tree node can be created in the device tree source file first, and attribute information can be configured for this device tree node based on the attributes of the target device, thus obtaining a device tree source file containing the target node. For example, taking the system-on-a-chip as a Loongson 2K2000 processor and the target device as a GPU, the configured attribute information could be: compatible = "loongson,ls2k2000-gpu"; (corresponding to the above identifier); reg (defines the memory mapping address and size of the GPU control register); interrupts (defines the interrupt numbers used by the GPU).
[0035] The compilation operation described above can be achieved by calling the Device Tree Compiler (DTC). DTC is a tool for compiling device trees, which can convert DTS files into binary DTB files. Specifically, the compilation operation can be performed by calling the DTC command line. The DTC command line format is: dtc -O<output_format> -o<output_file><input_file> Among them, the above<output_format> This is used to specify the format of the output file. Common options include dtb (device tree binary file) and dts (binary device tree), etc.<output_file> Used to specify the path and name of the output file, the above<input_file> The path and name of the input DTS file.
[0036] In this embodiment of the invention, by adding a target node to the device tree source file, a binary device tree containing the target node can be obtained through compilation, thereby ensuring that the device tree contains the node corresponding to the target device, which facilitates subsequent device tree parameter passing for the target device.
[0037] Furthermore, after obtaining the configuration information, the device structure corresponding to the target device can be registered on the physical platform bus, and the device structure corresponding to the target device and the driver can be matched on the physical platform bus. If the match is successful, the target device can be initialized based on the target driver on the physical platform bus, and then the identification and driving of the target device can be completed based on the device tree parameter passing.
[0038] The physical platform bus mentioned above can be pci_bus.
[0039] Optionally, the operation of registering the device structure corresponding to the target device on the physical platform bus based on the configuration information, as described above, may specifically include the following in this embodiment of the invention: S41. Create a device structure and add the configuration information to the device structure.
[0040] S42. Add the device structure to the preset device list of the physical platform bus.
[0041] The aforementioned device structure can be a structure instance conforming to the physical platform bus specifications, used to represent a physical PCI / PCIe device. Each PCI / PCIe device corresponds to a device structure in the kernel. For example, it can be a `struct pci_dev` object. Furthermore, the above configuration information can be added to the created device structure; that is, the created device structure is populated with the obtained configuration information to achieve registration.
[0042] The aforementioned device list refers to the set of devices pre-defined by the kernel for the physical platform bus or the global PCI device list. The physical platform bus manages hardware devices through this device list. Accordingly, by adding the created device structure to this device list (pci_bus_type->p->klist_devices), the target device can be registered on the physical platform bus.
[0043] In this way, the target device can be registered to the physical platform bus, avoiding the problem that the kernel cannot recognize the target device.
[0044] Furthermore, the target driver can be invoked to initialize the target device. Specifically, this initialization may include allocating memory, creating device files, etc., ultimately enabling the on-chip system to use the target device normally.
[0045] In summary, in this embodiment of the invention, during the parsing of the binary device tree of the on-chip system, the target node in the binary device tree is converted into platform device information, and the driver corresponding to the target device is registered on a pre-registered virtual platform bus. The target node is the device tree node corresponding to the target device, and the target device is the integrated platform device of the on-chip system. If it is determined that there is a driver matching the platform device information on the virtual platform bus, the configuration information corresponding to the target device is obtained based on the driver. Based on the configuration information, the device structure corresponding to the target device is registered on the physical platform bus, and if it is determined that there is a target driver matching the device structure among the drivers on the physical platform bus, the target device is initialized based on the target driver. Thus, by registering the driver corresponding to the target device on the virtual platform bus, this embodiment of the invention can match the platform device information of the target device with the corresponding driver on the virtual platform bus. When the match is successful, the kernel can obtain the configuration information of the target device, realize device tree parameter passing for the target device, and ensure the parameter passing effect for the target device. At the same time, after obtaining the configuration information, registering the device structure of the target device on the physical platform bus makes it easier to initialize the target device based on the target driver pre-registered on the physical platform bus, so that the target device can be used normally by the kernel.
[0046] Optionally, the attribute information includes identification information. The above-described operation of configuring attribute information for the device tree node can specifically include: S51. Configure the identification information of the device tree node as a preset identifier.
[0047] After the above-described operation of registering the driver corresponding to the target device on the pre-registered virtual platform bus, the embodiments of the present invention may further include: S52. In the virtual platform bus, add the preset identifier to the matching table of the driver corresponding to the target device.
[0048] S53. Through the virtual platform bus, the matching table of the registered drivers is traversed. If the preset identifier exists in the matching table, the driver is determined to be the driver that matches the platform device information.
[0049] The aforementioned preset identifier can be a unique identifier pre-set for the target device. For example, taking the target device as a GPU, the preset identifier can be "loongson,ls2k2000-gpu". Of course, it can also be other pre-set identifiers, and this embodiment of the invention does not limit this.
[0050] The aforementioned identification information (compatible) can be used to characterize the device corresponding to the device tree node. It is a key attribute of the device tree node, and the device tree node corresponding to different devices can be determined through this identification information. Accordingly, in this embodiment of the invention, when adding a target node in the device tree source file, the identification information can be directly configured as a preset identifier.
[0051] Furthermore, in the virtual platform bus, to facilitate the matching of driver and platform device information, the aforementioned preset identifier can be added to the matching table of the driver corresponding to the target device. Specifically, the structure object (struct platform_driver) of each driver on the virtual platform bus can include a matching table, which can include the identifier information of the tree nodes of the devices compatible with that driver. Optionally, the aforementioned struct platform_driver may also include callback function pointers, driver names, and other information.
[0052] Accordingly, after adding the aforementioned preset identifier to the matching table of the driver corresponding to the target device in the embodiments of the present invention, the matching tables of each driver registered on the virtual platform bus can be traversed. When the aforementioned preset identifier is found in the matching table of the driver, it can be determined that the driver matches the platform device information.
[0053] In this way, the platform device information and the driver can be matched by a preset identifier, which can improve the efficiency of kernel parameter passing to a certain extent.
[0054] Optionally, the above-described operation of initializing the target device based on the target driver may specifically include, in this embodiment of the invention: S61. Call the callback function corresponding to the target driver to initialize the target device.
[0055] Specifically, the callback function can be obtained through the function pointer defined in the target driver's structure (pci_driver). By calling this callback function, the target device can be initialized based on the configuration information in the device structure.
[0056] For example, taking the target device as a GPU, the kernel can call the probe function of the GPU function driver (pci_driver) to complete the initialization of the GPU hardware, including: allocating a large amount of video memory, initializing the 3D engine, registering with the Direct Rendering Manager (DRM) / Kernel Mode Setting (KMS) subsystem, creating the / dev / dri / cardX device file, etc., and finally enabling the application to use the GPU for rendering.
[0057] This allows the target device of the on-chip system to be used normally through parameter passing via the device tree, ensuring that the kernel can correctly drive the target device and guaranteeing the parameter passing effect.
[0058] It's important to note that the Loongson 2K2000 processor is a general-purpose embedded chip with an integrated processor core and a graphics processing unit (GPU). The use of the GPU is controlled by kernel parameter passing, which currently often uses the Advanced Configuration and Power Management Interface (ACPI). In this method, the kernel scans for PCI devices during ACPI initialization, and when a GPU device is detected, it executes the corresponding PCI / PCIe detection function to enable the GPU. However, embedded systems mostly use device tree parameter passing. Currently, when the kernel uses device tree parameter passing, the addresses of some devices (GPU hardware units) are fixed during the chip design phase, preventing the 2K2000 processor from using the GPU hardware unit.
[0059] Optionally, Figure 2 This is a schematic diagram of a device tree parameter passing process provided in an embodiment of the present invention, as shown below. Figure 2 As shown: During the compilation phase, GPU nodes are added to the DTS file to obtain a DTB file containing GPU nodes.
[0060] Furthermore, during the runtime phase, after the kernel starts up, it can first register the PCI bus (i.e., the virtual platform bus mentioned above), read and parse the DTB file to obtain the hardware device information supported by the processor, and convert it into platform device information, that is, create a platform_device for it, to ensure that the kernel knows about the existence of the GPU hardware entity at the beginning of the startup.
[0061] Furthermore, after obtaining the platform device information, it can be matched with the driver (platform_driver) on the virtual platform bus. If the match is successful, a PCI platform detection program can be executed to scan for devices, obtain PCI device information, and save the PCI device information to the PCI bus structure, that is, register the PCI device on the physical platform bus. At the same time, the GPU driver can be registered on the physical platform bus, that is, register the GPU's PCI driver.
[0062] Furthermore, the registered drivers and device information are matched on the physical platform bus. If the match is successful, the PCI bus prober (callback function) can be called. The PCI bus prober enables the GPU hardware and registers the actual GPU rendering function.
[0063] In this embodiment of the invention, after using the above-mentioned device tree parameter passing method, the GPU device can be used normally on the 2K2000 processor hardware device when the kernel uses the device tree parameter passing method.
[0064] It should be noted that, for the sake of simplicity, the method embodiments are all described as a series of actions. However, those skilled in the art should understand that the embodiments of the present invention are not limited to the described order of actions, because according to the embodiments of the present invention, some steps can be performed in other orders or simultaneously. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are preferred embodiments, and the actions involved are not necessarily essential to the embodiments of the present invention.
[0065] An example process: 1. Kernel startup, PCI bus registration.
[0066] 2. The bootloader passes the device tree containing the GPU nodes to the kernel.
[0067] The kernel parses the device tree, creates a platform_device for the GPU node, and registers it to the virtual platform_bus (the platform_bus is registered before this).
[0068] During initialization, the GPU platform_driver also registers with the platform_bus. The platform_bus performs a match based on the compatible attribute and the of_match_table. If a match is found, it calls the probe function of the platform_driver.
[0069] 3. The probe function of platform_driver performs key operations: a. Basic Hardware Enable: Configure the clock, power, or reset signals required by the GPU as needed to bring the GPU hardware into an accessible basic state.
[0070] b. Trigger PCI enumeration: Actively and forcibly initiate a scan of the specified PCI field by calling the interface function (pci_scan_slot or pci_scan_bridge) provided by the kernel PCI subsystem.
[0071] 4. After the kernel finds the 2K2000 GPU hardware through probe, it reads its vendor ID, device ID and other configuration information, creates a standard struct pci_dev object for the GPU, and registers it to the physical pci_bus_type.
[0072] 5. The GPU pci_driver on pci_bus_type matches the newly created GPU pci_dev.
[0073] After a successful match, the kernel calls the probe function of GPU pci_driver (GPU function driver) to perform the actual initialization of GPU functions: allocating video memory, initializing the 3D engine, registering with the DRM / KMS subsystem, creating the / dev / dri / cardX device file, etc., ultimately enabling the application to use the GPU for rendering.
[0074] Figure 3 This is a structural diagram of a device tree parameter transfer device for a system-on-a-chip provided in an embodiment of the present invention, as shown below. Figure 3 As shown, the device 20 includes: The node conversion module 201 is used to convert the target node in the binary device tree of the system-on-a-chip into platform device information during the parsing process of the binary device tree of the system-on-a-chip, and to register the driver corresponding to the target device on the pre-registered virtual platform bus; the target node is the device tree node corresponding to the target device, and the target device is the integrated platform device of the system-on-a-chip. The information acquisition module 202 is used to acquire the configuration information corresponding to the target device based on the driver if it is determined that there is a driver in the virtual platform bus that matches the platform device information; The registration module 203 is used to register the device structure corresponding to the target device on the physical platform bus based on the configuration information, and to initialize the target device based on the target driver if a target driver matching the device structure exists in the drivers on the physical platform bus.
[0075] Optionally, the information acquisition module is specifically used for: The callback function corresponding to the driver is invoked to scan the configuration address corresponding to the target device and obtain the configuration information corresponding to the target device.
[0076] Optionally, the device further includes: The file receiving module is used to receive the device tree source file of the on-chip system; The node adding module is used to add a device tree node in the device tree source file in response to a parameter transmission request for the target device, and configure attribute information for the device tree node based on the attributes of the target device to obtain the target node; The compilation module is used to compile the device tree source file to obtain the binary device tree.
[0077] Optionally, the attribute information includes identification information, and the node adding module is specifically used to: configure the identification information of the device tree node as a preset identifier; The device further includes: The identifier adding module is used to add the preset identifier to the matching table of the driver corresponding to the target device in the virtual platform bus; The matching module is used to traverse the matching table of the registered drivers through the virtual platform bus, and if the preset identifier exists in the matching table, determine the driver as the driver that matches the platform device information.
[0078] Optionally, the registration module includes: The structure creation submodule is used to create a device structure and add the configuration information to the device structure; The structure addition submodule is used to add the device structure to the preset device list of the physical platform bus.
[0079] Optionally, the registration module is specifically used for: The callback function corresponding to the target driver is invoked to initialize the target device.
[0080] Optionally, the target device includes a graphics processing unit.
[0081] In summary, the device tree parameter passing device for a system-on-a-chip provided in this embodiment of the invention converts the target node in the binary device tree of the system-on-a-chip into platform device information during the parsing process, and registers the driver corresponding to the target device on a pre-registered virtual platform bus. The target node is the device tree node corresponding to the target device, and the target device is the integrated platform device of the system-on-a-chip. If it is determined that there is a driver matching the platform device information in the virtual platform bus, the configuration information corresponding to the target device is obtained based on the driver. Based on the configuration information, the device structure corresponding to the target device is registered on the physical platform bus, and if it is determined that there is a target driver matching the device structure among the drivers on the physical platform bus, the target device is initialized based on the target driver. In this way, by registering the driver corresponding to the target device on the virtual platform bus, this embodiment of the invention can match the platform device information of the target device with the corresponding driver on the virtual platform bus. When the match is successful, the kernel can obtain the configuration information of the target device, realize device tree parameter passing for the target device, and ensure the parameter passing effect for the target device. At the same time, after obtaining the configuration information, registering the device structure of the target device on the physical platform bus makes it easier to initialize the target device based on the target driver pre-registered on the physical platform bus, so that the target device can be used normally by the kernel.
[0082] The present invention also provides an electronic device, see [link to relevant documentation]. Figure 4 The system includes a processor 301, a memory 302, and a computer program 3021 stored in the memory and executable on the processor. When the processor executes the program, it implements the device tree parameter passing method of the system-on-a-chip in the foregoing embodiments.
[0083] The present invention also provides a readable storage medium that, when the instructions in the storage medium are executed by the processor of an electronic device, enables the electronic device to execute the device tree parameter passing method of the system-on-chip described in the foregoing embodiments.
[0084] As the device embodiment is basically similar to the method embodiment, the description is relatively simple, and relevant parts can be found in the description of the method embodiment.
[0085] The algorithms and displays provided herein are not inherently related to any particular computer, virtual system, or other device. Various general-purpose systems can also be used in conjunction with the teachings herein. The required structure for constructing such systems is apparent from the above description. Furthermore, this invention is not directed to any particular programming language. It should be understood that the contents of the invention described herein can be implemented using various programming languages, and the above description of specific languages is for the purpose of disclosing the best mode of implementation of the invention.
[0086] Numerous specific details are set forth in the specification provided herein. However, it will be understood that embodiments of the invention may be practiced without these specific details. In some instances, well-known methods, structures, and techniques have not been shown in detail so as not to obscure the understanding of this specification.
[0087] Similarly, it should be understood that, in order to simplify the invention and aid in understanding one or more of the various inventive aspects, in the above description of exemplary embodiments of the invention, various features of the invention are sometimes grouped together in a single embodiment, figure, or description thereof. However, this disclosure should not be construed as reflecting an intention that the claimed invention requires more features than are expressly recited in each claim. Rather, as reflected in the following claims, inventive aspects lie in fewer than all features of a single foregoing disclosed embodiment. Therefore, the claims following the detailed description are hereby expressly incorporated into this detailed description, wherein each claim itself is a separate embodiment of the invention.
[0088] Those skilled in the art will understand that modules in the device of the embodiments can be adaptively changed and placed in one or more devices different from that embodiment. Modules, units, or components in the embodiments can be combined into a single module, unit, or component, and further, they can be divided into multiple sub-modules, sub-units, or sub-components. Except where at least some of such features and / or processes or units are mutually exclusive, any combination can be used to combine all features disclosed in this specification (including the accompanying claims, abstract, and drawings) and all processes or units of any method or device so disclosed. Unless expressly stated otherwise, each feature disclosed in this specification (including the accompanying claims, abstract, and drawings) may be replaced by an alternative feature that serves the same, equivalent, or similar purpose.
[0089] The various component embodiments of the present invention can be implemented in hardware, or as software modules running on one or more processors, or a combination thereof. Those skilled in the art will understand that microprocessors or digital signal processors (DSPs) can be used in practice to implement some or all of the functions of some or all of the components in the sorting device according to the present invention. The present invention can also be implemented as a device or apparatus program for performing part or all of the methods described herein. Such a program implementing the present invention can be stored on a computer-readable medium, or can be in the form of one or more signals. Such signals can be downloaded from an Internet website, provided on a carrier signal, or provided in any other form.
[0090] It should be noted that the above embodiments are illustrative of the invention and not restrictive, and that those skilled in the art can devise alternative embodiments without departing from the scope of the appended claims. In the claims, any reference signs placed between parentheses should not be construed as limiting the claims. The word "comprising" does not exclude the presence of elements or steps not listed in the claims. The word "a" or "an" preceding an element does not exclude the presence of a plurality of such elements. The invention can be implemented by means of hardware comprising several different elements and by means of a suitably programmed computer. In the unit claims enumerating several means, several of these means may be embodied by the same item of hardware. The use of the words first, second, and third, etc., does not indicate any order. These words can be interpreted as names.
[0091] Those skilled in the art will understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0092] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention should be included within the protection scope of the present invention.
[0093] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in the present invention should be included within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.
Claims
1. A device tree parameter passing method of a system on chip, characterized in that, The method includes: During the parsing of the binary device tree of the system-on-a-chip, the target node in the binary device tree is converted into platform device information, and the driver corresponding to the target device is registered on the pre-registered virtual platform bus; the target node is the device tree node corresponding to the target device, and the target device is the integrated platform device of the system-on-a-chip. If it is determined that a driver matching the platform device information exists in the virtual platform bus, then the configuration information corresponding to the target device is obtained based on the driver. Based on the configuration information, a device structure corresponding to the target device is registered on the physical platform bus, and if a target driver matching the device structure exists in the drivers on the physical platform bus, the target device is initialized based on the target driver.
2. The method according to claim 1, characterized in that, The step of obtaining the configuration information corresponding to the target device based on the driver includes: The callback function corresponding to the driver is invoked to scan the configuration address corresponding to the target device and obtain the configuration information corresponding to the target device.
3. The method according to claim 1, characterized in that, Before converting the target node in the binary device tree into platform device information, the method further includes: Receive the device tree source file of the on-chip system; In response to a parameter request for the target device, a device tree node is added to the device tree source file, and attribute information is configured for the device tree node based on the attributes of the target device to obtain the target node; The device tree source file is compiled to obtain the binary device tree.
4. The method according to claim 3, characterized in that, The attribute information includes identification information, and configuring attribute information for the device tree node includes: configuring the identification information of the device tree node to a preset identifier; After registering the driver corresponding to the target device on the pre-registered virtual platform bus, the method further includes: In the virtual platform bus, the preset identifier is added to the matching table of the driver corresponding to the target device; The matching table of the registered drivers is traversed through the virtual platform bus. If the preset identifier exists in the matching table, the driver is determined to be the driver that matches the platform device information.
5. The method according to claim 1, characterized in that, The step of registering the device structure corresponding to the target device on the physical platform bus based on the configuration information includes: Create a device structure and add the configuration information to the device structure; Add the device structure to the preset device list of the physical platform bus.
6. The method according to claim 1, characterized in that, The initialization of the target device based on the target driver includes: The callback function corresponding to the target driver is invoked to initialize the target device.
7. The method according to any one of claims 1-6, characterized in that, The target device includes a graphics processing unit.
8. A device tree parameter transfer device for a system-on-a-chip, characterized in that, The device includes: The node conversion module is used to convert the target node in the binary device tree of the system-on-a-chip into platform device information during the parsing process of the binary device tree of the system-on-a-chip, and to register the driver corresponding to the target device on the pre-registered virtual platform bus; the target node is the device tree node corresponding to the target device, and the target device is the integrated platform device of the system-on-a-chip. The information acquisition module is used to acquire the configuration information corresponding to the target device based on the driver if it is determined that there is a driver in the virtual platform bus that matches the platform device information. The registration module is used to register the device structure corresponding to the target device on the physical platform bus based on the configuration information, and to initialize the target device based on the target driver if a target driver matching the device structure exists in the drivers on the physical platform bus.
9. An electronic device, characterized in that, include: A processor, a memory, and a computer program stored in the memory and executable on the processor, characterized in that the processor, when executing the program, implements the method as described in any one of claims 1-7.
10. A readable storage medium, characterized in that, When the instructions in the storage medium are executed by the processor of the electronic device, the electronic device is able to perform the method of any one of claims 1-7.