Abstract:
The invention relates to a method for updating a basic input/output system (BIOS) and method for repairing the BIOS. A part of a program code of the BIOS is stored in a backup memory block in advance. If the BIOS fails to update, the backup program code can be adopted to start up a computer system and then the BIOS will be repaired.

Description:
CROSS-REFERENCE TO RELATED APPLICATION 
       [0001]    This application claims the priority benefit of Taiwan application serial no. 97134216, filed on Sep. 5, 2008. The entirety of the above-mentioned patent application is hereby incorporated by reference herein and made a part of this specification. 
       BACKGROUND OF THE INVENTION 
       [0002]    1. Field of the Invention 
         [0003]    The present invention relates to a Basic Input/Output System (hereinafter referred to as “BIOS”) and more particularly, to a method for updating and repairing the BIOS. 
         [0004]    2. Description of Related Art 
         [0005]    A BIOS stored in a flash memory of a motherboard in a current computer system often needs to be updated for reasons such as that it is required to support new hardware or that programming code of the BIOS has errors therein.  FIG. 1  is a flowchart illustrating a conventional method of updating BIOS. 
         [0006]    Referring to  FIG. 1 , the method starts with step S 100  to update the BIOS with the computer system executing an updating program. The updating program first clears a main BIOS stored in a flash memory in step S 110 . Next, updated main BIOS is written in the flash memory in step S 120 . Afterwards, the updating program determines in step S 130  whether a boot block of the BIOS has to be updated. If the boot block has to be updated, the boot block in the flash memory is cleared in step S 140  and a new boot block is written in the flash memory in step S 150 . Updating the BIOS is completed in step S 160 . If in step S 130 , the updating program determines that it is not required to update the boot block, updating the BIOS is then completed (step S 160 ). 
         [0007]    However, during the updating process, the BIOS in the computer system may sometimes be damaged due to update failure caused by computer power outage or system reset. At this point, if the damaged portion belongs to the main BIOS while the boot block remains intact, the user may update the BIOS again through external devices of the computer system. 
         [0008]    However, if the damaged portion of the BIOS belongs to the boot block, the BIOS will completely lose functionality and the computer system cannot be booted. When encountering the abovementioned damage to the boot block, the user wishing to remedy the BIOS has to change the flash memory with the damaged BIOS stored thereon to another flash memory with an (undamaged) BIOS in order for the computer system to resume normal operations. The abovementioned approach of replacing the flash memory, however, requires the user to remove the casing of the computer system and put the new flash memory on the motherboard, possibly resulting in damage to the entire memory if the pins of the flash memory are not inserted in the correct positions. 
         [0009]    Many manufacturers have so far proposed methods to prevent a computer system from failing to boot due to a BIOS damage. One of the methods is to dispose two flash memories, both containing the BIOS, on the motherboard. Thus, when one of the BIOS&#39;s is damaged at update, the user may switch a jumper on the motherboard so that the computer system may use the other BIOS at booting. However, the method results in an increase in the cost and area of the motherboard. In addition, the user has to remove the casing of the computer to switch the jumper. Furthermore, some manufacturers additionally dispose an automatic detection circuit and two flash memories to store the BIOS&#39;s. When the automatic detection circuit detects that one of the BIOS&#39;s is damaged, operation is automatically switched to the other BIOS so that the computer system may maintain normal operation. However, the method, though, frees the user from having to remove the computer casing but adds a detection circuit and a flash memory to the motherboard, thereby increasing the cost and area of the motherboard. 
       SUMMARY OF THE INVENTION 
       [0010]    The present invention provides a method for updating and repairing a basic input/output system which repairs a damaged BIOS without increasing cost of motherboard. Moreover, a computer system may normally operate regardless of whether the BIOS is intact. 
         [0011]    To resolve the aforesaid issue, the present invention provides a method for updating BIOS stored in a non-volatile memory including a first region in which there stores a part of program code of the BIOS. First, a descriptor table storing an address data is read. The address data has an address of the BIOS in the non-volatile memory. The address data at this time points to an original address of the BIOS. Next, the part of the program code in the first region is copied to a backup memory block. Then, the address data in the descriptor table is changed so that the address data points to the backup memory block. Afterwards, the first region is cleared and an updated program code is written in the first region. Finally, the address data in the descriptor table is restored to point to the original address. 
         [0012]    In one embodiment of the present invention, the abovementioned part of the program code is program code of a boot block in the BIOS. The abovementioned non-volatile memory further includes a second region used to store a main BIOS of the BIOS. Before copying the program code of the boot block, the second region of the non-volatile memory is first cleared and an updated main BIOS is written in the second region. 
         [0013]    The present invention further provides a method for repairing BIOS suitable for a computer system. First, detection is made on whether the computer system is in a descriptor mode. Next, a backup program code of the BIOS is read according to the descriptor mode. Finally, the backup program code is used to start up the computer system and repair the BIOS. 
         [0014]    In one embodiment of the present invention, steps of reading the backup program code include: reading a descriptor table in the descriptor mode; obtaining an address of the backup program code from an address data in the descriptor table; and reading the backup program code. 
         [0015]    In the present invention, a part of the BIOS program code is backed up so when the BIOS update fails, the computer system may still use the backup part of the BIOS program code to boot and restore the BIOS after booting. 
         [0016]    In order to make the aforementioned features and advantages of the present invention more comprehensible, several embodiments accompanied with figures are described in detail below. 
     
    
     
       BRIEF DESCRIPTION OF THE DRAWINGS 
         [0017]    The accompanying drawings are included to provide a further understanding of the invention, and are incorporated in and constitute a part of this specification. The drawings illustrate embodiments of the invention and, together with the description, serve to explain the principles of the invention. 
           [0018]      FIG. 1  is a flowchart illustrating a conventional method for updating BIOS. 
           [0019]      FIG. 2  is a flowchart illustrating a method of updating BIOS according to an embodiment of the present invention. 
           [0020]      FIG. 3  is a schematic diagram illustrating block configuration of a flash memory in a current motherboard. 
           [0021]      FIG. 4  is a schematic diagram illustrating block configuration of a flash memory according to an embodiment of the present invention. 
           [0022]      FIG. 5  is a flowchart illustrating a method for repairing BIOS according to an embodiment of the present invention. 
           [0023]      FIG. 6  is a flowchart illustrating a method for repairing BIOS according to another embodiment of the present invention. 
       
    
    
     DESCRIPTION OF EMBODIMENTS 
       [0024]    In a conventional method for updating BIOS, when the BIOS update fails, the computer system may not be able to boot. To prevent the computer system from being unable to boot due to a BIOS update failure, the present invention provides a method for updating and repairing BIOS to free a user from having to worry about a BIOS update failure. 
         [0025]      FIG. 2  is a flowchart illustrating a method of updating BIOS according to an embodiment of the present invention. For the purpose of illustrating the present embodiment, the method for updating BIOS of the present embodiment is assumed to be applied in a current computer system, in which the BIOS is stored in a non-volatile memory on the motherboard, for example. Take the current computer system as an example, the non-volatile memory is a flash memory, for instance. Furthermore, the non-volatile memory in the present embodiment is assumed to have a first region used to store a part of the BIOS program code. In addition, in the present embodiment, the part of the BIOS program code stored in the first region is assumed to be a boot block in the BIOS. However, persons having ordinary skill in the art should appreciate that the abovementioned assumptions are not to be used to limit the present invention. 
         [0026]    Referring to  FIG. 2 , updating the BIOS begins with step S 200 . First, in the computer system, a descriptor table is read in step S 210 . The descriptor table in the present embodiment stores an address data which is obtained when the descriptor table is read. The address data points to an address of the BIOS in the non-volatile memory. In the present embodiment, the address of the BIOS may be an initial position of the BIOS, a highest address or lowest address in the flash memory. Moreover, at this time, the address data in the descriptor table points to an original address of the BIOS in the non-volatile memory. 
         [0027]    Next, the boot block of the BIOS stored in the first region of the non-volatile memory is to be copied to a backup memory block in step S 220 . The backup memory block may be a block in the abovementioned non-volatile memory and may also be an arbitrary memory block at other positions on the motherboard. 
         [0028]    Next, the address data in the descriptor table is to be changed to point to the abovementioned backup memory block in step S 230 . Then, data in the first region of the non-volatile memory is to be cleared in step S 240 . An updated program code is to be written to the first region in step S 250  to update the boot block in the BIOS. The updated program code may be obtained through other peripheral devices of the computer system (e.g. a floppy disk drive, USB storage medium, and an optical disk drive) or may be pre-downloaded from a network to a hard disk of the computer system. Finally, the address dada in the descriptor table is to be restored to point to the original address of the original BIOS in step S 260 . Updating the BIOS completes in step S 270 . 
         [0029]    In the current computer technology, Intel has proposed a technique of a descriptor mode which mainly divides a flash memory on the motherboard into multiple regions and allows a plurality of elements on the motherboard to share the flash memory while only respectively accessing corresponding blocks in the flash memory. Take the flash memory on the current motherboard as an example; configuration of memory division thereof is as shown in  FIG. 3 . Referring to  FIG. 3 , a flash memory  300  includes four blocks  310 ˜ 340 . The block  310  stores a boot block of BIOS, the block  320  stores a main BIOS of the BIOS, the block  330  stores a program code of a management engine (ME) or a gigabit Ethernet network (GbE), and the block  340  stores a descriptor table. The descriptor table in the block  340  includes a plurality of sections, each of which respectively has different data. Part of data in the region is used to define each of the blocks of the flash memory and to record an initial address and length of each block. 
         [0030]    Take a current computer system which supports the descriptor mode. When the computer system starts up, a computer chip first reads the descriptor table in the flash memory and obtains an address of the BIOS in a region portion of the descriptor table. The computer chip is a south bridge chip, for example. A chip integrating a south bridge chip and a north bridge chip is also a feasible embodiment, which is not limited by the present invention herein. After obtaining the address of the BIOS, a central processor begins to execute the BIOS program code so that the computer system may enter a start-up process. Therefore, when the BIOS update fails, the boot block or the main BIOS of the BIOS may be damaged such that the computer system is not able to execute the boot block, resulting in the computer system&#39;s failure to normally start up. 
         [0031]    A new backup memory block may be additionally defined in, for example the flash memory, in the present embodiment. The new backup memory block is to be regarded as a backup memory block and used to store a backup boot block. In addition, configuration of division of the flash memory is as shown in  FIG. 4 . Blocks  410 ˜ 440  are identical to the blocks  310 ˜ 340  in  FIG. 3 . A block  450  is a backup memory block of the present embodiment. During the process of updating BIOS in the present embodiment, after a boot block  410  of the original BIOS is copied to the backup memory block  450 , BIOS address recorded in a region portion of a descriptor table  440  is to be changed to point to the backup memory block  450 . The BIOS address recorded in the region portion of the descriptor table  440  is to be restored to point to the original boot block  410  after the BIOS update completes. 
         [0032]    In the above embodiment, although only the boot block of the BIOS is copied to the backup memory block, persons having ordinary skill in the art should appreciate that the entire BIOS (e.g. the boot block and the main BIOS) may be copied to the backup memory block. 
         [0033]    It should be noted that the above embodiment has depicted a possible mode for updating BIOS. However, persons skilled in the art should realize that design methods applied in various computer systems are distinct. Hence, the application of the present invention is not to be limited to the possible mode described herein. In other words, any method involving changing an address data in a descriptor table to dynamically point to a backup memory block and then performing updating a part of a BIOS program code falls within the spirit of the present invention. 
         [0034]    In light of the method for updating the BIOS in the above embodiment, a computer system may still use data in the backup memory block to boot in the case of a BIOS update failure. Therefore, in the above embodiment, after the boot block of the first region is cleared in step S 240  above, the boot block will be damaged under the circumstances when the computer system is powered off or reset. The following illustrates how to repair the BIOS in the present embodiment. 
         [0035]      FIG. 5  is a flowchart illustrating a method of repairing BIOS according to an embodiment of the present invention. Referring to  FIG. 5 , a computer system is turned on in step S 500 . Next, a computer chip of the computer system first detects whether the computer system is in a descriptor mode in step S 510 . If the computer system is detected to be in a descriptor mode, the computer chip first reads a descriptor table in a flash memory in step S 520  and obtains an address of a backup memory block from an address data in the descriptor table in step S 530 . From the method for updating BIOS in the above embodiment, the address data in the descriptor table points to the backup memory block before the BIOS update completes. 
         [0036]    Then, a backup program code in the backup memory block are read in step S 540  and executed to start up the computer system in step S 550 . The backup program codes are a boot block of the BIOS, for example. Thus, some elements in the computer system (e.g. a floppy disk drive, a USB interface, and a random access memory) have been initialized after the computer system completes executing the boot block. The elements may then normally operate. The computer system then receives an updated program code from a peripheral device (e.g. a floppy disk drive or a USB storage medium) in step S 560 , stores the updated program code in a random access memory in step S 570 , and then writes the updated program code in a non-volatile memory in step S 580  so as to complete repairing the BIOS in step S 590 . The abovementioned updated program code may be an entire BIOS program code and may also only include a program code of a main BIOS or a boot block. 
         [0037]    In order for those having ordinary skill in the art to implement the present invention through the teachings of the present embodiment, yet another embodiment of the method for updating BIOS is illustrated below. 
         [0038]      FIG. 6  is a flowchart illustrating a method for updating BIOS according to another embodiment of the present invention. Before illustrating the present embodiment, the present embodiment is assumed to be in the same condition as  FIG. 2  above and the BIOS is assumed to be stored in a flash memory as shown in  FIG. 4 , for example. Referring to both  FIG. 4  and  FIG. 6 , updating the BIOS begins in step S 600 . First, a descriptor table  440  is read through a computer chip of a computer system in step S 610  to obtain an address of the BIOS in a non-volatile memory. Next, a second region of the non-volatile memory is cleared in step S 615 . The second region is the block  420  in  FIG. 4 , for example. Then, updated main BIOS is written in the second region in step S 620 . Here, the updated main BIOS is obtained from peripheral devices of the computer system (e.g. a floppy disk drive, a USB storage medium, and an optical disk drive). 
         [0039]    Next, a determination is made on whether the computer system is to update a boot block in step S 625 . If the computer system is not to update the boot block, updating the BIOS ends in step S 630 . When the computer system determines that the boot block is to be updated, the BIOS boot block stored in the first region (i.e. the block  410  in the flash memory) is to be copied to the backup memory block  450  in step S 640 . Next, an address data in the descriptor table is to be changed to point to the abovementioned backup memory block  450  in step S 650 . Then, data in the block  410  is to be cleared in step S 660 . In addition, an updated program code is written in the block  410  in step S 670  to update the boot block in the BIOS. Finally, the address dada in the descriptor table is to be restored to point to an original address of the original BIOS in step S 680 . Updating the BIOS completes in step S 630 . 
         [0040]    In summary, in the present invention, a part of the BIOS program code is backed up in a backup memory block so when the BIOS update fails, the computer system may still use the backed up part of the BIOS program code to boot and then repair the BIOS after booting. 
         [0041]    It will be apparent to those of ordinary skills in the technical field that various modifications and variations can be made to the structure of the present invention without departing from the scope or spirit of the invention. In view of the foregoing, it is intended that the present invention covers modifications and variations of this invention provided they fall within the scope of the following claims and their equivalents.