CN110737603B - Method and device for replacing functions in ROM - Google Patents

Method and device for replacing functions in ROM Download PDF

Info

Publication number
CN110737603B
CN110737603B CN201810792741.6A CN201810792741A CN110737603B CN 110737603 B CN110737603 B CN 110737603B CN 201810792741 A CN201810792741 A CN 201810792741A CN 110737603 B CN110737603 B CN 110737603B
Authority
CN
China
Prior art keywords
function
repaired
new
rom
group
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.)
Active
Application number
CN201810792741.6A
Other languages
Chinese (zh)
Other versions
CN110737603A (en
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.)
Ju Li Zhuhai Microelectronics Co ltd
Original Assignee
Ju Li Zhuhai Microelectronics 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 Ju Li Zhuhai Microelectronics Co ltd filed Critical Ju Li Zhuhai Microelectronics Co ltd
Priority to CN201810792741.6A priority Critical patent/CN110737603B/en
Publication of CN110737603A publication Critical patent/CN110737603A/en
Application granted granted Critical
Publication of CN110737603B publication Critical patent/CN110737603B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/0223User address space allocation, e.g. contiguous or non contiguous base addressing
    • G06F12/023Free address space management
    • G06F12/0238Memory management in non-volatile memory, e.g. resistive RAM or ferroelectric memory
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F15/00Digital computers in general; Data processing equipment in general
    • G06F15/76Architectures of general purpose stored program computers
    • G06F15/78Architectures of general purpose stored program computers comprising a single central processing unit
    • G06F15/7807System on chip, i.e. computer system on a single chip; System in package, i.e. computer system on one or more chips in a single package
    • 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)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computing Systems (AREA)
  • Microelectronics & Electronic Packaging (AREA)
  • Stored Programmes (AREA)

Abstract

The invention relates to computer technology, in particular to a method and a device for replacing functions in ROM, which are used for reducing code expenditure in the process of replacing functions and reducing implementation complexity. The method comprises the following steps: and searching a function table corresponding to the group number of the function to be repaired in the ROM, copying the function table into a new function table, updating the access address of the function to be repaired into the set access address of the new function in the new function table, and finally pointing a pointer set by the corresponding group number to the new function table. Therefore, when the function repair is carried out, only each function in the function group to which the function to be repaired belongs is affected, the modification influence range is small, so that the resource cost of the RAM in the repair process is reduced, and meanwhile, in the repair process, the repair can be completed only by repositioning the pointer corresponding to the function group to which the function to be repaired belongs, so that the code modification cost is effectively reduced, and the implementation complexity is effectively reduced.

Description

