Equipment initialization device and method, storage medium and equipment
By establishing a mapping relationship between physical addresses and virtual addresses in the embedded operating system, the problem of repeatedly parsing the device tree file during device initialization is solved, thereby shortening the device initialization time and optimizing resource utilization.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-01-04
- Publication Date
- 2026-04-07
AI Technical Summary
In embedded operating systems, the device initialization process is lengthy and consumes processing resources because each driver process needs to repeatedly parse the device tree file.
By establishing a mapping relationship between a preset physical address range and the virtual address range corresponding to the driver process in the operating system, the device tree file only needs to be parsed once, and the parsing result is stored in the physical storage space. The driver process can then directly access the parsing result through the mapping relationship for initialization.
This effectively reduces the number of times the device tree file is parsed, reduces processing time and resource waste, and improves device initialization efficiency.
Smart Images

Figure CN121807394A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present disclosure relates to operating system technology, and in particular, to an apparatus and method for initializing a device, a storage medium and a device. BACKGROUND
[0002] A device tree is a data structure for describing the hardware configuration of a device, such as a processor, memory, bus, external device, etc. The device tree is mainly applied in an embedded operating system to separate the hardware information of the device from the kernel code of the operating system, so that the same kernel image can support multiple hardware platforms, thereby improving the portability of the kernel code.
[0003] In order to improve the security, scalability and flexibility of the operating system, the core functions of the operating system are usually minimized, for example, only basic process scheduling, memory management, etc. are reserved in the kernel space (or kernel mode) of the operating system, and other service programs such as the driver program of the device are implemented in the user space (or user mode), and the driver program needs to be implemented through a driver process in the user space. Different device driver programs correspond to different driver processes, and each driver process is independent of each other, so that each driver process needs to manage the hardware resources of the corresponding device independently. Therefore, each driver process needs to separately parse the obtained device tree file and obtain the hardware information of the device from the parsing result when starting, so as to initialize the device. Since each driver process needs to parse the device tree file in the process of obtaining the hardware information of the device, it takes a long time to initialize the device and occupies a lot of processing resources. SUMMARY
[0004] Embodiments of the present disclosure provide an apparatus and method for initializing a device, a storage medium and a device, which can reduce the waste of processing time and processing resources of the operating system in the process of initializing the device, and thereby effectively improve the initialization efficiency of the device.
[0005] In a first aspect, an apparatus for initializing a device is provided. The apparatus includes a processor. The processor is configured to: in response to obtaining a first initialization request initiated by a first driver process in an operating system, establish a first mapping relationship between a preset physical address range and a first virtual address range corresponding to the first driver process based on the first initialization request, wherein a physical storage space corresponding to the preset physical address range stores a device tree file and a parsing result corresponding to the device tree file; in response to obtaining a first device information obtaining request from the first driver process, determine device information of a first device corresponding to the first device information obtaining request from the parsing result stored in the physical storage space based on first virtual address information in the first device information obtaining request and the first mapping relationship; and perform initialization processing on the first device based on the device information of the first device.
[0006] In a second aspect, a method for initializing a device is provided. The method includes: in response to obtaining a first initialization request initiated by a first driver process in an operating system, establishing a first mapping relationship between a preset physical address range and a first virtual address range corresponding to the first driver process based on the first initialization request, wherein a physical storage space corresponding to the preset physical address range stores a device tree file and a parsing result corresponding to the device tree file; in response to obtaining a first device information obtaining request from the first driver process, determining device information of a first device corresponding to the first device information obtaining request from the parsing result stored in the physical storage space based on first virtual address information in the first device information obtaining request and the first mapping relationship; and performing initialization processing on the first device based on the device information of the first device.
[0007] In a third aspect, a computer-readable storage medium is provided. The storage medium stores a computer program. The computer program is executed by a processor to perform the method for initializing a device according to any one of the embodiments of the present disclosure.
[0008] In a fourth aspect, an electronic device is provided. The electronic device includes a processor, and a memory for storing executable instructions of the processor. The processor is configured to read the executable instructions from the memory. The processor executes the executable instructions to implement the method for initializing a device according to any one of the embodiments of the present disclosure.
[0009] In a fifth aspect, a computer program product is provided. When instructions in the computer program product are executed by a processor, the method for initializing a device according to any one of the embodiments of the present disclosure is performed.
[0010] The initialization apparatus, method, medium and device provided by the above embodiments of the present disclosure are responsive to obtaining a first initialization request initiated by a first driver process in an operating system, establishing a first mapping relationship between a preset physical address range and a first virtual address range corresponding to the first driver process based on the first initialization request, wherein the physical storage space corresponding to the preset physical address range stores a device tree file and a parsing result corresponding to the device tree file; responsive to obtaining a first device information acquisition request from the first driver process, determining device information of a first device corresponding to the first device information acquisition request from the parsing result stored in the physical storage space based on first virtual address information in the first device information acquisition request and the first mapping relationship; and performing initialization processing on the first device based on the device information of the first device. Thus, in the initialization process of the device, the device tree file is only parsed once, and the parsing result is stored in the physical storage space corresponding to the preset physical address range. Any first driver process that needs to use the parsing result of the device tree file in the future can directly access the physical storage space corresponding to the preset physical address range by establishing a first mapping relationship between the first virtual address range corresponding to the first driver process and the preset physical address range, and obtain the device information corresponding to the device tree file from the parsing result stored in the physical storage space, thereby avoiding the situation that multiple driver processes need to repeatedly parse the device tree file during initialization in the related art. The present disclosure can effectively reduce the number of times of parsing the device tree file, reduce the waste of processing time and processing resources of the operating system during the initialization process of the device, and thus can effectively improve the initialization efficiency of the device. BRIEF DESCRIPTION OF DRAWINGS
[0011] Figure 1 is one exemplary application scenario of the initialization apparatus of the device provided by the present disclosure; Figure 2 is a structural schematic diagram of the initialization apparatus of the device provided by an exemplary embodiment of the present disclosure; Figure 3 is a flowchart of multiple driver processes in the related art; Figure 4 is a flowchart of the initialization method of multiple devices provided by an exemplary embodiment of the present disclosure; Figure 5 is a flowchart of the initialization method of the device provided by an exemplary embodiment of the present disclosure; Figure 6 is a flowchart of the initialization method of the device provided by another exemplary embodiment of the present disclosure; Figure 7 is a flowchart of the initialization method of the device provided by still another exemplary embodiment of the present disclosure; Figure 8 is a flowchart of a method for initializing a device according to an example embodiment of the present disclosure; Figure 9 is a structural diagram of an electronic device according to an example embodiment of the present disclosure. DETAILED DESCRIPTION
[0012] For the purpose of interpreting the present disclosure, example embodiments of the present disclosure will be described in detail below with reference to the accompanying drawings, obviously, the described embodiments are only part of the embodiments of the present disclosure, but not all the embodiments, it should be understood that the present disclosure is not limited by the example embodiments.
[0013] It should be noted that: unless otherwise specified, the relative arrangement, numerical expression and numerical value of the components and steps set forth in these embodiments do not limit the scope of the present disclosure.
[0014] Summary of the disclosure In the process of implementing the present disclosure, the inventors found that the device tree (Device Tree) is a data structure for describing the hardware configuration of a device, for example, including a processor, memory, bus and external device, etc. The device tree is mainly applied in embedded operating systems to separate the hardware information of the device from the kernel code of the operating system, so that the same kernel image can support multiple hardware platforms, thereby improving the portability of the kernel code.
[0015] In order to improve the security, scalability and flexibility of the operating system, the core functions of the operating system are usually minimized, for example, only basic process scheduling, memory management and other functions are reserved in the kernel space (or kernel state) of the operating system, and other service programs such as device drivers are implemented in the user space (or user state), and the driver needs to be implemented through the user space driver process. Different device drivers correspond to different driver processes, and each driver process is independent of each other, so that each driver process needs to manage the hardware resources of the corresponding device independently, therefore, each driver process needs to parse the obtained device tree file separately when starting, and obtain the hardware information of the device from the parsing result, for the initialization of the device. Since each driver process needs to parse the device tree file in the process of obtaining the hardware information of the device, it takes a long time to initialize the device and occupies a lot of processing resources.
[0016] Example overview Figure 1 is an example application scenario of the device initialization apparatus according to the present disclosure. As shown in Figure 1As shown, an operating system 11 is loaded on the hardware, and a plurality of application programs (not shown in the figure) run on the operating system 11, for example but not limited to a microkernel operating system, including a kernel state and a user state, wherein the kernel state runs an operating system kernel which can provide basic process scheduling, memory management and the like; a plurality of drivers developed based on the operating system kernel run in the user state, and the application programs access various devices on the hardware through the operating system 11, wherein the devices include, for example, devices 121, 122, 123 and the like in FIG. 1. Figure 1 Any device 12i can be but is not limited to one of a processor, a memory, a bus, an external device and the like, i = 1, 2, 3, … The driving program corresponding to each device is implemented through a user-state driving process. For example, the driving process A can be the driving process corresponding to the device 121, the driving process B can be the driving process corresponding to the device 122, the driving process C can be the driving process corresponding to the device 123, and so on.
[0017] In the process of starting the driving process corresponding to each device, the initialization operation of the device can be implemented by using the device initialization apparatus of the present disclosure. Specifically, the device initialization apparatus can include a processor configured to: In response to obtaining a first initialization request initiated by a first driving process in the operating system, a first mapping relationship between a preset physical address range and a first virtual address range corresponding to the first driving process is established based on the first initialization request; wherein the physical storage space corresponding to the preset physical address range stores a device tree file and a parsing result corresponding to the device tree file; in response to obtaining a first device information acquisition request from the first driving process, the device information of the first device corresponding to the first device information acquisition request is determined from the parsing result stored in the physical storage space based on the first virtual address information in the first device information acquisition request and the first mapping relationship; and the first device is initialized based on the device information of the first device.
[0018] The initialization apparatus of the device of the present disclosure can effectively avoid the situation that multiple driving processes need to repeatedly parse the device tree file when initializing the device, effectively reduce the number of times of parsing the device tree file, and in turn reduce the waste of processing time and processing resources in the process of executing device initialization, and can effectively improve the initialization efficiency of the device.
[0019] Example device Figure 2 FIG. 1 is a structural schematic diagram of an initialization apparatus of a device provided by an example embodiment of the present disclosure. The initialization apparatus of the device provided by the embodiment of the present disclosure is, for example but not limited to, an electronic device, a system on chip, or hardware applied to an electronic device or a system on chip, wherein the electronic device includes, for example but not limited to, a vehicle computing platform (or a vehicle terminal), a body intelligent agent, a mobile phone, a tablet, a wearable device, etc., and the system on chip includes, for example but not limited to, an intelligent driving system on chip, an intelligent cockpit system on chip, a cockpit-driving integrated system on chip, etc. Figure 2 As shown in FIG. 1, the initialization apparatus 20 of the device of the embodiment of the present disclosure can include a processor 21. The processor 21 is configured to: in response to obtaining a first initialization request initiated by a first driving process from an operating system, establishing a first mapping relationship between a preset physical address range and a first virtual address range corresponding to the first driving process based on the first initialization request; wherein a device tree file and a parsed result corresponding to the device tree file are stored in a physical storage space corresponding to the preset physical address range; in response to obtaining a first device information acquisition request from the first driving process, determining device information of a first device corresponding to the first device information acquisition request from the parsed result stored in the physical storage space based on first virtual address information in the first device information acquisition request and the first mapping relationship; and performing initialization processing on the first device based on the device information of the first device.
[0020] The processor 21 includes, for example but not limited to, one or more of a central processing unit and other processors.
[0021] The operating system is, for example but not limited to, a microkernel operating system, an embedded operating system, or an operating system developed based on a Linux kernel.
[0022] The driving process is an instance of the dynamic execution of the driver program, used to implement the related functions of the driver program, and the processor 21 executes the related tasks of the driver program by scheduling the driving process. Each driving process can have an independent address space and resources.
[0023] The first driving process can be a driving process corresponding to any device. The device includes, for example but not limited to, a processor, a memory, a bus, an external device, etc., wherein the external device includes, for example but not limited to, an external storage device, a network card, various sensors, etc. Alternatively, the first driving process is a driving process that is not the first to parse the device tree file among multiple driving processes in the operating system.
[0024] The device tree file is a file that describes the hardware configuration (i.e., device information) of the device according to a predetermined data structure. The parsing result of the device tree file is the device information corresponding to the device parsed from the device tree file according to the predetermined data structure of the device tree file, i.e., the parsing result includes the device information of one or more devices parsed.
[0025] During the operating system startup process, the processor 21 can create a driving process corresponding to the driver program of the device, and after the operating system is started, the processor 21 can schedule the driving process to initialize the device. Alternatively, when the device is inserted, a driving process corresponding to the device is dynamically created through the plug-and-play mechanism, and the device is initialized.
[0026] The first initialization request refers to a request for initializing the first device initiated by the first driving process. The first initialization request includes, for example but not limited to, a first virtual address range corresponding to the first driving process. The preset physical address range refers to an address range of a physical storage space for storing a device tree file and a parsing result thereof. For example, the preset physical address range is 0x0000~0x00ff, and the storage units in the address range of 0x0000~0x00ff constitute the physical storage space corresponding to the preset physical address range. In response to obtaining the first initialization request, the processor 21 can determine the first virtual address range corresponding to the first driving process based on the first initialization request, obtain the preset physical address range, and then establish a first mapping relationship between the preset physical address range and the first virtual address range. The first mapping relationship can include a conversion relationship between a virtual address in the first virtual address range and a physical address in the preset physical address range. Based on the first mapping relationship, any virtual address in the first virtual address range can be mapped to a physical address in the preset physical address range, so that the first driving process can initiate an access request (for example, a first device information obtaining request) to the physical storage space corresponding to the preset physical address range through the virtual address. Based on the access request, the processor 21 maps the virtual address to the corresponding physical address, obtains the corresponding data from the storage space corresponding to the physical address, for example, obtains the parsing result.
[0027] Optionally, the first initialization request can be a call request for a pre-configured initialization function. The function of the initialization function can include establishing a mapping relationship between the virtual address range of the driving process and the preset physical address range according to a preset mapping rule, wherein the preset mapping rule can be set according to the actual application scenario. Any first driving process can establish a first mapping relationship between the first virtual address range corresponding to the first driving process and the preset physical address range by calling the initialization function, so as to avoid repeatedly developing function code for establishing the mapping relationship in the driving program.
[0028] Optionally, in response to the first mapping relationship being established, the first driver process can initiate a first device information acquisition request, which includes, for example but not limited to, the first virtual address information, a device identifier of the first device corresponding to the first driver process, and the like. The first virtual address information includes, for example but not limited to, a virtual address corresponding to the physical storage space in which the parsed result of the device tree file is stored, or the first virtual address information can include a virtual address start address corresponding to the physical storage space in which the parsed result of the device tree file is stored and a data length of the parsed result. The virtual address included in the first virtual address information is a virtual address within the first virtual address range corresponding to the first driver process. In response to the first device information acquisition request, the processor 21 acquires, based on the first mapping relationship and the first virtual address information in the first device information acquisition request, device information of the first device corresponding to the first device information acquisition request from the parsed result stored in the physical storage space corresponding to the preset physical address range. For example, the first virtual address information can be converted into physical address information based on the first mapping relationship, the parsed result can be acquired from the physical storage space corresponding to the preset physical address range based on the physical address information, and the device information of the first device can be acquired from the parsed result based on the device identifier of the first device. Then, the device information of the first device can be transmitted to the first driver process, and the first driver process can initialize the first device based on the device information of the first device. The initialization of the first device includes, for example but not limited to, hardware configuration of the first device, resource allocation, reporting of the current state, and the like. The hardware configuration includes, for example but not limited to, setting the working mode of the first device, checking the state of the first device, configuring the register, interrupt service routine and other hardware parameters of the first device; the resource allocation includes, for example but not limited to, allocating memory resources for the first device to ensure that the first device can work normally. The reporting of the current state includes, for example but not limited to, notifying the operating system of the basic information of the first device at present, so that the operating system can manage the first device subsequently.
[0029] Optionally, the parsed result stored in the physical storage space is obtained by the processor 21 or other driver processes by parsing the device tree file before the first driver process initiates the first initialization request.
[0030] The initialization device of the device provided in the embodiment responds to obtaining a first initialization request initiated by a first driver process in an operating system, establishes a first mapping relationship between a preset physical address range and a first virtual address range corresponding to the first driver process based on the first initialization request, wherein the preset physical address range corresponds to a physical storage space in which a device tree file and a parsing result corresponding to the device tree file are stored, responds to obtaining a first device information acquisition request from the first driver process, determines device information of a first device corresponding to the first device information acquisition request from the parsing result stored in the physical storage space based on first virtual address information in the first device information acquisition request and the first mapping relationship, and performs initialization processing on the first device based on the device information of the first device. Thus, in the initialization process of the device, the device tree file is only parsed once, and the parsing result is stored in the physical storage space corresponding to the preset physical address range. Any first driver process that needs to use the parsing result of the device tree file subsequently can access the physical storage space corresponding to the preset physical address range through the first virtual address range corresponding to the first driver process and the first mapping relationship between the first virtual address range and the preset physical address range, and obtain the device information corresponding to the device tree file from the parsing result stored in the physical storage space, thereby avoiding the situation that multiple driver processes need to repeatedly parse the device tree file in the related art when performing initialization. The present disclosure can effectively reduce the number of times of parsing the device tree file, reduce the waste of processing time and processing resources of the operating system in the device initialization process, and thus can effectively improve the initialization efficiency of the device.
[0031] In some optional embodiments, on the basis of any of the above embodiments, the preset physical address range is a physical address range corresponding to a preset physical storage space in the first memory. Before obtaining the first initialization request initiated by the first driver process in the operating system, the processor 21 is further configured to: respond to a start instruction from the operating system, execute the bootloader, and respond to a first preset instruction in the bootloader, read the device tree file from the second memory, and write the device tree file into the first subspace in the physical storage space in the first memory; the physical storage space includes the first subspace for storing the device tree file and the second subspace for storing the parsing result.
[0032] The processor 21 is specifically configured to obtain the device information of the first device corresponding to the first device information acquisition request from the second subspace in the physical storage space based on the first virtual address information in the first device information acquisition request and the first mapping relationship.
[0033] Optionally, the first memory is preferably an internal memory (referred to as internal memory). The preset physical address range is a physical address range corresponding to a preset physical storage space in the internal memory. The physical storage space corresponding to the preset physical address range can be a storage space allocated for the device tree file and the parsing result in an operating system startup process. The startup instruction of the operating system is an instruction indicating to start the operating system. The processor 21 executes a bootloader in response to obtaining the startup instruction of the operating system. The bootloader is the first code to run when the operating system starts. The bootloader can be used to initialize hardware, load an operating system kernel, pass startup parameters to the kernel, and the like. The first preset instruction is an instruction in the bootloader for indicating to load the device tree file. The first preset instruction can include a storage address (which can be referred to as a source address) of the device tree file in the second memory and a storage address (which can be referred to as a destination address) of the device tree file in the first memory to which the device tree file needs to be loaded. In response to executing the first preset instruction, the source address and the destination address of the device tree file are determined according to the first preset instruction. Based on the source address of the device tree file, the device tree file is read from the second memory and written into a first subspace in the physical storage space corresponding to the destination address in the first memory. The first subspace is a subspace in the physical storage space for storing the device tree file. The physical storage space further includes a second subspace for storing a parsing result of the device tree file. The second memory is an external memory. The difference between the first memory and the second memory is that the first memory is a volatile memory for temporarily storing data, and the data will be lost after power-off, while the second memory is a non-volatile memory capable of storing data for a long time.
[0034] The first virtual address information in the first device information acquisition request is virtual address information corresponding to the second subspace. For example, the first virtual address information can include a starting address of a virtual address corresponding to the second subspace and a size of the second subspace (or a data length of the parsing result). Based on the first mapping relationship, the first virtual address information can be mapped to physical address information corresponding to the second subspace, for example, the starting address of the virtual address in the first virtual address information is mapped to a physical starting address of the second subspace. Then, based on the first virtual address information, the physical address information corresponding to the second subspace obtained by mapping can include the physical starting address of the second subspace and the size of the second subspace (or the data length of the parsing result). Based on the physical address information, the parsing result is obtained from the second subspace, and the device information of the first device corresponding to the first device information acquisition request is obtained from the parsing result.
[0035] In some optional embodiments, the first subspace and the second subspace can be continuous storage spaces, which facilitates space management and device information query.
[0036] In the embodiments of this disclosure, by loading the device tree file from the second memory to the first subspace of the physical storage space corresponding to a preset physical address range in the first memory during the operating system startup process, it is ensured that the first driver process can successfully read the device tree file from the physical storage space in the first memory during subsequent driver startup processes, providing effective data support for parsing the device tree file. Furthermore, only one copy of the device tree file and the parsing result needs to be stored in the first memory, which helps save storage space.
[0037] In some optional embodiments, based on any of the above embodiments, before receiving a first initialization request initiated by a first driver process in the operating system, the processor 21 is further configured to: In response to receiving a second initialization request initiated by a second driver process in the operating system, a second mapping relationship is established between a preset physical address range and a second virtual address range corresponding to the second driver process based on the second initialization request. The first virtual address range is the same as the second virtual address range. The startup time of the second driver process is earlier than that of the first driver process. The device tree file is read from the physical storage space corresponding to the preset physical address range, the device tree file is parsed, and the parsing result is written to the physical storage space. The parsing result includes device information of multiple devices.
[0038] The second driver process is, for example, but not limited to, the first driver process that resolves the device tree file and obtains the parsing result. Because the second driver process starts earlier than the first driver process, it ensures that the parsing result of the device tree file is already stored in the corresponding physical storage space when the first driver process initializes. The second initialization request refers to a request initiated by the second driver process to initialize the second device. The second initialization request includes, for example, but not limited to, the second virtual address range corresponding to the second driver process. In response to obtaining the second initialization request, the processor 21 can determine the second virtual address range corresponding to the second driver process based on the second initialization request, obtain a preset physical address range, and then establish a second mapping relationship between the preset physical address range and the second virtual address range.
[0039] After establishing the second mapping relationship, the processor 21 can read the device tree file from the physical storage space corresponding to the preset physical address range, parse the device tree file, and write the parsed result into the physical storage space. The device tree file can be written to the physical storage space corresponding to the preset physical address range by the processor 21 before the second driver process starts.
[0040] Parsing a device tree file specifically refers to the process of converting the data structure of the device tree file into a data structure that the operating system can operate on. Optionally, based on the data structure of the device tree file, device information for each device can be extracted from the device tree file, and the parsed device information can be identified as the parsing result corresponding to the device tree file. For example, the device tree file is a DTB (Device Tree Blob) file, which describes device information in a tree structure. The tree structure includes multiple device nodes, each corresponding to a device, and the attributes of the device nodes are device information. By parsing the DTB file, traversing each device node in the device tree file starting from the root node, and parsing the attributes of each device node, the device information corresponding to each device can be obtained.
[0041] In some optional embodiments, after the second mapping relationship is established, a pre-configured parsing service program can be invoked to parse and store the device tree file. The parsing service program's functions include reading the device tree file from the physical storage space corresponding to a preset physical address range, parsing the device tree file, and then writing the parsed results into the physical storage space. Therefore, any driver process that is the first to need to obtain the parsed device information corresponding to the device tree file can parse and store the device tree file by invoking the parsing service program.
[0042] In some optional embodiments, the aforementioned second driver process can be a preset driver process among multiple driver processes, that is, the first driver process that needs to parse the device tree file and obtain device information. When the processor 21 receives an initialization request initiated by the preset driver process, it determines the second virtual address range corresponding to the preset driver process based on the initialization request, obtains the preset physical address range, then establishes a second mapping relationship between the preset physical address range and the second virtual address range, reads the device tree file from the physical storage space corresponding to the preset physical address range, parses the device tree file, and writes the parsed result into the physical storage space. When other driver processes besides the preset driver process initiate an initialization request, the processor 21 determines the first virtual address range corresponding to the other driver process based on the initialization request, obtains the preset physical address range, and then establishes a first mapping relationship between the preset physical address range and the first virtual address range.
[0043] In some optional embodiments, the second driver process may be the first driver process dynamically identified that needs to parse device information from the device tree file. Optionally, the second driver process can be identified through preset identification logic. For example, if any driver process among multiple driver processes initiates an initialization request, based on the initialization request, the driver process is identified as the first second driver process that needs to parse device information from the device tree file by determining whether the parsing result is already stored in the physical storage space. If the driver process is determined to be the second driver process, the above-mentioned operations such as establishing a second mapping relationship with the second driver process and parsing the device tree file are performed. If the driver process is determined not to be the second driver process, the driver process is determined to be the first driver process, and the above-mentioned operations such as establishing a first mapping relationship with the first driver process are performed.
[0044] In some optional embodiments, the parsing status of the device tree file can be maintained in real time. In response to obtaining the second initialization request, if it is determined that the parsing status of the device tree file is unparsed, the device tree file is read from the physical storage space corresponding to the preset physical address range, the device tree file is parsed, and the parsing result is written to the physical storage space.
[0045] In the embodiments of this disclosure, in response to a second initialization request initiated by a second driver process whose startup time is earlier than that of the first driver process, a second mapping relationship is established between a second virtual address range corresponding to the second driver process and a preset physical address range. The device tree file is read from the physical storage space corresponding to the preset physical address range, the device tree file is parsed, and the parsing result is written to the physical storage space. This ensures that when the first driver process starts, the physical storage space already contains the parsing result of the device tree file. This achieves the goal of obtaining the corresponding parsing result by parsing the device tree file for the first time by a driver process, and subsequent driver processes can directly read the parsing result. This avoids the situation where multiple driver processes that need to obtain the parsing result need to repeatedly parse the device tree file.
[0046] In some alternative embodiments, processor 21 is also configured to: In response to receiving a second device information acquisition request from the second driver process, based on the second virtual address information and the second mapping relationship in the second device information acquisition request, the device information of the second device corresponding to the second device information acquisition request is determined from the parsing results stored in the physical storage space; based on the device information of the second device, the second device is initialized.
[0047] After writing the parsing result to the physical storage space, the second driver process can initiate a second device information acquisition request. This request may include second virtual address information, which can be the virtual address information corresponding to the physical address information of the parsing result stored in the physical storage space. In response to the second device information acquisition request, the processor 21 determines the physical address information corresponding to the second virtual address information based on the second virtual address information and the second mapping relationship in the request. Based on the physical address information, it determines the device information of the second device corresponding to the second device information acquisition request from the parsing result stored in the physical storage space. The second device is the device corresponding to the second driver process. The processor 21 schedules the second driver process, which performs initialization processing on the second device based on its device information.
[0048] In the embodiments of this disclosure, the device information of the second device is determined from the parsing results stored in the physical storage space, thereby realizing the initialization process of the second device and ensuring that the second device can enter the working state.
[0049] In some alternative embodiments, processor 21 is specifically configured as follows: In response to receiving the second initialization request, the parsing status of the device tree file is determined; based on the second initialization request, a second mapping relationship is established between the preset physical address range and the second virtual address range corresponding to the second driver process; in response to the parsing status being unparsed, a parsing service call request is generated; based on the parsing service call request, a pre-configured parsing service program is invoked to read the device tree file from the physical storage space corresponding to the preset physical storage address range, parse the device tree file, and write the parsed result to the physical storage space.
[0050] The resolution status indicates whether the device tree file has been resolved. The resolution status can include both resolved and unresolved states. A resolution service call request is a request to invoke the resolution service program (or resolution function), which is a pre-configured service program used to process the device tree file.
[0051] Optionally, if the device tree file's parsing status is "unparsed," it means that the physical storage space has not yet stored the parsing result of the device tree file, and the device tree file needs to be parsed. If the device tree file's parsing status is "parsed," it means that the physical storage space has already stored the parsing result of the device tree file, and it is not necessary to parse the device tree file again when initializing the device.
[0052] Optionally, in response to an unresolved resolution status, a resolution service call request is generated. The resolution service call request may include the identification information of the resolution service program, the storage address information of the device tree file, etc. The storage address information of the device tree file is the physical address information of the device tree file. Based on the resolution service call request, the corresponding resolution service program can be called to parse the device tree file. For example, based on the identification information of the resolution service program in the resolution service call request, the resolution service program to be called is determined, the storage address information of the device tree file is passed to the resolution service program as a parameter, the resolution service program is executed, the device tree file is read from the physical storage space corresponding to the preset physical storage address range based on the storage address information of the device tree file, the device tree file is parsed, and the parsed result is written to the physical storage space.
[0053] Optionally, the establishment of the second mapping relationship is not constrained by the parsing state of the device tree file. Therefore, the operation of determining the parsing state of the device tree file and the operation of establishing the second mapping relationship can be performed in any order.
[0054] In the embodiments of this disclosure, by maintaining the parsing state of the device tree file, after receiving the initialization request of the driver process, it is possible to determine whether a parsing operation of the device tree file is required by identifying the parsing state. When the parsing state is determined to be unparsed, it indicates that a parsing operation of the device tree file is required. The corresponding parsing service program is then called to parse the device tree file to obtain the parsing result. In this operation mode, an unparsed state indicates that this is the first time the device tree file is parsed, and there is no situation where the device tree file is parsed repeatedly. Furthermore, by pre-configuring the parsing service program, the parsing operation is made independent of the driver process. This allows any driver process that needs to parse the device tree file during startup to perform the parsing operation by calling the pre-configured parsing service program. This avoids the need to repeatedly develop parsing-related programs in multiple drivers, reducing the complexity of driver implementation and improving the flexibility of the parsing operation.
[0055] In some optional embodiments, after writing the parsed result to the physical storage space, the processor 21 is further configured to update the parsing status of the device tree file to "parsed".
[0056] The initial state value of the device tree file's parsing status can be a preset state value that indicates that it is not parsed, for example, represented by 0. After the parsing result is written to the physical storage space, the parsing status of the device tree file is updated from unparsed to parsed. For example, if parsed is represented by 1, then 0 is updated to 1.
[0057] Optionally, the parsing status of the device tree file can be stored in a parsing status register or other types of memory. During the startup of any driver process, if the parsing operation of the device tree file is completed and the parsing result is written to the physical storage space, the parsing status of the device tree file can be updated to "parsed" in real time, so that subsequent driver processes can determine whether to parse the device tree file based on its parsing status when initialization is required.
[0058] In the embodiments of this disclosure, by writing the parsing result into the object storage space and updating the parsing status of the device tree file from unparsed to parsed in real time, an accurate and effective parsing status reference can be provided for the startup of subsequent driver processes, avoiding the situation where subsequent driver processes repeatedly parse the device tree file.
[0059] In some optional embodiments, after writing the parsed result to the physical storage space, the processor 21 is further configured to update the access permissions of the physical storage space to read-only.
[0060] In this context, "read-only" access means that data can only be read from the physical storage space, and no data can be written to it. Optionally, before the parsed results are written to the physical storage space, the physical storage space can be both read and write.
[0061] In the embodiments of this disclosure, by updating the access permissions of the physical storage space to read-only after writing the parsed result to the physical storage space, the device tree file and parsing result stored in the physical storage space can be prevented from being tampered with, thus ensuring the security and reliability of the device tree file and parsing result.
[0062] In some alternative embodiments, based on any of the above embodiments, the processor 21 is specifically configured as follows: In response to receiving the first initialization request, the parsing status of the device tree file is determined; in response to the parsing status being parsed, a first mapping relationship is established between the preset physical address range and the first virtual address range corresponding to the first driver process based on the first initialization request.
[0063] Upon receiving a first initialization request, the parsing status of the device tree file can be determined to ascertain whether parsing is required. If the parsing status is "parsed," a first mapping relationship can be established between a preset physical address range and a first virtual address range corresponding to the first driver process, based on the first initialization request. This triggers the first driver process to initiate a first device information retrieval request. In response to receiving the first device information retrieval request from the first driver process, the device information of the first device corresponding to the first device information retrieval request is determined from the parsing results stored in the physical storage space based on the first virtual address information and the first mapping relationship in the first device information retrieval request. If the parsing status is "unparsed," after establishing the first mapping relationship, the device tree file can be read from the physical storage space corresponding to the preset physical address range, parsed, and the parsing results, including the device information of the first device, written to the physical storage space. This triggers the first driver process to initiate a first device information retrieval request. In response to receiving the first device information retrieval request from the first driver process, the device information of the first device corresponding to the first device information retrieval request is determined from the parsing results stored in the physical storage space based on the first virtual address information and the first mapping relationship in the first device information retrieval request.
[0064] In other words, after the processor 21 receives an initialization request from any driver process, it can first determine the parsing status of the device tree file. If the parsing status is determined to be unparsed, a mapping relationship is established between the virtual address range corresponding to the driver process and the preset physical address range. The device tree file is then parsed, and the parsing result is written to the physical storage space. The device information corresponding to the device information retrieval request initiated by the driver process can then be determined from the parsing result stored in the physical storage space. Based on this device information, the corresponding device is initialized. If the parsing status is determined to be parsed, repeated parsing operations on the device tree file can be avoided.
[0065] In some alternative embodiments, based on any of the above embodiments, the processor 21 is specifically configured as follows: In response to receiving a first device information acquisition request from the first driver process, based on the first device information acquisition request, a pre-configured device information query service program (or device information query function) is invoked to query the device information of the first device corresponding to the first device information acquisition request from the parsing results stored in the physical storage space; the device information of the first device is transmitted to the first driver process; and the first driver process performs initialization processing on the first device based on the device information of the first device.
[0066] The device information query service program is a pre-configured service program for querying device information. This program is independent of each driver program; each driver program can call the device information query service program to query device information from the parsing results stored in physical storage. Therefore, in response to a first device information retrieval request from the first driver process, the device information query service program can be called based on the request to retrieve the device information of the corresponding first device from the parsing results stored in physical storage. This device information is then transmitted to the first driver process, which performs initialization processing on the first device based on this information.
[0067] In the embodiments of this disclosure, the device information query function is separated from the driver by a pre-configured device information query service program, avoiding the duplication of device information query function code in the driver, further reducing the amount of code in the driver, and enabling the driver process corresponding to each driver to query device information by calling the device information query service program, thereby improving the versatility of the device information query service program and facilitating the expansion of the driver process.
[0068] In some optional embodiments, the first virtual address range corresponding to the first driver process and the second virtual address range corresponding to the second driver process are the same. This ensures that the mapping relationship between the virtual address ranges corresponding to different driver processes and the preset physical address range is the same. This facilitates different driver processes to call the same initialization function, establish the same mapping relationship between the virtual address range and the preset physical address range, and call the same parsing service program to complete the parsing of the device tree file and obtain the parsing result. Different driver processes can call the same device information query service program to query the device information of the device in the parsing result. This helps to improve the adaptability of the device initialization process to different drivers and avoids the situation where it is necessary to establish different mapping relationships between the virtual address ranges and the preset physical address range for the first driver process and the second driver process respectively when the first virtual address range corresponding to the first driver process and the second virtual address range corresponding to the second driver process are different. This can reduce the complexity of the initialization function.
[0069] In some optional embodiments, the initialization function and the device information query service program can be implemented in libdtb (Device Tree Blob Library). libdtb registers the interfaces (or identification information or function names) of the initialization function and the device information query service program with the driver process, enabling the driver process to call the initialization function based on its interface and the device information query service program based on its interface. The parsing service program can be implemented in libfdt (Flattened Device Tree Library), and libfdt registers the parsing service program's interface (or identification information or function name) with libdtb. This allows libdtb to call the parsing service program within the initialization function based on its interface, thus enabling the access to the device tree file.
[0070] In some optional embodiments, the processor 21 is specifically configured to: in response to a first initialization request from the first driving process, call a pre-set initialization function to establish a first mapping relationship between a preset physical address range and a first virtual address range corresponding to the first driving process; in response to the completion of the initialization function execution, return the initialization function execution result to the first driving process, the initialization function execution result may include information indicating that the first mapping relationship has been established; in response to the initialization function execution result, the first driving process initiates a first device information acquisition request; in response to the first device information acquisition request, the processor 21 calls a device information query service program to determine the device information of the first device from the parsing results stored in the physical storage space, and returns the device information of the first device to the first driving process; the first driving process performs initialization processing on the first device based on the device information of the first device.
[0071] In some optional embodiments, the processor 21 is specifically configured to: respond to a second initialization request from the second driving process, call a pre-set initialization function to establish a second mapping relationship between a preset physical address range and a second virtual address range corresponding to the second driving process; respond to a device tree file parsing status of unparsed, generate a parsing service call request; respond to the parsing service call request to call a pre-set parsing service program to read the device tree file from the physical storage space, parse the device tree file, write the parsed result to the physical storage space, and then return parsing completion information to the initialization function; the initialization function returns the parsing completion information to the second driving process; respond to the parsing completion information, the second driving process initiates a second device information acquisition request; respond to the acquisition request, the processor 21 calls a pre-set device information query service program to determine the device information of the second device from the parsing results stored in the physical storage space, and returns the device information of the second device to the second driving process; the second driving process performs initialization processing on the second device based on the device information of the second device.
[0072] Figure 3 This is a flowchart illustrating the startup process of multiple driver processes in related technologies. These driver processes include Driver Process A, Driver Process B, and Driver Process C. The startup process for each driver process is identical. Taking Driver Process A as an example, during its startup, Driver Process A calls a first preset function pre-registered by libdtb. The dtb API (Application Programming Interface) represents the interface (e.g., function name) of the first preset function in libdtb. The first preset function in libdtb calls a second preset function pre-registered by libfdt. The fdt API represents the interface of the second preset function. The second preset function parses the device tree file and returns the parsing result to the first preset function. In response to the parsing result of the second preset function, the first preset function returns the parsed execution result to Driver Process A. Driver Process A, in response to the parsed execution result, then calls a third preset function in libdtb. The third preset function queries device information from the query results and returns the device information to Driver Process A. Driver Process A then initializes the device based on this device information. The startup process of driver process B and driver process C is the same as that of driver process A, and will not be described in detail here.
[0073] As can be seen, in related technologies, each driver process needs to complete the parsing of the device tree file through two levels of calls during startup, and then query device information from the parsing results to initialize the device. Multiple driver processes need to perform repeated parsing operations on the device tree file. Furthermore, each driver process needs to store a copy of the device tree file and the parsing results.
[0074] Figure 4 This is a schematic diagram illustrating the initialization process of multiple devices provided in an exemplary embodiment of this disclosure. For example... Figure 4 As shown, taking driver process A as the second driver process that first needs to use the parsed results of the device tree file, and driver processes B and C as the first driver processes, during the startup process of driver process A, driver process A can use the interface of the initialization function (represented as...) Figure 4 The libdtb API calls the pre-registered initialization function of libdtb. Executing the initialization function maps the physical storage space used to store the device tree file and parsing results to the virtual address space corresponding to driver process A, establishing a second mapping relationship between the preset physical address range and the second virtual address range corresponding to driver process A. This is then based on the interface of the pre-registered parsing service program of libfdt (represented as...). Figure 4 The driver process A calls the libdt API to execute the device tree file, parses the device tree file, and then writes the parsed results to physical storage. Afterward, driver A can initiate a second device information retrieval request, calling the pre-registered libdtb device information query service to retrieve the second device's information from physical storage and perform initialization processing based on that information.
[0075] The startup process of driver process B is the same as that of driver process C. Taking driver process B as an example, driver process B calls the initialization function to map the physical storage space to the virtual address space corresponding to driver process B. That is, it establishes the first mapping relationship between the preset physical address range and the first virtual address range corresponding to driver process B. Since the device tree file parsing result is already stored in the physical storage space, there is no need to parse the device tree file again. Then, the driver process can directly initiate a first device information acquisition request, call the device information query service program pre-registered by libdtb, query the device information of the first device from the physical storage space, and perform initialization processing on the first device based on the device information.
[0076] As can be seen, the initialization process of the device initialization device in this embodiment only requires one driver process (such as driver process A) to perform a single parsing operation on the device tree file. Other driver processes (such as driver processes B and C) can directly read the parsing results stored in the physical storage space by establishing a first mapping relationship between the virtual address range and the preset physical address range of the physical storage space storing the device tree file and the parsing results. This avoids multiple driver processes having to repeatedly parse the device tree file, thereby improving the startup efficiency of the driver processes. Since multiple driver processes share the device tree file and parsing results in the same memory, memory space can be effectively saved. In addition, the initialization function and device information query function are implemented in libdtb, separating the functions of establishing the mapping relationship between the virtual address range and the preset physical address range, as well as the functions of querying device information, from the driver processes. This makes it easy to set the interface of the initialization function and device information query function to be consistent with the interface supported by any type of operating system. This allows the initialization function to be applied to the initialization operation of devices corresponding to any type of operating system, enabling the driver processes of different types of operating systems to call the initialization function without modifying the driver, thus improving the versatility of the initialization function. For example, by setting the interfaces of functions such as initialization functions and device information query functions in the microkernel operating system to be consistent with the relevant function interfaces supported by the Linux operating system, the initialization operations of devices in the microkernel operating system can be compatible with those in the Linux operating system, providing technical support for cross-operating system compatibility of drivers between the microkernel operating system and the Linux operating system.
[0077] The embodiments described above can be implemented individually or in any combination without conflict. The specific implementation can be set according to actual needs, and this disclosure does not limit them.
[0078] Example method Figure 5 This is a schematic flowchart of a device initialization method provided in an exemplary embodiment of this disclosure. The method provided in this embodiment can be implemented by the device initialization apparatus provided in any of the above embodiments of this disclosure, such as... Figure 5 The device initialization method shown may include the following steps: Step 510: In response to receiving a first initialization request initiated by the first driver process in the operating system, based on the first initialization request, establish a first mapping relationship between a preset physical address range and a first virtual address range corresponding to the first driver process.
[0079] The physical storage space corresponding to the preset physical address range stores the device tree file and the corresponding parsing results of the device tree file.
[0080] Step 520: In response to receiving a first device information acquisition request from the first driver process, based on the first virtual address information and the first mapping relationship in the first device information acquisition request, determine the device information of the first device corresponding to the first device information acquisition request from the parsing results stored in the physical storage space.
[0081] Step 530: Based on the device information of the first device, perform initialization processing on the first device.
[0082] Figure 6 This is a flowchart illustrating a device initialization method provided in another exemplary embodiment of this disclosure.
[0083] In some alternative embodiments, based on any of the above embodiments, such as Figure 6 As shown, before receiving the first initialization request initiated by the first driver process in the operating system, the method of this embodiment further includes: Step 610: In response to receiving a second initialization request initiated by the second driver process in the operating system, based on the second initialization request, establish a second mapping relationship between the preset physical address range and the second virtual address range corresponding to the second driver process.
[0084] The first virtual address range is the same as the second virtual address range; the second driver process starts earlier than the first driver process.
[0085] Step 620: Read the device tree file from the physical storage space corresponding to the preset physical address range, parse the device tree file, and write the parsing result into the physical storage space.
[0086] The parsing results include device information for multiple devices.
[0087] Figure 7 This is a flowchart illustrating a device initialization method provided in yet another exemplary embodiment of this disclosure.
[0088] In some alternative embodiments, such as Figure 7 As shown, the method in this embodiment of the disclosure further includes: Step 630: In response to receiving a second device information acquisition request from the second driver process, based on the second virtual address information and the second mapping relationship in the second device information acquisition request, determine the device information of the second device corresponding to the second device information acquisition request from the parsing results stored in the physical storage space.
[0089] Step 640: Based on the device information of the second device, perform initialization processing on the second device.
[0090] In some optional embodiments, step 610, in response to receiving a second initialization request initiated by a second driver process in the operating system, establishing a second mapping relationship between a preset physical address range and a second virtual address range corresponding to the second driver process based on the second initialization request, may include: In response to receiving the second initialization request, the parsing status of the device tree file is determined, and based on the second initialization request, a second mapping relationship is established between the preset physical address range and the second virtual address range corresponding to the second driver process.
[0091] Step 620 involves reading the device tree file from the physical storage space corresponding to the preset physical address range, parsing the device tree file, and writing the parsing result into the physical storage space, including: In response to an unresolved resolution status, a resolution service call request is generated. Based on the resolution service call request, a pre-configured resolution service program is invoked to read the device tree file from the physical storage space corresponding to the preset physical storage address range, parse the device tree file, and write the parsed result to the physical storage space.
[0092] In some optional embodiments, after writing the parsed result to the physical storage space, the method of this disclosure further includes updating the parsing status of the device tree file to "parsed".
[0093] In some optional embodiments, after writing the parsed result to the physical storage space, the method of this disclosure embodiment further includes: updating the access permissions of the physical storage space to read-only.
[0094] In some optional embodiments, based on any of the above embodiments, step 510, in response to obtaining a first initialization request initiated by a first driver process in the operating system, and establishing a first mapping relationship between a preset physical address range and a first virtual address range corresponding to the first driver process based on the first initialization request, may include: In response to receiving the first initialization request, the parsing status of the device tree file is determined; in response to the parsing status being parsed, a first mapping relationship is established between the preset physical address range and the first virtual address range corresponding to the first driver process based on the first initialization request.
[0095] In some optional embodiments, based on any of the above embodiments, in step 520, in response to obtaining a first device information acquisition request from the first driving process, the device information of the first device corresponding to the first device information acquisition request is determined from the parsing results stored in the physical storage space based on the first virtual address information and the first mapping relationship in the first device information acquisition request: In response to receiving a first device information retrieval request from the first driver process, based on the first device information retrieval request, a pre-configured device information query service program is invoked to query the device information of the first device corresponding to the first device information retrieval request from the parsing results stored in the physical storage space; and the device information of the first device is transmitted to the first driver process.
[0096] Step 530 involves initializing the first device based on its device information, including: initializing the first device through a first driver process based on its device information.
[0097] Figure 8 This is a schematic flowchart of a device initialization method provided in yet another exemplary embodiment of this disclosure.
[0098] In some optional embodiments, based on any of the above embodiments, the preset physical address range is the physical address range of a preset physical storage space in the first memory. For example... Figure 8 As shown, before receiving the first initialization request initiated by the first driver process in the operating system, the method of this embodiment further includes: Step 710: In response to the operating system's boot command, execute the bootloader.
[0099] Step 720: In response to the execution of the first preset instruction in the bootloader, the device tree file is read from the second memory and written into the first subspace of the physical storage space in the first memory.
[0100] The physical storage space includes a first subspace for storing device tree files and a second subspace for storing parsing results.
[0101] In step 520, in response to receiving a first device information acquisition request from the first driver process, based on the first virtual address information and the first mapping relationship in the first device information acquisition request, the device information of the first device corresponding to the first device information acquisition request is determined from the parsing results stored in the physical storage space, including: Step 5210: In response to receiving a first device information acquisition request from the first driver process, based on the first virtual address information and the first mapping relationship in the first device information acquisition request, the device information of the first device corresponding to the first device information acquisition request is obtained from the second subspace in the physical storage space.
[0102] The embodiments described above can be implemented individually or in any combination without conflict. The specific implementation can be set according to actual needs, and this disclosure does not limit them.
[0103] The beneficial technical effects corresponding to the exemplary embodiments of this method can be found in the corresponding beneficial technical effects of the exemplary device section above, and will not be repeated here.
[0104] The device initialization method provided in this disclosure can be executed by any suitable electronic device with data processing capabilities, including but not limited to terminal devices and servers. Alternatively, the device initialization method provided in this disclosure can be executed by a processor, such as by a processor calling corresponding instructions stored in memory to execute the device initialization method mentioned in this disclosure. Further details will not be elaborated below.
[0105] Example electronic device Figure 9 This is a structural diagram of an electronic device provided in an embodiment of the present disclosure, including at least one processor 91 and a memory 92.
[0106] The processor 91 may be a central processing unit (CPU) or other form of processing unit with data processing capabilities and / or instruction execution capabilities, and may control other components in the electronic device 90 to perform desired functions.
[0107] The memory 92 may include one or more computer program products, which may include various forms of computer-readable storage media, such as volatile memory and / or non-volatile memory. Volatile memory may include, for example, random access memory (RAM) and / or cache memory. Non-volatile memory may include, for example, read-only memory (ROM), hard disk, flash memory, etc. One or more computer program instructions may be stored on the computer-readable storage medium, and the processor 91 may execute one or more computer program instructions to implement the device initialization methods and / or other desired functions of the various embodiments of this disclosure described above.
[0108] In one example, the electronic device 90 may also include an input device 93 and an output device 94, which are interconnected via a bus system and / or other forms of connection mechanism (not shown).
[0109] The input device 93 may also include, for example, a touch screen, a microphone, various sensors, etc.
[0110] The output device 94 can output various information to the outside, including, for example, a display, a speaker, a communication network and its connected remote output devices, etc.
[0111] Of course, for the sake of simplicity, Figure 9Only some of the components of the electronic device 90 relevant to this disclosure are shown, omitting components such as buses, input / output interfaces, etc. In addition, the electronic device 90 may include any other suitable components depending on the specific application.
[0112] Example computer program product and computer readable storage medium In addition to the methods and apparatus described above, embodiments of this disclosure may also provide a computer program product, including computer program instructions that, when executed by a processor, cause the processor to perform steps in the device initialization methods of the various embodiments of this disclosure described in the "Exemplary Methods" section above.
[0113] Computer program products can be written in any combination of one or more programming languages to perform the operations of embodiments of this disclosure. These programming languages include object-oriented programming languages such as Java and C++, as well as conventional procedural programming languages such as C or similar languages. The program code can be executed entirely on a user's computing device, partially on a user's computing device, as a standalone software package, partially on a user's computing device and partially on a remote computing device, or entirely on a remote computing device or server.
[0114] Furthermore, embodiments of this disclosure may also be computer-readable storage media storing computer program instructions thereon, which, when executed by a processor, cause the processor to perform the steps in the device initialization methods of the various embodiments of this disclosure described in the "Exemplary Methods" section above.
[0115] Computer-readable storage media may take the form of any combination of one or more readable media. A readable medium may be a readable signal medium or a readable storage medium. A readable storage medium may include, but is not limited to, systems, apparatuses, or devices that are electrical, magnetic, optical, electromagnetic, infrared, or semiconductor, or any combination thereof. More specific examples of readable storage media (a non-exhaustive list) include: electrical connections having one or more wires, portable disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.
[0116] The basic principles of this disclosure have been described above with reference to specific embodiments. However, the advantages, benefits, and effects mentioned in this disclosure are merely examples and not limitations, and should not be considered as essential features of each embodiment of this disclosure. Furthermore, the specific details disclosed above are for illustrative and facilitative purposes only, and are not limitations. These details do not limit the scope of this disclosure to the necessity of employing the aforementioned specific details for implementation.
[0117] Various modifications and variations can be made to this disclosure without departing from the spirit and scope of this application. Therefore, if such modifications and variations fall within the scope of the claims of this disclosure and their equivalents, this disclosure is also intended to include such modifications and variations.
Claims
1. An initialization apparatus for a device, the apparatus comprising a processor configured to: In response to receiving a first initialization request initiated by a first driver process in the operating system, a first mapping relationship is established between a preset physical address range and a first virtual address range corresponding to the first driver process based on the first initialization request; wherein... The physical storage space corresponding to the preset physical address range stores the device tree file and the parsing result corresponding to the device tree file; In response to receiving a first device information acquisition request from the first driver process, based on the first virtual address information and the first mapping relationship in the first device information acquisition request, the device information of the first device corresponding to the first device information acquisition request is determined from the parsing results stored in the physical storage space; Based on the device information of the first device, the first device is initialized.
2. The apparatus according to claim 1, wherein, Before receiving the first initialization request initiated by the first driver process in the operating system, the processor is further configured to: In response to receiving a second initialization request initiated by a second driver process in the operating system, a second mapping relationship is established between the preset physical address range and the second virtual address range corresponding to the second driver process based on the second initialization request, wherein the first virtual address range is the same as the second virtual address range; The second driver process starts earlier than the first driver process; The device tree file is read from the physical storage space corresponding to the preset physical address range, the device tree file is parsed, and the parsing result is written to the physical storage space; the parsing result includes device information of multiple devices.
3. The apparatus according to claim 2, wherein, The processor is also configured to: In response to receiving a second device information acquisition request from the second driver process, based on the second virtual address information and the second mapping relationship in the second device information acquisition request, the device information of the second device corresponding to the second device information acquisition request is determined from the parsing result stored in the physical storage space; Based on the device information of the second device, the second device is initialized.
4. The apparatus according to claim 2, wherein, The processor is specifically configured as follows: In response to receiving the second initialization request, the parsing status of the device tree file is determined; Based on the second initialization request, a second mapping relationship is established between the preset physical address range and the second virtual address range corresponding to the second driver process; In response to the resolution status being unresolved, a resolution service call request is generated; Based on the parsing service call request, a pre-configured parsing service program is invoked to read the device tree file from the physical storage space corresponding to the preset physical storage address range, parse the device tree file, and write the parsing result obtained after parsing into the physical storage space; The processor is also configured to update the parsing status of the device tree file to "parsed".
5. The apparatus according to claim 2, wherein, After writing the parsed result to the physical storage space, the processor is further configured to: Update the access permissions of the physical storage space to read-only.
6. The apparatus according to any one of claims 1-5, wherein, The processor is specifically configured as follows: In response to receiving the first initialization request, determine the parsing status of the device tree file; In response to the resolution status being resolved, based on the first initialization request, a first mapping relationship is established between the preset physical address range and the first virtual address range corresponding to the first driver process.
7. The apparatus according to any one of claims 1-5, wherein, The processor is specifically configured as follows: In response to receiving the first device information acquisition request from the first driver process, based on the first device information acquisition request, a pre-configured device information query service program is invoked to query the device information of the first device corresponding to the first device information acquisition request from the parsing results stored in the physical storage space; Transmit the device information of the first device to the first driver process; The first driver process initializes the first device based on the device information of the first device.
8. The apparatus according to any one of claims 1-5, wherein, The preset physical address range is the preset physical address range of the physical storage space in the first memory; before receiving the first initialization request initiated by the first driver process in the operating system, the processor is further configured to: In response to the operating system's boot command, the bootloader is executed; In response to a first preset instruction executed in the bootloader, the device tree file is read from the second memory and written into a first subspace of the physical storage space in the first memory; the physical storage space includes a first subspace for storing the device tree file and a second subspace for storing the parsing result. The processor is specifically configured to obtain the device information of the first device corresponding to the first device information acquisition request from the second subspace in the physical storage space, based on the first virtual address information in the first device information acquisition request and the first mapping relationship.
9. A method for initializing a device, comprising: In response to receiving a first initialization request initiated by a first driver process in the operating system, a first mapping relationship is established between a preset physical address range and a first virtual address range corresponding to the first driver process based on the first initialization request; wherein, the physical storage space corresponding to the preset physical address range stores a device tree file and the parsing result corresponding to the device tree file; In response to receiving a first device information acquisition request from the first driver process, based on the first virtual address information and the first mapping relationship in the first device information acquisition request, the device information of the first device corresponding to the first device information acquisition request is determined from the parsing results stored in the physical storage space; Based on the device information of the first device, the first device is initialized.
10. A computer-readable storage medium storing a computer program that is executed by a processor to perform the initialization method of the device according to claim 9.
11. An electronic device, the electronic device comprising: processor; Memory used to store the processor's executable instructions; The processor is configured to read the executable instructions from the memory, and execute the executable instructions to implement the device initialization method of claim 9.