A method for kernel upgrade and usage, a computing device, and a storage medium
By creating new configuration information outside the first kernel configuration file of the operating system, generating the second kernel, and loading it into internal memory at the same time as the configuration file, the problem that the driver cannot adapt during the operating system is solved, and a kernel upgrade without recompiling the driver is achieved.
Patent Information
- Application Number
- CN202210398048.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-12
- Publication Date
- 2025-06-27
- Estimated Expiration
- 2042-04-12
AI Technical Summary
When the operating system is upgraded, the kernel interface verification value changes, causing the original driver to be unable to adapt to the new kernel unless the driver is recompiled.
By creating new configuration information outside the configuration file of the first kernel, without changing the data structure of the original configuration file, the second kernel is generated, and loading it into internal memory with the configuration file at the same time, ensuring that the driver can adapt.
When the operating system is upgraded, the kernel interface verification value is not changed to ensure that the original driver can continue to be used and avoid the necessity of recompilation.
Smart Images

Figure CN114879987B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of operating systems, and particularly to a method for kernel upgrade and use, a computing device, and a storage medium. Background Art
[0002] With the development of computer technology, people use computers through operating systems and call various driver programs to complete various tasks. Sometimes, in order to add additional functions or optimize the performance of the operating system, it is necessary to upgrade the operating system; specifically: customize and upgrade the kernel.
[0003] However, in the prior art, when using an operating system to call various drivers, in order to avoid incompatibility between the operating system and the driver program, the kernel interfaces called by the driver program are verified: it is determined whether the driver program is available according to the verification value of the kernel interface. However, when upgrading the operating system, directly adding corresponding functions to the kernel will cause the verification value of the kernel interface provided to the driver program to change. Once the verification value of the kernel interface that the driver program needs to call is different from the verification value of the kernel interface provided by the current operating system, the original driver program cannot be used continuously unless the driver program is recompiled.
[0004] Therefore, a new method for kernel upgrade and use is needed. Summary of the Invention
[0005] Therefore, the present invention provides a method for kernel upgrade and use, in an attempt to solve or at least alleviate the problems described above.
[0006] According to one aspect of the present invention, there is provided a method for kernel upgrade and use, suitable for execution in a computing device. The computing device includes an internal memory and runs an operating system. The operating system includes a first kernel and a driver program. The method includes the steps of: determining a configuration file according to the first kernel, and creating configuration information according to the configuration file to obtain a second kernel; setting a storage location of the configuration information in the internal memory; loading the second kernel into the internal memory according to the storage location; calling the driver program according to the second kernel, and implementing a target function according to the configuration information.
[0007] Optionally, in the method according to the present invention, allocating a storage location of the configuration information in the internal memory includes the steps of: determining a relative position of the configuration information and the configuration file in the internal memory; setting the storage location in the internal memory according to the relative position.
[0008] Optionally, in the method according to the present invention, the relative position includes that the configuration information is before the configuration file and the configuration information is after the relative position.
[0009] Optionally, in the method according to the present invention, loading the configuration information into the internal memory according to the storage location includes the steps of: determining the allocation method for allocating memory in the internal storage; and loading the configuration information into the internal memory according to the allocation method and the storage location.
[0010] Optionally, in the method according to the present invention, the allocation method includes general memory allocation. Loading the second kernel into the internal memory according to the storage location includes the steps of: when the allocation method is general memory allocation, calling a first allocation function to allocate memory for the configuration file and the configuration information according to the storage location to load the second kernel.
[0011] Optionally, in the method according to the present invention, the allocation method further includes dedicated memory allocation. The method further includes the steps of: when the allocation method is dedicated memory allocation, calling a second allocation function to allocate memory for the configuration file and the configuration information according to the storage location to load the second kernel.
[0012] Optionally, in the method according to the present invention, calling the driver according to the second kernel includes the steps of: calculating a second check value according to the configuration file and the configuration information stored in the internal memory; comparing the second check value with the first check value when the first kernel is loaded; and if the second check value is the same as the first check value, loading the driver.
[0013] Optionally, in the method according to the present invention, implementing the target function according to the configuration information includes the steps of: when the relative position is that the configuration information is before the configuration file, subtracting the storage address of the configuration file from the storage size of the configuration information in the internal memory to obtain a first storage address; and calling the configuration information according to the first storage address to implement the target function.
[0014] Optionally, in the method according to the present invention, the method further includes the steps of: when the relative position is that the configuration information is after the configuration file, adding the storage address of the configuration file to the storage size of the configuration file in the internal memory to obtain a second storage address;
[0015] According to another aspect of the present invention, there is provided a computing device, including: one or more processors; a memory; and one or more programs, wherein the one or more programs are stored in the memory and are configured to be executed by the one or more processors, and the one or more programs include those for executing the kernel upgrade and usage method according to the present invention.
[0016] According to still another aspect of the present invention, there is provided a computer-readable storage medium storing one or more programs, the one or more programs including instructions which, when executed by a computing device, cause the computing device to execute the kernel upgrade and usage method according to the present invention.
[0017] The present invention discloses a method for kernel upgrade and usage, which is suitable for execution in a computing device. The computing device includes an internal memory and runs an operating system. The operating system includes a first kernel and a driver. The method includes the steps of: determining a configuration file according to the first kernel, and creating configuration information according to the configuration file to obtain a second kernel; setting a storage location of the configuration information in the internal memory; loading the second kernel into the internal memory according to the storage location; calling the driver according to the second kernel, and implementing a target function according to the configuration information. By creating configuration information outside the original configuration file of the first kernel, the data structure of the original configuration file is not changed. Further, the configuration information and the configuration file are loaded into the internal memory simultaneously, while implementing the target function, ensuring that the driver can still be adapted and available. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] To achieve the above and related purposes, certain illustrative aspects are described herein in connection with the following description and the accompanying drawings, which indicate various ways in which the principles disclosed herein can be practiced, and all aspects and their equivalent aspects are intended to fall within the scope of the claimed subject matter. The above and other objects, features, and advantages of the present invention disclosed will become more apparent by reading the following detailed description in conjunction with the accompanying drawings. Throughout the present disclosure, the same reference numerals generally refer to the same components or elements.
[0019] Figure 1 FIG. 1 shows a block diagram of a computing device 100 according to an exemplary embodiment of the present invention;
[0020] Figure 2 FIG. 2 shows a schematic flowchart of a method 200 for kernel upgrade and usage according to an exemplary embodiment of the present invention;
[0021] Figure 3 FIG. 3 shows a schematic diagram of kernel upgrade in the prior art;
[0022] Figure 4a FIG. 4 shows a schematic diagram of setting configuration information before a configuration file according to an exemplary embodiment of the present invention;
[0023] Figure 4b FIG. 5 shows a schematic diagram of setting configuration information after a configuration file according to an exemplary embodiment of the present invention;
[0024] Figure 5 FIG. 6 shows a schematic diagram of allocating memory using general memory allocation according to an exemplary embodiment of the present invention;
[0025] Figure 6 FIG. 7 shows a schematic diagram of the memory allocated using general memory allocation according to an exemplary embodiment of the present invention;
[0026] Figure 7 A schematic diagram of allocating memory using dedicated memory allocation according to an exemplary embodiment of the present invention is shown; and
[0027] Figure 8 A schematic diagram of the memory allocated using dedicated memory allocation according to an exemplary embodiment of the present invention is shown. Detailed implementation manners
[0028] Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided so that the present disclosure can be more thoroughly understood and the scope of the present disclosure can be completely conveyed to those skilled in the art. The same reference numerals generally refer to the same components or elements.
[0029] Figure 1 A block diagram of the physical components (i.e., hardware) of a computing device 100 is shown. In a basic configuration, the computing device 100 includes at least one processing unit 102 and a system memory 104. According to one aspect, depending on the configuration and type of the computing device, the system memory 104 includes, but is not limited to, volatile storage (e.g., random access memory), non-volatile storage (e.g., read-only memory), flash memory, or any combination of such memories. According to one aspect, the system memory 104 includes an operating system 105. The operating system 105 includes a second kernel 103. The second kernel 103 is obtained by upgrading the first kernel according to method 200.
[0030] According to one aspect, the operating system 105, for example, is suitable for controlling the operation of the computing device 100. In addition, the examples are practiced in conjunction with a graphics library, other operating systems, or any other application programs, and are not limited to any specific application or system. In Figure 1 the basic configuration is shown by those components within the dashed line 108. According to one aspect, the computing device 100 has additional features or functions. For example, according to one aspect, the computing device 100 includes additional data storage devices (removable and / or non-removable), such as magnetic disks, optical disks, or magnetic tapes. Such additional storage is Figure 1 shown by a removable storage device 109 and a non-removable storage device 110 in
[0031] As stated above, according to one aspect, program modules 101 are stored in system memory 104. According to one aspect, the program modules may include one or more applications, and the types of applications are not limited by the present invention. For example, the applications may further include: email and contact applications, word processing applications, spreadsheet applications, database applications, slide show applications, painting or computer-aided applications, web browser applications, etc.
[0032] According to one aspect, the examples may be practiced in a circuit including discrete electronic components, a package or integrated electronic chip containing logic gates, a circuit utilizing a microprocessor, or on a single chip containing electronic components or a microprocessor. For example, the examples may be practiced via a system-on-a-chip (SOC) in which each or many of the components shown in Figure 1 may be integrated on a single integrated circuit. According to one aspect, such an SOC device may include one or more processing units, graphics units, communication units, system virtualization units, and various application functions, all of which are integrated (or "burned") onto the chip substrate as a single integrated circuit. When operating via an SOC, the functions described herein may be operated via dedicated logic integrated with other components of computing device 100 on a single integrated circuit (chip). Embodiments of the present invention may also be practiced using other technologies capable of performing logical operations (such as AND, OR, and NOT), including but not limited to mechanical, optical, fluidic, and quantum technologies. Additionally, embodiments of the present invention may be practiced within a general-purpose computer or in any other circuit or system.
[0033] According to one aspect, computing device 100 may also have one or more input devices 112, such as a keyboard, mouse, pen, voice input device, touch input device, etc. An output device 114 may also be included, such as a display, speaker, printer, etc. The foregoing devices are examples and other devices may also be used. Computing device 100 may include one or more communication connections 116 that allow communication with other computing devices 118. Examples of suitable communication connections 116 include but are not limited to: RF transmitter, receiver, and / or transceiver circuits; universal serial bus (USB), parallel, and / or serial ports.
[0034] According to another aspect, drivers 106 are loaded in operating system 105. Operating system 105 may call input device 112 or output device 114 via drivers 106.
[0035] Embodiments of the present invention also provide a non-transitory readable storage medium storing instructions for causing a computing device to execute the method according to the embodiments of the present invention. The readable medium of this embodiment includes permanent and non-permanent, removable and non-removable media, and information storage can be implemented by any method or technology. The information can be computer-readable instructions, data structures, program modules, or other data. Examples of readable storage media include, but are not limited to: phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassette tapes, magnetic disk storage or other magnetic storage devices, or any other non-transitory readable storage medium.
[0036] According to one aspect, a communication medium is implemented by computer-readable instructions, data structures, program modules, or other data in a modulated data signal (e.g., a carrier wave or other transmission mechanism), and includes any information delivery medium. According to one aspect, the term "modulated data signal" describes a signal having one or more characteristic sets or a signal that has been altered in a manner that encodes information in the signal. By way of example and not limitation, communication media include wired media such as a wired network or direct wired connection, and wireless media such as acoustic, radio frequency (RF), infrared, and other wireless media.
[0037] The method for kernel upgrade and use of the present invention is suitable for execution in a computing device, such as execution in computing device 100. Computing device 100 includes an internal memory, which can be specifically implemented as Figure 1 system memory 104 in. An operating system 105 runs in computing device 100. Before the operating system 105 is upgraded, it includes a first kernel and driver 106. The operating system running in the computing device can be implemented as any operating system, and the present invention does not limit the specific type of the operating system.
[0038] It should be noted that although the above computing device only shows a processing unit 102, a system memory 104, an input device 112, an output device 114, and a communication connection 116, in the specific implementation process, the device may also include other components necessary for normal operation. In addition, those skilled in the art can understand that the above device may also only include the components necessary to implement the solution of the embodiments of this specification, and does not necessarily include all the components shown in the figure. Figure 2 The flowchart of the method 200 for kernel upgrade and use according to an exemplary embodiment of the present invention is shown. As Figure 2As shown, first, step S210 is executed. A configuration file is determined according to the first kernel, and configuration information is newly created according to the configuration file to obtain a second kernel.
[0039] The kernel in the original operating system that needs to be upgraded is the first kernel. According to an embodiment of the present invention, when the operating system is a Linux system, the first kernel is the Linux kernel.
[0040] Figure 3 The figure shows a schematic diagram of kernel upgrade in the prior art. As Figure 3 shown, in the prior art, new attributes are directly added under the original kernel data structure to implement corresponding functions, which will cause the structure of the new kernel to change, and the verification value of the kernel interface provided to the driver program to change, which is different from the verification value of the kernel interface to be called by the driver program; resulting in the driver program being unable to adapt to the new kernel and unable to call the driver program according to the new kernel.
[0041] In the present invention, however, configuration information is newly created outside the configuration file that needs to add new functions, without destroying the original data structure of the configuration file. The configuration file is the kernel file to be modified when adding the target function. The configuration information is the attribute information carrying the target function, and the target function is the function to be expanded according to the original configuration file. The second kernel obtained after newly creating the configuration information according to the configuration file includes the configuration file and the configuration information. The second kernel can not only implement the functions originally implemented by the first kernel according to the original configuration file, but also implement the new target functions according to the configuration information.
[0042] According to an embodiment of the present invention, the configuration file can be implemented as a kernel header file. By constructing additional configuration information for the kernel header file, the extended attributes based on the configuration information can be realized to implement extended functions or optimize performance. After modifying the kernel header file, the target functions that can be extended can be realized based on the role of the kernel header file.
[0043] Subsequently, step S220 is executed to set the storage location of the configuration information in the internal memory; specifically: determine the relative position of the configuration information and the configuration file in the internal memory, and then set the storage location in the internal memory according to the relative position.
[0044] In order to change the kernel data structure of the second kernel, the size of the configuration file and its relative storage position in the internal memory are retained. According to an embodiment of the present invention, for the convenience of accessing the added configuration information, the relative position includes that the configuration information is before the configuration file and the configuration information is after the relative position.
[0045] When setting the storage location in the internal memory according to the relative position, if the relative position is determined to be before the configuration file, the storage location of the configuration information is set before the configuration file; if the relative position is determined to be after the configuration file, the storage location of the configuration information is set after the configuration file.
[0046] Figure 4a FIG. shows a schematic diagram of setting configuration information before a configuration file according to an exemplary embodiment of the present invention. Figure 4b FIG. shows a schematic diagram of setting configuration information after a configuration file according to an exemplary embodiment of the present invention. As Figure 4a shown, if the relative position of the configuration information is before the configuration file, the storage location of the configuration information is set before the storage location of the configuration file; as Figure 4b shown, if the relative position of the configuration information is after the configuration file, the storage location of the configuration information is set after the storage location of the configuration file.
[0047] Subsequently, step S230 is executed to load the second kernel into the internal memory according to the storage location. Specifically: first determine the allocation method for allocating memory in the internal storage; then load the configuration information into the internal memory according to the allocation method and the storage location.
[0048] According to an embodiment of the present invention, the allocation methods include general memory allocation and dedicated memory allocation, and these two allocation methods include different allocation functions.
[0049] According to an embodiment of the present invention, slab memory allocator is used for memory allocation in the internal memory. To further reduce memory waste, the slab memory allocator divides the memory into a general cache and a dedicated cache. When using the general cache for memory allocation, it is general allocation; when using the dedicated cache for memory allocation, it is dedicated allocation.
[0050] The general cache can be used to call the first allocation function to pass in the number of bytes of memory required to allocate an object from the general cache. The first allocation function includes the kmalloc function.
[0051] Using a dedicated cache, the second allocation function can be called to allocate an object from the dedicated cache by passing in the number of bytes of memory required. The second allocation function includes a function for passing in the object size and a function for allocating the object's memory. The function for passing in the object size includes the kmem_cache_create and kmem_cache_create_usercopy functions, which are used to pass in the size of the object to be created and create a dedicated memory (kmem_cache). The function for allocating the object's memory includes functions such as kmem_cache_zalloc, kmem_cache_alloc_node, and kmem_cache_alloc, which are called when the object needs to be used to allocate memory in the internal memory.
[0052] When loading the second kernel into the internal memory according to the storage location, when the allocation method is general memory allocation, the first allocation function is called to allocate memory for the configuration file and configuration information according to the storage location to load the second kernel; when the allocation method is dedicated memory allocation, the second allocation function is called to allocate memory for the configuration file and configuration information according to the storage location to load the second kernel.
[0053] According to an embodiment of the present invention, the configuration file is iomap_page, including:
[0054] atomic_t read_count
[0055] atomic_t write_count
[0056] DECLARE_BITMAP(uptodate,PAGE_SIZE / 512);
[0057] The configuration information is pre_iomap_page. Here, pre means before storing the configuration information into the configuration file. Figure 5 The figure shows a schematic diagram of allocating memory using general memory allocation according to an exemplary embodiment of the present invention. As Figure 5 shown, the iomap_page_create function is called first. The iomap_page_create function is the memory allocation function of the iomap_page general cache and will call the kmalloc function to allocate an object. When allocating the object, the memory of the data structure of the newly added configuration information (sizeof(struct uos_pre_iomap_page)) is increased.
[0058] Figure 6 The figure shows a schematic diagram of the allocated memory using general memory allocation according to an exemplary embodiment of the present invention. As Figure 6As shown, in the internal memory, the storage spaces of the configuration file iomap_page and the configuration information pre_iomap_page are objects allocated by the kmalloc function, where the configuration information pre_iomap_page is stored before the configuration file iomap_page.
[0059] According to another embodiment of the present invention, the configuration file is buffer_head, including:
[0060] unsigned long b_state
[0061] struct buffer_head*b_this_page structpage*b_page
[0062] sector_t b_blocknr
[0063] size_t b_size
[0064] char*b_data
[0065] struct block_device*b_bdev bh_end_io_t*b_end_io
[0066] void*b_private
[0067] struct list_head b_assoc_buffers struct address_space
[0068] *b_assoc_map
[0069] atomic_t b_count
[0070] The configuration information is post_buffer_head. Here, post means storing the configuration information after the configuration file. Figure 7 The figure shows a schematic diagram of allocating memory using dedicated memory allocation according to an exemplary embodiment of the present invention. As Figure 7As shown, the buffer_init function is called during kernel initialization. When the buffer_init function is called, it calls the kmem_cache_create function with the object size passed in to create a dedicated memory kmem_cache for the buffer_head data structure. When calling the kmem_cache_create function with the object size passed in, when configuring the memory size of the buffer_head in the configuration file, the memory size of the newly created configuration information post_buffer_head is added. The total size returned at this time (bh_cachep->size) is equal to the sum of the memory sizes of the configuration file buffer_head and the configuration information post_buffer_head.
[0071] Subsequently, the kmem_cache_zalloc function for allocating object memory is called to allocate a memory object in the internal memory.
[0072] Figure 8 A schematic diagram of the memory allocated using dedicated memory allocation according to an exemplary embodiment of the present invention is shown. As Figure 8 shown, in the internal memory, the storage spaces of the configuration file buffer_head and the configuration information post_buffer_head are objects allocated by the second allocation function, where the configuration file buffer_head is stored before the configuration information post_buffer_head.
[0073] Subsequently, step S340 is executed to call the driver according to the second kernel and implement the target function according to the configuration information. According to an embodiment of the present invention, when calling the driver according to the second kernel, a second check value is calculated based on the configuration file and the configuration information stored in the internal memory, and the second check value is compared with the first check value when the first kernel is loaded. If the second check value is the same as the first check value, the driver is loaded.
[0074] According to an embodiment of the present invention, when calculating the second check value, the CRC value of the exported symbols of the kernel interface provided by the second kernel to the driver can be calculated. The second check value is compared with the CRC value (i.e., the first check value) of the exported symbols of the kernel interface provided to the driver when the first kernel is loaded. When constructing the configuration information using the present invention to upgrade the second kernel, since the data structure of the configuration file in the first kernel is not changed, the second check value is the same as the first check value, and the driver can be loaded normally.
[0075] Subsequently, implementing the target function according to the configuration information includes the steps of: when the relative position is that the configuration information is before the configuration file, subtracting the storage address of the configuration file from the storage size of the configuration information in the internal memory to obtain a first storage address, and calling the configuration information according to the first storage address to implement the target function.
[0076] According to an embodiment of the present invention, when calling the configuration information as Figure 6 shown, subtracting the storage size of the configuration information pre_iomap_page from the storage address of the configuration file iomap_page to obtain the first storage address of the configuration information pre_iomap_page, and then the configuration information pre_iomap_page can be called.
[0077] When the relative position is that the configuration information is after the configuration file, adding the storage address of the configuration file to the storage size of the configuration file in the internal memory to obtain a second storage address, and then calling the configuration information according to the second storage address to implement the target function.
[0078] The present invention discloses a method for kernel upgrade and usage, which is suitable for execution in a computing device. The computing device includes an internal memory and runs an operating system. The operating system includes a first kernel and a driver. The method includes the steps of: determining a configuration file according to the first kernel, and creating configuration information according to the configuration file to obtain a second kernel; setting the storage location of the configuration information in the internal memory; loading the second kernel into the internal memory according to the storage location; calling the driver according to the second kernel, and implementing the target function according to the configuration information. By creating configuration information outside the original configuration file of the first kernel, the present invention does not change the data structure of the original configuration file. Further, the configuration information and the configuration file are loaded into the internal memory at the same time, ensuring that the driver can still be adapted and available while implementing the target function.
[0079] In the specification provided herein, a large number of specific details are set forth. However, it can be understood that the embodiments of the present invention may be practiced without these specific details. In some instances, well-known methods, structures, and technologies have not been shown in detail so as not to obscure the understanding of this specification.
[0080] Similarly, it should be understood that, in order to streamline the present disclosure and assist in understanding one or more of the various inventive aspects, in the above description of the exemplary embodiments of the present invention, the various features of the present invention are sometimes grouped together into a single embodiment, figure, or description thereof.
[0081] Those skilled in the art should understand that the modules or units or groups of the devices in the examples disclosed herein can be arranged in the devices as described in the embodiments, or alternatively can be located in one or more devices different from the devices in the examples. The modules in the foregoing examples can be combined into one module or further divided into multiple sub-modules.
[0082] Those skilled in the art can understand that the modules in the devices of the embodiments can be adaptively changed and arranged in one or more devices different from the embodiments. The modules or units or groups in the embodiments can be combined into one module or unit or group, and further can be divided into multiple sub-modules or sub-units or sub-groups. Except that at least some of such features and / or processes or units are mutually exclusive, any combination can be adopted to combine all the features disclosed in this specification and all the processes or units of any method or device thus disclosed. Unless otherwise explicitly stated, each feature disclosed in this specification can be replaced by an alternative feature providing the same, equivalent or similar purpose.
[0083] In addition, those skilled in the art can understand that although some of the embodiments described herein include certain features included in other embodiments rather than other features, the combination of the features of different embodiments means that it is within the scope of the present invention and forms different embodiments.
[0084] In addition, some of the embodiments herein are described as a combination of methods or method elements that can be implemented by a processor of a computer system or by other devices performing the functions. Therefore, a processor having the necessary instructions for implementing the method or method element forms a device for implementing the method or method element. In addition, the elements described herein in the device embodiments are examples of the following devices: the device is used to implement the functions performed by the elements for the purpose of implementing the present invention.
[0085] The various technologies described here can be implemented in combination with hardware or software, or a combination of them. Thus, the methods and devices of the present invention, or certain aspects or parts of the methods and devices of the present invention, can take the form of program code (i.e., instructions) embedded in a tangible medium, such as a floppy disk, CD-ROM, hard disk drive, or any other machine-readable storage medium, where when the program is loaded into a machine such as a computer and executed by the machine, the machine becomes a device for practicing the present invention.
[0086] In the case where program code is executed on a programmable computer, a computing device generally includes a processor, a processor-readable storage medium (including volatile and non-volatile memory and / or storage elements), at least one input device, and at least one output device. Among them, the memory is configured to store program code; the processor is configured to execute the kernel upgrade and usage method of the present invention according to the instructions in the program code stored in the memory.
[0087] By way of example and not limitation, computer-readable media includes computer storage media and communication media. Computer-readable media includes computer storage media and communication media. Computer storage media stores information such as computer-readable instructions, data structures, program modules, or other data. Communication media generally embodies computer-readable instructions, data structures, program modules, or other data in a modulated data signal such as a carrier wave or other transmission mechanism, and includes any information delivery medium. A combination of any of the above is also included within the scope of computer-readable media.
[0088] As used herein, unless otherwise specified, the use of ordinal numbers "first", "second", "third", etc. to describe ordinary objects merely indicates different instances of similar objects and is not intended to imply that the objects so described must have a given order in terms of time, space, ranking, or in any other way.
[0089] Although the present invention has been described in terms of a limited number of embodiments, those skilled in the art of this technology will appreciate that other embodiments can be conceived within the scope of the present invention as thus described. In addition, it should be noted that the language used in this specification has been selected primarily for readability and teaching purposes rather than for the purpose of explaining or limiting the subject matter of the present invention. Thus, many modifications and variations will be apparent to those of ordinary skill in the art. The disclosure of the present invention is illustrative, not restrictive, of the scope of the present invention.
Claims
1. A method for kernel upgrade and usage, suitable for execution in a computing device, which includes an internal memory and runs an operating system. The operating system includes a first kernel and a driver. The method includes the steps: Determine a configuration file according to the first kernel, and create configuration information according to the configuration file to obtain a second kernel. The configuration file is the kernel file to be modified when adding a target function, and the configuration information is the attribute information carrying the target function. The target function is the function to be extended by the original configuration file; Set the storage location of the configuration information in the internal memory; Load the second kernel into the internal memory according to the storage location, including: Determine the allocation method for allocating memory in the internal storage; Load the configuration information into the internal memory according to the allocation method and the storage location; Call the driver according to the second kernel, and implement the target function according to the configuration information.
2. The method according to claim 1, wherein The step of allocating the storage location of the configuration information in the internal memory includes: Determine the relative position of the configuration information and the configuration file in the internal memory; Set the storage location in the internal memory according to the relative position.
3. The method according to claim 2, wherein, The relative position includes that the configuration information is before the configuration file and the configuration information is after the relative position.
4. The method according to claim 1, wherein, The allocation method includes general memory allocation. The step of loading the second kernel into the internal memory according to the storage location includes: When the allocation method is general memory allocation, call the first allocation function to allocate memory for the configuration file and the configuration information according to the storage location to load the second kernel.
5. The method according to claim 4, wherein, The allocation method also includes dedicated memory allocation. The method also includes the steps: When the allocation method is dedicated memory allocation, call the second allocation function to allocate memory for the configuration file and the configuration information according to the storage location to load the second kernel.
6. The method according to any one of claims 1-5, wherein, The step of calling the driver according to the second kernel includes: Calculate a second check value according to the configuration file and the configuration information stored in the internal memory; Compare the second check value with the first check value when the first kernel is loaded; If the second check value is the same as the first check value, load the driver.
7. The method according to claim 2 or 3, wherein, The step of implementing the target function according to the configuration information includes: When the relative position is that the configuration information is before the configuration file, subtract the storage address of the configuration file from the storage size of the configuration information in the internal memory to obtain a first storage address; Call the configuration information according to the first storage address to implement the target function.
8. The method according to claim 7, wherein, The method also includes the steps: When the relative position is that the configuration information is after the configuration file, add the storage address of the configuration file to the storage size of the configuration file in the internal memory to obtain a second storage address; Call the configuration information according to the second storage address to implement the target function.
9. A computing device, including: One or more processors; A memory; And One or more devices, the one or more devices including instructions for performing the method according to any one of claims 1-8.
10. A computer-readable storage medium storing one or more programs, the one or more programs including instructions that, when executed by a computing device, cause the computing device to perform the method according to any one of claims 1-8.
Citation Information
Patent Citations
Embedded dual system updating method and system
CN103577201A
Configuration information replacement method and device, machine readable storage medium and processor
CN110968333A