Method and device for replacing functions in ROM
Technical Field
The present invention relates to computer technology, and more particularly, to a method and apparatus for replacing functions in ROM.
Background
In computer systems, read-Only Memory (ROM) is an essential component. Typically, the ROM is disposed inside a System On Chip (SOC) for storing data and codes, and after the SOC Chip is completed (i.e., production is completed), the data and codes stored in the ROM cannot be modified. Once the hidden trouble exists in the data or code stored in the ROM, when the hidden trouble needs to be modified, the SOC must be re-streamed, and the cost are high. In order to solve the above situation and still repair the hidden trouble of code and data without re-streaming, the following solutions are provided in the prior art:
referring to fig. 1, for each function that may be at risk recorded in the ROM, an access address of each function is defined, and stored in the form of a function table (function table) defined in a Random-access memory (RAM). While other functions call the functions recorded in the ROM that may be at risk, not directly, but through pointers.
For example: assuming that three functions are respectively function1 (function 1), function2 (function 2) and function3 (function 3), when function1, function2 and function3 need to call function A in ROM, instead of directly calling A, access address A of function A is obtained from a function table, and then the function A is jumped to read A in ROM according to the access address A to operate.
Then, when the code of the function a has hidden trouble and needs to be repaired for the function a, a new function A1 needs to be designed, then the access address a of the function a in the function table is modified to be the access address A1, the pointer is redirected to the calling interface of the function A1, and the function a is discarded and is not used any more.
Therefore, the calling function A can be changed into the calling function A1 without modifying codes in the ROM, and the repair requirement of the functions in the ROM is finished.
However, the above solution has the following drawbacks:
a new pointer call interface needs to be implemented for each function to be repaired in the ROM to replace the original interface, thereby increasing implementation complexity.
On the other hand, in the ROM code development stage, when a normal function in the ROM code needs to be changed to a function to be repaired, it is necessary to: defining a new function pointer, and modifying all codes called to the function to be repaired into a calling function pointer;
for example, a new function pointer is defined for function a, referred to as pointer A1, and assuming that functions 1, 2, and 3 require function a to be called, the code in functions 1, 2, and 3 that calls function a needs to be modified to call pointer A1.
Such modifications, known as "intrusive modifications," increase code overhead and increase implementation complexity.
Disclosure of Invention
The embodiment of the invention provides a method and a device for replacing functions in ROM (read only memory), which are used for reducing code expenditure in the process of replacing the functions and reducing implementation complexity.
The specific technical scheme provided by the embodiment of the invention is as follows:
a method of replacing a function in a read only memory ROM, comprising:
determining a function index of a function to be repaired, wherein the function index is at least used for indicating the group number of the function to be repaired;
the group number searches a function table corresponding to the function to be repaired in the ROM, and the function table records the access address of each function to be repaired in the function group to which the function to be repaired belongs;
copying the function table to a designated storage position, generating a corresponding new function table, and updating the access address of the function to be repaired into the set access address of the new function in the new function table, wherein the new function is used for replacing the function to be repaired to execute the corresponding function;
and acquiring pointers corresponding to the group numbers in the RAM, and pointing the pointers to the new function table.
Optionally, in the preprocessing stage, the method further includes:
determining all functions to be written to the ROM;
dividing each function appointed in the ROM into a plurality of groups based on a preset rule;
setting a corresponding function table in the ROM corresponding to each function group respectively;
corresponding group numbers are set for each function table.
Optionally, the method further comprises:
and setting corresponding interface functions corresponding to the designated functions respectively, wherein when one function is called by other functions, the function is indirectly called through the interface function corresponding to the one function.
Optionally, the functions specified in the ROM are divided into several groups based on preset rules, including:
dividing functions of which the difference between the risk levels is lower than a first set threshold value into a group; or alternatively, the process may be performed,
dividing functions of which the difference value between the repair difficulty levels is lower than a second set threshold value into a group; or alternatively, the process may be performed,
and dividing functions with the difference value of the real-time requirements lower than a third set threshold value in the function running process into a group.
Optionally, the method further comprises:
setting a RAM pointer table in a RAM, wherein each pointer recorded in the RAM pointer table points to each function table respectively;
and setting the group number of the corresponding pointer corresponding to the function table pointed by each pointer.
Optionally, determining the function index of the function to be repaired includes:
calling an interface function corresponding to the function to be repaired according to the indication;
and determining a function index of the function to be repaired based on the interface function.
Optionally, obtaining a pointer corresponding to the group number setting in the RAM includes:
based on the interface function, adopting a direct jump mode or an abnormal jump mode to jump to a preset distribution function;
and searching a corresponding pointer in the RAM based on the group number contained in the function index through the distribution function.
Optionally, the distribution functions are set uniformly, or the distribution functions are set corresponding to a function group to which the function to be repaired belongs, or the distribution functions are set corresponding to the function to be repaired.
Optionally, copying the function table to a designated storage location, generating a corresponding new function table, and updating the access address of the function to be repaired to the set access address of the new function in the new function table, including:
copying the function table into RAM to generate a corresponding new function table;
determining a new function generated for replacing the function to be repaired;
assigning a group number of the function to be repaired to the new function;
and based on the intra-group number of the function to be repaired further contained in the function index, searching the access address of the function to be repaired in the new function table, and replacing the access address of the function to be repaired with the access address of the new function.
An apparatus for replacing functions in a ROM, comprising at least:
a determining unit, configured to determine a function index of a function to be repaired, where the function index is at least used to indicate a group number of the function to be repaired;
the first processing unit is used for searching a function table corresponding to the function to be repaired in the ROM based on the group number, wherein the function table is recorded with the access address of each function to be repaired in the function group to which the function to be repaired belongs;
the second processing unit is used for copying the function table to a designated storage position, generating a corresponding new function table, and updating the access address of the function to be repaired into the set access address of the new function in the new function table, wherein the new function is used for replacing the function to be repaired to execute the corresponding function;
and the third processing unit is used for acquiring pointers corresponding to the group number settings in the RAM and pointing the pointers to the new function table.
Optionally, the method further comprises: a preprocessing unit, configured to perform the following operations in a preprocessing stage:
determining all functions to be written to the ROM;
dividing each function appointed in the ROM into a plurality of groups based on a preset rule;
setting a corresponding function table in the ROM corresponding to each function group respectively;
corresponding group numbers are set for each function table.
Optionally, the preprocessing unit is further configured to:
and setting corresponding interface functions corresponding to the designated functions respectively, wherein when one function is called by other functions, the function is indirectly called through the interface function corresponding to the one function.
When dividing each function specified in the ROM into a plurality of groups based on a preset rule, the preprocessing unit is used for:
dividing functions of which the difference between the risk levels is lower than a first set threshold value into a group; or alternatively, the process may be performed,
dividing functions of which the difference value between the repair difficulty levels is lower than a second set threshold value into a group; or alternatively, the process may be performed,
and dividing functions with the difference value of the real-time requirements lower than a third set threshold value in the function running process into a group.
Optionally, the preprocessing unit is further configured to:
setting a RAM pointer table in a RAM, wherein each pointer recorded in the RAM pointer table points to each function table respectively;
and setting the group number of the corresponding pointer corresponding to the function table pointed by each pointer.
Optionally, when determining the function index of the function to be repaired, the determining unit is configured to:
calling an interface function corresponding to the function to be repaired according to the indication;
and determining a function index of the function to be repaired based on the interface function.
Optionally, when acquiring the pointer corresponding to the group number setting in the RAM, the first processing unit is configured to:
based on the interface function, adopting a direct jump mode or an abnormal jump mode to jump to a preset distribution function;
and searching a corresponding pointer in the RAM based on the group number contained in the function index through the distribution function.
Optionally, the distribution functions are set uniformly, or the distribution functions are set corresponding to a function group to which the function to be repaired belongs, or the distribution functions are set corresponding to the function to be repaired.
Optionally, the function table is copied to a designated storage location, a corresponding new function table is generated, and when the access address of the function to be repaired is updated to the set access address of the new function in the new function table, the second processing unit is configured to:
copying the function table into RAM to generate a corresponding new function table;
determining a new function generated for replacing the function to be repaired;
assigning a group number of the function to be repaired to the new function;
and based on the intra-group number of the function to be repaired further contained in the function index, searching the access address of the function to be repaired in the new function table, and replacing the access address of the function to be repaired with the access address of the new function.
A storage medium storing a program for implementing a function in a replacement read only memory ROM, the program, when executed by a processor, performing the steps of:
determining a function index of a function to be repaired, wherein the function index is at least used for indicating the group number of the function to be repaired;
searching a function table corresponding to the function to be repaired in the ROM based on the group number, wherein the function table records the access address of each function to be repaired in the function group to which the function to be repaired belongs;
copying the function table to a designated storage position, generating a corresponding new function table, and updating the access address of the function to be repaired into the set access address of the new function in the new function table, wherein the new function is used for replacing the function to be repaired to execute the corresponding function;
and acquiring pointers corresponding to the group numbers in the RAM, and pointing the pointers to the new function table.
A communications apparatus comprising one or more processors; and
one or more computer-readable media having instructions stored thereon that, when executed by the one or more processors, cause the apparatus to perform the method of any of the above.
In the embodiment of the invention, each function in ROM is grouped in advance, then after the group number of the function to be repaired is determined, a function table corresponding to the function to be repaired is found in ROM based on the group number, the function table is copied to a designated storage position to generate a corresponding new function table, then in the new function table, the access address of the function to be repaired is updated to be the set access address of the new function, and finally, a pointer corresponding to the group number is pointed to the new function table. Therefore, when the functions in the ROM are grouped, the functions in the function group to which the functions to be repaired belong are only influenced, the modification influence range is small, and therefore, the resource expense of the RAM in the repairing process is reduced.
Drawings
FIG. 1 is a diagram of a function call mode in a ROM according to the prior art;
FIG. 2 is a schematic diagram of grouping functions to be repaired in ROM according to an embodiment of the invention;
FIG. 3 is a schematic diagram of a function to be repaired by intermediate call according to an embodiment of the present invention;
FIG. 4 is a flowchart of an alternative function to be repaired in an embodiment of the present invention;
FIG. 5 is a schematic diagram of an alternative function to be repaired in an embodiment of the present invention;
FIG. 6 is a functional block diagram of a computer device according to an embodiment of the present invention.
Detailed Description
In order to reduce the code cost in the process of replacing the functions in the ROM and reduce the implementation complexity, in the embodiment of the invention, each function is grouped in advance, then after the group number of the function to be repaired is determined, a function table corresponding to the group number is searched in the ROM, and only the function table is copied, modified and redirected, thereby effectively reducing the implementation complexity.
The preferred embodiments of the present invention will be described in detail with reference to the accompanying drawings.
In the embodiment of the invention, in the preprocessing stage, before the SOC is subjected to streaming, each function in the ROM needs to be marked and grouped. The method specifically comprises the following steps: determining each function to be written into the ROM, grouping the functions based on a preset rule, respectively corresponding to each function group, and setting a corresponding function table in the ROM; corresponding group numbers are set for each function table, and corresponding group numbers and intra-group numbers are set for each function.
For example, referring to fig. 2, it is assumed that the designated functions in the ROM are divided into N groups, and the designated functions refer to functions in the ROM that may be at risk and may need repair in a subsequent process. Each function group corresponds to a function table, in which access addresses of functions included in one function group are recorded, each function table is provided with a corresponding group number (e.g., 0, 1, 2 … … N), and further, each function is provided with a corresponding group number (e.g., 0, 1, 2 … … N) and an intra-group number (e.g., 0, 1, 2 … … M).
And when grouping the functions, the referenced preset rules can be flexibly set by the manager according to the specific application environment. Alternatively, any of the following arrangements may be employed.
Mode one: the functions of which the differences between the risk levels are below a first set threshold (i.e. the risk levels are similar) are grouped.
In practical application, the probability of hidden danger of different functions is different, so different risk levels can be set for different functions according to experience, for example, functions with frequent problems can be divided into a group, functions with infrequent problems can be divided into a group, and thus related operations on the function groups with infrequent problems can be effectively avoided, and the execution complexity in the repair process is effectively reduced.
Mode two: the functions of which the difference between the repair difficulty levels is lower than a second set threshold (i.e., the repair difficulty levels are similar) are divided into a group.
In practical application, the source code orders of different functions are different, so that different repair difficulty levels can be set according to experience aiming at the functions of different source code orders, the functions with high repair difficulty can be divided into a group, the functions with medium repair difficulty are divided into a group, and the functions with low repair difficulty are divided into a group, so that repair operation can be intensively performed on the functions with high repair difficulty, and the operation duration in the repair process is effectively reduced.
Mode three: the functions with the difference value of the real-time requirements lower than a third preset threshold value (namely, the real-time requirements are similar) in the function running process are divided into a group.
There are various so-called real-time requirements, such as the running time of the function, the number of resources occupied by the function during running, and so on.
Further, a RAM pointer table is generated in the RAM, a pointer corresponding to each function table is recorded in the RAM pointer table, and each pointer corresponds to a group number, so that a corresponding function table can be accessed in the ROM through one pointer in the RAM pointer table, and then an access address of a function to be called can be found through the function table.
As shown in fig. 3, assuming that the respective functions in the ROM are divided into N groups, N pointers are also recorded in the RAM pointer tables, respectively, for pointing to the start positions of the corresponding function tables, respectively.
Further, in the embodiment of the present invention, for each function specified in the ROM, a corresponding small jump code, also called an interface function (e.g., fix function), is also generated, and is used to set a function index (index) of the function, where the function index is used to implement indirect call of the function.
As shown in fig. 3, when the function1, the function2 and the function3 call the function a, the function a is directly called, but the call to the function a is modified to call the function a_fix, that is, modified to the function index of the call function a by a linking technology, so that the indirect call of the function a is realized.
Optionally, the fix function is required to conform to a uniform format:
setting a function index, wherein the function index at least comprises a group number and an intra-group number of the function to be contained, for example, (2, 8) can represent the 8 th function in the 2 nd group function table.
Through the fix function, the system can jump to the entry of the preset distribution function (distribution) to realize the subsequent function, alternatively, the system can jump to the distribution function in an abnormal jump mode (such as interrupt exception and instruction exception) or jump to the distribution function in a direct jump mode (namely, writing the common jump function in the ROM), wherein after the SOC stream is finished, when the abnormal jump mode is adopted, the system can jump to the source code of the distribution function written in the RAM directly to execute the related operation, and the source code of the distribution function can be readjusted in the RAM at any time, so that the distribution function is more simplified, and the CPU with different architectures can be supported.
In the embodiment of the invention, a unified distribution function is set for a plurality of functions, and the distribution function has the following functions: by calling the distribution function, the starting address of the corresponding function table can be found according to the group number contained in the function index, then starting from the starting address, searching the access address of the corresponding function based on the intra-group offset of the intra-group number contained in the function index, and then jumping to the access address to operate the corresponding function.
Optionally, the distribution functions may be globally and uniformly set, a distribution function may be set for each group of functions to be repaired, and a distribution function may be set for each function to be repaired.
Further, the functions of the distribution function and fix function may also be combined, thereby balancing RAM and CPU resources.
Further, the distribution function may be implemented by a hardware circuit, thereby increasing the execution speed.
Based on the above configuration, referring to fig. 4, in the embodiment of the present invention, a specific flow of replacing a function in a ROM is as follows:
step 400: and determining a function index of the function to be repaired, wherein the function index is at least used for indicating the group number of the function to be repaired.
Specifically, the system may call the fix function of the function to be repaired according to the instruction of the manager, thereby obtaining the function index of the function to be repaired.
In the embodiment of the present invention, it is assumed that the group number in the fix function index is 0.
Further, the fix function may further include an intra-group number of the target function to be modified, which is not described herein.
Step 410: and searching a function table corresponding to the function to be repaired in the ROM based on the group number, wherein the function table records the access address of each function in the function group to which the function to be repaired belongs.
For example, still referring to fig. 2, assume that group number 0 corresponds to function table_0 in ROM, and the access addresses of the function groups to which the function to be repaired belongs, i.e., the access addresses of f_0, f_1, and f_i, are recorded in function table_0.
Step 420: copying the function table to a designated storage position, generating a corresponding new function table, and updating the access address of the function to be repaired to the set access address of the new function in the new function table, wherein the new function is used for replacing the function to be repaired to execute the corresponding function.
Specifically, the system copies the function table (e.g., function table_0) corresponding to the function to be repaired in the ROM to the RAM, and generates a new function table (assuming that the function table is called function table_0_fix), and the system can modify the new function table because the function table is readable and writable in the RAM. Specifically, the system may generate a new function for replacing the function to be repaired (the new function may be generated at any time point, and this embodiment is only taken as an example before step 400), assign the group number of the function to be repaired to the new function, and then, based on the intra-group number of the function to be repaired further included in the function index, find the access address of the function to be repaired in the new function table, and replace the access address of the function to be repaired with the access address of the new function.
In the embodiment of the invention, the function table is copied to the RAM, in practical application, depending on the data quantity of the function table, the function table can be copied to any storage position except ROM in the computer device, such as a hard disk, a flash memory and the like, and only the function table is required to be copied to the designated storage position and can be modified correspondingly.
Step 430: and acquiring pointers corresponding to the group numbers in the RAM, and pointing the pointers to the new function table.
Specifically, the system may jump to a preset distribution function by adopting a direct jump mode or an abnormal jump mode based on a fix function corresponding to the function to be repaired, and then find a corresponding pointer in the RAM based on the group number contained in the function index through the distribution function. The distribution functions are uniformly arranged, or the distribution functions are arranged corresponding to a function group to which the function to be repaired belongs, or the distribution functions are arranged corresponding to the function to be repaired.
Specifically, the system searches the pointer set up by the corresponding group number in the RAM pointer table through the distribution function, and the pointer points to the function table corresponding to the function group used for storing the function to be repaired in the ROM.
For example, referring to fig. 2, assuming that the group number of the function to be repaired is 0, the pointer set corresponding to the group number 0 may be found in the RAM pointer table to be function_table_0_pointer.
Then, the system points the pointer (e.g., function_table_0_pointer) of the function table corresponding to the function to be repaired in the ROM from the original function table (e.g., function table_0) to the new function table (e.g., function table_0_fix). Thus, when other functions call the function to be repaired next time, the system does not read the function table_0 any more, but when the distribution function is called, the function table_0_pointer is searched according to the group number, and then the function table_0_fix in the RAM is searched by the function table_0_pointer, so that the access address of the new function is searched in the function table_0_fix according to the intra-group number (the new function is endowed) of the function to be repaired, and finally the new function is called to complete related operations.
For example, referring to fig. 5, after comparing the modified code with the original code (the original code is in ROM and is not changeable), the system determines all the functions to be repaired as function a, function C, and function D as shown in fig. 5. Meanwhile, as shown in fig. 5, in the ROM, it is assumed that the function a, the function B, the function C, and the function D belong to the same function group.
Then, the system stores the newly generated function A1, function C1 and function D1 in the RAM, and generates a new function table n_fix (i.e., function_table n_fix) based on the original function table N (i.e., function_table n_fix), and the original access addresses of function a, function C and function D in the ROM are replaced with the new access addresses of function A1, function C1 and function D1, respectively, so that the function B does not need to be repaired, and therefore, in function_table n_fix, the access address of function B remains unchanged and still points to the function B in the ROM.
Then, a pointer table_pointer_n to function_table N in the RAM pointer table points to function_table n_fix.
When other functions call the functions A, B and D, new functions A1, C1 and D1 are called, so that the replacement of the functions in the ROM is successfully completed.
Based on the above embodiments, referring to fig. 6, in an embodiment of the present invention, an apparatus (e.g., a computer apparatus) for replacing functions in a ROM includes at least:
a determining unit 60 for determining a function index of the function to be repaired, the function index being at least used for indicating a group number of the function to be repaired;
a first processing unit 61, configured to find a function table corresponding to the function to be repaired in the ROM based on the group number, where access addresses of the functions to be repaired in the function group to which the function to be repaired belongs are recorded in the function table;
the second processing unit 62 is configured to copy the function table to a specified storage location, generate a corresponding new function table, and update, in the new function table, an access address of the function to be repaired to a set access address of a new function, where the new function is used to execute a corresponding function in place of the function to be repaired;
and a third processing unit 63, configured to obtain a pointer corresponding to the group number setting in the RAM, and direct the pointer to the new function table.
Optionally, the method further comprises: a preprocessing unit 64, configured to perform the following operations in a preprocessing stage:
determining all functions to be written to the ROM;
dividing each function appointed in the ROM into a plurality of groups based on a preset rule;
setting a corresponding function table in the ROM corresponding to each function group respectively;
corresponding group numbers are set for each function table.
Optionally, the preprocessing unit 64 is further configured to:
and setting corresponding interface functions corresponding to the designated functions respectively, wherein when one function is called by other functions, the function is indirectly called through the interface function corresponding to the one function.
Alternatively, when the functions specified in the ROM are divided into several groups based on a preset rule, the preprocessing unit 64 is configured to:
dividing functions of which the difference between the risk levels is lower than a first set threshold value into a group; or alternatively, the process may be performed,
dividing functions of which the difference value between the repair difficulty levels is lower than a second set threshold value into a group; or alternatively, the process may be performed,
and dividing functions with the difference value of the real-time requirements lower than a third set threshold value in the function running process into a group.
Optionally, the preprocessing unit 64 is further configured to:
setting a RAM pointer table in a RAM, wherein each pointer recorded in the RAM pointer table points to each function table respectively;
and setting the group number of the corresponding pointer corresponding to the function table pointed by each pointer.
Optionally, when determining the function index of the function to be repaired, the determining unit 60 is configured to:
calling an interface function corresponding to the function to be repaired according to the indication;
and determining a function index of the function to be repaired based on the interface function.
Optionally, when acquiring the pointer corresponding to the group number setting in the RAM, the first processing unit 61 is configured to:
based on the interface function, adopting a direct jump mode or an abnormal jump mode to jump to a preset distribution function;
and searching a corresponding pointer in the RAM based on the group number contained in the function index through the distribution function.
Optionally, the distribution functions are set uniformly, or the distribution functions are set corresponding to a function group to which the function to be repaired belongs, or the distribution functions are set corresponding to the function to be repaired.
Optionally, the second processing unit 62 is configured to copy the function table to a designated storage location, generate a corresponding new function table, and update, in the new function table, the access address of the function to be repaired to the set access address of the new function, where:
copying the function table into RAM to generate a corresponding new function table;
determining a new function generated for replacing the function to be repaired;
assigning a group number of the function to be repaired to the new function;
and based on the intra-group number of the function to be repaired further contained in the function index, searching the access address of the function to be repaired in the new function table, and replacing the access address of the function to be repaired with the access address of the new function.
Based on the same inventive concept, in an embodiment of the present invention, there is provided a storage medium storing a program for realizing a function in a replacement read only memory ROM, which when executed by a processor, performs the steps of:
determining a function index of a function to be repaired, wherein the function index is at least used for indicating the group number of the function to be repaired;
searching a function table corresponding to the function to be repaired in the ROM based on the group number, wherein the function table records the access address of each function to be repaired in the function group to which the function to be repaired belongs;
copying the function table to a designated storage position, generating a corresponding new function table, and updating the access address of the function to be repaired into the set access address of the new function in the new function table, wherein the new function is used for replacing the function to be repaired to execute the corresponding function;
and acquiring pointers corresponding to the group numbers in the RAM, and pointing the pointers to the new function table.
Based on the same inventive concept, embodiments of the present invention provide a communication apparatus including one or more processors; and
one or more computer-readable media having instructions stored thereon that, when executed by the one or more processors, cause the apparatus to perform the method of any of claims 1-9.
In summary, in the embodiment of the present invention, each function in the ROM is grouped in advance, then, after determining the group number of the function to be repaired, a function table corresponding to the function to be repaired is found in the ROM based on the group number, and after copying the function table to a designated storage location to generate a corresponding new function table, in the new function table, the access address of the function to be repaired is updated to be the set access address of the new function, and finally, a pointer set corresponding to the group number is obtained in the RAM, and the pointer points to the new function table.
Therefore, when the functions in the ROM are grouped, the functions in the function group to which the functions to be repaired belong are only influenced, the modification influence range is small, and therefore, the resource expense of the RAM in the repairing process is reduced.
On the other hand, in the embodiment of the invention, in the ROM code development stage, a corresponding interface function is respectively defined for each designated function (i.e. the function which can be required to be modified) for realizing the indirect call of the function, and meanwhile, the direct call of other functions to each function is converted into the indirect call to the corresponding interface function, so that the source codes of the other functions do not need to be subjected to invasive modification, thereby further reducing the code modification cost and further effectively reducing the realization complexity,
it will be appreciated by those skilled in the art that embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
While preferred embodiments of the present invention have been described, additional variations and modifications in those embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. It is therefore intended that the following claims be interpreted as including the preferred embodiments and all such alterations and modifications as fall within the scope of the invention.
It will be apparent to those skilled in the art that various modifications and variations can be made to the embodiments of the present invention without departing from the spirit or scope of the embodiments of the invention. Thus, if such modifications and variations of the embodiments of the present invention fall within the scope of the claims and the equivalents thereof, the present invention is also intended to include such modifications and variations.

Claims (10)

1. A method for replacing a function in a read only memory ROM, comprising:
determining all functions to be written to the ROM;
dividing functions of which the difference between the risk levels is lower than a first set threshold value into a group; or dividing the function of which the difference value between the repair difficulty levels is lower than a second set threshold value into a group; or dividing the functions with the difference value of the real-time requirements lower than a third set threshold value in the function running process into a group;
setting a corresponding function table in the ROM corresponding to each function group respectively;
setting a corresponding group number corresponding to each function table;
determining a function index of a function to be repaired, wherein the function index is at least used for indicating the group number of the function to be repaired;
searching a function table corresponding to the function to be repaired in the ROM based on the group number, wherein the function table records the access address of each function to be repaired in the function group to which the function to be repaired belongs;
copying the function table to a designated storage position, generating a corresponding new function table, and updating the access address of the function to be repaired to the set access address of a new function in the new function table, wherein the new function is used for replacing the function to be repaired to execute the corresponding function, and the designated storage position is any storage position except ROM;
and acquiring pointers corresponding to the group numbers in the RAM, and pointing the pointers to the new function table.
2. The method as recited in claim 1, further comprising:
and setting corresponding interface functions corresponding to the designated functions respectively, wherein when one function is called by other functions, the function is indirectly called through the interface function corresponding to the one function.
3. The method as recited in claim 1, further comprising:
setting a RAM pointer table in a RAM, wherein each pointer recorded in the RAM pointer table points to each function table respectively;
and setting the group number of the corresponding pointer corresponding to the function table pointed by each pointer.
4. A method according to any of claims 1-3, wherein determining a function index of a function to be repaired comprises:
calling an interface function corresponding to the function to be repaired according to the indication;
and determining a function index of the function to be repaired based on the interface function.
5. The method of claim 4, wherein retrieving the pointer in RAM that corresponds to the group number setting comprises:
based on the interface function, adopting a direct jump mode or an abnormal jump mode to jump to a preset distribution function;
and searching a corresponding pointer in the RAM based on the group number contained in the function index through the distribution function.
6. The method of claim 5, wherein the distribution function is uniformly set, or wherein the distribution function is set corresponding to a function group to which the function to be repaired belongs, or wherein the distribution function is set corresponding to the function to be repaired.
7. A method according to any one of claims 1-3, characterized in that copying the function table to a designated storage location, generating a corresponding new function table, and in the new function table, updating the access address of the function to be repaired to the set access address of the new function, comprises:
copying the function table into RAM to generate a corresponding new function table;
determining a new function generated for replacing the function to be repaired;
assigning a group number of the function to be repaired to the new function;
and based on the intra-group number of the function to be repaired further contained in the function index, searching the access address of the function to be repaired in the new function table, and replacing the access address of the function to be repaired with the access address of the new function.
8. An apparatus for replacing a function in a ROM, comprising at least:
a determining unit, configured to determine a function index of a function to be repaired, where the function index is at least used to indicate a group number of the function to be repaired;
the first processing unit is used for searching a function table corresponding to the function to be repaired in the ROM based on the group number, wherein the function table is recorded with the access address of each function to be repaired in the function group to which the function to be repaired belongs;
the second processing unit is used for copying the function table to a designated storage position, generating a corresponding new function table, and updating the access address of the function to be repaired to the set access address of the new function in the new function table, wherein the new function is used for replacing the function to be repaired to execute the corresponding function, and the designated storage position is any storage position except ROM;
and the third processing unit is used for acquiring pointers corresponding to the group number settings in the RAM and pointing the pointers to the new function table.
9. A storage medium storing a program for implementing a function in a replacement read-only memory ROM, the program, when executed by a processor, performing the steps of:
determining a function index of a function to be repaired, wherein the function index is at least used for indicating the group number of the function to be repaired;
searching a function table corresponding to the function to be repaired in the ROM based on the group number, wherein the function table records the access address of each function to be repaired in the function group to which the function to be repaired belongs;
copying the function table to a designated storage position, generating a corresponding new function table, and updating the access address of the function to be repaired to the set access address of a new function in the new function table, wherein the new function is used for replacing the function to be repaired to execute the corresponding function, and the designated storage position is any storage position except ROM;
and acquiring pointers corresponding to the group numbers in the RAM, and pointing the pointers to the new function table.
10. A communications apparatus comprising one or more processors; and
one or more computer-readable media having instructions stored thereon that, when executed by the one or more processors, cause the apparatus to perform the method of any of claims 1-7.
CN201810792741.6A 2018-07-18 2018-07-18 Method and device for replacing functions in ROM Active CN110737603B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810792741.6A CN110737603B (en) 2018-07-18 2018-07-18 Method and device for replacing functions in ROM

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810792741.6A CN110737603B (en) 2018-07-18 2018-07-18 Method and device for replacing functions in ROM

Publications (2)

Publication Number Publication Date
CN110737603A CN110737603A (en) 2020-01-31
CN110737603B true CN110737603B (en) 2023-08-01

Family

ID=69234989

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810792741.6A Active CN110737603B (en) 2018-07-18 2018-07-18 Method and device for replacing functions in ROM

Country Status (1)

Country Link
CN (1) CN110737603B (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113342555B (en) * 2020-02-18 2024-01-09 炬芯科技股份有限公司 ROM repairing method, device and storage medium
CN112463230B (en) * 2020-11-23 2023-08-25 浙江地芯引力科技有限公司 Program running method and device, electronic equipment and storage medium
CN117743011A (en) * 2023-12-20 2024-03-22 无锡众星微系统技术有限公司 RomCode operation error repairing method and device

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106507371A (en) * 2015-09-07 2017-03-15 富士通株式会社 The method and apparatus for determining object of planning function

Family Cites Families (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5757690A (en) * 1997-04-23 1998-05-26 Exponential Technology, Inc. Embedded ROM with RAM valid bits for fetching ROM-code updates from external memory
US7310800B2 (en) * 2001-02-28 2007-12-18 Safenet, Inc. Method and system for patching ROM code
CN100371909C (en) * 2005-05-10 2008-02-27 展讯通信(上海)有限公司 Method for correcting ROM code in embedded system
US9037773B2 (en) * 2008-12-16 2015-05-19 Mediatek Inc. Methods for processing and addressing data between volatile memory and non-volatile memory in an electronic apparatus
CN101976211B (en) * 2010-09-26 2013-03-13 北京握奇数据系统有限公司 Method, device and system for replacing function in CAP file
JP2014063350A (en) * 2012-09-21 2014-04-10 Hitachi Automotive Systems Ltd Automotive electronic control device
CN105792751B (en) * 2013-11-27 2019-07-05 雅培糖尿病护理公司 System and method for correcting the programming based on permanent ROM
CN103885807A (en) * 2014-04-03 2014-06-25 四川九成信息技术有限公司 Equipment program updating method
JP6609199B2 (en) * 2016-03-01 2019-11-20 ルネサスエレクトロニクス株式会社 Embedded equipment

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106507371A (en) * 2015-09-07 2017-03-15 富士通株式会社 The method and apparatus for determining object of planning function
JP2017055395A (en) * 2015-09-07 2017-03-16 富士通株式会社 Method and device for determining plan object function

Also Published As

Publication number Publication date
CN110737603A (en) 2020-01-31

Similar Documents

Publication Publication Date Title
CN110737603B (en) Method and device for replacing functions in ROM
US4462077A (en) Trace facility for use in multiprocessing environment
US20200192658A1 (en) Identifying versions of running programs using signatures derived from object files
JP2021002317A (en) Method, apparatus, device and storage medium for upgrading application
US20120167060A1 (en) System and Method for Software Immunization Based on Static and Dynamic Analysis
CN107480476B (en) Android native layer instruction compiling virtualization shell adding method based on ELF infection
JP7212793B2 (en) METHOD, APPARATUS AND COMPUTER STORAGE MEDIUM FOR IMPLEMENTING FUNCTION JUMP
US10338910B2 (en) Multi-tenant upgrading
CN110764839A (en) Business processing flow configuration method, business request processing method and device
CN109542444B (en) JAVA application monitoring method, device, server and storage medium
US20160253157A1 (en) Software refactoring
CN115757149A (en) Automatic testing method, system, electronic equipment and storage medium
US20190220363A1 (en) Method, apparatus and computer program product for improving inline pattern detection
KR20150117522A (en) Graphics state manage apparatus and method
US20130152049A1 (en) Warning of register and storage area assignment errors
CN107491700B (en) Data access method and equipment
US20120054470A1 (en) Optimization system, optimization method, and compiler program
US20180321932A1 (en) Method, device and related system for dynamically repairing application
CN110688320A (en) Global variable detection method and device and terminal equipment
EP3057001A1 (en) Columnar database processing method and device
US11455156B1 (en) Generating tie code fragments for binary translation
US20120159247A1 (en) Automatically changing parts in response to tests
CN110908869A (en) Application program data monitoring method, device, equipment and storage medium
CN108008981B (en) Method and device for initializing program in system on chip (SoC)
CN114168275B (en) Task scheduling method, system, terminal device and storage medium

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
CB02 Change of applicant information
CB02 Change of applicant information

Address after: Room 105-1023, No.6 Baohua Road, Hengqin New District, Zhuhai City, Guangdong Province

Applicant after: Ju Li (Zhuhai) Microelectronics Co.,Ltd.

Address before: 519085 Guangdong city of Zhuhai province Hengqin Baohua Road No. 6, room 105 -1023

Applicant before: JUXIN (ZHUHAI) MICROELECTRONICS Co.,Ltd.

GR01 Patent grant
GR01 Patent grant