System starting method and device
By storing target information during hardware initialization and restoring hardware configuration using a generic bootloader, the problem of early firmware environment being overwritten is solved, ensuring that the operating system can boot and start smoothly.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-30
- Publication Date
- 2026-03-31
AI Technical Summary
During hardware initialization, the operating environment established by early firmware (such as UEFI) can be easily overwritten or changed, leading to operating system boot and startup failures.
The initial boot firmware stores the target information into the designated memory, performs hardware initialization operations while keeping the memory unchanged, and uses a general bootloader to restore the hardware configuration, ensuring that the operating system can boot and start smoothly.
This technology protects the information in a specified memory location during hardware initialization, thereby ensuring that the operating system can boot and start smoothly and avoiding boot failures caused by environmental changes.
Smart Images

Figure CN121764559A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a system startup method and apparatus. Background Technology
[0002] During the operating system startup process, the system typically loads a system kernel to perform hardware initialization. However, during hardware initialization, the runtime environment established by earlier firmware (such as Unified Extensible Firmware Interface UEFI) is usually overwritten or changed. This can damage the execution environment prepared by the earlier firmware for the subsequent operating system boot, thereby affecting the booting and startup of the operating system. Summary of the Invention
[0003] In view of the above, this application provides a system startup method and an electronic device, the specific solutions of which are as follows:
[0004] A system startup method, comprising:
[0005] The target information is stored in a designated memory of the electronic device by the initial boot firmware, and the target information is determined by the initial boot firmware and includes information for implementing the boot of the first operating system;
[0006] The hardware initialization operation is performed on the electronic device and the startup information of the operating system is obtained. The hardware initialization operation preserves the specified memory from being modified.
[0007] The hardware of the electronic device after the hardware initialization operation is performed is configured using a general bootloader according to the target information stored in the specified memory.
[0008] On an electronic device configured with the target information, a first operating system of the electronic device is guided and launched based on the startup information.
[0009] Furthermore, the hardware initialization operation performed on the electronic device includes:
[0010] The target kernel performs hardware initialization operations on the hardware of the electronic device. The target kernel is capable of performing hardware initialization operations and booting a second operating system for the electronic device, which is different from the first operating system.
[0011] Furthermore, the step of performing hardware initialization operations on the electronic device's hardware through the target kernel includes:
[0012] The first location in the specified memory where the target information is stored is determined by the target kernel;
[0013] The first location where the target information is stored is marked;
[0014] The target kernel performs hardware initialization operations on the hardware of the electronic device based on a second location in the specified memory, where the second location is different from the first location.
[0015] Furthermore, the hardware initialization operation performed on the electronic device includes:
[0016] The initial boot firmware performs hardware initialization operations on the electronic device's hardware.
[0017] Furthermore, the first operating system that guides and starts the electronic device based on the startup information includes:
[0018] The first operating system of the electronic device is booted and started using the general bootloader based on the boot information.
[0019] Furthermore, obtaining the operating system boot information includes:
[0020] Outputs operating system selection information for multiple operating systems that the electronic device can run;
[0021] Receive a selection instruction in response to the output operating system selection information, and determine the boot information of the operating system based on the selection instruction.
[0022] Furthermore, it also includes:
[0023] The boot information of the operating system is stored in a target area, which is the area determined by the initial boot firmware based on the specified memory and used to store information determined by the target kernel.
[0024] Furthermore, configuring the hardware of the electronic device after performing the hardware initialization operation according to the target information stored in the specified memory includes:
[0025] Read the target information stored in the specified memory;
[0026] The target information is saved to the register corresponding to the target information in the hardware of the electronic device after the hardware initialization operation is performed.
[0027] Furthermore, it also includes:
[0028] The initial boot firmware determines key information from multiple pieces of information used to implement the booting of the first operating system, and identifies the determined key information as target information. The target information includes at least: system table, global descriptor table, global interrupt descriptor table, and page table.
[0029] A system startup device, comprising:
[0030] A storage unit is used to store target information into a designated memory of an electronic device via initial boot firmware, the target information being determined by the initial boot firmware and including information for implementing the boot of a first operating system;
[0031] An initialization unit is used to perform hardware initialization operations on the hardware of an electronic device and obtain the startup information of the operating system. The hardware initialization operation preserves the specified memory from being modified.
[0032] A configuration unit is used to configure the hardware of an electronic device after performing the hardware initialization operation using a general bootloader according to the target information stored in the specified memory;
[0033] A startup unit is configured to boot and start a first operating system of an electronic device configured with the target information based on the startup information. Attached Figure Description
[0034] To more clearly illustrate the technical solutions in the embodiments or related technologies of this application, the accompanying drawings used in the description of the embodiments or related technologies will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0035] Figure 1 This is a flowchart of a system startup method disclosed in an embodiment of this application;
[0036] Figure 2 This is a flowchart of a system startup method disclosed in an embodiment of this application;
[0037] Figure 3 This is a schematic diagram illustrating the stage division of a system startup process as disclosed in an embodiment of this application;
[0038] Figure 4 This is a flowchart of a system startup method disclosed in an embodiment of this application;
[0039] Figure 5 This is a flowchart of a system startup method disclosed in an embodiment of this application;
[0040] Figure 6 This is a schematic diagram of the structure of a system startup device disclosed in an embodiment of this application. Detailed Implementation
[0041] The embodiments of this application are described below with reference to the accompanying drawings. The terminology used in the implementation section of this application is for explaining specific embodiments only and is not intended to limit the scope of this application.
[0042] The embodiments of this application will now be described with reference to the accompanying drawings. Those skilled in the art will recognize that, with technological advancements and the emergence of new scenarios, the technical solutions provided in the embodiments of this application are equally applicable to similar technical problems.
[0043] The terms "first," "second," etc., used in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such terms are interchangeable where appropriate; this is merely a way of distinguishing objects with the same attributes in the embodiments of this application. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion, so that a process, method, system, product, or apparatus that comprises a series of elements is not necessarily limited to those elements, but may include other elements not explicitly listed or inherent to those processes, methods, products, or apparatuses.
[0044] This application discloses a system startup method, the flowchart of which is as follows: Figure 1 As shown, it includes:
[0045] Step S11: Store the target information into the designated memory of the electronic device through the initial boot firmware. The target information is determined by the initial boot firmware and includes information used to implement the boot of the first operating system.
[0046] Step S12: Perform hardware initialization on the electronic device and obtain the operating system's startup information. The hardware initialization operation retains the specified memory and does not modify it.
[0047] Step S13: Configure the hardware of the electronic device after performing hardware initialization operation using the general bootloader according to the target information stored in the specified memory;
[0048] Step S14: On the electronic device configured with target information, the first operating system of the electronic device is booted and started based on the boot information.
[0049] During the operating system startup process, the system typically loads a system kernel to perform hardware initialization. However, during hardware initialization, the runtime environment established by earlier firmware (such as Unified Extensible Firmware Interface UEFI) is usually overwritten or changed. This can damage the execution environment prepared by the earlier firmware for the subsequent operating system boot, thereby affecting the booting and startup of the operating system.
[0050] Based on this, in this embodiment, the target information for implementing the first operating system boot is first stored in a designated memory of the electronic device. Then, a hardware initialization operation is performed on the hardware of the electronic device to obtain the boot information of the operating system. The hardware initialization operation retains the designated memory without modification. Afterward, the hardware after hardware initialization is configured according to the target information stored in the designated memory to restore the hardware configuration. This allows the hardware of the electronic device to be configured according to the target information, ensuring the booting of the first operating information. As a result, the electronic device can boot and start the first operating system based on the boot information, avoiding the problem of the first operating system failing to boot due to changes in the execution environment after the hardware initialization operation.
[0051] The system startup method disclosed in this embodiment is applied to electronic devices for booting and starting the operating system in the electronic device.
[0052] When an electronic device receives a system startup command, the command can be either a power-on operation performed by the user, requiring the electronic device to boot and start the operating system, or an operating system switching command performed by the user. This means the electronic device can run different operating systems. If the device is currently in a second operating state, upon receiving the operating system switching command, it can switch the operating system from the second to the first operating system. This process requires booting and starting the first operating system.
[0053] After receiving the system boot command, the electronic device can first store the target information into the designated memory of the electronic device through the initial boot firmware. The target information is determined by the initial boot firmware and includes information for implementing the boot of the first operating system.
[0054] In other words, the initial boot firmware must first determine the target information, and then store the target information in the designated memory of the electronic device. The process of the initial boot firmware determining the target information is the process of the initial boot firmware configuring the initial execution environment on the electronic device. This initial execution environment is the execution environment required by the electronic device to boot the first operating system.
[0055] Specifically, the initial boot firmware performs basic hardware initialization, that is, initializes the lowest-level hardware to ensure that the central processing unit (CPU), memory controller, and other components of the electronic device can function properly. This basic hardware initialization may include setting chipset registers and enabling memory, so as to provide a usable physical hardware foundation for the subsequent creation of the execution environment. Afterward, the initial boot firmware allocates space in memory and fills it with relevant data, including at least the data contained in the target information, and loads the relevant data to complete the creation of the execution environment. To ensure that the first operating system can complete the boot process within this execution environment, after the execution environment is created, at least the target information from the relevant data required to create the execution environment must be saved to designated memory so that the execution environment can be restored based on the saved target information if it is corrupted.
[0056] Next, hardware initialization is performed on the electronic device's hardware. This involves bringing all critical hardware components, including storage-related hardware, network-related hardware, and human-computer interaction-related hardware (such as storage controllers, network controllers, input / output devices, and graphics display devices), to a usable state, providing a stable and reliable hardware foundation for subsequent operating system operations.
[0057] After completing the hardware initialization of the electronic device, the boot information of the operating system can be obtained, so that when the operating system of the electronic device starts, the boot operation of the operating system can be executed based on the boot information.
[0058] During the hardware initialization process of an electronic device, the execution environment configured based on the target information changes. That is, during the hardware initialization process, initialization operations are performed on each piece of hardware in the electronic device. This process changes the hardware data obtained after the basic hardware initialization based on the target information. In order to ensure that the first operating system of the electronic device can be successfully booted and started, in this embodiment, during the hardware initialization process, it is necessary to ensure that the data in the specified memory is not modified. That is, the hardware initialization operation preserves the specified memory from being modified.
[0059] The specified memory stores the target information used to boot the first operating system. Even if the execution environment configured based on the target information changes, as long as the target information stored in the specified information remains unchanged, the execution environment can be restored to ensure that the first operating system of the electronic device can be successfully booted and started.
[0060] After the hardware initialization operation is completed, a general bootloader can be used to configure the hardware of the electronic device after the hardware initialization operation is performed according to the target information stored in the specified memory, so as to restore the execution environment.
[0061] Once the hardware initialization operation is completed, the electronic device's hardware has finished initialization. At this point, a general bootloader can be used to read the target information stored in the specified memory and configure the electronic device's hardware according to the read target information, so that the configured electronic device can restore the execution environment.
[0062] After restoring the execution environment, the first operating system of the electronic device can be booted and started based on the boot information of the operating system to ensure that the first operating system of the electronic device can successfully complete the boot and start-up process.
[0063] The system boot method disclosed in this embodiment stores target information in a designated memory of an electronic device through an initial boot firmware. The target information, determined by the initial boot firmware, includes information for booting a first operating system. Hardware initialization is performed on the electronic device's hardware to obtain the operating system's boot information. This hardware initialization operation retains the designated memory without modification. A general bootloader configures the hardware of the electronic device after hardware initialization according to the target information stored in the designated memory. On the electronic device configured with the target information, the first operating system of the electronic device is booted and started based on the boot information. This scheme first stores the target information in a designated memory of the electronic device through the initial boot firmware and ensures that the designated memory is retained and not modified during hardware initialization. This allows the general bootloader to configure the hardware of the initialized electronic device using the target information stored in the designated memory after hardware initialization, thereby ensuring that the first operating system of the electronic device can successfully boot and start.
[0064] This embodiment discloses a system startup method, the flowchart of which is as follows: Figure 2 As shown, it includes:
[0065] Step S21: Store the target information into the designated memory of the electronic device through the initial boot firmware. The target information is determined by the initial boot firmware and includes information used to implement the boot of the first operating system.
[0066] Step S22: Perform hardware initialization operation on the hardware of the electronic device through the target kernel. The target kernel can perform hardware initialization operation and boot the second operating system of the electronic device. The second operating system is different from the first operating system. The hardware initialization operation reserves the specified memory and does not modify it.
[0067] Step S23: Obtain the operating system's boot information;
[0068] Step S24: Configure the hardware of the electronic device after performing hardware initialization operation using the general bootloader according to the target information stored in the specified memory;
[0069] Step S25: On the electronic device configured with target information, the first operating system of the electronic device is booted and started based on the boot information.
[0070] To enable the booting and startup of the first operating system of an electronic device, target information is first stored in a designated memory of the electronic device using the initial boot firmware. This target information, determined by the initial boot firmware, includes information used to boot the first operating system. Next, hardware initialization is performed on the electronic device's hardware to obtain the operating system's startup information. This hardware initialization operation preserves the designated memory without modification. Then, a general bootloader is used to configure the initialized hardware according to the target information, enabling the electronic device to boot and start the first operating system based on the startup information. This ensures that the first operating system can successfully boot and start, avoiding the problem of the first operating system failing to boot and start due to damage to its execution environment caused by the hardware initialization operation.
[0071] Specifically, in this embodiment, the target kernel can perform hardware initialization operations on the hardware of the electronic device. The target kernel can not only perform hardware initialization operations, but also boot the second operating system of the electronic device. The second operating system is different from the first operating system.
[0072] In this embodiment, the electronic device can boot at least a first operating system or a second operating system, such as a Windows system as the first operating system and a Linux system as the second operating system. The electronic device can run both Windows and Linux systems.
[0073] If the electronic device needs to run a Linux system, the Linux Boot solution can be used directly to boot the operating system. Specifically, the initial boot firmware first performs basic hardware initialization, that is, initializes the lowest-level hardware to ensure that the central processing unit (CPU), memory controller, etc. of the electronic device can work properly, thus building an execution environment. Then, the target kernel (Linux kernel) performs hardware initialization operations, which can utilize the stable driver libraries built into the target kernel to initialize all hardware. After the target kernel completes the hardware initialization, it performs the boot and startup operations of the Linux system, thereby realizing the boot and startup of the Linux system on the electronic device.
[0074] However, the LinuxBoot solution can currently only boot Linux-like systems, such as CentOS, SUSE, and Kylin, and cannot boot Windows operating systems.
[0075] In order to enable the booting and startup of the first operating system (Windows system) via the LinuxBoot scheme, in this embodiment, after the initial boot firmware performs basic hardware initialization, the target information is determined and stored in the designated memory of the electronic device. Then, the target kernel performs hardware initialization operations. During the hardware initialization operation, the information stored in the designated memory is not changed, so that after the hardware initialization is completed, the configuration of part of the hardware can be restored based on the target information stored in the designated memory, so as to complete the booting and startup of the first operating system.
[0076] Because the target kernel (Linux kernel) possesses a unified and extremely large open-source driver ecosystem maintained by global developers, a significant portion of hardware can find stable drivers within it that have been validated in long-term production environments. Furthermore, the target kernel (Linux kernel) employs a unified device driver model; the drivers are developed according to standard interfaces, have a clear structure, and are easy to debug and maintain, ensuring the smooth completion of the hardware initialization process, reducing the probability of failure, and lowering development and maintenance costs. Therefore, in the method disclosed in this embodiment, the target kernel (Linux kernel) capable of booting the second operating system (Linux system) performs hardware initialization. After initialization, a general bootloader configures the hardware of the electronic device after the hardware initialization operation according to the target information stored in specified memory, ensuring the booting and startup of the first operating system (Windows system) on the electronic device. This achieves both the stability brought by hardware initialization performed by the target kernel and the ability to boot the Windows system.
[0077] The initial boot firmware can be specifically MINI-UEFI, which is a lightweight unified extensible firmware interface. It is a simplified implementation of UEFI, mainly for resource-constrained embedded devices or dedicated platforms (such as industrial control, IoT devices, specific development boards, etc.). It adapts to the needs of small storage space and low-performance processors by cutting off non-core functions.
[0078] The initial boot firmware MINI-UEFI creates the execution environment (UEFI environment) and saves the target information required for booting and starting the first operating system (Windows system) to the designated memory. Then, it enters the LinuxBoot stage, where the target kernel (Linux kernel) performs hardware initialization operations. During this process, it is necessary to ensure that the target information stored in the designated memory is not modified. After that, it enters the GrubX stage (generic bootloader). In the GrubX stage, in addition to performing standard Grub2 functions, it is also necessary to extract the target information stored in the designated memory and configure the hardware according to the target information to restore the execution environment. After the execution environment is restored, GrubX then performs the booting and starting of the first operating system (Windows system), that is, using the generic bootloader to boot and start the first operating system of the electronic device based on the boot information.
[0079] Grub2 (GRand Unified Bootloader version 2) is responsible for loading and starting the operating system kernel. Grub2 can locate, read and load the operating system kernel file (such as Linux's vmlinuz) and the initial memory disk (initrd / initramfs) from storage devices (such as hard drives, optical discs, and network storage devices) into memory. After loading the kernel into memory, Grub2 sets the boot parameters according to the format specified by the kernel, and then transfers control to the kernel's entry point so that the kernel can continue to complete the subsequent boot process.
[0080] In addition, Grub2 can also perform the following functions: booting multiple operating systems; providing graphical or text menus at startup to support user selection based on graphical or text menus; and having built-in drivers for various file systems (such as ext4, XFS, Btrfs, FAT, NTFS) to enable direct reading of the kernel and configuration files from these partitions without relying on the underlying firmware.
[0081] Therefore, in the system startup method disclosed in this embodiment, the system startup process is actually divided into four stages, such as... Figure 3 As shown, the four stages are: the first stage is the MINI-UEFI stage, the second stage is the LinuxBoot stage, the third stage is the GrubX stage, and the fourth stage is the operating system stage. These four stages enable the booting and starting of a Windows system using the LinuxBoot solution.
[0082] In addition, in the system startup method disclosed in this embodiment, the hardware initialization operation of the electronic device can be performed by the target kernel that can boot the second operating system, or the hardware initialization operation of the electronic device can be performed by the initial boot firmware. That is, there is no need to start the target kernel, but the hardware initialization operation is directly completed by the initial boot firmware. In this case, there is no longer any damage or recovery to the execution environment.
[0083] The system boot method disclosed in this embodiment stores target information into a designated memory of the electronic device through initial boot firmware. Then, a target kernel performs hardware initialization operations on the electronic device's hardware. This target kernel can perform hardware initialization operations and boot the electronic device's second operating system. Afterwards, a general bootloader configures the hardware of the electronic device after hardware initialization according to the target information stored in the designated memory, so as to boot and start the electronic device's first operating system based on the boot information. To achieve the booting and booting of the electronic device's first operating system, this solution requires configuring and saving the target information used to boot the first operating system, and then using the target kernel that boots the second operating system to perform hardware initialization operations. This ensures the success rate of hardware initialization and further guarantees the success rate of booting and starting the first operating system.
[0084] Furthermore, in the system startup method disclosed in this embodiment, the hardware initialization operation performed on the electronic device's hardware by the target kernel can be specifically as follows:
[0085] The target kernel determines the first location in the specified memory where the target information is stored, marks the first location where the target information is stored, and then performs hardware initialization operations on the electronic device based on the second location in the specified memory, which is different from the first location.
[0086] To ensure that the target information stored in the specified memory does not change during hardware initialization, the location of the target information in the specified memory must be determined before the target kernel performs hardware initialization operations. This location is designated as the first location and marked so that the marked location will not be initialized during subsequent hardware initialization operations.
[0087] If the first location in the specified memory is marked, then all other locations in the specified memory except the first location can be designated as the second location. During hardware initialization, hardware initialization is performed on the second location in the specified memory, while the marked first location is not modified, so as to preserve the target information stored at the first location in the specified memory.
[0088] Specifically, the EFI memory map can be parsed during the Linux Boot startup phase, and the data in the target type memory space in the parsed information can be soft reserved. The data in the target type memory space includes the target information stored in the specified memory.
[0089] EFI memory mapping is a core data structure provided by the initial boot firmware to the operating system or bootloader during system startup. It describes the complete layout, type, attributes, and usage status of physical memory space. It is the foundation for the operating system to manage hardware resources (especially memory) and directly affects the stability and security of system startup. EFI memory mapping explicitly records: which memory regions are available, which memory regions are occupied or reserved, and the purpose of different memory regions.
[0090] The data in the target type's memory space may include: EFI_LOADER_DATA (EFI loader data), EFI_LOADER_CODE (EFI loader code), EFI_BOOT_SERVICE_DATA (EFI boot service data), and EFI_BOOT_SERVICE_CODE (EFI boot service code).
[0091] Among them, EFI_LOADER_DATA (EFI loader data) is used to mark the temporary memory area allocated by the operating system loader during the boot phase. Its core function is to provide dynamic memory space for critical operations before the operating system kernel is loaded, ensuring the stability and resource isolation of the boot process.
[0092] EFI_LOADER_CODE (EFI loader code) is used to mark the executable code memory area of the operating system framework during the boot allocation phase. This type of memory is dedicated to storing the binary code of the European system kernel, drivers or UEFI applications. Its core function is to provide a secure and protected code execution environment for the boot process.
[0093] EFI_BOOT_SERVICE_DATA (EFI boot service data) is used to identify the data memory area allocated by the UEFI boot service driver for storing temporary, non-code runtime data;
[0094] The EFI_BOOT_SERVICE_CODE (EFI boot service code) is used to identify an executable code memory area allocated by the UEFI boot service driver. It is dedicated to storing instructions for internal firmware components, such as driver code.
[0095] Soft reserved refers to memory regions that are marked for special purposes by firmware, but which the operating system can choose to ignore or reuse.
[0096] The EFI memory mapping is parsed to identify data belonging to the target memory type. This data is then soft-preserved to prevent modification during the target kernel's hardware initialization process. The target information identified and saved by the initial boot firmware can be designated as EFI_LOADER_DATA (EFI loader data). Therefore, this target information is not modified during the target kernel's hardware initialization process. This ensures that after hardware initialization, the execution environment can be restored based on the preserved target information, thus successfully booting and starting the first operating system.
[0097] This embodiment discloses a system startup method, the flowchart of which is as follows: Figure 4 As shown, it includes:
[0098] Step S41: Store the target information into the designated memory of the electronic device through the initial boot firmware. The target information is determined by the initial boot firmware and includes information used to implement the boot of the first operating system.
[0099] Step S42: Perform hardware initialization on the electronic device. The hardware initialization operation preserves the specified memory and prevents it from being modified.
[0100] Step S43: Output operating system selection information for multiple operating systems that the electronic device can run;
[0101] Step S44: Receive a selection instruction in response to the output operating system selection information, and determine the operating system boot information based on the selection instruction;
[0102] Step S45: Configure the hardware of the electronic device after performing hardware initialization operation using the general bootloader according to the target information stored in the specified memory;
[0103] Step S46: On the electronic device configured with target information, the first operating system of the electronic device is booted and started based on the boot information.
[0104] To enable the booting and startup of the first operating system of an electronic device, target information is first stored in a designated memory of the electronic device using the initial boot firmware. This target information, determined by the initial boot firmware, includes information used to boot the first operating system. Next, hardware initialization is performed on the electronic device's hardware to obtain the operating system's startup information. This hardware initialization operation preserves the designated memory without modification. Then, a general bootloader is used to configure the initialized hardware according to the target information, enabling the electronic device to boot and start the first operating system based on the startup information. This ensures that the first operating system can successfully boot and start, avoiding the problem of the first operating system failing to boot and start due to damage to its execution environment caused by the hardware initialization operation.
[0105] Specifically, obtaining the operating system startup information can involve: outputting operating system selection information for multiple operating systems that the electronic device can run, receiving selection instructions in response to the output operating system selection information, and determining the operating system startup information based on the selection instructions.
[0106] If an electronic device can run multiple operating systems, the user needs to select the operating system that the electronic device should run during the startup process so that the operating system running on the electronic device can meet the user's needs.
[0107] Specifically, during the startup process of an electronic device's operating system, as long as the electronic device's display and the device used to perform the selection operation (such as a mouse or keyboard) are in normal working order, it can output operating system selection information for multiple operating systems that the electronic device can run. The electronic device can output the operating system selection information through a graphical interface or through a text menu.
[0108] When a user performs a selection operation based on the operating system selection information output by the electronic device, the electronic device can receive the selection instruction corresponding to the selection operation and respond to the selection instruction to determine the startup information of the operating system. The startup information of the operating system can identify the operating system selected by the user.
[0109] For example, electronic devices can run either Linux or Windows systems. During the startup process of an electronic device, its display screen can output a graphical interface, allowing the user to select whether to run Linux or Windows. If the user's selection operation indicates that Windows should be run, the electronic device receives the selection instruction corresponding to that operation, thus determining the operating system's startup information. When it is necessary to boot and start the operating system, the device determines that Windows should be booted and started based on the operating system's startup information.
[0110] Specifically, this can be done by performing hardware initialization on the electronic device, and after the hardware initialization is completed, the electronic device outputs operating system selection information, and after obtaining the operating system boot information, it saves it so that on the electronic device configured with the target information, the corresponding operating system can be booted and started based on the boot information.
[0111] Starting control logic (such as obtaining operating system startup information) requires the underlying hardware to be in an available state. Therefore, hardware initialization must be performed first. Only after hardware initialization is complete can control logic be executed; that is, there is a dependency between the two. For example, graphical or text menus require the display screen to display correctly. This requires ensuring that the display driver is loaded and initialized, and that the graphics frame buffer is established. In addition, it is also necessary to ensure that the display output port (such as HDMI, DP) is configured.
[0112] In addition, in the system startup method disclosed in this embodiment, after obtaining the startup information of the operating system, the startup information of the operating system needs to be stored so that when it is necessary to boot and start the operating system, the first operating system can be booted and started based on the stored startup information of the operating system.
[0113] Specifically, the system startup method disclosed in this embodiment may further include:
[0114] The operating system's boot information is stored in the target area, which is the area determined by the initial boot firmware based on specified memory and used to store information determined by the target kernel.
[0115] A target area can be predetermined. After obtaining the operating system's boot information, the boot information of the operating system is stored in the target area. After configuring the hardware of the initialized electronic device according to the target information, the boot information is read from the target area so as to boot and start the first operating system of the electronic device based on the boot information.
[0116] The target area used to store the operating system's boot information can be determined by the initial boot firmware, that is, after the initial boot firmware stores the target information in the designated memory of the electronic device, or the initial boot firmware also needs to determine a target area.
[0117] The target area can be specifically referred to as: a virtual memory disk (Ramdisk). Ramdisk is a technology that uses computer memory (RAM) to simulate a hard disk. It divides a portion of physical memory into virtual disk partitions through software. Its core principle is to significantly improve data access speed through the high-speed read and write performance of memory (far exceeding that of mechanical hard drives / solid-state drives) and to transfer temporary data through this virtual memory disk (Ramdisk).
[0118] This target area (the virtual RAM disk, Ramdisk) is determined during the MINI-UEFI phase and is used to transfer boot information between the Linux Boot and GrubX phases. Ramdisk is not used to store files or information; rather, it serves as a predefined memory area for transferring boot information between different boot phases. Specifically, during the Linux Boot phase, it obtains boot information and writes it to Ramdisk. During the GrubX phase, GrubX needs to read boot information from Ramdisk to determine which operating system to ultimately boot.
[0119] The MINI-UEFI phase is used to initialize memory management and define the early layout of physical memory. Memory allocation has not yet been performed in this phase. Therefore, only when the MINI-UEFI phase is determined can a contiguous physical memory region be identified as the Ramdisk without allocation conflicts, and its address and size be known and fixed.
[0120] Of course, in the system boot method disclosed in this embodiment, it is also possible not to determine the target region, but to directly select the default region as the target region, which is used to transmit the boot information obtained in the LinuxBoot stage to the GrubX stage.
[0121] The system startup method disclosed in this embodiment, after storing target information in a designated memory of the electronic device through the initial boot firmware, performs hardware initialization operations on the hardware of the electronic device, while keeping the designated memory unmodified. Then, it outputs operating system selection information for multiple operating systems that the electronic device can run, receives selection instructions in response to the output operating system selection information, determines the startup information of the operating system based on the selection instructions, and uses a general boot program to configure the hardware of the electronic device after hardware initialization according to the target information stored in the designated memory, so as to boot and start the first operating system of the electronic device based on the startup information. In this scheme, the initial boot firmware first stores the target information in a designated memory of the electronic device, and ensures that the designated memory is kept unmodified during hardware initialization. This allows the general boot program to configure the hardware of the electronic device after hardware initialization using the target information stored in the designated memory, thereby ensuring that the first operating system of the electronic device can successfully complete booting and startup. Furthermore, after hardware initialization, operating system selection information is output so that the user can select the operating system to boot from the electronic device, thereby achieving the booting and startup of the operating system.
[0122] This embodiment discloses a system startup method, the flowchart of which is as follows: Figure 5 As shown, it includes:
[0123] Step S51: Determine key information from multiple pieces of information used to implement the boot of the first operating system through the initial boot firmware, and determine the key information as target information. The target information includes at least: system table, global descriptor table, global interrupt descriptor table and page table.
[0124] Step S52: Store the target information into the designated memory of the electronic device through the initial boot firmware;
[0125] Step S53: Perform hardware initialization on the electronic device and obtain the operating system's startup information. The hardware initialization operation retains the specified memory and does not modify it.
[0126] Step S54: Use the general bootloader to configure the hardware of the electronic device after performing hardware initialization operation according to the target information stored in the specified memory;
[0127] Step S55: On the electronic device configured with target information, the first operating system of the electronic device is booted and started based on the boot information.
[0128] To enable the booting and startup of the first operating system of an electronic device, target information is first stored in a designated memory of the electronic device using the initial boot firmware. This target information, determined by the initial boot firmware, includes information used to boot the first operating system. Next, hardware initialization is performed on the electronic device's hardware to obtain the operating system's startup information. This hardware initialization operation preserves the designated memory without modification. Then, a general bootloader is used to configure the initialized hardware according to the target information, enabling the electronic device to boot and start the first operating system based on the startup information. This ensures that the first operating system can successfully boot and start, avoiding the problem of the first operating system failing to boot and start due to damage to its execution environment caused by the hardware initialization operation.
[0129] Specifically, the determination of target information can be achieved by: identifying key information from multiple pieces of information used to implement the booting of the first operating system through the initial boot firmware, and then defining the identified key information as target information.
[0130] There are multiple pieces of information used to implement the booting of the first operating system. If the initial boot firmware directly determines all the information used to implement the booting of the first operating system as target information, then the execution environment created during the execution phase of the initial boot firmware can be a complete execution environment for booting the first operating system. In this case, if the target information is saved, the required memory space is large. Furthermore, if a complete execution environment is created directly, then the booting and startup of the first operating system (such as Windows) can be directly achieved without going through the Linux Boot stage. Since the Linux Boot stage is implemented using the Linux kernel, its hardware initialization process is more stable. Therefore, in this embodiment, only a portion of the information used to boot the first operating system (such as Windows) is determined as target information, and only the determined target information is configured to complete the creation of the minimum execution environment. In the environment recovery stage, only the minimum execution environment needs to be restored.
[0131] The target information may include at least: the system table, the global descriptor table, the global interrupt descriptor table, and the page table.
[0132] The EFI system table is one of the most critical data structures in the UEFI architecture. As a bridge for user-space programs (such as UEFI applications or drivers) to access firmware kernel services, hardware resources, and system information, the EFI system table ensures permission isolation between the boot phase and the operating system runtime.
[0133] The Global Descriptor Table (GTD) is a core data structure for processors with specific architectures (such as x86 architecture processors) to enter protected mode. It is used to define the attributes, access permissions, and system resource management mechanisms of memory segments. Its core function is to provide the basic framework for memory segmentation management for the central processing unit (CPU), and to achieve hardware-level memory protection and multi-task isolation.
[0134] The Global Interrupt Descriptor Table (IDT) is a core data structure used to manage interrupt and exception handling in protected mode of a specific architecture (such as x86 architecture). It is essentially an array of gate descriptors that dispatch events to the corresponding handlers (ISRs) by indexing the interrupt vector number.
[0135] The page table is the core data structure of the operating system for implementing virtual memory management. It is responsible for mapping the virtual addresses (logical addresses) used by a process to the actual addresses (physical addresses) in physical memory, ensuring that the program can transparently use a contiguous address space that is larger than the physical memory.
[0136] In addition, the target information in the system startup method disclosed in this embodiment may also include: BlockIO (a standard protocol in the UEFI specification, EFI BLOCK IO PROTOCOL), which provides a set of function pointers and data structures, allowing UEFI drivers and applications (such as operating system bootloaders) to access different block devices in a unified manner without having to care about the specific hardware details of the devices. BlockIO is a standardized driver interface for the operating system or bootloader to read and write block devices such as hard disks and USB flash drives in the UEFI environment.
[0137] In this embodiment, during the MINI-UEFI stage (i.e., the stage of initial boot firmware execution), a UEFI environment containing the BlockIO protocol framework is created, and this framework structure is saved as part of the target information to ensure that Windows can find the BlockIO protocol in the restored environment. During the LinuxBoot stage (i.e., the stage of target kernel execution), the target kernel uses its stable and mature hard disk controller driver to complete the hard disk initialization. During the GrubX stage (i.e., the stage of generic bootloader execution), GrubX not only restores the structure of the BlockIO protocol, but also further links the underlying read and write operations of the BlockIO protocol with the hard disk driver that the target kernel has already initialized. This ensures that when the bootloader of the first operating system (Windows system) calls the BlockIO protocol in the restored environment to read and write the hard disk, the read and write request is efficiently forwarded to the driver of the target kernel for execution, so as to achieve more stable system operation.
[0138] The system boot method disclosed in this embodiment first determines key information from multiple pieces of information used to boot the first operating system using the initial boot firmware. This determined key information is then designated as target information, which includes at least the system table, global descriptor table, global interrupt descriptor table, and page table. Next, the target information is stored in designated memory of the electronic device. Hardware initialization is performed on the electronic device's hardware to obtain the operating system's boot information. The hardware initialization operation retains the designated memory without modification. Then, using general boot information, the hardware of the electronic device after hardware initialization is configured according to the target information in the designated memory, so that the first operating system of the electronic device can be booted and started based on the boot information. In this scheme, the initial boot firmware does not use all of the multiple pieces of information used to boot the first operating system as target information. Instead, it selects only some key information from multiple pieces of information and uses only the selected key information as target information. The execution environment built using only the selected key information quickly performs basic hardware initialization, while other hardware initialization is performed by the target kernel to ensure the stability of hardware initialization.
[0139] Furthermore, in the system startup method disclosed in this embodiment, configuring the hardware of the electronic device after performing hardware initialization operations according to the target information stored in the specified memory can be specifically as follows:
[0140] Read the target information stored in the specified memory and save the target information to the register corresponding to the target information in the hardware of the electronic device after the hardware initialization operation is performed.
[0141] When configuring the hardware in an electronic device after it has been initialized according to the target information, the target information needs to be saved to the corresponding register in order to configure the hardware.
[0142] Specifically, the base address and limit of the Global Descriptor Table (GTD) in the target information can be written into the GDTR register of the CPU. The GDTR register (Global Descriptor Table Register) is used to store the starting address of the GDT in memory and the size limit of the table. The CPU can find the location of the GDT in memory by reading the value in the GDTR.
[0143] The base address and limit of the Global Interrupt Descriptor Table (IDT) in the target information can be written into the CPU's IDTR register. The IDTR register (Global Interrupt Descriptor Table Register) is a dedicated register in the CPU used to store the starting address and size of the IDT. The CPU can find the location of the IDT in memory by reading the data in the IDTR, thereby determining where to jump to to execute the handler when an interrupt or exception occurs.
[0144] The base address of the page table in the target information can be written into the CPU's CR3 register. The CR3 register (Control Register 3) is used to store the physical memory starting address of the currently active page table. When the CPU needs to translate the virtual address used by the program into a physical address, it can determine the location of the page table from the CR3 register.
[0145] Additionally, the pointer to the EFI system table can be written back to a location specified in the UEFI specification (such as a specific register or a fixed address).
[0146] In the system startup method disclosed in this embodiment, after the hardware initialization operation is completed, different data in the target information are stored in the corresponding registers respectively, so as to ensure that after the operating system is started, the corresponding response can be performed based on the corresponding data stored in the registers.
[0147] This embodiment discloses a system startup device, the structural schematic diagram of which is shown below. Figure 6 As shown, it includes:
[0148] Storage unit 61, initialization unit 62, configuration unit 63 and startup unit 64.
[0149] The storage unit 61 is used to store target information into a designated memory of the electronic device through the initial boot firmware. The target information is determined by the initial boot firmware and includes information for implementing the boot of the first operating system.
[0150] The initialization unit 62 is used to perform hardware initialization operations on the hardware of the electronic device and obtain the startup information of the operating system. The hardware initialization operation preserves the specified memory without modification.
[0151] Configuration unit 63 is used to configure the hardware of an electronic device after hardware initialization operation by using a general bootloader according to the target information stored in a specified memory;
[0152] The startup unit 64 is used to boot and start the first operating system of an electronic device configured with target information based on the startup information.
[0153] Furthermore, the initialization unit is used for:
[0154] The target kernel performs hardware initialization operations on the electronic device's hardware. The target kernel can perform hardware initialization operations and boot a second operating system for the electronic device, which is different from the first operating system.
[0155] Furthermore, the initialization unit is used for:
[0156] The target kernel determines the first location in the specified memory where the target information is stored; the first location where the target information is stored is marked; the target kernel performs hardware initialization operations on the electronic device based on the second location in the specified memory, which is different from the first location.
[0157] Furthermore, the initialization unit is used for:
[0158] The initial boot firmware performs hardware initialization operations on the electronic device's hardware.
[0159] Furthermore, the startup unit is used for:
[0160] The first operating system of an electronic device is booted and started using a generic bootloader based on boot information.
[0161] Furthermore, the initialization unit is used for:
[0162] It outputs operating system selection information for multiple operating systems that the electronic device can run; it receives selection instructions in response to the output operating system selection information, and determines the boot information of the operating system based on the selection instructions.
[0163] Furthermore, the initialization unit is also used for:
[0164] The operating system's boot information is stored in the target area, which is the area determined by the initial boot firmware based on specified memory and used to store information determined by the target kernel.
[0165] Furthermore, the configuration unit is used for:
[0166] Read the target information stored in the specified memory; save the target information to the register corresponding to the target information in the hardware of the electronic device after the hardware initialization operation is performed.
[0167] Furthermore, the system startup device disclosed in this embodiment may further include:
[0168] The determining unit is used to determine key information from multiple pieces of information used to implement the booting of the first operating system through the initial boot firmware, and to determine the determined key information as target information. The target information includes at least: system table, global descriptor table, global interrupt descriptor table and page table.
[0169] The system startup device disclosed in this embodiment is based on the system startup method disclosed in the above embodiment, and will not be described again here.
[0170] The system boot device disclosed in this embodiment stores target information in a designated memory of an electronic device through initial boot firmware. The target information, determined by the initial boot firmware, includes information for booting a first operating system. It performs hardware initialization on the electronic device's hardware and obtains the operating system's boot information. The hardware initialization operation retains the designated memory without modification. A general bootloader configures the hardware of the electronic device after hardware initialization according to the target information stored in the designated memory. On the electronic device configured with the target information, the first operating system of the electronic device is booted and started based on the boot information. This solution first stores the target information in the designated memory of the electronic device through initial boot firmware and ensures that the designated memory is retained and not modified during hardware initialization. This allows the general bootloader to configure the hardware of the initialized electronic device using the target information stored in the designated memory after hardware initialization, thereby ensuring that the first operating system of the electronic device can successfully boot and start.
[0171] It should also be noted that the device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. In addition, in the device embodiment drawings provided in this application, the connection relationship between modules indicates that they have a communication connection, which can be implemented as one or more communication buses or signal lines.
[0172] Through the above description of the embodiments, those skilled in the art can clearly understand that this application can be implemented by means of software plus necessary general-purpose hardware, or it can be implemented by special-purpose hardware including application-specific integrated circuits, special-purpose CPUs, special-purpose memory, special-purpose components, etc. Generally, any function performed by a computer program can be easily implemented by corresponding hardware, and the specific hardware structure used to implement the same function can also be diverse, such as analog circuits, digital circuits, or special-purpose circuits. However, for this application, software program implementation is more often the preferred implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a readable storage medium, such as a computer floppy disk, USB flash drive, mobile hard disk, ROM, RAM, magnetic disk, or optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, training equipment, or network device, etc.) to execute the methods described in the various embodiments of this application.
[0173] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented, in whole or in part, as a computer program product.
[0174] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions may be transmitted from one website, computer, training device, or data center to another website, computer, training device, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium may be any available medium that a computer can store or a data storage device such as a training device or data center that integrates one or more available media. The available media may be magnetic media (e.g., floppy disks, hard disks, magnetic tapes), optical media (e.g., DVDs), or semiconductor media (e.g., solid-state drives (SSDs)).
Claims
1. A system startup method, comprising: The target information is stored in a designated memory of the electronic device by the initial boot firmware, and the target information is determined by the initial boot firmware and includes information for implementing the boot of the first operating system; The hardware initialization operation is performed on the electronic device and the startup information of the operating system is obtained. The hardware initialization operation preserves the specified memory from being modified. The hardware of the electronic device after the hardware initialization operation is performed is configured using a general bootloader according to the target information stored in the specified memory. On an electronic device configured with the target information, a first operating system of the electronic device is guided and launched based on the startup information.
2. The method according to claim 1, wherein performing hardware initialization operations on the hardware of the electronic device includes: The target kernel performs hardware initialization operations on the hardware of the electronic device. The target kernel is capable of performing hardware initialization operations and booting a second operating system for the electronic device, which is different from the first operating system.
3. The method according to claim 2, wherein performing hardware initialization operations on the hardware of the electronic device through the target kernel includes: The first location in the specified memory where the target information is stored is determined by the target kernel; The first location where the target information is stored is marked; The target kernel performs hardware initialization operations on the hardware of the electronic device based on a second location in the specified memory, where the second location is different from the first location.
4. The method according to claim 1, wherein performing hardware initialization operations on the hardware of the electronic device includes: The initial boot firmware performs hardware initialization operations on the electronic device's hardware.
5. The method according to claim 1, wherein the first operating system of the electronic device is guided and started based on the startup information, comprising: The first operating system of the electronic device is booted and started using the general bootloader based on the boot information.
6. The method according to claim 1, wherein obtaining the operating system startup information includes: Outputs operating system selection information for multiple operating systems that the electronic device can run; Receive a selection instruction in response to the output operating system selection information, and determine the boot information of the operating system based on the selection instruction.
7. The method according to claim 2, further comprising: The boot information of the operating system is stored in a target area, which is the area determined by the initial boot firmware based on the specified memory and used to store information determined by the target kernel.
8. The method according to claim 1, wherein configuring the hardware of the electronic device after performing the hardware initialization operation according to the target information stored in the specified memory includes: Read the target information stored in the specified memory; The target information is saved to the register corresponding to the target information in the hardware of the electronic device after the hardware initialization operation is performed.
9. The method according to claim 1, further comprising: The initial boot firmware determines key information from multiple pieces of information used to implement the booting of the first operating system, and identifies the determined key information as target information. The target information includes at least: system table, global descriptor table, global interrupt descriptor table, and page table.
10. A system startup device, comprising: A storage unit is used to store target information into a designated memory of an electronic device via initial boot firmware, the target information being determined by the initial boot firmware and including information for implementing the boot of a first operating system; An initialization unit is used to perform hardware initialization operations on the hardware of an electronic device and obtain the startup information of the operating system. The hardware initialization operation preserves the specified memory from being modified. A configuration unit is used to configure the hardware of an electronic device after performing the hardware initialization operation using a general bootloader according to the target information stored in the specified memory; A startup unit is configured to boot and start a first operating system of an electronic device configured with the target information based on the startup information.