Processor-based device processing method and device

By acquiring and parsing the device tree, obtaining the identification attributes of device objects, and matching the device driver, the problem of the processor being unable to initialize device objects in operating systems with poor compatibility is solved, thus realizing the initialization and efficient access of device objects.

CN116028122BActive Publication Date: 2026-06-19LOONGSON TECH CORP

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
LOONGSON TECH CORP
Filing Date
2022-11-29
Publication Date
2026-06-19

AI Technical Summary

Technical Problem

In operating systems with poor compatibility, the processor cannot obtain the attribute information of the device object, which makes it impossible to initialize the device object.

Method used

By obtaining the device tree, parsing the device tree to obtain the identification attributes of the device object, and matching the device driver in the driver library, the device object is initialized.

Benefits of technology

In operating systems with poor compatibility, device object initialization is implemented, improving the efficiency and compatibility of device object access.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116028122B_ABST
    Figure CN116028122B_ABST
Patent Text Reader

Abstract

This invention provides a processor-based device processing method and device. The method includes: the processor acquiring a device tree, where each device object mounted on a device controller is a node, and each node stores its corresponding attribute information; the processor parsing the device tree to obtain the identification attributes corresponding to each device object; the processor matching these identification attributes in a driver library to obtain the corresponding device driver for each device object; and the processor initializing the device objects according to the device drivers. In this embodiment, the attribute information of the device objects can be added to the device tree, and the attribute information can be transmitted to the processor through the device tree, enabling the processor to acquire the device drivers for the device objects and initialize them.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer technology, and in particular to a processor-based device processing method and device. Background Technology

[0002] In the field of computer science, a processor can run software code to perform data processing. This software code can include the operating system and the application software supported by the operating system.

[0003] In the prior art, a computer may include a processor and a bridge chip interconnected via a bus structure. The bridge chip can access one or more external device objects through a device controller. Because the processor and the device object are connected through the bridge chip, the processor can access the accessed device object through the input attribute information of the device object and the bridge chip.

[0004] However, in some operating systems with poor compatibility, such as Linux, the processor cannot obtain the attribute information of the device object, thus preventing the device object from being initialized. Summary of the Invention

[0005] This invention provides a processor-based device processing method and device for initializing device objects in operating systems with poor compatibility.

[0006] In a first aspect, the present invention provides a processor-based device processing method, comprising:

[0007] The processor acquires the device tree; the device tree uses each device object mounted on the device controller as a node, and stores the attribute information corresponding to each device object respectively.

[0008] The processor parses the device tree to obtain the identification attributes corresponding to each device object;

[0009] The processor parses the device tree to obtain the identification attributes corresponding to each device object.

[0010] Optionally, the device tree stores the attribute information of the device object in a storage format where the processor is the root node and the device object is a child node of the root node.

[0011] Optionally, the processor parses the device tree to obtain the identification attributes corresponding to each device object, including:

[0012] When the operating system starts, the processor parses the device tree through the kernel code of the operating system and traverses the leaf nodes of the device tree to obtain the identification attributes corresponding to the device objects.

[0013] Optionally, the processor initializes the device object according to the device driver, including:

[0014] The processor calls the initialization function of the device object according to the device driver to register the attribute information corresponding to the device object.

[0015] Optionally, the device controller is located on the PCI bus of the device, and the method further includes:

[0016] The processor obtains the attribute information of the device controller from the configuration information of the PCI bus;

[0017] After registering the attribute information of the device controller, the processor accesses the device controller via the PCI bus.

[0018] Optionally, it also includes:

[0019] The processor accesses the device object based on its attribute information to invoke the device object to execute a predetermined trigger event.

[0020] Optionally, the device object includes a flash memory, which is connected to the device controller via an SPI interface.

[0021] In a second aspect, the present invention provides a processor-based device processing apparatus, comprising:

[0022] The device tree acquisition module is used to acquire the device tree; the device tree uses each device object that is respectively attached to the device controller as a node, and stores the attribute information corresponding to each device object respectively.

[0023] The device tree parsing module is used to parse the device tree and obtain the identification attributes corresponding to each device object.

[0024] The device driver acquisition module is used to match the identification attributes in the driver library to obtain the device driver corresponding to each device object.

[0025] The first initialization module is used to initialize the device object according to the device driver.

[0026] Optionally, the device tree stores the attribute information of the device object in a storage format where the processor is the root node and the device object is a child node of the root node.

[0027] Optionally, the device tree parsing module is further configured to:

[0028] When the operating system starts, the device tree is parsed through the kernel code of the operating system, and the leaf nodes of the device tree are traversed to obtain the identification attributes corresponding to the device objects.

[0029] Optionally, the first initialization module is further configured to:

[0030] The device driver calls the initialization function of the device object respectively to register the attribute information corresponding to the device object.

[0031] Optionally, the device controller is located on the PCI bus of the device, and the device further includes:

[0032] The second initialization module is used to obtain the attribute information of the device controller from the configuration information of the PCI bus;

[0033] The first access module is used to register the attribute information of the device controller and then access the device controller via the PCI bus.

[0034] Optionally, the processor further includes:

[0035] The second access module is used to access the device object according to the attribute information of the device object, so as to invoke the device object to execute a predetermined trigger event.

[0036] Optionally, the device object includes a flash memory, which is connected to the device controller via an SPI interface.

[0037] Thirdly, embodiments of the present invention also provide a computing device, including: at least one processor and a memory;

[0038] The memory stores computer-executed instructions;

[0039] The at least one processor executes computer execution instructions stored in the memory, causing the computing device to perform the method as described in the first aspect.

[0040] Fourthly, embodiments of the present invention also provide a computer-readable storage medium storing computer-executable instructions, which, when executed by a computing device, are used to implement the method described in the first aspect.

[0041] Fifthly, embodiments of the present invention also provide a computer program for implementing the method of the first aspect described above.

[0042] This invention provides a processor-based device processing method and device. The method includes: the processor acquiring a device tree, where each device object mounted on a device controller is a node, and each node stores attribute information corresponding to its respective device object; the processor parsing the device tree to obtain the identification attributes corresponding to each device object; the processor matching the identification attributes in a driver library to obtain the device driver corresponding to each device object; and the processor initializing the device objects according to the device drivers. In this embodiment, the attribute information of the device objects can be added to the device tree, and the attribute information can be transmitted to the processor through the device tree, enabling the processor to acquire the device drivers for the device objects and initialize them. Attached Figure Description

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

[0044] Figure 1 This is a schematic diagram of the structure of a computing device provided in an embodiment of the present invention;

[0045] Figure 2 This is a flowchart of the steps of a processor-based device processing method provided in an embodiment of the present invention;

[0046] Figure 3 and Figure 4 These are schematic diagrams of the two device tree structures provided in embodiments of the present invention;

[0047] Figure 5 A structural block diagram of a processor-based device processing apparatus provided in an embodiment of the present invention;

[0048] Figure 6 This is a structural block diagram of another computing device provided in an embodiment of the present invention.

[0049] The accompanying drawings have illustrated specific embodiments of the invention, which will be described in more detail below. These drawings and descriptions are not intended to limit the scope of the invention in any way, but rather to illustrate the concept of the invention to those skilled in the art through reference to particular embodiments. Detailed Implementation

[0050] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numerals in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present invention. Rather, they are merely examples of apparatuses and methods consistent with some aspects of the invention as detailed in the appended claims.

[0051] The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments. The embodiments of the present invention will now be described with reference to the accompanying drawings.

[0052] The embodiments of the present invention can be used in computing devices, which are any devices with data processing capabilities. Figure 1 This is a schematic diagram of the structure of a computing device provided in an embodiment of the present invention. (Refer to...) Figure 1 As shown, a computing device may include memory, a processor, a bridge chip, and device objects. The processor and the bridge chip can be connected via a bus. Different processors support different buses. For example, when the processor is a LOONGARCH architecture processor and the bridge chip is a 7A bridge chip, the bus can be an HT (hyper transport) bus.

[0053] The aforementioned bridge chip is a processing chip used as a connection bridge. It can contain one or more device controllers, which can be located on the bridge chip's internal bus. This internal bus can be a Peripheral Component Interconnect (PCI) bus, and the device object can be attached to the device controller via a Serial Peripheral Interface (SPI). In this case, the device controller can also be called an SPI controller, and the device object can also be called an SPI device.

[0054] A device object can be understood as a subordinate device of a device controller. The address space of the bridge chip contains the addresses corresponding to the device controller and the device objects. Therefore, the processor can access the device controller and its subordinate device objects by accessing the address space of the bridge chip. Specifically, this can include: first, the processor loads software code from memory; then, the processor can run the software code to access the device controller through the PCI bus, and to access the device objects through the device controller.

