Adopt the intelligent card embedded software system implementation method of lagic interval chained list addressing
The present invention relates to the implementation method of a kind of intelligent card embedded software system, exactly, the implementation method that relates to the intelligent card embedded software system of a kind of employing " lagic interval chained list addressing ", the design field that belongs to the intelligent card embedded software system, software systems wherein comprise intelligent cards internal operating system COS (Chip Operating System) and smart card file system.
" Golden Card Program " (that is: electronic money engineering) is to advance one of informationalized Important Project of Chinese national economy, it is to be media with the smart card, utilize existing Internet resources, assist bank to promote credit card and cash card, realize that progressively cash deposits the electronization of converting and paying; For industries such as commerce and trade and tourism provide the E-Payment means, reduce the circulation of cash; Smart card also can be widely used in every field such as traffic administration, medical insurance, Telephone Payment, automobile fuel filler paying, its influence surface extensively be unprecedented.The intelligent card embedded software system is the headquarter of smart card operate as normal, and it is controlling smart card and extraneous message exchange; Storer in the control card is also finished the processing of command adapted thereto.The intelligent card embedded software system comprises intelligent cards internal operating system COS and smart card document system, smart card COS is the management carrier of embedded software, file system then is the entity that the COS operation moves and depends on for existence, and the most of instruction of COS is for being kept at E
2Data file service among the PROM (Electrically Erasable Read Only Memory), its Design of File Systems thinking has determined COS to E basically
2The managerial ability of data among the PROM.The traditional approach that generally uses is with E at present
2PROM integrally independently treats it as a continuous storage unit, and wherein each storage area still lacked effective ladder of management and way; In addition, since the restriction of production technology, E
2PROM has small size storage area generation corrupted phenomenon sometimes; And, similar as widely used floppy disk on the microcomputer, E
2PROM also has the restriction in serviceable life.But traditional COS can't address the above problem at all, even E
2PROM is that access inefficacy or mistake appear in some bytes or some zones, just mean scrapping of whole sheet smart card, certainly will increase the cost of smart card management, production, use so greatly and shorten serviceable life of smart card, the market competition of smart card vendor has been brought adverse effect.
The implementation method that the purpose of this invention is to provide a kind of intelligent card embedded software system, a kind of implementation method that adopts the intelligent card embedded software system of lagic interval chained list addressing just is provided, so that can overcome the unreasonable above-mentioned multiple adverse effect of bringing of present intelligent card embedded software system design, simultaneously also make the application of IC cards merchant provide more, more flexible, featured services, use for the penetration and promotion of smart card and make contributions to the user.
The object of the present invention is achieved like this: a kind of implementation method that adopts the intelligent card embedded software system of lagic interval chained list addressing, and it is characterized in that: it includes the following step:
(1) at first, in the intelligent card embedded software system, introduce " between logic area ", " file allocation table " and " file directory list item " three notions; Wherein " between logic area " is with E
2Storage space people in the PROM is for setting E for
2Continuous a plurality of address spaces---between logic area, its size is 2 in the PROM
nIndividual byte, wherein n is a positive integer, span can be according to E between 5~10
2The PROM size is set up on their own by the user; " file allocation table (FAT table) " is the single-track link table of an expression file storage address, file logging is being that its information content is deposited by unit between logic area, the list item of a corresponding file allocation table between each logic area, COS locatees or the addressing file according to the file allocation table between logic area; The list item of each file allocation table can have following four kinds may: between 1. untapped logic area, 2. between next logic area number, 3. between bad logic area number, 4. be the file allocation table last-of-chain of a file between this logic area; " file directory list item " is a parameter list of file index, is used for the each side characteristic of description document;
(2) with E
2The PROM storage space is according to being divided into three parts by the low side address to the order of high-end address: file allocation list area, file directory district and data field; Wherein the contents in table of file allocation table is placed in the file allocation list area, and the file directory list item is placed in the file directory district, and normally has what files what file directory list items are just arranged, and the particular content of file is then deposited in the data field;
(3) above-mentioned file allocation list area, file directory district and data field three parts are carried out initialization, assignment respectively, and set up simultaneously and distribute list area, file directory district, data field three parts corresponding relation each other;
(4) according to distributing list area, file directory district and data field three parts corresponding relation each other to write the relevant addressed instruction of COS, with realize COS to the addressing visit of file, revise and to the mistake that the occurs revisal of making amendment;
(5) last, to the E of smart card
2The PROM storage space carries out readwrite tests, after test, to being judged as normally functioning zone, it is labeled as the utilogic interval; Bad when regional when finding to have, only need to be labeled as between bad logic area between the logic area that it is corresponding, make COS no longer read and write the storage space that uses this part; And in the smart card use E appears
2During the PROM write error, COS can call and " write E
2PROM is unusual " handle subroutine, file content is transferred to E
2In the not usage space of PROM, thereby can not influence the use of this smart card.
Four kinds of list items of each file allocation table can be used following character representation: between the logic area that use at (1) end: 0000h, (2) between next logic area number: 0001h-fff6h, (3) between bad logic area number: Fff7h is the file allocation table last-of-chain of a file: Fff8h-ffffh between (4) this logic area.
The file directory list item is the each side characteristic of description document, and its characteristic includes: the multiple information of number class between the first logic area of the size of the attribute of file, type, file, document storage.
This document directory entry can adopt following structure: wherein top two byte representation document numbers, then per two of tactic six bytes subsequently are one group, respectively between the initial logic area of expression storage this document number, the size of this document and the attribute of this document; In two bytes of expression file attribute, wherein the different numerical value of two of first byte bits are used to represent that four kinds of file are dissimilar: transparent file, linear fixed-length file, linear non-fixed-length file and circular file, and the different numerical value of two bits are then represented catalogue file and key file respectively in addition; Other remaining four bits and another byte are then waited until extended use from now on.
The relevant addressed method of COS has two kinds in above-mentioned (4) step: first kind is to be provided with for the file under the root directory: its file allocation watch chain is between the first logic area that at first is positioned at from this document in the root directory item storage space number, search out between its next logic area number in the address of file allocation table, and and this logic area between number corresponding file logging content stores at E
2The address in PROM space also obtains between next logic area number the address in file allocation table simultaneously again; FFFF, the expression end of file number appear in the continuation of so always postponing up between logic area; The length of its file allocation watch chain depends on the length of this document; By being converted into E with between the logic area of file number
2The memory address of PROM just can obtain the data content of this document; Second kind is to be provided with for the file under the sub-directory: the file structure under the sub-directory and its distribute the list area, the file directory district, relation between the three of data field is very similar with the relation between the three of above-mentioned root directory, its difference is because the directory entry between the first logic area of file under the sub-directory number is to be kept in the data field of upper level catalogue, when locating the file logging under certain sub-directory, at first be to locate its upper level catalogue, then from the data field of upper level catalogue, find the directory entry of this document again, from this directory entry, search out then between the first logic area of this document number, search out simultaneously between its next logic area number in the address of file allocation table, and and this logic area between number corresponding file logging content stores at E
2The address in PROM space also obtains between next logic area number the address in file allocation table again; The continuation of so always postponing just can obtain the file allocation watch chain of this document; FFFF number appears up between logic area, the expression end of file.
Increase by degrees for the file addressing process under the sub-directory, n level catalogue is promptly arranged, will repeat above-mentioned sub-directory addressing process for n time, wherein n is a positive integer, and span is between 5~10.
After the implementation method of logic-based interval chain list structure of the present invention addressing is applied to the intelligent card embedded software system, just can in the intelligent card embedded software system, carry out read-write operation flexibly on the microcomputer as to catalogue and file.The developer of smart card system software just can be for smart card increase perfect functions more, for the client provides flexible, various service.This method not only can make smart card after distribution or the user can dynamically increase, delete wherein catalogue and file between the operating period, make the application of smart card widen more and extend; Lifting by software design technology simultaneously, can improve the yield rate when smart card is produced greatly, and can revise and remedy the local corrupted that occurs in the smart card use, thereby prolong serviceable life of smart card, smart card can be more widely used.
Describe method step of the present invention and characteristics in detail below in conjunction with accompanying drawing:
Fig. 1 is the schematic flow sheet of implementation method step of the present invention.
Fig. 2 is the implication and the corresponding characters comparative examples figure of four kinds of different situations in the FAT list item of the present invention.
Fig. 3 is the byte correspondence position of the present invention's " file directory list item " lining and the comparative examples figure of implication thereof.
Fig. 4 is the comparative examples figure of the implication of each bit correspondence position in the present invention's " file attribute " byte.
Fig. 5 is E of the present invention
2Memory space address in the PROM distributes synoptic diagram.
Fig. 6 is that the present invention is used for the file addressing step synoptic diagram under the root directory.
Fig. 7 is that the present invention is used for the file addressing step synoptic diagram under the sub-directory.
Referring to Fig. 1-Fig. 5, the present invention is the implementation method of the intelligent card embedded software system of a kind of employing " lagic interval chained list addressing ", and its concrete operations step is as follows:
(1) at first, in the intelligent card embedded software system, introduce " between logic area ", " file allocation table (FAT table) " and " file directory list item " three notions; Wherein " between logic area " is with E
2Storage space people in the PROM is for setting E for
2Continuous a plurality of address spaces---between logic area, its size is 2 in the PROM
nIndividual byte, wherein n is a positive integer, span can be according to E between 5~10
2The PROM size is set up on their own by the user; " file allocation table (FAT table) " is the single-track link table of an expression file storage address, file logging is being that its information content is deposited by unit between logic area, the list item of corresponding FAT table between each logic area, COS locatees or the addressing file according to the chained list between logic area (being the FAT table); The list item of each FAT table can have following four kinds may: between 1. untapped logic area, 2. between next logic area number, 3. between bad logic area number, 4. be the FAT last-of-chain of a file between this logic area; Referring to Fig. 2, four kinds of list items of each FAT table can be used following character representation: between 1. untapped logic area: 0000h, 2. between next logic area number: 0001h-fff6h, between 3. bad logic area number: 4. Fff7h is the FAT last-of-chain of a file: Fff8h-ffffh between this logic area." file directory list item " is a parameter list of file index, is used for the each side characteristic of description document.The file directory list item is the each side characteristic of description document, and its characteristic includes: the multiple information of number class between the first logic area of the size of the attribute of file, type, file, document storage.The type of file has: proprietary file DF (Dedicated File), basic document EF (ElementaryFile).Fig. 3 has showed an embodiment of " file directory list item ", can be for user of the present invention with reference to reference.This document directory entry can adopt following structure: wherein top two byte representation document numbers, then per two of tactic six bytes subsequently are one group, respectively between the initial logic area of expression storage this document number, the size of this document and the attribute of this document.In two bytes of expression file attribute (referring to Fig. 4), wherein the different numerical value of two of first byte bits are used to represent that four kinds of file are dissimilar: transparent file, linear fixed-length file, linear non-fixed-length file and circular file, and the different numerical value of two bits are then represented catalogue file and key file respectively in addition; Other remaining four bits and another byte are then waited until extended use from now on.
(2) with E
2The PROM storage space is according to being divided into three parts by the low side address to the order of high-end address: file allocation list area, file directory district and data field; Wherein the contents in table of file allocation table (FAT table) is placed in the file allocation list area, and the file directory list item is placed in the file directory district, and normally has what files what file directory list items are just arranged, and the particular content of file is then deposited in the data field; As shown in Figure 5.
(3) above-mentioned file allocation list area, file directory district and data field three parts are carried out initialization, assignment respectively, and set up simultaneously and distribute list area, file directory district, data field three parts corresponding relation each other;
(4) according to distributing list area, file directory district and data field three parts corresponding relation each other to write the relevant addressed instruction of COS, with realize COS to the addressing visit of file, revise and to the mistake that the occurs revisal of making amendment;
The relevant addressed method of COS has two kinds in above-mentioned (4) step: first kind is (referring to the Fig. 6) that is provided with for the file under the root directory: its FAT chain is between the first logic area that at first is positioned at from this document in the root directory item storage space number, search out between its next logic area number in the address of FAT table, and and this logic area between number corresponding file logging content stores at E
2The address in PROM space also obtains between next logic area number the address at the FAT table simultaneously again; FFFF, the expression end of file number appear in the continuation of so always postponing up between logic area; The length of its FAT chain depends on the length of this document; By being converted into E with between the logic area of file number
2The memory address of PROM just can obtain the data content of this document.
Second kind of the relevant addressed method of COS is (referring to the Fig. 7) that is provided with for the file under the sub-directory in above-mentioned (4) step: the file structure under the sub-directory and its distribute the list area, the file directory district, relation between the three of data field is very similar with the relation between the three of above-mentioned root directory, its difference is because the directory entry between the first logic area of file under the sub-directory number is to be kept in the data field of upper level catalogue, when locating the file logging under certain sub-directory, at first be to locate its upper level catalogue, then from the data field of upper level catalogue, find the directory entry of this document again, from this directory entry, search out then between the first logic area of this document number, search out simultaneously between its next logic area number in the address of FAT table, and and this logic area between number corresponding file logging content stores at E
2The address in PROM space also obtains between next logic area number the address at the FAT table again; The continuation of so always postponing just can obtain the FAT chain of this document; FFFF number appears up between logic area, the expression end of file.
Increase by degrees for the file addressing process under the sub-directory, n level catalogue is promptly arranged, will repeat above-mentioned sub-directory addressing process for n time, wherein n is a positive integer, and span is between 5~10; At first must read the content of file directory list item during the COS accessing file.
5) last, to the E of smart card
2The PROM storage space carries out readwrite tests, after test, to being judged as normally functioning zone, it is labeled as the utilogic interval; Bad when regional when finding to have, only need to be labeled as between bad logic area between the logic area that it is corresponding, make COS no longer read and write the storage space that uses this part; And in the smart card use E appears
2During the PROM write error, COS can call and " write E
2PROM is unusual " handle subroutine, file content is transferred to E
2In the not usage space of PROM, thereby can not influence the use of this smart card.
The present invention has been programmed by the applicant and carried out l-G simulation test enforcement in smart card COS system, has obtained the design effect of expection, has realized goal of the invention.