CN116302332A - Simulator processing method, simulator processing device, computer equipment and storage medium - Google Patents

Simulator processing method, simulator processing device, computer equipment and storage medium Download PDF

Info

Publication number
CN116302332A
CN116302332A CN202310175104.5A CN202310175104A CN116302332A CN 116302332 A CN116302332 A CN 116302332A CN 202310175104 A CN202310175104 A CN 202310175104A CN 116302332 A CN116302332 A CN 116302332A
Authority
CN
China
Prior art keywords
loop structure
real
blocking
operating system
target
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202310175104.5A
Other languages
Chinese (zh)
Inventor
王衍豪
谢禹翀
程越强
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Weilai Software Technology Shanghai Co ltd
Original Assignee
Weilai Software Technology Shanghai Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Weilai Software Technology Shanghai Co ltd filed Critical Weilai Software Technology Shanghai Co ltd
Priority to CN202310175104.5A priority Critical patent/CN116302332A/en
Publication of CN116302332A publication Critical patent/CN116302332A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/455Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/30Arrangements for executing machine instructions, e.g. instruction decode
    • G06F9/30098Register arrangements
    • G06F9/30101Special purpose registers
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The present disclosure relates to a simulator processing method, apparatus, computer device, and storage medium. The simulator is used for simulating a virtual hardware system comprising core equipment and external equipment for running a real-time operating system, and the processing method comprises the following steps: identifying a function body corresponding to firmware of the real-time operating system, and determining at least one target circulation structure for representing external equipment state detection in the function body; determining a blocking loop structure that causes loop blocking from the at least one target loop structure; and changing the value of a target state register of the external equipment corresponding to the blocking loop structure to indicate the real-time operating system to exit the blocking loop structure. The method can bypass the dead circulation state without manually processing the value of the state register simulated by the simulator in the processing process of the real-time operating system, and can automatically process the blockage caused by the blockage circulation structure.

Description

Simulator processing method, simulator processing device, computer equipment and storage medium
Technical Field
The disclosure relates to the technical field of simulation, and in particular relates to a processing method and device of a simulator, computer equipment and a storage medium.
Background
With the development of the internet of things, for example, a large number of real-time operating systems are operated in intelligent automobiles and various household hardware devices, and various tasks with high real-time requirements are processed through the real-time operating systems.
Currently, a corresponding system-wide simulation technique has emerged for a real-time operating system, which can simulate the logic of firmware (real-time operating system) running therein without hardware, and debug and test the firmware. In order to be real-time, the real-time operating system usually removes the abstraction of the middle layer and directly interacts with the peripheral equipment of the bottom layer.
This requires the real-time operating system to determine whether the peripheral is in a ready state by the value in the status register of the target peripheral, and is typically expressed in the system by looping through the value in the peripheral register for a timeout period, determining whether the value indicates in a ready state, exiting the loop if ready, or else requesting to exit the loop until the timeout has ended, but this approach may trap into a dead loop state, blocking the processing of the real-time operating system. In order to solve the above problems, most of the current methods are performed manually to bypass the dead-loop state.
Disclosure of Invention
In view of the foregoing, it is desirable to provide a processing method, apparatus, computer device, and storage medium for a simulator, which can bypass a dead loop state without requiring manual processing during processing of a real-time operating system, and which does not cause loop blocking.
In a first aspect, the present disclosure provides a processing method of a simulator, where the simulator is configured to simulate a virtual hardware system including a core device and an external device, so as to enable a real-time operating system to run, and the processing method includes:
identifying a function body corresponding to firmware of the real-time operating system, and determining at least one target circulation structure for representing external equipment state detection in the function body;
determining a blocking loop structure that causes loop blocking from the at least one target loop structure;
and changing the value of a target state register of the external equipment corresponding to the blocking loop structure to indicate the real-time operating system to exit the blocking loop structure.
In one embodiment, the determining the at least one target loop structure representing external device state detection in the function body further includes:
determining at least one circulation structure in the function body, and judging whether each circulation structure contains an instruction segment for representing the state detection of external equipment;
Determining a loop structure including the instruction fragment as the target loop structure.
In one embodiment, the instruction segment for characterizing the external device state detection includes:
reading the value of the specific address;
performing numerical processing on the read value; and
comparing the value after the numerical value processing with an immediate value; wherein,,
the specific address is not a stack address to characterize the address of the status register of the detected external device.
In one embodiment, the determining a blocking loop structure that causes loop blocking from the at least one target loop structure further comprises:
operating each target circulation structure, and judging whether each circulation reads the value of the same specific address and the read value is the same in the operation process;
and determining that each cycle in the running process reads the value of the same specific address and the target cycle structure with the same read value is a blocking cycle structure.
In one embodiment, the changing the value of the target status register of the external device corresponding to the blocking loop structure to instruct the real-time operating system to exit the blocking loop structure includes:
changing the value of a single bit in the target status register;
In response to changing the value of the single bit, the real-time operating system does not exit the blocking loop structure, changing the value of the plurality of bits in the target status register to indicate that the real-time operating system exits the blocking loop structure.
In one embodiment, the method further comprises:
and storing the values of the blocking loop structure and the target state register, and responding to repeated operation of the blocking loop structure, and utilizing the values of the target state register to enable the real-time operating system to exit the blocking loop structure.
In one embodiment, before the identifying the function body corresponding to the firmware of the real-time operating system, the method further includes:
loading firmware of a real-time operating system;
the loading the firmware of the real-time operating system comprises the following steps:
acquiring a firmware file, wherein the firmware file comprises processing logic of the real-time operating system;
mapping data corresponding to each segment in the firmware file into memory equipment in the core equipment, wherein the memory equipment is a memory used when the real-time operating system runs;
and determining an operation starting point of the firmware file, and operating the data corresponding to each segment mapped to the memory device according to the operation starting point.
In one embodiment, the method further comprises:
creating a corresponding peripheral template according to the description document of the basic external device used by the real-time operating system in the external device, wherein the peripheral template is used for initializing a memory space corresponding to the basic external device in the memory device into a virtual basic external device;
and responding to the memory space corresponding to the basic external equipment in the memory equipment according to the operation starting point, and triggering the processing logic corresponding to the basic external equipment.
In one embodiment, the determining the running start point of the firmware file, and after running the data mapped to each segment in the memory device according to the running start point, the method further includes:
and in response to the occurrence of an abnormality when an executing program in the real-time operating system accesses the memory device when the real-time operating system runs, distributing a preset page space to the executing program.
In one embodiment, the method further comprises:
identifying communication external equipment which receives first data and/or transmits second data by utilizing a communication channel in the external equipment;
Creating a virtual channel in response to an inability to simulate the communication channel, replacing the communication channel with the virtual channel, wherein the virtual channel is of a different type than the data transmitted by the communication channel;
receiving the first data by utilizing the virtual channel in response to the detection of the first data, converting the first data into data with the same data type as the data transmitted by the communication channel, and writing the converted first data into a memory device in the core device, wherein the memory device is a memory used when the real-time operating system runs;
and responding to the second data to be sent, acquiring the second data from the memory device, converting the second data into data with the same data type as the data transmitted by the virtual channel, and sending the converted second data by utilizing the virtual channel.
In one embodiment, the method further comprises:
simulating the communication channel in response to supporting simulation of the communication channel to obtain a simulation channel;
the analog channel is utilized to receive the first data and/or transmit the second data.
In one embodiment, the method further comprises: in the process of simulating the external equipment by the simulator, under the condition that the external equipment comprises complex external equipment, the complex external equipment comprises: according to the external equipment which cannot be simulated correctly by the operation code and/or the external equipment which generates errors without recording and maintaining the state information of the external equipment;
analyzing the complex external equipment and determining an operation interface corresponding to the complex external equipment;
creating a simulation template according to the operation interface, wherein the simulation template is used for simulating the operation logic of the complex external equipment and maintaining the generated state information after the operation logic is executed;
determining a calling function of the complex external device according to the operation interface and the function body, and generating a hook function according to function entry information and function exit information of the calling function and the simulation template;
the hook function is added to the simulator.
In a second aspect, the present disclosure further provides a processing apparatus of a simulator, where the simulator is configured to simulate a virtual hardware system including a core device and an external device, for running a real-time operating system, and the apparatus includes:
The loop structure determining module is used for identifying a function body corresponding to the firmware of the real-time operating system and determining at least one target loop structure for representing the state detection of the external equipment in the function body;
a blocking loop structure determination module for determining a blocking loop structure that causes loop blocking from the at least one target loop structure;
and the loop structure processing module is used for changing the value of a target state register of the external equipment corresponding to the blocking loop structure so as to indicate the real-time operating system to exit the blocking loop structure.
In a third aspect, the present disclosure also provides a computer device. The computer device comprises a memory storing a computer program and a processor implementing the steps of any of the method embodiments described above when the processor executes the computer program.
In a fourth aspect, the present disclosure also provides a computer-readable storage medium. The computer readable storage medium has stored thereon a computer program which, when executed by a processor, implements the steps of any of the method embodiments.
In a fifth aspect, the present disclosure also provides a computer program product. The computer program product comprises a computer program which, when executed by a processor, implements the steps of any of the method embodiments.
In the above embodiments, a function body corresponding to the firmware of the real-time operating system is identified, and at least one target loop structure representing the detection of the state of the external device in the function body is determined. Since not all the loop structures are used for the status detection of the external device, it is necessary to determine a target loop structure for the status detection of the external device. In addition, not all the target loop structures may cause loop blocking, and a blocking loop structure causing loop blocking may be determined among the target loop structures. After the blocking loop structure is determined, the target state register of the external device corresponding to the blocking loop structure can be determined, so that the value in the target state register can be changed, the real-time operating system can be withdrawn from the blocking loop structure, and the blocking loop structure corresponding to the target state register can not fall into a dead loop state after the real-time operating system is withdrawn. Compared with the prior art, the method and the device can automatically process the circulation blocking caused by the blocking circulation structure, can execute more functional codes, reduce the manual processing process and increase the processing efficiency.
Drawings
In order to more clearly illustrate the embodiments of the present disclosure or the prior art, the drawings that are required in the detailed description or the prior art will be briefly described, it will be apparent that the drawings in the following description are some embodiments of the present disclosure, and other drawings may be obtained according to the drawings without inventive effort for a person of ordinary skill in the art.
FIG. 1 is a flow diagram of a method of processing a simulator in one embodiment;
FIG. 2 is a flow chart of a portion of the step S102 in one embodiment;
FIG. 3 is a flow diagram of a segment of instructions representing external device status detection in one embodiment;
FIG. 4 is a flow chart of step S104 in one embodiment;
FIG. 5 is a flow chart of step S106 in one embodiment;
FIG. 6 is a flowchart illustrating steps performed to load firmware of a real-time operating system in one embodiment;
FIG. 7 is a flowchart illustrating steps for loading a basic external device according to one embodiment;
FIG. 8 is a flowchart illustrating steps of data processing of a communication external device in one embodiment;
FIG. 9 is a flow chart illustrating steps for simulating complex external device processing in one embodiment;
FIG. 10 is a flow chart of a processing method of the simulator in another embodiment;
FIG. 11 is a block diagram of a processing device of the simulator in one embodiment;
FIG. 12 is a schematic diagram of the internal structure of a computer device in one embodiment.
Detailed Description
In order to make the objects, technical solutions and advantages of the present disclosure more apparent, the present disclosure will be further described in detail with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the present disclosure.
It should be noted that the terms "first," "second," and the like in the description and claims herein and in the foregoing figures are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged where appropriate such that the embodiments described herein may be capable of operation in sequences other than those illustrated or described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, apparatus, article, or device that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed or inherent to such process, method, article, or device.
In this document, the term "and/or" is merely one association relationship describing the associated object, meaning that three relationships may exist. For example, a and/or B may represent: a exists alone, A and B exist together, and B exists alone. In addition, the character "/" herein generally indicates that the front and rear associated objects are an "or" relationship.
As mentioned in the background, in the field of intelligent automobiles, more and more sensors and computing resources are added inside the intelligent automobiles, which are usually controlled by embedded electronic control units (ECU, electronic Control Unit) and micro-control units (MCU, microcontroller Unit), the purpose of which is to optimize the control and management of the various devices and subsystems. In order to respond to various requests on the vehicle in time, most of the ECU and MCU adopt a real-time operating system (RTOS, real Time Operating System). It is currently very difficult to simulate the peripheral device for the control of the real-time operating system. The real-time operating system removes the abstraction of the middle layer for real-time and interacts directly with the underlying peripherals (e.g., the sensors mentioned above). This makes it necessary for the simulator to recognize the loading address of the vertical firmware, process the memory access logic, process the operation logic of the peripheral (such as the sensor), etc., so as to ensure the simulation of the normal operation and complete functions of the simulator. Generally, various types of operating systems (including real-time operating systems) provide an abstraction layer for various types of hardware, so that upper level applications are not concerned with underlying hardware logic at all. Similarly, the simulator virtualizes and abstracts the bottom real hardware, so that an upper operating system can not sense the bottom real hardware and still normally operate. The simulator itself is also just an application program, which is an application program that implements hardware logic with software code.
However, this type of situation needs to be handled during processing by the real-time operating system. A type of status register typically exists in peripherals (e.g., sensors or other hardware) that are accessed and operated by the real-time operating system. If the value of the status register is not ready, the value is obtained continuously and the loop can not be exited until the time-out. However, in some cases, a time corresponding to the timeout may not be set, so that endless circulation is caused, and the circulation is not stopped until the circulation state is reached, and the exit cannot be performed. The processing of a real-time operating system, especially simulation, is affected. In addition, since the status registers of different peripheral devices are different, the corresponding values of the trap cycle status are also different, so that for this part, the inspection of the status registers is mainly performed manually, which increases the processing time and reduces the processing efficiency.
Therefore, to solve the above-mentioned problems, as shown in fig. 1, an embodiment of the present disclosure provides a processing method of a simulator, and this embodiment is applied to a terminal for illustration, in which a system-wide simulation technique is generally operated. It will be appreciated that the method may also be applied to a server, and may also be applied to a system comprising a terminal and a server, and implemented by interaction of the terminal and the server. The simulator is used for simulating a virtual hardware system comprising core equipment and external equipment so as to run a real-time operating system. In this embodiment, the method includes the steps of:
S102, identifying a function body corresponding to firmware of the real-time operating system, and determining at least one target circulation structure for representing the detection of the state of the external equipment in the function body.
In general, system-wide simulation techniques refer to the complete simulation of all components in a computer composition at the software level, such that the software of the machine being simulated (including even the operating system) can run in the simulator with little modification. In some embodiments of the present disclosure, the simulator may generally be a software program simulating a real-time operating system and corresponding peripherals, an application program that utilizes software code to implement hardware logic. The real-time operating system can be an operating system which can accept and process external events or data quickly enough, can control the production process or respond quickly to the processing system within a specified time, schedule all available resources to complete real-time tasks and control all real-time tasks to run in a coordinated and consistent manner. The firmware is usually a program written in a memory, and in the hardware device, the firmware is a soul of the hardware device, and the firmware generally determines the functions and performances of the hardware device. A function body is typically the entirety of all code in a programming language that defines the functionality of a function, which refers to a piece of program or code that can be directly referenced by another piece of program or code. State detection may generally be a method of detecting a value of a state register in an external device, thereby determining the state of the external device. The target loop structure may generally be a structure in code that regularly repeatedly executes certain statements, and in some embodiments of the present disclosure may generally be a loop structure used to detect a status register in an external device. The external device may generally include: various sensors, detectors, etc. In some embodiments of the present disclosure, the external device may generally be a peripheral connected to a real-time operating system.
Specifically, in general, the simulator may simulate a core device (for example, a CPU, a memory, etc.), or may simulate an external device (peripheral), so as to simulate a virtual hardware system for running a real-time operating system according to the core device and the external device. The real-time operating system may thus run on a virtual hardware system that is emulated by the emulator. While a real-time operating system is running, it is usually required to rely on interaction with an external device (interaction may include various external hardware devices, storage, processing, etc.). While simulators can typically run on real devices. In some embodiments of the present disclosure, a real-time operating system may be run in the simulator and interact with an external device that is simulated by the simulator. The firmware of a real-time operating system is typically a binary program. The function boundaries corresponding to the functions in the firmware of the real-time operating system can be identified by using a reverse analysis method, and then the function body can be determined according to the function boundaries. The cyclic structure contained therein is determined from the function volume. After determining the loop structure, not all loop structures are used for status detection of the external device. It is therefore necessary to determine at least one loop structure for performing the external device detection among all loop structures, which may be the target loop structure. Typically, each target loop structure may correspond to a status register in the external device, i.e. typically, one target loop structure is used to obtain the value of the status register of one external device. Therefore, the target circulation structure can acquire the value in the status register of the external equipment, and the real-time operating system can detect the status of the external equipment according to the value.
S104, determining a blocking circulation structure which causes circulation blocking from the at least one target circulation structure.
Where loop blocking may generally be a state in which the corresponding state register value is always acquired using the loop structure and cannot be exited.
In particular, because not all target loop structures may cause loop blocking, the target loop structures may be analyzed to determine loop structures in the target loop structures that cause loop blocking, which may be blocking loop structures.
In some exemplary embodiments, whether the circulation blocking condition occurs may be determined according to the memory information of the external device read by the target circulation structure, and if the memory information of the external device read by the target circulation structure is the same each time, it may be determined that the circulation blocking condition occurs in the target circulation structure, where the target circulation structure may be a blocking circulation structure.
S106, changing the value of a target state register of the external device corresponding to the blocking loop structure to indicate the real-time operating system to exit the blocking loop structure.
The value of the target status register may be a bit value, the bit may be a bit in a binary digit, and the measurement unit of the information amount is the minimum unit of the information amount.
In particular, the target status register of the external device mostly marks the change of status by a change of bit value. Therefore, the bit in the target state register of the external device simulated by the simulator can be assigned, and the value of the bit in the target state register is changed, so that the real-time operating system exits the blocking loop structure. And the subsequent use of the blocking circulation structure can not generate circulation blocking condition when the value of the target state register of the external equipment is acquired.
In the above embodiments, a function body corresponding to the firmware of the real-time operating system is identified, and at least one target loop structure representing the detection of the state of the external device in the function body is determined. Since not all the loop structures are used for the status detection of the external device, it is necessary to determine a target loop structure for the status detection of the external device. In addition, not all the target loop structures may cause loop blocking, and a blocking loop structure causing loop blocking may be determined among the target loop structures. After the blocking loop structure is determined, the target state register of the external device corresponding to the blocking loop structure can be determined, so that the value in the target state register can be changed, the real-time operating system can be withdrawn from the blocking loop structure, and the blocking loop structure corresponding to the target state register can not fall into a dead loop state after the real-time operating system is withdrawn. Compared with the prior art, the method and the device can automatically process the circulation blocking caused by the blocking circulation structure, can execute more functional codes in the same time, reduce the manual processing process and increase the processing efficiency.
In one embodiment, as shown in fig. 2, the determining at least one target loop structure that represents external device state detection in the function body further includes:
s202, determining at least one circulation structure in the function body, and judging whether each circulation structure contains an instruction segment representing the detection of the state of the external equipment.
S204, determining a loop structure containing the instruction fragments as the target loop structure.
The instruction segment may be an instruction for detecting a state of the external device.
Specifically, a loop structure composed of basic blocks can be identified from the connection relation before the basic blocks of the codes in the function body. A basic block is typically a sequence of sequentially executed statements in a code sequence, typically having only one entry and one exit. The basic blocks corresponding to each code in the function body can be determined through the entry statement and the exit statement in the code. The loop structure in the function body is determined from the basic blocks. And judging whether an instruction segment for detecting the state of the external equipment exists in the circulation structure or not, so as to determine whether instruction information for detecting the external equipment is included in the circulation structure or not. If the above-mentioned instruction segment or instruction information exists in the loop structure, the loop structure containing the above-mentioned instruction segment or instruction information can be determined as a target loop structure, and can be used for detecting the state of the external device.
In other embodiments, there is typically information exiting the loop structure. Typically, there will also be code addresses in the loop structure that jump out of the loop point, and if these codes are triggered, then this will represent exiting the loop structure. Each loop structure typically has instructions that jump out of the loop structure, typically the instruction that follows the instruction segment to which the loop structure corresponds. Depending on the loop structure, one skilled in the art can determine instructions that jump out of the loop structure depending on the actual situation. Therefore, the circulation structure can be screened according to the instruction fragments for representing the state detection of the external equipment and the information for exiting the circulation structure, and the target circulation structure can be determined. The target circulation structure may be one or a plurality of target circulation structures.
In this embodiment, since not all the loop structures are used for detecting the state of the external device, the loop structures can be screened according to the instruction segment representing the state detection of the external device, so that the processing speed and the processing efficiency can be improved.
In one embodiment, as shown in fig. 3, the instruction segment for characterizing the external device status detection includes:
S302, reading the value of a specific address;
s304, performing numerical processing on the read value; and
s306, comparing the value after the numerical value processing with an immediate value; wherein the specific address is not a stack address to characterize the address of the status register of the detected external device.
The specific address may generally refer to a memory address of the external device. The numerical processing may include: shift operation, AND operation, OR operation, etc. An immediate may generally be a proper noun in an assembly that represents a type of operand, typically a number, such as 0x1. The instruction compared to the immediate is similar to cmp reg,0x1 compares instruction information. Wherein cmp is understood to be compare, which may be an assembled form of instructions, reg represents registers in the instruction architecture, and 0x1 may be an immediate, which typically occurs in a loop structure. The stack address may typically be a special memory address.
Specifically, the real-time operating system generally includes some logic for detecting states such as whether different peripherals (external devices) are ready, and the firmware can only operate normally when the values in the status registers of the external devices meet certain conditions, otherwise the system can exit overtime. Therefore, after each loop structure in the function body is determined, it is necessary to determine whether or not each loop structure is a loop structure that performs state detection on the external device. Since the decision logic of the loop structure for performing state detection on the external device usually takes a value from the internal memory of the external device, then performs some operations on the value, including shifting, and/or comparing with an immediate value after performing an equal-value operation. Thus, the following can be used: the target circulation structure is screened by the instruction information of 'taking the value from the internal memory, carrying out numerical operation and comparing with the immediate data'.
In some exemplary embodiments, for example, the comparison is performed after the numerical processing with the immediate, the result of the explicit comparison is not required, only the presence of the compare instruction is known, one operand in the instruction is the immediate, and then the "value from memory, the numerical operation is performed and compared with the immediate" is identified, the instruction fragment conforming to such a pattern that can be used to identify the target loop structure in the loop structure. The internal access value is generally understood as reading information in the memory from the memory address of the external device, or taking the value. After reading the information or the value in the memory, the subsequent operation can be performed by using the information or the obtained value in the memory.
In addition, the specific address is not a stack address. In some embodiments of the present disclosure, when a specific address is a stack address, it is generally the case that a condition variable requiring removal of loop exit is a temporary variable, where some functions are generally implemented by a loop in a function, which is irrelevant to state detection of an external device, i.e., the stack address is not used for performing state detection on the external device. Therefore, deletion is required to remove extraneous effects.
In one embodiment, as shown in fig. 4, the determining a blocking loop structure that causes loop blocking from the at least one target loop structure includes:
s402, running each target circulation structure.
S404, judging whether the same specific address value is read every time the cycle is in the running process, and the read values are the same.
S406, determining that the target loop structure with the same read value and the same read value reads the same specific address every time of the loop in the running process is a blocking loop structure.
S408, otherwise, the target loop structure is not a blocking loop structure.
Specifically, a binary program corresponding to firmware of the real-time operating system needs to be run. During the running of the binary program, the respective target loop structure determined above is typically also in the binary program. Thus, when running to the target loop structure, it can be seen from the above embodiments that the target loop structure is typically a structure in which values of specific addresses are read and then compared. The value of the specific address read in the target loop structure and the information obtained after the reading can be acquired. In general, the value of the specific address read when the target loop structure has loop blocking is the memory address of the same external device, and the read value is not changed. It is possible to determine whether the value of the specific address read per cycle and the value read by using the target loop structure are the same every time the target loop structure is operated during the operation. If not identical, it can be determined that the target loop structure is not normally loop indefinitely, i.e., does not cause loop blocking, which is not normally a blocking loop structure. If the target circulation structure is the same, it can be determined that the target circulation structure is normally subjected to infinite circulation, thus causing circulation blockage, and the target circulation structure is determined to be a blocked circulation structure.
In this embodiment, in general, not all target loop structures will cause loop blocking, so that a blocking loop structure that will cause loop blocking needs to be found in the determined target loop structures, and then the target state registers of the external devices corresponding to the blocking loop structures need not be processed, so that the processing speed can be improved.
In one embodiment, as shown in fig. 5, the changing the value of the target status register of the external device corresponding to the blocking loop structure to instruct the real-time operating system to exit the blocking loop structure includes:
s502, changing the value of a single bit in the target state register.
S504, judging whether the real-time operating system exits the blocking loop structure.
S506, in response to changing the value of the single bit, the real-time operating system does not exit the blocking loop structure, changing the value of the plurality of bits in the target status register to indicate that the real-time operating system exits the blocking loop structure.
S508, in response to changing the value of the single bit or the values of the plurality of bits, the real-time operating system exits the blocking loop structure, saves and marks the value of the single bit or the values of the plurality of bits.
Wherein the value of the plurality of bits may generally be a value of at least two bits, the number of bits in the corresponding multi-bit value may be different according to different status registers, and in some embodiments of the present disclosure, the specific number of bits in the multi-bit value is not limited.
In particular, in a target status register in an external device, the value of a single bit or the value of multiple bits is changed to identify a change in status. Therefore, firstly, a certain single bit in the target state register can be assigned, the assignment is changed into 0 or 1, after the assignment, the execution of the blocking loop structure corresponding to the target state register is continued, and if the real-time operating system exits the blocking loop structure corresponding to the target state register after the execution, the corresponding bit is saved and marked as the single bit. If the real-time operating system does not exit the blocking loop structure corresponding to the target register after changing the single bit, the values of the multiple bits need to be changed, the assignment of the multiple bits in the target state register is changed, the blocking loop structure in the real-time operating system is continuously executed after the assignment, if the real-time operating system exits the blocking loop structure after the execution, the corresponding bits are saved, and the values corresponding to the blocking loop structure are marked as the values of the multiple bits.
In some exemplary embodiments, for example, the value of the destination register may be an 8-bit value (assuming 11000011), and when changing the value of the destination register, it may be possible to first see if the blocking loop structure can be exited (e.g., only the first bit, 11000010, changed and then see if the loop structure can be exited, if the loop structure is not exited, the first bit may be restored, then the second bit, 11000001, changed only 1 bit each time) by changing the value of the single bit, so it is necessary to remember what single bit value the change is.
If all single bit positions are changed, or if the loop blocking result is not exited, the change of the values of the multiple bits may be changed (e.g., the values of two bits may be changed first, the first bit change is guaranteed, and one more bit change is added accordingly, i.e., 11000000, then 11000110, and then 11001010 is retried, and the analogy is repeated, each time, changing the values of two three or more bits until the blocking loop structure can be exited).
Typically, the data structure may be used in the simulator code to identify the address location of the bit corresponding to the bit value or values exiting the loop structure and then stored in the data structure corresponding to the address. The purpose of the save and flag is to make use of this saved bit information to resolve the blocking problem faster the next time this blocking loop structure is encountered again.
In some exemplary embodiments, the manner in which the exit from the blocking loop structure is determined may be to determine the code address of the exit from the loop point in the blocking loop structure, which if triggered, would be indicative of the exit from the blocking loop structure. Each loop has instructions that jump out of the loop structure, typically the next instruction of the loop instruction fragment, from which it can be determined whether a blocked loop structure has been exited.
In this embodiment, the loop structure of the target state register can be exited by changing the single-bit value and the multi-bit value, so that blocking caused by the blocking loop structure corresponding to the target state register can be automatically processed, the manual processing process and time are reduced, and the efficiency is improved.
In one embodiment, the method further comprises: and storing the values of the blocking loop structure and the target state register, and responding to repeated operation of the blocking loop structure, and utilizing the values of the target state register to enable the real-time operating system to exit the blocking loop structure.
Specifically, the above embodiments may save (dump), tag, and load (load) the already processed blocking loop structure and corresponding bit values during processing. The blocking loop structure is saved and marked and the real-time operating system is caused to exit the value of the target state register of the blocking loop structure. And when the blocking loop structure is repeatedly operated, a load mechanism can be used for assigning the stored numerical value to the corresponding bit in the target state register to quickly pass through the blocking point in the blocking loop structure so as to exit the blocking loop structure.
In this embodiment, by storing the processed blocking loop structure and the bit value corresponding to the target status register, when the blocking loop structure is executed again, the real-time operating system can exit the blocking loop structure without attempting to change the value of the single bit or the multiple bits of the target status register again, and can directly use the stored bit value for processing, thereby improving the processing speed.
In one embodiment, before the identifying the function body corresponding to the firmware of the real-time operating system, the method further includes:
loading firmware of a real-time operating system;
the real-time operating system may be a real-time operating system that the simulator needs to simulate. The firmware in the real-time operating system may be a file that includes functions such as CPU behavior and system interrupt of the real-time operating system.
Specifically, firmware of the real-time operating system can be loaded, and core logic (except for the part which is interacted with the external device) of the firmware of the real-time operating system is normally simulated and operated.
Further, as shown in fig. 6, the loading firmware of the real-time operating system includes:
s602, obtaining a firmware file, wherein the firmware file comprises processing logic of the real-time operating system.
The firmware file is usually a real-time operating system firmware, and is a file that needs to be executed when the simulator simulates the real-time operating system, and in general, the logic of the real-time operating system is in the firmware.
S604, mapping the data corresponding to each segment in the firmware file to a memory device in the core device, wherein the memory device is a memory used by the real-time operating system in running.
In general, an executable binary program includes multiple types of segments, such as a code segment (text), a data segment (data), and a bss segment, where each segment includes corresponding code or data. When the program is loaded, it is necessary to map the segments to the exact locations for proper operation. Similarly, the process also exists when an ELF file (firmware file) corresponding to the real-time operating system is loaded. As noted in the above embodiments, the core device may generally include a CPU, a memory, and the like, and the memory device may generally refer to a memory simulated by the simulator. In some embodiments of the present disclosure, the memory device may generally be a memory used by a real-time operating system running or a memory space of a used memory.
Specifically, the loading can be performed according to the format of the firmware file, and binary data of each segment is mapped into a memory space used when the real-time operating system runs during loading. The memory space may typically be the memory space of a memory device in a core device emulated by the emulator.
S606, determining an operation starting point of the firmware file, and operating the data corresponding to each segment mapped to the memory device according to the operation starting point.
Wherein the starting point of the operation may generally be the starting point of the operation. Typically, execution of a system or a program needs to start from a starting point (start of operation) or otherwise there is no way to operate correctly.
Specifically, the function information in the identified firmware file may be utilized to extract the running start point from the firmware of the real-time operating system by analyzing or reversely analyzing the function information based on the source code. After determining the running start point, the real-time operating system needs to be simulated, so that the real-time operating system (except the part which performs interactive processing with the external device) needs to be normally simulated and run according to the data corresponding to each segment in the memory device (the memory simulated by the simulator and used for running the real-time operating system) mapped by the running start point.
It will be appreciated that source code analysis or reverse analysis is merely for illustration, and that the method is determined by corresponding firmware of the real-time operating system on different architectures during actual application, and that the starting point of the operation of the firmware on different architectures may be determined according to the corresponding method, and that the method for determining the starting point of the operation is not specifically limited in some embodiments of the present disclosure.
In this embodiment, the firmware loading address can be automatically identified by loading the firmware of the real-time operating system and mapping the data corresponding to each bit in the firmware into the corresponding memory space. In addition, the loading addresses and the running starting points of different firmware are different, the memory spaces where different sections of the firmware are located are different, and the automatic mapping processing is needed to perform correct running and data access, so that the normal running of the real-time operating system is ensured.
In one embodiment, as shown in fig. 7, the method further comprises:
s702, creating a corresponding peripheral template according to the description document of the basic external device used by the real-time operating system in the external device, wherein the peripheral template is used for initializing the memory space corresponding to the basic external device in the memory device into a virtual basic external device.
And S704, responding to the operation starting point, and operating to the memory space corresponding to the basic external equipment in the memory equipment, and triggering the processing logic corresponding to the basic external equipment.
The base external device may be, for example, a clock, a PendSV, etc. The description document may be a document in which a usage method or an execution method of the corresponding basic external device is stored, in which processing logic of the corresponding basic external device exists, such as a clock interrupt, a task switch interrupt, and the like. The specific form of the peripheral template is not particularly limited in some embodiments of the present disclosure, as long as the corresponding function thereof can be realized.
Specifically, for basic external devices in external devices required to be used when the real-time operating system operates, a corresponding peripheral template can be constructed according to the instruction architecture description document corresponding to each basic external device. The external template can initialize the memory space corresponding to the basic external device (the memory space corresponding to the basic external device in the memory used when the real-time operating system operates) to be a virtual basic external device when the basic external device is accessed under the normal condition. When the firmware code in the real-time operating system is executed to the memory space corresponding to the basic external equipment according to the running starting point, the corresponding interrupt is triggered, and the processing logic of the preset value is triggered, so that the simulation of the basic external equipment is completed. The processing logic of the preset value is usually processing logic of the basic external device, for example, the basic external device is a clock, and may be a clock interrupt.
In this embodiment, since the external device is often used in the firmware of the real-time operating system, and the address of the external device does not explicitly exist in the segment of the firmware, and the direct access of the external device can generate the problem of abnormal memory access, the memory space corresponding to the basic external device can be processed according to the peripheral template, and when the real-time operating system operates, the memory space corresponding to each basic external device can be correctly processed, so as to complete the simulation of the basic external device, ensure that the basic external device can operate normally, and further ensure that the real-time operating system can operate normally.
In one embodiment, the determining the running start point of the firmware file, and after running the data mapped to each segment in the memory device according to the running start point, the method further includes:
and in response to the occurrence of an abnormality when an executing program in the real-time operating system accesses the memory device when the real-time operating system runs, distributing a preset page space to the executing program.
Specifically, if an exception occurs when an executing program in the real-time operating system accesses a memory device (more specifically, accesses a memory space of the memory device) while the real-time operating system is running, a memory address in the memory space may not be mapped or the memory space may be used without being declared in advance. Typically, a page space is dynamically allocated to an executing program, and the executing program is normally operated by using the page space.
In some exemplary embodiments, for example, the execution program now has to access that the memory address in the memory space is 0xfffff123, but there is no allocation, and the page space of 0xfffff000-oxffffffff may be dynamically allocated to the execution program, and the execution program may continue to run normally.
In this embodiment, by allocating a preset page space, the execution program can also operate normally when the access to the memory device is abnormal, so as to avoid unnecessary error reporting.
In one embodiment, as shown in fig. 8, the method further comprises:
s802, identifying the communication external device which receives the first data and/or transmits the second data by using the communication channel in the external device.
Wherein the communication channel is typically a channel in communication with third party software or hardware, such as a CAN channel or a BUS channel. The device corresponding to the real-time operating system firmware comprises a Chip (CPU), peripherals and other elements. The external device communicates with this device and typically sends out a data packet (first data).
Specifically, the external equipment which is simulated by the simulator and has external data flow interaction is identified, and the equipment can be communication external equipment. Performing the interaction may generally include: the communication external device receives the first data sent by the external device and/or sends the second data to the external device by utilizing a communication channel.
In some exemplary embodiments, the identification of the communication external device in the external device may be performed by a function code logic feature based on a function name, a key in the function (e.g., whether or not the function contains CAN).
S804, judging whether the communication channel can be simulated.
And S806, in response to the fact that the communication channel cannot be simulated, creating a virtual channel, and replacing the communication channel by using the virtual channel, wherein the virtual channel is different from the data type transmitted by the communication channel, and the virtual channel can be a communication channel created by a simulator and used for replacing the communication channel.
In particular, the simulator may determine whether the simulated communication channel is enabled, and if the simulator is unable to do so, a virtual channel needs to be created. Typically, the virtual channel is a network communication channel supported by the simulator running host. And replacing a communication channel for actually communicating between the communication external device and the external device by using the virtual channel.
S808, receiving the first data by using the virtual channel in response to the detection of the first data, converting the first data into data with the same data type as the data transmitted by the communication channel, and writing the converted first data into a memory device in the core device, wherein the memory device is a memory used when the real-time operating system runs.
Specifically, when the first data transmitted by the external device is detected, the data receiving end of the channel in the simulator needs to use the virtual channel to receive the first data. And because the virtual signal is different from the original data type transmitted by the communication channel after the virtual channel is used, the data receiving end needs to convert the first data received by the virtual channel into the first data conforming to the communication channel type in order to ensure the consistency with the real scene. Therefore, the received first data needs to be converted into data with the same data type as the data transmitted by the communication channel, and the converted first data is written into a memory device (a memory used when the real-time operating system is running) used when the real-time operating system is running. Further, the detection of the first data may be performed at a stable loop point of the real-time operating system. The stable loop point is typically a period of time after completion of the start-up and initialization of the tasks that will enter IDLE tasks like IDLE, and the period of IDLE tasks may be characterized by executing IDLE tasks for a substantial portion of the clock cycle.
In some exemplary embodiments, for example, virtual channels transmit data of type a, communication channels transmit data of type B, and the simulator cannot simulate the communication channels. Therefore, the external device and the hardware device simulated by the simulator can only transmit the data of the type A by using the virtual channel when communicating. The simulator needs to simulate the operation under the real scene, and the real operation is usually that the data of the type B is stored in the real-time operating system, so that the data of the type A needs to be converted into the data of the type B for storage.
In other exemplary embodiments, it should be noted that, in the conventional technology, at the data receiving end of the external communication device, when a data signal flows to the data interface of the external communication device, a corresponding interrupt is triggered, and then a callback function (corresponding to the data receiving processing logic) in the interrupt vector table is called and data analysis is performed. The complete simulation of this process requires the simulation of the interrupt controller and external data to the interrupt triggered process, which increases the difficulty and effort of simulation.
Therefore, in order to reduce the simulation difficulty and workload, firstly, searching callback functions received by the data stream and corresponding interrupt vector numbers; then detecting a stable circulating point of the real-time operating system, and adding external data receiving judgment logic at the stable circulating point; when first data sent by the external device is monitored, the first data is received, after the first data is received, interruption is sent to a chip (for example, a CPU) in the core device, after the chip receives a signal, a corresponding interruption number is actively added into an interruption controller, and after a callback function is triggered, the first data is written into a memory used when the real-time operating system runs, wherein how to process the data sent by the external device and the triggered interruption can be determined according to the interruption number. Interrupts are typically engines that the system handles various critical logic such as external data, clocks, task switches, etc., and if there is no interrupt, the real-time operating system will not operate properly.
And S810, in response to the need of sending the second data, acquiring the second data from the memory device, converting the second data into data with the same data type as the data transmitted by the virtual channel, and sending the converted second data by using the virtual channel.
Specifically, when the real-time operating system running on the simulator or the virtual hardware system needs to send the second data through the communication external device, the second data can be obtained from the memory device (memory) used when the real-time operating system runs. Typically, the data stored in the memory device (memory) used by the real-time operating system when running is typically data that conforms to the actual communication channel type. The simulator cannot simulate the communication channel, so that the second data needs to be converted into data conforming to the type of the virtual channel, and then the communication external device sends the converted second data to the external device by utilizing the virtual channel.
In addition, after receiving and/or transmitting data by using the virtual channel, various operation interfaces corresponding to the communication channel process the data, the processed data can be correspondingly transmitted to the virtual channel, but not to the communication channel.
And S812, simulating the communication channel in response to supporting simulation of the communication channel, so as to obtain a simulation channel.
S814, receiving the first data and/or transmitting the second data by using the analog channel.
Specifically, when the simulator can simulate the communication channel, the simulator is utilized to simulate the communication channel, and the simulated channel is obtained after the simulation. For example, when the external communication device for network communication uses CAN, CAN be simulated to obtain vCAN, and CAN is replaced by vCAN. CAN frame transmission is also possible using vCAN. Because the analog signal obtained after the simulation and the data type transmitted by the communication channel are the same, the data can be directly received or transmitted by using the analog channel without data conversion.
In this embodiment, when the communication external device is operated in normal circumstances, the communication external device is not an independent individual, and needs to perform data flow interaction with the external device, but the data flow interaction process is complex, the interaction types are various, and the interaction channels or interfaces are not uniform, so that it can be determined whether the communication channels can be simulated, if so, the simulated signals after simulation can be directly used for transmission, and if not, a corresponding virtual channel is created, then data type conversion is performed, and it is ensured that the simulator can simulate the interaction process of the data flow of the communication external device.
In one embodiment, as shown in fig. 9, the method further comprises:
s902, in the process of simulating the external equipment by the simulator, under the condition that the external equipment comprises complex external equipment, the complex external equipment comprises: and (3) according to the external equipment which cannot be simulated correctly by the operation code and/or the external equipment which generates errors without recording and maintaining the state information of the external equipment. Analyzing the complex external equipment and determining an operation interface corresponding to the complex external equipment;
s904, creating a simulation template according to the operation interface, wherein the simulation template is used for simulating the operation logic of the complex external equipment and maintaining the generated state information after the operation logic is executed.
Wherein the operation interface may be an API interface in general. The particular type of simulation template is not limiting in some embodiments of the present disclosure, so long as the above-mentioned functionality can be implemented.
Specifically, in the process of simulating an external device by a simulator, there are usually some complete simulation operations according to the system on the operation instructions of the hardware device, which cannot realize the operation logic. For example, the operation on FlexSPI itself is not completed by firmware code, but the corresponding operation is completed by external hardware when API (Application Programming Interface) is called. Meanwhile, the operation of the real-time operating system on the external device is usually accompanied with the recording and maintenance of the state information, if only the behavior of the external device is simulated (only the operation code is simulated) but the state information of the external device is not maintained, the operation of the real-time operating system on the external device is caused to be in error due to the lack of the historical operation record information state, so that the external device which is required to simulate the behavior or the operation logic of the external device and also maintain the state information after the corresponding behavior or the operation logic of the external hardware device is executed each time can be called as a complex external device. Therefore, if there is a complex external device in the process of simulating the external device by the simulator, unexpected errors (for example, firmware running errors indicate abnormal states of hardware devices) will be usually encountered according to the traditional simulation mode when the complex external device is simulated, so that additional processing needs to be performed on the complex external device.
Specifically, when the complex external device is simulated, the complex external device comprises: operational logic (operational behavior) and state maintenance logic (maintenance state information). The operation logic is generally an operation such as reading and writing performed on the corresponding operation API by the system when the system calls the operation API, and the state maintenance logic is generally an operation for updating the state of the operation such as reading and writing after the operation such as reading and writing. Therefore, the complex external equipment to be simulated needs to be analyzed in turn. To determine the corresponding operation interface of each complex external device. And determining operations such as reading and writing of the operation interface, and updating states after the operations such as reading and writing of the operation interface are performed, so that a simulation template is constructed, and the operation logic and the state maintenance logic of the bottom layer on the complex external device are directly simulated. The simulation templates generally correspond to the operation logic in the complex external device and the state maintenance logic after the operation logic is executed.
In some exemplary embodiments, such as FlexSPI, they include operation logic and state maintenance logic when running, i.e., history operations affect their state, so we need to update their state after each operation, i.e., the system reads and writes to the corresponding operation API when it is called. Because the different types of complex external devices have large differences, each complex external device needs to be specifically analyzed, templates need to be written after analysis, and operation logic and state maintenance logic of the complex external devices are simulated, so that a simulated template is obtained. The simulation templates may generally include: and simulating an operation logic template and a state maintenance logic template. The simulation operation logic template can be used for simulating the operation behavior (operation logic) of the complex external device in general. The state maintenance logic templates may be used to maintain state information (state maintenance logic) after execution of the corresponding behavior or operation logic.
S906, determining a calling function of the complex external device according to the operation interface and the function body, and generating a hook function according to function inlet information and function outlet information of the calling function and the simulation template.
Specifically, the above-mentioned simulation template for determining the complex external device needs to determine under what condition the corresponding logic in the template can be executed. As the functional volumes of the functions in the firmware have been determined in the above embodiments. Because the operation logic and the state maintenance logic of the complex external device need to be simulated, the whole system simulation scheme is usually performed by simulating the bottom peripheral functions, so that symbol information in a function body and an API (operation interface) of the operation are needed to determine the function which needs to be processed and corresponds to the final complex external device. The symbol information comprises names of functions contained in the complex external equipment, entrance and exit positions of the functions and other information. The hook function may then be generated based on the function entry information and the function exit information and the simulation template.
S908 adding the hook function to the simulator.
The hook function usually executes functional logic in the hook function when firmware runs to a certain instruction, usually at a hook point, and specific behaviors are realized in the hook function to realize the simulation of the operation logic and the state maintenance logic of the simulator on the complex external device.
Specifically, a hook function is added to the simulator. When the simulator needs to simulate the complex external device, the simulator usually runs to a hook point of the hook function, and at the moment, functional logic in the hook function is run, so that the simulation of the complex external device is realized.
In some exemplary embodiments, operations such as erasing, writing, etc. of the FLASH device are performed by reading parameters of a function, such as the flexspi_transferring blocking function of the FlexSPI hardware device. The operation is equivalent to that a behavior mapping layer is established between an API for operating the complex external equipment and the simulated complex external equipment, and the operation result is directly acted on a memory space and a register corresponding to the complex external equipment.
In the embodiment, by creating the simulation template, repeated analysis of manual simulation of complex peripheral equipment can be avoided, and the efficiency of full-system simulation is improved. In addition, the hook function is utilized to simulate the complex external equipment, so that the operation behavior of the complex external equipment and the maintenance state information can be simulated at the same time, and unexpected errors can be avoided.
In one embodiment, the present disclosure also provides another simulator processing method, as shown in figure 10,
the firmware of the real-time operating system is loaded first using the binary program and steps S602 to S506 as mentioned in the above embodiments. Then, the target status register in the external device obtained by simulation of the simulator after loading may be processed, for example, steps S102 to S106 mentioned in the above embodiment. The data stream interaction corresponding to the communication external device in the external device obtained by the simulator simulation may also be processed, for example, in steps S802 to S814 mentioned in the above embodiment. In the case of simulating a complex external device, the complex external device may also be simulated by using steps S902 to S908, for example, as mentioned in the above embodiments.
It should be understood that, although the steps in the flowcharts related to the embodiments described above are sequentially shown as indicated by arrows, these steps are not necessarily sequentially performed in the order indicated by the arrows. The steps are not strictly limited to the order of execution unless explicitly recited herein, and the steps may be executed in other orders. Moreover, at least some of the steps in the flowcharts described in the above embodiments may include a plurality of steps or a plurality of stages, which are not necessarily performed at the same time, but may be performed at different times, and the order of the steps or stages is not necessarily performed sequentially, but may be performed alternately or alternately with at least some of the other steps or stages.
Based on the same inventive concept, the embodiments of the present disclosure also provide a processing apparatus of a simulator for implementing the above-mentioned processing method of a simulator. The implementation of the solution provided by the device is similar to the implementation described in the above method, so the specific limitation in the embodiments of the processing device of one or more simulators provided below may be referred to as the limitation of the processing method of the simulator hereinabove, and will not be repeated herein.
In one embodiment, as shown in fig. 11, a processing apparatus 1000 of a simulator is provided, where the simulator is configured to simulate a virtual hardware system including a core device and an external device, for running a real-time operating system, and includes: a loop structure determination module 1002, a blocking loop structure determination module 1004, and a loop structure processing module 1006, wherein:
the loop structure determining module 1002 is configured to identify a function body corresponding to firmware of the real-time operating system, and determine at least one target loop structure that represents detection of a state of an external device in the function body.
A blocking loop structure determination module 1004 is configured to determine a blocking loop structure that causes loop blocking from the at least one target loop structure.
And a loop structure processing module 1006, configured to change a value of a target status register of the external device corresponding to the blocking loop structure, so as to instruct the real-time operating system to exit the blocking loop structure.
In one embodiment of the apparatus, the loop structure determining module 1002 is further configured to determine at least one loop structure in the function body, and determine whether each loop structure includes an instruction segment that characterizes detection of a state of an external device; determining a loop structure including the instruction fragment as the target loop structure.
In one embodiment of the apparatus, the instruction segment for characterizing the external device state detection includes:
reading the value of the specific address;
performing numerical processing on the read value; and
comparing the value after the numerical value processing with an immediate value; wherein,,
the specific address is not a stack address to characterize the address of the status register of the detected external device.
In one embodiment of the apparatus, the blocking loop structure determination module 1004 includes:
and the judging module is used for operating each target circulation structure and judging whether the same specific address value is read every time of circulation in the operation process and the read values are the same.
And the determining submodule is used for determining that the value of the same specific address is read every cycle in the running process and the target cycle structure with the same read value is a blocking cycle structure.
In an embodiment of the apparatus, the bit values comprise: single bit values and multi-bit values; the loop structure processing module 1006 includes:
a single bit value processing module for changing the value of a single bit in the target status register.
A multi-bit value processing module configured to change values of a plurality of bits in the target status register to indicate that the real-time operating system exits the blocking loop structure in response to the real-time operating system not exiting the blocking loop structure after changing the value of the single bit;
and the marking module is used for responding to the change of the single bit value or the plurality of bit values, exiting the blocking loop structure by the real-time operating system, and storing and marking the single bit value or the plurality of bit values.
In one embodiment of the apparatus, the apparatus further comprises: and the repetition processing module is used for storing the blocking loop structure and the value of the target state register, and responding to the repeated operation of the blocking loop structure, and utilizing the value of the target state register to enable the real-time operating system to exit the blocking loop structure.
In one embodiment of the apparatus, the apparatus further comprises: and the firmware loading module is used for loading the firmware of the real-time operating system. The firmware loading module is further configured to obtain a firmware file, where the firmware file includes processing logic of the real-time operating system; mapping data corresponding to each segment in the firmware file into memory equipment in the core equipment, wherein the memory equipment is a memory used when the real-time operating system runs; and determining an operation starting point of the firmware file, and operating the data corresponding to each segment mapped to the memory device according to the operation starting point.
In one embodiment of the apparatus, the firmware loading module includes: the external template creation module is used for creating a corresponding external template according to the description document of the basic external device used by the real-time operating system in the external device, and the external template is used for initializing the memory space corresponding to the basic external device in the memory device into a virtual basic external device; and responding to the memory space corresponding to the basic external equipment in the memory equipment according to the operation starting point, and triggering the processing logic corresponding to the basic external equipment.
In one embodiment of the apparatus, the firmware loading module further includes: and the space allocation module is used for allocating preset page space to the execution program in the real-time operating system in response to the occurrence of an abnormality when the execution program in the real-time operating system accesses the memory device when the real-time operating system runs.
In one embodiment of the apparatus, the apparatus further comprises: the communication external equipment processing module is used for identifying communication external equipment which receives first data and/or transmits second data by utilizing a communication channel in the external equipment; creating a virtual channel in response to an inability to simulate the communication channel, replacing the communication channel with the virtual channel, wherein the virtual channel is of a different type than the data transmitted by the communication channel; receiving the first data by utilizing the virtual channel in response to the detection of the first data, converting the first data into data with the same data type as the data transmitted by the communication channel, and writing the converted first data into a memory device in the core device, wherein the memory device is a memory used when the real-time operating system runs; and responding to the second data to be sent, acquiring the second data from the memory device, converting the second data into data with the same data type as the data transmitted by the virtual channel, and sending the converted second data by utilizing the virtual channel.
In one embodiment of the apparatus, the communication external device processing module is further configured to simulate the communication channel in response to supporting simulation of the communication channel, to obtain a simulated channel; the analog channel is utilized to receive the first data and/or transmit the second data.
In one embodiment of the apparatus, the apparatus further comprises: the complex external equipment simulation module is used for simulating the external equipment in the process of the simulator, and under the condition that the external equipment comprises complex external equipment, the complex external equipment comprises: according to the external equipment which cannot be simulated correctly by the operation code and/or the external equipment which generates errors without recording and maintaining the state information of the external equipment; analyzing the complex external equipment and determining an operation interface corresponding to the complex external equipment; creating a simulation template according to the operation interface, wherein the simulation template is used for simulating the operation logic of the complex external equipment and maintaining the generated state information after the operation logic is executed; determining a calling function of the complex external device according to the operation interface and the function body, and generating a hook function according to function entry information and function exit information of the calling function and the simulation template; the hook function is added to the simulator.
The various modules in the processing means of the simulator described above may be implemented in whole or in part by software, hardware, and combinations thereof. The above modules may be embedded in hardware or may be independent of a processor in the computer device, or may be stored in software in a memory in the computer device, so that the processor may call and execute operations corresponding to the above modules.
In one embodiment, a computer device is provided, which may be a server, and the internal structure of which may be as shown in fig. 12. The computer device includes a processor, a memory, and a network interface connected by a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The database of the computer device is for storing binary program data. The network interface of the computer device is used for communicating with an external terminal through a network connection. The computer program is executed by a processor to implement a method of processing a simulator.
Those skilled in the art will appreciate that the structures shown in FIG. 12 are only block diagrams of portions of structures associated with the disclosed aspects and are not limiting as to the computer device on which the disclosed aspects may be implemented, and that a particular computer device may include more or less components than those shown, or may combine some of the components, or have a different arrangement of components.
In one embodiment, a computer device is provided, comprising a memory and a processor, the memory having stored therein a computer program, the processor implementing the steps of any of the method embodiments described above when the computer program is executed.
In one embodiment, a computer readable storage medium is provided, having stored thereon a computer program which, when executed by a processor, implements the steps of any of the method embodiments described above.
In an embodiment, a computer program product is provided comprising a computer program which, when executed by a processor, implements the steps of any of the method embodiments described above.
Those skilled in the art will appreciate that implementing all or part of the above described methods may be accomplished by way of a computer program stored on a non-transitory computer readable storage medium, which when executed, may comprise the steps of the embodiments of the methods described above. Any reference to memory, database, or other medium used in embodiments provided by the present disclosure may include at least one of non-volatile and volatile memory, among others. The nonvolatile Memory may include Read-Only Memory (ROM), magnetic tape, floppy disk, flash Memory, optical Memory, high density embedded nonvolatile Memory, resistive random access Memory (ReRAM), magnetic random access Memory (Magnetoresistive Random Access Memory, MRAM), ferroelectric Memory (Ferroelectric Random Access Memory, FRAM), phase change Memory (Phase Change Memory, PCM), graphene Memory, and the like. Volatile memory can include random access memory (Random Access Memory, RAM) or external cache memory, and the like. By way of illustration, and not limitation, RAM can be in the form of a variety of forms, such as static random access memory (Static Random Access Memory, SRAM) or dynamic random access memory (Dynamic Random Access Memory, DRAM), and the like. The databases referred to in the various embodiments provided by the present disclosure may include at least one of a relational database and a non-relational database. The non-relational database may include, but is not limited to, a blockchain-based distributed database, and the like. The processors involved in the embodiments provided by the present disclosure may be general-purpose processors, central processing units, graphics processors, digital signal processors, programmable logic, quantum computing-based data processing logic, etc., without limitation thereto.
The technical features of the above embodiments may be arbitrarily combined, and all possible combinations of the technical features in the above embodiments are not described for brevity of description, however, as long as there is no contradiction between the combinations of the technical features, they should be considered as the scope of the description.
The foregoing examples have expressed only a few embodiments of the present disclosure, which are described in more detail and detail, but are not to be construed as limiting the scope of the present disclosure. It should be noted that variations and modifications can be made by those skilled in the art without departing from the spirit of the disclosure, which are within the scope of the disclosure. Accordingly, the scope of the present disclosure should be determined from the following claims.