[0055] The processor mentioned in this embodiment of the invention can be a CPU (central processing unit), or a microprocessor. The processor executes computer instructions to process data. The device object can be any external device mounted on a device controller. There can be one or more device objects; for example, a device object can be flash memory used for data storage, backup, and parameter embedding. Device objects can also be network cards, sound cards, etc. Specifically, the network card is used to process network data required for network communication to achieve network communication, which includes sending data requests to the network and receiving response data from the network. The sound card is used to process audio data to achieve audio playback, which can include playback via an external microphone or headphones.

[0056] In some operating systems with poor compatibility, such as Linux, the processor obtains the device controller's attribute information through the PCI bus configuration information to initialize the device controller. However, since the PCI bus configuration information does not contain the attribute information of the device objects attached to the device controller, the initialization of the device objects cannot be achieved.

[0057] In this embodiment of the invention, the attribute information of a device object can be added to a device tree, and the attribute information of the device object can be transmitted to the processor through the device tree, so that the processor can access the device object and initialize it. In this way, the initialization of the device object is achieved.

[0058] The technical solution of the present invention and how the technical solution of the present invention solves the above-mentioned technical problems are described in detail below with specific embodiments. These specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments. The embodiments of the present invention will now be described with reference to the accompanying drawings.

[0059] Figure 2 A flowchart illustrating the steps of a processor-based device processing method provided in this embodiment of the invention, applied to... Figure 1 In the computing device shown. (Refer to...) Figure 2 As shown, the method includes the following steps.

[0060] S201: The processor obtains the device tree; the device tree uses each device object mounted on the device controller as a node, and stores the attribute information corresponding to each device object.

[0061] The device tree stores attribute information of each hardware device in the computing device and represents the relationships between different hardware devices in a hierarchical manner. Hardware devices corresponding to nodes at the same level in the device tree are independent, while the hardware devices corresponding to child nodes require access from the hardware devices corresponding to their parent nodes. For example, access to a device object in this embodiment requires execution through a processor, thus the node corresponding to the processor is the parent node of the node corresponding to the device object.

[0062] It should be noted that the device tree described above can include multiple levels of nodes. The root node can be called the first-level node, the child nodes of the root node can be called the second-level nodes, and so on downwards until the leaf nodes. The first-level nodes can store the attribute information of the processor, while the attribute information of the device controller and the device object can be stored in the Nth-level nodes of the device tree, where N is greater than 1.

[0063] The attribute information of the aforementioned device controller and the attribute information of the device object can be located in different levels of nodes or in the same level of nodes. Figure 3 and Figure 4 These are schematic diagrams illustrating the structures of two device trees provided in embodiments of this disclosure. Figure 3 In this context, the attribute information of the device controller and the attribute information of the device object reside in different levels of nodes. Figure 4 In this context, the attribute information of the device controller and the attribute information of the device object reside in the same level node. Figure 3 In the device tree shown, device controllers and device objects correspond to parent and child nodes. Access to a device object's node is achieved through the device controller's node, making it suitable for scenarios requiring simultaneous access to both the device controller's node and the device object's node. Figure 4 The device tree shown has corresponding sibling nodes for device controllers and device objects. This can be applied to scenarios where only the nodes of the device controller or the nodes of the device object are accessed.

[0064] Reference Figure 3 As shown, the device tree consists of six nodes, N1 to N6. N1 is a first-level node used to store processor attribute information. N2 and N3 are second-level nodes; N2 stores attribute information for device controller DC1, and N3 stores attribute information for device controller DC2. N4 is a third-level node used to store attribute information for device object DO1, which is attached to device controller DC1. N5 is a third-level node used to store attribute information for device object DO2, which is attached to device controller DC2. N6 is a third-level node used to store attribute information for device object DO3, which is attached to device controller DC2.

[0065] From the above Figure 3As can be seen, the attribute information of the device controller is located in the second-level node, while the attribute information of the device object is located in the third-level node. Furthermore, the node corresponding to the device object and the node corresponding to its device controller have a parent-child relationship.

[0066] Reference Figure 4 As shown, the device tree includes six nodes, N1 to N6, where N1 is a first-level node, and N2, N3, N4, N5, and N6 are all second-level nodes. Figure 3 Similar to nodes N1 to N6 shown, N1 is used to store the attribute information of the processor, N2 is used to store the attribute information of device controller DC1, N3 is used to store the attribute information of device controller DC2, N4 is used to store the attribute information of device object DO1 attached to device controller DC1, N5 is used to store the attribute information of device object DO2 attached to device controller DC2, and N6 is used to store the attribute information of device object DO3 attached to device controller DC2.

