Method for storing and using executable programs and apparatus therefor

Abstract: A computer having a reduced instruction computer (RISC) architecture has a RISC central processing unit (CPU)(1)coupled to a RAM memory (3) and to a flash ROM memory (4). A set of compressed operating instructions (6,8), including a subset defining a compression method (8), are stored in the flash ROM (4) together with a set of uncompressed instructions (7) defining a compression algorithm. Upon booting of the computer, the uncompressed instructions (7) are read from the ROM (4) by the CPU (1) which then also reads the compressed instructions (6,8), decompresses them according to the decompression process (7), and writes the decompressed instructions (6',8') to the RAM (3). The compressed instructions (6,8) can be dynamically altered by the CPU (1), by generating an altered set of uncompressed instructions, compressing these in accordance with the now decompressed compression method (8'), and writing these to the flash ROM (4).

Description: The present invention relates to executable programs and in particular to a method and apparatus for storing and using executable programs. At the heart of most modem electronic devices is a microprocessor or central processing unit which operates in accordance with a set of software operating instructions which together form an executable program. The instructions are stored in a digital memory which may be internal to the microprocessor or, as is more usually the case, externally connected to the microprocessor. The set of operating instructions generally define the basic input/output system (BIOS) of the microprocessor together with device drivers, libraries, and user applications. Software instructions defining the basic operation of a microprocessor are usually stored in non-volatile read only memory (ROM). Until recently, the preferred choice for storing operating instructions was UV light erasable programmable read only memory. More recently however, the preferred choice for storing operating instructions, especially in embedded devices (e.g. mobile phones, personal digital assistants, etc) has become flash ROM. Flash ROM is both non-volatile and electrically erasable and is used, to a large extent, because it can be programmed following assembly of the PCB containing the flash ROM or of the completed device. A further advantage is that it is possible to upgrade operating instruction stored in the flash ROM at some future date. Compared to conventional ROM, flash ROM remains expensive. There therefore exists a desire to reduce the amount of flash ROM used in individual products. Furthermore, accessing flash ROM is relatively slow, significantly reducing the performance of electronic devices. Conventional computer architectures rely upon a complex instruction set computer (CISC) architecture. This utilises a large number (e.g. 1000) of instructions which define very specific tasks. The instructions are of variable length and are decoded by the computer's CPU before execution. There is described in Japanese non-examined patent publication no. 55-131848 a data processing unit which comprises a central processing unit, a main memory unit, and an external memory unit. A compressed program is stored in the external memory unit and, before commencing processing operations, the compressed program is read from the external memory unit in blocks and decompressed. The decompressed program is then written to the main memory unit. However, the compression ratio which can be achieved with CISC code is relatively low. US-A-5 671 413 describes a computer system, where the services to be provided by a basic input/output system (BIOS) are implemented via a number of independently executable service components. Additionally, the BIOS is provided with a decompression dispatcher for decompressing and dispatching the service components into random access memory (RAM) of the computer system for execution on an as needed basis, and optionally removing the dispatched service components when they are no longer needed. As a result, the service components may be stored in a non-volatile storage in a compressed state, allowing more services to be implemented without requiring more non-volatile storage. Patent Abstracts of Japan, vol. 96, no 1, 31 January 1996 & JP-A-07 248921 describes an initial program loading method for parallel processor system. WO-A-94 19768 describes a compressed BIOS system. There, a means is provided for providing a BIOS routine from an EPROM to RAM in a general purpose computer, where the BIOS routine is greater in number of lines of code than the line capacity of the EPROM. The BIOS routine is stored in EPROM in three portions. A first portion is uncompressed, and loadable and operable by the CPU of the computer to initialize RAM. A second portion is compressed by one of a number of schemes. A third portion is a decompression utility loadable and operable by the computer CPU to decompress the compressed portion from EPROM and copy the resulting code to RAM, resulting in a BIOS routine in RAM. The present invention flows from the recognition that the new generation of reduced instruction set computers (RISC) make use of a much reduced set of instructions. In addition, RISC architectures have a generally fixed length instruction size, allowing the use of hard-wired decoding logic. According to a first aspect of the present invention there is provided a method of operating apparatus having a central processing unit (CPU) and a read only memory (ROM), the method comprising reading a set of compressed operating instructions from the ROM into the CPU, decompressing the compressed instructions in the CPU, and thereafter operating the apparatus in accordance with the decompressed instructions, characterised by the method further comprising generating one or more replacement or additional compressed instructions in the CPU and writing the compressed instruction(s) to the ROM. The first aspect of the present invention makes it possible to amend the stored compressed instructions in a dynamic manner. This may, for example, allow a user to configure the computer according to his specific needs. Additionally, the present invention makes it possible to make a considerable saving in the amount of ROM memory required for storing RISC operating instructions for a central processing unit. As the set of different possible RISC instructions is relatively small (e.g. around 250) compared to the total number of instructions (e.g. around 1000,000), instructions tend to be repeated many times and therefore the degree of compression which can be achieved is high. Although extra RAM may be required, a considerable cost saving may be achieved where expensive ROM is replaced by cheap RAM. Furthermore, manufacturing times may be reduced as it only becomes necessary to write a relatively short program to the ROM memory, rather than a long uncompressed program. Preferably, the method comprises the step of reading a set of operating instructions from the ROM into the CPU, which instructions define a program for compressing said replacement or additional instruction(s). More preferably, the instructions defining the compression program form part of said set of compressed operating instructions. Preferably, the method of the above first aspect of the invention comprises writing the decompressed instruction set to a random access memory (RAM). Thereafter, the decompressed instructions are read from the RAM by the CPU. It is noted that RAM typically offers high access speeds compared to slow (e.g. flash) ROM memory, giving a significant increase in system performance. In this case, increased speed also offers reduced power consumption compared to systems which use slow ROM memory and in which power is consumed even when the system is waiting to access the ROM. According to a second aspect of the present invention there is provided apparatus comprising a central processing unit (CPU), a read only memory (ROM), and a set of compressed operating instructions stored in the ROM, the CPU being arranged in use to read the compressed instructions from the ROM, decompress the compressed instructions, and thereafter operate the apparatus in accordance with the decompressed instructions, characterised by the apparatus being further arranged in use to compress replacement or additional operating instructions and to write these compressed instructions to the ROM. Preferably, said ROM memory is flash ROM memory. Preferably, the apparatus comprises a random access memory which, in use, is arranged to store the operating instructions following decompression by the CPU. Apparatus according to the above second aspect of the invention may advantageously be incorporated into mobile communication devices such as mobile telephones and combined mobile telephone/personal digital assistants. For a better understanding of the present invention and in order to show how the same may be carried into effect reference will now be made, by way of example, to the accompanying drawings, in which: Figure 1 shows in block diagram form the architecture of a simple computer; Figure 2 shows a memory map of the computer of Figure 1 prior to booting of the computer, where the memory stores a set of operating instructions in accordance with a first embodiment of the present invention; Figure 3 shows the memory map of Figure 2 after booting of the computer; and Figure 4 shows a memory map of the computer of Figure 1 prior to booting of the computer, where the memory stores a set of operating instructions in accordance with a second embodiment of the present invention. A much simplified block diagram of a computer is illustrated in Figure 1. The computer comprises a RISC based microprocessor 1 with an internal RAM cache 5. The microprocessor 1 may be, for example, an ARM9TDMI (Trade Mark of Advanced RISC Machines, UK) microprocessor coupled to a parallel bus 2. Also coupled to the bus 2 are a RAM memory 3 (for example SDRAM) and a flash ROM memory 4. A detailed description of the ARM TM system architecture and of RISC is given in "ARM System Architecture", Steve Furber, Addison Wesley, ISBN 0-201-40352-8. However, a feature of RISC is that it employs code which tends to contain a few operands repeated many times. Furthermore, these operands and register/address identifications tend to be of a fixed length. The flash ROM 4 is used to store a set of RISC operating instructions which define the basic input/output system (BIOS) of the microprocessor as well as the device drivers, libraries, and user applications. The instructions are in compressed form, having previously been compressed using the Pkzip compression program. The compressed instructions occupy considerably less flash ROM space than would the corresponding uncompressed instructions, e.g. 1/2 to 1/5 of the memory space. Such a high compression ratio results from the particular structure of RISC instructions. In order to enable the microprocessor 1 to decompress the stored compressed instructions, the flash ROM 4 additionally stores a set of instructions, in uncompressed form, which define the Pkzip decompression program. Figure 2 shows a memory map of the ROM 4 prior to booting the computer, where a part of the memory space is occupied by the compressed instructions 6 and a part is occupied by the uncompressed Pkzip instructions 7. In Figure 2, the ROM 4 is shown coupled to the microprocessor 1, as is the RAM 3 which at this stage remains empty. Upon booting of the computer, the microprocessor 1 is directed by hardwired logic to read the first instruction of the decompressed instruction set 7, from the ROM 4. Thereafter the microprocessor is directed, by the decompressed set, to read and decompress the compressed instruction set 6. The expanded instruction set 6' is then stored in the RAM 3 as shown in Figure 3. The last operation that the set of decompression instructions perform is to cause the microprocessor 1 to jump to the first instruction in the decompressed code. Thereafter, the computer is operated in accordance with the decompressed operating instructions 6'. It will be appreciated that the operating system of the computer may be altered by directly accessing the flash ROM 5 to erase and/or rewrite compressed instructions 6 stored therein. However, in some circumstances it may be desirable for the end-user to be able to alter the compressed operating instructions 6, or indeed for the computer itself to be able to 'dynamically' alter the instructions. To this end, the Pkzip compression method may also be stored in the flash ROM 4. In order to reduce memory requirements, the corresponding Pkzip instructions may be stored in compressed form 8 as illustrated in Figure 4. During booting, the compressed Pkzip instructions 8 are read from the flash ROM 4 by the microprocessor 1, decompressed, and stored in the RAM 3 as decompressed instructions 8' together with the decompressed operating instructions 6' (Figure 4). Alternatively, the compressed Pkzip instructions 8 may only be read from the flash ROM 4, and subsequently decompressed, when a specific request is made to alter the compressed instructions 6,8. In either case, the microprocessor 1 employs the decompressed Pkzip method to compress an amended version of the operating instructions 6',8' and writes the compressed instructions to the corresponding areas of the flash ROM. It is noted that the compression ratio is maximised when the entire set of operating instructions 6,8 are compressed as a single 'unit'. However, it is also possible to compress the instructions in smaller sub-units, in which case only those units which have been amended need be compressed and written to the flash ROM 4. It will be appreciated by the person of skill in the art that other modifications may be made to the embodiments described above without departing from the scope of the present invention. For example, compression algorithms other than Pkzip may be used, including Gzip-9, Zoo-a, and Arj-a. Compression methods may also be optimised for ARM (Trade Mark) processors.

Claims: A method of operating apparatus having a central processing unit (CPU) and a read only memory (ROM), the method comprising reading a set of compressed operating instructions from the ROM into the CPU, decompressing the compressed instructions in the CPU, and thereafter operating the apparatus in accordance with the decompressed instructions, characterised by the method further comprising generating one or more replacement or additional compressed instructions in the CPU and writing the compressed instruction(s) to the ROM. A method according to claim 1 and comprising the step of reading a set of operating instructions from the ROM into the CPU, which instructions define a program for compressing said replacement or additional instruction(s). A method according to claim 2, wherein the instructions defining the compression program form part of said set of compressed operating instructions. A method according to any one of the preceding claims and comprising forming an operating system of the decompressed instruction set. A method according to any one of the preceding claims and comprising writing the decompressed instruction set to a random access memory (RAM) and thereafter reading the decompressed instructions from the RAM by the CPU. Apparatus comprising a central processing unit (CPU, 1), a read only memory (ROM,4), and a set of compressed operating instructions (6,8) stored in the ROM (4), the CPU (1) being arranged in use to read the compressed instructions (6,8) from the ROM (4), decompress the compressed instructions (6,8), and thereafter operate the apparatus in accordance with the decompressed instructions (6',8'), characterised by the apparatus being further arranged in use to compress replacement or additional operating instructions and to write these compressed instructions to the ROM. Apparatus according to claim 6, wherein said ROM memory (4) is flash ROM memory. Apparatus according to claim 6 or 7 and comprising a random access memory (RAM,3) which, in use, is arranged to store the operating instructions following decompression by the CPU (1). Apparatus according to any one of claims 6 to 8, wherein the CPU is arranged to form an operating system of the decompressed operating instructions. A mobile communication device comprising apparatus according to any one of claims 6 to 9.

Inventors: MAEKINEN RAUNO, MAEKINEN, RAUNO, Mäkinen, Rauno
Applicants: NOKIA CORP, NOKIA CORPORATION
Application year: 1998
Main classification: G06F9
IPC codes: G06F9, G06F5