[summary of the invention]
The invention provides a kind of management method of storage space of electronic hard disc, improve the operating efficiency of reading and writing data, improve usability, reduce cost.
For achieving the above object, the invention provides a kind of electronic hard disc, comprise central processing unit, interface controller, static RAM, flash memories, described central processing unit inside is provided with the firmware memory of store electrons disk read-write control data and program, described interface controller is connected with central processing unit and is connected with the data processing equipment of outside and carries out data transmission and read-write, described storer comprises some storage blocks, each storage block is divided into data field and status indicator district, the status indicator district comprises logical address area, the data mode tag slot, the storage block tag slot, whether the data field that each storage block is stored in described data mode tag slot writes the state of data, described logical address area recorded data zone writes the logical address of this data field of setting up after the data, unique identification marking of storage data field, described storage block tag slot; When described electronic hard disc was connected with external data processing device by interface controller, look-up table was one to one set up between the physical address of the storage block sign of storage block tag slot of storage block and storage block in the electronic hard disc initialization in the static RAM.
Another object of the present invention provides a kind ofly carries out the method for data write operation to above-mentioned electronic hard disc, comprises the steps:
1), finds the required storage block that writes of data according to look-up table, the storage data field, data mode tag slot of described each storage block writes the data mode sign of " storage " or " sky " of data, if the data mode of this storage block is designated " storage ", then the storage block sign of this storage block is mapped to the rearmost position of the free block formation of look-up table, execution in step 2); If the data mode of this storage block is designated " sky ", then data are write this storage block, execution in step 3);
2) inquire about look-up table, data are write the storage block of free block formation primary importance in the look-up table;
3) set up the logical address of the storage block write data, this logical address and corresponding storage block sign are write to the primary importance that data mode in the look-up table is designated storage block identification information in the data field formation of " storage ";
4), data write operation is finished.
The present invention also further provides the improvement technical scheme of the method for above-mentioned data write operation, when described electronic hard disc is in the non-read-write operation state of data, described memory controller carries out erase operation with the storage block that the data mode in the look-up table is designated storage, discharges logical address simultaneously.
As shown from the above technical solution, the data write operation method of the management method of the storage space of electronic hard disc of the present invention and this electronic hard disc, physical address by setting up limited storage block sign and storage block in static RAM is the mode of look-up table one to one, occupying system resources is few, simplify the reading and writing data management of electronic hard disc, improve the usability of electronic hard disc.
[embodiment]
Reach technological means and the effect that predetermined purpose is taked for further setting forth the present invention, below in conjunction with drawings and Examples, embodiment, architectural feature and effect thereof to the management method of the storage space of electronic hard disc of the present invention are described in detail as follows.
See also Fig. 1, the management method of the storage space of electronic hard disc of the present invention, comprise the interface controller that is provided with data-interface, flash memories, central processing unit and static RAM, flash memories comprises some storage blocks, central processing unit inside is provided with firmware memory, this firmware memory store electrons disk read-write control data and program, promptly be called " Firmware " (firmware), storer comprises some storage blocks, each storage block is divided into data field and status indicator district, and the status indicator district comprises the logical address tag slot, the data mode tag slot, the storage block tag slot.Whether storage data field, data mode tag slot writes the state of data.Logical address area identification data district writes the logical address of this data field of setting up after the data.When electronic hard disc of the present invention is connected with external data processing device, the electronic hard disc power-up initializing, static RAM is set up between the physical address of the storage block sign of storage block and storage block look-up table one to one.
As shown in Figure 2, each storage block of electronic hard disc of the present invention is divided into data field and status indicator district.The data area stores data, the status indicator district is used to write down the information of the state data memory of corresponding data field, and status indicator is divided into logical address area, data mode tag slot and storage block tag slot.After the logical address area recorded data zone storage data, system sets up the logical address of this data field.The state data memory of data mode tag slot storage data field, when data area stores has data, being designated of data mode tag slot " storage "; When data are not stored in the data field, being designated of data mode tag slot " sky ".Unique identification marking of storage data field, storage block tag slot, promptly, corresponding to each data field in each storage block unique fixing identification marking is arranged all, this identification marking becomes system carries out data read-write operation to the different pieces of information district of storage block sign, so the unique fixing identification marking of each data field is stored to the storage block tag slot.
Be the structure of the storage block that specifies electronic hard disc of the present invention, below concrete storage block in 2,3 in conjunction with the accompanying drawings be that example describes.
Again as shown in Figure 2, in the diagram of present embodiment, be simple and clear structure and the principle of work of describing the storage block of electronic hard disc of the present invention, different numberings is all adopted in each data field at storage block, use alphabetical A1, A2, A3 ... expression, the logical address of logical address area adopts letter b 1, B2, B3 ... expression, letter C 1 is adopted in the storage block tag slot, C2, C3 ... expression, each data field look-up table of corresponding stored piece is set up physical address one by one, above-mentioned alphabetic flag only for ease of the explanation electronic hard disc of the present invention storage block design feature and identify, non-in order to the restriction the present invention.
All there is unique identification marking each data field, this identification marking is stored to the storage block tag slot, for example, when the data area stores of storage block A1 has data, system sets up data field A1 logical address B1, the data mode tag slot is designated " storage ", data are not all stored in the data field of storage block A4, A5, the sign of data mode tag slot is " sky ", logical address area does not write down the unallocated logical address of expression system, and the sign C4 of storage block tag slot, C5 are used for divided data district, tag slot A4, A5.
In conjunction with consulting Fig. 4, when electronic hard disc of the present invention and external data processing device (as computing machine) when being connected, electronic hard disc powers on, carry out initialization, the look-up table one to one between the physical address of the storage block sign of storage block and storage block is set up in static RAM inside, instruct when electronic hard disc of the present invention receives data write operation, data write operation comprises the steps:
1), finds the data field of physical address B 1 correspondence of the storage block A1 that data need write according to the storage block in look-up table sign C1;
2) whether the data mode tag slot sign of judging the data field of storage block A1 is empty, if the data mode tag slot of storage block A1 is " storage ", then carries out next step 3); If the data mode tag slot of storage block A1 is " sky ", carry out step 2.1);
2.1) write the data field of data to storage block A1, the data mode tag slot of storage block A1 is designated " storage ";
2.2) assign logical addresses gives storage block A1, the logical address of storage block A1 and storage block sign are write the primary importance of the data field formation (the data mode tag slot of the data field correspondence of storage block for the data field of " storage " according to going into the principle that afterwards the goes out formed formation of sorting earlier) of look-up table, execution in step 7);
3) data field of storage block A1 has stored data, so, the storage block sign C1 of the data field of storage block A1 is aligned to the least significant end position of the free block formation (the data mode tag slot of the data field correspondence of storage block is arranged formed formation for the storage block of " sky " according to the stacking order of first in first out) of look-up table according to the stacking order of first in first out, in this specific embodiment, the storage block sign C1 of the data field correspondence of storage block A1 is aligned to the back of storage block sign C5 of the data field correspondence of storage block A5;
4) the inquiry look-up table finds the storage block A2 that is positioned at free block formation (also the storage block of unallocated logical address is according to the formed formation of the stacking order of first in first out) primary importance, that is, the data mode tag slot is the formation of the data field of " sky ";
5) data are write the data field that the storage block that comes free block formation primary importance is designated the storage block A4 of C4 correspondence, after data write this data field, correspondingly, the data mode tag slot is designated " storage ";
6) assign logical addresses B4 gives data field A4, logical address B4 and corresponding storage block sign C4 are written in the look-up table primary importance of storage block identification information in the formation of data field, in this specific embodiment, logical address B4, storage block sign C4 are write the front of logical address B2 in the look-up table, storage block sign C2 respectively, simultaneously, the data field physical address corresponding D4 of look-up table corresponding record storage block A4;
7) data write operation is finished.
As shown in Figure 4, after above-mentioned data write operation is finished, when if electronic hard disc of the present invention is in the non-read-write operation state of data, central controller carries out erase operation with the state data memory in the free block formation in the look-up table for empty data field, in this specific embodiment, the data field of erase block memory A1, the logical address B1 of release data field, and the state data memory of storage block A1 sign changed to " sky ", to carry out the next write operation of data.
Correspondence relationship information in the look-up table of electronic hard disc of the present invention between the physical address of the storage space of different storage blocks of storage and electronic hard disc, and stored relation information is a constant volume in the look-up table, in concrete enforcement, storer is divided into the information of different groups and each group of corresponding stored, for example, every group of storage space that comprises 128M, once store the correspondence relationship information of storage stack in the look-up table, when the correspondence relationship information of the storage block that system searches surpasses the memory capacity of this group in the look-up table, central processing unit is according to the information of the storage block that will search, rebulid the correspondence relationship information of all storage blocks of the group at this storage block place, thereby, follow the management method of above-mentioned storage space, the correspondence relationship information of the group of the newly-established look-up table of the same counterweight of electronic hard disc of the present invention manages.
In sum, the management method of the storage space of electronic hard disc of the present invention, the storage block sign by setting up storage block in static RAM inside and the corresponding look-up table of physical address of storage block, and look-up table is divided into data field formation and free block formation two states district according to the distribution state of logical address, thereby, find the storage block sign that need write data according to the sign of the storage block in the look-up table, thereby correspondence finds corresponding data field, if this data area stores has data, the storage block sign that then finding from the free block formation makes number one puts, thereby data are write in the corresponding data field of this storage block sign, simplify the dina base administration of storage block, only the look-up table of setting up by the storage block sign is saved the data manipulation time, promotes the efficiency of management of electronic hard disc.
Electronic hard disc of the present invention passes through central processing unit, ROM (read-only memory), the static random read-write memory, interface controller and memory controller are integrated into the controller of the interior System on Chip/SoC (System OnChip) of sheet as electronic hard disc, and look-up table only need be set up the corresponding informance relation of one group of storage block at every turn, the less resource that takies static RAM just can be carried out data write operation easily, make full use of the resource of the interior System on Chip/SoC of integrated sheet of electronic hard disc of the present invention, be convenient to the integrated level of system, improve the readwrite performance of electronic hard disc when reducing the cost of electronic hard disc, meet the development need of current electronic hard disc.
In addition, the method of the data write operation of electronic hard disc of the present invention, ordering based on the first in first out of simple storage block is carried out erase operation to storage block, the read-write wearing and tearing of balanced flash memories, prolong the life cycle of electronic hard disc, thereby improve the usability of electronic hard disc of the present invention, reduce use cost.