[0067] From the above Figure 4 As can be seen, the attribute information of the device controller and the attribute information of the device object are located in the same level node, and the node corresponding to the device object and the node corresponding to the device controller are siblings.

[0068] It should be noted that, for Figure 3 In the device tree, the processor first needs to obtain the attribute information of the device controllers, and then obtain the attribute information of the device objects based on the attribute information of the device controllers. Specifically, first, the processor parses the second-level nodes in the device tree to obtain the identification attributes corresponding to all device controllers, which include the attribute information of the device controllers; then, the identification attributes of the device controllers are matched with the device driver library to obtain the device drivers of the device controllers; finally, the attribute information of the device objects attached to the device controllers is obtained from the device tree through the device drivers of the device controllers.

[0069] And for Figure 4 In the device tree, the processor can directly obtain the attribute information of device objects, achieving the goal of directly obtaining the attribute information of device objects without bypassing the device controller. For Figure 4 The device tree shown can be used if the processor does not need to obtain the device controller's attribute information from the device tree. Figure 4 In the device tree shown, nodes N2 and N3 corresponding to the device controller are deleted, so that all second-level nodes in the device tree are used to store the attribute information of device objects. This ensures that the processor can directly obtain the attribute information of the device object without needing to access the attribute information of the device controller, thus enabling the initialization of the device object.

[0070] Of course, the device tree described above can be stored as a file, which can be called a device tree file, such as a .dts file. A .dts file is a text file that describes the device tree using ASCII codes and is located in the / arch / arm / boot / dts directory of the operating system.

[0071] After generating the device tree, the operating system can update the device tree based on the deletion or addition of device controllers and / or device objects. The operating system can also build the device tree using information obtained from the driver.

[0072] During the operating system startup process, a device tree is first generated, and then the processor, device controller, and device objects are initialized based on the device tree.

[0073] exist Figure 3 In the device tree generation process shown, firstly, the scanning process in the operating system kernel scans the hardware devices, obtaining the attribute information of the processor, device controllers, and device objects. Then, the operating system kernel generates a node N1 based on the processor's attribute information and makes N1 the root node of the device tree. Next, the operating system kernel generates a node based on the attribute information of each device controller; for example, two device controllers can generate nodes N2 and N3, which are then used as the two child nodes of the root node. Finally, the operating system kernel generates its child nodes for each device controller. For example, for device controller DC1, node N4 is generated for device object DO1 attached to device controller DC1, and it becomes a child node of N2. For device controller DC2, nodes N5 and N6 are generated for device objects DO2 and DO3 attached to device controller DC2, and they become the two child nodes of N3. This generates the device tree as shown. Figure 3 The device tree shown.

[0074] for Figure 3 As shown in the device tree, when a new device object is added to a device controller, the device controller can detect the device object and obtain its attribute information from the device object's configuration information, so as to add the device object's attribute information to the third-level node of the device tree.

[0075] for Figure 3 The device tree shown allows the device controller to detect when a device object is removed from the device tree and delete the node corresponding to that device object from the third-level nodes of the device tree. For example, when device object DO1 is removed, device controller DC1 can delete node N4 from the device tree.

[0076] exist Figure 4In the device tree generation process shown, firstly, the scanning process in the operating system kernel scans the hardware devices, obtaining the attribute information of the processor, device controllers, and device objects. Then, the operating system kernel generates a node N1 based on the processor's attribute information and sets N1 as the root node of the device tree. Next, the operating system kernel generates a node based on the attribute information of each device controller; for example, two device controllers can generate nodes N2 and N3, which are then set as the first and second child nodes of the root node. Finally, the operating system kernel generates a node based on the attribute information of each device object; for example, three device objects can generate three nodes N4, N5, and N6, which serve as the third to fifth child nodes of the root node. This process continues until the device tree is generated. Figure 4 The device tree shown.

[0077] for Figure 4 As shown in the device tree, when a new device object is added to a device controller, the device controller can detect the device object and obtain its attribute information from its configuration information to add the device object's attribute information to the controller. Figure 4 In the device tree shown, specifically, firstly, the device controller generates a node from the device object's attribute information; then, the device controller adds this node as a new child node of the processor. Figure 4 In the device tree shown.

[0078] for Figure 4 The device tree shown allows the device controller to detect and remove the node corresponding to the device object from the second-level nodes of the device tree when a device object is removed from its control. For example, when device object DO1 is removed, device controller DC1 can... Figure 4 Delete node N4 from the device tree shown.

[0079] Having obtained the above Figure 3 or Figure 4 Following the device tree shown, you can traverse the device tree to obtain the attribute information of the target device controller or the device object.