Claims (10)

1. A processing method of a simulator, wherein the simulator is configured to simulate a virtual hardware system including a core device and an external device, for running a real-time operating system, the processing method comprising:
identifying a function body corresponding to firmware of the real-time operating system, and determining at least one target circulation structure for representing external equipment state detection in the function body;
Determining a blocking loop structure that causes loop blocking from the at least one target loop structure;
and changing the value of a target state register of the external equipment corresponding to the blocking loop structure to indicate the real-time operating system to exit the blocking loop structure.
2. The method of claim 1, wherein determining at least one target loop structure representing external device state detection in the function body further comprises:
determining at least one circulation structure in the function body, and judging whether each circulation structure contains an instruction segment for representing the state detection of external equipment;
determining a loop structure including the instruction fragment as the target loop structure.
3. The method of claim 2, wherein the instruction segment characterizing the external device state detection comprises:
reading the value of the specific address;
performing numerical processing on the read value; and
comparing the value after the numerical value processing with an immediate value; wherein,,
the specific address is not a stack address to characterize the address of the status register of the detected external device.
4. The method of claim 3, wherein said determining a blocking loop structure from said at least one target loop structure that causes loop blocking further comprises:
Operating each target circulation structure, and judging whether each circulation reads the value of the same specific address and the read value is the same in the operation process;
and determining that each cycle in the running process reads the value of the same specific address and the target cycle structure with the same read value is a blocking cycle structure.
5. The method of claim 1, wherein the changing the value of the target status register of the external device corresponding to the blocking loop structure to instruct the real-time operating system to exit the blocking loop structure comprises:
changing the value of a single bit in the target status register;
in response to changing the value of the single bit, the real-time operating system does not exit the blocking loop structure, changing the value of the plurality of bits in the target status register to indicate that the real-time operating system exits the blocking loop structure.
6. The method according to any one of claims 1 to 5, further comprising:
and storing the values of the blocking loop structure and the target state register, and responding to repeated operation of the blocking loop structure, and utilizing the values of the target state register to enable the real-time operating system to exit the blocking loop structure.
7. A processing apparatus of a simulator for simulating a virtual hardware system including a core device and an external device for running a real-time operating system, the apparatus comprising:
the loop structure determining module is used for identifying a function body corresponding to the firmware of the real-time operating system and determining at least one target loop structure for representing the state detection of the external equipment in the function body;
a blocking loop structure determination module for determining a blocking loop structure that causes loop blocking from the at least one target loop structure;
and the loop structure processing module is used for changing the value of a target state register of the external equipment corresponding to the blocking loop structure so as to indicate the real-time operating system to exit the blocking loop structure.
8. A computer device comprising a memory and a processor, the memory storing a computer program, characterized in that the processor implements the steps of the method of any of claims 1 to 6 when the computer program is executed.
9. A computer readable storage medium, on which a computer program is stored, characterized in that the computer program, when being executed by a processor, implements the steps of the method of any of claims 1 to 6.
10. A computer program product comprising a computer program, characterized in that the computer program, when being executed by a processor, implements the steps of the method of any of claims 1 to 6.
CN202310175104.5A 2023-02-27 2023-02-27 Simulator processing method, simulator processing device, computer equipment and storage medium Pending CN116302332A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310175104.5A CN116302332A (en) 2023-02-27 2023-02-27 Simulator processing method, simulator processing device, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310175104.5A CN116302332A (en) 2023-02-27 2023-02-27 Simulator processing method, simulator processing device, computer equipment and storage medium

Publications (1)

Publication Number Publication Date
CN116302332A true CN116302332A (en) 2023-06-23

Family

ID=86831752

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310175104.5A Pending CN116302332A (en) 2023-02-27 2023-02-27 Simulator processing method, simulator processing device, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN116302332A (en)

Similar Documents

Publication Publication Date Title
CN108459962B (en) Code normalization detection method and device, terminal equipment and storage medium
CN108304307B (en) Performance detection method of intelligent contract on block chain
CN103092751B (en) Web application performance test system based on customer behavior model in cloud environment
CN111309734B (en) Method and system for automatically generating table data
CN115934346B (en) Operator automatic detection method and device, electronic equipment and medium
CN110598855A (en) Deep learning model generation method, device, equipment and storage medium
CN113504918A (en) Equipment tree configuration optimization method and device, computer equipment and storage medium
CN113127314A (en) Method and device for detecting program performance bottleneck and computer equipment
CN114911706A (en) Use case recommendation method, device, equipment and storage medium
CN105027089B (en) Core functions detector
CN116662039B (en) Industrial information parallel detection method, device and medium based on shared memory
CN112711427A (en) Method and device for acquiring mirror image file
CN116302332A (en) Simulator processing method, simulator processing device, computer equipment and storage medium
CN114727100B (en) Joint debugging method and device for monitoring equipment
CN116521414A (en) Fault code positioning method, cloud server, system and storage medium
CN115994086A (en) Image processing method and device, storage medium and terminal
CN115202946A (en) Automated testing method, apparatus, device, storage medium, and program product
JP2019179284A (en) Simulation system and simulation program
US9934035B2 (en) Device and method for tracing updated predicate values
CN113626340A (en) Test requirement identification method and device, electronic equipment and storage medium
CN111694729A (en) Application testing method and device, electronic equipment and computer readable medium
CN113220334B (en) Program fault positioning method, terminal equipment and computer readable storage medium
CN116774988B (en) Method and device for releasing frame package mode symbol dependence
US20240004780A1 (en) Parallel execution during application debugging
CN114706715B (en) Control method, device, equipment and medium for distributed RAID based on BMC

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination