A compatible operating system and its loading and startup method
By introducing a compatible boot layer into the operating system, the loading problem caused by inconsistency between the boot loader and the operating system ABI is solved, and efficient and economical operating system loading and startup is achieved, suitable for various processors and target machine platforms.
Patent Information
- Application Number
- CN202111647852.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-29
- Publication Date
- 2025-07-04
- Estimated Expiration
- 2041-12-29
AI Technical Summary
When the boot loader of the target machine is inconsistent with the application binary interface (ABI) of the operating system, the prior art requires modification of the boot loader to realize the loading of the operating system, resulting in increased costs and extended development cycles.
Design a compatible operating system and its load startup method. By introducing a compatible startup layer in the operating system, it realizes load startup when the operating system is inconsistent with the boot loader ABI, including parsing the operating system image size and entry address, and executing the main operating system program in the compatible startup layer.
It realizes that without modifying the boot loader, it can be compatible with operating system loading of different ABIs, reduces communication costs, shortens development time, and has high economic efficiency, simplicity and strong versatility.
Smart Images

Figure CN114443133B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of embedded software, relates to operating system startup technology, and specifically provides a compatible operating system and its loading and startup method. Background Art
[0002] During the development of an embedded operating system, it is often necessary to load the operating system image onto the target machine for running, and the loading process depends on the boot loader on the target machine. Usually, the boot loader is generally burned into the ROM space of a storage device such as flash in binary form. After the target machine is powered on, the boot loader will be executed first, and the boot loader will load the operating system image stored in the host or ROM space into the memory space for running.
[0003] If the boot loader of the target machine is provided by a third party and the boot loader does not have the ability to compatibly start the operating system, when the ABI of the boot loader and the operating system image is inconsistent, the boot loader cannot correctly parse and load the operating system image. At this time, the third party needs to modify the boot loader and re-burn the boot, which will increase the cost of the embedded operating system and also extend the development cycle of the embedded operating system, resulting in certain limitations. Summary of the Invention
[0004] In order to solve the situation where the operating system cannot be loaded due to the inconsistency between the boot loader of the target machine and the operating system ABI, the present invention discloses a compatible operating system and its loading and startup method. The compatible operating system and loading and startup method designed by the present invention can achieve the compatible loading and startup of the operating system without changing the boot loader, and has the characteristics of high economic efficiency, simple implementation, flexible and easy use, and strong versatility.
[0005] The technical solutions for achieving the invention purpose are as follows:
[0006] In a first aspect, the present invention provides a method for loading and starting a compatible operating system. The operating system image to be started and loaded includes an operating system image layer and a compatible startup layer.
[0007] Among them, the method for loading and starting the operating system includes the following steps:
[0008] S101. The boot loader of the target machine parses the loadable and executable operating system image file of the operating system, and obtains the image size and the first program entry address of the operating system from the compatible startup layer.
[0009] S102. The boot loader jumps to the first program entry address and executes the program in the compatible startup layer.
[0010] S103. In the compatibility startup layer, the compatibility startup layer program jumps to the second program entry address of the preset operating system binary file and starts executing the main operating system program.
[0011] S104. The main operating system program takes over the CPU and initializes the CPU to complete the loading and startup of the operating system.
[0012] By designing a method for loading and starting a compatible operating system, the present invention can achieve that when the ABI of the boot loader on the target machine is inconsistent with the operating system ABI, there is no need to modify the ABI of the boot loader on the target machine. By adding a compatibility startup layer to the operating system, the loading and startup of an operating system with a different ABI from the boot loader on the target machine can be achieved. The method for loading and starting the operating system designed by the present invention has the advantages of high economic efficiency, simple implementation, flexible and easy use, and strong versatility.
[0013] In an embodiment of the method for loading and starting a compatible operating system of the present invention, before the operating system is loaded and started, it further includes the step of compiling a loadable and executable operating system image with a compatibility startup layer.
[0014] Further, the method for compiling a loadable and executable operating system image with a compatibility startup layer includes the following steps:
[0015] S201. Based on actual requirements, generate an executable operating system binary file within the operating system image layer.
[0016] S202. Compile the operating system binary file as data into the data segment of the compatibility startup layer.
[0017] S203. In the compatibility startup layer, set the program to jump to the second program entry address, and a loadable and executable operating system image with a compatibility startup layer can be formed.
[0018] In an embodiment of the above method for loading and starting a compatible operating system, when the ABI of the operating system image layer is different from the ABI of the boot loader of the target machine, the first program entry address is the same as the ABI of the boot loader of the target machine, and the second program entry address is a compatible entry address.
[0019] Further, when the first program entry address and the ABI of the boot loader of the target machine are 32 bits, the ABI of the operating system image layer is 64 bits. Or when the first program entry address and the ABI of the boot loader of the target machine are 64 bits, the ABI of the operating system image layer is 32 bits.
[0020] In a second aspect, the present invention provides a compatible operating system, and the compatible operating system is loaded and started by using the method of the first aspect.
[0021] Among them, the operating system image loaded by the compatible operating system includes an operating system image layer and a compatible boot layer. The compatible boot layer is provided with a first program entry address and a second program entry address, and the second program entry address is the compatible entry address. The first program entry address is the same as the ABI of the boot loader of the target machine, and the first program entry address is the entry address between the boot loader of the target machine and the compatible boot layer. The second program entry address is the same as the ABI of the operating system image layer, and the second program entry address is the entry address between the compatible boot layer and the operating system image layer.
[0022] The compatible operating system designed by the present invention can be applied when the operating system ABI is inconsistent with the boot loader on the target machine, and it is not necessary to modify the boot on the target machine, and it can also realize the loading and startup of the operating system by using the boot on the target machine.
[0023] In an embodiment of the above compatible operating system, when the ABI of the first program entry address and the boot loader of the target machine is 32 bits, the ABI of the operating system image layer is 64 bits. Or when the ABI of the first program entry address and the boot loader of the target machine is 64 bits, the ABI of the operating system image layer is 32 bits.
[0024] Compared with the prior art, the beneficial effects of the present invention are as follows: By designing a method for loading and starting a compatible operating system, the present invention can realize that when the ABI of the boot loader on the target machine is inconsistent with the operating system ABI, it is not necessary to modify the ABI of the boot loader on the target machine, and by adding a compatible boot layer to the operating system, the loading and starting of an operating system with a different ABI from the boot loader on the target machine can be realized. The method for loading and starting the operating system designed by the present invention has the following characteristics: 1. It saves communication costs and shortens the development time, and has high economic benefits; 2. The implementation method is simple, the operability is strong, and the amount of code to be developed is extremely small; 3. It is applicable to various processors and different target machine platforms, and has strong versatility. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for the description of the embodiments will be briefly introduced below. Obviously, the drawings in the following description are only for the purpose of more clearly illustrating the technical solutions of the embodiments of the present invention or the prior art, and for those of ordinary skill in the art, other drawings can be obtained according to these drawings without creative efforts.
[0026] Figure 1 It is a flowchart of the method for loading and starting a compatible operating system in the specific implementation manner. Detailed implementation manners
[0027] The present invention will be further described below in conjunction with specific embodiments, and the advantages and features of the present invention will become clearer as the description proceeds. However, these embodiments are merely exemplary and do not constitute any limitation to the scope of the present invention. Those skilled in the art should understand that modifications or substitutions can be made to the details and forms of the technical solutions of the present invention without departing from the spirit and scope of the present invention, and such modifications and substitutions all fall within the protection scope of the present invention.
[0028] In the description of this embodiment, it should be understood that the orientation or positional relationship indicated by the terms "center", "longitudinal", "transverse", "upper", "lower", "front", "rear", "left", "right", "vertical", "horizontal", "top", "bottom", "inner", "outer", etc. is based on the orientation or positional relationship shown in the drawings, and is only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and thus should not be construed as a limitation to the present invention.
[0029] In addition, the terms "first", "second", "third", etc. are only used for descriptive purposes and cannot be understood as indicating or implying relative importance or implicitly specifying the quantity of the indicated technical features. Thus, the features defined with "first", "second", etc. may explicitly or implicitly include one or more of such features. In the description of the present invention, unless otherwise specified, the meaning of "a plurality" is two or more.
[0030] Embodiment 1:
[0031] During the development of an embedded operating system, when the ABI (i.e., Application Binary Interface) of the boot loader is inconsistent with the ABI (i.e., Application Binary Interface) of the developed embedded operating system, for example, when the ABI of the boot loader is 32-bit while the developed embedded operating system is 64-bit, or when the ABI of the boot loader is 64-bit while the developed embedded operating system is 32-bit, at this time, the boot loader cannot load and start the embedded operating system. In order to achieve the loading and starting of the embedded operating system by the boot loader without modifying the ABI of the boot loader, this specific implementation manner discloses a compatible operating system.
[0032] In this specific implementation manner, the operating system image loaded by the compatible operating system includes an operating system image layer and a compatible boot layer. The compatible boot layer is provided with a first program entry address and a second program entry address, and the second program entry address is the compatible entry address.
[0033] Specifically, the above first program entry address is the same as the ABI of the boot loader of the target machine, and the first program entry address is the entry address between the boot loader of the target machine and the compatible boot layer. The second program entry address is the same as the ABI of the operating system image layer, and the second program entry address is the entry address between the compatible boot layer and the operating system image layer.
[0034] In an embodiment of the above compatible operating system, when the ABI of the above first program entry address and the boot loader of the target machine is 32 bits, the ABI of the operating system image layer is 64 bits. Or when the ABI of the first program entry address and the boot loader of the target machine is 64 bits, the ABI of the operating system image layer is 32 bits.
[0035] It should be noted here that the compatible operating system designed in this specific embodiment can also be applied when the ABI of the operating system image layer is the same as the ABI of the boot loader of the target machine. At this time, the first program entry address, the second program entry address, and the ABI of the boot loader of the target machine are all the same, and the second program entry address can be a compatible or incompatible entry address. When the ABI of the operating system image layer is the same as the ABI of the boot loader of the target machine, the loading and startup of the operating system are carried out in the current common way, and no detailed description is given here.
[0036] The compatible operating system designed in this specific embodiment can be applied when the ABI of the operating system is inconsistent with the boot loader on the target machine. Without modifying the boot on the target machine, it is also possible to realize the loading and startup of the operating system using the boot on the target machine, which has the advantages of high economic efficiency, simple implementation, flexible and easy to use, and strong versatility.
[0037] Embodiment 2:
[0038] This specific embodiment discloses a method for loading and starting a compatible operating system. The loading and starting method is to start the compatible operating system in Embodiment 1, especially when the ABI of the developed operating system is different from the ABI of the boot loader of the target machine, without modifying the ABI of the boot loader, the operating system can be normally loaded and started.
[0039] In this specific embodiment, the operating system image to be started and loaded includes an operating system image layer and a compatible boot layer. The method for loading and starting the operating system includes the following steps:
[0040] S101. The bootloader of the target machine parses the loadable and executable operating system image file of the operating system, and obtains the image size of the operating system and the first program entry address (also referred to as address A, the compatible boot layer entry address) from the compatible boot layer.
[0041] S102. The bootloader jumps to the first program entry address and executes the compatible boot layer program.
[0042] S103. In the compatible boot layer, the compatible boot layer program jumps to the second program entry address (also referred to as address B, the operating system binary entry address) of the preset operating system binary file and starts to execute the operating system main program.
[0043] S104. The operating system main program takes over the CPU and initializes the CPU to complete the loading and startup of the operating system.
[0044] Among them, the above loading and startup of the operating system includes two cases:
[0045] The first case: The ABI of the operating system image layer is different from the ABI of the bootloader of the target machine, the first program entry address is the same as the ABI of the bootloader of the target machine, and the second program entry address is a compatible entry address. Specifically, when the above first program entry address and the ABI of the bootloader of the target machine are 32 bits, the ABI of the operating system image layer is 64 bits; or when the first program entry address and the ABI of the bootloader of the target machine are 64 bits, the ABI of the operating system image layer is 32 bits.
[0046] The second case: The ABI of the operating system image layer is the same as the ABI of the bootloader of the target machine. At this time, the first program entry address, the second program entry address, and the ABI of the bootloader of the target machine in the above steps are all the same, and the second program entry address can be a compatible or incompatible entry address. The loading and startup of the operating system in this case is carried out in the current common way, and no detailed description is given here.
[0047] In another embodiment of the method for loading and starting a compatible operating system in this specific embodiment, before the above operating system is loaded and started, it is also necessary to compile a loadable and executable operating system image with a compatible boot layer.
[0048] Specifically, the method for compiling a loadable and executable operating system image with a compatible boot layer includes the following steps:
[0049] S201. Based on actual requirements, an executable operating system binary file is compiled and generated within the operating system image layer.
[0050] S202. Compile the operating system binary file as data into the data segment of the compatible boot layer.
[0051] S203. In the compatible boot layer, set the program to jump to the second program entry address, and a loadable executable operating system image with a compatible boot layer can be formed.
[0052] The method for loading and starting the compatible operating system designed in this specific embodiment (see Figure 1 ) can achieve that when the boot loader on the target machine and the operating system ABI are inconsistent, it is not necessary to modify the ABI of the boot loader on the target machine. By adding a compatible boot layer to the operating system, the loading and starting of an operating system with a different ABI from the boot loader on the target machine can be realized. The operating system loading and starting method designed by the present invention has the advantages of high economic efficiency, simple implementation, flexible and easy use, and strong versatility.
[0053] The following takes a 32-bit boot loader to load and start a 64-bit compatible operating system as an example to illustrate the operating system loading and starting method of this embodiment, including the following steps:
[0054] Step 1: Compile and generate a 64-bit executable operating system binary, and its entry address is address B. At this time, address B must be a compatible address.
[0055] Step 2: In the compatible boot layer, take the operating system binary generated in Step 1 as data, put it into the data segment of the compatible boot layer, set the program to directly jump to address B to execute, and compile and generate a 32-bit loadable executable operating system image with a compatible boot layer, and its entry address is address A;
[0056] Step 3: The target machine boot loader parses the loadable executable operating system image with a compatible boot layer, and after parsing out information such as the address A and image size of the compatible boot layer, moves and jumps to address A to start execution;
[0057] Step 4: In the compatible boot layer, the program directly jumps to address B to start executing the operating system main program;
[0058] Step 5: The operating system main program takes over the CPU, configures the processor into 64-bit address mode, initializes the CPU, and completes the startup of the operating system.
[0059] The above are only the preferred embodiments of the present invention and are not intended to limit the present invention. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
[0060] In addition, it should be understood that although this specification is described according to embodiments, not every embodiment only contains an independent technical solution. This narrative way of the specification is only for clarity. Those skilled in the art should regard the specification as a whole, and the technical solutions in each embodiment can also be appropriately combined to form other embodiments that can be understood by those skilled in the art.
Claims
1. A method for loading and starting a compatible operating system, characterized in that: The operating system image for startup loading includes an operating system image layer and a compatibility startup layer, and the following steps are included: S101. The boot loader of the target machine parses the loadable and executable operating system image file of the operating system, and obtains the image size of the operating system and the first program entry address from the compatibility startup layer; S102. The boot loader jumps to the first program entry address and executes the compatibility startup layer program; S103. In the compatibility startup layer, the compatibility startup layer program jumps to the second program entry address of the preset operating system binary file and starts to execute the operating system main program; S104. The operating system main program takes over the CPU and initializes the CPU to complete the loading and startup of the operating system; Wherein, when the ABI of the operating system image layer is different from the ABI of the boot loader of the target machine, the first program entry address is the same as the ABI of the boot loader of the target machine, and the second program entry address is a compatible entry address; When the first program entry address and the ABI of the boot loader of the target machine are 32 bits, the ABI of the operating system image layer is 64 bits; or when the first program entry address and the ABI of the boot loader of the target machine are 64 bits, the ABI of the operating system image layer is 32 bits.
2. The loading and startup method of the compatible operating system according to claim 1, wherein: Before the operating system is loaded and started, it also includes the step of compiling a loadable and executable operating system image with a compatibility startup layer.
3. The loading and startup method of the compatible operating system according to claim 2, characterized in that: The method for compiling a loadable and executable operating system image with a compatibility startup layer includes the following steps: S201. Based on actual requirements, an executable operating system binary file is compiled and generated within the operating system image layer; S202. The operating system binary file is compiled as data into the data segment of the compatibility startup layer; S203. In the compatibility startup layer, set the program to jump to the second program entry address, and a loadable and executable operating system image with a compatibility startup layer can be formed.
4. A compatible operating system, characterized in that: The operating system image loaded by the compatible operating system includes an operating system image layer and a compatibility startup layer. The compatibility startup layer is provided with a first program entry address and a second program entry address, and the second program entry address is a compatible entry address; The first program entry address is the same as the ABI of the boot loader of the target machine, and the first program entry address is the entry address between the boot loader of the target machine and the compatibility startup layer; The second program entry address is the same as the ABI of the operating system image layer, and the second program entry address is the entry address between the compatibility startup layer and the operating system image layer; Wherein, when the first program entry address and the ABI of the boot loader of the target machine are 32 bits, the ABI of the operating system image layer is 64 bits; or when the first program entry address and the ABI of the boot loader of the target machine are 64 bits, the ABI of the operating system image layer is 32 bits.