Compatible layer transplantation method and device, electronic equipment and storage medium
By obtaining and modifying the Wine compatibility layer source code, the problem that Wine cannot be built and run on the loongarch platform is solved, and the ability to run Windows applications on the loongarch platform is realized.
Patent Information
- Application Number
- CN202310969319.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-02
- Publication Date
- 2025-02-14
AI Technical Summary
Wine does not support building wine on the loongarch platform, which makes it impossible to run Windows programs on the loongarch platform.
By obtaining the compatibility layer global source code of the first processor architecture, the construction tool source code, the kernel library and the service source code, add the declaration definition source code related to the second processor architecture, modify the assembly code, add the kernel function, and modify the service source code to support the second processor architecture The second processor architecture is compiled to obtain compatibility layers, kernel libraries and services.
It implements the construction of a compatibility layer and its related libraries and programs on the second processor architecture, allowing Windows applications to be directly run on the second processor architecture.
Smart Images

Figure CN119440620A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a compatibility layer transplantation method, a compatibility layer transplantation device, an electronic device and a readable storage medium. Background Art
[0002] Wine (short for "Wine Is Not an Emulator") is a solution for running Windows applications on Linux systems, but it is mainly used on the X86 architecture and does not involve cross-architecture operation. It simulates the core environment for Windows programs to run, and provides a function interface that is consistent with Windows API names, parameters, and return values, but internally it is implemented by Linux system calls, so that Windows programs can be run directly.
[0003] Currently, Wine does not support cross-platform operation, and only has relevant codes for the X86 and ARM architectures. It does not support building Wine on the Loongarch (Loongson architecture) platform, and therefore cannot run Windows programs on the Loongarch platform. Summary of the invention
[0004] The technical problem to be solved by the embodiments of the present invention is to provide a compatibility layer transplantation method, device, electronic device and readable storage medium to solve the problem that Wine does not support building Wine on the Loongarch platform and then cannot run Windows programs on the Loongarch platform.
[0005] In order to solve the above problems, the present invention provides a compatibility layer transplantation method, comprising:
[0006] Obtaining a compatibility layer global source code, a compatibility layer building tool source code, a compatibility layer kernel library, and a compatibility layer service source code of a first processor architecture;
[0007] In the compatibility layer global source code, adding a declaration definition source code corresponding to a second processor architecture related to the processor;
[0008] In the compatibility layer construction tool source code, modifying the assembly code of the first processor architecture into the assembly code of the second processor architecture;
[0009] In the compatibility layer kernel library, adding kernel functions corresponding to the second processor architecture;
[0010] Modifying the compatibility layer service source code so that the compatibility layer service supports the second processor architecture;
[0011] The compatibility layer, the compatibility layer kernel library and the compatibility layer service are compiled according to the compatibility layer global source code, the compatibility layer construction tool source code, the compatibility layer kernel library and the compatibility layer service source code.
[0012] Optionally, adding a declaration definition source code corresponding to a second processor architecture related to the processor in the compatibility layer global source code includes:
[0013] In the header file of the global source code of the compatibility layer, keyword judgment, processor register information, processor flag information and macro definition corresponding to the second processor architecture are added.
[0014] Optionally, modifying the assembly code of the first processor architecture into the assembly code of the second processor architecture includes:
[0015] Adding assembly code corresponding to the macro of the second processor architecture to the output import conversion function of the compatibility layer construction tool source code;
[0016] Modify the function of the source code of the compatibility layer construction tool, which is used to insert the distribution jump code when generating the dynamic library, into a function implemented by the assembly code of the second processor architecture;
[0017] The function of the compatible layer construction tool source code for generating a pile function is modified into a function implemented by the assembly code of the second processor architecture, and a character string recording the position of the pile function generated is added;
[0018] In the declaration file of the compatibility layer construction tool source code, the assembly code of the macro judgment processing of the second processor architecture is added.
[0019] Optionally, the kernel function includes an exception handling function, a start function and a signal function, and in the compatible layer kernel library, adding the kernel function corresponding to the second processor architecture includes:
[0020] Adding an exception handling function for capturing exceptions or interrupts and a start function for calling when creating a process under the current directory of the compatibility layer kernel library;
[0021] Adding a start function to be called when creating a process in the system directory corresponding to the second processor architecture;
[0022] Register a signal function corresponding to the second processor architecture.
[0023] Optionally, the modifying the compatibility layer service source code so that the compatibility layer service supports the second processor architecture includes:
[0024] Macros related to the second processor architecture are added to thread-related files, mapping-related files, and protocol definition files of the compatibility layer service source code.
[0025] The present invention also provides a compatible layer transplantation device, comprising:
[0026] A source code acquisition module, used to acquire the compatibility layer global source code, compatibility layer construction tool source code, compatibility layer kernel library and compatibility layer service source code of the first processor architecture;
[0027] A source code adding module, used for adding a declaration definition source code corresponding to a second processor architecture related to the processor in the global source code of the compatibility layer;
[0028] An assembly modification module, used to modify the assembly code of the first processor architecture into the assembly code of the second processor architecture in the source code of the compatibility layer construction tool;
[0029] A kernel function adding module, used for adding kernel functions corresponding to the second processor architecture in the compatibility layer kernel library;
[0030] A service source code modification module, used to modify the compatibility layer service source code so that the compatibility layer service supports the second processor architecture;
[0031] The compiling module is used to compile the compatibility layer, the compatibility layer kernel library and the compatibility layer service according to the compatibility layer global source code, the compatibility layer construction tool source code, the compatibility layer kernel library and the compatibility layer service source code to obtain the compatibility layer, the compatibility layer kernel library and the compatibility layer service.
[0032] Optionally, the source code adding module includes:
[0033] The source code adding submodule is used to add keyword judgment, processor register information, processor flag information and macro definition corresponding to the second processor architecture in the header file of the global source code of the compatibility layer.
[0034] Optionally, the assembly modification module includes:
[0035] A first modification submodule is used to add assembly code corresponding to the macro of the second processor architecture in the output import conversion function of the compatibility layer construction tool source code;
[0036] A second modification submodule is used to modify the function of the source code of the compatibility layer construction tool used for inserting distribution jump codes when generating dynamic libraries into a function implemented by the assembly code of the second processor architecture;
[0037] The third modification submodule is used for modifying the function of the compatible layer construction tool source code for generating a pile function into a function implemented by the assembly code of the second processor architecture, and adding a character string recording the position of the generated pile function;
[0038] The fourth modification submodule is used to add the assembly code of the macro judgment processing of the second processor architecture in the declaration file of the compatibility layer construction tool source code.
[0039] Optionally, the kernel function includes an exception handling function, a start function and a signal function, and the kernel function adding module includes:
[0040] A first adding submodule is used to add an exception handling function for capturing exceptions or interrupts and a start function for calling when creating a process in the current directory of the compatible layer kernel library;
[0041] A second adding submodule, used to add a start function called when creating a process under the system directory corresponding to the second processor architecture;
[0042] The function registration submodule is used to register the signal function corresponding to the second processor architecture.
[0043] Optionally, the service source code modification module includes:
[0044] The macro adding submodule is used to add macros related to the second processor architecture in the thread-related files, mapping-related files, and protocol definition files of the compatibility layer service source code.
[0045] The embodiment of the present invention further discloses an electronic device, characterized in that it includes a processor;
[0046] The memory is used to store a computer program, and when the computer program is executed by the processor, the processor implements the method steps described above.
[0047] The embodiment of the present invention further discloses a readable storage medium. When instructions in the storage medium are executed by a processor of an electronic device, the electronic device can execute one or more methods described in the embodiment of the present invention.
[0048] According to an embodiment of the present invention, by obtaining a compatibility layer global source code, a compatibility layer construction tool source code, a compatibility layer kernel library and a compatibility layer service source code of a first processor architecture, a declaration definition source code corresponding to a second processor architecture related to the processor is added to the compatibility layer global source code, the assembly code of the first processor architecture is modified to the assembly code of the second processor architecture in the compatibility layer construction tool source code, the kernel function corresponding to the second processor architecture is added to the compatibility layer kernel library, the compatibility layer service source code is modified to enable the compatibility layer service to support the second processor architecture, and the compatibility layer, the compatibility layer kernel library and the compatibility layer service source code are compiled according to the compatibility layer global source code, the compatibility layer construction tool source code, the compatibility layer kernel library and the compatibility layer service source code, so that the compatibility layer and its related libraries and programs can be built on the second processor architecture, and the compatibility layer is transplanted to the second processor architecture, so that the Windows application can be directly run on the second processor architecture. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] Figure 1 A flowchart of a compatible layer transplantation method provided by an embodiment of the present invention is shown;
[0050] Figure 2 A structural block diagram of an embodiment of a compatible layer transplantation device provided by an embodiment of the present invention is shown;
[0051] Figure 3 A structural block diagram of an electronic device for compatible layer transplantation according to an exemplary embodiment is shown. DETAILED DESCRIPTION
[0052] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.
[0053] Reference Figure 1 , shows a flowchart of a compatibility layer transplantation method provided by an embodiment of the present invention, which may specifically include the following steps:
[0054] Step 101, obtaining a compatibility layer global source code, a compatibility layer construction tool source code, a compatibility layer kernel library, and a compatibility layer service source code of a first processor architecture.
[0055] In an embodiment of the present invention, the first processor architecture and the second processor architecture are two different processor architectures. For example, the first processor architecture is an x86 architecture or an ARM architecture, and the second processor architecture is a loongarch architecture.
[0056] In the embodiment of the present invention, the compatibility layer refers to a software program that simulates the core environment for Windows program operation, provides a function interface consistent with Windows API names, parameters, and return values, but is implemented by Linux system calls internally, so that Windows programs can be directly run, for example, Wine. The global source code of the compatibility layer refers to the source code that is globally effective for the compatibility layer. For example, the source code in the include directory in Wine.
[0057] In the embodiment of the present invention, the compatibility layer construction tool refers to a tool for constructing the above compatibility layer. The compatibility layer construction tool source code refers to the source code of the compatibility layer construction tool, for example, the source code in the winebuild directory.
[0058] In the embodiment of the present invention, the compatibility layer kernel library refers to a kernel-related library used by the compatibility layer, for example, the source code in the ntdll directory in wine.
[0059] In the embodiment of the present invention, the compatibility layer service refers to a service used to manage Windows objects and some public environment variables, such as the registry, and is also responsible for synchronizing messages and events. The compatibility layer service source code refers to the relevant source code of the compatibility layer service, for example, the source code in the wineserver directory.
[0060] Step 102: Add declaration definition source code corresponding to a second processor architecture related to the processor in the compatibility layer global source code.
[0061] In the embodiment of the present invention, some declarations and definitions of the first processor architecture and the second processor architecture are different. Declarations refer to declarations related to the processor, such as declarations related to keyword judgment, and definitions refer to definitions related to the processor, such as commonly used registers and other flags. Therefore, in the global source code of the compatibility layer, according to the second processor architecture, the source code of corresponding declarations and definitions is added so that the compatibility layer can correctly use the processor of the second processor architecture.
[0062] Step 103: In the compatibility layer construction tool source code, the assembly code of the first processor architecture is modified into the assembly code of the second processor architecture.
[0063] In an embodiment of the present invention, there are some assembly codes for building a compatibility layer in the compatibility layer building tool. Since the assembly code is usually not universal among different processor architectures, it is necessary to modify the assembly code of the first processor architecture into the assembly code of the second processor architecture so that the compatibility layer compiler (such as winegcc) can call the assembly code of the second processor architecture during the process of building the compatibility layer, and the compatibility layer can be directly built on the second processor architecture.
[0064] Step 104: Add kernel functions corresponding to the second processor architecture to the compatibility layer kernel library.
[0065] In the embodiment of the present invention, the kernel function of the processor is defined in the kernel library of the compatibility layer, and the kernel functions of different processor architectures are different. The kernel function refers to the function related to the processing of the processor kernel, for example, the exception handling function for capturing exceptions or interrupts, the start function called when creating a process, various signal functions, etc.
[0066] In the embodiment of the present invention, kernel functions corresponding to the second processor architecture are added to the compatibility layer kernel library, so that the compatibility layer kernel library supports the second processor architecture.
[0067] Step 105: modify the compatibility layer service source code so that the compatibility layer service supports the second processor architecture.
[0068] In an embodiment of the present invention, the compatibility layer service source code originally supports the first processor architecture and can process executable files in the PE format corresponding to the first processor architecture. In order to enable the compatibility layer service to support the second processor architecture, the compatibility layer service source code needs to be modified. Specifically, macros related to the second processor architecture can be added.
[0069] Step 106: compile the compatibility layer, the compatibility layer kernel library and the compatibility layer service according to the compatibility layer global source code, the compatibility layer construction tool source code, the compatibility layer kernel library and the compatibility layer service source code to obtain the compatibility layer, the compatibility layer kernel library and the compatibility layer service.
[0070] In an embodiment of the present invention, after completing all the above modifications, the compatibility layer global source code, the compatibility layer construction tool source code, the compatibility layer kernel library and the compatibility layer service source code are compiled, so as to obtain the compatibility layer, the compatibility layer kernel library and the compatibility layer service locally, that is, a usable compatibility layer is directly built on the second processor architecture.
[0071] For example, after all the above modifications are completed, create a build directory under the wine source directory. Then execute the command: .. / configure--enable-win64 to prepare the software build environment on the system used by the second processor architecture, ensure that the dependencies required for the subsequent build and installation process are ready, and figure out what is needed to use these dependencies. Then execute the make command to execute the build and compile the software source code into an executable file. After waiting for the compilation to complete, run the built-in program, such as running loader / wine64 regedit to run the registry program.
[0072] According to an embodiment of the present invention, by obtaining a compatibility layer global source code, a compatibility layer construction tool source code, a compatibility layer kernel library and a compatibility layer service source code of a first processor architecture, a declaration definition source code corresponding to a second processor architecture related to the processor is added to the compatibility layer global source code, the assembly code of the first processor architecture is modified to the assembly code of the second processor architecture in the compatibility layer construction tool source code, the kernel function corresponding to the second processor architecture is added to the compatibility layer kernel library, the compatibility layer service source code is modified to enable the compatibility layer service to support the second processor architecture, and the compatibility layer, the compatibility layer kernel library and the compatibility layer service source code are compiled according to the compatibility layer global source code, the compatibility layer construction tool source code, the compatibility layer kernel library and the compatibility layer service source code, so that the compatibility layer and its related libraries and programs can be built on the second processor architecture, and the compatibility layer is transplanted to the second processor architecture, so that the Windows application can be directly run on the second processor architecture.
[0073] In an optional embodiment of the present invention, in a specific implementation method of adding a declaration definition source code corresponding to a second processor architecture related to the processor in the compatibility layer global source code, it may include: adding keyword judgment, processor register information, processor flag information and macro definition corresponding to the second processor architecture in the header file of the compatibility layer global source code.
[0074] The source code of processor-related declarations and definitions includes keyword judgment, processor register information, processor flag information, and macro definitions. Keywords refer to strings with specific meanings related to the processor. Keyword judgment refers to the declaration of judging keywords in the assembly code. Processor register information and processor flag information refer to declarations related to registers and flags used by the processor, such as the CONTEXT structure in wine. Macro definitions refer to the definitions of macros used by the processor.
[0075] For example, modify the winnt.h file (i.e., header file) in the include directory. Add the judgment of the keyword corresponding to __loongarch64. Define the CONTEXT structure of loongarch64, including common registers and other flags. Add macro definitions, such as PROCESSOR_ARCHITECTURE_LOONGARCH64, CPU_LOONGARCH64 macros, and so on.
[0076] In an optional embodiment of the present invention, a specific implementation method of modifying the assembly code of the first processor architecture into the assembly code of the second processor architecture may include: adding the assembly code corresponding to the macro of the second processor architecture in the output import conversion function of the compatibility layer construction tool source code; modifying the function of the compatibility layer construction tool source code for inserting distribution jump code when generating a dynamic library into a function implemented by the assembly code of the second processor architecture; modifying the function of the compatibility layer construction tool source code for generating a stub function into a function implemented by the assembly code of the second processor architecture, and adding a character string recording the location of the generated stub function; and adding the assembly code for judgment processing of the macro of the second processor architecture in the declaration file of the compatibility layer construction tool source code.
[0077] The output-import conversion function refers to a function in the function of the corresponding index in the function table when called, for example, the output_import_thunk function in the import.c file in the winebuild directory. In the output-import conversion function, the assembly code corresponding to the macro of the second processor architecture is added so that the compiled compatibility layer can compile an executable file in the PE format that can be recognized by the second processor architecture.
[0078] The function used to insert the distribution jump code when generating a dynamic library refers to the function used in the process of generating a dynamic library. For the function that needs to use the distribution jump in the dynamic library, the distribution jump code is inserted according to the function. For example, the output_syscall_dispatcher function in the import.c file under the winebuild directory is mainly used when generating dll.so and .so of the corresponding library. The assembly code of the second processor architecture is used to implement the function used to insert the distribution jump code when generating a dynamic library.
[0079] Stub function refers to the special function generally used in unit test, is used to simulate the interface called in the tested function, or returns nothing to the function, or returns a fixed value. Function used to generate stub function, for example, output_stubs function in the import.c file under the winebuild directory. In the function used to generate stub function, add the function realized by the assembly code of the second processor architecture.
[0080] In an optional embodiment of the present invention, the kernel function includes an exception handling function, a start function and a signal function. In the compatibility layer kernel library, a specific implementation method of adding the kernel function corresponding to the second processor architecture may include: adding an exception handling function for capturing exceptions or interrupts under the current directory of the compatibility layer kernel library; adding a start function for calling when creating a process under the system directory corresponding to the second processor architecture; and registering the signal function corresponding to the second processor architecture.
[0081] The kernel functions of the processor are defined in the compatibility layer kernel library, for example, ntdll in wine. The current directory of the compatibility layer kernel library refers to the root directory of the compatibility layer kernel library. The system directory corresponding to the second processor architecture in the compatibility layer kernel library refers to the directory used by the system corresponding to the second processor architecture, for example, the loongarch architecture corresponds to the unix system, and the system directory is the unix directory in the compatibility layer kernel library. Add the source code files corresponding to the kernel functions in these two directories respectively.
[0082] In the current directory, add the exception handling function and the start function, and in the system directory, add the start function. The exception handling function refers to the kernel function used to capture exceptions or interrupts, and the start function refers to the kernel function called when creating a process. Then register various signal functions in the signal initialization process function to handle various internal exceptions. The added kernel function needs to be implemented using inline assembly.
[0083] For example, in ntdll, add the signal_loongarch64.c file in the current directory and the unix directory respectively, add the call_stack_handlers function (exception handling function) in the file added in the current directory, mainly for capturing exceptions or interrupts, and add the signal_start_thread function (starting function) in the file added in the system directory, mainly for calling and saving parameters when wineserver creates a process. The aforementioned functions need to use inline assembly to use the assembly code of the second processor architecture. Then register various signal functions that support the second processor architecture in the signal_init_process (signal initialization process) function to handle various internal exceptions.
[0084] In an optional embodiment of the present invention, a specific implementation method of modifying the compatibility layer service source code so that the compatibility layer service supports the second processor architecture may include: adding macros related to the second processor architecture in thread-related files, mapping-related files, and protocol definition files of the compatibility layer service source code.
[0085] The compatibility layer service source code includes thread-related files, mapping-related files, and protocol definition files. Thread-related files refer to source code files related to threads, such as thread.c. Mapping-related files refer to source code files related to mapping relationships, such as mapping.c. Protocol definition files refer to source code files related to the definition of protocols, such as protocol.def.
[0086] In the above file, add macros related to the second processor architecture, for example, macros related to LOONGARCH64, so as to ensure that wineser can process PE format executable files corresponding to the second processor architecture.
[0087] It should be noted that, for the sake of simplicity, the method embodiments are described as a series of action combinations, but those skilled in the art should be aware that the embodiments of the present invention are not limited by the order of the actions described, because according to the embodiments of the present invention, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of the present invention.
[0088] Reference Figure 2 , shows a structural block diagram of an embodiment of a compatible layer transplantation device provided by another embodiment of the present invention, which may specifically include the following modules:
[0089] The source code acquisition module 201 is used to acquire the compatibility layer global source code, the compatibility layer construction tool source code, the compatibility layer kernel library and the compatibility layer service source code of the first processor architecture;
[0090] A source code adding module 202, configured to add a declaration definition source code corresponding to a second processor architecture related to the processor in the compatibility layer global source code;
[0091] An assembly modification module 203, used to modify the assembly code of the first processor architecture into the assembly code of the second processor architecture in the source code of the compatibility layer construction tool;
[0092] A kernel function adding module 204, used for adding kernel functions corresponding to the second processor architecture in the compatibility layer kernel library;
[0093] A service source code modification module 205, configured to modify the compatibility layer service source code so that the compatibility layer service supports the second processor architecture;
[0094] The compiling module 206 is used to compile the compatibility layer, the compatibility layer kernel library and the compatibility layer service according to the compatibility layer global source code, the compatibility layer construction tool source code, the compatibility layer kernel library and the compatibility layer service source code to obtain the compatibility layer, the compatibility layer kernel library and the compatibility layer service.
[0095] Optionally, the source code adding module includes:
[0096] The source code adding submodule is used to add keyword judgment, processor register information, processor flag information and macro definition corresponding to the second processor architecture in the header file of the global source code of the compatibility layer.
[0097] Optionally, the assembly modification module includes:
[0098] A first modification submodule is used to add assembly code corresponding to the macro of the second processor architecture in the output import conversion function of the compatibility layer construction tool source code;
[0099] A second modification submodule is used to modify the function of the source code of the compatibility layer construction tool used for inserting distribution jump codes when generating dynamic libraries into a function implemented by the assembly code of the second processor architecture;
[0100] The third modification submodule is used for modifying the function of the compatible layer construction tool source code for generating a pile function into a function implemented by the assembly code of the second processor architecture, and adding a character string recording the position of the generated pile function;
[0101] The fourth modification submodule is used to add the assembly code of the macro judgment processing of the second processor architecture in the declaration file of the compatibility layer construction tool source code.
[0102] Optionally, the kernel function adding module includes:
[0103] A first adding submodule, used for adding a first kernel function for capturing an exception or an interrupt under the current directory of the compatible layer kernel library;
[0104] A second adding submodule, used to add a second kernel function called when creating a process under the system directory corresponding to the second processor architecture;
[0105] The function registration submodule is used to register the first kernel function and the second kernel function.
[0106] Optionally, the service source code modification module includes:
[0107] The macro adding submodule is used to add macros related to the second processor architecture in the thread-related files, mapping-related files, and protocol definition files of the compatibility layer service source code.
[0108] According to an embodiment of the present invention, by obtaining a compatibility layer global source code, a compatibility layer construction tool source code, a compatibility layer kernel library and a compatibility layer service source code of a first processor architecture, a declaration definition source code corresponding to a second processor architecture related to the processor is added to the compatibility layer global source code, the assembly code of the first processor architecture is modified to the assembly code of the second processor architecture in the compatibility layer construction tool source code, the kernel function corresponding to the second processor architecture is added to the compatibility layer kernel library, the compatibility layer service source code is modified to enable the compatibility layer service to support the second processor architecture, and the compatibility layer, the compatibility layer kernel library and the compatibility layer service source code are compiled according to the compatibility layer global source code, the compatibility layer construction tool source code, the compatibility layer kernel library and the compatibility layer service source code, so that the compatibility layer and its related libraries and programs can be built on the second processor architecture, and the compatibility layer is transplanted to the second processor architecture, so that the Windows application can be directly run on the second processor architecture.
[0109] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0110] Figure 3 1 is a block diagram of an electronic device 700 for compatible layer transplantation according to an exemplary embodiment. For example, the electronic device 700 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, etc.
[0111] Reference Figure 3 , the electronic device 700 may include one or more of the following components: a processing component 702 , a memory 704 , a power component 706 , a multimedia component 708 , an audio component 710 , an input / output (I / O) interface 712 , a sensor component 714 , and a communication component 716 .
[0112] The processing component 702 generally controls the overall operation of the electronic device 700, such as operations associated with display, phone calls, data communications, camera operations, and recording operations. The processing component 702 may include one or more processors 720 to execute instructions to complete all or part of the steps of the above-mentioned method. In addition, the processing component 702 may include one or more modules to facilitate the interaction between the processing component 702 and other components. For example, the processing component 702 may include a multimedia module to facilitate the interaction between the multimedia component 708 and the processing component 702.
[0113] The memory 704 is configured to store various types of data to support operations on the device 700. Examples of such data include instructions for any application or method operating on the electronic device 700, contact data, phone book data, messages, pictures, videos, etc. The memory 704 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.
[0114] The power component 704 provides power to various components of the electronic device 700. The power component 704 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the electronic device 700.
[0115] The multimedia component 708 includes a screen that provides an output interface between the electronic device 700 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundaries of the touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 708 includes a front camera and / or a rear camera. When the electronic device 700 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera may receive external multimedia data. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.
[0116] The audio component 710 is configured to output and / or input audio signals. For example, the audio component 710 includes a microphone (MIC), and when the electronic device 700 is in an operating mode, such as a call mode, a recording mode, and a voice recognition mode, the microphone is configured to receive an external audio signal. The received audio signal can be further stored in the memory 704 or sent via the communication component 716. In some embodiments, the audio component 710 also includes a speaker for outputting audio signals.
[0117] I / O interface 712 provides an interface between processing component 702 and peripheral interface components, such as keyboards, click wheels, buttons, etc. These buttons may include, but are not limited to, a home button, a volume button, a start button, and a lock button.
[0118] The sensor assembly 714 includes one or more sensors for providing various aspects of status assessment for the electronic device 700. For example, the sensor assembly 714 can detect the open / closed state of the device 700, the relative positioning of components, such as the display and keypad of the electronic device 700, and the sensor assembly 714 can also detect the position change of the electronic device 700 or a component of the electronic device 700, the presence or absence of contact between the user and the electronic device 700, the orientation or acceleration / deceleration of the electronic device 700, and the temperature change of the electronic device 700. The sensor assembly 714 may include a proximity sensor configured to detect the presence of nearby objects without any physical contact. The sensor assembly 714 may also include an optical sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 714 may also include an accelerometer, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
[0119] The communication component 716 is configured to facilitate wired or wireless communication between the electronic device 700 and other devices. The electronic device 700 can access a wireless network based on a communication standard, such as WiFi, 2G or 3G, or a combination thereof. In an exemplary embodiment, the communication component 714 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 714 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.
[0120] In an exemplary embodiment, the electronic device 700 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to perform the above methods.
[0121] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 704 including instructions, and the instructions can be executed by a processor 720 of an electronic device 700 to perform the above method. For example, the non-transitory computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.
[0122] A non-transitory computer-readable storage medium, when instructions in the storage medium are executed by a processor of a terminal, enables the terminal to perform a compatibility layer migration method, the method comprising:
[0123] Obtaining a compatibility layer global source code, a compatibility layer building tool source code, a compatibility layer kernel library, and a compatibility layer service source code of a first processor architecture;
[0124] In the compatibility layer global source code, adding a declaration definition source code corresponding to a second processor architecture related to the processor;
[0125] In the compatibility layer construction tool source code, modifying the assembly code of the first processor architecture into the assembly code of the second processor architecture;
[0126] In the compatibility layer kernel library, adding kernel functions corresponding to the second processor architecture;
[0127] Modifying the compatibility layer service source code so that the compatibility layer service supports the second processor architecture;
[0128] The compatibility layer, the compatibility layer kernel library and the compatibility layer service are compiled according to the compatibility layer global source code, the compatibility layer construction tool source code, the compatibility layer kernel library and the compatibility layer service source code.
[0129] Optionally, adding a declaration definition source code corresponding to a second processor architecture related to the processor in the compatibility layer global source code includes:
[0130] In the header file of the global source code of the compatibility layer, keyword judgment, processor register information, processor flag information and macro definition corresponding to the second processor architecture are added.
[0131] Optionally, modifying the assembly code of the first processor architecture into the assembly code of the second processor architecture includes:
[0132] Adding assembly code corresponding to the macro of the second processor architecture to the output import conversion function of the compatibility layer construction tool source code;
[0133] Modify the function of the source code of the compatibility layer construction tool, which is used to insert the distribution jump code when generating the dynamic library, into a function implemented by the assembly code of the second processor architecture;
[0134] The function of the compatible layer construction tool source code for generating a pile function is modified into a function implemented by the assembly code of the second processor architecture, and a character string recording the position of the pile function generated is added;
[0135] In the declaration file of the compatibility layer construction tool source code, the assembly code of the macro judgment processing of the second processor architecture is added.
[0136] Optionally, adding a kernel function corresponding to the second processor architecture in the compatibility layer kernel library includes:
[0137] Adding a first kernel function for capturing exceptions or interrupts under the current directory of the compatibility layer kernel library;
[0138] Adding a second kernel function for calling when creating a process in a system directory corresponding to the second processor architecture;
[0139] The first kernel function and the second kernel function are registered.
[0140] Optionally, the modifying the compatibility layer service source code so that the compatibility layer service supports the second processor architecture includes:
[0141] Macros related to the second processor architecture are added to thread-related files, mapping-related files, and protocol definition files of the compatibility layer service source code.
[0142] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0143] It will be appreciated by those skilled in the art that the embodiments of the present invention may be provided as methods, devices, or computer program products. Therefore, the embodiments of the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the embodiments of the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.
[0144] The embodiments of the present invention are described with reference to the flowcharts and / or block diagrams of the methods, terminal devices (systems), and computer program products according to the embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of the processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1A device that provides the functions specified in a block or multiple blocks.
[0145] These computer program instructions may also be stored in a computer readable memory capable of directing a computer or other programmable data processing terminal device to operate in a specific manner, so that the instructions stored in the computer readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0146] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable terminal device to implement the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0147] Although the preferred embodiments of the present invention have been described, those skilled in the art may make other changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the embodiments of the present invention.
[0148] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or terminal device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or terminal device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or terminal device including the elements.
[0149] The above describes in detail a compatibility layer transplantation method, a compatibility layer transplantation device, an electronic device, and a readable storage medium provided by the present invention. Specific examples are used herein to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. At the same time, for those skilled in the art, according to the idea of the present invention, there will be changes in the specific implementation methods and application scopes. In summary, the content of this specification should not be understood as a limitation on the present invention.
Claims
1. A compatibility layer transplantation method, characterized in that: include: Obtaining a compatibility layer global source code, a compatibility layer building tool source code, a compatibility layer kernel library, and a compatibility layer service source code of a first processor architecture; In the compatibility layer global source code, adding a declaration definition source code corresponding to a second processor architecture related to the processor; In the compatibility layer construction tool source code, modifying the assembly code of the first processor architecture into the assembly code of the second processor architecture; In the compatibility layer kernel library, adding kernel functions corresponding to the second processor architecture; Modifying the compatibility layer service source code so that the compatibility layer service supports the second processor architecture; The compatibility layer, the compatibility layer kernel library and the compatibility layer service are compiled according to the compatibility layer global source code, the compatibility layer construction tool source code, the compatibility layer kernel library and the compatibility layer service source code.
2. The method according to claim 1, characterized in that The adding of the declaration definition source code corresponding to the second processor architecture related to the processor in the global source code of the compatibility layer includes: In the header file of the global source code of the compatibility layer, keyword judgment, processor register information, processor flag information and macro definition corresponding to the second processor architecture are added.
3. The method according to claim 1, characterized in that The modifying the assembly code of the first processor architecture into the assembly code of the second processor architecture comprises: Adding assembly code corresponding to the macro of the second processor architecture to the output import conversion function of the compatibility layer construction tool source code; Modify the function of the source code of the compatibility layer construction tool, which is used to insert the distribution jump code when generating the dynamic library, into a function implemented by the assembly code of the second processor architecture; The function of the compatible layer construction tool source code for generating a pile function is modified into a function implemented by the assembly code of the second processor architecture, and a character string recording the position of the pile function generated is added; In the declaration file of the compatibility layer construction tool source code, the assembly code of the macro judgment processing of the second processor architecture is added.
4. The method according to claim 1, characterized in that: The kernel function includes an exception handling function, a start function and a signal function. In the compatible layer kernel library, adding the kernel function corresponding to the second processor architecture includes: Adding an exception handling function for capturing exceptions or interrupts and a start function for calling when creating a process under the current directory of the compatibility layer kernel library; Adding a start function to be called when creating a process in the system directory corresponding to the second processor architecture; Register a signal function corresponding to the second processor architecture.
5. The method according to claim 1, characterized in that The modifying the compatibility layer service source code so that the compatibility layer service supports the second processor architecture includes: Macros related to the second processor architecture are added to thread-related files, mapping-related files, and protocol definition files of the compatibility layer service source code.
6. A compatible layer transplantation device, characterized in that: include: A source code acquisition module, used to acquire the compatibility layer global source code, compatibility layer construction tool source code, compatibility layer kernel library and compatibility layer service source code of the first processor architecture; A source code adding module, used for adding a declaration definition source code corresponding to a second processor architecture related to the processor in the global source code of the compatibility layer; An assembly modification module, used to modify the assembly code of the first processor architecture into the assembly code of the second processor architecture in the source code of the compatibility layer construction tool; A kernel function adding module, used for adding kernel functions corresponding to the second processor architecture in the compatibility layer kernel library; A service source code modification module, used to modify the compatibility layer service source code so that the compatibility layer service supports the second processor architecture; The compiling module is used to compile the compatibility layer, the compatibility layer kernel library and the compatibility layer service according to the compatibility layer global source code, the compatibility layer construction tool source code, the compatibility layer kernel library and the compatibility layer service source code to obtain the compatibility layer, the compatibility layer kernel library and the compatibility layer service.
7. The device according to claim 6, characterized in that The source code adding module includes: The source code adding submodule is used to add keyword judgment, processor register information, processor flag information and macro definition corresponding to the second processor architecture in the header file of the global source code of the compatibility layer.
8. The device according to claim 6, characterized in that The assembly modification module includes: A first modification submodule is used to add assembly code corresponding to the macro of the second processor architecture in the output import conversion function of the compatibility layer construction tool source code; A second modification submodule is used to modify the function of the source code of the compatibility layer construction tool used for inserting distribution jump codes when generating dynamic libraries into a function implemented by the assembly code of the second processor architecture; The third modification submodule is used for modifying the function of the compatible layer construction tool source code for generating a pile function into a function implemented by the assembly code of the second processor architecture, and adding a character string recording the position of the generated pile function; The fourth modification submodule is used to add the assembly code of the macro judgment processing of the second processor architecture in the declaration file of the compatibility layer construction tool source code.
9. The device according to claim 6, characterized in that The kernel function includes an exception handling function, a start function and a signal function, and the kernel function adding module includes: A first adding submodule is used to add an exception handling function for capturing exceptions or interrupts and a start function for calling when creating a process in the current directory of the compatible layer kernel library; A second adding submodule, used to add a start function called when creating a process under the system directory corresponding to the second processor architecture; The function registration submodule is used to register the signal function corresponding to the second processor architecture.
10. The device according to claim 6, characterized in that The service source code modification module includes: The macro adding submodule is used to add macros related to the second processor architecture in the thread-related files, mapping-related files, and protocol definition files of the compatibility layer service source code.
11. An electronic device, characterized in that: include: processor; A memory for storing a computer program, wherein when the computer program is executed by the processor, the processor implements the method steps described in any one of claims 1 to 5.
12. A readable storage medium, characterized in that: When the instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to perform one or more of the methods described in method claims 1-5.