JP2004265275A - Ic card and ic card program - Google Patents
Ic card and ic card program Download PDFInfo
- Publication number
- JP2004265275A JP2004265275A JP2003056563A JP2003056563A JP2004265275A JP 2004265275 A JP2004265275 A JP 2004265275A JP 2003056563 A JP2003056563 A JP 2003056563A JP 2003056563 A JP2003056563 A JP 2003056563A JP 2004265275 A JP2004265275 A JP 2004265275A
- Authority
- JP
- Japan
- Prior art keywords
- information
- area
- writing
- card
- save
- 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
Links
Images
Landscapes
- Techniques For Improving Reliability Of Storages (AREA)
Abstract
Description
【0001】
【発明の属する技術分野】
本発明は、書き換え可能な記憶手段への書き込みにおいてエラーがあった場合に書き込み前の状態に戻す復帰を行うICカード及びICカードプログラムに関するものである。
【0002】
【従来の技術】
一般にICカードは、ROM、RAM、書き換え可能な不揮発性メモリ(以下、「不揮発性メモリ」という。)の3種類のメモリと、これらのメモリにアクセスするCPUとを備えている。
RAMは、揮発性メモリであり、CPUが処理を行う作業領域として使用される。ROMは、不揮発性の読み出し専用メモリであって、オペレーティングシステム(以下、「OS」という。)などの基本ソフトウェア、実行環境などのプログラム、パラメータなど、ハードウェアを管理してアプリケーションがこれを利用できるようにするプログラム及びデータを格納している。不揮発性メモリは、EEPROM、フラッシュメモリ、FRAMなどの随時書き換え可能な不揮発性のメモリであり、通常ユーザのワークエリア、プログラムエリアなどとして使用されている。なお、ICカードとは、その基材を問わず、SIMカード、ICタグなどの少なくともCPUと、外部との通信手段と、情報を記憶する記憶手段とを備える携帯型の情報処理装置をいう。
このICカードを使用する場合には、ICカードをリーダライタなどの外部装置に接続し、外部装置からコマンドをICカードへ送信する。コマンドを受信したICカードでは、CPUがROM、不揮発性メモリに格納されているプログラムのうち、コマンドに対応する部分を実行する。この結果、コマンドの処理がなされ、不揮発性メモリに新たなデータを書き込むなどの処理が行われ、処理結果がレスポンスとしてICカードから外部装置へ送信される(例えば、特許文献1参照)。
【0003】
【特許文献1】
特開平10−40350号公報(第3頁、第1図)
【0004】
【発明が解決しようとする課題】
ICカードは、外部装置から処理のための電源の供給を受けるため、不揮発性メモリへのデータの書き込み途中で電源の供給が中断されるおそれがある。特に非接触式で外部装置と通信を行う非接触式のICカードの場合には、通信中に外部装置との相対位置が固定されていないため、電源供給の中断(以下、「電源断」という。)が発生する可能性が高い。そこで、ICカードは、かかる場合にデータの書き込み前の状態に戻す、つまり、復帰するために書き込み保証の処理を行う。
【0005】
図10は、書き込み保証の処理を説明するための不揮発性メモリ15−2のメモリ構造図である。なお、不揮発性メモリ15−2にデータAが記憶されている領域にデータBを新たに書き込む場合の書き込み保証について説明する。図10(a)は、正常に書き込みがおこなわれた場合を示し、図10(b)は、処理の途中で電源断などの書き込みエラーがあり、書き込みが正常に行われなかった場合を示している。
図10(a)に示すように、不揮発性メモリ15−2には、新たなデータを書き込む領域であって、データAなどのデータ、アプリケーションプログラムなどのプログラムが記録され、データ領域15d−2と、データ領域15d−2への書き込みにより、消去されるデータのバックアップを記憶する退避領域15s−2とを備えている。
【0006】
図10の#101に示すように、先ず、CPUは、データAを退避領域15s−2に退避する(書き込む)。次にデータ領域15d−2のデータAが記憶されている領域にデータBを書き込み、データAをデータBに書き換え(#102)、最後に退避領域15s−2のデータAをクリア(消去)する(#103)。
データAを退避領域15s−2に書き込んでいる途中(#101)に電源断があった場合には、図10(b1)に示すように、退避領域15s−2に退避したデータが不正(無効)なものとなるが、データ領域15d−2にデータAが残っている。また、データAをデータBに書き換えている途中(#102)に電源断があった場合には、図10(b2)に示すように、退避領域15s−2にデータAが残っているため、このデータAをデータ領域15d−2に書き込むことによって復帰を行うことが可能である[#104,図10(b3)]。更に、この復帰中に電源断があった場合にも、退避領域15s−2にデータAが残っているため[図10(b4)]、同様に復帰は可能である[#105,図10(b3)]。よって、不揮発性メモリ15−2へデータを書き込む途中に電源断があった場合には、書き込み保証によって元の状態へ復帰し、再度データを書き込むこととなる。
【0007】
一方、不揮発性メモリ15−2へデータを書き込む処理は、不揮発性メモリ15−2からデータやプログラムを読み出す処理などの他の処理に比べて特異に時間がかかるため、頁単位での書き込みが行われている。頁単位とは、所定の量のデータひとまとまりという意味であって、例えば64バイトのデータを処理の一単位とすることである。1頁がnバイトである場合に、同一頁であるときには、1バイトの書き込みの処理及びnバイトの書き込みの処理にかかる時間は、ともに書き込み回数が1回であるため、ほとんど変わらない。一方、2バイトの書き込みであっても頁が異なる場合には、書き込み回数が異なるため、同一頁に2バイト書き込むときに比べて2倍程度の処理時間がかかる。
【0008】
図11は、頁単位での書き込みにおける書き込み保証の処理を説明するための図である。なお、データ領域15d−2から退避領域15s−2へデータを退避する処理(図10の#101)について説明する。
図11に示すように、頁番号Kのデータを書き換える場合には、退避領域15s−2に頁番号Kのデータがそのまま複製され(#111)、退避領域15s−2に格納されている情報を制御するための情報であって、退避領域15s−2に記憶されている情報の元の位置などの属性を示す制御情報の領域15c−2に頁番号Kなどが書き込まれる(#112)。また、頁番号N及び頁番号N+1の2頁に渡るデータを書き換える場合にも同様に、頁番号N及び頁番号N+1の2頁全てのデータが複製され(#113,#114)、制御情報の領域15c−2に頁番号が書き込まれる(#115)。
【0009】
従って、1頁のデータの退避する場合には、2回の書き込み、2頁に渡るデータを退避する場合には、3回の書き込みが必要となる。つまり、退避の処理だけで少なくとも2回の書き込みが必要となり、処理時間が長くなる原因となるとともに、電源断の発生する確率を上昇する一因ともなっていた。また、書き込み中に電源断があった場合には、元の状態に復帰してから再度書き込みを行わなければならないため、書き込みのみを行うときに比べて処理の時間がかかることとなり、復帰における処理の迅速化、特に処理に時間がかかる書き込み処理の迅速化が強く要請されていた。
【0010】
本発明の課題は、処理速度の向上を図ることが可能なICカード及びICカードプログラムを提供することである。
【0011】
【課題を解決するための手段】
本発明は、以下のような解決手段により、前記課題を解決する。なお、理解を容易にするために、本発明の実施形態に対応する符号を付して説明するが、これに限定されるものではない。すなわち、請求項1の発明は、書き換え可能な記憶手段(15)と、書き込み要求があった場合に、前記書き換え可能な記憶手段の指定された領域に指定された情報を頁単位で書き込む指定情報書き込み手段(122、S360)とを備えるICカードであって、前記書き込み要求があった場合(S300)に、前記指定された領域とは別の領域である退避領域(15s)に、前記指定された領域に記憶されている対象情報と、この対象情報の管理情報とを続けて頁単位で書き込む退避領域書き込み手段(122、S350)を備え、前記指定情報書き込み手段は、前記退避領域書き込み手段による書き込みの後に前記指定された情報の書き込みを行うこと、を特徴とするICカード(10)である。
【0012】
請求項2の発明は、請求項1に記載のICカードにおいて、前記退避領域書き込み手段は、前記対象情報と、前記指定された領域の位置を示す退避元位置情報及び/又は前記対象情報の情報量を含む管理情報とを続けて前記退避領域へ書き込むこと、を特徴とするICカード(10)である。
【0013】
請求項3の発明は、請求項1又は請求項2に記載のICカードにおいて、前記退避領域書き込み手段は、前記対象情報と、対象情報、又は、対象情報及び管理情報が前記退避領域書き込み手段によって正常に退避領域に書き込まれたか否かを示す書き込み正否情報を含む管理情報とを続けて前記退避領域へ書き込むこと、を特徴とするICカード(10)である。
【0014】
請求項4の発明は、請求項1から請求項3までのいずれか1項に記載のICカードにおいて、前記書き換え可能な記憶手段は、前記退避領域に有効な対象情報を記憶しているか否かを示す退避領域有効性情報、及び/又は、前記退避領域に記憶されている対象情報が有効であるか否かをその属性によって示す属性別有効性情報を含む有効性情報を記憶すること、を特徴とするICカード(10)である。
【0015】
請求項5の発明は、請求項4に記載のICカードにおいて、前記書き換え可能な記憶手段は、前記退避領域において最初にアクセスされる位置に前記退避領域有効性情報を記憶すること、を特徴とするICカード(10)である。
【0016】
請求項6の発明は、請求項4又は請求項5に記載のICカードにおいて、前記書き込み要求があった場合に、前記有効性情報に基づいて前記退避領域に有効な対象情報が記憶されているか否かを判定する退避領域有効性判定手段(121、S310,S380)を備え、前記退避領域書き込み手段は、前記退避領域有効性判定手段によって肯と判定された場合に、前記退避領域において前記有効な対象情報及びその管理情報の頁の後に前記書き込み要求に応じて対象情報及び管理情報の頁を書き込むこと、を特徴とするICカード(10)である。
【0017】
請求項7の発明は、請求項6に記載のICカードにおいて、前記退避領域有効性判定手段によって肯と判定された場合に、前記有効な対象情報及び管理情報の頁に前記書き込み要求に応じて対象情報及び管理情報を書き込む空き領域があるか否かを判定する空き領域判定手段(121)を備え、前記退避領域書き込み手段は、前記空き領域判定手段によって否と判定された場合に、前記有効な対象情報及び管理情報の頁の後に前記書き込み要求に応じて対象情報及び管理情報の頁を書き込み、前記空き領域判定手段によって肯と判定された場合に、前記書き込み要求に応じて対象情報及び管理情報を前記空き領域に書き込むこと、を特徴とするICカード(10)である。
【0018】
請求項8の発明は、請求項4から請求項7までのいずれか1項に記載のICカードにおいて、復帰必要性確認要求があった場合(S500)に、前記退避領域に記憶されている対象情報の復帰を行う必要性があるか否かを前記有効性情報に基づいて判定する復帰必要性判定手段(S510,S550)と、前記復帰必要性判定手段によって肯と判定された場合に、前記対象情報をその管理情報に基づいて前記指定された領域に書き込み、前記対象情報の復帰を行う復帰手段(122、S560)とを備えること、を特徴とするICカード(10)である。
【0019】
請求項9の発明は、請求項6から請求項8までのいずれか1項に記載のICカードにおいて、前記退避領域有効性判定手段及び/又は前記復帰必要性判定手段は、前記有効性情報及び前記対象情報に対応する前記書き込み正否情報に基づいて判定を行う(S400、S520)こと、を特徴とするICカードである。
【0020】
請求項10の発明は、請求項1から請求項9までのいずれか1項に記載のICカードにおいて、前記書き換え可能な記憶手段は、前記退避領域が初期化済みか否かを示す初期化情報を記憶すること、を特徴とするICカード(10)である。
【0021】
請求項11の発明は、書き換え可能な記憶手段(15)を備えるICカード(10)のCPU(12)に、書き込み要求があった場合(S300)に、前記書き換え可能な記憶手段の指定された領域に指定された情報を頁単位で書き込む指定情報書き込み手順(S360)を実行させるICカードプログラムであって、前記書き込み要求があった場合に、前記指定された領域とは別の領域である退避領域に、前記指定された領域に記憶されている対象情報と、この対象情報の管理情報とを続けて頁単位で書き込む退避領域書き込み手順(S350)を備え、前記指定情報書き込み手順は、前記退避領域書き込み手順の後に実行されること、を特徴とするICカードプログラムである。
【0022】
請求項12の発明は、請求項11に記載のICカードプログラムにおいて、前記退避領域書き込み手順は、前記対象情報と、前記指定された領域の位置を示す退避元位置情報及び/又は前記対象情報の情報量を含む管理情報とを続けて前記退避領域へ書き込むこと、を特徴とするICカードプログラムである。
【0023】
請求項13の発明は、請求項11又は請求項12に記載のICカードプログラムにおいて、前記退避領域書き込み手順は、前記対象情報と、前記対象情報、又は、前記対象情報及び前記管理情報が前記退避領域書き込み手順において正常に退避領域に書き込まれたか否かを示す書き込み正否情報を含む管理情報とを続けて前記退避領域へ書き込むこと、を特徴とするICカードプログラムである。
【0024】
請求項14の発明は、請求項11から請求項13までのいずれか1項に記載のICカードプログラムにおいて、前記書き込み要求があった場合に、前記有効性情報に基づいて前記退避領域に有効な対象情報が記憶されているか否かを判定する退避領域有効性判定手順(S310,S380)を備え、前記退避領域書き込み手順は、前記退避領域有効性判定手順において肯と判定した場合に、前記退避領域において前記有効な対象情報及びその管理情報の頁の後に前記書き込み要求に応じて対象情報及び管理情報の頁を書き込むこと、を特徴とするICカードプログラムである。
【0025】
請求項15の発明は、請求項14に記載のICカードにおいて、前記退避領域有効性判定手順において肯と判定した場合に、前記有効な対象情報及び管理情報の頁に前記書き込み要求に応じて対象情報及び管理情報を書き込む空き領域があるか否かを判定する空き領域判定手順を備え、前記退避領域書き込み手順は、前記空き領域判定手順において否と判定した場合に、前記有効な対象情報及び管理情報の頁の後に前記書き込み要求に応じて対象情報及び管理情報の頁を書き込み、前記空き領域判定手順において肯と判定した場合に、前記書き込み要求に応じて対象情報及び管理情報を前記空き領域に書き込むこと、を特徴とするICカードプログラムである。
【0026】
請求項16の発明は、請求項11から請求項15までのいずれか1項に記載のICカードプログラムにおいて、復帰必要性確認要求があった場合に、前記退避領域に記憶されている対象情報の復帰を行う必要性があるか否かを判定する復帰必要性判定手順(S510,S520,S550)と、前記復帰必要性判定手順において肯と判定した場合に、前記対象情報をその管理情報に基づいて前記指定された領域に書き込み、前記対象情報の復帰を行う復帰手順(S560)とを備えること、を特徴とするICカードプログラムである。
【0027】
【発明の実施の形態】
以下、図面等を参照しながら、本発明の実施の形態について、更に詳しく説明する。
(実施形態)
図1は、本発明によるICカードの実施形態を示すブロック図である。
なお、前述した従来例と同様の機能を果たす部分には、同一の符号を付して、重複する説明を適宜省略する。
図1に示すように、ICカード10は、外部装置20との通信を実現するための入出力回路などのインターフェイスであるI/Oインターフェイス11、CPU12、RAM13、ROM14、不揮発性メモリ15などを備えている。
CPU12は、ROM14、不揮発性メモリ15などに格納されているOS、アプリケーションなどのプログラムを実行することによって、ICカード10を統括制御し、外部装置20から受信するコマンドに応じた処理を行い、判定部121、書き込み部122、書き換え部123、退避情報生成部124などを実現し、処理結果をレスポンスとして外部装置20へ送信する。各部の機能については、図4、図5及び図7を用いて後述する。
不揮発性メモリ15の情報記憶領域は、データ領域15d、退避領域15sなどに割り当てられている。
【0028】
図2は、退避領域15sのメモリ構造を示す図である。
図2に示すように、退避領域15sには、データ有無情報、初期化情報、トランザクション番号、退避情報(#21)などが格納されている。これらの情報は、書き込み部122によって頁単位で書き込まれたものである。データ有無情報は、退避領域15sに有効な退避情報が記憶されているか否かを示す退避領域有効性情報であって、退避領域15sに退避情報を書き込み始める位置、退避領域15sから情報を読み出し始める位置、つまり、CPU12が最初にアクセスする位置に格納される。本実施形態においては、退避領域15sの先頭頁に格納されている。
【0029】
初期化情報は、退避領域15sが初期化されたか否かを示す情報であって、退避領域15sを効率的に使用するため、最終頁(#22)に格納される。図3に示すように、退避領域15sが初期化された場合には、データ有無情報は「データ無」、全てのトランザクション番号は「0」、初期化情報は「初期化済」となり、退避情報が格納されていない状態となる。なお、初期化は、カード発行段階など、ICカード10の使用前において少なくとも1度行われていればよい。
【0030】
図2及び図3に示すように、トランザクション番号は、退避領域15sに略頁単位間隔(先頭頁以外は、頁単位間隔)で格納され、後に続けて書き込まれている対応する退避情報がいずれの処理段階(トランザクション)で退避領域15sに書き込まれたかを示す属性情報である。つまり、コマンドを受信してからCommitの処理などによってデータ有無情報を「データ有」から「データ無」に書き換えるまでの一又は複数のWriteの処理(一のコマンドに対応して行った処理に含まれる一又は複数のWriteの処理)を一の処理段階として、このWriteの処理で書き込まれた退避情報について同一のトランザクション番号を結びつけて管理している。トランザクション番号は、処理段階が変わるたびに「1」の値がインクリメント(加算)され、所定の最大値に達したとき、「0」にリセットされる。従って、トランザクション番号は、対応する退避情報が有効な又は古い無効な処理段階において書き込まれたものであるか、つまり、対象情報が有効であるか否かをその属性によって示す属性有効性情報である。
【0031】
なお、トランザクション番号のリセット時にCPU12は、退避領域15sの初期化を行うことが望ましい。トランザクション番号が一回りし、以前の処理段階及び新たな処理段階の退避情報に同一のトランザクション番号が付されることを防止するためである。また、Commitの処理及びWrite(書き込み要求)の処理とは、それぞれ所定の要求(Commit、Write)があった場合、つまり、CPU12が実行するプログラムから所定の呼び出しがあった場合に行う処理であって、その処理内容については、図6(c)及び図5を用いて後述する。更に、有効な退避情報とは、バックアップとしての役割を果たすなどの有用な退避情報であって、役割がなくなれば、無効な退避情報となる。
【0032】
図2に示すように、退避情報は、退避情報生成部124によって生成される情報であって、書き込み要求があった場合に、データ領域15dの指定された領域に記憶されている退避の対象となった対象情報であるデータと、その管理情報とが続けて退避領域15sに書き込まれたものである。なお、「続けて書き込まれる」とは、図2の#21に示すように、対象情報又は管理情報が分割され、その一部が続けて書き込まれている場合であってもよい。管理情報は、アドレス、データ長、チェックコードなどの退避したデータを管理するための情報である。アドレスは、退避したデータの退避元のデータ領域15dにおける先頭アドレス、つまり、書き込み要求で指定された領域の位置を示す退避元位置情報であり、データ長は、退避したデータの情報量である。また、チェックコードは、退避情報と照合などすることによって、退避情報データが退避領域15sに正常に書き込まれたか否か、つまり、退避情報の正当性を示す書き込み正否情報である。
【0033】
図4、図5及び図7は、本発明によるICカードの動作及び本発明によるICカードプログラムを示すフローチャートである。以下、CPU12の処理を中心に説明する。
図4(a)に示すように、ステップ110(以下、「ステップ」を「S」という。)において、ICカード10は、外部装置20に接続され、電源、クロックの供給を受け、処理を開始する。ICカード10は、外部装置20からコマンドを受信し(S120)、Rollbackの処理(後述する図7参照)を行い(S130)、その後にコマンドに応じた処理を実行する(S140)。ICカード10は、この処理結果をレスポンスとして外部装置20へ送信し(S150)、再びコマンド待ちの状態となり、外部装置20との接続が切れるまで、次のコマンドを受信した場合にも同様の処理を繰り返す(S120からS150まで)。
【0034】
図4(b)は、図4(a)においてICカード10が受信したコマンド(S120)に対応して行う処理(S140)のうち、不揮発性メモリ15に対して行う書き込みなどの処理を示す図である。なお、図4(a)のS100においてICカード10は、初期化された状態(図3参照)にあり、ICカード10がS120で受信したコマンドに対応して行う処理において、書き込み要求(Write)が2回行われるものとする。
図4(b)に示すように、ICカード10は、コマンドに対応して2回のWriteの処理を行う(S210,S230)。Writeの処理は、指定されたデータ領域15dに指定された新たなデータを書き込む処理であって、このとき、指定された領域のデータを退避領域15sに退避する(図10(a)の#1,#2参照)。Writeの処理の詳細については、図5を用いて後述する。
ICカード10は、2回のWriteの処理が正常に行われた場合には、Commitの処理を行う(S250)。Commitの処理は、退避領域15sをクリアにする、つまり、退避領域15sに記憶されている退避情報を無効とする処理であって、詳細については、図6(c)を用いて後述する。
【0035】
一方、ICカード10は、退避領域15s又はデータ領域15dへの書き込みが正常に行われなかったなど、いずれかのWriteの処理中にエラーとなった場合には(S220,S240)、Rollbackの処理を行い(S260)、コマンドに対応する処理の実行を終了する(S270)。Rollbackの処理とは、退避領域15sに復帰すべき退避情報が存在する場合に、復帰し、その後に退避領域15sをクリアにする処理であって、詳細については、図7を用いて後述する。
【0036】
図5は、本発明によるICカードが行うWriteの処理を示すフローチャートであり、図6は、図5の処理における不揮発性メモリ15の退避領域15sの変化を示す図である。
先ず1回目のWriteの処理[図4(b)のS210]について説明する。
S300において、書き込み要求があり、CPU12は、処理を開始し、判定部121は、退避領域15sに有効な退避情報が記憶されているか否かをデータ有無情報に基づいて判定する(S310)。ICカード10は、初期化された状態(図3参照)であるため、否と判定し、書き換え部123は、「データ有」に書き換える(S320)。また、書き換え部123は、先頭頁(最初)のトランザクション番号をインクリメントし、「0」から「1」へ書き換える(S330)。退避情報生成部124は、退避情報をRAM13上で生成し(S340)、書き込み部122は、この生成された退避情報に含まれるデータと、その管理情報とを続けて書き込む[S350、図6(a)]。これら一連の処理が正常に終了した場合に、書き込み部122は、データ領域15dの指定された領域へ新たなデータを書き込み(S360)、処理を終了する(S410)。
【0037】
次に2回目のWriteの処理[図4(b)のS230]について説明する。S310において、ICカード10の判定部121は、データ有と判定し[図6(a)の#61]、先頭頁のトランザクション番号と、次の頁のトランザクション番号を比較する(S370)。同一である場合には、判定部121は、その頁(次の頁)のチェックコードに基づいて、退避情報の正当性を判定する(S400)。正しいと判定した場合には、CPU12は、次の頁(「次の頁」の次の頁)について同様の処理を行う(S370,S380)。S400の判定において否と判定した場合には、S340へ進む。また、S380の判定において、次の頁のトランザクション番号が先頭頁と異なる場合には、書き換え部123は、次の頁のトランザクション番号を先頭頁のトランザクション番号と同一に書き換える(S390)。
【0038】
退避情報が1頁で収まらない場合には、書き換え部123は、退避情報を書き込む予定の頁の全てのトランザクション番号を先頭頁と同一に書き換える。本実施形態においては、書き換え部123は、2つの頁のトランザクション番号を書き換える[図6(b)の#62]。退避情報生成部124は、退避情報を生成し(S340)、書き込み部122は、生成した退避情報を、書き換えられたトランザクション番号の後(S390)、又は、有効でないと判定された退避情報の頁に、つまり、有効な退避情報の頁の後(S400)に対象情報及び管理情報を続けて2つの頁に分けて書き込む[S350、図6(b)]。書き込み部122は、新たなデータをデータ領域15dの指定された領域へ書き込み(S360)、処理を終了する(S410)。
【0039】
これら2回のWriteの処理が正常に行われた場合には、ICカード10は、Commitの処理を行い、退避領域15sをクリアにする[図4(b)のS250]。つまり、書き換え部123は、データ有無情報を「データ無」に書き換える[図6(c)の#63]。
なお、図4(b)のS250でCommitの処理を終了した後に、図4(a)のS120において、ICカード10が次のコマンドを受信し、Writeの処理を行った場合には、ICカード10は、図5のS300からS390まで2回目のWriteの処理と同様に処理を行い、トランザクション番号を「2」にインクリメントし、退避情報を書き込む。処理後の退避領域15sは、図6(d)の状態となる。トランザクション番号が「1」の頁の退避情報は、以前の処理段階で書き込まれた古い無効な退避情報である。
【0040】
図7は、ICカード10が行うRollbackの処理を示すフローチャートである。ICカード10は、次のルールに従って、Rollbackの処理を行う。
(1)データ有無情報が「データ有」の場合、つまり、退避領域15sに有効な退避情報が記憶されている場合に処理を行う。
(2)先頭頁のトランザクション番号と同一のトランザクション番号に対応する退避情報(対象情報)、つまり、直近に書き込まれた先頭頁の有効な退避情報と同一の処理段階において書き込まれた退避情報を復帰の対象(復帰対象情報)とする。
(3)チェックコードが正しい退避情報を復帰の対象とする、つまり、退避領域15sへ正常に書き込まれた退避情報を復帰対象情報とする。
(4)ファーストイン・ラストアウト、つまり、後に退避領域15sに書き込まれた退避情報(復帰対象情報)から復帰を行う。
(5)全ての復帰対象情報の復帰が終了、つまり、復帰対象情報のデータ領域15dへの書き込みが終了してからデータ有無情報を「データ無」と書き換える。
以上のルールに従って処理を行うなど、復帰すべき有効な退避情報(復帰対象情報)を退避元の場所(指定された領域)に戻して復帰できれば、Rollbackの処理手順は、限定されない。以下、図7を参照しながらその一例を説明する。
【0041】
図7に示すように、S500において、所定の呼び出し(復帰必要性確認要求;Rollback)があり、ICカード10は、Rollbackの処理を開始する。S510において、判定部121は、退避領域15sに有効な退避情報が記憶されているか否かをデータ有無情報に基づいて判定する(S510)。否と判定した場合には、ICカード10は、Rollbackの処理を終了する(S580)。肯と判定した場合には、判定部121は、先頭頁の退避情報の正当性をチェックコードに基づいて判定する(S520)。不正と判定した場合には、S560に進む。正しいと判定した場合には、CPU12は、この退避情報を復帰すべき情報(復帰対象情報)と判断する(S530)。
【0042】
判定部121は、先頭頁のトランザクション番号及び次の頁のトランザクション番号を比較し(S540)、同一であるか否かを判定する(S550)。同一である場合には、ICカード10は、同様に次の頁(「次の頁」の次の頁)について処理を行う(S540からS570まで)。判定部121が次の頁のトランザクション番号が先頭頁のトランザクション番号と異なると判定した場合には(S550)、書き込み部122は、S530において復帰対象情報と判断された全ての退避情報について、データをその管理情報に基づいてデータ領域15dへそれぞれ書き込み、データの復帰を行う(S560)。なお、書き込み部122は、後の頁の退避情報から先頭頁の退避情報の順にデータの復帰を行う。データの復帰が正常に終了した場合に、書き換え部123は、データ有無情報を「データ無」に書き換え(S570)、ICカード10は、Rollbackの処理を終了する(S580)。
【0043】
図8(a)は、ICカード10がCommitの処理[図4(b)のS250]を行う直前に電源断が発生した場合の退避領域15sのメモリ構造を示す図である。このICカード10に再び電源が供給された場合には[図4(a)のS110]、ICカード10は、Rollbackの処理を行う[図4(a)のS130]。図7に示すように、ICカード10は、データ有無情報、チェックコード、トランザクション番号などに基づいて判定を行い(S510,S520,S550)、トランザクション番号が先頭頁と同一の「2」である頁の退避情報[図8(a)の#81]を復帰対象情報と判断し(S530)、データ領域15dへ復帰する(S560)。
【0044】
図8(b)は、退避領域15sへの退避情報の書き込み中(図5のS350)に電源断が発生した場合の退避領域15sの構造を示す図である。このICカード10に再び電源が供給された場合に[図4(a)のS110]、ICカード10は、Rollbackの処理を行う[図4(a)のS130]。図7に示すように、ICカード10は処理を行い、チェックコードに基づいて2番目及び3番目の頁の退避情報について不備があると判定し(S520)、先頭頁の退避情報のみ[図8(b)の点線]を復帰対象情報と判断し(S530)、復帰を行う(S580)。
【0045】
本実施形態によれば、ICカード10は、不揮発性メモリ15の退避領域15sに対象情報であるデータと、アドレス、データ長及びチェックコードを含む管理情報とを続けて頁単位で書き込み、頁単位での迅速な書き込みによる書き込み保証が可能となった。また、図11に示すように、頁番号N及びN+1の領域(縦線)を指定する書き込み要求があった場合には、この指定された領域に記憶されているデータと、管理情報とを続けて、1頁又は2頁の退避情報として退避領域15sへ書き込むため、書き込み回数が1回又は2回となり、管理情報を別の領域に書き込む場合(3回)に比べて書き込み回数を減らすことができ、より一層の処理の迅速化を図ることが可能となった。
【0046】
また、データ長を含む管理情報を対象情報に続けて退避領域15sに書き込むことによって、退避領域15sの各頁において対象情報が書き込まれている領域を明確にすることが可能となった。更に、対象情報及び管理情報の情報量を明確にすることによって、頁毎の空き領域の情報量を把握することが可能となった。更にまた、チェックコードを退避領域15sに書き込むことによって、対象情報を退避領域15sに書き込む処理においてエラーがあった場合であっても、その検出を容易に行うことが可能となった。
【0047】
また、退避領域15sに有効な対象情報が記憶されているか否かを判定することによって、対象情報を書き込む位置を明確にし、特に、データ有無情報及びトランザクション番号に基づいて判定を行うことによって、判定を容易にし、処理の迅速化を図ることが可能となった。また、退避領域15sの先頭頁(最初にアクセスされる位置)にデータ有無情報を記憶することによって、判定をより一層容易にすることが可能となった。
更に、トランザクション番号を記憶し、対象情報の属性(処理段階)毎に有効性を差別化することによって、退避領域15sに書き込まれている対象情報についての処理手順に柔軟性を持たせ、効率的な処理を行うことが可能となった。
【0048】
更にまた、データ有無情報及びトランザクション番号に基づいて対象情報の復帰を行う必要性について判定することによって、判定を容易にし、処理の迅速化を図ることが可能となった。
また、チェックコードに基づいて、対象情報の有効性、対象情報の復帰の必要性について判定することによって、正確な判定を実現し、確実に書き込み保証を行うことが可能となった。
更に、初期化情報を記憶することによって任意のタイミングでの初期化を可能とし、利便性の向上を図ることが可能となった。
【0049】
(変形形態)
以上説明した実施形態に限定されることなく、種々の変形や変更が可能であって、それらも本発明の均等の範囲内である。例えば、ICカード10及び外部装置20は、接触式、非接触式のいずれの方式で通信を行ってもよく、通信方式は、限定されない。また、ICカード10は、データ領域15dに記憶されているデータについて書き込み保証を行うが、アプリケーションプログラムの書き換えが行われる場合など、データ領域15dに記憶されているプログラムが消去される場合には、プログラムについて書き込み保証を行ってもよく、対象となるデータ領域15dに記憶されている情報の種類は、限定されない。
【0050】
ICカード10は、Writeの処理において、先頭頁と異なるトランザクション番号の頁に書き込みを行うが(図5のS370,S380,S350など)、図9(a)及び図9(b)に示すように、トランザクション番号が同一の頁(有効な退避情報の頁)において、その空き領域(#91)に退避情報生成部124が生成した退避情報を書き込む容量があるか否かをデータ長などに基づいて判定部121が判定し、肯と判定した場合には、書き込み部122は、この空き領域へ退避情報の書き込みを行ってもよい(#92)。
また、チェックコードは、退避情報の正当性を示す書き込み正否情報であるが、トランザクション番号(退避情報が複数頁にわたる場合には、複数頁のトランザクション番号)の正当性をも示していてもよい[図9(c)の#94]。図9(c)は、空き領域へ退避情報が書き込まれ[図9(b)]、Commitの処理が行われ[図4(b)のS250]、受信した新たなコマンドの処理[図4(a)のS140]、つまり、次の処理段階において同一のデータ長を有する退避情報の書き込み(#93)が行われた場合の退避領域15sのメモリ構造を示している。このような場合に、チェックコードが退避情報のみの正否のみを示すときには、前の処理段階において書き込まれた退避情報(#92)がトランザクション番号に基づいて有効なものとみなされるおそれがあるが、チェックコードがトランザクション番号の正当性を示しているとき(#94)には、トランザクション番号が「1」から「2」へ書き換えられているため、トランザクション番号が不正とみなされ、前の処理段階の無効な退避情報(#92)が復元されることを防止することが可能となる。
【0051】
ICカード10は、一の書き換え可能な不揮発性メモリ(不揮発性メモリ15)の記憶領域がデータ領域15d及び退避領域15sに割り当てられているが、2以上の書き換え可能な不揮発性メモリを備える場合には、異なる不揮発性メモリにそれぞれデータ領域15d、退避領域15sを割り当ててもよい。対象情報を記憶するデータ領域15d、退避情報を記憶する退避領域15sをそれぞれ別個の領域として管理できれば、いずれの不揮発性メモリに記憶するかは限定されない。
【0052】
ICカードは、コマンドの受信後[図4(a)のS130]、Writeの処理にエラーがあった場合[図4(b)のS260]にRollbackの処理(図7)を行うが、外部装置20から電源などが供給されてから[図4(a)のS110]、Writeの処理を行う前までに少なくとも1度のRollbackの処理を行っていれば、その処理を行うタイミングは、限定されない。
【0053】
また、Rollbackの処理と同様に、Writeの処理もデータ領域15dの指定された領域に記憶されている対象情報から退避情報を生成し、適切なトランザクション番号に書き換えられれば、トランザクション番号の書き換え(図5のS390)、退避情報の生成(S340)などの処理の前後、つまりWriteの処理手順は、限定されない。
【0054】
Writeの処理、Rollbackの処理及びCommitの処理をCPU12に実行させるプログラムは、オペレーティングシステムに含まれていてもよいし、アプリケーションプログラムに含まれていてもよく、ICカード10に記憶されているいずれのプログラムに含まれるかは限定されない。
【0055】
不揮発性メモリ15は、退避領域15sの先頭頁にデータ有無情報を格納し、記憶しているが、CPU12が退避領域15sの最終頁からアクセスする場合には、最終頁に記憶していてもよく、最初にアクセスされる位置に記憶していればよい。
【0056】
【発明の効果】
以上詳しく説明したように、本発明によれば、以下の効果を得ることが可能となった。
(1)退避領域に対象情報と、退避元位置情報などの管理情報とを続けて頁単位で書き込み、頁単位での迅速な書き込みによる書き込み保証を実現するとともに、制御情報(管理情報)を別の領域に書き込む場合に比べて書き込み回数を減らすことによって、より一層の処理の迅速化を図る。
(2)対象情報の情報量を含む管理情報を対象情報に続けて退避領域に書き込むことによって、退避領域の各頁において対象情報が書き込まれている領域を明確にする。また、対象情報及び管理情報の情報量を明確にすることによって、頁毎の空き領域の情報量を明確にし、空き領域に対象情報及び管理情報を書き込むなど、2以上の対象情報及び管理情報を一の頁に格納し、退避領域を有効に活用する。
(3)チェックコードなどの書き込み正否情報を退避領域に書き込むことによって、対象情報を退避領域に書き込む処理においてエラーがあった場合であっても、その容易な検出を可能とする。
(4)退避領域に有効な対象情報が記憶されているか否かを判定することによって、対象情報を書き込む位置を明確にする。特に、有効性情報に基づいて判定を行うことによって、判定を容易にし、処理の迅速化を図る。また、退避領域の最初にアクセスされる位置に退避領域有効性情報を記憶することによって、判定をより一層容易にする。
(5)例えば、トランザクション番号などの属性別有効性情報を記憶し、対象情報の属性(処理段階)毎に有効性を差別化することによって、退避領域に書き込まれている対象情報についての処理手順に柔軟性を持たせ、効率的な処理を可能とする。
(6)有効性情報に基づいて対象情報の復帰を行う必要性について判定することによって、判定を容易にし、処理の迅速化を図る。
(7)正否示唆情報に基づいて、対象情報、又は、対象情報及び管理情報の正当性、対象情報の復帰の必要性について判定することによって、的確な判定を実現し、確実に書き込み保証を行う。
(8)初期化情報を記憶することによって任意のタイミングでの初期化を可能とし、利便性の向上を図る。
【図面の簡単な説明】
【図1】本発明によるICカードの実施形態を示すブロック図である。
【図2】退避領域15sのメモリ構造を示す図である。
【図3】退避領域15sの初期化された状態を示すメモリ構造図である。
【図4】本発明によるICカードの動作及び本発明によるICカードプログラムを示すフローチャートである。
【図5】本発明によるICカードの動作及び本発明によるICカードプログラムを示すフローチャートである。
【図6】Writeの処理における退避領域15sの変化を示す図である。
【図7】本発明によるICカードの動作及び本発明によるICカードプログラムを示すフローチャートである。
【図8】ICカード10に電源断が発生した場合の退避領域15sのメモリ構造図である。
【図9】本発明によるICカード及びICカードプログラムの変形形態における退避領域15sの構造を示す図である。
【図10】従来のICカードによる書き込み保証の処理を説明するためのEEPROM15−2のメモリ構造図である。
【図11】従来のICカードによる頁単位での書き込み保証の処理を説明するためのEEPROM15−2のメモリ構造図である。
【符号の説明】
10 ICカード
11 I/Oインターフェイス
12 CPU
13 RAM
14 ROM
15 不揮発性メモリ
15d データ領域
15s 退避領域
20 外部装置
121 判定部
122 書き込み部
123 書き換え部
124 退避情報生成部[0001]
TECHNICAL FIELD OF THE INVENTION
The present invention relates to an IC card and an IC card program for performing a return to a state before writing when there is an error in writing to rewritable storage means.
[0002]
[Prior art]
In general, an IC card includes three types of memories, a ROM, a RAM, and a rewritable nonvolatile memory (hereinafter, referred to as “nonvolatile memory”), and a CPU that accesses these memories.
The RAM is a volatile memory and is used as a work area where the CPU performs processing. The ROM is a nonvolatile read-only memory, which manages hardware such as basic software such as an operating system (hereinafter, referred to as “OS”), programs such as an execution environment, and parameters, and can be used by an application. Program and data to be stored. The non-volatile memory is a rewritable non-volatile memory such as an EEPROM, a flash memory, and an FRAM, and is generally used as a work area, a program area, and the like for a user. Note that the IC card refers to a portable information processing device including at least a CPU such as a SIM card and an IC tag, a communication unit with the outside, and a storage unit for storing information, regardless of the base material.
When this IC card is used, the IC card is connected to an external device such as a reader / writer, and a command is transmitted from the external device to the IC card. In the IC card that has received the command, the CPU executes a portion corresponding to the command in the program stored in the ROM or the nonvolatile memory. As a result, the command is processed, processing such as writing new data to the nonvolatile memory is performed, and the processing result is transmitted from the IC card to the external device as a response (for example, see Patent Document 1).
[0003]
[Patent Document 1]
JP-A-10-40350 (
[0004]
[Problems to be solved by the invention]
Since the IC card is supplied with power for processing from an external device, the power supply may be interrupted during data writing to the nonvolatile memory. In particular, in the case of a non-contact type IC card that communicates with an external device in a non-contact type, the power supply is interrupted (hereinafter referred to as “power-off”) because the relative position with the external device is not fixed during communication. )) Is likely to occur. Therefore, in such a case, the IC card returns to the state before the data is written, that is, performs a process of guaranteeing the writing in order to return.
[0005]
FIG. 10 is a memory structure diagram of the nonvolatile memory 15-2 for explaining the write assurance process. Note that a description will be given of write assurance when data B is newly written in an area where data A is stored in the nonvolatile memory 15-2. FIG. 10A shows a case where the writing is performed normally, and FIG. 10B shows a case where the writing is not performed normally due to a write error such as a power-off during the processing. I have.
As shown in FIG. 10A, in the nonvolatile memory 15-2, data such as data A and a program such as an application program are recorded. And a
[0006]
As shown in # 101 of FIG. 10, first, the CPU saves (writes) the data A into the
If the power is turned off while writing data A to the
[0007]
On the other hand, the process of writing data to the non-volatile memory 15-2 takes a peculiar time compared to other processes such as the process of reading data and programs from the non-volatile memory 15-2. Has been done. The page unit means a unit of a predetermined amount of data. For example, data of 64 bytes is used as one unit of processing. When one page is n bytes and the page is the same page, the time required for the processing of writing one byte and the processing of writing n bytes hardly change because the number of times of writing is one. On the other hand, if the page is different even in the case of 2-byte writing, the number of times of writing is different, so that it takes about twice as much processing time as writing 2 bytes to the same page.
[0008]
FIG. 11 is a diagram for explaining a write assurance process in writing in page units. The process of saving data from the
As shown in FIG. 11, when rewriting the data of the page number K, the data of the page number K is copied as it is in the
[0009]
Therefore, when data of one page is saved, two writings are required, and when data of two pages is saved, three writings are required. In other words, at least two writings are required only for the evacuation process, which causes a longer processing time and also increases the probability of occurrence of power interruption. Also, if the power is interrupted during writing, it is necessary to return to the original state and then perform writing again, so that it takes longer processing time than when only writing is performed. There has been a strong demand for speeding up, especially speeding up of write processing, which takes time for processing.
[0010]
An object of the present invention is to provide an IC card and an IC card program capable of improving the processing speed.
[0011]
[Means for Solving the Problems]
The present invention solves the above problem by the following means. In addition, in order to facilitate understanding, the description will be given with reference numerals corresponding to the embodiment of the present invention, but the present invention is not limited to this. In other words, the invention according to
[0012]
According to a second aspect of the present invention, in the IC card according to the first aspect, the save area writing means is configured to store the target information, save source position information indicating a position of the designated area, and / or information of the target information. An IC card (10), wherein management information including an amount is continuously written in the save area.
[0013]
According to a third aspect of the present invention, in the IC card according to the first or second aspect, the save area writing unit is configured to store the target information and the target information or the target information and the management information by the save area writing unit. An IC card (10) characterized in that management information including write correctness information indicating whether or not the data has been normally written in the save area is continuously written in the save area.
[0014]
A fourth aspect of the present invention is the IC card according to any one of the first to third aspects, wherein the rewritable storage means stores valid target information in the save area. And / or storing validity information including attribute-specific validity information indicating whether the target information stored in the save area is valid or not by its attribute. It is an IC card (10) characterized by the following.
[0015]
According to a fifth aspect of the present invention, in the IC card according to the fourth aspect, the rewritable storage unit stores the save area validity information at a position accessed first in the save area. This is an IC card (10).
[0016]
According to a sixth aspect of the present invention, in the IC card according to the fourth or fifth aspect, when the write request is made, whether valid target information is stored in the save area based on the validity information. A save area validity determination means (121, S310, S380) for determining whether or not the save area is valid when the save area validity determination means determines affirmative. An IC card (10) characterized in that a page of target information and management information is written in response to the write request after a page of target information and management information thereof.
[0017]
According to a seventh aspect of the present invention, in the IC card according to the sixth aspect, when the evacuation area validity judging unit judges affirmative, it responds to the write request on the page of the valid target information and management information. A vacant area determination unit (121) for determining whether there is a vacant area in which the target information and the management information are to be written; After the page of the target information and the management information, the page of the target information and the management information is written in response to the write request, and when the free space determination unit determines affirmative, the target information and the management in response to the write request An IC card (10), wherein information is written in the empty area.
[0018]
According to an eighth aspect of the present invention, in the IC card according to any one of the fourth to seventh aspects, when a return necessity confirmation request is issued (S500), the object stored in the save area is determined. A return necessity determining means (S510, S550) for determining whether or not there is a need to perform the information return, based on the validity information; An IC card (10) comprising: a return unit (122, S560) for writing target information in the designated area based on the management information and for returning the target information.
[0019]
According to a ninth aspect of the present invention, in the IC card according to any one of the sixth to eighth aspects, the evacuation area validity judging means and / or the return necessity judging means comprises the validity information and the return necessity judging means. An IC card characterized in that a determination is made based on the write right / wrong information corresponding to the target information (S400, S520).
[0020]
According to a tenth aspect of the present invention, in the IC card according to any one of the first to ninth aspects, the rewritable storage means stores initialization information indicating whether or not the save area has been initialized. Is stored in the IC card (10).
[0021]
The invention according to an eleventh aspect is characterized in that when a write request is issued to the CPU (12) of the IC card (10) having the rewritable storage means (15) (S300), the rewritable storage means is designated. An IC card program for executing a specified information writing procedure (S360) for writing information specified in an area in units of pages, wherein when the writing request is issued, the evacuation area is different from the specified area. The area includes a save area writing procedure (S350) in which the target information stored in the designated area and the management information of the target information are successively written in page units. An IC card program which is executed after an area writing procedure.
[0022]
According to a twelfth aspect of the present invention, in the IC card program according to the eleventh aspect, the evacuation area writing procedure includes a step of storing the target information and evacuation source position information indicating a position of the designated area and / or the target information. An IC card program characterized in that management information including an information amount is continuously written in the save area.
[0023]
According to a thirteenth aspect of the present invention, in the IC card program according to the eleventh or twelfth aspect, in the save area writing step, the target information and the target information or the target information and the management information are stored in the save area. An IC card program characterized by continuously writing management information including write validity information indicating whether or not data has been normally written to the save area in the area write procedure, to the save area.
[0024]
According to a fourteenth aspect of the present invention, in the IC card program according to any one of the eleventh to thirteenth aspects, when the write request is issued, a valid area in the save area is validated based on the validity information. A save area validity determination procedure (S310, S380) for determining whether or not the target information is stored, wherein the save area writing procedure is performed when the save area validity determination procedure determines that the save is valid. An IC card program characterized by writing a page of target information and management information in response to the write request after a page of the valid target information and its management information in an area.
[0025]
According to a fifteenth aspect of the present invention, in the IC card according to the fourteenth aspect, when the evacuation area validity determination step determines that the answer is affirmative, the target is set to a page of the valid target information and management information in response to the write request. A vacant area determining step of determining whether there is a vacant area in which information and management information are to be written, wherein the evacuation area writing procedure includes: After the page of information, the page of the target information and the management information is written in response to the write request, and if the determination is affirmative in the empty area determination procedure, the target information and the management information are written in the empty area in response to the write request. Writing an IC card program.
[0026]
According to a sixteenth aspect of the present invention, in the IC card program according to any one of the eleventh to fifteenth aspects, when a return necessity confirmation request is made, the target information stored in the save area is A return necessity determination procedure (S510, S520, S550) for determining whether or not there is a need to perform the return, and when the return necessity determination procedure is determined to be positive, the target information is determined based on the management information. (S560) for writing data in the designated area and restoring the target information.
[0027]
BEST MODE FOR CARRYING OUT THE INVENTION
Hereinafter, embodiments of the present invention will be described in more detail with reference to the drawings and the like.
(Embodiment)
FIG. 1 is a block diagram showing an embodiment of an IC card according to the present invention.
Note that the same reference numerals are given to portions that perform the same functions as those of the above-described conventional example, and redundant description will be omitted as appropriate.
As shown in FIG. 1, the
The
The information storage area of the
[0028]
FIG. 2 is a diagram illustrating a memory structure of the
As shown in FIG. 2, the
[0029]
The initialization information is information indicating whether or not the save
[0030]
As shown in FIG. 2 and FIG. 3, the transaction numbers are stored in the
[0031]
It is desirable that the
[0032]
As shown in FIG. 2, the save information is information generated by the save
[0033]
FIGS. 4, 5 and 7 are flowcharts showing the operation of the IC card according to the present invention and the IC card program according to the present invention. Hereinafter, the processing of the
As shown in FIG. 4A, in step 110 (hereinafter, “step” is referred to as “S”), the
[0034]
FIG. 4B is a diagram showing processing such as writing performed on the
As shown in FIG. 4B, the
If the two Write processes are performed normally, the
[0035]
On the other hand, if an error occurs during the processing of any of the Writes (S220, S240), for example, the writing to the save
[0036]
FIG. 5 is a flowchart showing a Write process performed by the IC card according to the present invention, and FIG. 6 is a diagram showing a change in the
First, the first Write process [S210 in FIG. 4B] will be described.
In S300, there is a write request, and the
[0037]
Next, the second Write process [S230 in FIG. 4B] will be described. In S310, the
[0038]
If the save information does not fit on one page, the
[0039]
When these two Write processes are performed normally, the
After the commit process is completed in S250 of FIG. 4B, if the
[0040]
FIG. 7 is a flowchart illustrating a Rollback process performed by the
(1) The process is performed when the data presence / absence information is “data present”, that is, when valid save information is stored in the
(2) Restore the save information (target information) corresponding to the same transaction number as the transaction number of the first page, that is, the save information written in the same processing stage as the valid save information of the first page written most recently. (Return target information).
(3) Save information whose check code is correct is set as a recovery target, that is, save information normally written in the
(4) First in / last out, that is, restoration is performed from save information (return target information) written in the
(5) After the restoration of all the restoration target information is completed, that is, after the restoration target information has been written into the
Rollback processing procedures are not limited, as long as valid save information (return target information) to be restored can be returned to the save source location (designated area) and restored, such as by performing processing according to the above rules. Hereinafter, an example will be described with reference to FIG.
[0041]
As shown in FIG. 7, in S500, there is a predetermined call (return necessity confirmation request; Rollback), and the
[0042]
The
[0043]
FIG. 8A is a diagram illustrating the memory structure of the
[0044]
FIG. 8B is a diagram showing the structure of the
[0045]
According to the present embodiment, the
[0046]
Further, by writing the management information including the data length in the
[0047]
Further, by determining whether or not valid target information is stored in the
Furthermore, by storing the transaction number and differentiating the validity for each attribute (processing stage) of the target information, the processing procedure for the target information written in the
[0048]
Furthermore, by determining the necessity of returning the target information based on the data presence / absence information and the transaction number, the determination can be facilitated and the processing can be speeded up.
Further, by determining the validity of the target information and the necessity of returning the target information based on the check code, it is possible to realize an accurate determination and to surely guarantee the writing.
Furthermore, by storing the initialization information, initialization can be performed at an arbitrary timing, and convenience can be improved.
[0049]
(Modified form)
Various modifications and changes are possible without being limited to the embodiments described above, and these are also within the equivalent scope of the present invention. For example, the
[0050]
In the Write process, the
Further, the check code is write correctness information indicating the validity of the save information, but may also indicate the validity of the transaction number (if the save information covers a plurality of pages, the transaction number of a plurality of pages) [ # 94 in FIG. 9 (c)]. In FIG. 9C, the evacuation information is written into the free space [FIG. 9B], the commit process is performed [S250 in FIG. 4B], and the process of the received new command [FIG. a) S140], that is, the memory structure of the
[0051]
When the storage area of one rewritable nonvolatile memory (nonvolatile memory 15) is allocated to the
[0052]
After receiving the command [S130 in FIG. 4A], the IC card performs the Rollback process (FIG. 7) when there is an error in the Write process [S260 in FIG. 4B]. The timing of performing the Rollback process at least once from when power is supplied from the
[0053]
Similarly to the Rollback process, the Write process also generates save information from the target information stored in the designated area of the
[0054]
The program that causes the
[0055]
The
[0056]
【The invention's effect】
As described above in detail, according to the present invention, the following effects can be obtained.
(1) The target information and the management information such as the save source position information are successively written in the save area in units of pages to realize writing assurance by rapid writing in page units and separate control information (management information). By reducing the number of times of writing as compared with the case of writing in the area, the processing can be further speeded up.
(2) By writing management information including the information amount of the target information in the save area following the target information, the area where the target information is written in each page of the save area is clarified. Also, by clarifying the information amount of the target information and the management information, the information amount of the free area for each page is clarified, and the target information and the management information are written in the free area. It is stored in one page, and the save area is used effectively.
(3) By writing the write right / wrong information such as a check code to the save area, even if there is an error in the process of writing the target information to the save area, it is possible to easily detect the error.
(4) The position where the target information is to be written is clarified by determining whether valid target information is stored in the save area. In particular, by making a determination based on the validity information, the determination is facilitated and the processing is speeded up. Also, by storing the save area validity information at the first accessed position of the save area, the determination is further facilitated.
(5) For example, by storing attribute-specific validity information such as a transaction number and differentiating the validity for each attribute (processing stage) of the target information, a processing procedure for the target information written in the save area With flexibility and efficient processing.
(6) By determining the necessity of returning the target information based on the validity information, the determination is facilitated and the processing is speeded up.
(7) By judging the validity of the target information, or the validity of the target information and the management information, and the necessity of returning the target information based on the suggestion information, an accurate determination is realized, and the writing guarantee is surely performed. .
(8) By storing the initialization information, initialization can be performed at an arbitrary timing, and convenience is improved.
[Brief description of the drawings]
FIG. 1 is a block diagram showing an embodiment of an IC card according to the present invention.
FIG. 2 is a diagram showing a memory structure of a
FIG. 3 is a memory structure diagram showing an initialized state of a
FIG. 4 is a flowchart showing an operation of an IC card according to the present invention and an IC card program according to the present invention.
FIG. 5 is a flowchart showing an operation of the IC card according to the present invention and an IC card program according to the present invention.
FIG. 6 is a diagram showing a change in a
FIG. 7 is a flowchart showing an operation of an IC card according to the present invention and an IC card program according to the present invention.
FIG. 8 is a memory structure diagram of a
FIG. 9 is a diagram showing a structure of a
FIG. 10 is a memory structure diagram of an EEPROM 15-2 for explaining a write assurance process using a conventional IC card.
FIG. 11 is a diagram showing a memory structure of an EEPROM 15-2 for explaining a process of guaranteeing writing in units of pages using a conventional IC card.
[Explanation of symbols]
10 IC card
11 I / O interface
12 CPU
13 RAM
14 ROM
15 Non-volatile memory
15d data area
15s evacuation area
20 External devices
121 Judgment unit
122 Writing Unit
123 Rewriting unit
124 evacuation information generation unit
Claims (16)
前記書き込み要求があった場合に、前記指定された領域とは別の領域である退避領域に、前記指定された領域に記憶されている対象情報と、この対象情報の管理情報とを続けて頁単位で書き込む退避領域書き込み手段を備え、
前記指定情報書き込み手段は、前記退避領域書き込み手段による書き込みの後に前記指定された情報の書き込みを行うこと、
を特徴とするICカード。An IC card comprising: a rewritable storage unit; and a designated information writing unit that writes, in a page unit, information specified in a specified area of the rewritable storage unit when a write request is issued,
When the write request is issued, the target information stored in the specified area and the management information of the target information are sequentially stored in a save area, which is an area different from the specified area, in a page. A save area writing means for writing in units of
The designated information writing unit writes the designated information after the writing by the save area writing unit;
An IC card characterized by the above-mentioned.
前記退避領域書き込み手段は、前記対象情報と、前記指定された領域の位置を示す退避元位置情報及び/又は前記対象情報の情報量を含む管理情報とを続けて前記退避領域へ書き込むこと、
を特徴とするICカード。The IC card according to claim 1,
The save area writing means continuously writes the target information and the save source position information indicating the position of the designated area and / or management information including the information amount of the target information in the save area;
An IC card characterized by the above-mentioned.
前記退避領域書き込み手段は、前記対象情報と、前記対象情報、又は、前記対象情報及び前記管理情報が前記退避領域書き込み手段によって正常に退避領域に書き込まれたか否かを示す書き込み正否情報を含む管理情報とを続けて前記退避領域へ書き込むこと、
を特徴とするICカード。In the IC card according to claim 1 or 2,
The save area writing means manages the target information and the target information, or the write information indicating whether or not the target information and the management information have been normally written in the save area by the save area writing means. Continuously writing information with the save area,
An IC card characterized by the above-mentioned.
前記書き換え可能な記憶手段は、前記退避領域に有効な対象情報を記憶しているか否かを示す退避領域有効性情報、及び/又は、前記退避領域に記憶されている対象情報が有効であるか否かをその属性によって示す属性別有効性情報を含む有効性情報を記憶すること、
を特徴とするICカード。The IC card according to any one of claims 1 to 3,
The rewritable storage means may include save area validity information indicating whether valid object information is stored in the save area, and / or whether the target information stored in the save area is valid. Storing validity information including validity information by attribute indicating whether or not the attribute is present,
An IC card characterized by the above-mentioned.
前記書き換え可能な記憶手段は、前記退避領域において最初にアクセスされる位置に前記退避領域有効性情報を記憶すること、
を特徴とするICカード。The IC card according to claim 4,
The rewritable storage unit stores the save area validity information at a position where the save area is first accessed,
An IC card characterized by the above-mentioned.
前記書き込み要求があった場合に、前記有効性情報に基づいて前記退避領域に有効な対象情報が記憶されているか否かを判定する退避領域有効性判定手段を備え、
前記退避領域書き込み手段は、前記退避領域有効性判定手段によって肯と判定された場合に、前記退避領域において前記有効な対象情報及びその管理情報の頁の後に前記書き込み要求に応じて対象情報及び管理情報の頁を書き込むこと、
を特徴とするICカード。In the IC card according to claim 4 or 5,
When the write request is made, the apparatus further comprises a save area validity determination unit that determines whether valid target information is stored in the save area based on the validity information,
The evacuation area writing means, when the evacuation area validity determination means determines affirmative, in the evacuation area, after the page of the valid object information and its management information, the object information and management in response to the write request. Writing pages of information,
An IC card characterized by the above-mentioned.
前記退避領域有効性判定手段によって肯と判定された場合に、前記有効な対象情報及び管理情報の頁に前記書き込み要求に応じて対象情報及び管理情報を書き込む空き領域があるか否かを判定する空き領域判定手段を備え、
前記退避領域書き込み手段は、前記空き領域判定手段によって否と判定された場合に、前記有効な対象情報及び管理情報の頁の後に前記書き込み要求に応じて対象情報及び管理情報の頁を書き込み、前記空き領域判定手段によって肯と判定された場合に、前記書き込み要求に応じて対象情報及び管理情報を前記空き領域に書き込むこと、
を特徴とするICカード。The IC card according to claim 6,
When the evacuation area validity determination unit determines affirmative, it is determined whether or not there is a free area for writing the target information and the management information in response to the write request on the page of the valid target information and the management information. A vacant area determination unit,
The evacuation area writing unit writes the target information and management information pages in response to the write request after the valid target information and management information pages, when the empty area determination unit determines that the area is not available. When the free space determination means is determined to be affirmative, writing target information and management information to the free space in response to the write request;
An IC card characterized by the above-mentioned.
復帰必要性確認要求があった場合に、前記退避領域に記憶されている対象情報の復帰を行う必要性があるか否かを前記有効性情報に基づいて判定する復帰必要性判定手段と、
前記復帰必要性判定手段によって肯と判定された場合に、前記対象情報をその管理情報に基づいて前記指定された領域に書き込み、前記対象情報の復帰を行う復帰手段とを備えること、
を特徴とするICカード。The IC card according to any one of claims 4 to 7,
When there is a return necessity confirmation request, a return necessity determination unit that determines whether or not it is necessary to return the target information stored in the save area based on the validity information,
When the return necessity determination unit is determined to be affirmative, the return unit performs writing of the target information to the designated area based on the management information, and returns the target information.
An IC card characterized by the above-mentioned.
前記退避領域有効性判定手段及び/又は前記復帰必要性判定手段は、前記有効性情報及び前記対象情報に対応する前記書き込み正否情報に基づいて判定を行うこと、
を特徴とするICカード。The IC card according to any one of claims 6 to 8,
The evacuation area validity determination unit and / or the return necessity determination unit perform a determination based on the validity information and the write correct / unnecessary information corresponding to the target information;
An IC card characterized by the above-mentioned.
前記書き換え可能な記憶手段は、前記退避領域が初期化済みか否かを示す初期化情報を記憶すること、
を特徴とするICカード。The IC card according to any one of claims 1 to 9,
The rewritable storage unit stores initialization information indicating whether the save area has been initialized,
An IC card characterized by the above-mentioned.
前記書き込み要求があった場合に、前記指定された領域とは別の領域である退避領域に、前記指定された領域に記憶されている対象情報と、この対象情報の管理情報とを続けて頁単位で書き込む退避領域書き込み手順を備え、
前記指定情報書き込み手順は、前記退避領域書き込み手順の後に実行されること、
を特徴とするICカードプログラム。An IC for executing a designated information writing procedure for writing, in a page unit, designated information in a designated area of the rewritable storage means when a write request is issued to a CPU of the IC card having the rewritable storage means; A card program,
When the write request is issued, the target information stored in the specified area and the management information of the target information are sequentially stored in a save area, which is an area different from the specified area, in a page. Equipped with a save area write procedure to write in units
The designation information writing procedure is performed after the save area writing procedure,
An IC card program characterized by the above-mentioned.
前記退避領域書き込み手順は、前記対象情報と、前記指定された領域の位置を示す退避元位置情報及び/又は前記対象情報の情報量を含む管理情報とを続けて前記退避領域へ書き込むこと、
を特徴とするICカードプログラム。The IC card program according to claim 11,
The save area writing procedure is to continuously write the target information and management information including the save source position information indicating the position of the designated area and / or the information amount of the target information to the save area,
An IC card program characterized by the above-mentioned.
前記退避領域書き込み手順は、前記対象情報と、前記対象情報、又は、前記対象情報及び前記管理情報が前記退避領域書き込み手順において正常に退避領域に書き込まれたか否かを示す書き込み正否情報を含む管理情報とを続けて前記退避領域へ書き込むこと、
を特徴とするICカードプログラム。In the IC card program according to claim 11 or 12,
The evacuation area writing procedure includes managing the target information and the target information, or write correct / incorrect information indicating whether the target information and the management information have been normally written in the evacuation area in the evacuation area writing procedure. Continuously writing information with the save area,
An IC card program characterized by the above-mentioned.
前記書き込み要求があった場合に、前記有効性情報に基づいて前記退避領域に有効な対象情報が記憶されているか否かを判定する退避領域有効性判定手順を備え、
前記退避領域書き込み手順は、前記退避領域有効性判定手順において肯と判定した場合に、前記退避領域において前記有効な対象情報及びその管理情報の頁の後に前記書き込み要求に応じて対象情報及び管理情報の頁を書き込むこと、
を特徴とするICカードプログラム。The IC card program according to any one of claims 11 to 13,
When the write request is made, the method further comprises a save area validity determination step of determining whether valid target information is stored in the save area based on the validity information,
In the save area writing procedure, when the save area validity determination step is determined to be affirmative, the target information and the management information in the save area in response to the write request after the page of the valid target information and the management information thereof. Writing pages of
An IC card program characterized by the above-mentioned.
前記退避領域有効性判定手順において肯と判定した場合に、前記有効な対象情報及び管理情報の頁に前記書き込み要求に応じて対象情報及び管理情報を書き込む空き領域があるか否かを判定する空き領域判定手順を備え、
前記退避領域書き込み手順は、前記空き領域判定手順において否と判定した場合に、前記有効な対象情報及び管理情報の頁の後に前記書き込み要求に応じて対象情報及び管理情報の頁を書き込み、前記空き領域判定手順において肯と判定した場合に、前記書き込み要求に応じて対象情報及び管理情報を前記空き領域に書き込むこと、
を特徴とするICカードプログラム。The IC card according to claim 14,
When the save area validity determination procedure is determined to be affirmative, an empty area for determining whether there is an empty area for writing the target information and the management information in response to the write request on the page of the valid target information and the management information. Equipped with an area determination procedure,
The evacuation area writing procedure writes a page of the target information and the management information in response to the write request after the page of the valid target information and the management information when it is determined to be no in the empty area determination procedure, and When it is determined to be affirmative in the area determination procedure, writing the target information and the management information to the free area in response to the write request,
An IC card program characterized by the above-mentioned.
復帰必要性確認要求があった場合に、前記退避領域に記憶されている対象情報の復帰を行う必要性があるか否かを判定する復帰必要性判定手順と、
前記復帰必要性判定手順において肯と判定した場合に、前記対象情報をその管理情報に基づいて前記指定された領域に書き込み、前記対象情報の復帰を行う復帰手順とを備えること、
を特徴とするICカードプログラム。The IC card program according to any one of claims 11 to 15,
When there is a return necessity confirmation request, a return necessity determination procedure for determining whether or not it is necessary to return the target information stored in the save area;
When the determination is affirmative in the return necessity determination procedure, the target information is written to the designated area based on the management information, and a return procedure for returning the target information is provided.
An IC card program characterized by the above-mentioned.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2003056563A JP4195822B2 (en) | 2003-03-04 | 2003-03-04 | IC card and IC card program |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2003056563A JP4195822B2 (en) | 2003-03-04 | 2003-03-04 | IC card and IC card program |
Related Child Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
JP2008215437A Division JP5104653B2 (en) | 2008-08-25 | 2008-08-25 | IC card and IC card program |
Publications (2)
Publication Number | Publication Date |
---|---|
JP2004265275A true JP2004265275A (en) | 2004-09-24 |
JP4195822B2 JP4195822B2 (en) | 2008-12-17 |
Family
ID=33120209
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
JP2003056563A Expired - Fee Related JP4195822B2 (en) | 2003-03-04 | 2003-03-04 | IC card and IC card program |
Country Status (1)
Country | Link |
---|---|
JP (1) | JP4195822B2 (en) |
Cited By (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP2005235028A (en) * | 2004-02-23 | 2005-09-02 | Sony Corp | Information processor, information processing method, and computer program |
JP2006113985A (en) * | 2004-10-18 | 2006-04-27 | Nissan Motor Co Ltd | Data rewrite method for electronic control apparatus |
JP2009151603A (en) * | 2007-12-21 | 2009-07-09 | Toshiba Corp | Information processing apparatus and data recovering method |
JP2013003831A (en) * | 2011-06-16 | 2013-01-07 | Dainippon Printing Co Ltd | Ic chip, processing program for ic chip, and writing processing method in ic chip |
JP2014110057A (en) * | 2012-12-04 | 2014-06-12 | Samsung Electronics Co Ltd | Storage devices, flash memories, and methods of operating storage devices |
-
2003
- 2003-03-04 JP JP2003056563A patent/JP4195822B2/en not_active Expired - Fee Related
Cited By (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP2005235028A (en) * | 2004-02-23 | 2005-09-02 | Sony Corp | Information processor, information processing method, and computer program |
JP4701618B2 (en) * | 2004-02-23 | 2011-06-15 | ソニー株式会社 | Information processing apparatus, information processing method, and computer program |
US8756384B2 (en) | 2004-02-23 | 2014-06-17 | Sony Corporation | Information processing device and information processing method for data recovery after failure |
JP2006113985A (en) * | 2004-10-18 | 2006-04-27 | Nissan Motor Co Ltd | Data rewrite method for electronic control apparatus |
JP2009151603A (en) * | 2007-12-21 | 2009-07-09 | Toshiba Corp | Information processing apparatus and data recovering method |
JP2013003831A (en) * | 2011-06-16 | 2013-01-07 | Dainippon Printing Co Ltd | Ic chip, processing program for ic chip, and writing processing method in ic chip |
JP2014110057A (en) * | 2012-12-04 | 2014-06-12 | Samsung Electronics Co Ltd | Storage devices, flash memories, and methods of operating storage devices |
Also Published As
Publication number | Publication date |
---|---|
JP4195822B2 (en) | 2008-12-17 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
JP4037605B2 (en) | Nonvolatile memory unit controller, memory system having the controller, and nonvolatile memory unit control method | |
US20070011416A1 (en) | Data storage device and medium and related method of storing backup data | |
CN109685190B (en) | Power-down protection method and device for IC card | |
JP2005085011A (en) | Nonvolatile memory controller | |
CN104978154A (en) | Cache operation-based flash rapid read-write method and system | |
JP5104653B2 (en) | IC card and IC card program | |
JP2003216511A (en) | Non-volatile memory device, data updating method, data updating program and computer readable recording medium with recorded program | |
JP4195822B2 (en) | IC card and IC card program | |
CN113918485B (en) | Method, device, equipment and storage medium for preventing flash memory data from being lost | |
JP4460850B2 (en) | IC card and IC card processing method | |
JP3607658B2 (en) | Portable electronic device | |
JP3818130B2 (en) | Data management method and apparatus, data management program, and storage medium storing data management program | |
JP2001084180A (en) | File managing device | |
JP4784138B2 (en) | IC card and IC card program | |
US7849279B2 (en) | Method for the secure updating data areas in non volatile memory, device to perform such a method | |
JPH06309527A (en) | Ic card | |
JP2000243093A (en) | Data storing method for flash memory and data reading out method from flash memory | |
JP7322923B2 (en) | Secure element, transaction control method and device | |
US11150940B2 (en) | System and method for recording transaction associated with a page-oriented non-volatile memory | |
JP5092370B2 (en) | Portable information recording medium and program thereof | |
JP2007199846A (en) | Memory control device and memory control method | |
JP2004151958A (en) | Ic card | |
CN116669224A (en) | Network connection method, intelligent device and storage medium | |
JPH1027225A (en) | Memory management system for non-contact ic card | |
JPH11161562A (en) | Ic card and memory management method for ic card |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
A621 | Written request for application examination |
Free format text: JAPANESE INTERMEDIATE CODE: A621 Effective date: 20060221 |
|
RD02 | Notification of acceptance of power of attorney |
Free format text: JAPANESE INTERMEDIATE CODE: A7422 Effective date: 20061117 |
|
A977 | Report on retrieval |
Free format text: JAPANESE INTERMEDIATE CODE: A971007 Effective date: 20080620 |
|
A131 | Notification of reasons for refusal |
Free format text: JAPANESE INTERMEDIATE CODE: A131 Effective date: 20080624 |
|
A521 | Written amendment |
Free format text: JAPANESE INTERMEDIATE CODE: A523 Effective date: 20080825 |
|
TRDD | Decision of grant or rejection written | ||
A01 | Written decision to grant a patent or to grant a registration (utility model) |
Free format text: JAPANESE INTERMEDIATE CODE: A01 Effective date: 20080916 |
|
A01 | Written decision to grant a patent or to grant a registration (utility model) |
Free format text: JAPANESE INTERMEDIATE CODE: A01 |
|
A61 | First payment of annual fees (during grant procedure) |
Free format text: JAPANESE INTERMEDIATE CODE: A61 Effective date: 20080929 |
|
R150 | Certificate of patent or registration of utility model |
Ref document number: 4195822 Country of ref document: JP Free format text: JAPANESE INTERMEDIATE CODE: R150 Free format text: JAPANESE INTERMEDIATE CODE: R150 |
|
FPAY | Renewal fee payment (event date is renewal date of database) |
Free format text: PAYMENT UNTIL: 20111003 Year of fee payment: 3 |
|
FPAY | Renewal fee payment (event date is renewal date of database) |
Free format text: PAYMENT UNTIL: 20121003 Year of fee payment: 4 |
|
FPAY | Renewal fee payment (event date is renewal date of database) |
Free format text: PAYMENT UNTIL: 20131003 Year of fee payment: 5 |
|
LAPS | Cancellation because of no payment of annual fees |