CN116028122A - Device processing method and device based on processor - Google Patents
Device processing method and device based on processor Download PDFInfo
- Publication number
- CN116028122A CN116028122A CN202211507058.6A CN202211507058A CN116028122A CN 116028122 A CN116028122 A CN 116028122A CN 202211507058 A CN202211507058 A CN 202211507058A CN 116028122 A CN116028122 A CN 116028122A
- Authority
- CN
- China
- Prior art keywords
- equipment
- processor
- tree
- attribute information
- controller
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Images
Classifications
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D10/00—Energy efficient computing, e.g. low power processors, power management or thermal management
Landscapes
- Stored Programmes (AREA)
Abstract
The invention provides a device processing method and device based on a processor. The method comprises the following steps: the processor acquires a device tree, wherein the device tree takes each device object respectively mounted on a device controller as a node, and respectively stores attribute information corresponding to each device object; the processor analyzes the equipment tree to respectively obtain the identification attribute corresponding to each equipment object; the processor respectively matches the identification attributes in the drive library to obtain respective corresponding device drivers of the device objects; the processor initializes the device objects according to the device drivers, respectively. The embodiment of the invention can add the attribute information of the equipment object into the equipment tree, and transmit the attribute information of the equipment object to the processor through the equipment tree so that the processor acquires the equipment driver of the equipment object to initialize the equipment driver.
Description
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a device processing method and a device based on a processor.
Background
In the computer arts, a processor may run software code to implement a data processing process. The software code herein may include an operating system and application software supported by the operating system.
In the prior art, a computer may include a processor and a bridge connected to each other by a bus structure, the bridge having access to one or more external device objects through a device controller. Because the processor and the device object are connected through the bridge piece, the processor can access the accessed device object through the input attribute information of the device object and the bridge piece.
However, in some operating systems with poor compatibility, for example, linux operating systems, the processor cannot acquire attribute information of the device object, so that the device object cannot be initialized.
Disclosure of Invention
The invention provides a device processing method and device based on a processor, which are used for initializing a device object in an operating system with poor compatibility.
In a first aspect, the present invention provides a method for processing a processor-based device, including:
the processor acquires a device tree; the equipment tree takes each equipment object respectively mounted on the equipment controller as a node, and respectively stores attribute information corresponding to each equipment object;
the processor analyzes the equipment tree to respectively obtain the identification attributes corresponding to the equipment objects;
And the processor analyzes the equipment tree to respectively obtain the identification attributes corresponding to the equipment objects.
Optionally, the device tree uses the processor as a root node, and uses the device object as a storage format of a child node of the root node to store attribute information of the device object respectively.
Optionally, the processor parses the device tree to obtain the identifier attribute corresponding to each device object, where the parsing includes:
when the operating system is started, the processor analyzes the equipment tree through the kernel code of the operating system, and traverses leaf nodes of the equipment tree to respectively obtain the identification attribute corresponding to the equipment object.
Optionally, the processor initializes the device objects according to the device drivers, including:
and the processor respectively calls an initialization function of the equipment object according to the equipment driver and registers attribute information corresponding to the equipment object.
Optionally, the device controller is located on a PCI bus of the device, and the method further includes:
the processor acquires attribute information of the equipment controller from configuration information of the PCI bus;
And the processor accesses the equipment controller through the PCI bus after registering the attribute information of the equipment controller.
Optionally, the method further comprises:
the processor accesses the equipment object according to the attribute information of the equipment object to call the equipment object to execute the set trigger event.
Optionally, the device object includes: and the flash memory is mounted under the equipment controller through an SPI interface.
In a second aspect, the present invention provides a processor-based device processing apparatus comprising:
the device tree acquisition module is used for acquiring a device tree; the equipment tree takes each equipment object respectively mounted on the equipment controller as a node, and respectively stores attribute information corresponding to each equipment object;
the equipment tree analysis module is used for analyzing the equipment tree to respectively obtain the identification attributes corresponding to the equipment objects;
the device driver acquisition module is used for respectively matching in a driver library according to the identification attribute to obtain device drivers corresponding to the device objects respectively;
and the first initializing module is used for initializing the equipment objects according to the equipment drivers respectively.
Optionally, the device tree uses the processor as a root node, and uses the device object as a storage format of a child node of the root node to store attribute information of the device object respectively.
Optionally, the device tree parsing module is further configured to:
when an operating system is started, analyzing the equipment tree through kernel codes of the operating system, traversing leaf nodes of the equipment tree, and respectively obtaining identification attributes corresponding to the equipment objects.
Optionally, the first initialization module is further configured to:
and respectively calling an initialization function of the equipment object according to the equipment driver, and registering attribute information corresponding to the equipment object.
Optionally, the device controller is located on a PCI bus of the device, and the apparatus further includes:
a second initialization module, configured to obtain attribute information of the device controller from configuration information of the PCI bus;
and the first access module is used for accessing the equipment controller through the PCI bus after registering the attribute information of the equipment controller.
Optionally, the processor further comprises:
and the second access module is used for accessing the equipment object according to the attribute information of the equipment object so as to call the equipment object to execute the set trigger event.
Optionally, the device object includes: and the flash memory is mounted under the equipment controller through an SPI interface.
In a third aspect, embodiments of the present invention also provide a computing device, including: at least one processor and memory;
the memory stores computer-executable instructions;
the at least one processor executes computer-executable instructions stored by the memory to cause the computing device to implement the method as described in the first aspect.
In a fourth aspect, embodiments of the present invention also provide a computer-readable storage medium having stored therein computer-executable instructions for implementing the method of the first aspect when the computer-executable instructions are executed by a computing device.
In a fifth aspect, an embodiment of the present invention further provides a computer program for implementing the method of the first aspect.
The invention provides a device processing method and device based on a processor, wherein the method comprises the following steps: the processor acquires a device tree, wherein the device tree takes each device object respectively mounted on a device controller as a node, and respectively stores attribute information corresponding to each device object; the processor analyzes the equipment tree to respectively obtain the identification attribute corresponding to each equipment object; the processor respectively matches the identification attributes in the drive library to obtain respective corresponding device drivers of the device objects; the processor initializes the device objects according to the device drivers, respectively. The embodiment of the invention can add the attribute information of the equipment object into the equipment tree, and transmit the attribute information of the equipment object to the processor through the equipment tree so that the processor acquires the equipment driver of the equipment object to initialize the equipment driver.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and together with the description, serve to explain the principles of the invention.
FIG. 1 is a schematic diagram of a computing device according to an embodiment of the present invention;
FIG. 2 is a flow chart of steps of a method for processing a processor-based device according to an embodiment of the present invention;
FIGS. 3 and 4 are schematic diagrams of two device trees according to an embodiment of the present invention;
FIG. 5 is a block diagram of a device processing apparatus based on a processor according to an embodiment of the present invention;
FIG. 6 is a block diagram of another computing device according to an embodiment of the present invention.
Specific embodiments of the present invention have been shown by way of the above drawings and will be described in more detail below. The drawings and the written description are not intended to limit the scope of the inventive concepts in any way, but rather to illustrate the inventive concepts to those skilled in the art by reference to the specific embodiments.
Detailed Description
Reference will now be made in detail to exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, the same numbers in different drawings refer to the same or similar elements, unless otherwise indicated. The implementations described in the following exemplary examples do not represent all implementations consistent with the invention. Rather, they are merely examples of apparatus and methods consistent with aspects of the invention as detailed in the accompanying claims.
The following embodiments may be combined with each other, and the same or similar concepts or processes may not be described in detail in some embodiments. Embodiments of the present invention will be described below with reference to the accompanying drawings.
The embodiment of the invention can be used in a computing device, wherein the computing device is any device with a data processing function. FIG. 1 is a schematic diagram of a computing device according to an embodiment of the present invention. Referring to FIG. 1, a computing device may include memory, a processor, a bridge, and a device object. The processors and the bridge may be connected by buses, and buses supported by different processors may be different, for example, when the processor is a LOONGARCH architecture processor and the bridge is a 7A bridge, the buses may be HT (high transport end-to-end bus technology) buses.
The bridge piece is a processing chip used as a connecting bridge, wherein one or more equipment controllers can be arranged on an internal bus of the bridge piece. The internal bus here may be a peripheral component interconnect standard (peripheral component interconnect, PCI) bus, and the device object here may be mounted under the device controller through a serial peripheral interface (serial peripheral interface, SPI). At this time, the device controller may also be referred to as an SPI controller, and the device object may also be referred to as an SPI device.
The device object may be understood as a subordinate device of the device controller, where an address corresponding to the device controller and an address corresponding to the device object exist in an address space of the bridge slice, so that the processor may access the device controller and the device object downloaded by the device controller by accessing the address space of the bridge slice. Specifically, the method comprises the following steps: firstly, loading software codes from a memory by a processor; the processor may then execute the software code to access the device controller via the PCI bus and to access the device object via the device controller.
The above-mentioned processor in the embodiment of the present invention may be a CPU (central processing unit ), and the processor in the embodiment of the present invention may be a microprocessor, where the processor is configured to execute computer instructions to implement processing of data. The device object may be any external device mounted on the device controller, and the device object may be one or more devices, for example, the device object may be a Flash memory (Flash) for performing data storage, backup, curing parameters, and the like, and the device object may also be a network card, a sound card, and other devices. The network card device is used for processing network data required in the network communication process to realize network communication, wherein the network communication comprises the steps of sending a data request to a network and receiving response data sent by the network. The sound card apparatus processes the audio data to realize audio playback, which may include playing with an external microphone or playing with an earphone.
In some operating systems with poor compatibility, for example, linux operating systems, the processor acquires attribute information of the device controller through configuration information of the PCI bus to initialize the device controller. However, since the attribute information of the device object downloaded by the device controller does not exist in the configuration information of the PCI bus, the initialization of the device object cannot be realized.
The embodiment of the invention can add the attribute information of the equipment object into the equipment tree, and transmit the attribute information of the equipment object to the processor through the equipment tree so that the processor accesses the equipment object and initializes the equipment object. In this way, initialization of the device object is achieved.
The following describes the technical scheme of the present invention and how the technical scheme of the present invention solves the above technical problems in detail with specific embodiments. The following embodiments may be combined with each other, and the same or similar concepts or processes may not be described in detail in some embodiments. Embodiments of the present invention will be described below with reference to the accompanying drawings.
Fig. 2 is a flowchart of steps of a processing method of a processor-based device according to an embodiment of the present invention, which is applied to the computing device shown in fig. 1. Referring to fig. 2, the method includes the following steps.
S201: the processor acquires a device tree; the device tree takes each device object respectively mounted on the device controller as a node, and respectively stores attribute information corresponding to each device object.
The device tree is used for storing attribute information of each hardware device in the computing device, and represents the relation among different hardware devices in a hierarchical form. The hardware devices corresponding to the nodes at the same level in the device tree are independent, and the hardware devices corresponding to the child nodes in the device tree need to be accessed by the hardware devices corresponding to the parent nodes. For example, the access of the device object of the embodiments of the present disclosure needs to be performed by the processor, so that the node to which the processor corresponds is a parent node of the node to which the device object corresponds.
It should be noted that, the above device tree may include multiple levels of nodes, where a root node may be referred to as a first level node, and a child node of the root node may be referred to as a second level node, and sequentially increases downward until a leaf node. The first level node may store attribute information of a processor, and attribute information of a device controller and attribute information of a device object may be stored in an nth level node of a device tree, where N is greater than 1.
The attribute information of the device controller and the attribute information of the device object may be located in different level nodes or in the same level node. Fig. 3 and 4 are schematic structural diagrams of two device trees provided in an embodiment of the present disclosure. In fig. 3, the attribute information of the device controller and the attribute information of the device object are located in different level nodes, and in fig. 4, the attribute information of the device controller and the attribute information of the device object are located in the same level node. The device controller and the device object in the device tree shown in fig. 3 correspond to parent-child nodes, and the node of the device object needs to be accessed through the node of the device controller, so that the device tree is suitable for a scene that the node of the device controller and the node of the device object need to be accessed at the same time. While the corresponding sibling nodes of the device controller and the device object in the device tree shown in fig. 4 may be suitable for a scenario where the node of the device controller is accessed separately, or a scenario where the node of the device object is accessed separately.
Referring to fig. 3, the device tree includes six nodes N1 to N6. Where N1 is a first level node for storing attribute information of the processor. N2 and N3 are second level nodes, N2 is used to store attribute information of the device controller DC1, and N3 is used to store attribute information of the device controller DC 2. N4 is a third level node for storing attribute information of the device object DO1 mounted under the device controller DC 1. N5 is a third level node for storing attribute information of the device object DO2 mounted under the device controller DC 2. N6 is a third level node for storing attribute information of the device object DO3 mounted under the device controller DC 2.
As can be seen from the above fig. 3, the attribute information of the device controller is located in the second level node, and the attribute information of the device object is located in the third level node. And the node corresponding to the device object and the node corresponding to the device controller where the device object is located are in a parent-child relationship.
Referring to fig. 4, the device tree includes six nodes N1 to N6, and N1 is a first level node, and N2, N3, N4, N5, and N6 are second level nodes. As with the N1 to N6 nodes shown in fig. 3, N1 is used to store attribute information of a processor, N2 is used to store attribute information of a device controller DC1, N3 is used to store attribute information of a device controller DC2, N4 is used to store attribute information of a device object DO1 mounted under the device controller DC1, N5 is used to store attribute information of a device object DO2 mounted under the device controller DC2, and N6 is used to store attribute information of a device object DO3 mounted under the device controller DC 2.
As can be seen from fig. 4, 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 controller are sibling relations.
It should be noted that, for the device tree in fig. 3, the processor needs to acquire the attribute information of the device controller first, and then acquire the attribute information of the device object according to the attribute information of the device controller. Specifically, firstly, a processor analyzes a second-level node in a device tree to obtain identification attributes corresponding to all device controllers, wherein the identification attributes comprise attribute information of the device controllers; then, matching the identification attribute of the equipment controller in an equipment driver library to obtain equipment driver of the equipment controller; and finally, acquiring attribute information of the device object downloaded by the device controller from the device tree through device driving of the device controller.
For the device tree in fig. 4, the processor may directly acquire the attribute information of the device object, thereby achieving the goal of directly acquiring the attribute information of the device object across the device controller. For the device tree shown in fig. 4, if the processor does not need to acquire the attribute information of the device controller from the device tree, the nodes N2 and N3 corresponding to the device controller may be deleted from the device tree shown in fig. 4, so that the second level nodes of the device tree are all used to store the attribute information of the device object. Therefore, the processor can be ensured to directly acquire the attribute information of the equipment object under the condition of not acquiring the attribute information of the equipment controller, and the initialization of the equipment object is realized.
Of course, the above-mentioned device tree may be stored in the form of a file, which may be referred to as a device tree file, for example, a. Dts file, which is a text file describing the device tree by ASCII code, is located in the operating system/arch/arm/boot/dts directory.
After the operating system generates the device tree, the operating system can also update the device tree according to the deletion and the newly-added of the device controller and/or the device object, and the operating system can establish the device tree through the information acquired by the driver.
In the starting process of the operating system, the device tree is generated first, and then the initialization of the processor, the device controller and the device object is executed according to the device tree.
In the process of generating the device tree shown in fig. 3, first, a scanning process in the kernel of the operating system may scan the hardware device to obtain attribute information of the processor, attribute information of the device controller, and attribute information of the device object. Then, the operating system kernel generates a node N1 according to the attribute information of the processor, and takes the node N1 as a root node of the device tree. Then, the operating system kernel generates a node according to the attribute information of each device controller, for example, two device controllers may obtain nodes N2 and N3, and take the N2 and N3 as two child nodes of the root node. Finally, the operating system kernel generates its child node for each device controller, for example, for device controller DC1, generates node N4 of the device object DO1 mounted under device controller DC1 as a child node of N2. For the device controller DC2, the nodes N5 and N6 of the device objects DO2 and DO3 mounted under the device controller DC2 are generated and serve as two child nodes of N3, thus generating a device tree as shown in fig. 3.
For the device tree shown in fig. 3, when a new device object is added under a device controller, the device controller may detect the device object and acquire attribute information of the device object from configuration information of the device object to add the attribute information of the device object to a third level node of the device tree.
For the device tree shown in fig. 3, when one device object is pulled out from the device controller, the device controller may detect the pulling operation and delete the node corresponding to the device object from the third level nodes of the device tree. For example, when the device object DO1 is pulled out, the device controller DC1 may delete the node N4 from the device tree.
In the process of generating the device tree shown in fig. 4, first, a scanning process in the kernel of the operating system may scan the hardware device to obtain attribute information of the processor, attribute information of the device controller, and attribute information of the device object. Then, the operating system kernel generates a node N1 according to the attribute information of the processor, and takes the node N1 as a root node of the device tree. Then, the operating system kernel generates a node according to the attribute information of each device controller, for example, two device controllers may obtain the nodes N2 and N3, and take the N2 and N3 as the first child node and the second child node of the root node. Finally, the operating system kernel generates a node according to the attribute information of the device object, for example, three nodes N4, N5 and N6 may be obtained by three device objects as the third to fifth child nodes of the root node, so that the device tree shown in fig. 4 may be obtained.
For the device tree shown in fig. 4, when a new device object is added under a device controller, the device controller may detect the device object and acquire attribute information of the device object from configuration information of the device object to add the attribute information of the device object to the device tree shown in fig. 4. Specifically, first, the device controller generates attribute information of the device object into one node; the device controller then adds this node as a new child node of the processor to the device tree shown in fig. 4.
For the device tree shown in fig. 4, when one device object is pulled out from the device controller, the device controller may detect the pulling operation and delete the node corresponding to the device object from the second level nodes of the device tree. For example, when the device object DO1 is pulled out, the device controller DC1 may delete the node N4 from the device tree shown in fig. 4.
After obtaining the device tree shown in fig. 3 or fig. 4, the device tree may be traversed to obtain attribute information of the target device controller or attribute information of the device object.
For the device tree shown in fig. 3, the corresponding traversal procedure when obtaining the attribute information of the target device controller is: and acquiring a second-level node (such as N2) from the equipment tree in sequence each time to match the attribute information in the second-level node N2 with the identification of the target equipment controller, and taking the attribute information in the current second-level node N2 as the attribute information of the target equipment controller if the matching is successful. Otherwise, continuing to acquire the attribute information in the next second-stage node N3 to match with the identifier of the target equipment controller again until the matching is successful or the last second-stage node N3 is matched. For the device tree shown in fig. 3, when acquiring the attribute information of the device object, the target device controller of the device object may be determined first to match the attribute information stored in the child node (e.g., N5) of the corresponding node (e.g., N3) of the target device controller with the identification of the device object. And if the matching is successful, taking the attribute information in the current child node N5 of the corresponding node N3 of the target equipment controller as the attribute information of the equipment object. Otherwise, continuing to acquire attribute information in the next sub-node N6 of the corresponding node of the target device controller, so as to match with the identifier of the target device controller again until the matching is successful or the matching of the last sub-node N6 of the corresponding node N3 of the target device controller is finished.
For the device tree shown in fig. 4, the process of acquiring the attribute information of the target device controller or the attribute information of the device object is similar, taking the device object as an example, the corresponding traversal process is as follows: and acquiring a second-level node (such as N2) from the equipment tree in sequence each time to match the attribute information in the second-level node N2 with the identification of the equipment object, and taking the attribute information in the current second-level node N2 as the attribute information of the equipment object if the matching is successful. Otherwise, continuing to acquire the attribute information in the next second-level node N3 to match with the identifier of the equipment object again until the matching is successful or the last second-level node N6 is matched.
It can be seen that the above device tree stores attribute information of various hardware devices, and different hardware devices have different features, so as to correspond to different attribute information. For example, the attribute information of the processor may include, but is not limited to: frequency, processor cache size, instruction set type, power consumption, number of processors, etc. Frequencies may include, but are not limited to: primary frequency, doubled frequency, bus type, bus frequency.
The attribute information of the device controller includes an address space of the device controller, an identification of the device controller, the number of device objects downloaded by the device controller, and the like.
The attribute information of the device object is information associated with an access policy, and when the attribute information is different, different access policies can be associated. The attribute information herein may include, but is not limited to: compatibility (compatible), bus number (bus_num), clock information of the serial peripheral interface, wherein 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), SPI three-WIRE (SPI-3 WIRE). When the device object is a storage device, the address of a register in the storage device may also be included.
The attribute value of the compatibility is a string list, which is used for binding information of the target external device and the driver so as to select the driver to be used by the target external device from the string list. The information of the driver may correspond to a provider of the driver, a name of the driver, a version of the driver, and the like. It will be appreciated that the processor accesses the target external device via the driver, such that the driver to which the target external device is compatible will affect access to the target external device, that is, the processor is associated with compatibility with the target external device.
The bus number is a number indicating the bus on which the device controller mounted on the target external device is located. The processor needs to access the target external device through the bus where the device controller is located and the device controller, so that when the buses where the device controller is located are different, the access policy to the target external device may also be different, that is, the access policy is related to the bus number.
The address of the register includes a start address and a length, so that an end address can be determined according to the start address and the length, and the end address is the sum of the start address and the length, so that the start address and the length can be used for representing the address range of the register. The processor may temporarily store some data in the corresponding registers when accessing the target external device, and the addresses of the registers corresponding to different target external devices may be different. So that the access policy to the target external device is related to the address of the register corresponding to the target external device.
In some implementations, the device tree can store the attribute information of the device objects in an attribute information storage format of the device controller. Therefore, the processor can multiplex the existing equipment tree analysis algorithm, analyze and obtain the identification attribute of the equipment object from the equipment tree without additionally developing analysis codes, and reduce the complexity of codes and development cost.
S202: and the processor analyzes the equipment tree to respectively obtain the identification attributes corresponding to the equipment objects.
The processor may parse the device tree according to a preset structure of the device tree to obtain an identification attribute of the device object, that is, after determining the structure, the processor may determine information stored in each node in the device tree, so as to implement parsing, to extract attribute information from the device tree, and represent the attribute information with the identification attribute. The identification attribute herein may be understood as an object in software code, for example, a platform device object in the Linux operating system.
The embodiment of the invention can multiplex the processing logic implementation of the equipment tree in the operating system, can reduce the development cost and reduce the code complexity.
Specifically, in the process of starting the operating system of the computing device, the processor may analyze the device tree through kernel codes of the operating system, traverse leaf nodes of the device tree to obtain identification attributes corresponding to the device object, and execute S203 and S204 to initialize the device object. It can be seen that, in the embodiment of the invention, when the operating system is started, the attribute information of the device object can be obtained, so that the operating system is ready for accessing the device object in the subsequent operation process, and the efficiency of accessing the device object can be improved. And the security of the equipment tree can be better ensured by analyzing the equipment tree through the kernel code.
Traversing the leaf nodes of the device tree may be understood as obtaining each leaf node in the device tree one by one, where each leaf node may obtain an identification attribute of a device object.
S203: and the processor respectively matches the identification attributes in the drive library to obtain the corresponding device drivers of the device objects.
The device driver may be understood as a driving function for driving the device object, and may include various functions for driving the device object. For example, a platform driver function in the Linux operating system. The device driver for one device object may be located in one or more driver files and the driver files for all device objects may be stored in one device object driver directory. Likewise, a controller driver catalog may also be provided to store driver files for all device controllers.
The identifier attribute of the device object and the device driver are corresponding relations established according to a certain mapping rule, the device driver name may be a name of a driver file, and the device driver name and the identifier attribute name of the device object may each include a device object name, for example, the device driver name may be: the name_driver may be a name_device, where name is a device object name. Therefore, when the identification attribute of the device object is matched in the drive library, judging whether the name of each drive file in the drive library and the identification attribute name of the device object comprise the same device object name, if so, determining that the matching is successful, otherwise, the matching is failed. The embodiment of the invention does not limit the mapping rule between the identification attribute of the device object and the device driver.
In the prior art, since the attribute information of the target external device does not exist in the device tree, the device object of the target external device and the device driver of the target external device do not exist in the driver. In the embodiment of the invention, after the attribute information of the target external device is added in the device tree, the device object and the device driver are required to be added, and the mapping relation between the device object and the device object is established.
S204: the processor initializes the device objects according to the device drivers, respectively.
The device driver may include an initialization function of the device object, so that the processor invokes the initialization function in the device driver, and registers attribute information corresponding to the device object in a device registration list of the operating system kernel. The initialization function herein is related to an operating system, such as a probe function in a Linux operating system. Therefore, the attribute information of the equipment object can be registered when the target equipment object is initialized so as to be used when the equipment object is accessed later, and the normal access of the equipment object can be ensured.
After registering the attribute information of the device object, the processor may access the device object according to the attribute information of the device object to invoke the device object to execute the predetermined trigger event. Specifically, the processor may call the device driver access device object of S203 described above.
Wherein the triggering event includes, but is not limited to: writing, reading, etc. events to the device object.
Optionally, the device controller is located on a PCI bus in the bridge, and at this time, the processor may acquire attribute information of the device controller from 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.
The configuration information of the PCI bus may include attribute information of all device controllers in the bridge. The processor may call an initialization function of the device controller to register the attribute information of the device controller acquired from the configuration information of the PCI bus into a device list in the operating system kernel. Thus, when the device controller needs to be accessed, the processor calls an access interface in the operating system to send an access request to the PCI bus according to the attribute information of the registered device controller, so as to realize the access to the device controller.
It can be seen that the attribute information of the device controller is not required to be obtained from the device tree, but can be obtained from the configuration information, so that the complexity of initializing the device controller can be reduced, and the efficiency of initializing the device controller can be improved.
The application scene of the embodiment of the invention is that the operating system is a Linux operating system, and the equipment object comprises: flash memory Flash, flash memory is installed under the device controller of 7A bridge piece through SPI interface. Thus, the device controller may be referred to as an SPI device controller, and the flash memory as an SPI flash memory.
Based on the above scenario, during the process of starting the operating system, the PCI scanning process may scan to obtain the attribute information of Flash and the attribute information of the processor, so as to store the attribute information of the processor to the root node of the device tree, and store the attribute information of each Flash to a second level node, thereby obtaining a device tree. After the device tree is obtained, the kernel code of the operating system can traverse the second-stage node of the device tree to obtain the identification attribute of the flash, wherein the identification attribute name is SPI flash_device, so that the identification attribute name SPI flash_device is matched with the device driver name in the driver library, and the device driver SPI flash_driver is obtained. The processor can enter a probe function according to the SPI_flash_driver to register the attribute information of the flash on the PCI bus. The initialization process of the flash is completed.
When the flash is required to be accessed, the processor sends the identifier of the target flash to be accessed to the device controller, and the device controller can complete the access process of the flash when the attribute information of the target flash exists on the PCI bus, so that the writing or reading process of the flash is realized.
In summary, the invention can provide support for the functions of data storage, solidification parameters and the like of the 7A bridge chip mounting a plurality of flash memories, so that the processor is suitable for more storage schemes.
In summary, in the processor according to the embodiment of the present invention, the driver of the device controller is operated, and the driver of the device controller is used for performing access control on the device controller. The driver of the device controller can acquire the attribute information of the device controller through the PCI bus, and the attribute information of the device controller does not need to be transmitted through a device tree. However, the attribute information of the target external device does not exist in the configuration information of the PCI bus. In this scenario, since the device controller does not use the device tree, the initialization Probe function cannot be entered through the driver of the device controller to acquire attribute information of the target external device. According to the embodiment of the invention, the attribute information of the target external device can be written into the device tree, and the corresponding device driver function is written so as to establish a mapping relation with the device object. In this way, an initialization probe function can be entered to obtain attribute information of the target external device. Therefore, the processor can acquire the attribute information of the target external device across the device controller under the Linux operating system so as to realize the access to the target external device.
Fig. 5 is a block diagram of a device processing apparatus based on a processor according to an embodiment of the present invention. Referring to fig. 5, the processor-based device processing apparatus 400 includes the following modules.
An equipment tree acquisition module 401, configured to acquire an equipment tree; and the equipment tree takes each equipment object respectively mounted on the equipment controller as a node, and respectively stores attribute information corresponding to each equipment object.
And the device tree analysis module 402 is configured to analyze the device tree to obtain the identifier attributes corresponding to the device objects respectively.
And the device driver obtaining module 403 is configured to match the device driver in the driver library according to the identifier attribute, so as to obtain device drivers corresponding to the device objects respectively.
And a first initializing module 404, configured to initialize the device objects according to the device drivers, respectively.
Optionally, the device tree uses the processor as a root node, and uses the device object as a storage format of a child node of the root node to store attribute information of the device object respectively.
Optionally, the device tree parsing module 402 is further configured to:
when an operating system is started, analyzing the equipment tree through kernel codes of the operating system, traversing leaf nodes of the equipment tree, and respectively obtaining identification attributes corresponding to the equipment objects.
Optionally, the first initialization module 404 is further configured to:
and respectively calling an initialization function of the equipment object according to the equipment driver, and registering attribute information corresponding to the equipment object.
Optionally, the device controller is located on a PCI bus of the device, and the apparatus further includes:
and the second initialization module is used for acquiring the attribute information of the equipment controller from the configuration information of the PCI bus.
And the first access module is used for accessing the equipment controller through the PCI bus after registering the attribute information of the equipment controller.
Optionally, the apparatus further comprises:
and the second access module is used for accessing the equipment object according to the attribute information of the equipment object so as to call the equipment object to execute the set trigger event.
Optionally, the device object includes: and the flash memory is mounted under the equipment controller through an SPI interface.
Fig. 6 is a block diagram of a computing device 600 that is schematically illustrated in an embodiment of the present invention. The computing device 600 includes a memory 602 and at least one processor 601.
Wherein the memory 602 stores computer-executable instructions.
At least one processor 601 executes computer-executable instructions stored in memory 602, causing computing device 600 to implement the method of fig. 2 described above.
The computing device may further comprise a receiver 603 for receiving information from the remaining apparatus or device and forwarding to the processor 601, and a transmitter 604 for transmitting information to the remaining apparatus or device.
The above computing device is an embodiment of an apparatus corresponding to the method shown in fig. 2, and specific reference may be made to the detailed description of the embodiment of the method shown in fig. 2, which is not repeated herein.
Embodiments of the present invention also provide a computer-readable storage medium having stored therein computer-executable instructions for performing a method as shown in fig. 2 when the computer-executable instructions are executed by a computing device.
The embodiment of the invention also provides a computer program for realizing the method shown in the figure 2.
The above description is only illustrative of the preferred embodiments of the present invention and of the principles of the technology employed. It will be appreciated by persons skilled in the art that the scope of the disclosure referred to in the present invention is not limited to the specific combinations of technical features described above, but also covers other technical features formed by any combination of the technical features described above or their equivalents without departing from the spirit of the disclosure. Such as the above-mentioned features and the technical features disclosed in the present invention (but not limited to) having similar functions are replaced with each other.
Moreover, although operations are depicted in a particular order, this should not be understood as requiring that such operations be performed in the particular order shown or in sequential order. In certain circumstances, multitasking and parallel processing may be advantageous. Likewise, 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 that are described in the context of separate embodiments can also be implemented in combination in a single embodiment. Conversely, various features that are described in the context of a single embodiment can also be implemented in multiple embodiments separately or in any suitable subcombination.
Although the subject matter has been described in language specific to structural features and/or methodological acts, it is to be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are example forms of implementing the claims.
The terms first, second, third and the like in the description and in the claims and in the above-described figures are used for distinguishing between similar or similar objects or entities and not necessarily for describing a particular sequential or chronological order, unless otherwise indicated (Unless otherwise indicated). It is to be understood that the terms so used are interchangeable under appropriate circumstances such that the embodiments of the application are, for example, capable of operation in sequences other than those illustrated or otherwise described herein.
Furthermore, the terms "comprise" and "have," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a product or apparatus that comprises a list of elements is not necessarily limited to those elements expressly listed, but may include other elements not expressly listed or inherent to such product or apparatus.
The term "module" as used in this application refers to any known or later developed hardware, software, firmware, artificial intelligence, fuzzy logic, or combination of hardware and/or software code that is capable of performing the function associated with that element.
Claims (11)
1. A method of processing a processor-based device, the method comprising:
the processor acquires a device tree; the equipment tree takes each equipment object respectively mounted on the equipment controller as a node, and respectively stores attribute information corresponding to each equipment object;
the processor analyzes the equipment tree to respectively obtain the identification attributes corresponding to the equipment objects;
the processor respectively matches the identification attributes in a drive library to obtain device drives corresponding to the device objects respectively;
and the processor respectively initializes the device objects according to the device drivers.
2. The method of claim 1, wherein the device tree stores attribute information of the device objects in a storage format in which the processor is a root node and the device objects are child nodes of the root node, respectively.
3. The method of claim 2, wherein the parsing the device tree by the processor to obtain the respective identification attributes of the device objects includes:
when the operating system is started, the processor analyzes the equipment tree through the kernel code of the operating system, and traverses leaf nodes of the equipment tree to respectively obtain the identification attribute corresponding to the equipment object.
4. The method of claim 1, wherein the processor separately initializing the device objects according to the device drivers comprises:
and the processor respectively calls an initialization function of the equipment object according to the equipment driver and registers attribute information corresponding to the equipment object.
5. The method of any of claims 1-4, wherein the device controller is located on a PCI bus of a device in which the device controller is located, the method further comprising:
The processor acquires attribute information of the equipment controller from configuration information of the PCI bus;
and the processor accesses the equipment controller through the PCI bus after registering the attribute information of the equipment controller.
6. The method according to any one of claims 1 to 4, further comprising:
the processor accesses the equipment object according to the attribute information of the equipment object to call the equipment object to execute the set trigger event.
7. The method of claim 1, wherein the device object comprises: and the flash memory is mounted under the equipment controller through an SPI interface.
8. A processor-based device processing apparatus, comprising:
the device tree acquisition module is used for acquiring a device tree; the equipment tree takes each equipment object respectively mounted on the equipment controller as a node, and respectively stores attribute information corresponding to each equipment object;
the equipment tree analysis module is used for analyzing the equipment tree to respectively obtain the identification attributes corresponding to the equipment objects;
the device driver acquisition module is used for respectively matching in a driver library according to the identification attribute to obtain device drivers corresponding to the device objects respectively;
And the first initializing module is used for initializing the equipment objects according to the equipment drivers respectively.
9. A computing device, comprising: at least one processor and memory;
the memory stores computer-executable instructions;
the at least one processor executing computer-executable instructions stored in the memory causes the computing device to implement the method of any one of claims 1 to 7.
10. A computer readable storage medium having stored therein computer executable instructions for implementing the method of any of claims 1 to 7 when the computer executable instructions are executed by a computing device.
11. A computer program for implementing the method according to any one of claims 1 to 7.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202211507058.6A CN116028122A (en) | 2022-11-29 | 2022-11-29 | Device processing method and device based on processor |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202211507058.6A CN116028122A (en) | 2022-11-29 | 2022-11-29 | Device processing method and device based on processor |
Publications (1)
Publication Number | Publication Date |
---|---|
CN116028122A true CN116028122A (en) | 2023-04-28 |
Family
ID=86076712
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202211507058.6A Pending CN116028122A (en) | 2022-11-29 | 2022-11-29 | Device processing method and device based on processor |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN116028122A (en) |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN117707628A (en) * | 2023-06-15 | 2024-03-15 | 荣耀终端有限公司 | Device initialization method, electronic equipment and readable storage medium |
CN118524277A (en) * | 2024-07-22 | 2024-08-20 | 比亚迪股份有限公司 | Camera driving method, device, vehicle and storage medium |
-
2022
- 2022-11-29 CN CN202211507058.6A patent/CN116028122A/en active Pending
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN117707628A (en) * | 2023-06-15 | 2024-03-15 | 荣耀终端有限公司 | Device initialization method, electronic equipment and readable storage medium |
CN118524277A (en) * | 2024-07-22 | 2024-08-20 | 比亚迪股份有限公司 | Camera driving method, device, vehicle and storage medium |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN110297689B (en) | Intelligent contract execution method, device, equipment and medium | |
CN111061643B (en) | SDK cluster compatibility detection method and device, electronic equipment and storage medium | |
CN109597677B (en) | Method and apparatus for processing information | |
US7539854B2 (en) | System and method to seamlessly enable enhanced management and scripting of a computer system and its add-in devices | |
CN109634718B (en) | Method and system for creating mirror image by cloud platform | |
CN116028122A (en) | Device processing method and device based on processor | |
CN110276074B (en) | Distributed training method, device, equipment and storage medium for natural language processing | |
CN109492181B (en) | Page jump method, device, computer equipment and storage medium | |
CN113961919B (en) | Malicious software detection method and device | |
WO2010052999A1 (en) | Maintenance system, maintenance method, and maintenance program | |
CN110990346A (en) | File data processing method, device, equipment and storage medium based on block chain | |
CN112463256A (en) | Method, system, electronic device and storage medium for determining configuration file | |
US8196093B2 (en) | Apparatus and method for componentizing legacy system | |
CN111240772A (en) | Data processing method and device based on block chain and storage medium | |
CN114706533A (en) | Multi-file multi-stage starting and loading method and device based on GPT partition table | |
CN108446144B (en) | Application program starting method and device, terminal and storage medium | |
CN116756016A (en) | Multi-browser testing method, device, equipment, medium and program product | |
CN112052234B (en) | Service data processing method and device, storage medium and electronic device | |
CN116301602A (en) | Data recording or reading method and device, acquisition equipment, vehicle and medium | |
CN110471708B (en) | Method and device for acquiring configuration items based on reusable components | |
CN110327626B (en) | Virtual server creation method and device | |
KR102193157B1 (en) | Apparatus and method for providing container service | |
CN115993979A (en) | Configuration conversion method, smooth upgrading method, device, equipment and storage medium | |
WO2021070352A1 (en) | Graph association system and graph association method | |
CN115145571B (en) | Method, apparatus and medium for hiding system function call in program core code |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |