A kernel startup processing method, system, storage medium and electronic device
By using a kernel boot location-independent program and a kernel deterministic mapping range, combined with a unified parsing framework and initialization sequence management mechanism, the problems of poor flexibility, scalability, and compatibility in kernel boot management in industrial control systems are solved, thereby improving the flexibility and stability of kernel deployment.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- SUPCON TECH CO LTD
- Filing Date
- 2023-12-20
- Publication Date
- 2026-07-21
AI Technical Summary
In existing technologies, kernel boot management methods for industrial control systems suffer from poor kernel deployment flexibility, poor scalability, and poor compatibility. In particular, the memory mapping problem caused by the coupling between the kernel boot process and the bootloader affects the stability and security of the system.
By using a kernel boot location-independent program and a kernel deterministic mapping range, combined with a unified resolution framework and initialization order management mechanism, the kernel boot parameters can be configured independently and flexibly extended, ensuring the initialization order of each module during kernel boot and solving the memory mapping coupling problem between the kernel and the bootloader.
It improves the flexibility and scalability of kernel deployment, enhances system compatibility and stability, avoids the problems of poor compatibility and usability caused by version iteration, and ensures the security and availability of industrial operating system kernel startup.
Smart Images

Figure CN117687699B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of process industry automation, and more specifically, to a kernel boot process method, system, storage medium, and electronic device. Background Technology
[0002] There are two main methods for kernel boot management in industrial control systems. The first is the traditional method, which requires determining the kernel boot parameters during the bootloader compilation stage. The second method involves obtaining the boot parameters from a kernel parsing parameter configuration file and configuring the corresponding environment variables and boot parameters during the kernel boot process.
[0003] The first kernel boot management method, due to the coupling between the kernel boot and bootloader spaces, results in the kernel bootloader being location-dependent code, which needs to be loaded into a specified link location to run, greatly reducing the flexibility of kernel deployment.
[0004] The second kernel boot management method requires the bootloader to parse kernel boot parameters and environment variables during kernel initialization. Adding or removing kernel parameters necessitates synchronized changes by the bootloader. This coupling issue caused by modifying boot parameters leads to poor overall kernel scalability. Furthermore, the sequential management is easily modified by users, resulting in poor compatibility during version iterations.
[0005] Therefore, how to improve the flexibility, scalability, and compatibility of kernel deployment in the kernel boot management of industrial control systems is a problem that this application urgently needs to solve. Summary of the Invention
[0006] In view of this, this application discloses a kernel boot processing method, system, storage medium, and electronic device, aiming to improve the flexibility, scalability, and compatibility of kernel deployment in kernel boot management of industrial control systems.
[0007] To achieve the above objectives, the disclosed technical solution is as follows:
[0008] The first aspect of this application discloses a kernel boot process method, the method comprising:
[0009] By using the kernel to boot a position-independent program and the kernel deterministic mapping range, the page table entries required for kernel boot are obtained; the kernel deterministic range is determined by the start and end addresses of the kernel linker file.
[0010] The page table entries are parsed using a unified parsing framework to obtain the parsing results;
[0011] If the parsing result matches the preset matching conditions, the kernel startup parameters and environment variables are obtained;
[0012] When a kernel startup request is received, the kernel startup parameters and environment variables are initialized using an initialization order management mechanism to obtain the kernel initialization result corresponding to the kernel startup request. The initialization order management mechanism is used to ensure the initialization order of each module during the kernel startup process.
[0013] If the kernel initialization result meets the preset initialization conditions, the kernel startup is completed.
[0014] Preferably, obtaining the page table entries required for kernel startup by using the kernel boot location-independent program and the kernel deterministic mapping range includes:
[0015] Obtain a separate configuration file for kernel boot parameters;
[0016] The independent configuration file for kernel boot parameters is parsed into the kernel boot parameter area;
[0017] The bootloader and the kernel startup parameter area are passed parameters; the passed parameters are used to concatenate the data of the bootloader and the kernel startup parameter area.
[0018] The physical memory address for kernel startup is obtained based on the passed parameters;
[0019] Obtain the kernel boot virtual address from the pre-acquired kernel linker file;
[0020] The offset between the physical memory address and the kernel startup virtual address is obtained by taking the difference between the physical memory address and the kernel startup virtual address.
[0021] Read the start and end addresses of the kernel linker file;
[0022] The start and end addresses of the kernel linker file are corrected using the offset.
[0023] Calculate the kernel image size based on the corrected start address and corrected end address;
[0024] The kernel image size is determined according to a preset value selection method to obtain the kernel deterministic mapping range;
[0025] By using the kernel boot location-independent program and the kernel deterministic mapping range, the page table entries required for kernel boot are obtained.
[0026] Preferably, the step of parsing the page table entries using a unified parsing framework to obtain the parsing results includes:
[0027] When the kernel program starts, the unified parsing framework is triggered to parse the page table entries for kernel startup parameters to obtain the configuration file;
[0028] According to the identifier, the configuration file is stored in the kernel boot parameter area;
[0029] Index the kernel startup parameter compilation area and match the identifiers of the kernel startup parameter area with those of the kernel startup parameter compilation area;
[0030] If the identifier in the kernel boot parameter area matches the identifier in the kernel boot parameter compilation area, the match is successful, and the parsing result of the successful match is obtained.
[0031] If the identifier of the kernel boot parameter area does not match the identifier of the kernel boot parameter compilation area, the matching is determined to be unsuccessful, and the parsing result of the unsuccessful matching is obtained.
[0032] Preferably, if the parsing result meets preset matching conditions, the kernel startup parameters and environment variables are obtained, including:
[0033] If the parsing result is a successful match, it is determined that the parsing result meets the preset matching conditions, and the kernel startup parameters and environment variables are obtained.
[0034] Preferably, when a kernel boot request is received, the kernel boot parameters and environment variables are initialized using an initialization order management mechanism to obtain the kernel initialization result corresponding to the kernel boot request, including:
[0035] When a kernel startup request is received, the kernel startup parameters and environment variables are initialized using the initialization order management mechanism to obtain the kernel-initialized gradient compilation area.
[0036] Determine whether the gradient compilation region after kernel initialization is not empty; the gradient compilation region is obtained by creating a kernel image; the gradient compilation region stores the initialization programs of each module during kernel startup and the corresponding module initialization tasks executed by multiple gradient compilation regions indexed according to a preset order;
[0037] If the gradient compilation region after kernel initialization is not empty, the first kernel gradient sequential initialization result is obtained; the first kernel gradient sequential initialization result indicates that the gradient compilation region corresponding to the kernel startup requirements is not empty.
[0038] If the gradient compilation region after kernel initialization is not empty, the second kernel gradient sequential initialization result is obtained; the second kernel gradient sequential initialization result indicates that the gradient compilation region corresponding to the kernel startup requirements is not empty.
[0039] Preferably, if the kernel initialization result meets the preset initialization conditions, the kernel startup is completed, including:
[0040] If the kernel initialization result indicates that the gradient compilation region corresponding to the kernel startup requirement is not empty, it is determined that the kernel initialization result meets the preset initialization conditions, and the kernel startup is completed.
[0041] Preferred options also include:
[0042] If the kernel initialization result indicates that the gradient compilation area corresponding to the kernel startup requirement is not empty, return to the step of performing kernel startup initialization operations on the kernel startup parameters and environment variables through the initialization order management mechanism when the kernel startup requirement is received, and obtain the kernel initialization result corresponding to the kernel startup requirement.
[0043] A second aspect of this application discloses a kernel boot processing system, the system comprising:
[0044] The first acquisition unit is used to obtain the page table entries required for kernel startup by using the kernel startup location-independent program and the kernel deterministic mapping range; the kernel deterministic range is determined by the start and end addresses of the kernel linker file;
[0045] The parsing unit is used to parse the page table entries using a unified parsing framework to obtain the parsing results;
[0046] The second acquisition unit is used to obtain kernel startup parameters and environment variables if the parsing result meets the preset matching conditions;
[0047] An operation unit is used to perform kernel startup initialization operations on the kernel startup parameters and environment variables through an initialization order management mechanism when a kernel startup request is received, so as to obtain the kernel initialization result corresponding to the kernel startup request; the initialization order management mechanism is used to ensure the initialization order of each module during the kernel startup process;
[0048] The completion unit is used to complete the kernel startup if the kernel initialization result meets the preset initialization conditions.
[0049] A third aspect of this application discloses a storage medium comprising stored instructions, wherein, when the instructions are executed, the device in which the storage medium resides executes a kernel boot process as described in any one of the first aspects.
[0050] The fourth aspect of this application discloses an electronic device, including a memory and one or more instructions, wherein one or more instructions are stored in the memory and configured to be executed by one or more processors using a kernel-initiated processing method as described in any of the first aspects.
[0051] As can be seen from the above technical solution, this application discloses a kernel boot processing method, system, storage medium, and electronic device. By using a kernel boot location-independent program and a kernel deterministic mapping range, the page table entries required for kernel boot are obtained. The kernel deterministic range is determined by the start and end addresses of the kernel linker file. A unified parsing framework is used to parse the page table entries, obtaining the parsing results. If the parsing results meet preset matching conditions, kernel boot parameters and environment variables are obtained. When a kernel boot request is received, an initialization order management mechanism is used to perform kernel boot initialization operations on the kernel boot parameters and environment variables, obtaining the kernel initialization result corresponding to the kernel boot request. The initialization order management mechanism is used to ensure the initialization order of each module during kernel boot. If the kernel initialization result meets the preset initialization conditions, kernel boot is completed. Through the above solution, and by designing a unified kernel boot parameter parsing framework, kernel boot parameters can be arbitrarily expanded as needed, improving the scalability and flexibility of kernel boot parameters under multi-standard requirements, thereby improving the flexibility and scalability of kernel deployment in kernel boot management. Furthermore, by employing a kernel startup initialization order management mechanism, the initialization order is established as needed, avoiding the compatibility and usability issues caused by kernel version iterations, and preventing version compatibility and user usability problems resulting from modifying the initialization order. This improves the compatibility of kernel deployment in industrial control system kernel startup management. In addition, by using a kernel startup location-independent program and a deterministic kernel mapping range, the coupling problem between kernel startup and the bootloader's memory mapping is resolved, ensuring the stability and security of the industrial operating system kernel startup. Attached Figure Description
[0052] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of this application. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.
[0053] Figure 1 This is a diagram illustrating the overall kernel boot framework disclosed in an embodiment of this application.
[0054] Figure 2 This is a flowchart illustrating a kernel startup process disclosed in an embodiment of this application;
[0055] Figure 3 This is a schematic diagram of the structure of a kernel boot processing system disclosed in an embodiment of this application;
[0056] Figure 4This is a schematic diagram of the structure of an electronic device disclosed in an embodiment of this application. Detailed Implementation
[0057] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0058] In this application, the terms "comprising," "including," or any other variations thereof are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0059] As the background technology indicates, the first kernel boot management method significantly reduces the flexibility of kernel deployment, while the second method introduces coupling issues that result in poor overall kernel scalability. Furthermore, sequential management is easily modified by users, leading to poor compatibility issues during version iterations.
[0060] To address the aforementioned issues, this application discloses a kernel boot processing method, system, storage medium, and electronic device. Through a unified kernel boot parameter parsing framework, kernel boot parameters can be arbitrarily expanded as needed, improving the scalability and flexibility of kernel boot parameters under multi-standard requirements. This enhances the flexibility and scalability of kernel deployment in kernel boot management. Furthermore, through a kernel boot initialization order management mechanism, an initialization order is established as needed, avoiding the compatibility and usability issues caused by kernel version iterations and the version compatibility and user usability issues caused by modifying the initialization order. This improves the compatibility of kernel deployment in industrial control system kernel boot management. In addition, by using a kernel boot position-independent program and a kernel deterministic mapping range, the mutual coupling problem of memory mapping between the kernel boot process and the bootloader is solved, ensuring the stability and security of industrial operating system kernel boot. Specific implementation methods are described in detail in the following embodiments.
[0061] refer to Figure 1The diagram shown is an overall kernel boot framework diagram disclosed in this application embodiment. The overall kernel boot framework mainly consists of three parts: kernel boot location independence and initial page table local deterministic mapping (i.e., kernel deterministic mapping range), independent configuration and unified parsing framework design for kernel boot parameters, and kernel initialization order management design.
[0062] Kernel boot location-independent and initial page table locally deterministic mapping design:
[0063] The bootloader and kernel are designed as two independent and decoupled parts. The kernel boot location-independent program and the initial page table local deterministic mapping design are adopted to accurately map the page table entries required for kernel boot, which effectively improves the efficiency of kernel boot. At the same time, it avoids the mutual influence of bootloader memory mapping on kernel boot, thus improving kernel availability.
[0064] 1. The kernel startup initialization program is written in a position-independent program, which ensures that the program in the kernel initialization preparation stage can be loaded into any address space for execution.
[0065] Position independence means that the link address of the executed program instructions is independent of the actual running memory space;
[0066] 2. The bootloader passes parameters to the kernel: kernel physical memory address, starting address of configuration data area, and size;
[0067] 3. Calculate the address deviation between the virtual address and the physical address based on the kernel physical memory address for address correction. Calculate the kernel image size based on the corrected start address and corrected end address. Implement initial page table deterministic local mapping based on the corrected parameters (i.e., assign values to the kernel image size according to a preset value method to obtain the kernel deterministic mapping range).
[0068] 4. Initialize other resource configurations such as exception vector table and stack, and complete the pre-boot preparation work of the kernel.
[0069] Kernel boot parameter independent configuration and unified parsing framework design:
[0070] Startup parameter compilation area: The parameters that the kernel needs to configure are compiled into the specified compilation area.
[0071] Kernel boot parameter area: The bootloader parses the configuration file and stores it in the boot parameter area according to the tag items, which are used for subsequent indexing and matching.
[0072] It supports independent configuration of kernel boot parameter files, eliminating the need to synchronously modify the bootloader when kernel boot parameters are changed. Users can arbitrarily extend kernel boot parameters as needed. During parameter parsing, the boot parameter compilation area and the kernel boot parameter area can be matched through TAG identifiers. If the match verification passes, parameter passing is performed. This unified parsing framework effectively avoids the problems of poor extensibility of kernel boot parameters and excessive redundancy and complexity in development and maintenance. The kernel boot parameter parsing and matching process is as follows:
[0073] 1. Write the kernel boot parameters into the configuration file you wrote, and package the configuration file together with the operating system kernel into an image file and download it to the storage medium;
[0074] 2. After the system is powered on, the bootloader parses the configuration file from the operating system image package and stores the kernel boot parameters and environment variables extracted from the configuration file into the kernel configuration data area.
[0075] 3. During the kernel creation phase, the boot parameters that need to be configured are compiled into the specified boot parameter compilation area;
[0076] 4. Before the kernel starts, the data in the indexed boot parameter compilation area and the kernel configuration data area are matched (based on the matching principle of the same TAG identifier);
[0077] 5. If the TAG matches, the address of the corresponding entry in the kernel parameter area is passed to the boot parameter item to realize the parsing and acquisition of kernel boot parameters.
[0078] Kernel initialization order management design:
[0079] It mainly targets the kernel startup initialization process, establishing the startup order of modules that need to be started in a specific order, including order setting and initial startup management.
[0080] 1. In kernel image creation, multiple gradient compilation regions are defined, and the initialization models that need to be executed in order are compiled and linked to the specified compilation regions;
[0081] 2. Based on the requirements of different industrial operating system kernel standards, compile the initialization programs of each module during kernel startup into the specified compilation area;
[0082] 3. After the kernel parameters are parsed, the corresponding module initialization tasks are executed in the multiple gradient compilation areas defined by the sequential index. This enables flexible control and management during the kernel startup process, ensures the initialization order of each module during kernel startup, prevents poor compatibility issues caused by kernel iteration, and greatly increases the usability of the kernel for users.
[0083] Figure 1 In the kernel startup process, the overall framework is executed as follows:
[0084] Parse the kernel boot parameter independent configuration file into the kernel boot parameter area;
[0085] The kernel boot parameter area is passed through the bootloader to start the kernel;
[0086] Calculate virtual and physical address offsets;
[0087] Design deterministic mapping of kernel temporary page tables by using kernel deterministic mapping range;
[0088] Perform register and stack initialization;
[0089] The kernel C program starts, and after the kernel C program starts, the kernel startup parameters are parsed.
[0090] The kernel boot parameter compilation area is indexed, and the kernel boot parameter area is matched with the kernel boot parameter compilation area TAG.
[0091] If the match fails, return to the step of compiling the index startup parameters;
[0092] If the match is successful, obtain the kernel startup parameters and environment variables;
[0093] When a kernel boot request is received, the kernel boot parameters and environment variables are initialized using the initialization order management mechanism.
[0094] During the kernel startup initialization process, it is determined whether the initialization gradient compilation area is not empty;
[0095] If the initial gradient compilation region is not empty, the kernel gradient sequential initialization is executed, and the kernel startup is complete.
[0096] If the initialization gradient compilation area is not empty, return to the step of performing kernel startup initialization operations on kernel startup parameters and environment variables through the initialization order management mechanism.
[0097] In the kernel boot process of industrial operating systems, particularly considering the significant differences in kernel functional requirements across various industrial control systems, the strong coupling of kernel boot parameters, the complexity of the operation process, and the compatibility risks caused by modifying the kernel boot initialization order, a user-friendly industrial operating system kernel boot framework method is proposed. This method solves the problems of complex kernel boot configuration and poor scalability caused by the large differences in requirements of traditional industrial operating systems, avoids the problems of poor compatibility and poor user usability caused by modifying the kernel boot initialization order, and resolves the mutual coupling problem of memory mapping between kernel boot and bootloader. Simultaneously, it meets the kernel configuration and rapid development needs under different industrial operating system requirements, greatly improving the maintainability and usability of industrial operating system kernels.
[0098] The technology applied in this solution can be used in safety instrumented systems, etc.
[0099] In this embodiment, a unified kernel boot parameter parsing framework is designed, allowing kernel boot parameters to be arbitrarily expanded as needed. This improves the scalability and flexibility of kernel boot parameters under multi-standard requirements, thereby enhancing the flexibility and scalability of kernel deployment in kernel boot management. Furthermore, through a kernel boot initialization order management mechanism, an initialization order is established as needed, avoiding the poor compatibility and usability issues caused by kernel version iterations, and preventing version compatibility and user usability problems caused by modifying the initialization order. This improves the compatibility of kernel deployment in industrial control system kernel boot management. In addition, by using a kernel boot position-independent program and a deterministic kernel mapping range, the mutual coupling problem of memory mapping between the kernel boot process and the bootloader is solved, ensuring the stability and security of the industrial operating system kernel boot process.
[0100] refer to Figure 2 The diagram shown is a schematic flowchart of a kernel startup processing method disclosed in an embodiment of this application. This kernel startup processing method is applicable to the above embodiment. Figure 1 The publicly disclosed kernel boot framework, whose boot process mainly includes the following steps:
[0101] S201: Obtain the page table entries required for kernel startup by using the kernel boot location-independent program and the kernel deterministic mapping range; the kernel deterministic range is determined by the start and end addresses of the kernel linker file.
[0102] Specifically, deterministic mapping of kernel temporary page tables is performed through kernel deterministic mapping ranges.
[0103] Taking a 32-bit system as an example, after the kernel starts, it uses the formal kernel page table to map 4G space. The kernel temporary page table is used from the time the kernel starts until it is initialized. During this time period, it only maps the necessary space for the kernel to run and initialize (only maps the size of the kernel, such as 2MB). In terms of mapping efficiency, this page table only helps the kernel to speed up the startup and reduce the time consumption caused by the traditional full mapping. It can be discarded after startup, so it is a temporary page table.
[0104] The specific process of obtaining the page table entries required for kernel startup by using the kernel boot location-independent program and the kernel deterministic mapping range is shown in A1-A11.
[0105] A1: Obtain the kernel boot parameter independent configuration file.
[0106] A2: Parse the kernel boot parameter independent configuration file into the kernel boot parameter area.
[0107] The kernel boot parameter area is where the bootloader parses the configuration file and stores the data according to the TAG items for subsequent indexing and matching.
[0108] A3: Pass parameters between the bootloader and the kernel startup parameter area; the parameters are used to concatenate the data of the bootloader and the kernel startup parameter area.
[0109] A4: Obtain the physical memory address for kernel startup based on the passed parameters.
[0110] A5: Obtain the kernel boot virtual address from the pre-obtained kernel linker file.
[0111] A6: Calculate the difference between the physical memory address and the kernel boot virtual address to obtain the offset between the kernel boot virtual address and the physical memory address.
[0112] A7: Reads the start and end addresses of the kernel linker file.
[0113] A8: Corrects the start and end addresses of the kernel linker file using offsets.
[0114] A9: Calculate the kernel image size based on the corrected start address and corrected end address.
[0115] A10: The kernel image size is determined according to a preset value selection method to obtain the kernel deterministic mapping range.
[0116] The preset value selection method includes rounding the kernel image size up by 1MB, rounding the kernel image size up by 2MB, etc. This application does not specifically limit the preset value selection method, but the preferred preset value selection method is rounding the kernel image size up by 1MB.
[0117] Unused space is not mapped, which can speed up kernel startup time, while used space is mapped deterministically. For example, traditional first-level mapping of 4GB space (4096MB requires mapping 4096 entries) is less efficient if the kernel size is 10MB. In this case, deterministic mapping only requires mapping 10 entries, which significantly improves mapping efficiency and can speed up kernel startup.
[0118] A11: Obtain the page table entries required for kernel startup by using the kernel boot location-independent program and the kernel deterministic mapping range.
[0119] S202: Parse the page table entries using a unified parsing framework to obtain the parsing results.
[0120] Specifically, the process of parsing page table entries using a unified parsing framework to obtain the parsing results is shown in B1-B5.
[0121] B1: When the kernel program starts, the unified resolution framework is triggered to parse the kernel startup parameters of the page table entries and obtain the configuration file.
[0122] It should be noted that independent configuration of kernel boot parameter files is supported. When kernel boot parameters are modified, the bootloader does not need to be modified synchronously. Users can extend kernel boot parameters as needed. During parameter parsing, the boot parameter compilation area and the kernel boot parameter area can be matched through TAG items. If the matching verification passes, the parameter passing will proceed. This unified parsing framework effectively avoids the problems of poor extensibility of kernel boot parameters and excessive redundancy and complexity in development and maintenance. The kernel boot parameter parsing and matching process is as follows:
[0123] 1) Write the kernel boot parameters into the configuration file you wrote, and package the configuration file together with the operating system kernel into an image file and download it to the storage medium;
[0124] 2) After the system is powered on, the bootloader parses the configuration file from the operating system image package and stores the kernel boot parameters and environment variables extracted from the configuration file into the kernel configuration data area.
[0125] 3) During the kernel creation phase, the boot parameters that need to be configured are compiled into the specified boot parameter compilation area;
[0126] For example, when the kernel starts, the root file system needs to obtain two parameters: the physical base address and the root file system type, to complete the initialization process of the root file system startup. Since different users or different users have different file types and physical base addresses, the kernel will put its own TAG representation and the two parameters of physical base address and root file system type into its own startup parameter compilation area. When the kernel starts, it indexes the TAG for matching, and if the match is successful, it assigns values to these two parameters.
[0127] 4) Before the kernel starts, the data in the indexed boot parameter compilation area and the kernel configuration data area are matched (based on the matching principle of the same TAG identifier);
[0128] 5) If the TAG item matches, the address of the corresponding entry in the kernel parameter area is passed to the boot parameter item to realize the parsing and acquisition of kernel boot parameters.
[0129] B2: According to the TAG item, store the configuration file into the kernel boot parameter area.
[0130] B3: Index the kernel boot parameter compilation area, and match the kernel boot parameter area with the kernel boot parameter compilation area.
[0131] The kernel boot parameter compilation area is where the parameters that the kernel needs to configure are compiled into a specified compilation area.
[0132] B4: If the identifier of the kernel boot parameter area matches the identifier of the kernel boot parameter compilation area, the match is successful, and the parsing result of the successful match is obtained.
[0133] The data in the compilation area consists of TAG identifiers (i.e., TAG items) and data. Different kernel components use different TAGs. When the kernel starts, it indexes and parses the compilation area to obtain startup parameters. Different kernel components obtain their own data by matching the TAGs in the compilation area to complete the acquisition of startup parameters or environment variables.
[0134] B5: If the identifier of the kernel boot parameter area is inconsistent with the identifier of the kernel boot parameter compilation area, the matching is determined to be unsuccessful, and the parsing result of the unsuccessful matching is obtained.
[0135] S203: If the parsing result matches the preset matching conditions, obtain the kernel startup parameters and environment variables.
[0136] In S203, if the parsing result is a successful match, it is determined that the parsing result meets the preset matching conditions, and the kernel startup parameters and environment variables are obtained.
[0137] S204: When a kernel boot request is received, the kernel boot parameters and environment variables are initialized through the initialization order management mechanism to obtain the kernel initialization result corresponding to the kernel boot request; the initialization order management mechanism is used to ensure the order of initialization of each module during the kernel boot process.
[0138] Specifically, when a kernel boot request is received, the kernel boot parameters and environment variables are initialized through the initialization order management mechanism to obtain the kernel initialization result corresponding to the kernel boot request, as shown in C1-C4.
[0139] C1: When a kernel startup request is received, the kernel startup parameters and environment variables are initialized through the initialization order management mechanism to obtain the gradient compilation area after kernel initialization.
[0140] C2: Determines whether the gradient compilation region after kernel initialization is not empty; the gradient compilation region is created by the kernel image; the gradient compilation region stores the initialization programs of each module during kernel startup and the corresponding module initialization tasks executed by multiple gradient compilation regions indexed according to a preset order.
[0141] C3: If the gradient compilation region after kernel initialization is not empty, the first kernel gradient sequential initialization result is obtained; the first kernel gradient sequential initialization result indicates that the gradient compilation region corresponding to the kernel startup requirements is not empty.
[0142] C4: If the gradient compilation region after kernel initialization is not empty, the second kernel gradient sequential initialization result is obtained; the second kernel gradient sequential initialization result indicates that the gradient compilation region corresponding to the kernel startup requirements is not empty.
[0143] It should be noted that, since traditional kernel initialization operations directly call the initialization interface function, the quality of the functions written by different developers cannot be guaranteed, or the incorrect calling order can lead to kernel startup failure, which is quite troublesome for subsequent upgrades and maintenance. Therefore, this solution divides a read-only data area in the kernel space, divides this read-only data area into gradient levels and sets gradient requirements. According to the requirements or dependencies of the gradient compilation area, the initialization function can be placed in the corresponding gradient range. At startup, the gradient compilation area is indexed, and the kernel initialization process is executed according to the gradient order.
[0144] Traditional environment variable tables include default environment variable tables and environment variables configured by the user at startup, resulting in inefficient startup processes and the inability to support custom extensions. Therefore, this solution compiles environment variables into the startup parameter compilation area. Based on user needs, if the compilation area contains the required environment variable or startup parameter, an indexing and matching operation is performed. If a match is successful, the parsed environment variable or startup parameter is used. The matching principle uses TAG key-value pairs. Startup parameters and environment variables support custom extensions, improving usability and ease of use.
[0145] If the kernel initialization result indicates that the gradient compilation area corresponding to the kernel startup requirement is not empty, return to the step of executing the kernel startup initialization operation on the kernel startup parameters and the environment variables through the initialization order management mechanism when the kernel startup requirement is received, and obtain the kernel initialization result corresponding to the kernel startup requirement.
[0146] S205: If the kernel initialization result meets the preset initialization conditions, complete the kernel startup.
[0147] In S205, if the kernel initialization result indicates that the gradient compilation area corresponding to the kernel startup requirement is not empty, it is determined that the kernel initialization result meets the preset initialization conditions, and the kernel startup is completed.
[0148] Key points and areas to be protected in this plan:
[0149] 1. By supporting independent configuration of kernel boot parameter files, modifications to kernel boot parameters do not require synchronous modifications to the bootloader, achieving complete decoupling between the bootloader and kernel boot parameters, thus avoiding security and stability issues caused by coupling.
[0150] 2. The kernel boot parameter unified parsing framework design allows kernel boot parameters to be arbitrarily extended as needed, avoiding the problems of poor scalability of kernel boot parameters and excessive redundancy and complexity in development and maintenance.
[0151] 3. The kernel startup initialization order is uniformly managed, and the initialization order is established as needed, avoiding the poor compatibility and usability issues caused by kernel version iteration.
[0152] 4. It supports a location-independent design for the kernel bootloader and hardware MMU space management. Combined with a deterministic local mapping mechanism for temporary page tables, it solves the problems of poor security and low kernel boot efficiency caused by the mutual coupling of memory mapping between the kernel and the bootloader.
[0153] Compared with existing technologies, the advantages of this solution are:
[0154] 1. This invention designs an easy-to-use industrial operating system kernel boot framework method. By independently configuring the kernel boot parameters, it achieves complete decoupling between the bootloader and the kernel boot parameters, simplifies the complexity of kernel development and configuration, improves the quality of kernel porting, and ensures the security and uniformity of the industrial operating system.
[0155] 2. This invention realizes a unified framework design for kernel boot parameter parsing, which allows kernel boot parameters to be arbitrarily extended as needed, solving problems such as poor scalability of kernel boot parameters and complex development and maintenance under multi-system requirements;
[0156] 3. This invention solves the problems of poor version compatibility and poor user usability caused by modifying the initialization order by using a kernel startup initialization order management design;
[0157] 4. This invention solves the problem of mutual coupling between kernel startup and bootloader memory mapping by designing a kernel startup program location-independent and kernel initial page table local deterministic mapping. While accelerating kernel startup, it effectively ensures the stability and security of industrial operating system kernel startup.
[0158] This solution employs a unified framework design for kernel boot parameter parsing, enabling arbitrary expansion of kernel boot parameters as needed. This addresses issues such as poor scalability and complex development and maintenance of kernel boot parameters under multi-standard requirements. Independent configuration of kernel boot parameters completely decouples the bootloader and kernel boot parameters, simplifying kernel development and configuration complexity, improving kernel porting quality, and ensuring the security and uniformity of industrial operating systems. Kernel boot initialization order management avoids version compatibility and user usability issues caused by modifying the initialization order. Furthermore, the kernel bootloader position independence and locally deterministic mapping of the kernel initial page table resolve the coupling issue between kernel boot and bootloader memory mapping, ensuring the stability and security of industrial operating system kernel booting.
[0159] In this embodiment, a unified kernel boot parameter parsing framework is designed, allowing kernel boot parameters to be arbitrarily expanded as needed. This improves the scalability and flexibility of kernel boot parameters under multi-standard requirements, thereby enhancing the flexibility and scalability of kernel deployment in kernel boot management. Furthermore, through a kernel boot initialization order management mechanism, an initialization order is established as needed, avoiding the poor compatibility and usability issues caused by kernel version iterations, and preventing version compatibility and user usability problems caused by modifying the initialization order. This improves the compatibility of kernel deployment in industrial control system kernel boot management. In addition, by using a kernel boot position-independent program and a deterministic kernel mapping range, the mutual coupling problem of memory mapping between the kernel boot process and the bootloader is solved, ensuring the stability and security of the industrial operating system kernel boot process.
[0160] Based on the above embodiments Figure 1 This application discloses a kernel boot processing method and, in its embodiments, also discloses a kernel boot processing system, such as... Figure 3 As shown, the processing system booted by this kernel includes:
[0161] The first acquisition unit 301 is used to obtain the page table entries required for kernel startup by using the kernel startup location-independent program and the kernel deterministic mapping range; the kernel deterministic range is determined by the start address and end address of the kernel linker file;
[0162] Parsing unit 302 is used to parse page table entries using a unified parsing framework to obtain parsing results;
[0163] The second acquisition unit 303 is used to obtain kernel startup parameters and environment variables if the parsing result meets the preset matching conditions;
[0164] Operation unit 304 is used to perform kernel startup initialization operations on kernel startup parameters and environment variables through an initialization order management mechanism when a kernel startup request is received, so as to obtain the kernel initialization result corresponding to the kernel startup request; the initialization order management mechanism is used to ensure the initialization order of each module during the kernel startup process;
[0165] The completion unit 305 is used to complete the kernel startup if the kernel initialization result meets the preset initialization conditions.
[0166] Furthermore, the first acquisition unit 301 includes:
[0167] The first acquisition module is used to acquire the independent configuration file for kernel boot parameters;
[0168] The first parsing module is used to parse the independent configuration file of kernel boot parameters into the kernel boot parameter area;
[0169] The parameter passing module is used to pass parameters between the bootloader and the kernel boot parameter area; the parameter passing module is used to concatenate the data between the bootloader and the kernel boot parameter area.
[0170] The second acquisition module is used to obtain the physical memory address of the kernel startup based on the passed parameters;
[0171] The third acquisition module is used to obtain the kernel boot virtual address from the pre-acquired kernel linker file;
[0172] The difference module is used to calculate the difference between the physical memory address and the kernel startup virtual address to obtain the offset between the kernel startup virtual address and the physical memory address.
[0173] The read module is used to read the start and end addresses of kernel linker files;
[0174] The correction module is used to correct the start and end addresses of the kernel linker file using offsets;
[0175] The calculation module is used to calculate the kernel image size based on the corrected start address and the corrected end address;
[0176] The value retrieval module is used to retrieve the kernel image size according to a preset value retrieval method to obtain the kernel deterministic mapping range;
[0177] The fourth acquisition module is used to obtain the page table entries required for kernel startup by using the kernel startup location-independent program and the kernel deterministic mapping range.
[0178] Furthermore, the parsing unit 302 includes:
[0179] The second parsing module is used to trigger the unified parsing framework to parse the page table entries for kernel startup parameters when the kernel program starts, so as to obtain the configuration file.
[0180] The storage module is used to store the configuration file into the kernel boot parameter area according to the identifier.
[0181] The identifier matching module is used to index the kernel boot parameter compilation area and match the identifiers of the kernel boot parameter area with those of the kernel boot parameter compilation area.
[0182] The first determining module is used to determine a successful match if the identifier of the kernel boot parameter area matches the identifier of the kernel boot parameter compilation area, and to obtain a successful matching parsing result.
[0183] The second determining module is used to determine the matching failure if the identifier of the kernel boot parameter area is inconsistent with the identifier of the kernel boot parameter compilation area, and to obtain the parsing result of the matching failure.
[0184] Furthermore, the second acquisition unit 303 is specifically used to determine that the parsing result meets the preset matching conditions if the parsing result is a successfully matched parsing result, and to obtain the kernel startup parameters and environment variables.
[0185] Operation unit 304 includes:
[0186] The operation module is used to perform kernel startup initialization operations on kernel startup parameters and environment variables through the initialization order management mechanism when a kernel startup request is received, so as to obtain the gradient compilation area after kernel initialization.
[0187] The judgment module is used to determine whether the gradient compilation area is not empty after kernel initialization; the gradient compilation area is created by the kernel image; the gradient compilation area stores the initialization programs of each module during kernel startup and the corresponding module initialization tasks executed by multiple gradient compilation areas indexed according to a preset order.
[0188] The fifth acquisition module is used to obtain the first kernel gradient order initialization result if the gradient compilation region after kernel initialization is not empty; the first kernel gradient order initialization result indicates that the gradient compilation region corresponding to the kernel startup requirements is not empty;
[0189] The sixth acquisition module is used to obtain the second kernel gradient order initialization result if the gradient compilation region after kernel initialization is not non-empty; the second kernel gradient order initialization result indicates that the gradient compilation region corresponding to the kernel startup requirements is not non-empty.
[0190] Furthermore, the completion unit 305 is specifically used to determine that the kernel initialization result meets the preset initialization conditions and complete the kernel startup if the kernel initialization result indicates that the gradient compilation area corresponding to the kernel startup requirement is not empty.
[0191] Furthermore, the kernel boot process also includes:
[0192] The execution unit is used to return to the step of performing kernel startup initialization operations on kernel startup parameters and environment variables through the initialization order management mechanism when the kernel startup requirement is received, if the kernel initialization result indicates that the gradient compilation area corresponding to the kernel startup requirement is not empty.
[0193] In this embodiment, a unified kernel boot parameter parsing framework is designed, allowing kernel boot parameters to be arbitrarily expanded as needed. This improves the scalability and flexibility of kernel boot parameters under multi-standard requirements, thereby enhancing the flexibility and scalability of kernel deployment in kernel boot management. Furthermore, through a kernel boot initialization order management mechanism, an initialization order is established as needed, avoiding the poor compatibility and usability issues caused by kernel version iterations, and preventing version compatibility and user usability problems caused by modifying the initialization order. This improves the compatibility of kernel deployment in industrial control system kernel boot management. In addition, by using a kernel boot position-independent program and a deterministic kernel mapping range, the mutual coupling problem of memory mapping between the kernel boot process and the bootloader is solved, ensuring the stability and security of the industrial operating system kernel boot process.
[0194] This application embodiment also provides a storage medium, the storage medium including stored instructions, wherein, when the instructions are executed, the device where the storage medium is located is controlled to execute the kernel startup process method described above.
[0195] This application also provides an electronic device, the structural schematic diagram of which is shown below. Figure 4 As shown, it specifically includes a memory 401 and one or more instructions 402, wherein one or more instructions 402 are stored in the memory 401 and configured to be executed by one or more processors 403 to perform the above-mentioned kernel startup process.
[0196] For the foregoing method embodiments, in order to simplify the description, they are all described as a series of actions. However, those skilled in the art should understand that this application is not limited to the described order of actions, because according to this application, some steps can be performed in other orders or simultaneously. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily essential to this application.
[0197] It should be noted that the various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For system-type embodiments, since they are basically similar to method embodiments, the description is relatively simple; relevant parts can be referred to the descriptions in the method embodiments.
[0198] The steps in the methods of the various embodiments of this application can be adjusted, combined, or deleted according to actual needs.
[0199] Finally, it should be noted that in this paper, relational terms such as first and second are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations.
[0200] The above description of the disclosed embodiments enables those skilled in the art to make or use this application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the scope of this application. Therefore, this application is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
[0201] The above description is only a preferred embodiment of this application. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of this application, and these improvements and modifications should also be considered within the scope of protection of this application.
Claims
1. A kernel boot process, characterized in that, The method includes: By using the kernel to boot a position-independent program and the kernel deterministic mapping range, the page table entries required for kernel boot are obtained; the kernel deterministic range is determined by the start and end addresses of the kernel linker file. The page table entries are parsed using a unified parsing framework to obtain the parsing results; If the parsing result matches the preset matching conditions, the kernel startup parameters and environment variables are obtained; When a kernel startup request is received, the kernel startup parameters and environment variables are initialized using an initialization order management mechanism to obtain the kernel initialization result corresponding to the kernel startup request. The initialization order management mechanism is used to ensure the initialization order of each module during the kernel startup process. If the kernel initialization result meets the preset initialization conditions, the kernel startup is complete; The process of obtaining the page table entries required for kernel startup by using the kernel boot location-independent program and the kernel deterministic mapping range includes: Obtain a separate configuration file for kernel boot parameters; The independent configuration file for kernel boot parameters is parsed into the kernel boot parameter area; The bootloader and the kernel startup parameter area are passed parameters; the passed parameters are used to concatenate the data of the bootloader and the kernel startup parameter area. The physical memory address for kernel startup is obtained based on the passed parameters; Obtain the kernel boot virtual address from the pre-acquired kernel linker file; The offset between the physical memory address and the kernel startup virtual address is obtained by taking the difference between the physical memory address and the kernel startup virtual address. Read the start and end addresses of the kernel linker file; The start and end addresses of the kernel linker file are corrected using the offset. Calculate the kernel image size based on the corrected start address and corrected end address; The kernel image size is determined according to a preset value selection method to obtain the kernel deterministic mapping range; By using the kernel boot location-independent program and the kernel deterministic mapping range, the page table entries required for kernel boot are obtained.
2. The method according to claim 1, characterized in that, The process of parsing the page table entries using a unified parsing framework to obtain the parsing results includes: When the kernel program starts, the unified parsing framework is triggered to parse the page table entries for kernel startup parameters to obtain the configuration file; According to the identifier, the configuration file is stored in the kernel boot parameter area; Index the kernel startup parameter compilation area and match the identifiers of the kernel startup parameter area with those of the kernel startup parameter compilation area; If the identifier in the kernel boot parameter area matches the identifier in the kernel boot parameter compilation area, the match is successful, and the parsing result of the successful match is obtained. If the identifier of the kernel boot parameter area does not match the identifier of the kernel boot parameter compilation area, the matching is determined to be unsuccessful, and the parsing result of the unsuccessful matching is obtained.
3. The method according to claim 2, characterized in that, If the parsing result matches a preset matching condition, the kernel startup parameters and environment variables are obtained, including: If the parsing result is a successful match, it is determined that the parsing result meets the preset matching conditions, and the kernel startup parameters and environment variables are obtained.
4. The method according to claim 1, characterized in that, When a kernel boot request is received, the kernel boot parameters and environment variables are initialized using an initialization order management mechanism to obtain the kernel initialization result corresponding to the kernel boot request, including: When a kernel startup request is received, the kernel startup parameters and environment variables are initialized using the initialization order management mechanism to obtain the kernel-initialized gradient compilation area. Determine whether the gradient compilation region after kernel initialization is not empty; the gradient compilation region is obtained by creating a kernel image; the gradient compilation region stores the initialization programs of each module during kernel startup and the corresponding module initialization tasks executed by multiple gradient compilation regions indexed according to a preset order; If the gradient compilation region after kernel initialization is not empty, the first kernel gradient sequential initialization result is obtained; the first kernel gradient sequential initialization result indicates that the gradient compilation region corresponding to the kernel startup requirements is not empty. If the gradient compilation region after kernel initialization is not empty, the second kernel gradient sequential initialization result is obtained; the second kernel gradient sequential initialization result indicates that the gradient compilation region corresponding to the kernel startup requirements is not empty.
5. The method according to claim 4, characterized in that, If the kernel initialization result meets the preset initialization conditions, the kernel startup is completed, including: If the kernel initialization result indicates that the gradient compilation region corresponding to the kernel startup requirement is not empty, it is determined that the kernel initialization result meets the preset initialization conditions, and the kernel startup is completed.
6. The method according to claim 1, characterized in that, Also includes: If the kernel initialization result indicates that the gradient compilation area corresponding to the kernel startup requirement is not empty, return to the step of performing kernel startup initialization operations on the kernel startup parameters and environment variables through the initialization order management mechanism when the kernel startup requirement is received, and obtain the kernel initialization result corresponding to the kernel startup requirement.
7. A kernel boot processing system, characterized in that, The system includes: The first acquisition unit is used to obtain the page table entries required for kernel startup by using the kernel startup location-independent program and the kernel deterministic mapping range; the kernel deterministic range is determined by the start and end addresses of the kernel linker file; The parsing unit is used to parse the page table entries using a unified parsing framework to obtain the parsing results; The second acquisition unit is used to obtain kernel startup parameters and environment variables if the parsing result meets the preset matching conditions; An operation unit is used to perform kernel startup initialization operations on the kernel startup parameters and environment variables through an initialization order management mechanism when a kernel startup request is received, so as to obtain the kernel initialization result corresponding to the kernel startup request; the initialization order management mechanism is used to ensure the initialization order of each module during the kernel startup process; The completion unit is used to complete the kernel startup if the kernel initialization result meets the preset initialization conditions. The first acquisition unit includes: The first acquisition module is used to acquire the independent configuration file for kernel boot parameters; The first parsing module is used to parse the independent configuration file of kernel boot parameters into the kernel boot parameter area; The parameter passing module is used to pass parameters between the bootloader and the kernel startup parameter area; the parameter passing module is used to concatenate the data of the bootloader and the kernel startup parameter area. The second acquisition module is used to obtain the physical memory address of the kernel startup based on the passed parameters; The third acquisition module is used to obtain the kernel boot virtual address from the pre-acquired kernel linker file; The difference module is used to calculate the difference between the physical memory address and the kernel startup virtual address to obtain the offset between the kernel startup virtual address and the physical memory address. The reading module is used to read the start and end addresses of the kernel linker file. The correction module is used to correct the start and end addresses of the kernel linker file using the offset. The calculation module is used to calculate the kernel image size based on the corrected start address and the corrected end address; The value retrieval module is used to retrieve the kernel image size according to a preset value retrieval method to obtain the kernel deterministic mapping range; The fourth acquisition module is used to obtain the page table entries required for kernel startup by using the kernel startup location-independent program and the kernel deterministic mapping range.
8. A storage medium, characterized in that, The storage medium includes stored instructions, wherein, when the instructions are executed, the device where the storage medium is located is controlled to perform the kernel boot process as described in any one of claims 1 to 6.
9. An electronic device, characterized in that, It includes memory, and one or more instructions, wherein one or more instructions are stored in memory and configured to be executed by one or more processors as described in any one of claims 1 to 6.