[0080] for Figure 3The device tree shown illustrates the following traversal process for obtaining the attribute information of the target device controller: One second-level node (e.g., N2) is retrieved sequentially from the device tree. The attribute information in this second-level node N2 is then matched against the identifier of the target device controller. If a match is found, the attribute information in the current second-level node N2 is used as the attribute information of the target device controller. Otherwise, the attribute information in the next second-level node N3 is retrieved and matched against the identifier of the target device controller again, until a match is found or the last second-level node N3 is matched. Figure 3 The device tree shown, when retrieving attribute information of a device object, first determines the target device controller of the device object. Then, it matches the attribute information stored in the child nodes (e.g., N5) of the target device controller's corresponding node (e.g., N3) with the device object's identifier. If a match is successful, the attribute information in the current child node N5 of the target device controller's corresponding node N3 is used as the device object's attribute information. Otherwise, it continues to retrieve the attribute information from the next child node N6 of the target device controller's corresponding node, and matches it again with the target device controller's identifier, until a match is successful or the last child node N6 of the target device controller's corresponding node N3 has finished matching.

[0081] for Figure 4 The process of obtaining attribute information for the target device controller or device object in the device tree shown is similar. Taking a device object as an example, the corresponding traversal process is as follows: First, retrieve one second-level node (e.g., N2) sequentially from the device tree. Then, match the attribute information in this second-level node N2 with the identifier of the device object. If a match is found, the attribute information in the current second-level node N2 is used as the attribute information of the device object. Otherwise, continue retrieving the attribute information from the next second-level node N3 and matching it with the identifier of the device object again, until a match is found or the last second-level node N6 is matched.

[0082] As can be seen, the device tree described above stores attribute information for various hardware devices. Different hardware devices have different characteristics, thus corresponding to different attribute information. For example, the attribute information of a processor may include, but is not limited to: frequency, processor cache size, instruction set type, power consumption, and number of processors. Frequency may include, but is not limited to: clock speed, multiplier, bus type, and bus frequency.

[0083] The attribute information of a device controller includes its address space, identifier, and the number of device objects attached to it.

[0084] The attribute information of the aforementioned device object is associated with the access strategy; different attribute information corresponds to different access strategies. This attribute information may include, but is not limited to: compatibility, bus number (bus_num), and clock information for the serial peripheral interface. The clock information may include clock polarity (SPI-CPOL), clock phase (SPI-CPHA), and whether the clock is a high-level chip select signal (SPI-CS-HIGH) or SPI three-wire (SPI-3WIRE). When the aforementioned device object is a storage device, it may also include the addresses of registers within the storage device.

[0085] The compatibility attribute is a list of strings that binds information about the target external device and its driver, allowing the selection of the appropriate driver from the list. Driver information may include the driver provider, driver name, and driver version. Essentially, the processor accesses the target external device through its driver, and therefore, the compatibility of the target external device with its driver will affect access to that device; in other words, the processor's compatibility with the target external device is relevant.

[0086] The bus number indicates the bus number on which the device controller of the target external device resides. The processor needs to access the target external device through the bus on which the device controller resides and the device controller itself. Therefore, the access strategy for the target external device may differ depending on the bus on which the device controller resides. In other words, the access strategy is related to the bus number.

[0087] A register address includes a start address and a length. The end address can be determined from the start address and length, and the end address is the sum of the start address and length. Therefore, the start address and length can be used to represent the register's address range. When a processor accesses a target external device, it can temporarily store some data in the corresponding register. Different target external devices may have different register addresses. Thus, the access strategy for a target external device is related to the address of the register corresponding to that target external device.

[0088] In some implementations, the device tree can store the attribute information of device objects in the attribute information storage format of the device controller. This allows the processor to reuse existing device tree parsing algorithms without developing additional parsing code, enabling it to parse the identification attributes of device objects from the device tree, thus reducing code complexity and development costs.

[0089] S202: The processor parses the device tree and obtains the identification attributes corresponding to each device object.

[0090] The processor can parse the device tree according to its preset structure to obtain the identification attributes of the device objects. In other words, once the structure is determined, the information stored in each node of the device tree can be determined, enabling parsing to extract attribute information from the device tree and represent it using identification attributes. These identification attributes can be understood as objects in software code, such as the platform device object in the Linux operating system.

[0091] The embodiments of the present invention can reuse the device tree processing logic in the operating system, which can reduce development costs and code complexity.

[0092] Specifically, during the startup of the operating system for the computing device, the processor can parse the device tree through the kernel code of the operating system, traverse the leaf nodes of the device tree to obtain the identification attributes corresponding to the device objects, and execute S203 and S204 to initialize the device objects. It can be seen that this embodiment of the invention can obtain the attribute information of the device objects when the operating system starts, preparing for the operating system to access the device objects during subsequent operation, thus improving the efficiency of accessing device objects. Furthermore, parsing the device tree through kernel code can better ensure the security of the device tree.

[0093] Traversing the leaf nodes of the device tree can be understood as obtaining each leaf node in the device tree one by one, and each leaf node can obtain the identification attribute of a device object.

[0094] S203: The processor matches the identification attributes in the driver library to obtain the device driver corresponding to each device object.

[0095] In this context, a device driver can be understood as a driver function used to drive a device object. This can include various functions that drive the device object. For example, the `platform driver` function in the Linux operating system. A device driver for a device object can reside in one or more driver files, and all device object driver files can be stored in a single device object driver directory. Similarly, a controller driver directory can be set to store the driver files for all device controllers.

[0096] The identification attributes of a device object and its device driver are linked according to a specific mapping rule. The device driver name can be the name of a driver file, and both the device driver name and the device object's identification attribute name can include the device object name. For example, the device driver name could be `name_driver`, and the identification attribute could be `name_device`, where `name` is the device object name. Therefore, when matching the device object's identification attribute in the driver library, it is determined whether the name of each driver file in the driver library includes the same device object name as the device object's identification attribute name. If so, the match is successful; otherwise, the match fails. This embodiment of the invention does not impose restrictions on the mapping rule between the device object's identification attribute and the device driver.

[0097] In existing technologies, because the target external device's attribute information is not present in the device tree, the driver also lacks a device object and a device driver for that target external device. However, in this embodiment of the invention, after adding the target external device's attribute information to the device tree, it is necessary to add a device object and a device driver, and establish a mapping relationship between them.

[0098] S204: The processor initializes the device objects according to the device driver.

[0099] The device driver mentioned above can include an initialization function for the device object. This function is invoked by the processor to register the corresponding attribute information of the device object in the operating system kernel's device registry. This initialization function is operating system-dependent; for example, it might be the `probe` function in Linux. In this way, the device object's attribute information can be registered during initialization for subsequent access, ensuring proper access to the device object.

[0100] After registering the attribute information of the aforementioned device object, the processor can access the device object based on its attribute information to invoke the device object to execute predetermined trigger events. Specifically, the processor can invoke the device driver described in S203 to access the device object.

[0101] Among them, the triggering events include, but are not limited to, events such as writing to and reading from device objects.

[0102] Optionally, the device controller is located on the PCI bus in the bridge chip. In this case, the processor can obtain the attribute information of the device controller from the configuration information of the PCI bus. Then, the processor registers the attribute information of the device controller and accesses the device controller through the PCI bus.

[0103] The PCI bus configuration information can include attribute information for all device controllers in the bridge chip. The processor can call the device controller's initialization function to register the device controller's attribute information, obtained from the PCI bus configuration information, into the device list in the operating system kernel. Then, when access to a device controller is needed, the processor calls the access interface in the operating system to send an access request to the PCI bus based on the registered device controller's attribute information, thus gaining access to the device controller.

[0104] As can be seen, the attribute information of the device controller does not need to be obtained from the device tree, but can be obtained from the configuration information, which can reduce the complexity of initializing the device controller and improve the efficiency of initializing the device controller.

[0105] One application scenario of this invention is as follows: the operating system is Linux, and the device object includes Flash memory, which is connected to the device controller of the 7A bridge chip via an SPI interface. Therefore, the device controller can be called an SPI device controller, and the Flash memory can be called SPI Flash memory.

[0106] Based on the above scenario, during the operating system startup process, the PCI scanning process can scan and obtain the attribute information of the Flash memory and the processor. The processor's attribute information is stored in the root node of the device tree, and the attribute information of each Flash memory is stored in a second-level node, thus obtaining a device tree. After obtaining the device tree, the operating system's kernel code can traverse the second-level nodes of the device tree to obtain the Flash's identification attribute, named SPI flash_device. This identification attribute name, SPI flash_device, is then matched with the device driver name in the driver library to obtain the device driver, SPI flash_driver. The processor can then enter the probe function based on SPI flash_driver to register the Flash's attribute information onto the PCI bus. This completes the Flash initialization process.

[0107] When flash memory needs to be accessed, the processor sends the identifier of the target flash memory to the device controller. If the attribute information of the target flash memory exists on the PCI bus, the device controller can complete the access process of the flash memory, thus realizing the writing or reading process of the flash memory.

[0108] In summary, this invention can support the 7A bridge chip to mount multiple flash memory for data storage, parameter fixing and other functions, enabling the processor to adapt to more storage solutions.

[0109] In summary, the processor in this embodiment of the invention runs a device controller driver, which is used for access control of the device controller. This device controller driver can obtain the device controller's attribute information via the PCI bus without needing to transmit the attribute information through the device tree. However, the PCI bus configuration information does not contain the attribute information of the target external device. In this scenario, since the device controller does not use the device tree, it is impossible to enter the initialization probe function through the device controller driver to obtain the attribute information of the target external device. This embodiment of the invention can write the attribute information of the target external device into the device tree and write a corresponding device driver function to establish a mapping relationship with the device object. In this way, the initialization probe function can be entered to obtain the attribute information of the target external device. Thus, the processor, under the Linux operating system, can obtain the attribute information of the target external device by bypassing the device controller, thereby enabling access to the target external device.

[0110] Figure 5 This is a structural block diagram of a processor-based device processing apparatus provided in an embodiment of the present invention. (Refer to...) Figure 5 As shown, the processor-based device processing apparatus 400 includes the following modules.

[0111] The device tree acquisition module 401 is used to acquire the device tree; the device tree uses each device object that is respectively attached to the device controller as a node, and stores the attribute information corresponding to each device object.

[0112] The device tree parsing module 402 is used to parse the device tree and obtain the identification attributes corresponding to each device object.

[0113] The device driver acquisition module 403 is used to match the identification attributes in the driver library to obtain the device driver corresponding to each device object.

[0114] The first initialization module 404 is used to initialize the device objects according to the device driver.

[0115] Optionally, the device tree stores the attribute information of the device object in a storage format where the processor is the root node and the device object is a child node of the root node.

[0116] Optionally, the device tree parsing module 402 is further configured to:

[0117] When the operating system starts, the device tree is parsed through the kernel code of the operating system, and the leaf nodes of the device tree are traversed to obtain the identification attributes corresponding to the device objects.

[0118] Optionally, the first initialization module 404 is further configured to:

[0119] The device driver calls the initialization function of the device object respectively to register the attribute information corresponding to the device object.

[0120] Optionally, the device controller is located on the PCI bus of the device, and the device further includes:

[0121] The second initialization module is used to obtain the attribute information of the device controller from the configuration information of the PCI bus.

[0122] The first access module is used to register the attribute information of the device controller and then access the device controller via the PCI bus.

[0123] Optionally, the device further includes:

[0124] The second access module is used to access the device object according to the attribute information of the device object, so as to invoke the device object to execute a predetermined trigger event.

[0125] Optionally, the device object includes a flash memory, which is connected to the device controller via an SPI interface.

[0126] Figure 6 This is a structural block diagram of a computing device 600 exemplarily shown in an embodiment of the present invention. The computing device 600 includes a memory 602 and at least one processor 601.

[0127] Among them, memory 602 stores computer-executed instructions.

[0128] At least one processor 601 executes computer execution instructions stored in memory 602, causing the computing device 600 to perform the aforementioned functions. Figure 2 The method in the middle.

[0129] In addition, the computing device may also include a receiver 603 and a transmitter 604, wherein the receiver 603 is used to receive information from other devices or equipment and forward it to the processor 601, and the transmitter 604 is used to send information to other devices or equipment.

[0130] The aforementioned computing device is Figure 2 For a detailed description of the apparatus embodiments corresponding to the methods shown, please refer to the following: Figure 2 The detailed description of the method embodiments shown will not be repeated here.

[0131] This invention also provides a computer-readable storage medium storing computer-executable instructions, which, when executed by a computing device, are used to implement, for example... Figure 2 The method shown.

[0132] This invention also provides a computer program for implementing the foregoing. Figure 2 The method shown.

[0133] The above description is merely a preferred embodiment of the present invention and an explanation of the technical principles employed. Those skilled in the art should understand that the scope of disclosure in this invention is not limited to technical solutions formed by specific combinations of the above-described technical features, but should also cover other technical solutions formed by arbitrary combinations of the above-described technical features or their equivalents without departing from the above-disclosed concept. For example, technical solutions formed by substituting the above features with (but not limited to) technical features with similar functions disclosed in this invention.

