HK1080961B - Apparatus and method for initializing system global variables by using multiple load/store instructions - Google Patents
Apparatus and method for initializing system global variables by using multiple load/store instructions Download PDFInfo
- Publication number
- HK1080961B HK1080961B HK06100826.4A HK06100826A HK1080961B HK 1080961 B HK1080961 B HK 1080961B HK 06100826 A HK06100826 A HK 06100826A HK 1080961 B HK1080961 B HK 1080961B
- Authority
- HK
- Hong Kong
- Prior art keywords
- system global
- global variable
- initialization function
- return address
- function
- Prior art date
Links
Description
Technical Field
The present invention relates to an apparatus and method for initializing system global variables by using a multiple load/store instruction, and more particularly, to an apparatus and method for initializing system global variables by storing return addresses of functions that initialize system global variables into general purpose registers and using a multiple load/store instruction in order to shorten initialization time.
Background
When a system having a Central Processing Unit (CPU) such as a wireless communication terminal is powered on or a reset button of the system is activated, a number of initialization processes are performed in which a number of system global variables of a software program operating and controlling the system are initialized. Therefore, it takes a considerable time for the system to perform the initialization process. The system global variables may be divided into two types, for example, zero initialization data (ZI data) initialized to 0, and read/write data (RW data) initialized to predetermined data.
In the conventional method, the initialization of system global variables is performed before the operating system of the system is initialized. Therefore, a function that includes multiple load/store instructions cannot be used because the function will also clear the return address of the function itself, which is stored in the stack, which is also part of the global variable.
Multiple load instructions read multiple bytes of data, while multiple store instructions store multiple bytes of data. That is, multiple load/store instructions process data simultaneously in units of a predetermined number of bytes to increase the processing time of load and store operations. However, the "memset" function of the STM instruction using the C programming language cannot be used to initialize system global variables because in the conventional method, the operating system is initialized after the system global variables are initialized.
Thus, conventional methods use the following "loop" statement to initialize system global variables.
void init_ram(void)
{
int*a;
for(a=start address of ZI data;a< end address
of ZI data;a++)
{
*a=0;
}
for(a=start address of RW.data;a< end address
of RW data;a++)
{
*a=*(address containing a predetermined value for
initializing++);
}
}
As shown, the function void init _ ram (void) initializes ZI data and RW data through a "for" statement. The "for" statement reads and processes the ZI and RW data one word at a time. Thus, the system takes a relatively long time to initialize processes compared to systems that use multiple load/store instructions.
As described above, there is a time delay for initializing system global variables when the system is powered up or reset. This time delay increases with the size and complexity of the software programs that operate and control the system. Therefore, as electronic systems rapidly develop, the size and complexity of software programs will increase unpredictably, and the time delay problem will become more serious.
Disclosure of Invention
It is therefore an object of the present invention to provide an apparatus and a method for reducing the time for initializing system global variables by using multiple load/store instructions.
It is a further object of this invention to provide an apparatus and a method for initializing system global variables by storing return addresses in general purpose registers.
According to an aspect of the present invention, there is provided an apparatus for initializing system global variables by using multiple load/store instructions, the apparatus comprising: a first storage unit for storing a system global variable function and an initialization function using multiple load/store instructions; a second storage unit for storing the return address; a control unit for storing a first return address of the system global variable initialization function to the second storage unit when the system global variable initialization function is called to initialize the system global variable, initializing the system global variable by calling the initialization function using multiple load/store instructions when the system global variable function is executed, and executing the remaining part of the system global variable initialization function by finding and executing an execution sequence (execution sequence) based on the first return address stored in the second storage unit; and the third storage unit is used for storing the initialized system global variables according to the control unit.
According to another aspect of the present invention, there is provided a method for initializing system global variables by using multiple load/store instructions, the method comprising the steps of: a) when a control unit of the system starts to initialize a system global variable, calling a system global variable initialization function; b) storing the return address of the system global variable initialization function in a storage unit, wherein the storage unit is not initialized by a control unit of the system; c) when the system global variable initialization function is executed, calling the initialization function using multiple loading/storing instructions to initialize the system global variable; d) after the initialization of the system global variable is completed, copying the return address stored in the storage unit into a register; and e) executing the remaining part of the system global variable initialization function by looking up and executing the execution sequence based on the return address indicating the first return address retrieved in step d) above.
According to another aspect of the present invention, there is provided a method for initializing system global variables by using multiple load/store instructions, the method comprising the steps of: a) when a control unit of the system starts to initialize a system global variable, calling a system global variable initialization function; b) storing the return address of the system global variable initialization function in a return general register in a storage unit which is not initialized by a control unit of the system; c) during the execution of the system global variable initialization function, calling the initialization function using multiple loading/storing instructions to initialize the system global variable; and d) after finishing executing the initialization function, executing the remaining part of the system global variable initialization function by looking up and executing the execution sequence based on the first return address stored in the storage unit.
Drawings
The above and other objects and features of the present invention will be better understood from the following description of preferred embodiments taken in conjunction with the accompanying drawings, in which:
fig. 1 is a block diagram illustrating a wireless communication terminal having an apparatus for initializing system global variables by using multiple load/store instructions according to a preferred embodiment of the present invention;
FIGS. 2-5 are diagrams for explaining the operation of calling a function and storing a return address in accordance with the preferred embodiment of the present invention; and
fig. 6 is a flowchart illustrating the operation of an apparatus and method for initializing system global variables according to a preferred embodiment of the present invention.
Detailed Description
Hereinafter, an apparatus and method for initializing system global variables according to preferred embodiments of the present invention will be described in more detail with reference to the accompanying drawings.
Fig. 1 is a block diagram illustrating a wireless communication terminal having an apparatus for initializing a system global variable by using a block input/output instruction according to a preferred embodiment of the present invention.
As shown, the wireless communication terminal 100 having an apparatus for initializing system global variables includes a wireless transceiver 110, a central processing unit 120(CPU), a compressor/decompressor (CODEC)130, a memory 140, an audio output device 150, a display 160, an input device (keypad) 170, an audio input device 180, and an antenna 190.
The wireless transceiver 110 receives and transmits radio frequency signals through the antenna 190.
The CPU120 controls the operation of the wireless communication terminal 100. In detail, when the wireless communication terminal 100 is powered on and the CPU120 calls an initialization function using multiple load/store instructions for initializing the system global variables, the CPU120 stores a return address of the system global variable initialization function. Also, the CPU120 controls an execution sequence of operating the wireless communication terminal 100 including a system global variable initialization function and an initialization function based on the stored return address.
A compressor/decompressor (CODEC)130 converts the radio frequency signal from the wireless transceiver 110 into audio data and outputs the audio data through an audio output device 150. Further, the CODEC 130 converts a voice signal input from the audio input device 180 into digital data and transmits the digital data to the CPU120, and transmits the digital data through the wireless transceiver 110.
The memory 140 stores programs for operating and controlling the wireless communication terminal 100, an image, character and icon file system, a system global variable initialization function, and an initialization function using multiple load/store instructions. The memory 140 also stores initialized system global variables according to the CPU 120.
The audio output device 150 outputs audio data included in the radio frequency signal from the wireless transceiver 110 according to the control of the CPU 120.
The display 160 displays data according to the control of the CPU 120.
The input device (keyboard) 170 receives input data such as a telephone number and menu selection information from a user.
The audio input device (microphone) 180 receives a voice signal and transmits the input voice signal to the CODEC 130.
The CPU120 includes a predetermined number of registers. Each register is a small storage space that temporarily stores instructions or data. That is, each register is an internal memory of the CPU for storing binary data of a predetermined length for mathematical calculation, logical calculation, analysis, and transmission. The access time of this register is faster than any other memory like main memory, hard disk and floppy disk.
These registers are classified into general purpose registers for temporarily storing the results of mathematical and logical calculations, depending on the application; a program counter for storing an address of a currently executing instruction; and a link register for storing a return address of the function. The ARM, one of CPUs most widely used in wireless communication systems, includes 16 registers (0-15), of which the 15 th register is a link register.
When the wireless communication terminal is powered on or reset, the CPU of the wireless communication terminal executes a program having a set of instructions for controlling the operation of the wireless communication terminal according to the execution sequence of the program. The program includes various functions for initializing system global variables, external devices, and hardware of the wireless communication terminal system. When one of these functions is called during execution of the program, the return address of the function is stored in the link register. After executing the called function, the remainder of the program is executed by looking up a start execution sequence for the remainder of the program based on the return address stored in the link register, the start execution sequence being the next execution sequence to the execution sequence that called the called function. The link register stores the return address of the called function.
In the case where the second function is called during execution of the first function, the return address of the first function (calling function) is copied in the stack, and the return address of the second function (called function) is written into the link register. The operations of calling a function and storing a return address are explained in detail with reference to fig. 2 to 5.
Fig. 2 to 5 are views for explaining an operation procedure of calling a function and storing a return address according to a preferred embodiment of the present invention.
It is assumed that a program includes a plurality of functions and the program is executed according to an execution sequence of the program. Referring to fig. 2, when a first function is called while the program is being executed, a first return address of the first function is stored in the connection register 21. In fig. 3, if a second function is called during execution of the first function, the first return address stored in the link register 21 is stored in the stack 23, and the second return address of the second function is stored in the link register 21. Furthermore, if a third function is called while the second function is being executed, the second return address stored in the link register 21 is stored in the stack 23, and the third return address is restored in the link register 21. The return address stores the return address of the most recently called function, and the stack 23 stores the return addresses of the functions in the reverse order of the calling function.
After the execution of the function is ended, the link register 21 for returning the calling function of the function is checked first, and then an execution sequence (execution sequence) is executed based on the return address stored in the link register. After returning the calling function, the stack 23 is checked. If any return address is present, the top of the stack is read as the return address of the calling function and the read return address is written into the link register. For example, after the third function is ended, the remaining portion of the second function is executed by executing the execution sequence based on the third return address stored in the link register. After returning the second function based on the third return address, the stack 23 is examined and the top of the stack 23 is read out as the second return address for the second function. The second return address is written to the link register. After the second function is finished, the remainder of the first function is executed by executing the execution sequence based on the second return address stored in the link register, and the top of the stack is read out as the first return address and written to the link register. Finally, after the first function is completely executed, the remaining part of the program calling the first function is executed by executing the execution sequence based on the first return address stored in the link register.
In the present invention, a program for controlling the wireless communication terminal includes a system global variable initialization function and an initialization function. When the program is executing, the program calls the system global variable initialization function and the initialization function using multiple/store instructions. In addition, a system global variable initialization function calls the initialization function. When the program calls the system global variable initialization function, the first return address of the system global variable initialization function is stored in the link register. Furthermore, when the system global variable initialization function calls an initialization function, a first return address stored in the return address is copied to another general register, and a second return address of the initialization function is stored in a link register.
In general, when a calling function for initializing system global variables calls a called function during execution of the calling function, the return address of the called function is stored to the link register 21, and the return address of the calling function is copied to the stack 23. However, as shown in FIG. 4, after the system global variable is initialized by the called function, the stack 23 is initialized with null data because the stack 23 is also one of the system global variables. Therefore, since the return address of the calling function already stored in the stack 23 is also deleted, the remaining part of the calling function cannot be executed. This explains why a function like "memset" cannot generally be used as an initialization function, although it is much faster than a simple "for-loop".
To overcome the above-mentioned problems of the conventional method, the first return address of the system global variable initialization function is stored in another general purpose register in the CPU before the call uses the multiple load/store instruction function or before the second return address of the initialization function is stored in the link register. After the execution of the system global variable initialization function, the first return address stored in the other general register 22 is stored again in the link register 21, and the rest of the program is executed by finding and executing the next execution sequence of the program that calls the execution sequence of the system global variable initialization function based on the stored first return address.
Referring to fig. 5, the procedure of the initialization operation is explained in detail.
First, while a program for controlling the wireless communication terminal is being executed, a system global variable initialization function is called by the CPU120 to execute an initialization process. The first return address of the system global variable initialization function is stored in the link register and at the same time the first return address stored in the return address is also copied to another general purpose register within the CPU. If the initialization function is called while the system global variable initialization function is executed, the second return address of the initialization function is restored in the link register.
For another example, the system global variable initialization function is called by the CPU120 during the execution of a program for controlling the wireless communication terminal to perform an initialization process. The first return address of the system global variable initialization function is stored in the link register 21. When the initialization function is called during the execution of the system global variable initialization function, the first return address of the system global variable initialization function is copied to another general register 22 of the CPU120 and the second return address of the initialization function is stored in the link register 21.
After the execution of the initialization function, the remainder of the system global variable initialization function is executed by finding and executing the next execution sequence of the execution sequence calling the initialization function based on the second return address stored in the link register 21. After returning to the system global variable initialization function, the first return address stored in the other general register 22 is copied into the link register 21. After the remaining portion of the system global variable initialization function is executed, the remaining portion of the system global variable initialization function is executed by finding and executing the next execution sequence of the execution sequence calling the system global variable initialization function according to the first return address stored in the link register 21.
In a preferred embodiment of the present invention, the system global variable initialization function calls the memset function and the memcpy function in order as initialization functions. The memset function and the memcpy function initialize system global variables by using multiple load/store instructions in order to reduce the time for initializing the system global variables. The memset function and the memcpy function may be replaced with any other function using multiple load/store instructions to initialize system global variables.
Memory 140 includes non-volatile memory (such as ROM) and volatile memory RAM. The nonvolatile memory stores programs, a file system, characters and icons that control the wireless communication terminal, and an initialization function using block input/output instructions. The volatile memory stores system global variables initialized according to the control of the CPU 120.
A Read Only Memory (ROM) is a storage device that stores non-volatile data. ROM allows stored data to be read at high speed, but writing data in ROM is very limited.
Random Access Memory (RAM) is a storage device that allows data to be written to and read from the storage element. RAM has the advantage of allowing write and read operations with low cost, small size, low electrical power consumption and high speed access.
Fig. 6 is a flowchart illustrating operations of an apparatus and method for initializing system global variables according to a preferred embodiment of the present invention.
As shown in the figure, when the wireless communication terminal is powered on or reset, a program for controlling the operation of the wireless communication terminal is executed at step S601. In step S602, the program calls a system global variable initialization function stored in the ROM to initialize the system global variable.
In step S603, after executing the system global variable initialization function, the CPU stores the first return address of the system global variable initialization function in the return address, and the code should be executed to copy that address into a free general register to execute the rest of the program. The remaining portion of the program is executed by finding and executing a next execution sequence that calls an execution sequence of the system global variable initialization function based on the first return address.
That is, when the program calls the system global variable initialization function, the CPU stores the first return address of the system global variable initialization function in the return address. After the CPU stores the first return address into the return address, the code should be executed to store that first return address in another general purpose register.
As described above, the first return address should be stored in other general purpose registers before the system global variable initialization function is called, or the first return address should be stored after the system global variable initialization function is called and before the first return address is stored in the return address.
After storing the first return address, in step S604, the system global variable is initialized by calling an initialization function using multiple load/store instructions.
The system global variable initialization function (void init ram (void)) and the initialization function using multiple load/store instructions (memset, memcpy) are as follows:
void init_ram(void)
{
memset(start address of ZI data,0,end address of ZI data-start
address of ZI data+1);
memcpy(start address of RW data,address having initialization
value,size of RW data)
}
the system global variable initialization function (void init ram (void)) of the present invention calls the initialization function memset function and the memcpy function in order.
The memset function initializes the system global variable to "0" by simultaneously processing predetermined bytes of the system global variable. Typically, for acceleration, this function is implemented using multiple load/store instructions. That is, the ZI data stored in the RAM of the wireless communication terminal is initialized in units of blocks. In the preferred embodiment of the present invention, the memset function is used as the initialization function, but any other function that processes a plurality of bytes of data per instruction may be used.
The memcpy function, which is a function that copies n bytes of data stored in a first storage location to a second storage location, is used in the preferred embodiment of the present invention to initialize RW data. That is, to initialize the system global variables, the memcpy function reads the initialized value of the system global variable stored in the ROM and copies it to the corresponding memory location of the RAM.
When the system global variable initialization function calls the memset function, the second return address of the memset function is restored in the link register. After executing the memset function, the remainder of the system global variables are executed by looking up and executing the next execution sequence of the execution sequence calling the memset function based on the second return address stored in the return address.
The invocation and return of the memcpy function is done in the same way as the memset function.
After ending the execution of the system global variable initialization function, the CPU reads a first return address of the system global variable initialization function, which is stored in another general register. The remainder of the program is executed by finding and executing the next execution sequence of the execution sequence that called the system global variable initialization function based on the first return address stored in another general purpose register.
The invention described above may be applied to an electronic device having any Central Processing Unit (CPU) that supports multiple load/store instructions. That is, the present invention can reduce the booting time of an electronic device having the CPU, such as a computer and a wireless communication terminal.
As described above, by storing the return address in one of the general purpose registers of the central processor and using multiple load/store instruction functions, the present invention can reduce the time it takes to initialize system global variables.
The present invention includes subject matter related to korean patent application No. kr 2004-.
While the present invention has been described in terms of certain preferred embodiments, it will be apparent to those skilled in the art that various changes and modifications can be made without departing from the spirit and scope of the invention as defined in the following claims.
Claims (16)
1. An apparatus for initializing system global variables by using multiple load/store instructions, the apparatus comprising:
a first storage unit for storing a system global variable initialization function and an initialization function using multiple load/store instructions;
a second storage unit for storing the return address;
a control unit for storing a first return address of the system global variable initialization function to the second storage unit when the system global variable initialization function is called to initialize the system global variable, initializing the system global variable by calling the initialization function using multiple load/store instructions during execution of the system global variable function, and executing the remaining part of the system global variable initialization function by finding and executing an execution sequence based on the first return address stored in the second storage unit; and
a third storage unit for storing the initialized system global variables according to the control unit,
wherein the second storage location is one of the general purpose registers of the CPU that is not initialized during the initialization of the system global variables.
2. The apparatus of claim 1, wherein the control unit stores the first return address of the system global variable initialization function in both the register and the second storage unit when the system global variable initialization function is called.
3. The apparatus of claim 2, wherein when the initialization function is called during execution of the system global variable initialization function, the control unit stores a second return address of the initialization function in the register, and executes the remaining portion of the system global variable initialization function by finding and executing an execution sequence based on the second return address stored in the register.
4. The apparatus of claim 1, wherein when the initialization function is called while the system global variable initialization function is executed, the control unit stores a first return address of the system global variable initialization function in the second storage unit, stores a second return address of the initialization function in the register, initializes the system global variable by using multiple load/store instructions, and executes the remaining part of the system global variable initialization function by finding and executing an execution sequence based on the second return address stored in the register.
5. The apparatus of claim 1, wherein the control unit reads the first return address stored in the second storage unit and writes the first return address to the register after the initialization function is executed.
6. The apparatus of claim 1, wherein the first storage unit is a Read Only Memory (ROM) and the third storage unit is a Random Access Memory (RAM).
7. The apparatus of claim 4, wherein the first storage unit, the second storage unit, the third storage unit and the control unit are included in a wireless communication terminal.
8. The device according to claim 4, wherein the first storage unit, the second storage unit, the third storage unit and the control unit are comprised in a computer, or in any other electronic device.
9. A method for initializing system global variables using multiple load/store instructions, the method comprising the steps of:
a) when a control unit of the system starts to initialize a system global variable, calling a system global variable initialization function;
b) storing the return address of the system global variable initialization function in a storage unit, wherein the storage unit is not initialized by a control unit of the system;
c) when the system global variable initialization function is executed, calling the initialization function using multiple loading/storing instructions to initialize the system global variable;
d) after the initialization of the system global variable is completed, copying the return address stored in the storage unit into a register; and
e) executing the remaining part of the system global variable initialization function by looking up and executing an execution sequence based on the return address indicating the first return address retrieved in step d) above.
10. The method of claim 9, wherein in step b), the storage unit includes one of the general purpose registers, and the control unit stores the first return address in both the register and a predetermined general purpose register when the system global variable initialization function is called.
11. The method of claim 10, wherein in step e), when the initialization function is called while the system global variable initialization function is executed, a second return address of the initialization function is stored in the register, the system global variable is initialized by using multiple load/store instructions, and the remaining part of the system global variable initialization function is executed by finding and executing an execution sequence based on the second return address stored in the register.
12. The method of claim 9, wherein in steps b) and c), when the initialization function is called while the system global variable initialization function is executed, a first return address of the system global variable initialization function stored in the register is copied into a predetermined general register, a second return address of the initialization function is stored in the register, the system global variable is initialized by using a multiple load/store instruction, and the remaining part of the system global variable initialization function is executed by finding and executing an execution sequence based on the second return address stored in the register.
13. The method of claim 12, wherein in the step e), after initializing the system global variable, the first return address stored in the predetermined general register is copied to the register.
14. The method according to claim 13, wherein the step c) comprises the steps of:
c-1) initializing ZI data of a predetermined byte length of the system global variable using multiple load/store instructions by calling a function that initializes the ZI data; and
c-2) initializing RW data of a predetermined byte length of the system global variable using multiple load/store instructions by calling a function that initializes the RW data.
15. The method as claimed in claim 14, wherein in the step c-1), when the system global variable initialization function is executed, the control unit calls a function of initializing the ZI data and initializes the ZI data stored in the RAM by using multiple load/store instructions.
16. The method according to claim 14, wherein in the step c-2), the function for initializing RW data reads a predetermined value stored in a Read Only Memory (ROM) in units of blocks and copies the predetermined value to a predetermined location of the RW data located in the RAM using multiple load/store instructions for initializing RW data.
Applications Claiming Priority (2)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| KR21183/2004 | 2004-03-29 | ||
| KR1020040021183A KR100658918B1 (en) | 2004-03-29 | 2004-03-29 | System global variable initialization device using block unit I / O instruction and its method |
Publications (2)
| Publication Number | Publication Date |
|---|---|
| HK1080961A1 HK1080961A1 (en) | 2006-05-04 |
| HK1080961B true HK1080961B (en) | 2008-02-29 |
Family
ID=
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| US7934209B2 (en) | Method for firmware variable storage with eager compression, fail-safe extraction and restart time compression scan | |
| EP1619589B1 (en) | Method for programming a system on a chip DMA controller and system on a chip therefore. | |
| CN100565454C (en) | System and method for booting from a non-volatile application and file storage device | |
| US6988163B2 (en) | Executing binary images from non-linear storage systems | |
| KR101583002B1 (en) | Computing system, its booting method, and code data pinning method | |
| CN1573694A (en) | Apparatus and method for initializing coprocessor for use in system comprised of main processor and coprocessor | |
| US20130179670A1 (en) | Booting method of multimedia device and multimedia device | |
| CN1447227A (en) | Guide system utilizing non-flash memory and its method | |
| WO2014200511A1 (en) | Unified extensible firmware interface (uefi) driver and protocol | |
| US7565521B2 (en) | Method for managing memory space during system initialization | |
| US6961848B2 (en) | System and method for supporting legacy operating system booting in a legacy-free system | |
| CN101042654A (en) | Method and apparatus for booting from a non-local execution memory | |
| US20110246759A1 (en) | Method for boosting an electronic device with multiple processing units, and electronic device for implementing the same | |
| US20020083427A1 (en) | Embedded system capable of rapidly updating software and method for rapidly updating software of embedded system | |
| CN1207851C (en) | Apparatus and method for interfacing between modem and memory in mobile station | |
| US7512777B2 (en) | Method and system for maintaining system management BIOS | |
| US20170060640A1 (en) | Routine task allocating method and multicore computer using the same | |
| CN1362667A (en) | Embedded structure with software capable of being updated fast and its software updating method | |
| CN100346300C (en) | Apparatus and method for initializing system global variables by using multiple load/store instructions | |
| CN1782993A (en) | Improved operating system performance | |
| HK1080961B (en) | Apparatus and method for initializing system global variables by using multiple load/store instructions | |
| KR100534613B1 (en) | apparatus and method for booting system using flash memory | |
| CN1455343A (en) | Method to prevent overwriting of MAC addresses of peripheral terminals in DMI data | |
| CN114647411B (en) | Programming interface loading method, device, electronic device and storage medium | |
| JP2006524973A (en) | System for controlling camera resources in portable devices |