CN103678180A - Intelligent card nonvolatile memory management method - Google Patents

Intelligent card nonvolatile memory management method Download PDF

Info

Publication number
CN103678180A
CN103678180A CN201310619963.5A CN201310619963A CN103678180A CN 103678180 A CN103678180 A CN 103678180A CN 201310619963 A CN201310619963 A CN 201310619963A CN 103678180 A CN103678180 A CN 103678180A
Authority
CN
China
Prior art keywords
space
eep
free
page
state
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN201310619963.5A
Other languages
Chinese (zh)
Other versions
CN103678180B (en
Inventor
程诗猛
丁峰
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Wuhan Tianyu Information Industry Co Ltd
Original Assignee
Wuhan Tianyu Information Industry Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Wuhan Tianyu Information Industry Co Ltd filed Critical Wuhan Tianyu Information Industry Co Ltd
Priority to CN201310619963.5A priority Critical patent/CN103678180B/en
Publication of CN103678180A publication Critical patent/CN103678180A/en
Application granted granted Critical
Publication of CN103678180B publication Critical patent/CN103678180B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Abstract

The invention discloses an intelligent card nonvolatile memory management method. The method includes the following steps: receiving a space applying instruction submitted by an application, distributing proper space to the application according to idle space in a storage state list, and updating the storage state list and a logic distribution list; receiving a space release request instruction submitted by the application, executing space release operation according to the space release request instruction, changing state of a corresponding storage space to be idle space, and deleting a corresponding list entry in the logic distribution list; collecting fragments generated by the release operation together to form a continuous idle section for subsequent distribution and utilization. By the method, space is distributed and released according to application of the application, and reutilization of released space is realized through compact processing of the released space.

Description

The management method of smart card nonvolatile memory
Technical field
The present invention relates to the space management of smart card system nonvolatile memory, relate in particular to a kind of fast, efficiently and fully management method of the smart card nonvolatile memory of recycling that has discharged the rear FREE EXTENT FRAGMENTATION IN producing.
Background technology
In smart card system, storer (as EEPROM, FLASH, RAM etc.) space is limited, how effectively identifying, distribute and discharge storage unit, particularly how effectively to utilize the FREE EXTENT FRAGMENTATION IN producing after discharging, is a critical index weighing COS performance.
And, operating relatively with writing RAM, the operation of writing nonvolatile memory (as EEPROM, FLASH etc., hereinafter to be referred as NVM) is quite time-consuming, and card hardware itself does not guarantee the integrality of write operation.
Conventionally smart card RAM capacity be several KB to tens KB, NVM capacity is that tens KB are to hundreds of KB; And common PC in save as several GB to tens GB, hard-disk capacity is hundreds of GB to several TB, its memory span is 10 of smart card memory capacity 6doubly.Compare with PC, making full use of of smart card memory more seems particularly important.
At present smart card on the market can be realized distribution and the release of NVM mostly, but a large amount of fragments that produce after storage space reallocation after conventionally discharging can not be used again and be wasted.
Conversion from a kind of system state to another kind of state may comprise the renewal of the several storage unit of NVM.Or complete renewal these upgrade operation must be the execution of atomicity,, or keeps intact, and must not occur intermediateness.
Before affairs submit operation completes, if there is power down or other system failure, update all operation is cancelled, and returns to original state.
Compare with read operation, the write operation of NVM is quite time-consuming.So in order to improve the execution efficiency of smart card, should reduce the write operation number of times of NVM in issued transaction as far as possible.
May be former thereby need patch installing processing because having left over BUG or Function Extension etc. after smart card COS mask, patch code will be written in NVM; But the size that whether needs patch installing and patch code is " dynamically ", in the time of can not starting to design, just reserved fixed space, to patch area, so not only causes the waste in NVM space, and may cannot realize because headspace deficiency causes patch function.
Summary of the invention
A target of the present invention will provide method and the mechanism of sign, distribution, release and the free space compactness of a kind of efficient smart card NVM storage space (unit) exactly.
Another target of the present invention is exactly that a kind of NVM management method and mechanism of using in smart card system will be provided, and to avoid space waste and the running time waste in transactional cache, and ensures the consistance of transaction write operation.
Another target of the present invention is exactly to realize the dynamic assignment in NVM space and the dynamic management of patch address.
The technical problem to be solved in the present invention is the waste problem for smart card system in prior art Free up Memory fragment, and write the low defect of NVM operation effect, provide a kind of and can effectively utilize Free up Memory, improve the management method of the smart card nonvolatile memory of smart card operation efficiency.
The technical solution adopted for the present invention to solve the technical problems is:
The management method that a kind of smart card nonvolatile memory is provided, comprises the following steps:
Receive the space application instruction that application is submitted to, according to the free space in store status table, suitable free space is distributed to this application, and upgrade store status table and assignment of logical table;
Receive the space releasing request instruction that application is submitted to, according to this space releasing request instruction, carry out space releasing operation, by the status modifier in corresponding stored space, be free space, and delete the list item in corresponding assignment of logical table;
The fragment that releasing operation is produced collects and forms between a continuous free area together, so that the distribution utilization in later stage.
In method of the present invention,
Before allocation of free space state, in advance assignment of logical table and store status table are backed up respectively, produce worksheet separately;
When allocation space, the worksheet of backup is copied to respectively in cache table separately; Upgrade corresponding physical block sequence number and logical table link information in the cache table of assignment of logical table, and upgrade the use state in corresponding stored space in the cache table of store status table; Then the cache table after upgrading is copied in worksheet separately, and replace corresponding original table with worksheet.
In method of the present invention, step distributes suitable space to be specially to this application according to the free space in store status table:
From store status table, search the free space equating with applied for space length, if having, distributed to this application; If no, length is greater than to the free space of length minimum in the free space of applied for space length, distribute to this application;
If all free space length is all less than applied for space length, whether the remaining space that checks bottom, space, storer user area is more than or equal to applied for space length, if so, from the space length that the bottom distribution of allocation space is applied for, to this, apply; Otherwise apply for unsuccessfully in space.
In method of the present invention, while carrying out space releasing operation, revise the cache table of assignment of logical table and store status table, with the state in final updated store status table, and remove the record in assignment of logical table.
In method of the present invention, the step of the compact operation of storage space is specially: all space content of having used are all moved to the top of storer user area, and the free space that releasing operation is produced all moves to the bottom of storer user area.
In method of the present invention, when carrying out the operation of storage space compactness, generate the compact anti-back-up job table that pulls out information original table, after storage space compactness has operated, the anti-information backup worksheet that pulls out of compactness is replaced to the compact anti-information original table that pulls out.
In method of the present invention, also comprise step: by the spatial division of storer, be a plurality of physical blocks in advance, the length of physical block is set to 128 bytes or its integral multiple.
In method of the present invention, also comprise step:
Further storage block is divided into a plurality of memory features, the minimum memory unit that memory feature is storer, the list item in store status table records the use state of storage block and memory feature.
In method of the present invention, at the worksheet of assignment of logical table or store status table, complete after renewal, before corresponding original table is replaced, if meet accident power down, re-power the rear replacement of automatically carrying out original table;
Worksheet at assignment of logical table or store status table completes before renewal, if meet accident power down, and imperfect for the relevant work table backing up, after re-powering, automatically remove incomplete affairs, get back to the state before affairs start.
In method of the present invention, when carrying out allocation of space and space releasing operation, if the renewal of the cache table of assignment of logical table or store status table surpasses one page, first the cache table after upgrading is copied in worksheet separately.
The beneficial effect that the present invention produces is: the present invention, according to application distribution and the Free up Memory of application, processes by the compactness to Free up Memory, has realized the recycling of Free up Memory.
Accompanying drawing explanation
Below in conjunction with drawings and Examples, the invention will be further described, in accompanying drawing:
Fig. 1 is the process flow diagram of the management method of embodiment of the present invention smart card nonvolatile memory;
Fig. 2 is embodiment of the present invention logical table, state table and storage block structural representation;
Fig. 3 is embodiment of the present invention user memory district, assignment of logical table and memory state table schematic layout pattern;
Fig. 4 is that embodiment of the present invention free space is searched schematic diagram;
Fig. 5 is the compact operation of embodiment of the present invention power down preventing message structure schematic diagram;
Fig. 6 is the compact schematic flow sheet of the embodiment of the present invention.
Embodiment
In order to make object of the present invention, technical scheme and advantage clearer, below in conjunction with drawings and Examples, the present invention is further elaborated.Should be appreciated that specific embodiment described herein, only in order to explain the present invention, is not intended to limit the present invention.
The management method of smart card nonvolatile memory of the present invention can realize the implementation of the effective management and use of FREE EXTENT FRAGMENTATION IN, the NVMShi You user memory district of the present invention's management, assignment of logical table, memory state table and the compact anti-compositions such as information table that pull out, the quantity of assignment of logical table and memory state table list item is equal to the storage block quantity of user storage area, and compactness prevents that pulling out information table takies two pages of NVM spaces.
The management method of embodiment of the present invention smart card nonvolatile memory, as shown in Figure 1, comprises the following steps:
The space application instruction that S1, reception application are submitted to;
S2, according to the free space in store status table, suitable free space is distributed to this application, and upgrade store status table and assignment of logical table;
The space releasing request instruction that S3, reception application are submitted to;
S4, according to the releasing request instruction of this space, carry out space releasing operation, by the status modifier in corresponding stored space, be free space, and delete the list item in corresponding assignment of logical table;
S5, the fragment that releasing operation is produced collect and form between a continuous free area together, so that the distribution utilization in later stage.
Because the write operation of NVM can not be across page, and in page the time of write operation irrelevant with the byte number writing at every turn, the time of writing a byte and writing a whole page is identical, the Physical Page length that therefore NVM in block length and card is set matches.
Taking into account the utilization factor of NVM and write operation not across the physical characteristics of page, is the situation of 128 bytes or 256 bytes for NVM Physical Page, and definition block length equals Physical Page length; For NVM Physical Page, be 64 bytes, 32 bytes or less situation, definition block length is 128 bytes, and a piece is comprised of a plurality of Physical Page, and by Physical Page, divides page operations while upgrading.
assignment of logical table(eep_logic_table)
In order to identify easily and effectively the physical address of NVM, will use the logical table (eep_logic_table) that is similar to the FAT in DOS system.
The piece sequence number of a physical block of a list item record of logical table, and can extrapolate easily piece physical address by piece sequence number.
A logic list item is comprised of two elements: first element records physical block sequence number, 2 bytes; Second element records the logical table list item of url page, 2 bytes.
The definition of assignment of logical list structure:
typedef struct
{
U16 physical_index; The corresponding physical block sequence number of // logical page (LPAGE)
U16 next_logic_index; // link logical page (LPAGE) list item
}eep_logic_table_t;
Eep_logic_table_t far g_eep_logic_table[C_EEP_MAX_BLOCKS]; The original table of // assignment of logical table
Eep_logic_table_t far g_eep_logic_table_ebak[C_EEP_MAX_BLOCKS]; The worksheet of // assignment of logical table
Eep_logic_table_t sdata eep_logic_table_sbak[C_EEP_PAGE_SIZE/sizeof (eep_logic_table_t)]; // cache shows (being cache table)
The worksheet of g_eep_logic_table_ebak(assignment of logical table wherein) for power down preventing processes, design, its use scenes elaborates in follow-up affair mechanism again.
Because NVM writes a byte, be identical with the time of writing one page, the setting of eep_logic_table_sbak is in order to improve the execution speed of bookkeeping.
As can be seen from the above description, locate the logical table list item (each 4 bytes of original table and worksheet) that a physical block needs 8 bytes, thereby the utilization factor that the direct NVM of impact is set of physical block size.The reason place that can block length in one embodiment of the present of invention be set to 128 bytes or 256 bytes.
store status table(eep_state_table)
For the use state of effective id memory, the embodiment of the present invention can further be divided into storage block several memory features: sheet is the part in data field, and a memory feature is a minimum memory unit.
The use state of a memory feature of one bit-identify of state table: " 0 " identifies this memory feature for " free time ", " 1 " identifies this memory feature for " using ".
A list item by state table with state of a physical block identifies.The utilization factor of integrated management expense and storage space, arranges the length of rational memory feature.As sheet length is set is 16 bytes, for the situation of 128 bytes of block length, memory state table can identify by a byte use state of a piece; In like manner, the situation for 256 bytes of block length, need to identify by two bytes the use state of a piece.
The definition of store status list structure:
typedef struct
{
#if NVM_PAGE_SIZE == 128
U8 free16; The idle mark of 16 block of bytes in // page,
#elif NVM_PAGE_SIZE == 256
U16 free16; The idle mark of 16 block of bytes in // page,
#endif
// a certain position is 0: corresponding 16 block of bytes are idle
// a certain position is 1: corresponding 16 block of bytes are used
}eep_state_table_t;
Eep_state_table_t far g_eep_state_table[C_EEP_MAX_BLOCKS]; The original table of // store status table
Eep_state_table_t far g_eep_state_table_ebak[C_EEP_MAX_BLOCKS]; The worksheet of // store status table
Eep_state_table_t sdata eep_state_table_sbak[C_EEP_PAGE_SIZE/sizeof (eep_state_table_t)]; // cache table
Identical with arranging of eep_logic_table_ebak, the object that eep_state_table_ebak is set is also the processing for affair mechanism.
Identical with arranging of eep_logic_table_sbak, the object that eep_state_table_sbak is set is also in order to improve the execution efficiency of bookkeeping.
the compact anti-information table that pulls out
As the description of following " storage space is compact " part, defragmentation process is irreversible.For preventing in compact operating process interrupting causing space management chaotic because power down etc. is abnormal, need to before the compact operation of each step, first record complete compact information.
NVM is used information structure definition:
typedef struct
{
U16 index; // counter: the anti-information table sequence number of pulling out of compactness, each renewal compactness prevents pulling out information table, and this adds 1 automatically
U16 index_N; The radix-minus-one complement of // index
U16 current_logic_index; // current use logic list item
U16 null; // unused entry, merges and forms a dword with current_logic_index
U32 free_size; // remaining space byte number
}eep_status_t;
Compact sign structure body definition:
typedef struct
{
U32 reclaim_begin; // compact flow process opening flag
U32 reclaim_end; The compact complement mark of // compact flow spaces
U32 reclaim_bak; // compact flow process has completed logic table and state table backup mark
}eep_reclaim_head_t;
Compact operation information structure definition:
typedef struct
{
U16 free_page; // go to the compact new physics page page number (free page) of processing
U16 used_page; // go to the compact old physical page page number of processing (busy page)
U32 reclaim_page; // complete free_page and used_page record mark
}eep_reclaim_info_t;
The compact anti-information table definition of pulling out:
#define MAX_INFO ((C_EEP_PAGE_SIZE - sizeof(eep_status_t) - sizeof(eep_reclaim_head_t)) / sizeof(eep_reclaim_info_t))
typedef struct
{
Eep_status_t eep_status; // NVM is used information
Eep_reclaim_head_t reclaim_head; // compact sign
Eep_reclaim_info_t reclaim_info[MAX_INFO]; // compact operation information table
}anti_tearing_t;
Anti_tearing_t far anti_tearing_table; // table
Anti_tearing_t far anti_tearing_table_bak; // table two
uint16_t current_logic_index; // cache,current_logic_index = eep_status.current_logic_index
uint32_t eep_free_size; // cache, eep_free_size = eep_status.free_size
Anti_tearing_table and the anti_tearing_table_bak table that backups each other,, when anti_tearing_table is for compact anti-while pulling out information original table, anti_tearing_table_bak is the compact anti-information work table that pulls out; Otherwise when anti_tearing_table_bak is original table, anti_tearing_table is worksheet.This design is in order to guarantee the atomicity of compact operation.
memory allocation
For application, submit the space application that length is eep_size to, the present invention has first searched a length from reference position to last in eep_state_table_ebak table allocation space be just the free space of eep_size, and distributed to this application; As there is no free space just equal in length, the free space that length is greater than to length minimum in the free space of eep_size is distributed to this application.
If all free space length is all less than eep_size, check that the remaining space of user's space bottom is whether more than or equal to eep_size, as be more than or equal to eep_size, from the bottom of allocation space, distribute eep_size length space to apply to this.
Otherwise apply for unsuccessfully in space.
Allocation of space process is exactly to upgrade the process of eep_state_table_sbak and eep_logic_table_sbak, be that state_table shows corresponding state and is revised as use state " 1 " by idle condition " 0 ", and record corresponding physical block sequence number and logical table link information in logic_table table.
In allocation of space and dispose procedure, eep_state_table_sbak or eep_logic_table_sbak overflow (upgrade surpass one page), more new sheet eep_state_table_ebak or eep_logic_table_ebak accordingly.Just embody the importance that eep_state_table_sbak and eep_logic_table_sbak arrange here, only have when eep_state_table_sbak or eep_logic_table_sbak upgrade while surpassing one page and just carry out write operation, be about to eep_state_table_sbak or eep_logic_table_sbak and copy in corresponding worksheet eep_state_table_ebak or eep_logic_table_ebak.Because NVM writes a byte, be identical with the time of writing one page, so the setting of eep_state_table_sbak or eep_logic_table_sbak has improved the execution speed of bookkeeping greatly.
Allocation of space completes, free_size-=eep_size, and logic_index and eep_offset are returned to the application that apply in this space.
storage space discharges
When application proposes space releasing request, except length parameter eep_size need be provided, also need to provide parameter l ogic_index and eep_offset, and the value of these three parameters must be space application time, application must guarantee the correctness of these parameters.
The process that space discharges is exactly to upgrade the process of eep_state_table_sbak and eep_logic_table_sbak, be that state_table shows corresponding state and is revised as idle condition " 0 " by use state " 1 ", and in logic_table table record, remove corresponding physical block sequence number and logical table link information.
In the releasing operation process of space, as eep_state_table_sbak or eep_logic_table_sbak overflow (upgrade and surpass one page), need accordingly more new sheet eep_state_table_ebak or eep_logic_table_ebak.
Space discharges successfully, free_size+=eep_size.
Space after release is free space, and free space can be reallocated again.
affair mechanism
For avoiding unexpected power down etc. to cause storage space chaotic, the distribution of storage space and discharging all must be carried out in affair mechanism.
Affairs start
The original table of admin table is copied in worksheet, copy eep_state_table in eep_state_table_ebak, copy eep_logic_table in eep_logic_table_ebak.
Distribute and discharge
Worksheet is copied to cache(cache table) in, the corresponding page information that copies eep_state_table_ebak in eep_state_table_sbak, the corresponding page information that copies eep_logic_table_ebak is in eep_logic_table_sbak;
Distribute and releasing operation, revise exactly cache, revise eep_state_table_sbak and eep_logic_table_sbak, as operating process relates to sbak across page, need first sbak to be written in corresponding ebak page;
Pre-submission to
Cache is write to worksheet, be about to corresponding page that eep_state_table_sbak writes eep_state_table_ebak, by eep_logic_table_sbak be written to eep_logic_table_ebak corresponding page, eep_free_size and current_logic_index are write to anti_tearing_table or anti_tearing_table_bak (index+=1 simultaneously).
Affairs are submitted to
With worksheet, replace original table: eep_logic_table_ebak is copied (writing) to eep_logic_table, eep_state_table_ebak is copied to (writing) to a little table of index value in eep_state_table, release (wiping) anti_tearing_table and anti_tearing_table_bak.
Before powering on, roll
As pre-submission completes, and affairs are submitted the power down that meets accident while not yet completing to, because admin table has backed up completely, re-power the rear affairs that automatically complete and submit flow process to, complete issued transaction, carry out affairs roll forward operation.
Rollback powers on
As the pre-submission power down that meets accident before completing, now backup sheet is not necessarily complete, but original admin table is not destroyed, automatically performs affairs and restart after re-powering, and removes incomplete affairs, gets back to the state before affairs start, and carries out transaction rollback operation.
storage space is compact
Left free space after discharging for space, because it can not always just meet the follow-up length requirement re-using, if do not processed, fragment can get more and more, and then affects follow-up service efficiency.In order fully to improve the service efficiency of NVM, need to repeatedly after the releasing operation of space, carry out the compact processing in space: the fragment that soon releasing operation will produce collects and forms between a continuous free area together, so that the distribution utilization in later stage.
Compact operating process is exactly all space content of having used all to be moved to the top of NVM user area, and the free space that releasing operation is produced all moves to the process of the bottom of NVM user area.Namely by the interval afterbody of the NVM clear area that the data Replica of allocation space has discharged to front end, and by the use region release of afterbody.
For guaranteeing the atomicity of compact operation, in the compact operation of single, must not copy of data covers this compact preoperative valid data.
Fig. 2 has described logical table, state table and storage block structure.All block lengths are identical, by logical block number (LBN) (logic_index) sign.How by logic_index, to calculate physical block number (physical_index) and physical address, need to be by the assignment of logical table (eep_logic_table) shown in Fig. 2.
Eep_logic_table is similar to the FAT of MSDOS.Because block length is fixed, if data length is not the integral multiple of data block, can cause the significant wastage of storer.For avoiding this waste, do not lose again the system advantage of fixed block length, introduce the concept of memory feature, sheet is minimum memory unit.
A upper layer application epistemic losic piece is described (logical block number (LBN)), is converted into physical block describes by eep_logic_table.So just can calculate storage address.
The invention provides transaction processing facility.This just mean all storage operations until its final effectively complete before, be all can follow the tracks of, abolishable.
For building the data cell that is greater than block length, just need block chaining.The foundation of this link is that the logic_index(of record sensing subsequent block in second element of logical table record is next_logic_index).A data cell is continuous, can comprise a plurality of memory features.
The eep_logic_table structure of Fig. 2 consists of a series of fixed length logical records in fact.First element of its entry is physical block number (physical_index), and second element directed records the recording mechanism (next_logic_index) of chained block.
The eep_state_table structure of Fig. 2 is to consist of the fixed-length record of a series of description physical block states (1 byte or 2 bytes).The entry of eep_state_table be with physical block one to one, record indicates the use state of a physical block.Its each indicate the use state of a memory feature: " 0 " indicates corresponding memory feature for " free time ", and " 1 " indicates corresponding memory feature for " using ".Wherein lowest order indicates the use state of the lowest address memory feature of corresponding physical block, and most significant digit indicates the use state of the superlatively location memory feature of corresponding physical block.
Fig. 3 describes the layout in whole card NVM space.NVM top is to be the reserved specific use interval of COS.The bottom of trough is memory management allocation list, record the admin table start addresses such as eep_logic_table, eep_logic_table_ebak, eep_state_table, eep_state_table_ebak, NVM user area start address, NVM patch area start address (being user area termination address) etc.
Successively be NVM backed-up pages, anti_tearing_table, anti_tearing_table_bak, eep_logic_table, eep_logic_table_ebak, eep_state_table, eep_state_table_ebak and NVM user area and NVM patch area thereafter.
The search procedure of free space in allocation of space flow process that the free space of Fig. 4 has been searched schematic diagram shows.Batch operation is first searched between a most suitable free area in the free space that early stage, releasing operation produced: if find a length just in time to equal the free space of the length of space application, distributed to and this time apply applicant; Otherwise all length being greater than in the free space of application length to a free space of length minimum distributes to and this time applies applicant; As the length of free space is all less than this time length of application, has used after interval and distribute remaining space to this time applying applicant following last closely.
Concrete operations flow process is as follows:
Current_physical_addr: the current tail address of having used;
Size (i): i continuous free area length;
G_eep_size: current application length;
Found_size: the free area satisfying the demands.
step1:
From nvm start address, to current tail address, search one by one free area and calculate its continuous length and skew.Equal in length to exiting; Otherwise the minimum value min that record satisfies condition.
Found_size=0xFFFFFFFF; // initialize
If (g_eep_size==size (i)) // length coupling, ok
{ found_size = g_eep_size; return true; }
else if((size(i) > g_eep_size) && (size(i) < found_size))
{ found_size = size(i); }
i ++;
if(found_size == 0xFFFFFFFF)
{ return false; The eligible free area of } // do not find
else
{ return true; The eligible free area of } // find
step2:
The free area meeting the demands as found, is distributed and (if not being complete free page, is searched its corresponding logical record sequence number; Otherwise distribute an idle logical record item.
step3:
Do not find the free area meeting the demands, from current tail location, start to distribute (as enough large in remaining space).
Fig. 5 is compact operation power down preventing message structure schematic diagram.Wherein, index is that compactness prevents pulling out information table counter, and current_logic_index records the logical record pointer that last has used physical block, and free_size is current NVM residue free space byte number, and subsequent content is that the information of pulling out is prevented in compact operation.
For avoid upgrade compact anti-while pulling out information table power down cause the situation of information confusion to occur, after pre-submission to or the compact anti-information meter that pulls out when full, the compact anti-information table that pulls out is double.At any time, it is effective in two tables, only having one.For distinguishing original table and worksheet, 16 digit counters (index) are set in information table.The table that Counter Value is large is worksheet; When in two counters, one for 0xffff, another is 0x0, the table of 0x0 is worksheet.
Only two stages, compactly anti-ly pull out information table and have two parts, in the stage before completing to affairs submit operation after the pre-submit operation of the first, it two is that in compact operating process, the compact anti-information table meter that pulls out expire and is enabled and records another table and complete the previous operational phase.In other any moment compactness, prevent that pulling out information table only has portion.
Before pre-submit operation, only has an anti_tearing_table table.In pre-submit operation flow process, the information such as current_logic_index and free_size are write to a new anti_tearing_table table; After above information writes successfully, read the index in former anti_tearing_table, added one, and write in the lump in new anti_tearing_table table together with the radix-minus-one complement of (index+1).Here the mode that adopts secondary to write is to be all accurate in order to ensure the effective information in anti_tearing_table.Now, there are two parts of anti_tearing_table information tables.
After affairs submit operation completes, former anti_tearing_table table is wiped, now returned to again the state that only has a anti_tearing_table information table, but information table is now the information table after upgrading.
Fig. 6 is that anti-the pulling out of the compactness operation at Fig. 5 described compact operating process on information table basis.In fact close-coupled process divides two large operation cycle flow processs.
V Step1. finds from front to back first free page (free_page) in g_eep_state_table, as still without free page, jumps to step7 bottom searching;
V Step2. one page from it starts to find first busy page (used_page), as search bottom still nothing but free page jump to step7;
V Step3. records single and moves anti-pull out information: free_page, used_page;
V Step4. records single and moves the anti-sign reclaim_page(0xA5A5A5A5 that pulls out);
V is the correctness of pulling out information f ree_page and used_page in order to ensure anti-by step3 and step4 separate operation here;
V Step5. copies to free page by busy page, amounts to pages=used_page-free_page page:
N 5.1 copies to free_page by used_page page;
n 5.2 free_page++;
N 5.3 used_page++, search an empty pages downwards, as forwarded step6 to bottom;
N 5.4 pages--, repeat 5.1 ~ 5.4, until pages=0.
V Step6. searches free_page downwards from currency, repeats step1 ~ step5, until exit.
Above Step1 ~ step6 is the operating process of NVM user's space content compactness;
Following step7 ~ step15 is the treatment scheme of NVM admin table in compact operation.
V Step7. copies to g_eep_logic_table_ebak by g_eep_logic_table;
V Step8. copies to g_eep_state_table_ebak by g_eep_state_table;
V Step9. finds from top to bottom first free page (free_page) in g_eep_state_table, as still without free page, jumps to step13 bottom searching;
V Step10. one page from it starts to find first busy page (used_page), as search bottom still nothing but free page jump to step13;
V Step11. revises nvm admin table, altogether pages=used_page-free_page item:
N 11.1 revises g_eep_logic_table: in g_eep_logic_table, search used_page, to cache, in cache, used_page is changed to one page g_eep_logic_table information reproduction at used_page place into free_epage; As across page, be written to corresponding g_eep_logic_table_ebak;
N 11.2 revises g_eep_state_table: the corresponding page of state_table is copied to cache, in state cache, revise g_eep_state_table_cache [used_page]=g_eep_state_table [free_page], g_eep_state_table_cache [free_page]=NULL; As across page, be written to g_eep_state_table_ebak;
N 11.3 used_page++, search an empty pages downwards, as arrived bottom, are withdrawn into step13;
N 11.4 pages--, as pages=0, jump to step12.
N 11.5 repeats 11.1 ~ 11.4, until exit.
V Step12. searches free_page downwards from currency, repeats step9 ~ step11, until exit;
V Step13. writes g_eep_state_table_ebak by state_cache; Logic_cache is write to g_eep_logic_table_ebak;
V Step14. records nvm admin table and has backed up confirmation: reclaim_bak;
V Step15. copies g_eep_logic_table_ebak to g_eep_logic_table, copies g_eep_state_table_ebak to g_eep_state_table.
So far, compactness completes v Step16., copies anti_tearing gauge outfit information (not containing the compact anti-information of pulling out) to anti_tearing_bak, and wipes anti_tearing.
Should be understood that, for those of ordinary skills, can be improved according to the above description or convert, and all these improvement and conversion all should belong to the protection domain of claims of the present invention.

Claims (10)

1. a management method for smart card nonvolatile memory, is characterized in that, comprises the following steps:
Receive the space application instruction that application is submitted to, according to the free space in store status table, suitable free space is distributed to this application, and upgrade store status table and assignment of logical table;
Receive the space releasing request instruction that application is submitted to, according to this space releasing request instruction, carry out space releasing operation, by the status modifier in corresponding stored space, be free space, and delete the list item in corresponding assignment of logical table;
The fragment that releasing operation is produced collects and forms between a continuous free area together, so that the distribution utilization in later stage.
2. method according to claim 1, is characterized in that,
Before allocation of free space state, in advance assignment of logical table and store status table are backed up respectively, produce worksheet separately;
When allocation space, the worksheet of backup is copied to respectively in cache table separately; Upgrade corresponding physical block sequence number and logical table link information in the cache table of assignment of logical table, and upgrade the use state in corresponding stored space in the cache table of store status table; Then the cache table after upgrading is copied in worksheet separately, and replace corresponding original table with worksheet.
3. method according to claim 2, is characterized in that, step distributes suitable space to be specially to this application according to the free space in store status table:
From store status table, search the free space equating with applied for space length, if having, distributed to this application; If no, length is greater than to the free space of length minimum in the free space of applied for space length, distribute to this application;
If all free space length is all less than applied for space length, whether the remaining space that checks bottom, space, storer user area is more than or equal to applied for space length, if so, from the space length that the bottom distribution of allocation space is applied for, to this, apply; Otherwise apply for unsuccessfully in space.
4. method according to claim 2, is characterized in that, while carrying out space releasing operation, revises the cache table of assignment of logical table and store status table, with the state in final updated store status table, and removes the record in assignment of logical table.
5. method according to claim 1, it is characterized in that, the step of the compact operation of storage space is specially: all space content of having used are all moved to the top of storer user area, and the free space that releasing operation is produced all moves to the bottom of storer user area.
6. method according to claim 5, it is characterized in that, when carrying out the compact operation of storage space, generate the compact anti-back-up job table that pulls out information original table, after storage space compactness has operated, the anti-information backup worksheet that pulls out of compactness is replaced to the compact anti-information original table that pulls out.
7. according to the method described in any one in claim 1-6, it is characterized in that, also comprise step: by the spatial division of storer, be a plurality of physical blocks in advance, the length of physical block is set to 128 bytes or its integral multiple.
8. method according to claim 7, is characterized in that, also comprises step:
Further storage block is divided into a plurality of memory features, the minimum memory unit that memory feature is storer, the list item in store status table records the use state of storage block and memory feature.
9. method according to claim 2, is characterized in that,
Worksheet at assignment of logical table or store status table completes after renewal, before corresponding original table is replaced, if meet accident power down, re-powers the rear replacement of automatically carrying out original table;
Worksheet at assignment of logical table or store status table completes before renewal, if meet accident power down, and imperfect for the relevant work table backing up, after re-powering, automatically remove incomplete affairs, get back to the state before affairs start.
10. method according to claim 7, is characterized in that, when carrying out allocation of space and space releasing operation, if the renewal of the cache table of assignment of logical table or store status table surpasses one page, first the cache table after upgrading is copied in worksheet separately.
CN201310619963.5A 2013-11-29 2013-11-29 The management method of intelligent card nonvolatile memory Active CN103678180B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201310619963.5A CN103678180B (en) 2013-11-29 2013-11-29 The management method of intelligent card nonvolatile memory

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201310619963.5A CN103678180B (en) 2013-11-29 2013-11-29 The management method of intelligent card nonvolatile memory

Publications (2)

Publication Number Publication Date
CN103678180A true CN103678180A (en) 2014-03-26
CN103678180B CN103678180B (en) 2017-11-24

Family

ID=50315805

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201310619963.5A Active CN103678180B (en) 2013-11-29 2013-11-29 The management method of intelligent card nonvolatile memory

Country Status (1)

Country Link
CN (1) CN103678180B (en)

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105279097A (en) * 2014-07-07 2016-01-27 北京数码视讯科技股份有限公司 Management method and equipment of invoke transient object, and smart card
CN105512342A (en) * 2016-01-05 2016-04-20 上海交通大学 Durability method of transactional memory computing based on HTM (Hyper-Text Markup) and NVRAM (Non Volatile Random Access Memory)
CN105892938A (en) * 2016-03-28 2016-08-24 乐视控股(北京)有限公司 Optimization method and system of disk cache system
CN106294189A (en) * 2015-05-25 2017-01-04 中兴通讯股份有限公司 Memory fragmentation method for sorting and device
CN107861887A (en) * 2017-11-30 2018-03-30 科大智能电气技术有限公司 A kind of control method of serial volatile memory
CN111143241A (en) * 2019-12-30 2020-05-12 深圳Tcl数字技术有限公司 Memory data migration method and device and storage medium
CN112527197A (en) * 2020-12-09 2021-03-19 北京握奇智能科技有限公司 Smart card fragment storage space arrangement method, smart card and system
CN116126591A (en) * 2022-12-23 2023-05-16 北京熵核科技有限公司 Transaction mechanism of embedded system

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1299096A (en) * 2001-01-12 2001-06-13 常促宇 High-capacity moving storage of universal serial bus interface and its implementation method
CN1632765A (en) * 2004-12-31 2005-06-29 大唐微电子技术有限公司 A flash memory file system management method
CN102004697A (en) * 2010-10-21 2011-04-06 北京握奇数据系统有限公司 Flash recovery method and device
CN102081577A (en) * 2011-01-12 2011-06-01 厦门雅迅网络股份有限公司 Data storage structure of Flash memory and data manipulation mode thereof
US20130227207A1 (en) * 2011-05-12 2013-08-29 Densbits Technologies Ltd. Advanced management of a non-volatile memory

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1299096A (en) * 2001-01-12 2001-06-13 常促宇 High-capacity moving storage of universal serial bus interface and its implementation method
CN1632765A (en) * 2004-12-31 2005-06-29 大唐微电子技术有限公司 A flash memory file system management method
CN102004697A (en) * 2010-10-21 2011-04-06 北京握奇数据系统有限公司 Flash recovery method and device
CN102081577A (en) * 2011-01-12 2011-06-01 厦门雅迅网络股份有限公司 Data storage structure of Flash memory and data manipulation mode thereof
US20130227207A1 (en) * 2011-05-12 2013-08-29 Densbits Technologies Ltd. Advanced management of a non-volatile memory

Cited By (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105279097A (en) * 2014-07-07 2016-01-27 北京数码视讯科技股份有限公司 Management method and equipment of invoke transient object, and smart card
CN105279097B (en) * 2014-07-07 2019-06-18 北京数码视讯科技股份有限公司 A kind of management method, equipment and smart card calling transient object
CN106294189A (en) * 2015-05-25 2017-01-04 中兴通讯股份有限公司 Memory fragmentation method for sorting and device
CN106294189B (en) * 2015-05-25 2020-09-25 中兴通讯股份有限公司 Memory defragmentation method and device
CN105512342A (en) * 2016-01-05 2016-04-20 上海交通大学 Durability method of transactional memory computing based on HTM (Hyper-Text Markup) and NVRAM (Non Volatile Random Access Memory)
CN105892938A (en) * 2016-03-28 2016-08-24 乐视控股(北京)有限公司 Optimization method and system of disk cache system
CN107861887A (en) * 2017-11-30 2018-03-30 科大智能电气技术有限公司 A kind of control method of serial volatile memory
CN111143241A (en) * 2019-12-30 2020-05-12 深圳Tcl数字技术有限公司 Memory data migration method and device and storage medium
CN112527197A (en) * 2020-12-09 2021-03-19 北京握奇智能科技有限公司 Smart card fragment storage space arrangement method, smart card and system
CN116126591A (en) * 2022-12-23 2023-05-16 北京熵核科技有限公司 Transaction mechanism of embedded system
CN116126591B (en) * 2022-12-23 2023-12-15 北京熵核科技有限公司 Transaction mechanism of embedded system

Also Published As

Publication number Publication date
CN103678180B (en) 2017-11-24

Similar Documents

Publication Publication Date Title
CN103678180A (en) Intelligent card nonvolatile memory management method
TWI682278B (en) Memory system and control method
CN101278267B (en) Non-volatile memory with scheduled reclaim operations
CN100555246C (en) A kind of on flash memory the system and method for access data
TWI710900B (en) Storage device and method
US7227788B2 (en) Memory management device and memory device
CN101221536B (en) Internal memory managing method and device of embedded system
CN102841851B (en) Flash memory management method and flash memory device
CN101918913A (en) Reclaiming storage on a thin-provisioning storage device
JP4701321B2 (en) Memory management
CN102163175B (en) Hybrid address mapping method based on locality analysis
CN102135942B (en) Method for realizing wear-leveling in storage equipment as well as the storage equipment
US20120284551A1 (en) Deep standby method and device for embedded system
CN104424103B (en) Solid state storage device medium-speed cached management method
US9213634B2 (en) Efficient reuse of segments in nonoverwrite storage systems
CN102629234B (en) Fast retrieval method for data of built-in Flash of single chip microcomputer
WO2005106673A1 (en) Nonvolatile storage device and data write method
CN103455379A (en) Resource allocation method and system
CN103996412A (en) Power-fail protection method applied to intelligent-card nonvolatile memories
CN109683830A (en) A kind of method for writing data, system and the associated component of full flash memory array
CN103412822A (en) Operation method of non-volatile RAM, data operation method and relevant device
CN109558333B (en) Solid state storage device namespaces with variable additional storage space
CN102184140A (en) Real-time database-orientated table file space distribution method
CN109669889B (en) Light Nor Flash control method and device
CN102880553B (en) The reading/writing method of the outer FLASH file system of a kind of sheet based on MCU

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant