[go: up one dir, main page]

JP4195822B2 - IC card and IC card program - Google Patents

IC card and IC card program Download PDF

Info

Publication number
JP4195822B2
JP4195822B2 JP2003056563A JP2003056563A JP4195822B2 JP 4195822 B2 JP4195822 B2 JP 4195822B2 JP 2003056563 A JP2003056563 A JP 2003056563A JP 2003056563 A JP2003056563 A JP 2003056563A JP 4195822 B2 JP4195822 B2 JP 4195822B2
Authority
JP
Japan
Prior art keywords
information
area
writing
save area
target information
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.)
Expired - Fee Related
Application number
JP2003056563A
Other languages
Japanese (ja)
Other versions
JP2004265275A (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.)
Dai Nippon Printing Co Ltd
Original Assignee
Dai Nippon Printing 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 Dai Nippon Printing Co Ltd filed Critical Dai Nippon Printing Co Ltd
Priority to JP2003056563A priority Critical patent/JP4195822B2/en
Publication of JP2004265275A publication Critical patent/JP2004265275A/en
Application granted granted Critical
Publication of JP4195822B2 publication Critical patent/JP4195822B2/en
Anticipated expiration legal-status Critical
Expired - Fee Related legal-status Critical Current

Links

Images

Landscapes

  • Techniques For Improving Reliability Of Storages (AREA)

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)と、前記書き込み要求があった場合に、前記退避領域に有効な対象情報を記憶しているか否かを示す退避領域有効性情報、及び/又は、前記退避領域に記憶されている対象情報が有効であるか否かをその属性によって示す属性別有効性情報を含む有効性情報に基づいて前記退避領域に有効な対象情報が記憶されているか否かを判定する退避領域有効性判定手段(121、S310,S380)を備え、前記指定情報書き込み手段は、前記退避領域書き込み手段による書き込みの後に前記指定された情報の書き込みを行い、前記書き換え可能な記憶手段は、前記有効性情報を記憶し、前記退避領域書き込み手段は、前記退避領域有効性判定手段によって肯と判定された場合に、前記退避領域において前記有効な対象情報及びその管理情報の頁の後に前記書き込み要求に応じて対象情報及び管理情報の頁を書き込むこと、を特徴とするICカード(10)である。
【0012】
請求項2の発明は、請求項1に記載のICカードにおいて、前記退避領域書き込み手段は、前記対象情報と、前記指定された領域の位置を示す退避元位置情報及び/又は前記対象情報の情報量を含む管理情報とを続けて前記退避領域へ書き込むこと、を特徴とするICカード(10)である。
【0013】
請求項3の発明は、請求項1又は請求項2に記載のICカードにおいて、前記退避領域書き込み手段は、前記対象情報と、対象情報、又は、対象情報及び管理情報が前記退避領域書き込み手段によって正常に退避領域に書き込まれたか否かを示す書き込み正否情報を含む管理情報とを続けて前記退避領域へ書き込むこと、を特徴とするICカード(10)である。
【0014】
請求項4の発明は、請求項1に記載のICカードにおいて、前記書き換え可能な記憶手段は、前記退避領域において最初にアクセスされる位置に前記退避領域有効性情報を記憶すること、を特徴とするICカード(10)である。
【0015】
請求項5の発明は、請求項1に記載のICカードにおいて、前記退避領域有効性判定手段によって肯と判定された場合に、前記有効な対象情報及び管理情報の頁に前記書き込み要求に応じて対象情報及び管理情報を書き込む空き領域があるか否かを判定する空き領域判定手段(121)を備え、前記退避領域書き込み手段は、前記空き領域判定手段によって否と判定された場合に、前記有効な対象情報及び管理情報の頁の後に前記書き込み要求に応じて対象情報及び管理情報の頁を書き込み、前記空き領域判定手段によって肯と判定された場合に、前記書き込み要求に応じて対象情報及び管理情報を前記空き領域に書き込むこと、を特徴とするICカード(10)である。
【0016】
請求項6の発明は、請求項1から請求項1までのいずれか1項に記載のICカードにおいて、復帰必要性確認要求があった場合(S500)に、前記退避領域に記憶されている対象情報の復帰を行う必要性があるか否かを前記有効性情報に基づいて判定する復帰必要性判定手段(S510,S550)と、前記復帰必要性判定手段によって肯と判定された場合に、前記対象情報をその管理情報に基づいて前記指定された領域に書き込み、前記対象情報の復帰を行う復帰手段(122、S560)とを備えること、を特徴とするICカード(10)である。
【0017】
請求項7の発明は、請求項1から請求項6までのいずれか1項に記載のICカードにおいて、前記退避領域有効性判定手段及び/又は前記復帰必要性判定手段は、前記有効性情報及び前記対象情報に対応する前記書き込み正否情報に基づいて判定を行う(S400、S520)こと、を特徴とするICカードである。
【0018】
請求項8の発明は、請求項1から請求項7までのいずれか1項に記載のICカードにおいて、前記書き換え可能な記憶手段は、前記退避領域が初期化済みか否かを示す初期化情報を記憶すること、を特徴とするICカード(10)である。
【0019】
請求項9の発明は、書き換え可能な記憶手段(15)を備えるICカード(10)のCPU(12)に、書き込み要求があった場合(S300)に、前記書き換え可能な記憶手段の指定された領域に指定された情報を頁単位で書き込む指定情報書き込み手順(S360)を実行させるICカードプログラムであって、前記書き込み要求があった場合に、前記指定された領域とは別の領域である退避領域に、前記指定された領域に記憶されている対象情報と、この対象情報の管理情報とを続けて頁単位で書き込む退避領域書き込み手順(S350)と、前記書き込み要求があった場合に、前記有効性情報に基づいて前記退避領域に有効な対象情報が記憶されているか否かを判定する退避領域有効性判定手順(S310,S380)を備え、前記指定情報書き込み手順は、前記退避領域書き込み手順の後に実行され、前記退避領域書き込み手順は、前記退避領域有効性判定手順において肯と判定した場合に、前記退避領域において前記有効な対象情報及びその管理情報の頁の後に前記書き込み要求に応じて対象情報及び管理情報の頁を書き込むこと、を特徴とするICカードプログラムである。
【0020】
請求項10の発明は、請求項9に記載のICカードプログラムにおいて、前記退避領域書き込み手順は、前記対象情報と、前記指定された領域の位置を示す退避元位置情報及び/又は前記対象情報の情報量を含む管理情報とを続けて前記退避領域へ書き込むこと、を特徴とするICカードプログラムである。
【0021】
請求項11の発明は、請求項9又は請求項10に記載のICカードプログラムにおいて、前記退避領域書き込み手順は、前記対象情報と、前記対象情報、又は、前記対象情報及び前記管理情報が前記退避領域書き込み手順において正常に退避領域に書き込まれたか否かを示す書き込み正否情報を含む管理情報とを続けて前記退避領域へ書き込むこと、を特徴とするICカードプログラムである。
【0022】
請求項12の発明は、請求項9から請求項11までのいずれか1項に記載のICカードプログラムにおいて、前記退避領域有効性判定手順において肯と判定した場合に、前記有効な対象情報及び管理情報の頁に前記書き込み要求に応じて対象情報及び管理情報を書き込む空き領域があるか否かを判定する空き領域判定手順を備え、前記退避領域書き込み手順は、前記空き領域判定手順において否と判定した場合に、前記有効な対象情報及び管理情報の頁の後に前記書き込み要求に応じて対象情報及び管理情報の頁を書き込み、前記空き領域判定手順において肯と判定した場合に、前記書き込み要求に応じて対象情報及び管理情報を前記空き領域に書き込むこと、を特徴とするICカードプログラムである。
【0023】
請求項13の発明は、請求項9から請求項12までのいずれか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]
BACKGROUND OF THE INVENTION
The present invention relates to an IC card and an IC card program that perform a return to a state before writing when there is an error in writing to a 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 non-volatile read-only memory, and can be used by applications by managing hardware such as basic software such as an operating system (hereinafter referred to as “OS”), programs such as execution environment, and parameters. A program and data to be stored are stored. The nonvolatile memory is a rewritable nonvolatile memory such as an EEPROM, a flash memory, or an FRAM, and is normally used as a user work area, a program area, or the like. Note that the IC card refers to a portable information processing apparatus that includes at least a CPU such as a SIM card or an IC tag, an external communication unit, and a storage unit that stores information, regardless of the base material.
When using this IC card, 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 among the programs stored in the ROM and the nonvolatile memory. As a result, processing of the command is performed, processing such as writing new data to the nonvolatile memory, and the processing result is transmitted from the IC card to the external device as a response (see, for example, Patent Document 1).
[0003]
[Patent Document 1]
Japanese Patent Laid-Open No. 10-40350 (page 3, FIG. 1)
[0004]
[Problems to be solved by the invention]
Since the IC card is supplied with power for processing from an external device, there is a risk that power supply may be interrupted while data is being written 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 relative position with respect to the external device is not fixed during communication, so the interruption of power supply (hereinafter referred to as “power-off”) .) Is likely to occur. Therefore, in such a case, the IC card performs a write guarantee process to return to the state before data writing, that is, to return.
[0005]
FIG. 10 is a memory structure diagram of the nonvolatile memory 15-2 for explaining the write guarantee processing. The write guarantee when data B is newly written in the area where the data A is stored in the nonvolatile memory 15-2 will be described. FIG. 10A shows a case where the writing is normally performed, and FIG. 10B shows a case where the writing is not performed normally due to a writing error such as a power-off during the processing. Yes.
As shown in FIG. 10A, the non-volatile memory 15-2 is an area in which new data is written, and data such as data A and programs such as application programs are recorded in the data area 15d-2. And a save area 15s-2 for storing a backup of data to be erased by writing to the data area 15d-2.
[0006]
As shown in # 101 of FIG. 10, first, the CPU saves (writes) data A in the save area 15s-2. Next, data B is written into an area where data A in the data area 15d-2 is stored, data A is rewritten to data B (# 102), and finally data A in the save area 15s-2 is cleared (erased). (# 103).
If the power is cut off while data A is being written to the save area 15s-2 (# 101), the data saved in the save area 15s-2 is invalid (invalid) as shown in FIG. 10 (b1). However, data A remains in the data area 15d-2. Further, when the power is cut off during the rewriting of data A to data B (# 102), as shown in FIG. 10 (b2), data A remains in the save area 15s-2. The data A can be restored by writing it in the data area 15d-2 [# 104, FIG. 10 (b3)]. Further, even if the power is interrupted during the restoration, since the data A remains in the save area 15s-2 [FIG. 10 (b4)], the restoration is possible in the same manner [# 105, FIG. b3)]. Therefore, when the power supply is interrupted while data is being written to the nonvolatile memory 15-2, the data is restored to the original state by the write guarantee and the data is written again.
[0007]
On the other hand, the process of writing data to the non-volatile memory 15-2 takes a specific time compared to other processes such as a process of reading data and programs from the non-volatile memory 15-2. It has been broken. The page unit means a set of data of a predetermined amount, and for example, 64 bytes of data is used as a unit of processing. When one page is n bytes and the same page, the time required for the 1-byte writing process and the n-byte writing process is almost the same because the number of times of writing is one. On the other hand, even if 2 bytes are written, if the pages are different, the number of times of writing is different, so that it takes about twice the processing time compared to writing 2 bytes on the same page.
[0008]
FIG. 11 is a diagram for explaining a write guarantee process in writing in page units. A process of saving data from the data area 15d-2 to the save area 15s-2 (# 101 in FIG. 10) will be described.
As shown in FIG. 11, when the data of page number K is rewritten, the data of page number K is copied as it is in the save area 15s-2 (# 111), and the information stored in the save area 15s-2 is stored. The page number K and the like are written in the control information area 15c-2 indicating the attributes such as the original position of the information stored in the save area 15s-2, which is information for control (# 112). Similarly, when data over two pages of page number N and page number N + 1 is rewritten, the data of all two pages of page number N and page number N + 1 are duplicated (# 113, # 114). The page number is written in the area 15c-2 (# 115).
[0009]
Accordingly, when saving one page of data, writing twice is required, and when saving two pages of data, writing three times is required. In other words, at least two write operations are required only for the saving process, which causes a longer processing time and increases the probability that a power interruption will occur. In addition, if the power is cut off during writing, it must be written again after returning to the original state. Therefore, it takes more time for processing than when only writing is performed. There has been a strong demand for speeding up the writing process, in particular, speeding up the writing process that takes time.
[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 problems by the following means. In addition, in order to make an understanding easy, although the code | symbol corresponding to embodiment of this invention is attached | subjected and demonstrated, it is not limited to this. That is, the invention according to claim 1 is the rewritable storage means (15) and the designation information for writing the designated information in the designated area of the rewritable storage means when there is a write request. An IC card having writing means (122, S360), and when the write request is made (S300), the designated area is stored in a save area (15s) that is an area different from the designated area. Save area writing means (122, S350) for continuously writing the target information stored in the area and the management information of the target information in units of pages.When the write request is made, the save area validity information indicating whether valid target information is stored in the save area and / or the target information stored in the save area is valid. Save area validity determination means (121, 121) for determining whether valid target information is stored in the save area based on validity information including attribute-specific validity information indicating whether or not S310, S380)The specified information writing means writes the specified information after the writing by the save area writing means.And the rewritable storage means stores the validity information, and the save area writing means determines the valid target information in the save area when the save area validity determination means determines affirmative. In addition, the IC card (10) is characterized in that a page of object information and management information is written in response to the write request after a page of management information.
[0012]
According to a second aspect of the present invention, in the IC card according to the first aspect, the save area writing means includes the target information, save source position information indicating a position of the designated area, and / or information of the target information. The IC card (10) is characterized in that the management information including the 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 includes the target information and the target information, or the target information and the management information are transmitted by the save area writing unit. The IC card (10) is characterized in that management information including write correct / incorrect information indicating whether or not data has been normally written to the save area is continuously written to the save area.
[0014]
  According to a fourth aspect of the present invention, in the IC card according to the first aspect, the rewritable storage means stores the evacuation area validity information at a position that is first accessed in the evacuation area. IC card (10).
[0015]
  According to a fifth aspect of the present invention, in the IC card according to the first aspect, when the saving area validity determining means determines affirmative, the page of the effective target information and management information is responded to the write request. Free space determining means (121) for determining whether or not there is a free area to which the target information and management information are written is provided, and when the save area writing means determines NO, the effective area writing means If the page of the target information and management information is written in response to the write request after the page of the target information and management information is determined to be affirmative by the free area determination unit, the target information and management is updated in response to the write request. An IC card (10) characterized in that information is written in the empty area.
[0016]
  According to a sixth aspect of the present invention, in the IC card according to any one of the first to first aspects, when there is a return necessity confirmation request (S500), the object stored in the save area When the return necessity determination means (S510, S550) for determining whether or not there is a need to return information is determined affirmative by the return necessity determination means (S510, S550) and the return necessity determination means, An IC card (10), comprising: return means (122, S560) for writing target information in the designated area based on the management information and returning the target information.
[0017]
  According to a seventh aspect of the present invention, in the IC card according to any one of the first to sixth aspects, the save area validity determining means and / or the return necessity determining means includes the validity information and The IC card is characterized in that a determination is made based on the write correct / incorrect information corresponding to the target information (S400, S520).
[0018]
  According to an eighth aspect of the present invention, in the IC card according to any one of the first to seventh aspects, the rewritable storage means includes initialization information indicating whether or not the save area has been initialized. Is an IC card (10) characterized in that
[0019]
  In the invention of claim 9, when there is a write request to the CPU (12) of the IC card (10) having the rewritable storage means (15), the rewritable storage means is designated. An IC card program for executing a designated information writing procedure (S360) for writing information designated in an area in units of pages, and when there is the write request, save is performed in an area different from the designated area. When there is a save area write procedure (S350) in which the target information stored in the specified area and the management information of the target information are continuously written to the area in units of pages, and the write request is received, A save area validity determination procedure (S310, S380) for determining whether valid target information is stored in the save area based on validity information; The fixed information writing procedure is executed after the save area writing procedure, and when the save area writing procedure is determined to be affirmative in the save area validity determining procedure, the effective target information and its management in the save area are determined. An IC card program that writes a page of object information and management information in response to the write request after a page of information.
[0020]
  According to a tenth aspect of the present invention, in the IC card program according to the ninth aspect, the save area writing procedure includes the target information, the save source position information indicating the position of the designated area, and / or the target information. An IC card program characterized by continuously writing management information including an amount of information into the save area.
[0021]
  According to an eleventh aspect of the present invention, in the IC card program according to the ninth or tenth aspect, the save area writing procedure includes: the target information and the target information, or the target information and the management information are saved. An IC card program characterized in that management information including write correct / incorrect information indicating whether or not data has been normally written in the save area in the area write procedure is written to the save area continuously.
[0022]
  According to a twelfth aspect of the present invention, in the IC card program according to any one of the ninth to eleventh aspects, the effective target information and management are determined when it is determined affirmative in the evacuation area validity determination procedure. A free area determination procedure for determining whether or not there is a free area for writing the target information and management information in response to the write request, and the save area write procedure is determined to be negative in the free area determination procedure; If the page of the target information and management information is written in response to the write request after the page of the valid target information and management information, and if it is determined affirmative in the free space determination procedure, And writing the target information and management information in the empty area.
[0023]
  The invention of claim 13 is the IC card program according to any one of claims 9 to 12, wherein when there is a return necessity confirmation request, the target information stored in the save area is stored. Based on the management information, when it is determined to be affirmative in the return necessity determination procedure (S510, S520, S550) for determining whether or not there is a necessity for return, and the return necessity determination procedure. And a return procedure (S560) for writing to the designated area and restoring the target information.
[0027]
DETAILED DESCRIPTION OF THE INVENTION
Hereinafter, embodiments of the present invention will be described in more detail with reference to the drawings.
(Embodiment)
FIG. 1 is a block diagram showing an embodiment of an IC card according to the present invention.
In addition, the same code | symbol is attached | subjected to the part which fulfill | performs the function similar to the prior art example mentioned above, and the overlapping description is abbreviate | omitted suitably.
As shown in FIG. 1, the IC card 10 includes an I / O interface 11, which is an interface such as an input / output circuit for realizing communication with the external device 20, a CPU 12, a RAM 13, a ROM 14, a nonvolatile memory 15, and the like. ing.
The CPU 12 executes a program according to a command received from the external device 20 by performing overall control of the IC card 10 by executing a program such as an OS or an application stored in the ROM 14, the nonvolatile memory 15 or the like. The unit 121, the writing unit 122, the rewriting unit 123, the save information generation unit 124, and the like are realized, and the processing result is transmitted as a response to the external device 20. The function of each part will be described later with reference to FIGS. 4, 5, and 7.
The information storage area of the nonvolatile memory 15 is allocated to the data area 15d, the save area 15s, and the like.
[0028]
FIG. 2 is a diagram illustrating a memory structure of the save area 15s.
As shown in FIG. 2, the save area 15s stores data presence / absence information, initialization information, transaction number, save information (# 21), and the like. These pieces of information are written by the writing unit 122 in units of pages. The data presence / absence information is save area validity information indicating whether or not valid save information is stored in the save area 15s, and a position where the save information starts to be written to the save area 15s and reading information from the save area 15s starts. It is stored in the position, that is, the position where the CPU 12 first accesses. In the present embodiment, it is stored in the first page of the save area 15s.
[0029]
The initialization information is information indicating whether or not the save area 15s has been initialized, and is stored in the last page (# 22) in order to efficiently use the save area 15s. As shown in FIG. 3, when the save area 15s is initialized, the data presence / absence information is “no data”, all the transaction numbers are “0”, and the initialization information is “initialized”. Is not stored. The initialization may be performed at least once before the use of the IC card 10 such as a card issuing stage.
[0030]
As shown in FIG. 2 and FIG. 3, the transaction number is stored in the save area 15s at approximately page unit intervals (page unit intervals except for the first page), and the corresponding save information written subsequently is This is attribute information indicating whether data has been written to the save area 15s in the processing stage (transaction). In other words, one or a plurality of write processes (included in the process performed in response to one command) from when the command is received until the data presence / absence information is rewritten from “data present” to “data not present” by a commit process or the like. One or a plurality of write processes) are managed as one processing stage, and the save information written in the write process is managed by linking the same transaction number. The transaction number is incremented (added) every time the processing stage changes, and is reset to “0” when it reaches a predetermined maximum value. Accordingly, the transaction number is attribute validity information indicating whether the corresponding save information is written in a valid or old invalid processing stage, that is, whether the target information is valid or not by its attribute. .
[0031]
Note that the CPU 12 desirably initializes the save area 15s when the transaction number is reset. This is to prevent the transaction number from going around and attaching the same transaction number to the save information of the previous processing stage and the new processing stage. The commit process and the write (write request) process are processes performed when there is a predetermined request (Commit, Write), that is, when there is a predetermined call from a program executed by the CPU 12. The processing contents will be described later with reference to FIGS. Furthermore, the effective save information is useful save information such as a role as a backup, and becomes invalid save information when the role is lost.
[0032]
As shown in FIG. 2, the save information is information generated by the save information generation unit 124, and when there is a write request, the save information stored in the specified area of the data area 15d The data that is the target information and the management information are successively written in the save area 15s. Note that “continuously written” may be a case where target information or management information is divided and a part thereof is continuously written, as indicated by # 21 in FIG. The management information is information for managing saved data such as an address, a data length, and a check code. The address is the start address in the save source data area 15d of the saved data, that is, save source position information indicating the position of the area specified by the write request, and the data length is the information amount of the saved data. The check code is write correct / incorrect information indicating whether or not the save information data has been normally written in the save area 15s by collating with the save information, that is, the validity of the save information.
[0033]
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 process of the CPU 12 will be mainly described.
As shown in FIG. 4A, in step 110 (hereinafter, “step” is referred to as “S”), the IC card 10 is connected to the external device 20, receives supply of power and clock, and starts processing. To do. The IC card 10 receives a command from the external device 20 (S120), performs Rollback processing (see FIG. 7 described later) (S130), and then executes processing corresponding to the command (S140). The IC card 10 transmits the processing result as a response to the external device 20 (S150), enters the command waiting state again, and receives the next command until the connection with the external device 20 is disconnected. Is repeated (from S120 to S150).
[0034]
FIG. 4B is a diagram showing processing such as writing to the nonvolatile memory 15 in the processing (S140) performed in response to the command (S120) received by the IC card 10 in FIG. 4A. It is. Note that the IC card 10 is in an initialized state (see FIG. 3) in S100 of FIG. 4A, and a write request (Write) is performed in the process performed by the IC card 10 in response to the command received in S120. Shall be performed twice.
As shown in FIG. 4B, the IC card 10 performs a write process twice in response to the command (S210, S230). The write process is a process of writing the specified new data in the specified data area 15d. At this time, the data in the specified area is saved in the save area 15s (# 1 in FIG. 10A). , # 2). Details of the Write process will be described later with reference to FIG.
The IC card 10 performs a commit process when the two write processes are normally performed (S250). The commit process is a process of clearing the save area 15s, that is, invalidating the save information stored in the save area 15s, and details will be described later with reference to FIG.
[0035]
On the other hand, the IC card 10 performs the Rollback process when an error occurs during any Write process (S220, S240), such as when writing to the save area 15s or the data area 15d is not normally performed. (S260) and the execution of the process corresponding to the command is terminated (S270). The rollback process is a process of restoring and then clearing the save area 15s when there is save information to be restored in the save area 15s, and details thereof will be described later with reference to FIG.
[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 save area 15s of the nonvolatile memory 15 in the process of FIG.
First, the first Write process [S210 in FIG. 4B] will be described.
In S300, there is a write request, and the CPU 12 starts processing, and the determination unit 121 determines whether valid save information is stored in the save area 15s based on the data presence / absence information (S310). Since the IC card 10 is in an initialized state (see FIG. 3), the IC card 10 determines NO, and the rewrite unit 123 rewrites “data present” (S320). The rewriting unit 123 increments the transaction number of the first page (first) and rewrites from “0” to “1” (S330). The save information generation unit 124 generates save information on the RAM 13 (S340), and the writing unit 122 continuously writes the data included in the generated save information and its management information [S350, FIG. a)]. When the series of processing ends normally, the writing unit 122 writes new data to the designated area of the data area 15d (S360), and ends the processing (S410).
[0037]
Next, the second Write process [S230 in FIG. 4B] will be described.
In S310, the determination unit 121 of the IC card 10 determines that there is data [# 61 in FIG. 6A], and compares the transaction number of the first page with the transaction number of the next page (S370). If they are the same, the determination unit 121 determines the validity of the save information based on the check code of the page (next page) (S400). If it is determined that it is correct, the CPU 12 performs the same processing for the next page (the page next to the “next page”) (S370, S380). If it is determined NO in S400, the process proceeds to S340. If it is determined in S380 that the transaction number of the next page is different from the first page, the rewriting unit 123 rewrites the transaction number of the next page to be the same as the transaction number of the first page (S390).
[0038]
If the save information does not fit on one page, the rewrite unit 123 rewrites all the transaction numbers of the page on which the save information is to be written to the same as the first page. In the present embodiment, the rewriting unit 123 rewrites the transaction numbers of the two pages [# 62 in FIG. 6B]. The save information generation unit 124 generates save information (S340), and the writing unit 122 sets the generated save information after the rewritten transaction number (S390) or a page of save information determined to be invalid. In other words, the target information and the management information are successively written in two pages after the page of valid save information (S400) [S350, FIG. 6 (b)]. The writing unit 122 writes new data to the designated area of the data area 15d (S360), and ends the process (S410).
[0039]
When these two write processes are normally performed, the IC card 10 performs the commit process and clears the save area 15s [S250 in FIG. 4B]. That is, the rewriting unit 123 rewrites the data presence / absence information to “no data” [# 63 in FIG. 6C].
After the commit process is completed in S250 of FIG. 4B, when the IC card 10 receives the next command and performs the write process in S120 of FIG. 4A, the IC card 10 performs processing similar to the second Write processing from S300 to S390 in FIG. 5, increments the transaction number to “2”, and writes the save information. The saved area 15s after processing is in the state shown in FIG. The save information of the page with the transaction number “1” is old invalid save information written in the previous processing stage.
[0040]
FIG. 7 is a flowchart showing Rollback processing performed by the IC card 10. The IC card 10 performs Rollback processing according to the following rules.
(1) Processing is performed when the data presence / absence information is “data present”, that is, when valid save information is stored in the save area 15s.
(2) Restore save information (target information) corresponding to the same transaction number as the transaction number of the first page, that is, save information written in the same processing stage as the valid save information of the first page written most recently (Recovery target information).
(3) The save information with the correct check code is set as the return target, that is, the save information normally written in the save area 15s is set as the return target information.
(4) First-in / last-out, that is, return from the save information (recovery target information) written in the save area 15s later.
(5) The data presence / absence information is rewritten as “no data” after the restoration of all the restoration target information is completed, that is, the writing of the restoration target information to the data area 15d is completed.
As long as the effective save information (recovery target information) to be restored can be returned to the save source location (specified area) and restored, such as processing according to the above rules, the Rollback processing procedure is not limited. 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 IC card 10 starts the Rollback process. In S510, the determination unit 121 determines whether valid save information is stored in the save area 15s based on the data presence / absence information (S510). If the determination is NO, the IC card 10 ends the Rollback process (S580). If it is determined as affirmative, the determination unit 121 determines the validity of the save information on the first page based on the check code (S520). If it is determined to be illegal, the process proceeds to S560. If it is determined that it is correct, the CPU 12 determines that the save information is information to be returned (recovery target information) (S530).
[0042]
The determination unit 121 compares the transaction number of the first page with the transaction number of the next page (S540) and determines whether or not they are the same (S550). If they are the same, the IC card 10 similarly performs processing for the next page (next page of “next page”) (S540 to S570). When the determination unit 121 determines that the transaction number of the next page is different from the transaction number of the first page (S550), the writing unit 122 stores data for all save information determined as the return target information in S530. Based on the management information, data is written to the data area 15d and data is restored (S560). Note that the writing unit 122 restores data in the order of the saving information of the subsequent page to the saving information of the first page. When the data restoration ends normally, the rewrite unit 123 rewrites the data presence / absence information to “no data” (S570), and the IC card 10 ends the Rollback process (S580).
[0043]
FIG. 8A is a diagram showing a memory structure of the save area 15s when the power failure occurs immediately before the IC card 10 performs the commit process [S250 in FIG. 4B]. When power is again supplied to the IC card 10 [S110 in FIG. 4A], the IC card 10 performs Rollback [S130 in FIG. 4A]. As shown in FIG. 7, the IC card 10 makes a determination based on data presence / absence information, a check code, a transaction number, and the like (S510, S520, S550), and the page whose transaction number is “2” that is the same as the first page. Evacuation information [# 81 in FIG. 8A] is determined to be restoration target information (S530), and the data area 15d is restored (S560).
[0044]
FIG. 8B is a diagram showing the structure of the save area 15s when a power interruption occurs while saving information is being written to the save area 15s (S350 in FIG. 5). When power is supplied again to the IC card 10 [S110 in FIG. 4A], the IC card 10 performs Rollback [S130 in FIG. 4A]. As shown in FIG. 7, the IC card 10 performs processing, determines that the save information of the second and third pages is incomplete based on the check code (S520), and only save information of the first page [FIG. The dotted line (b)] is determined as the return target information (S530), and the return is performed (S580).
[0045]
According to the present embodiment, the IC card 10 continuously writes the data that is the target information to the save area 15s of the nonvolatile memory 15 and the management information including the address, data length, and check code in units of pages. The writing guarantee by the rapid writing in the case became possible. Also, as shown in FIG. 11, when there is a write request for designating areas (vertical lines) of page numbers N and N + 1, the data stored in the designated area and the management information are continued. Thus, since the save information is written to the save area 15s as the save information of one page or two pages, the number of times of writing becomes one or two times, and the number of times of writing can be reduced as compared with the case where the management information is written in another area (three times). This makes it possible to further speed up the processing.
[0046]
Further, by writing management information including the data length in the save area 15s after the target information, it is possible to clarify the area in which the target information is written in each page of the save area 15s. Furthermore, by clarifying the information amount of the target information and the management information, it is possible to grasp the information amount of the empty area for each page. Furthermore, by writing the check code in the save area 15s, even if there is an error in the process of writing the target information in the save area 15s, it is possible to easily detect it.
[0047]
Further, by determining whether valid target information is stored in the save area 15s, the position where the target information is written is clarified, and in particular, the determination is performed based on the data presence / absence information and the transaction number. This makes it possible to facilitate the processing. Further, by storing the data presence / absence information on the first page (first accessed position) of the save area 15s, the determination can be further facilitated.
Further, 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 save area 15s is made flexible and efficient. Can be processed.
[0048]
Furthermore, by determining the necessity of restoring the target information based on the data presence / absence information and the transaction number, it is possible to facilitate the determination and speed up the processing.
Also, by determining the validity of the target information and the necessity of the return of the target information based on the check code, it is possible to realize accurate determination and reliably perform writing guarantee.
Further, by storing the initialization information, it is possible to perform initialization at an arbitrary timing, and it is possible to improve convenience.
[0049]
(Deformation)
The present invention is not limited to the embodiment described above, and various modifications and changes are possible, and these are also within the equivalent scope of the present invention. For example, the IC card 10 and the external device 20 may perform communication using either a contact type or a non-contact type, and the communication method is not limited. Further, the IC card 10 guarantees writing for the data stored in the data area 15d, but when the program stored in the data area 15d is erased, such as when the application program is rewritten, Write guarantee may be performed for the program, and the type of information stored in the target data area 15d is not limited.
[0050]
In the write process, the IC card 10 writes to a page having a transaction number different from the first page (S370, S380, S350, etc. in FIG. 5), as shown in FIGS. 9A and 9B. Based on the data length or the like, whether or not the page having the same transaction number (valid save information page) has a capacity for writing the save information generated by the save information generation unit 124 in the empty area (# 91). If the determination unit 121 determines that the determination is affirmative, the writing unit 122 may write the save information in this empty area (# 92).
The check code is write correct / incorrect information indicating the validity of the save information, but may also indicate the validity of the transaction number (a transaction number of a plurality of pages when the save information extends over a plurality of pages) [ # 94 in FIG. 9C. In FIG. 9C, the save information is written in the free area [FIG. 9B], the commit process is performed [S250 in FIG. 4B], and the received new command process [FIG. a) S140], that is, the memory structure of the save area 15s when the save information having the same data length is written (# 93) in the next processing stage. In such a case, if the check code indicates only whether the save information is correct or not, the save information (# 92) written in the previous processing stage may be regarded as valid based on the transaction number. When the check code indicates the validity of the transaction number (# 94), since the transaction number has been rewritten from “1” to “2”, the transaction number is regarded as invalid, and the previous processing stage It is possible to prevent invalid save information (# 92) from being restored.
[0051]
In the IC card 10, when the storage area of one rewritable nonvolatile memory (nonvolatile memory 15) is allocated to the data area 15d and the save area 15s, the IC card 10 includes two or more rewritable nonvolatile memories. May allocate the data area 15d and the save area 15s to different non-volatile memories, respectively. As long as the data area 15d for storing the target information and the save area 15s for storing the save information can be managed as separate areas, there is no limitation on which nonvolatile memory is stored.
[0052]
After receiving the command [S130 in FIG. 4 (a)], if there is an error in the Write process [S260 in FIG. 4 (b)], the IC card performs the Rollback process (FIG. 7). If the Rollback process is performed at least once before the Write process is performed after power is supplied from the power source 20 (S110 in FIG. 4A), the timing for performing the process is not limited.
[0053]
Similarly to the Rollback process, the Write process generates save information from the target information stored in the specified area of the data area 15d, and rewrites the transaction number if it is rewritten to an appropriate transaction number (see FIG. 5 (S390), before and after processing such as generation of save information (S340), that is, the processing procedure of Write is not limited.
[0054]
The program that causes the CPU 12 to execute the write process, the rollback process, and the commit process may be included in the operating system, may be included in the application program, or any of the programs stored in the IC card 10. Whether it is included in the program is not limited.
[0055]
The nonvolatile memory 15 stores and stores data presence / absence information on the first page of the save area 15s. However, when the CPU 12 accesses from the last page of the save area 15s, it may be stored on the last page. It suffices if it is stored at the location accessed first.
[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 continuously written in the save area in units of pages, and writing is guaranteed by rapid writing in units of pages, and control information (management information) is separated. By reducing the number of times of writing as compared with the case of writing in this area, the processing is further accelerated.
(2) By writing management information including the information amount of the target information in the save area following the target information, the area in which 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 management information, the information amount of the free area for each page is clarified, and the target information and management information are written in the free area. Store on one page and use the save area effectively.
(3) Writing correct / incorrect information such as a check code in the save area enables easy detection even when there is an error in the process of writing the target information in the save area.
(4) The position where the target information is written is clarified by determining whether valid target information is stored in the save area. In particular, the determination is made based on the validity information, thereby facilitating the determination and speeding up the processing. Further, by storing the save area validity information at the position accessed first in the save area, the determination is further facilitated.
(5) For example, processing procedure for target information written in the save area by storing validity information for each attribute such as a transaction number and differentiating the validity for each attribute (processing stage) of the target information Is flexible and enables efficient processing.
(6) By determining the necessity of restoring the target information based on the validity information, the determination is facilitated and the processing is speeded up.
(7) Based on the correctness suggestion information, by determining the validity of the target information, or the validity of the target information and management information, and the necessity for the return of the target information, an accurate determination is realized, and writing is guaranteed reliably. .
(8) By storing initialization information, initialization can be performed at an arbitrary timing to improve convenience.
[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 illustrating a memory structure of a save area 15s.
FIG. 3 is a memory structure diagram showing an initialized state of a save area 15s.
FIG. 4 is a flowchart showing the operation of the IC card according to the present invention and the IC card program according to the present invention.
FIG. 5 is a flowchart showing the operation of the IC card according to the present invention and the IC card program according to the present invention.
FIG. 6 is a diagram illustrating a change in a save area 15s in a write process.
FIG. 7 is a flowchart showing the operation of the IC card according to the present invention and the IC card program according to the present invention.
FIG. 8 is a memory structure diagram of a save area 15s when a power failure occurs in the IC card 10.
FIG. 9 is a diagram showing a structure of a save area 15s in a modified form of the IC card and the IC card program according to the present invention.
FIG. 10 is a memory structure diagram of an EEPROM 15-2 for explaining a write guarantee process by a conventional IC card.
FIG. 11 is a memory structure diagram of an EEPROM 15-2 for explaining a write guarantee process in units of pages by a conventional IC card.
[Explanation of symbols]
10 IC card
11 I / O interface
12 CPU
13 RAM
14 ROM
15 Nonvolatile memory
15d data area
15s evacuation area
20 External devices
121 determination unit
122 Writing unit
123 Rewriting part
124 evacuation information generation unit

Claims (13)

書き換え可能な記憶手段と、書き込み要求があった場合に、前記書き換え可能な記憶手段の指定された領域に指定された情報を頁単位で書き込む指定情報書き込み手段とを備えるICカードであって、
前記書き込み要求があった場合に、前記指定された領域とは別の領域である退避領域に、前記指定された領域に記憶されている対象情報と、この対象情報の管理情報とを続けて頁単位で書き込む退避領域書き込み手段と、
前記書き込み要求があった場合に、前記退避領域に有効な対象情報を記憶しているか否かを示す退避領域有効性情報、及び/又は、前記退避領域に記憶されている対象情報が有効であるか否かをその属性によって示す属性別有効性情報を含む有効性情報に基づいて前記退避領域に有効な対象情報が記憶されているか否かを判定する退避領域有効性判定手段を備え、
前記指定情報書き込み手段は、前記退避領域書き込み手段による書き込みの後に前記指定された情報の書き込みを行い、
前記書き換え可能な記憶手段は、前記有効性情報を記憶し、
前記退避領域書き込み手段は、前記退避領域有効性判定手段によって肯と判定された場合に、前記退避領域において前記有効な対象情報及びその管理情報の頁の後に前記書き込み要求に応じて対象情報及び管理情報の頁を書き込むこと、
を特徴とするICカード。
An IC card comprising rewritable storage means and designated information writing means for writing, in a page unit, information designated in a designated area of the rewritable storage means when there is a write request,
When there is a write request, the target information stored in the specified area and the management information of the target information are continuously stored in a save area that is different from the specified area. Save area writing means for writing in units ;
When there is a write request, save area validity information indicating whether valid target information is stored in the save area and / or target information stored in the save area is valid. A save area validity determining means for determining whether valid target information is stored in the save area based on validity information including attribute-specific validity information indicating whether or not by attribute;
The specified information writing means writes the specified information after writing by the save area writing means ,
The rewritable storage means stores the validity information,
The save area writing means, when the save area validity determining means determines affirmative, the target information and management in response to the write request after the page of the valid target information and its management information in the save area Writing a page of information,
IC card characterized by
請求項1に記載のICカードにおいて、
前記退避領域書き込み手段は、前記対象情報と、前記指定された領域の位置を示す退避元位置情報及び/又は前記対象情報の情報量を含む管理情報とを続けて前記退避領域へ書き込むこと、
を特徴とするICカード。
In the IC card according to claim 1,
The save area writing means continuously writes the target information and save source position information indicating the position of the designated area and / or management information including the information amount of the target information to the save area,
IC card characterized by
請求項1又は請求項2に記載のICカードにおいて、
前記退避領域書き込み手段は、前記対象情報と、前記対象情報、又は、前記対象情報及び前記管理情報が前記退避領域書き込み手段によって正常に退避領域に書き込まれたか否かを示す書き込み正否情報を含む管理情報とを続けて前記退避領域へ書き込むこと、
を特徴とするICカード。
In the IC card according to claim 1 or 2,
The save area writing means includes management information including the target information and write correct / incorrect information indicating whether the target information or the target information and the management information have been normally written to the save area by the save area writing means. Continuously writing information to the save area;
IC card characterized by
請求項1に記載のICカードにおいて、In the IC card according to claim 1,
前記書き換え可能な記憶手段は、前記退避領域において最初にアクセスされる位置に前記退避領域有効性情報を記憶すること、The rewritable storage means stores the evacuation area validity information at a position accessed first in the evacuation area;
を特徴とするICカード。IC card characterized by
請求項1に記載のICカードにおいて、In the IC card according to claim 1,
前記退避領域有効性判定手段によって肯と判定された場合に、前記有効な対象情報及び管理情報の頁に前記書き込み要求に応じて対象情報及び管理情報を書き込む空き領域があるか否かを判定する空き領域判定手段を備え、If the saving area validity determining means determines affirmative, it is determined whether or not there is a free area in which the target information and management information is written in response to the write request on the page of the valid target information and management information. With free space determination means,
前記退避領域書き込み手段は、前記空き領域判定手段によって否と判定された場合に、前記有効な対象情報及び管理情報の頁の後に前記書き込み要求に応じて対象情報及び管理情報の頁を書き込み、前記空き領域判定手段によって肯と判定された場合に、前記書き込み要求に応じて対象情報及び管理情報を前記空き領域に書き込むこと、The save area writing means writes a page of the target information and management information in response to the write request after the valid target information and management information page when the empty area determination means determines NO, Writing the target information and management information in the free space in response to the write request when the free space determining means determines positive,
を特徴とするICカード。IC card characterized by
請求項1から請求項5までのいずれか1項に記載のICカードにおいて、In the IC card according to any one of claims 1 to 5,
復帰必要性確認要求があった場合に、前記退避領域に記憶されている対象情報の復帰をWhen there is a return necessity confirmation request, the target information stored in the save area is restored. 行う必要性があるか否かを前記有効性情報に基づいて判定する復帰必要性判定手段と、Return necessity determination means for determining whether or not there is a need to perform based on the validity information;
前記復帰必要性判定手段によって肯と判定された場合に、前記対象情報をその管理情報に基づいて前記指定された領域に書き込み、前記対象情報の復帰を行う復帰手段とを備えること、A recovery means for writing the target information in the designated area based on the management information when the return necessity determination means determines affirmative, and for returning the target information;
を特徴とするICカード。IC card characterized by
請求項1から請求項6までのいずれか1項に記載のICカードにおいて、In the IC card according to any one of claims 1 to 6,
前記退避領域有効性判定手段及び/又は前記復帰必要性判定手段は、前記有効性情報及び前記対象情報に対応する前記書き込み正否情報に基づいて判定を行うこと、The save area validity determination unit and / or the return necessity determination unit performs determination based on the validity information and the write correct / incorrect information corresponding to the target information;
を特徴とするICカード。IC card characterized by
請求項1から請求項7までのいずれか1項に記載のICカードにおいて、In the IC card according to any one of claims 1 to 7,
前記書き換え可能な記憶手段は、前記退避領域が初期化済みか否かを示す初期化情報を記憶すること、The rewritable storage means stores initialization information indicating whether or not the save area has been initialized;
を特徴とするICカード。IC card characterized by
書き換え可能な記憶手段を備えるICカードのCPUに、書き込み要求があった場合に、前記書き換え可能な記憶手段の指定された領域に指定された情報を頁単位で書き込む指定情報書き込み手順を実行させるICカードプログラムであって、An IC for executing a specified information writing procedure for writing, in a page unit, specified information in a specified area of the rewritable storage means when the CPU of the IC card having the rewritable storage means has a write request. A card program,
前記書き込み要求があった場合に、前記指定された領域とは別の領域である退避領域に、前記指定された領域に記憶されている対象情報と、この対象情報の管理情報とを続けて頁単位で書き込む退避領域書き込み手順と、When there is a write request, the target information stored in the specified area and the management information of the target information are continuously stored in a save area that is different from the specified area. Save area write procedure to write by unit,
前記書き込み要求があった場合に、前記有効性情報に基づいて前記退避領域に有効な対象情報が記憶されているか否かを判定する退避領域有効性判定手順を備え、A save area validity determination procedure for determining whether valid target information is stored in the save area based on the validity information when there is a write request;
前記指定情報書き込み手順は、前記退避領域書き込み手順の後に実行され、The specified information writing procedure is executed after the save area writing procedure,
前記退避領域書き込み手順は、前記退避領域有効性判定手順において肯と判定した場合に、前記退避領域において前記有効な対象情報及びその管理情報の頁の後に前記書き込み要求に応じて対象情報及び管理情報の頁を書き込むこと、In the save area writing procedure, if it is determined to be affirmative in the save area validity determination procedure, the target information and management information according to the write request after the page of the valid target information and its management information in the save area Writing the page of
を特徴とするICカードプログラム。IC card program characterized by this.
請求項9に記載のICカードプログラムにおいて、The IC card program according to claim 9, wherein
前記退避領域書き込み手順は、前記対象情報と、前記指定された領域の位置を示す退避元位置情報及び/又は前記対象情報の情報量を含む管理情報とを続けて前記退避領域へ書き込むこと、The save area writing procedure continuously writes the target information and save source position information indicating the position of the designated area and / or management information including the information amount of the target information to the save area,
を特徴とするICカードプログラム。IC card program characterized by this.
請求項9又は請求項10に記載のICカードプログラムにおいて、In the IC card program according to claim 9 or 10,
前記退避領域書き込み手順は、前記対象情報と、前記対象情報、又は、前記対象情報及び前記管理情報が前記退避領域書き込み手順において正常に退避領域に書き込まれたか否かを示す書き込み正否情報を含む管理情報とを続けて前記退避領域へ書き込むこと、The save area writing procedure includes management information including the target information and the target information, or write correct / incorrect information indicating whether the target information and the management information are normally written in the save area in the save area writing procedure. Continuously writing information to the save area;
を特徴とするICカードプログラム。IC card program characterized by this.
請求項9から請求項11までのいずれか1項に記載のICカードプログラムにおいて、In the IC card program according to any one of claims 9 to 11,
前記退避領域有効性判定手順において肯と判定した場合に、前記有効な対象情報及び管理情報の頁に前記書き込み要求に応じて対象情報及び管理情報を書き込む空き領域があるか否かを判定する空き領域判定手順を備え、When it is determined to be affirmative in the save area validity determination procedure, it is determined whether or not there is a free area in which target information and management information are written in response to the write request in the page of the valid target information and management information. With an area determination procedure,
前記退避領域書き込み手順は、前記空き領域判定手順において否と判定した場合に、前記有効な対象情報及び管理情報の頁の後に前記書き込み要求に応じて対象情報及び管理情報の頁を書き込み、前記空き領域判定手順において肯と判定した場合に、前記書き込み要求に応じて対象情報及び管理情報を前記空き領域に書き込むこと、When the save area write procedure determines NO in the free area determination procedure, the page of the target information and management information is written in response to the write request after the valid target information and management information page, and the empty area is determined. When it is determined as affirmative in the area determination procedure, the target information and management information are written to the free area in response to the write request;
を特徴とするICカードプログラム。IC card program characterized by this.
請求項9から請求項12までのいずれか1項に記載のICカードプログラムにおいて、In the IC card program according to any one of claims 9 to 12,
復帰必要性確認要求があった場合に、前記退避領域に記憶されている対象情報の復帰を行う必要性があるか否かを判定する復帰必要性判定手順と、A return necessity determination procedure for determining whether or not there is a need to restore target information stored in the save area when there is a return necessity confirmation request;
前記復帰必要性判定手順において肯と判定した場合に、前記対象情報をその管理情報に基づいて前記指定された領域に書き込み、前記対象情報の復帰を行う復帰手順とを備えること、A recovery procedure for writing the target information in the designated area based on the management information and performing recovery of the target information when it is determined affirmative in the return necessity determination procedure;
を特徴とするICカードプログラム。IC card program characterized by this.
JP2003056563A 2003-03-04 2003-03-04 IC card and IC card program Expired - Fee Related JP4195822B2 (en)

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 JP2004265275A (en) 2004-09-24
JP4195822B2 true 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)

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP4701618B2 (en) * 2004-02-23 2011-06-15 ソニー株式会社 Information processing apparatus, information processing method, and computer program
JP4812278B2 (en) * 2004-10-18 2011-11-09 日産自動車株式会社 Data rewriting method for electronic control unit
JP5224800B2 (en) * 2007-12-21 2013-07-03 株式会社東芝 Information processing apparatus and data recovery 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
KR102002826B1 (en) * 2012-12-04 2019-07-23 삼성전자 주식회사 Storage device, flash memory and operating method for storage device

Also Published As

Publication number Publication date
JP2004265275A (en) 2004-09-24

Similar Documents

Publication Publication Date Title
CN103914393B (en) MCU-based (microprogrammed control unit-based) non-loss FLASH storage update method
AU676731B2 (en) Data writing to non-volatile memory
JP4037605B2 (en) Nonvolatile memory unit controller, memory system having the controller, and nonvolatile memory unit control method
JP5104653B2 (en) IC card and IC card program
CN101699476B (en) Data processing method and device of smart cards
CN109947594B (en) Data backup method and device and data recovery method and device
US20070011416A1 (en) Data storage device and medium and related method of storing backup data
CN101561950B (en) Method and device for processing data of intelligent card
JP4195822B2 (en) IC card and IC card program
JP2003216511A (en) Nonvolatile memory device, data update method, data update program, and computer-readable recording medium on which the program is recorded
CN100432926C (en) Method and apparatus for processing transactions in a data processing system
EP2102748B1 (en) System and method for recovery of memory transactions
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
JPH06309527A (en) IC card
JP7322923B2 (en) Secure element, transaction control method and device
US20040073744A1 (en) Method for the secure updating data areas in non volatile memory, device to perform such a method
US11150940B2 (en) System and method for recording transaction associated with a page-oriented non-volatile memory
US7346730B2 (en) Mobile electronic device
JP5092370B2 (en) Portable information recording medium and program thereof
JP4784138B2 (en) IC card and IC card program
JP6281302B2 (en) Information processing apparatus, IC card, and data processing method
JPH11161562A (en) Ic card and memory management method for ic card
JP2008134945A (en) Storage device, storage device program, and storage processing method

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