Summary of the invention
The present invention in view of the drawbacks of the prior art, provides a kind of method for repairing hard disk ROM by BootCode, can have
Solution the above-mentioned problems of the prior art of effect.
A method of hard disk ROM, including below step are repaired by BootCode:
S1: hard disk ROM is read by BootCode mode using faulty disk com port, the detailed step of the S1 is as follows:
S101: check whether disk C OM mouthfuls connect normally;
S102: judging whether hard disk is under bootcode, if so then execute S103;If not then opening again electric and continuous
" U " instruction is sent to hard disk, allows hard disk to enter bootcode, executes S103;
S103: it is offset to address " 0x100000 ";
S104: since the offset address, 512 bytes are read, and the data of return are stored in Buffer1;
S105: judging whether the value that the position 0xAC is deviated in buffer1 is less than " 0x200000 ", if so then execute S106,
If guidance file otherwise is written in bootcode, bootcode is initialized;
S106: by the value of the position 0xAC in S105 and " 0xFFFFFF00 " progress " with operation ", acquisition refetches address;
S107: it is offset to and refetches address: by instructing AP " 0x refetches address " to be deviated;
S108: reading refetches 512 bytes behind address, and returned data is stored in buffer2;
S109: the value and " 0xFF " progress " with operation " of the position 0xAC, one word of obtained low level are deviated in buffer1
It saves as the deviation post in Buffer2 for determining 512 stressed bytes;
S110: the content and " 0000C0C1C1810140C30103C00280C2 of 16 byte lengths are taken backward from the position
41 " compare;If equal execution S111, guidance file is modified if unequal can normally read ROM, execute
S111;
S111: hard disk is written into guidance file, " 0x401 " is navigated to, inputs 1024 GO, obtain in returned ROM
Hold;
S2: SAP, RAP, CAP and SHELL data volume in ROM are found, and above-mentioned data volume is covered in adaptation ROM, shape
The ROM of Cheng Xin;
S3: by the ROM after adaptation again write-back hard disk.
Preferably, the detailed step of the S2 is as follows:
S201: the storage location of intracorporal SAP, RAP, CAP and SHELL data volume of ROM data is found;
S202: the size of SAP, RAP, CAP and SHELL data volume is calculated, and is extracted;The calculation method of the size is 4
A byte is one group, rear three bytes of one group of data after SAP, RAP, CAP and SHELL feature subtract SAP, RAP, CAP and
The value of three bytes is equal to the size of SAP, RAP, CAP and SHELL data volume after SHELL feature;
S203: looking for a kind of adaptation ROM code of lowest version, finds SAP, RAP, CAP and SHELL data volume of adaptation ROM,
Faulty disk SAP, RAP, CAP and SHELL data volume is covered in adaptation ROM, forms new ROM, and by new ROM Write fault
Disk.
The detailed step of the S3 is as follows:
S301: check whether disk C OM mouthfuls connect normally;
S302: judging whether hard disk is under bootcode, if so then execute S304;If not then opening again electric and continuous
" U " instruction is sent to hard disk, allows hard disk to interrupt it and normally leads into bootcode, re-execute S302;
S304: check ROM integrality: whether the size for judging the ROM is 512kb, if so then execute S305, if not
Then indicate that ROM is abnormal, re-executes S203;
S305: positioning to address 0x1000000;
S306: 256 bytes are read since the position and return to buffer3;
S307: it takes 4 bytes to be judged at the 0xAC of buffer3, if it is greater than 0x200000, then modifies write-in
Guidance file allow to be normally written execute S308, on the contrary it is then it is not necessary to modify execution S309;
S308: amended guidance file is written at 0x400 in positioning address;
S309: then positioning address starts the write-in of ROM data at 0x401.
Compared with prior art the present invention has the advantages that repairing hard disk success rate height, reduce because hard disk failure causes to count
According to loss brought by loss.
Specific embodiment
To make the objectives, technical solutions, and advantages of the present invention more comprehensible, by the following examples, to the present invention do into
One step is described in detail.
A method of hard disk ROM, including below step are repaired by BootCode:
S1: hard disk ROM is read by BootCode mode using faulty disk com port;
S2: SAP, RAP, CAP and SHELL data volume in ROM are found, and above-mentioned data volume is covered in adaptation ROM, shape
The ROM of Cheng Xin;
S3: by the ROM after adaptation again write-back hard disk.
The detailed step of the S1 is as follows:
S101: check whether disk C OM mouthfuls connect normally;
S102: judging whether hard disk is under bootcode, (by whether BootCmds can be obtained: character string determines, energy
Obtaining then representative is under bootcode), if so then execute S103;If not then opening electricity again and continuously being sent to hard disk
" U " instruction allows hard disk to interrupt it and normally leads into bootcode, executes S103;
S103: it is offset to address " 0x100000 ";
S104: since the offset address, 512 bytes are read, and the data of return are stored in Buffer1;
S105: judging whether the value that the position 0xAC is deviated in buffer1 is less than " 0x200000 ", if so then execute S106,
If guidance file otherwise is written in bootcode, bootcode is initialized;
S106: by the value of the position 0xAC in S105 and " 0xFFFFFF00 " progress " with operation ", acquisition refetches address;
S107: it is offset to and refetches address: by instructing AP " 0x refetches address " to be deviated;
S108: reading refetches 512 bytes behind address, and returned data is stored in buffer2;
S109: the value and " 0xFF " progress " with operation " of the position 0xAC, one word of obtained low level are deviated in buffer1
It saves as the deviation post in Buffer2 for determining 512 stressed bytes;
S110: the content and " 0000C0C1C1810140C30103C00280C2 of 16 byte lengths are taken backward from the position
41 " compare;If equal execution S111, guidance file is modified if unequal, and (guidance file is at BootCode
Read ROM, the file write in advance) ROM can be normally read, execute S111;
S111: hard disk is written into guidance file, " 0x401 " is navigated to, inputs 1024 GO, obtain in returned ROM
Hold;
The detailed step of the S2 is as follows:
It should be noted that " XX " that appear below is random number;
S201: the storage location of intracorporal SAP, RAP, CAP and SHELL data volume of ROM data is found;Here SAP is found
Storage address there are two types of mode, the first are as follows: look for the head ROM, with 4 bytes for one group, find SAP feature
" 05XXXXXX ", RAP feature " 04XXXXXX ", CAP feature " 06XXXXXX " and SHELL feature " 0BXXXXXX ", the value are
The head bias feature of SAP, RAP, CAP and SHELL data volume jumps and SAP, RAP, CAP and SHELL data volume head can be obtained
Portion position.
Second are as follows: be one group in the head ROM with 4 bytes and retrieved, find the base address SAP, RAP, CAP and SHELL
Offsets " 24XXXXXX " are retrieved backward for one group with 4 bytes after being jumped by this feature and find SAP feature
" 05XXXXXX ", RAP feature " 04XXXXXX ", CAP feature " 06XXXXXX " and SHELL feature " 0BXXXXXX ".
Such as: the base address SAP feature is " 24000001 ", then " 0x10000 " is exactly SAP base address offset feature, is jumped
It is one group after turning with 4 bytes and retrieves " 05866800 " backward,
Obtaining SAP data volume head bias position by " 0x10000 "+" 0x6886 "=" 0x18668 " is
“0x18668”。
S202: the size of SAP, RAP, CAP and SHELL data volume is calculated, and is extracted;The calculation method of the size is 4
A byte is one group, rear three bytes of one group of data after SAP, RAP, CAP and SHELL feature subtract SAP, RAP, CAP and
The value of three bytes is equal to the size of SAP, RAP, CAP and SHELL data volume after SHELL feature.
Such as SAP feature is that " 05000007 " is followed by RAP feature " 06005007 ", then passing through
" 0x075000 "-" 0x070000 " obtains SAP data volume size.
S203: looking for a kind of lowest version (lowest version relative to current ROM) ROM code of adaptation, finds adaptation ROM's
SAP, RAP, CAP and SHELL data volume cover faulty disk SAP, RAP, CAP and SHELL data volume in adaptation ROM, composition
New ROM, and by new ROM Write fault disk.
The detailed step of the S3 is as follows:
S301: check whether disk C OM mouthfuls connect normally;
S302: judging whether hard disk is under bootcode, (by whether BootCmds can be obtained: character string determines, energy
Obtaining then representative is under bootcode).If so then execute S304;If not then opening electricity again and continuously being sent to hard disk
" U " instruction, allows hard disk to interrupt it and normally leads into bootcode, re-execute S302;
S304: check ROM integrality: whether the size for judging the ROM is 512kb, if so then execute S305, if not
Then indicate that ROM is abnormal, returns to S203;
S305: positioning to address 0x1000000;
S306: 256 bytes are read since the position and return to buffer3;
S307: it takes 4 bytes to be judged at the 0xAC of buffer3, if it is greater than 0x200000, then modifies write-in
Guidance file allow to be normally written execute S308, on the contrary it is then it is not necessary to modify execution S309;
S308: amended guidance file is written at 0x400 in positioning address;
S309: then positioning address starts the write-in of ROM data at 0x401.
Those of ordinary skill in the art will understand that the embodiments described herein, which is to help reader, understands this hair
Bright implementation method, it should be understood that protection scope of the present invention is not limited to such specific embodiments and embodiments.Ability
The those of ordinary skill in domain disclosed the technical disclosures can make its various for not departing from essence of the invention according to the present invention
Its various specific variations and combinations, these variations and combinations are still within the scope of the present invention.