[0134] Furthermore, while the operations are described in a specific order, this should not be construed as requiring these operations to be performed in the specific order shown or in sequential order. In certain circumstances, multitasking and parallel processing may be advantageous. Similarly, while several specific implementation details are included in the above discussion, these should not be construed as limiting the scope of the invention. Certain features described in the context of individual embodiments may also be implemented in combination in a single embodiment. Conversely, various features described in the context of a single embodiment may also be implemented individually or in any suitable sub-combination in multiple embodiments.

[0135] Although the subject matter has been described using language specific to structural features and / or methodological logic, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. Rather, the specific features and actions described above are merely illustrative examples of implementing the claims.

[0136] The terms "first," "second," "third," etc., used in the specification, claims, and accompanying drawings of this application are used to distinguish similar or related objects or entities and do not necessarily imply a specific order or sequence, unless otherwise indicated. It should be understood that such terms can be used interchangeably where appropriate, for example, to implement embodiments in a sequence other than those given in the illustrations or description of this application.

[0137] Furthermore, the terms “comprising” and “having”, and any variations thereof, are intended to cover but not exclusively include, for example, a product or device that includes a series of components is not necessarily limited to those that are explicitly listed, but may include other components that are not explicitly listed or that are inherent to such product or device.

[0138] As used in this application, the term "module" means any known or subsequently developed hardware, software, firmware, artificial intelligence, fuzzy logic, or combination of hardware and / or software code capable of performing the functions associated with that element.

Claims

1. A processor-based device processing method, characterized in that, The device controller is located on the PCI bus of the device. The processor obtains the attribute information of the device controller from the configuration information of the PCI bus. The method includes: The processor acquires a device tree; the device tree has the processor as the root node, and the device controller and each device object mounted on the device controller as child nodes, respectively storing the attribute information corresponding to the device controller and each device object, wherein the node corresponding to the device controller and the node corresponding to each device object are siblings; In order to directly obtain the attribute information of each device object without going through the device controller, the processor traverses the device tree and parses the device tree to obtain the identification attributes corresponding to each device object. Write the corresponding platform driver function and add the device driver corresponding to each device object to the driver library. The processor matches the identification attribute in the driver library to obtain the device driver corresponding to the device object. The processor initializes the device object according to the device driver.

2. The method according to claim 1, characterized in that, The processor parses the device tree to obtain the identification attributes corresponding to each device object, including: When the operating system starts, the processor parses the device tree through the kernel code of the operating system and traverses the leaf nodes of the device tree to obtain the identification attributes corresponding to each device object.

3. The method according to claim 1, characterized in that, The processor initializes the device objects according to the device driver, including: The processor calls the initialization function of the device object according to the device driver to register the attribute information corresponding to the device object.

4. The method according to any one of claims 1 to 3, characterized in that, After the processor obtains the attribute information of the device controller from the configuration information of the PCI bus, the method further includes: After registering the attribute information of the device controller, the processor accesses the device controller via the PCI bus.

5. The method according to any one of claims 1 to 3, characterized in that, Also includes: The processor accesses the device object based on its attribute information to invoke the device object to execute a predetermined trigger event.

6. The method according to claim 1, characterized in that, The device object includes a flash memory, which is connected to the device controller via an SPI interface.

7. A processor-based device processing apparatus, characterized in that, The device controller is located on the PCI bus of the device. The processor obtains the attribute information of the device controller from the configuration information of the PCI bus. The device includes: The device tree acquisition module is used to acquire the device tree; the device tree takes the processor as the root node, the device controller and each device object mounted on the device controller as child nodes, and stores the attribute information corresponding to the device controller and each device object respectively. The node corresponding to the device controller and the node corresponding to each device object are siblings. The device tree parsing module is used to traverse the device tree and parse the device tree to obtain the attribute information of each device object directly without going through the device controller, so as to obtain the identification attribute corresponding to each device object respectively. The device driver acquisition module is used to write the corresponding device driver platform driver function and add the device driver corresponding to each device object to the driver library. It matches the identification attribute in the driver library to obtain the device driver corresponding to the device object. The first initialization module is used to initialize the device object according to the device driver.

8. A computing device, characterized in that, include: At least one processor and memory; The memory stores computer-executed instructions; The at least one processor executes computer execution instructions stored in the memory, causing the computing device to implement the method as described in any one of claims 1 to 6.

9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions that, when executed by a computing device, are used to implement the method as described in any one of claims 1 to 6.

10. A computer program, characterized in that, The computer program is used to implement the method as described in any one of claims 1 to 6.