JPH0997218A - Method and device for managing flash rom and computer control equipment - Google Patents

Method and device for managing flash rom and computer control equipment

Info

Publication number
JPH0997218A
JPH0997218A JP25123895A JP25123895A JPH0997218A JP H0997218 A JPH0997218 A JP H0997218A JP 25123895 A JP25123895 A JP 25123895A JP 25123895 A JP25123895 A JP 25123895A JP H0997218 A JPH0997218 A JP H0997218A
Authority
JP
Japan
Prior art keywords
erase
sector
flash rom
data
block
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.)
Withdrawn
Application number
JP25123895A
Other languages
Japanese (ja)
Inventor
Takeshi Ogawa
武志 小川
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.)
Canon Inc
Original Assignee
Canon Inc
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 Canon Inc filed Critical Canon Inc
Priority to JP25123895A priority Critical patent/JPH0997218A/en
Priority to US08/710,946 priority patent/US5933847A/en
Publication of JPH0997218A publication Critical patent/JPH0997218A/en
Priority to US09/350,188 priority patent/US6604168B2/en
Withdrawn legal-status Critical Current

Links

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Read Only Memory (AREA)
  • Techniques For Improving Reliability Of Storages (AREA)
  • Memory System (AREA)

Abstract

PROBLEM TO BE SOLVED: To decrease dispersion in the number of times of erasure for every erasure unit concerning a managing system with which a flash ROM can be made adaptive to a filing system. SOLUTION: Plural sectors composed of data areas and managing areas corresponding to these data areas are formed in the flash ROM and state information (such as a sector number 154, occupied flag 155 and used flag 156) showing the storage states of respective sectors is stored in the managing areas so that the memory management of the flash ROM can be performed. When the instruction to start garbage collection processing is given for putting invalid data inside the flash ROM in order, while referring to an erasure time counter 152, the erase block of an erasure object is decided. When erasing processing is executed to the decided erase block of the erasure object, the erasure time counter 152 of the erase block is incremented by one.

Description

【発明の詳細な説明】Detailed Description of the Invention

【0001】[0001]

【発明の属する技術分野】本発明は、コンピュータ等に
おけるフラッシュROMの管理方法及び装置及びコンピ
ュータ制御装置に関する。
BACKGROUND OF THE INVENTION 1. Field of the Invention The present invention relates to a flash ROM management method and apparatus for a computer and the like, and a computer control apparatus.

【0002】[0002]

【従来の技術】フラッシュROMは現在いろいろなタイ
プのものがあるが大きく分けてフラッシュDISK用に
開発されたタイプとパーソナルコンピュータのBIOS
用に開発されたものがある。
2. Description of the Related Art Currently, there are various types of flash ROMs, which are roughly classified into a type developed for a flash disk and a BIOS of a personal computer.
There is one developed for.

【0003】前者は消去単位がハードディスクで一般的
な512バイトであり、ファイルシステムとの整合性が
非常に良い。後者のフラッシュROMは消去単位が例え
ば64Kなどといった大きなブロック単位でしか行えな
い様になっている。また、PROMの様に書き込み電圧
として12V等の電圧が必要なものもある。後者のフラ
ッシュROMの方が安価に入手できるがファイルシステ
ムとの整合性が悪い為に特に小容量の記録メディアとし
ては使う事が出来なかった。
In the former case, the erase unit is 512 bytes which is generally used in a hard disk, and the compatibility with the file system is very good. The latter flash ROM can be erased only in large block units such as 64K. Some PROMs require a voltage such as 12V as a write voltage. The latter flash ROM can be obtained at a lower cost, but it cannot be used as a particularly small-capacity recording medium due to its poor compatibility with the file system.

【0004】[0004]

【発明が解決しようとする課題】以上のように、BIO
S用に設計されたフラッシュROMは、その消去単位が
大きく、ファイルシステムとの整合性が悪いが、安価で
入手しやすい。従って、そのようなフラッシュROMを
ファイルシステムに適用できれば、安価な小容量の記録
メディアを提供することができる。
DISCLOSURE OF THE INVENTION Problems to be Solved by the Invention
The flash ROM designed for S has a large erasing unit and has poor compatibility with the file system, but is inexpensive and easily available. Therefore, if such a flash ROM can be applied to a file system, an inexpensive small-capacity recording medium can be provided.

【0005】本発明は、消去単位の大きいフラッシュR
OMをファイルシステムと適合させることを可能とする
フラッシュROM管理方法及び装置を提供するものであ
る。
According to the present invention, a flash R having a large erase unit is used.
A flash ROM management method and apparatus capable of adapting an OM with a file system.

【0006】ファイルシステムにより、フラッシュRO
Mに記憶されているデータの更新を行う場合、当該デー
タ領域へ新たなデータを上書きするか、当該データ領域
のデータを無効化して他のデータ領域へデータを書き込
むことが考えられる。フラッシュROMでは、データの
上書きができないので、他のデータ領域へのデータ書込
みを行う。この結果、無効データが蓄積され、フラッシ
ュROMの利用効率が低下する。よって、ファイルシス
テムと適合したフラッシュROMのアクセスを管理する
場合、フラッシュROM上の無効データを消去すること
が不可欠である。
The file system allows flash RO
When updating the data stored in M, it is conceivable to overwrite the data area with new data or invalidate the data in the data area and write the data to another data area. Since data cannot be overwritten in the flash ROM, data is written to other data areas. As a result, invalid data is accumulated and the utilization efficiency of the flash ROM decreases. Therefore, when managing access to the flash ROM compatible with the file system, it is essential to erase invalid data on the flash ROM.

【0007】以上のように、消去単位の大きいフラッシ
ュROMをファイルシステムに適用すべく管理する場
合、該消去単位における消去動作の実行が不可欠とな
る。しかしながら、このような消去動作の対象となる消
去単位の選択を、例えば消去単位中の無効データの多い
少ないのみに基づいて行うと、消去動作が行われる消去
単位に偏りが生じる。この偏りは、各消去単位の時間的
な寿命をばらつかせることになる。
As described above, when the flash ROM having a large erase unit is managed so as to be applied to the file system, it is indispensable to execute the erase operation in the erase unit. However, if the selection of the erase unit to be the target of such an erase operation is performed based on, for example, only a large amount of invalid data in the erase unit, the erase unit in which the erase operation is performed is biased. This imbalance causes the erasing units to have different temporal lives.

【0008】本発明は上記の問題に鑑みてなされたもの
であり、フラッシュROMをファイルシステムに適応さ
せることが可能な管理方式において、各消去単位毎の消
去回数のばらつきを減少させることが可能なフラッシュ
ROM管理方法及び装置及びコンピュータ制御装置を提
供することを目的とする。
The present invention has been made in view of the above problems, and in a management system capable of adapting a flash ROM to a file system, it is possible to reduce the variation in the number of erases for each erase unit. An object of the present invention is to provide a flash ROM management method and device and a computer control device.

【0009】[0009]

【課題を解決するための手段】上記の目的を達成するた
めの本発明のフラッシュROM管理装置は以下の構成を
備える。即ち、データ領域、及びデータ領域に対応する
管理領域とで構成される複数の記憶ブロックをフラッシ
ュROMに形成し、各記憶ブロックにおいてデータ領域
の記憶状態を示す状態情報を管理領域に格納し、該状態
情報に基づいてフラッシュROMのアクセスを管理する
管理手段と、前記フラッシュROM内の消去ブロックに
ついて、前記状態情報に基づいてデータ領域に有効デー
タが存在する記憶ブロックを抽出し、その内容を移動さ
せて当該消去ブロックを消去する消去手段と、前記消去
手段による消去が行われた回数を消去回数として消去ブ
ロック毎にカウントし、該消去回数を消去ブロックの記
憶領域に記憶するカウント手段と、前記消去手段におい
て消去対象となる消去ブロックを前記消去回数に基づい
て決定する決定手段とを備える。
A flash ROM management apparatus of the present invention for achieving the above object has the following configuration. That is, a plurality of storage blocks each including a data area and a management area corresponding to the data area are formed in the flash ROM, and status information indicating the storage status of the data area in each storage block is stored in the management area. Management means for managing access to the flash ROM based on the status information, and with respect to erase blocks in the flash ROM, a storage block in which valid data exists in the data area is extracted based on the status information, and the contents are moved. Erasing means for erasing the erasing block, counting means for counting the number of times erasing by the erasing means is performed for each erasing block, and storing the erasing number in the memory area of the erasing block; Erasing block to be erased in the means based on the number of times of erasing. That.

【0010】また、好ましくは、前記決定手段は、無効
データを含む消去ブロックのうち前記消去回数の少ない
消去ブロックを消去対象に決定する。無効データを含
み、消去回数の少ない消去ブロックを優先して消去する
ことにより、消去ブロック間の消去回数の分散化が図
れ、書き換え耐久をぶんさんさせることができるからで
ある。
Further, preferably, the deciding means decides, as an erasing target, an erasing block having a small erasing number among erasing blocks including invalid data. By preferentially erasing an erase block containing invalid data and having a small erase count, the erase count can be dispersed among the erase blocks, and rewrite durability can be reduced.

【0011】[0011]

【発明の実施の形態】以下に添付の図面を参照して本発
明の実施の形態を説明する。
BEST MODE FOR CARRYING OUT THE INVENTION Embodiments of the present invention will be described below with reference to the accompanying drawings.

【0012】[実施形態1] <カメラシステムの構成>図1は実施形態1におけるカ
メラシステムの構成を表すブロック図である。本カメラ
システムは、電子カメラと、これに着脱可能な外部記憶
媒体17、PC通信インターフェース19、及びPC通
信インターフェース19を介して電子カメラと通信可能
に接続されたパーソナルコンピュータ22から構成され
る。
[First Embodiment] <Structure of Camera System> FIG. 1 is a block diagram showing the structure of a camera system according to the first embodiment. The camera system includes an electronic camera, an external storage medium 17 that can be attached to and detached from the electronic camera, a PC communication interface 19, and a personal computer 22 communicatively connected to the electronic camera via the PC communication interface 19.

【0013】1はレンズであり、2はレンズ1を通った
光を電気信号として出力するCCDユニットである。3
はA/Dコンバータであり、CCDユニット2からのア
ナログ信号をデジタル信号へ変換する。4はSSGユニ
ットであり、CCDユニット2とA/Dコンバータ3に
同期信号を供給する。5はCPUであり、本カメラシス
テムにおける各種の制御を実現する。
Reference numeral 1 is a lens, and 2 is a CCD unit for outputting the light passing through the lens 1 as an electric signal. Three
Is an A / D converter, which converts an analog signal from the CCD unit 2 into a digital signal. Reference numeral 4 is an SSG unit, which supplies a synchronization signal to the CCD unit 2 and the A / D converter 3. A CPU 5 realizes various controls in the camera system.

【0014】6は信号処理アクセラレータであり、信号
処理を高速に実現する。7は電池であり、8は、電池7
よりの電力を電子カメラ全体へ供給するためのDC/D
Cコンバータである。9は電源コントローラユニットで
あり、DC/DCコンバータ8をコントロールする。1
0はパネル操作・表示装置・電源のコントロールを行う
マイクロコンピュータである。11はユーザへ各種の情
報を表示する表示装置であり、液晶パネル等が用いられ
る。12はコントロールパネルであり、ユーザが直接操
作するレリーズスイッチを含む。
A signal processing accelerator 6 realizes signal processing at high speed. 7 is a battery, 8 is a battery 7
DC / D for supplying more power to the entire electronic camera
It is a C converter. A power controller unit 9 controls the DC / DC converter 8. 1
Reference numeral 0 is a microcomputer that controls the panel operation, display device, and power supply. Reference numeral 11 is a display device for displaying various information to the user, and a liquid crystal panel or the like is used. A control panel 12 includes a release switch that is directly operated by the user.

【0015】13はROMであり、OS等のシステムプ
ログラムを格納する。14はDRAMであり、本電子カ
メラの主記憶である。15はフラッシュROMであり、
内蔵記憶媒体として使用する。16はPCMCIAカー
ドのインタフェース部、17はATAハードディスクな
どの外部記憶媒体、18は拡張バスインタフェースであ
る。19はPC通信インタフェースであり、パーソナル
コンピュータ等を接続してデータの授受を行う。20は
DMAコントローラ、21はストロボである。また、2
2はパーソナルコンピュータであり、PC通信インター
フェース19を介して、電子カメラとの通信を行う。
A ROM 13 stores a system program such as an OS. Reference numeral 14 is a DRAM, which is the main memory of the electronic camera. 15 is a flash ROM,
Used as a built-in storage medium. Reference numeral 16 is a PCMCIA card interface unit, 17 is an external storage medium such as an ATA hard disk, and 18 is an expansion bus interface. A PC communication interface 19 connects a personal computer or the like to exchange data. 20 is a DMA controller and 21 is a strobe. Also, 2
Reference numeral 2 is a personal computer, which communicates with the electronic camera via the PC communication interface 19.

【0016】<撮影動作>この電子カメラの撮影時の動
作を簡単に説明する。コントロールパネル12のレリー
ズスイッチをユーザが押すと、CPU5がそのことを検
出して撮影シーケンスを開始する。以下の動作は全てC
PU5によるコントロールで行われることを前提とす
る。
<Photographing Operation> The photographing operation of this electronic camera will be briefly described. When the user presses the release switch on the control panel 12, the CPU 5 detects that and starts the photographing sequence. The following operations are all C
It is assumed that the control is performed by PU5.

【0017】さて、レリーズスイッチの押下により、S
SG4がCCD2を駆動する。CCD2から出力される
アナログ信号は、A/Dコンバータ3でデジタル信号へ
変換される。A/Dコンバータ3の出力は、DMAコン
トローラ20によってDRAM14へDMA転送され
る。1フレーム分のDMA転送が終了した時点でCPU
5は、信号処理シーケンスを開始する。
By pressing the release switch, S
SG4 drives CCD2. The analog signal output from the CCD 2 is converted into a digital signal by the A / D converter 3. The output of the A / D converter 3 is DMA-transferred to the DRAM 14 by the DMA controller 20. When the DMA transfer for one frame is completed, the CPU
5 starts the signal processing sequence.

【0018】信号処理シーケンスでは、フラッシュRO
M15から信号処理プログラムを主記憶(DRAM1
4)上に読み出し、主記憶上のデータを信号処理アクセ
ラレータ6へ転送し信号処理を行う。但し、信号処理ア
クセラレータ6は信号処理の全てを行うわけではなく、
CPU5で行う処理の特に時間のかかる処理などを助け
る演算回路であり、CPU5の処理ソフトウェアと連携
して動作する。信号処理の一部または全部が終了すると
画像ファイルとしてフラッシュROM15へ記録する。
この時記録するファイルフォーマットが圧縮処理を必用
とするのであれば圧縮も行う。
In the signal processing sequence, the flash RO
The signal processing program from M15 is stored in the main memory (DRAM1
4) Read out, transfer the data in the main memory to the signal processing accelerator 6, and perform signal processing. However, the signal processing accelerator 6 does not perform all signal processing,
It is an arithmetic circuit that helps particularly time-consuming processing performed by the CPU 5, and operates in cooperation with the processing software of the CPU 5. When part or all of the signal processing is completed, it is recorded in the flash ROM 15 as an image file.
If the file format recorded at this time requires compression processing, compression is also performed.

【0019】信号処理プログラムは、フラッシュROM
15の中でファイルシステムが管理するファイルの1つ
である。カメラのプログラムはOSやファイルシステム
といっしょにROM13に納められている。カメラのプ
ログラムは、特定のファイル名のファイルをプログラム
であると認識する。
The signal processing program is a flash ROM
It is one of the files managed by the file system among the fifteen. The camera program is stored in the ROM 13 together with the OS and file system. The camera program recognizes a file with a specific file name as a program.

【0020】フラッシュROM15の中でファイルは不
連続に配置されている上に、本実施形態のファイルシス
テムが頻繁に再配置を行うため、、フラッシュROM1
5内の制御プログラムををCPUが直接実行することは
できない。従って、主記憶(DRAM14)に読み出し
て実行させなければならない。更に、主記憶はメモリマ
ネージャが動的に記憶場所をアロケーションするた
め、、特定のアドレスに格納されることを想定したソフ
トウエアであってはならない。そのため、本実施形態で
信号処理を行うプログラムのファイルは図41のような
形式となっている。
Since the files are discontinuously arranged in the flash ROM 15 and the file system of this embodiment frequently rearranges the files, the flash ROM 1
The control program in 5 cannot be directly executed by the CPU. Therefore, the main memory (DRAM 14) must be read and executed. Further, the main memory should not be software that is supposed to be stored at a specific address because the memory manager dynamically allocates the memory location. Therefore, the file of the program that performs the signal processing in this embodiment has the format shown in FIG.

【0021】図41は本実施形態におけるフラッシュR
OMへの制御プログラムの格納状態を説明する図であ
る。図41において、識別コードはファイルがプログラ
ムであることを確認するためのコードである。ファイル
は可変長のレコードの集合として表現されている。レコ
ードには、始めに当該レコードに格納されている情報の
種類を識別するIDがあり、次にそのレコードの大きさ
を示す値が格納されている。
FIG. 41 shows the flash R in this embodiment.
It is a figure explaining the storing state of the control program in OM. In FIG. 41, the identification code is a code for confirming that the file is a program. A file is represented as a set of variable length records. The record first has an ID for identifying the type of information stored in the record, and then stores a value indicating the size of the record.

【0022】そして、プログラムのレコードとリロケー
ション情報のレコードがファイルに格納されている。プ
ログラムコードは例えば図42のようなデータである。
図42は相対アドレスで表現されたプログラムコードの
一例を表す図である。図42では、0050番地にジャ
ンプ命令があるが、CPUはこの命令を絶対番地へのジ
ャンプ命令と認識する。この命令のオペランドは相対ア
ドレスで表現されている。
The program record and the relocation information record are stored in the file. The program code is data as shown in FIG. 42, for example.
FIG. 42 is a diagram showing an example of a program code expressed by a relative address. In FIG. 42, there is a jump instruction at the address 0050, but the CPU recognizes this instruction as a jump instruction to the absolute address. The operand of this instruction is represented by a relative address.

【0023】図42のリロケーション情報レコードのデ
ータは図43のような形式で納められている。即ち、図
42のプログラムの中で、絶対番地へ変換しなければな
らないデータ(相対アドレス表現になっているデータ)
のプログラム番地を示すアドレステーブルがリロケーシ
ョン情報として格納される。
The data of the relocation information record shown in FIG. 42 is stored in the format shown in FIG. That is, in the program of FIG. 42, data that must be converted to an absolute address (data that is expressed as a relative address)
An address table indicating the program address of is stored as relocation information.

【0024】図41のファイルを主記憶にロードするた
めの領域を確保すると、ROM13のOSのメモリマネ
ージャがアドレスを決定する。メモリマネージャのアロ
ケーションはC言語ではalloc関数に相当する機能であ
る。メモリマネージャがプログラム用に8710番地を
割り当てた場合図44のようにプログラムがロードされ
る。図44は図41のプログラムを主記憶の8710番
地へマッピングした場合のプログラムコードを示す図で
ある。ジャンプ命令のオペランドが実際の絶対番地に置
き換えられている。この実アドレスへの変換をしながら
プログラムを主記憶へ読み出すと言う作業を行うプログ
ラムはROM13に格納されている。
When the area for loading the file shown in FIG. 41 into the main memory is secured, the memory manager of the OS of the ROM 13 determines the address. The allocation of the memory manager is a function equivalent to the alloc function in C language. When the memory manager allocates address 8710 for the program, the program is loaded as shown in FIG. FIG. 44 is a diagram showing a program code when the program of FIG. 41 is mapped to address 8710 in the main memory. The operand of the jump instruction is replaced with the actual absolute address. A program for performing a work of reading out the program into the main memory while converting into the real address is stored in the ROM 13.

【0025】以上のように構成することにより、記憶媒
体に信号処理ソフトウエアや圧縮ソフトウエアをファイ
ル形式で格納することができる。その結果、カメラが最
終ユーザの元へ届いてから、新しい信号処理アルゴリズ
ムや、Windoiws(商標)のBMP形式やTIFF形
式、あるいは将来新たに登場する形式等、多種多様なフ
ァイル形式への対応が可能となる。
With the above configuration, the signal processing software and the compression software can be stored in the storage medium in a file format. As a result, after the camera reaches the end user, it is possible to support a wide variety of file formats, such as new signal processing algorithms, WindowsMP (Trademark) BMP format, TIFF format, or new formats that will appear in the future. Becomes

【0026】以上の様に、本実施形態1における電子カ
メラは、撮影画像をフラッシュROM15へファイルす
るものである。
As described above, the electronic camera according to the first embodiment files captured images in the flash ROM 15.

【0027】<デバイスドライバインタフェース>図2
は、本実施形態の電子カメラにおけるファイルシステム
の階層構造を表す図である。最上位の層がユーザアプリ
ケーション101である。ユーザアプリケーション10
1は電子カメラの内部で動くソフトウェアであり、ファ
イルをファイル名でオープンして読み書きした後クロー
ズする。
<Device Driver Interface> FIG. 2
FIG. 3 is a diagram showing a hierarchical structure of a file system in the electronic camera of this embodiment. The highest layer is the user application 101. User application 10
1 is software that runs inside the electronic camera, which opens a file with a file name, reads / writes it, and then closes it.

【0028】ユーザアプリケーション101から直接フ
ァンクションコールによって呼び出されるのがファイル
システムAPI層102である。このファイルシステム
API層102がドライブ名とファイルシステムを関連
付けて管理している。各ドライブ毎にファイルシステム
アーキテクチャ層をマウントする用に構成しているた
め、複数のファイルシステムアーキテクチャを混在させ
る事が可能となっている。
The file system API layer 102 is called by the function call directly from the user application 101. The file system API layer 102 manages drive names and file systems in association with each other. Since it is configured to mount the file system architecture layer for each drive, it is possible to mix multiple file system architectures.

【0029】ファイルシステムアーキテクチャ層103
が実際のファイル管理を行う部分である。最下位の層が
ブロックデバイス層104である。ファイルシステムア
ーキテクチャ層103がブロックデバイス層104の提
供するサービスを利用してファイル入出力を実現してい
る。このブロックデバイス層104では、データをセク
タという単位で管理しており、1セクタは例えば512
バイトである。このブロックデバイス層104でデバイ
スごとの入出力制御の違いと、ヘッドやシリンダなどパ
ラメータの違いを吸収している。このように構成してい
るため、同時に複数の種類のデバイスを混在させること
ができる。
File system architecture layer 103
Is the part that actually manages the files. The lowest layer is the block device layer 104. The file system architecture layer 103 realizes file input / output using the service provided by the block device layer 104. The block device layer 104 manages data in units of sectors, and one sector is, for example, 512
It is a byte. The block device layer 104 absorbs a difference in input / output control for each device and a difference in parameters such as a head and a cylinder. With this configuration, it is possible to mix a plurality of types of devices at the same time.

【0030】本実施形態の電子カメラでは、特にブロッ
クデバイス層104におけるフラッシュROMの記憶管
理方法に特徴を有する。
The electronic camera of the present embodiment is characterized by a flash ROM storage management method in the block device layer 104.

【0031】図1で示したフラッシュROM11には、
現在いろいろなタイプのものがあるが、大きく分けてフ
ラッシュDISK用に開発されたタイプとパーソナルコ
ンピュータのBIOS用に開発されたタイプがある。前
者は消去単位がハードディスクで一般的な512バイト
であり、ファイルシステムとの整合性が非常に良い。後
者のフラッシュROMは消去単位が例えば64kなどと
いった大きなブロック単位でしか行えない様になってい
る。また、PROMの様に書き込み電圧として12V等
の電圧が必要なものもある。しかしながら、後者のタイ
プのフラッシュROMは安価で入手が容易である。本実
施形態では、後者の様な特徴を持つフラッシュROMで
ありながらファイルシステムに対してハードディスク同
様のサービスを提供する。
The flash ROM 11 shown in FIG.
At present, there are various types, but there are broadly classified types, one developed for flash disk and the other developed for BIOS of personal computer. In the former, the unit of erasure is 512 bytes, which is generally used for hard disks, and the compatibility with the file system is very good. The latter flash ROM is designed so that it can be erased only in large block units such as 64k. Some PROMs require a voltage such as 12V as a write voltage. However, the latter type of flash ROM is inexpensive and easily available. In the present embodiment, a service similar to a hard disk is provided for a file system even though it is a flash ROM having the latter feature.

【0032】<フラッシュROMドライバインタフェー
ス>一般的にブロックデバイスがファイルシステムへ提
供するサービスは以下の2つである。即ち、 (1)ロジカルセクタナンバーで指定したセクタからの
読み出し (2)ロジカルセクタナンバーで指定したセクタからの
書き込み である。そして、これに加えて (3)ロジカルセクタナンバーで指定したセクタの開放 の機能があれば、フラッシュROMのドライバは必要に
応じて不要なセクタを消去することが可能となるため、
効率良くフラッシュROMを消去することができる。
<Flash ROM Driver Interface> Generally, the block device provides the following two services to the file system. That is, (1) reading from the sector designated by the logical sector number, and (2) writing from the sector designated by the logical sector number. In addition to this, if (3) the function of releasing the sector specified by the logical sector number is provided, the flash ROM driver can erase unnecessary sectors as necessary.
The flash ROM can be erased efficiently.

【0033】(3)に挙げた機能は、通常のDISKで
は必要のない機能だが、キャッシュを持ったシステムだ
と、積極的にキャッシュリストから削除できるので、結
果的にキャッシュのヒット率を上げる効果がある。ファ
イルシステムは、ファイルの消去等で不必要となったセ
クタを(3)の機能を用いてデバイスドライバへ通知す
る。フラッシュROMの消去は非常に時間がかかる処理
だが、CPU時間をほとんど消費しないためバックグラ
ンド処理で行うのが良い。
The function mentioned in (3) is a function which is not necessary in the normal DISK, but in a system having a cache, it can be positively deleted from the cache list, so that the effect of increasing the cache hit rate is as a result. There is. The file system notifies the device driver of unneeded sectors due to file deletion or the like by using the function (3). Erasing the flash ROM is a very time-consuming process, but it is preferable to perform it in the background process because it consumes almost no CPU time.

【0034】後述の<FATキャッシュ>においても説
明するが、本実施形態のキャッシュは、新しいデータ
(キャッシュ上に無いデータ)をアクセスする場合にキ
ャッシュリストの中で最も古いデータを廃棄する。不要
セクタをキャッシュリストの最後へ移動させる(即ち、
最も古くアクセスしたデータがキャッシュの後ろへ移動
する)ことで有効なデータがキャッシュから廃棄される
可能性が低くなる。特にコンパイラー等の中間ファイル
を多く生成するシステムでは、消去すべき中間ファイル
がキャッシュに残っている可能性が高く、上記のキャッ
シュ管理はヒット率の向上に非常に有効である。
As will be described later in <FAT cache>, the cache of this embodiment discards the oldest data in the cache list when accessing new data (data that is not on the cache). Move unnecessary sectors to the end of the cache list (ie
By moving the oldest accessed data to the back of the cache), it is less likely that valid data will be discarded from the cache. Especially in a system such as a compiler that generates many intermediate files, there is a high possibility that intermediate files to be deleted remain in the cache, and the above cache management is very effective in improving the hit rate.

【0035】図3は、デバイスドライバの管理ブロック
をC言語で記述した宣言文を示す図である。構造体のN
extは、次のデバイスへのリングポインタであり、メ
モリ中のデバイスを検索する目的で使用される。Dev
Nameは、デバイスの名前として使用される。Ini
tDevは、デバイスの初期化ルーチンへのポインタで
ある。ShutDownは、デバイスのシャットダウン
ルーチンへのポインタである。ReadSector
は、ロジカルセクタを指定して媒体の内容をバッファへ
転送するルーチンへのポインタである。WriteSe
ctorは、ロジカルセクタを指定してバッファの内容
を媒体へ転送する(書き込む)プログラムへのポインタ
である。ReleaseSectorはロジカルセクタ
を指定して、セクタを解放するルーチンへのポインタで
ある。
FIG. 3 is a diagram showing a declaration statement in which the management block of the device driver is described in C language. N of structure
ext is a ring pointer to the next device, and is used for searching the device in the memory. Dev
Name is used as the name of the device. Ini
tDev is a pointer to the device initialization routine. ShutDown is a pointer to the device shutdown routine. ReadSector
Is a pointer to a routine for designating a logical sector and transferring the contents of the medium to the buffer. WriteSe
ctor is a pointer to a program for designating a logical sector and transferring (writing) the contents of the buffer to the medium. ReleaseSector is a pointer to a routine for designating a logical sector and releasing the sector.

【0036】ファイルシステムは、この構造体を仲介し
てデバイスドライバを利用することになる。固定ディス
クやフロッピーディスクの場合、ReleaseSec
torには何も仕事をしないプログラムへのポインタが
代入されている。または、ディスクキャッシュのキャッ
シュリストから指定セクタを削除するポインタでもよ
い。
The file system uses the device driver via this structure. ReleaseSec for fixed and floppy disks
A pointer to a program that does nothing is assigned to tor. Alternatively, it may be a pointer that deletes the specified sector from the cache list of the disk cache.

【0037】<フラッシュROM管理方法>フラッシュ
ROMに対するデータ書き込みは、上位層のファイルシ
ステムからセクタ単位で行われる。図4は、フラッシュ
ROM上のセクタ構造の例を示す図である。図4におい
て、151はイレースブロックである。このイレースブ
ロック151は消去の単位であり、フラッシュROMの
技術用語ではセクタと呼ばれるものである。しかしなが
ら、ファイルシステムが扱う単位である“論理セクタ”
と区別する為に、ここではイレースブロックと呼ぶこと
にする。
<Flash ROM Management Method> Data writing to the flash ROM is performed in sector units from the upper layer file system. FIG. 4 is a diagram showing an example of a sector structure on the flash ROM. In FIG. 4, 151 is an erase block. The erase block 151 is a unit of erasing and is called a sector in the technical term of the flash ROM. However, the "logical sector" that is the unit handled by the file system
In order to distinguish it from, it is called an erase block here.

【0038】図4によれば、システム中に複数のフラッ
シュROM15が搭載されていて、各フラッシュROM
15は複数のイレースブロック151によって構成され
る。更に、各イレースブロック151は消去回数カウン
タ152と複数のセクタ153によって構成されている
様子をあらわしている。消去回数カウンタ152は、イ
レースブロック151を消去した回数をカウントする為
に用いる部分である。各セクタ153は、管理領域とデ
ータ領域とを有する。管理領域は、論理セクタ番号を表
すセクタ番号154と、セクタが有効利用されているか
どうかを表わす使用中フラグ155と、セクタとしての
利用が終了したことを表わす使用済みフラグ156とで
構成される。また、データ領域は、512バイトのデー
タ部157によって構成されている。
According to FIG. 4, a plurality of flash ROMs 15 are installed in the system, and each flash ROM is
Reference numeral 15 is composed of a plurality of erase blocks 151. Further, each erase block 151 is shown to be composed of an erase count counter 152 and a plurality of sectors 153. The erase count counter 152 is a part used for counting the number of erases of the erase block 151. Each sector 153 has a management area and a data area. The management area is composed of a sector number 154 indicating a logical sector number, a busy flag 155 indicating whether or not the sector is effectively used, and a used flag 156 indicating that the use as a sector is completed. The data area is composed of a 512-byte data section 157.

【0039】データ領域と管理領域は、隣り合って配置
する必要は無く、図5の様にまとめて管理することも考
えられる。図5は、管理領域用データと、データ領域と
を分離して格納する構成を表す図である。セクタ番号テ
ーブルには、複数のセクタ153の各セクタ番号154
が格納される。また、フラグテーブルには、使用中フラ
グ155、使用済みフラグ156が格納される。更に、
データテーブルには、データ部157の内容が格納され
る。以上のようなデータ構成をとることも可能である
が、少なくとも管理領域と、これに対応するデータ領域
とは同じイレースブロック内に納めるのが好ましい。
It is not necessary to arrange the data area and the management area adjacent to each other, and it is conceivable to manage them collectively as shown in FIG. FIG. 5 is a diagram showing a configuration in which the management area data and the data area are separately stored. In the sector number table, each sector number 154 of the plurality of sectors 153
Is stored. The flag table stores a used flag 155 and a used flag 156. Furthermore,
The contents of the data section 157 are stored in the data table. Although it is possible to have the data structure as described above, it is preferable that at least the management area and the data area corresponding thereto are stored in the same erase block.

【0040】なお、システムは「使用中フラグ155」
より「使用済みフラグ156」の方を優先的に評価す
る。図6は、各フラグの状態に対応した意味を示す図で
ある。図中、FALSEは、消去後の状態と同じ値をと
る。使用中フラグ155がTRUEであっても、使用済
みフラグ156がFALSEであれば、当該セクタのデ
ータは無効である。
The system is "in-use flag 155".
The “used flag 156” is evaluated more preferentially. FIG. 6 is a diagram showing the meaning corresponding to the state of each flag. In the figure, FALSE has the same value as the state after erasing. Even if the in-use flag 155 is TRUE, if the used flag 156 is FALSE, the data in the sector is invalid.

【0041】<フラッシュROMの論理セクタ書き換え
>フラッシュROMはPROM同様、データを書き換え
る為に、一度消去してから再書き込みをしなければなら
ない。しかも、消去の最少単位が大きく(例えば64k
バイト)消去時間が長い(例えば1秒)。そこで上位層
のファイルシステムが、特定のセクタを書き換えようと
した場合、消去済みの領域へ論理セクタを移動させるこ
とで、消去動作をせずに、見かけ上で論理セクタのデー
タ書き換えを実現する。
<Logical Sector Rewriting of Flash ROM> Like the PROM, the flash ROM must be erased once and then rewritten to rewrite data. Moreover, the minimum unit of erasure is large (for example, 64k
(Byte) Erase time is long (for example, 1 second). Therefore, when the upper-layer file system attempts to rewrite a specific sector, the logical sector is moved to the erased area to apparently rewrite the data of the logical sector without performing the erasing operation.

【0042】図7はセクタの書き換え手順を説明する図
である。同図を用いて、8番セクタ(論理セクタ番号が
8のセクタ)の書き換えを例にして詳しく説明する。図
7中、左側が書き換え前の状態であり((a)の状
態)、右側が書き換え後の状態((b)の状態)であ
る。また、図7において、管理領域中の数字は論理セク
タ番号を表し、(使用中)は使用中フラグ155がTR
UEで使用済みフラグ156がFALSEの状態、(使
用済)は使用中フラグ155と使用済みフラグ156が
共にTRUEの状態を示す。
FIG. 7 is a diagram for explaining a sector rewriting procedure. The rewriting of the 8th sector (sector whose logical sector number is 8) will be described in detail with reference to FIG. In FIG. 7, the left side is the state before rewriting (state (a)), and the right side is the state after rewriting (state (b)). Further, in FIG. 7, the numbers in the management area represent logical sector numbers, and (in use) indicates that the in-use flag 155 is TR.
In the UE, the used flag 156 indicates the FALSE state, and (used) indicates that both the in-use flag 155 and the used flag 156 are TRUE.

【0043】“セクタ番号8(使用中)”の場所に、8
番セクタのデータが格納されている。今、8番セクタが
FATやファイルの一部として利用されていて、その内
容を変更したい場合に上位層から8番セクタの書き換え
要求が発生したとする。書き換え要求が発生すると、フ
ラッシュROMのデバイスドライバは、フラッシュRO
Mの未使用セクタを検索し、その場所を新たな8番セク
タの場所としてセクタ番号と更新後のデータを格納し、
使用中フラグをTRUEにする。次に、以前8番セクタ
だったセクタの使用済みフラグをTRUEにする。この
ような手順で8番セクタのデータの書き換えが実現され
る。
In the place of "sector number 8 (in use)", 8
The data of No. sector is stored. Now, suppose that the 8th sector is used as a part of a FAT or a file and a request for rewriting the 8th sector is issued from the upper layer when changing the contents. When a rewrite request is generated, the flash ROM device driver is
The unused sector of M is searched, and the sector number and the updated data are stored using that location as the location of the new 8th sector.
The busy flag is set to TRUE. Next, the used flag of the sector which was the 8th sector before is set to TRUE. Rewriting of the data of the 8th sector is realized by such a procedure.

【0044】<ガベージコレクション>以上の様な方法
で論理セクタの書き換えを実行していくと、いずれフラ
ッシュROMのほとんどの領域を“使用済セクタ”にし
てしまうことになる。そこであるタイミングでフラッシ
ュROMを一旦消去して“使用済セクタ”を“未使用セ
クタ”へ戻す必要がある。基本的なガベージコレクショ
ンの動作を図8を用いて説明する。図8は、本実施形態
におけるフラッシュROMのガベージコレクション動作
を説明する図である。
<Garbage Collection> When the rewriting of the logical sector is executed by the above method, most of the area of the flash ROM eventually becomes the “used sector”. Therefore, it is necessary to erase the flash ROM once at a certain timing to restore the "used sector" to the "unused sector". The basic garbage collection operation will be described with reference to FIG. FIG. 8 is a diagram for explaining the garbage collection operation of the flash ROM in this embodiment.

【0045】図中(A)は、ガベージコレクション前の
状態である。説明を簡単にするために、本例のフラッシ
ュROMはセクタ6個分の大きさのイレースブロックで
構成されているものとする。イレースブロック(1)に
は使用済セクタが3個と使用中セクタが3個あり、消去
回数は5回である(消去回数カウンタ152の内容が5
である)。イレースブロック(2)には使用中セクタが
1個、使用済セクタが1個、未使用セクタが4個あり、
消去回数は9回である。この状態からガベージコレクシ
ョンを開始する。
In the figure, (A) shows a state before garbage collection. To simplify the description, the flash ROM of this example is assumed to be composed of erase blocks each having a size of six sectors. The erase block (1) has three used sectors and three in-use sectors, and the erase count is 5 (the erase count counter 152 has a content of 5).
Is). The erase block (2) has one used sector, one used sector, and four unused sectors.
The erase count is 9. Garbage collection is started from this state.

【0046】先ず、調整対象イレースブロックを選定す
る。ここで調整対象イレースブロックは消去を行う対象
としてイレースブロックとなる。整理対象イレースブロ
ックの選定は、使用済セクタをたくさん含むイレースブ
ロックから優先的に選択すると整理効率が良い。しかし
使用済セクタを含まない場合を別として消去回数の少な
いイレースブロックを優先的に整理対象とする方法を取
ればチップ内のイレースブロックを平均的に使用するこ
とができ、書き換え耐久を分散させることができる。選
択手順の詳細についてはフローチャートを用いて後述す
る。
First, an erase block to be adjusted is selected. Here, the erase block to be adjusted is an erase block to be erased. When selecting an erase block to be rearranged, the rearrangement efficiency can be improved by preferentially selecting an erase block including many used sectors. However, if the erase blocks with a small number of erases are preferentially sorted out except when the used sectors are not included, the erase blocks in the chip can be used evenly and the rewriting endurance can be dispersed. You can Details of the selection procedure will be described later using a flowchart.

【0047】今、イレースブロック(1)が整理対象と
して選定されたとする。次に、整理対照であるイレース
ブロック(1)の使用中セクタ(使用中フラグがTRU
Eで、使用済みフラグがFALSEのセクタ)を他のイ
レースブロックに移動させる。使用中セクタの移動手順
は、セクタの書き換え時と同様に、他のイレースブロッ
ク中の未使用セクタを検索して、使用中セクタ内のデー
タ領域と管理領域の内容をコピーし、移動元の使用中セ
クタの使用済みフラグをTRUEにする。なお、未使用
セクタが無い場合の処理は、後で述べる。
Now, it is assumed that the erase block (1) is selected as a rearrangement target. Next, the in-use sector of the erase block (1) which is the rearrangement contrast (the in-use flag is TRU
At E, the sector whose used flag is FALSE) is moved to another erase block. The procedure for moving the in-use sector is the same as when rewriting the sector, searching for unused sectors in other erase blocks, copying the contents of the data area and management area in the in-use sectors, and using The used flag of the medium sector is set to TRUE. The processing when there are no unused sectors will be described later.

【0048】図8の(B)は、イレースブロック(1)
の使用中セクタをすべてイレースブロック(2)へ移動
させた状態である。この結果、イレースブロック(1)
には、使用済セクタしか存在しないことになる。
FIG. 8B shows an erase block (1).
All the in-use sectors of are moved to the erase block (2). As a result, erase block (1)
In this case, only used sectors exist.

【0049】次に、使用済セクタだけで構成されている
イレースブロックを検索する。ここで、検索を行うの
は、通常の書き換え動作の際に偶然イレースブロック内
のセクタが全て使用済セクタとなっている場合があるか
らである。続いて検索されたイレースブロックに対して
消去を行う。消去には時間がかかるが、複数のイレース
ブロックを同時に消去できるため、できるだけ一度に複
数のイレースブロックを消去するのが良い。消去が終了
すると消去回数カウンタへ消去前の値+1したものを書
く。これでガベージコレクション完了である。
Next, an erase block composed of only used sectors is searched. Here, the search is performed because all the sectors in the erase block may happen to be used sectors during the normal rewriting operation. Then, erase is performed on the retrieved erase block. It takes time to erase, but since it is possible to erase multiple erase blocks at the same time, it is better to erase multiple erase blocks at once. When the erasing is completed, the value before erasing plus 1 is written to the erase count counter. This completes garbage collection.

【0050】図8の(C)がガベージコレクション終了
時の状態である。イレースブロックをできるだけ同時に
消去した方が効率が良いため、使用済セクタと未使用セ
クタがある限りたくさんのイレースブロックを同時に調
整すると良い。極端に消去回数カウンタの値が他のイレ
ースブロックより少ないものがあれば、使用済セクタを
含んでいなくても整理さえすれば、書き換え耐久の分散
を図れる。また、一度整理するとデータの配列が変わる
為、書き換え耐久分散のきっかけとなる。
FIG. 8C shows the state at the end of garbage collection. Since it is more efficient to erase erase blocks at the same time as much as possible, it is good to adjust many erase blocks at the same time as long as there are used sectors and unused sectors. If the erase count value is extremely smaller than that of other erase blocks, rewriting durability can be dispersed by rearranging even if the used sectors are not included. In addition, once arranged, the arrangement of the data changes, which is a trigger for rewriting endurance distribution.

【0051】<未使用セクタがない場合>次にシステム
中に使用済セクタが有るにもかかわらず未使用セクタが
全く無くなってしまった場合のガベージコレクション手
順を図9を使って説明する。図9は、未使用セクタが存
在しない場合のガベージコレクションの動作を説明する
図である。
<Case of No Unused Sector> Next, the garbage collection procedure in the case where there is a used sector in the system but there is no unused sector will be described with reference to FIG. FIG. 9 is a diagram for explaining the operation of garbage collection when there are no unused sectors.

【0052】先ず、上述した基本的なガベージコレクシ
ョン手順に従い、イレースブロック(1)を整理対象と
して選択する。次にイレースブロック(1)の使用中セ
クタを移動する為の未使用セクタを検索する。未使用セ
クタがある場合は、上述の基本的ガベージコレクション
と同様にセクタの移動を行う。
First, the erase block (1) is selected as a rearrangement target in accordance with the basic garbage collection procedure described above. Next, an unused sector for moving the used sector of the erase block (1) is searched. If there are unused sectors, the sectors are moved in the same manner as the basic garbage collection described above.

【0053】一方、検索の結果、未使用セクタが無けれ
ば、DRAM14のヒープエリアからデータの退避に必
要な大きさのメモリブロックをアロケーションする。そ
して調整対象イレースブロック内の使用中セクタをDR
AM14へコピーする。この場合は、フラッシュROM
の別の領域へセクタを移動する場合と違い、元のセクタ
の使用済フラグをTRUEにしない。なぜならこの時点
で電子カメラの電池7が外れるなどの事故が起こった場
合に、DRAM内のデータが消滅してしまい、データの
修復ができなくなるからである。図9の(B)は、DR
AM14の領域へコピーされたセクタを表現している。
調整対象のイレースブロックの使用中セクタをすべて退
避出来たら、その調整対象のイレースブロックを選択し
て消去する(図9の(C)参照)。消去が終わった後は
未使用セクタがたくさん出来ているはずである。よっ
て、次に未使用領域を検索してDRAM14へ待避して
あったデータを復元する。図9の(D)は、ガベージコ
レクションが完了した状態を示している。
On the other hand, if there is no unused sector as a result of the search, a memory block of a size necessary for saving data is allocated from the heap area of the DRAM 14. Then, the used sector in the erase block to be adjusted is DR
Copy to AM14. In this case, flash ROM
Unlike the case where the sector is moved to another area of, the used flag of the original sector is not set to TRUE. This is because, if an accident such as the battery 7 of the electronic camera is removed at this point, the data in the DRAM will be lost and the data cannot be restored. FIG. 9B shows DR
The sector copied to the area of AM14 is represented.
When all used sectors of the erase block to be adjusted can be saved, the erase block to be adjusted is selected and erased (see (C) in FIG. 9). After erasing, there should be many unused sectors. Therefore, the unused area is searched next and the data saved in the DRAM 14 is restored. FIG. 9D shows a state where the garbage collection is completed.

【0054】上記の手順でガベージコレクションをした
場合でも、イレースブロックを消去してからデータを復
元するまでの間に電子カメラの電池7が外れるなどの事
故が起こったらデータの修復をすることはできない。つ
まり、セクタのデータをDRAM14に退避する方法は
できる限り取らない方が、よりシステムの安全性を保つ
ことができる。一回、DRAMを使ってガベージコレク
ションを行えば未使用セクタができる。したがって、1
度DRAM14を使ったガベージコレクションを行い、
その後に通常のガベージコレクションを行えば、消去時
間は余分にかかるが安全性を高めることができる。逆に
DRAM14への退避を積極的に行う(例えばヒープ領
域がある限り退避する)と、同時に整理できるイレース
ブロックが増える為効率を上げることができる。従っ
て、安全性と効率のどちらを優先するかを指定できるよ
うに構成してもよい。またシステムの電源が電池7より
供給されている場合は安全性優先、ACアダプタから供
給されている場合は効率優先に自動的に切り替わるよう
に構成してもよい。本処理については図36を参照して
後述する。
Even if garbage collection is performed by the above procedure, data cannot be restored if an accident such as removal of the battery 7 of the electronic camera occurs after the erase block is erased until the data is restored. . In other words, it is possible to keep the system safety better by not saving the sector data in the DRAM 14 as much as possible. Once the DRAM is used for garbage collection, unused sectors are created. Therefore, 1
Garbage collection using the DRAM14,
If normal garbage collection is performed after that, the erasing time will be extra, but the safety can be improved. On the contrary, if the saving to the DRAM 14 is actively performed (for example, as long as there is a heap area), the efficiency can be improved because the number of erase blocks that can be sorted at the same time increases. Therefore, it may be configured so that it is possible to specify which of safety and efficiency is to be prioritized. Further, when the power of the system is supplied from the battery 7, safety may be prioritized, and when supplied from the AC adapter, efficiency may be automatically prioritized. This processing will be described later with reference to FIG.

【0055】<イレースブロックを余分に1つ用意>残
り容量が極端に少なくなるとガベージコレクションが多
発してシステムのパフォーマンスが極端に落ちる。総論
理セクタ分を格納できるイレースブロック数よりも1つ
だけ余分にイレースブロックを使用すれば、そのような
事態を避けることが可能である。仮に、1イレースブロ
ックあたり127セクタ格納できるとして、全てのセク
タが使用中となった場合、同じ1セクタを10回書換え
る場合を例にすると、余分イレースブロックがなけれ
ば、10回の消去と1270セクタの書き込みが発生す
る。しかし、イレースブロックを余分に1つ用意してお
けば、10セクタの書き込みしか発生しない。
<Preparing an extra erase block> If the remaining capacity becomes extremely small, garbage collection will occur frequently and the system performance will drop extremely. Such a situation can be avoided by using an erase block one more than the number of erase blocks that can store the total logical sectors. Assuming that 127 sectors can be stored per erase block, if all sectors are in use and the same one sector is rewritten 10 times, if there are no extra erase blocks, 10 erases and 1270 Sector writing occurs. However, if an extra erase block is prepared, only 10 sectors will be written.

【0056】よって、本実施形態では、イレースブロッ
クの数はチップの構成で決まるので、最低1つのイレー
スブロックが余る様な総論理セクタ数を設計する。
Therefore, in this embodiment, since the number of erase blocks is determined by the chip configuration, the total number of logical sectors is designed so that at least one erase block remains.

【0057】<ガベージコレクションのタイミング>ガ
ベージコレクションは消去動作を伴うために非常に時間
がかかる。そのためガベージコレクションをいつ行うか
によってカメラの使い勝ってを左右することとなる。例
えば、セルフタイマなどの数秒間撮影しなくても良い時
にガベージコレクションを行えばユーザがストレスを感
じることがない。
<Timing of Garbage Collection> Garbage collection is extremely time-consuming because it involves an erase operation. Therefore, the ease of use of the camera depends on when the garbage collection is performed. For example, if the garbage collection is performed when it is not necessary to take a picture for several seconds such as with a self-timer, the user will not feel stress.

【0058】<RAM上の記憶場所管理>フラッシュR
OM15上ではセクタ番号と実際の記憶場所が関連して
いないために特定のセクタを読み書きする為にフラッシ
ュROM15を検索しなければならない。そこでシステ
ムがリブートする際に、フラッシュROM15における
各セクタの格納アドレスを示す記憶場所管理テーブルを
DRAM114上に作成しておくと、フラッシュROM
15に対して高速なデータの読み書きを実現できる。一
度、記憶場所管理テーブルを作成すれば、フラッシュR
OM15に対するセクタの書き込みやガベージコレクシ
ョンによって記憶場所に変更が生じた場合に限って記憶
場所管理テーブルの記憶位置を更新するだけで常に正し
い記憶場所管理テーブルを維持することが可能である。
<Memory Location Management on RAM> Flash R
Since the sector number and the actual storage location are not associated with each other on the OM 15, the flash ROM 15 must be searched to read / write a specific sector. Therefore, when the system is rebooted, a storage location management table indicating the storage addresses of the respective sectors in the flash ROM 15 is created in the DRAM 114.
High-speed data reading and writing can be realized for 15. Once you create a storage location management table, flash R
It is possible to maintain the correct storage location management table only by updating the storage location of the storage location management table only when the storage location is changed by writing a sector to the OM 15 or garbage collection.

【0059】図10は、DRAM上に作成された記憶場
所管理テーブルを説明する図である。図中、右側にRA
M上の作成した記憶場所管理テーブル140を示した。
0セクタと4セクタは記憶場所不在を意味する値(NUL
L)が入っている。これらは、フォーマット後そのセク
タに対する書き込みが全く無かったか、もしくは、ファ
イルシステムが開放したセクタである。
FIG. 10 is a diagram for explaining the storage location management table created on the DRAM. RA on the right side of the figure
The created storage location management table 140 on M is shown.
0 sector and 4 sector are values that mean no storage location (NUL
L) is included. These are the sectors that have not been written to the sector at all after formatting or the file system has released them.

【0060】ファイルシステムがファイルの消去などで
不要となったセクタを解放する命令をドライバに出した
場合のデバイスドライバの動作は次のようになる。ま
ず、DRAM14上の記憶場所管理テーブル140の指
定されたセクタのポインタを参照してフラッシュROM
15上の現在使用中の該当するセクタを探し出す。そし
て、当該セクタの使用済フラグをTRUEにし、DRA
M14上の記憶場所管理テーブル140の指定セクタの
ポインタへ不在値(NULL)を代入する。
The operation of the device driver when the file system issues a command to the driver to release an unnecessary sector due to file erasure or the like is as follows. First, referring to the pointer of the designated sector in the storage location management table 140 on the DRAM 14, the flash ROM
Find the appropriate sector currently in use on 15. Then, the used flag of the sector is set to TRUE, and the DRA
The absent value (NULL) is assigned to the pointer of the designated sector of the storage location management table 140 on M14.

【0061】なお、ガベージコレクションの為にセクタ
の内容をDRAM14へ待避している場合は、記憶場所
としてDRAMへのポインタが代入されている。また、
同一論理セクタに対する同時操作を禁止する為のロック
変数もテーブルに納めることが望ましい。
When the contents of the sector are saved in the DRAM 14 for garbage collection, the pointer to the DRAM is assigned as the storage location. Also,
It is desirable to store the lock variable for prohibiting the simultaneous operation on the same logical sector in the table.

【0062】<MS−DOSのファイル復元>本電子カ
メラとパーソナルコンピュータ22で、記憶媒体上のデ
ータ交換が出来ると都合が良い。本実施形態で説明した
フラッシュROM管理方式を使用して、現在パーソナル
コンピュータで普及しているMS−DOS(商標)と互
換性があるファイルシステムを実装することができる。
MS−DOSには一度消去したファイルを復元するユー
ティリティが付属している。ところが、本実施形態では
フラッシュROMの消去効率を向上させる為に、消去し
たセクタのデータ部を失ってしまう様な構成となってい
る。カメラで消去した媒体をパーソナルコンピュータで
復元する事が原理的にできない構成になっているのであ
る。
<File Restoration of MS-DOS> It is convenient that the electronic camera and the personal computer 22 can exchange data on a storage medium. The flash ROM management method described in the present embodiment can be used to implement a file system compatible with MS-DOS (trademark) currently popular in personal computers.
MS-DOS comes with a utility to restore files that have been deleted. However, in this embodiment, in order to improve the erase efficiency of the flash ROM, the data portion of the erased sector is lost. In principle, it is impossible to restore the medium erased by the camera with a personal computer.

【0063】パーソナルコンピュータでのファイル復元
機能を禁止できれば、このような事故を防ぐことができ
る。本実施形態では、MS−DOSがファイル復元の時
に使用するデータを破壊することでファイル復元機能を
禁止する。これをいかに説明する。
If the file restoration function in the personal computer can be prohibited, such an accident can be prevented. In this embodiment, the file restoration function is prohibited by destroying the data used by the MS-DOS when restoring the file. How will this be explained?

【0064】MS−DOS(商標)で、ファイルを消去
するとディレクトリに空きスロットができる。ディレク
トリにはファイル名/タイムスタンプ/最初のクラスタ
などの情報が格納されている。図45はディレクトリス
ロットの特徴を表す図である。ディレクトリスロットの
最後には、リストの最後であることを示すEndOfDirが格
納されている。
In MS-DOS (trademark), when a file is deleted, an empty slot is created in the directory. Information such as file name / time stamp / first cluster is stored in the directory. FIG. 45 is a diagram showing the characteristics of the directory slot. EndOfDir indicating the end of the list is stored at the end of the directory slot.

【0065】今、File Bを削除すると、ファイル名の先
頭が削除を表すシンボルに置き換えられ、FATのクラ
スタチェーンが消去される。この様子を図46に示す。
Now, when File B is deleted, the beginning of the file name is replaced with a symbol indicating deletion, and the FAT cluster chain is deleted. This state is shown in FIG.

【0066】アンデリートプログラムは、2番目のスロ
ットに残った情報を元に、ファイルの復元を試みる。逆
にこの情報がなければ、ファイルの復元を防止できる。
The undelete program tries to restore the file based on the information remaining in the second slot. Conversely, without this information, file restoration can be prevented.

【0067】図47は本実施形態のDOS互換ファイル
システムでファイルを消去した後の状態を表している。
本実施形態では、ディレクトリエントリテーブルの最後
に格納されているファイルを消去したいファイルのエン
トリに上書きし、ディレクトリエントリテーブルの最後
のファイルだった部分にEndOfDirを上書きするように構
成する。こうすることにより、ファイル復元機能による
ファイルの復元を防止できる。
FIG. 47 shows a state after a file is erased by the DOS compatible file system of this embodiment.
In the present embodiment, the file stored at the end of the directory entry table is overwritten on the entry of the file to be deleted, and EndOfDir is overwritten on the part that was the last file in the directory entry table. By doing so, it is possible to prevent the file restoration by the file restoration function.

【0068】なお、ファイルの消去時にはMS−DOS
と同様にセクタのデータをそのまま残しておき(セクタ
の開放を行わない)、ガベージコレクション時にまとめ
てFATとデータの関係を参照してしながら不要部分を
消去する方法もある。
When deleting a file, MS-DOS
There is also a method in which the data in the sector is left as it is (the sector is not released) and the unnecessary portion is erased while collectively referring to the relationship between the FAT and the data at the time of garbage collection.

【0069】<バックグランドで前処理>あるフラッシ
ュROMでは、消去前のデータが“0”になっている方
が高速に消去処理できる。フラッシュROMの消去完了
の確認は、データ書き込み時と同様にデータポーリング
によって行われる。従って、このようなフラッシュRO
Mを使う場合は、バックグランド処理で“使用済”とな
ったセクタのデータを0に書き換える「前処理」を行う
ことで性能を向上させることができる。最も低いプライ
オリティのタスクとして実行するようにしておけば、ス
ループットの低下にはつながらない。
<Background Preprocessing> In a certain flash ROM, the erasing process can be performed faster when the data before erasing is “0”. Confirmation of the erasing completion of the flash ROM is performed by data polling as in the data writing. Therefore, such a flash RO
When M is used, the performance can be improved by performing "preprocessing" in which the data of the sector which has been "used" in the background processing is rewritten to 0. If it is executed as the task with the lowest priority, the throughput will not decrease.

【0070】この前処理バックグラウンドでの“前処理
済セクタ”管理の為にフラグを用意しておけば前処理の
効率を上げることができる。
If a flag is prepared for the management of the "preprocessed sector" in the background of the preprocessing, the efficiency of the preprocessing can be improved.

【0071】そのために、セクタのとりうる状態とし
て、「未使用」「使用中」「使用済」に加えて「前処理
済」の4つの状態を表示できる管理フラグをフラッシュ
ROMのセクタ内部へ用意すると効率が良い。
Therefore, management flags capable of displaying four states of “pre-processed” in addition to “unused”, “in use”, and “used” are prepared in the sector of the flash ROM as possible states of the sector. Then it is efficient.

【0072】図38は、本実施形態における消去処理速
度向上のための前処理の制御手順を表すフローチャート
である。同図において、ステップS2501にて、使用
済でかつ前処理の済んでいないセクタを抽出する。これ
は、セクタ内の管理フラグが「使用済」となっていて、
かつ「前処理済」となっていないセクタを抽出すること
で実現できる。ステップS2502において、抽出され
たセクタに対してデータ「0」を上書きを開始する。ス
テップS2503では当該セクタについて前処理を終了
したか否かを判断する。フラッシュROMへの書込みは
1バイト単位であるので、1セクタ分のバイト数の書込
みが必要となる。当該セクタに対する前処理が終了して
いなければステップS2504へ進み、他のタスクへ制
御を移す。
FIG. 38 is a flow chart showing a control procedure of preprocessing for improving the erase processing speed in this embodiment. In the figure, in step S2501, used sectors that have not been preprocessed are extracted. This is because the management flag in the sector is "used",
And it can be realized by extracting the sector which is not “preprocessed”. In step S2502, the data “0” is overwritten in the extracted sector. In step S2503, it is determined whether preprocessing has been completed for the sector. Since writing to the flash ROM is in 1-byte units, it is necessary to write the number of bytes for one sector. If the preprocessing for the sector has not been completed, the process advances to step S2504 to transfer control to another task.

【0073】上述したように本処理は最もプライオリテ
ィの低いタスクで行われるので、CPU5がアイドル状
態となったときに再び本処理が実行される。この場合処
理はステップS2503へ戻る。この時点で、前回の書
込みが終了していなければそのまま他のタスクへ処理を
移行する。
As described above, since this processing is performed by the task with the lowest priority, this processing is executed again when the CPU 5 enters the idle state. In this case, the process returns to step S2503. At this point, if the previous writing is not completed, the process is directly transferred to another task.

【0074】以上のようにして当該セクタの全バイトに
対して「0」の書込みを終えると、ステップS2503
からステップS2505へ進み、当該セクタの管理フラ
グを、「前処理済」を示す状態にセットする。そして、
引き続き、他のセクタについて前処理を行うために、ス
テップS2501へ戻る。
When the writing of "0" is completed for all the bytes of the sector as described above, step S2503.
From step S2505, the management flag of the sector is set to a state indicating "preprocessed". And
Subsequently, the process returns to step S2501 to perform preprocessing for other sectors.

【0075】<FATキャッシュ>本システムでは、書
き込み発生の度に記憶場所を変更し、その度に「未使用
セクタ」が発生する。そこで、使用頻度の多い部分を特
に優先的にバッファリングするキャッシュが有ればトー
タルの書き込み頻度が激減する事が予想される。キャッ
シュとして用意するメモリは多ければ多いほど良いが、
システムのメモリには限界がある。
<FAT cache> In this system, the memory location is changed each time a write occurs, and an "unused sector" occurs each time. Therefore, it is expected that the total writing frequency will be drastically reduced if there is a cache that preferentially buffers the frequently used portion. The more memory you prepare as a cache, the better,
System memory is limited.

【0076】本来使用頻度の高いセクタのデータは、キ
ャッシュ中に存在する確率も高いが、使用頻度の低いセ
クタを大量に読み書きした場合、当然キャッシュから吐
き出されることになる。
Although the data of a sector which is originally frequently used is highly likely to be present in the cache, when a large number of sectors which are rarely used are read and written, they are naturally discharged from the cache.

【0077】そこで、ファイルシステムが管理する管理
領域を優先的にキャッシングする様に構成すれば、スル
ープットの向上を期待できる。なぜならファイルシステ
ムの管理領域は頻繁に更新されているからである。
Therefore, if the management area managed by the file system is configured to be preferentially cached, an improvement in throughput can be expected. This is because the management area of the file system is updated frequently.

【0078】パーソナルコンピュータで普及しているM
S−DOSのFATシステムの場合、720kや1.4
Mといったフォーマット形式では1クラスタが1セクタ
で構成されている為、シーケンシャルにファイルを読む
場合でも2回に1回はFATを読まなければならない。
ファイルを書く場合は、さらにたくさんのFATアクセ
スが発生する。このため、システム中にたくさんのファ
イルがオープンされるとキャッシュのヒット率が落ちて
しまう。
M widely used in personal computers
For S-DOS FAT system, 720k or 1.4
In the format format such as M, one cluster is composed of one sector, so even if the file is read sequentially, the FAT must be read once every two times.
When writing a file, more FAT accesses occur. Therefore, if many files are opened in the system, the cache hit rate drops.

【0079】アプリケーションソフトウェアにもよる
が、FATシステムにおいてFATのみを対処にしたキ
ャッシュは、DISK全体を対象にしたキャッシュに対
して1/2のメモリで同等のヒット率を確保できる。図
11はキャッシュソフトウエアの階層的な位置付けを表
す図である。キャッシュのソフトウェアは図11の様に
ファイルシステムとフラッシュROMの中間的な場所と
なる。
Although it depends on the application software, the cache that deals with only FAT in the FAT system can secure an equivalent hit rate with a memory half that of the cache for the entire DISK. FIG. 11 is a diagram showing the hierarchical positioning of cache software. The cache software is an intermediate location between the file system and the flash ROM as shown in FIG.

【0080】図12はキャッシュの主記憶上のデータ構
造を表わす図である。片方向線形リスト構造でバッファ
全体を管理している。検索方向順にデータが古くなって
いる。論理セクタ番号が12,11,6,5の順番でア
クセスすれば、図12に示されるような順番となる。ま
た、各セクタには、変更フラグが設けられており、キャ
ッシュ上でデータの更新があった場合、変更フラグがF
ALSEからTRUEに変化する。このようなFATキ
ャッシュの読み出し手順、及び書き込み手順を図13、
14を参照して説明する。図13はFATキャッシュの
読み出し手順を表すフローチャートである。図14はF
ATキャッシュの書込み手順を表すフローチャートであ
る。
FIG. 12 is a diagram showing the data structure on the main memory of the cache. The entire buffer is managed by a one-way linear list structure. The data is outdated in the order of search direction. If access is made in the order of logical sector numbers 12, 11, 6, and 5, the order will be as shown in FIG. Further, each sector is provided with a change flag, and when data is updated on the cache, the change flag is set to F.
Change from ALSE to TRUE. A read procedure and a write procedure of such a FAT cache are shown in FIG.
This will be described with reference to FIG. FIG. 13 is a flowchart showing the procedure for reading the FAT cache. Figure 14 is F
It is a flowchart showing the writing procedure of AT cache.

【0081】図13において、ステップS1501でN
セクタの読み出しを開始する。ステップS1502でN
セクタがFATかどうかを判断する。FATでなけれ
ば、ステップS1509でフラッシュROM15からデ
ータを読み出す。
In FIG. 13, N is returned in step S1501.
Start reading the sector. N in step S1502
Determine if the sector is FAT. If it is not FAT, data is read from the flash ROM 15 in step S1509.

【0082】一方、ステップS1502でNセクタがF
ATならステップS1503へ進み、キャッシュリスト
を検索する。ここでは、図12で説明した片方向線形リ
ストを検索することになる。キャッシュ中にNセクタが
存在すればステップS1507へ進み、Nセクタのバッ
ファからデータを読み出す。
On the other hand, in step S1502, the N sector is F
If it is AT, the process advances to step S1503 to search the cache list. Here, the one-way linear list described with reference to FIG. 12 is searched. If N sectors exist in the cache, the flow advances to step S1507 to read data from the N sector buffer.

【0083】また、ステップS1503でNセクタがキ
ャッシュリスト中に存在しなかった場合は、ステップS
1504へ分岐し、最も長くアクセスされていないセク
タのデータ(図12ではセクタ番号12のデータ)の吐
き出しを行う。まず、ステップS1504では、キャッ
シュリストの最後の項の変更フラグを判断する。もし変
更フラグがTRUEなら、ステップS1505へ進み、
変更内容をフラッシュROM15へ書き込む。変更が無
い(変更フラグがFALSEの場合)なら、そのままス
テップS1506へ制御を移す。読み出し手順の中で書
き込みを行うのは奇妙に思うかもしれないが、バッファ
がキャッシュの吐き出しが起こるまで極力書き込み動作
を行わない方が効率が良い。
If N sector is not present in the cache list in step S1503, step S1503 is executed.
The process branches to 1504, and the data of the sector that has not been accessed for the longest (data of sector number 12 in FIG. 12) is discharged. First, in step S1504, the change flag of the last item in the cache list is determined. If the change flag is TRUE, processing proceeds to step S1505,
The changed contents are written in the flash ROM 15. If there is no change (when the change flag is FALSE), control is directly transferred to step S1506. It may seem strange to write during the read procedure, but it is more efficient not to do any write operations until the buffer is flushed out of the cache.

【0084】ステップS1506でフラッシュROM1
5からリスト最後のバッファへNセクタの内容を読み出
す。ステップS1507でNセクタのバッファからデー
タを読み出す。ステップS1508でNセクタのバッフ
ァをキャッシュリストの先頭へ移動させる。これは、図
12において、各セクタが有する「次のバッファー」
(次のバッファーを示すアドレス)の値を変更すること
で達成される。FATキャッシュへのアクセスが行われ
る度にステップS1508の動作が繰り返されること
で、自然にアクセスされないバッファがリストの先頭か
ら最後に向かってシフトしていく。よって、ステップS
1504でリスト最後のバッファを選ぶのは、最も古い
バッファを吐き出す為である。
In step S1506, the flash ROM 1
The contents of N sectors are read from 5 to the last buffer in the list. In step S1507, data is read from the N sector buffer. In step S1508, the N sector buffer is moved to the head of the cache list. This is the "next buffer" that each sector has in FIG.
This is achieved by changing the value of (address indicating the next buffer). The operation of step S1508 is repeated every time the FAT cache is accessed, so that the buffers that are not naturally accessed shift from the head of the list toward the end. Therefore, step S
The buffer at the end of the list is selected in 1504 because the oldest buffer is discharged.

【0085】次に図14を参照して書込み手順を説明す
る。
Next, the writing procedure will be described with reference to FIG.

【0086】ステップS1600でNセクタの書き込み
を開始する。ステップS1601では、NセクタがFA
Tかどうかを判断する。FATでなければ、ステップS
1608へ進み、フラッシュROM15へのデータの書
き込みを実行する。
In step S1600, writing of N sectors is started. In step S1601, N sector is FA
Judge whether it is T or not. If not FAT, step S
In step 1608, the writing of data to the flash ROM 15 is executed.

【0087】一方、ステップS1601でNセクタがF
ATならば、ステップS1602へ進み、キャッシュリ
ストを検索する。キャッシュ中にNセクタが存在すれば
ステップS1606へ進み、Nセクタのバッファへデー
タの書き込みを実行する。
On the other hand, in step S1601, N sector is F
If it is AT, the process advances to step S1602 to search the cache list. If there are N sectors in the cache, the flow advances to step S1606 to write data in the N sector buffer.

【0088】また、ステップS1602でNセクタがキ
ャッシュリスト中に存在しなかった場合は、ステップS
1603へ分岐し、バッファから最も長くアクセスされ
ていないセクタの吐き出しを行うとともに、Nセクタを
キャッシュに登録する。まず、ステップS1603でキ
ャッシュリストの最後の項の変更フラグを判断する。も
し変更フラグがTRUEなら、ステップS1604で変
更内容をフラッシュROMへ書き込み、ステップS16
05へ進む。また、変更が無いなら(変更フラグがFA
LSEなら)そのままステップS1605へ制御を移
す。ステップS1605では、キャッシュリストの最後
の項をNセクタとする。その後、ステップS1606
で、Nセクタのバッファへデータの書込みを実行する。
If N sectors are not present in the cache list in step S1602, step S1602 is executed.
The process branches to 1603 to eject the sector that has not been accessed for the longest time from the buffer and register N sectors in the cache. First, in step S1603, the change flag of the last item in the cache list is determined. If the change flag is TRUE, the contents of the change are written in the flash ROM in step S1604, and step S16
Go to 05. If there is no change (change flag is FA
If it is LSE), control is directly transferred to step S1605. In step S1605, the last item of the cache list is set to N sector. After that, step S1606
Then, writing of data to the buffer of N sectors is executed.

【0089】その後、ステップS1607でN、セクタ
のバッファをキャッシュリストの先頭へ移動させる。書
き込み手順の中でフラッシュROMへの書き込みを行わ
ないのは奇妙に思うかもしれないが、キャッシュの吐き
出しが起こるまで極力書き込み動作を行わない方が効率
が良い。
After that, in step S1607, the buffers of N and sector are moved to the head of the cache list. It may be strange that writing to the flash ROM is not performed in the writing procedure, but it is more efficient not to perform writing operation as much as possible until the cache is flushed.

【0090】また、ステップS1501及びステップS
1601における、FATの判断であるが、ICカード
等の完全に上位層(ファイルシステム)の情報を共有で
きないシステムでも、書き込みデータの内容を解析する
ことでFAT領域の場所を特定できる。なぜならば、論
理セクタOに相当する部分にFATの位置等の情報か格
納されていることが決まっているからである。
Also, step S1501 and step S
Regarding the FAT determination in 1601, the location of the FAT area can be specified by analyzing the contents of the write data even in a system such as an IC card that cannot completely share information of the upper layer (file system). This is because it is determined that information such as the FAT position is stored in the portion corresponding to the logical sector O.

【0091】<フラッシュROMへの1バイトの書き込
み>フラッシュROM15に対する全ての(管理領域を
含む)読み書きは、最終的に1バイトの読み書き命令に
よって実行される。フラッシュROM15の書き込みに
は、通常のPROM同様の時間がかかる。1バイトの書
き込みが終了するまでは、同じチップへの書き込みはで
きない。書き込み終了信号として信号線が用意されてい
るチップと特別な信号が用意されていないチップがあ
る。後者の場合は、データポーリングと言う手法で書き
込み終了を確認しなければならない。データポーリング
とは、ベリファイに非常によく似た方法で、書き込みデ
ータと読み出しデータが一致するまで待つビジー制御方
法である。
<Writing of 1 Byte to Flash ROM> All reading and writing (including the management area) with respect to the flash ROM 15 is finally executed by a 1-byte read / write command. Writing to the flash ROM 15 takes the same time as a normal PROM. It is not possible to write to the same chip until the writing of 1 byte is completed. Some chips have a signal line as a write end signal and some have no special signal. In the latter case, the write end must be confirmed by a method called data polling. Data polling is a busy control method that waits until the write data and read data match, in a manner very similar to verify.

【0092】信号線によって書き込み終了を知ることが
出来る場合は、CPU5への割り込みと併用して書き込
み待ち中のCPUタイムを別のタスクへ割り当てること
ができる。
When the completion of writing can be known by the signal line, the CPU time waiting for writing can be assigned to another task in combination with the interruption to the CPU 5.

【0093】上述のように、信号線が無いチップの場合
は、データポーリングを行なわなければならない。デー
タ書き込みの効率をあげる為にはいくつものチップに対
してパイプライン的に書き込みを行い、データポーリン
グ時間のロスを押さえなければならない。そのため、1
バイトの書き込みが完了する前に次の動作へ制御を移す
必要がある。新たな読み書きを行う前に以前の書き込み
が完了しているかどうかを確認するのが良い。図15
は、その様子をC言語で表現したものである。
As described above, in the case of a chip having no signal line, data polling must be performed. In order to improve the efficiency of data writing, it is necessary to write in a pipeline to several chips to suppress the loss of data polling time. Therefore, 1
Control must be passed to the next operation before the byte write is complete. Before doing a new read or write, it's a good idea to check if the previous write is complete. FIG.
Is a representation of the situation in C language.

【0094】図15の1行目は、データ書き込みを行う
関数の入り口である。最初の引数は最後に書き込んだア
ドレスとデータを保存するための構造体へのポインタ、
第2の引数は書き込むアドレス、第2の引数は書き込む
データである。
The first line in FIG. 15 is the entrance of a function for writing data. The first argument is a pointer to a structure to save the last written address and data,
The second argument is a write address, and the second argument is write data.

【0095】3行目では、最後に書き込んだアドレスを
参照してチップに書かれたデータと最後に書いたデータ
を比較して、両者が一致するまでループを実行する。こ
れがデータポーリングである。前回の書き込みが完了す
るとこのループから抜け出す。
On the third line, the last written address is referred to and the data written to the chip is compared with the last written data, and the loop is executed until the two match. This is data polling. When the previous writing is completed, it exits from this loop.

【0096】4行目で新しいアドレスへDataを書き
込む。5行目と6行目で、今回書いたアドレスとデータ
を保存する。この情報は、次のデータポーリングで利用
される。
Data is written to a new address on the fourth line. On the 5th and 6th lines, save the address and data you wrote this time. This information is used in the next data polling.

【0097】リスト7行目のRotateRdyQueueは、自タス
クの次に実行されるべき同一プライオリティの実行可能
状態のタスクへCPUを譲るオペレーティングシステム
のシステムコールである。
RotateRdyQueue on the 7th line of the list is a system call of the operating system that yields the CPU to the task in the ready state of the same priority which should be executed next to the own task.

【0098】9行目は読み出し関数の入り口である。第
1の引数はアドレスとデータを保存するための構造体へ
のポインタ、第2の引数は読み出すアドレスである。こ
の関数は上位のプログラムに対して第2の引数で指定さ
れたアドレスに格納されたデータを返す。
The ninth line is the entrance of the read function. The first argument is a pointer to a structure for storing the address and data, and the second argument is the address to read. This function returns the data stored in the address specified by the second argument to the upper program.

【0099】11行目では、もし読み出そうとしたアド
レスが最後に書き込んだアドレスなら戻す値は最後に書
き込んだデータなので構造体の中に保存された情報を返
す。12行目は3行目と同じようなデータポーリングで
ある。データポーリングに成功しないと同じチップの別
のアドレスを読むことができない。データポーリングが
終わって13行目で指定したアドレスの内容を戻してい
る。
In line 11, if the address to be read is the last written address, the value to be returned is the last written data, and the information stored in the structure is returned. The 12th line is data polling similar to the 3rd line. Only after successful data polling can another address on the same chip be read. After the data polling is completed, the contents of the address specified on the 13th line are returned.

【0100】1チップへの書き込みを以上の様な構成に
しておけば、チップ数と書き込みタスクを増やすだけで
確実に見かけ上の書き込み速度を向上させることができ
る。また、全体のスループットを上げる為にわざとチッ
プ数分のセクタバッファを用意(2チップなら2セク
タ)して書き込む内容がバッファに溜まるまで処理しな
いようにすると効果がある。
If the writing to one chip is configured as described above, the apparent writing speed can be surely improved only by increasing the number of chips and the writing task. Further, in order to increase the overall throughput, it is effective to intentionally prepare sector buffers for the number of chips (2 sectors for 2 chips) so that the contents to be written are not processed until they are accumulated in the buffer.

【0101】図15のプログラムの特徴的なところは、
データポーリングをデータ書き込み直後に行うのではな
く、次の書き込みの前に行うことである。そのために前
回書いたアドレスとデータを保存しておくRAM領域を
チップごとに確保し構造体「struct DEV」として格納し
ているのである。
The characteristic feature of the program shown in FIG.
Data polling is not performed immediately after writing data, but is performed before the next writing. Therefore, the RAM area for storing the previously written address and data is secured for each chip and stored as a structure "struct DEV".

【0102】図39は、本実施形態におけるフラッシュ
ROMへの1バイトデータの書込み手順を表すフローチ
ャートである。本フローチャートは、1つのフラッシュ
ROMチップへの書込みの制御手順を示している。ステ
ップS2601では、前回の書込み処理が完了したか否
かを判断する。前回の書込み処理が終了していなければ
ステップS2604へ進み、そのまま他のタスクへ制御
を移す。
FIG. 39 is a flow chart showing the procedure for writing 1-byte data to the flash ROM in this embodiment. This flowchart shows a control procedure for writing to one flash ROM chip. In step S2601, it is determined whether the previous writing process has been completed. If the previous writing process has not been completed, the process advances to step S2604, and control is transferred to another task.

【0103】一方、前回の書込み処理が終了していれ
ば、次の書込みデータを準備し、これをDRAM14へ
保存する。上述のステップS2601における書込み終
了の判断は、フラッシュROMに書き込まれたデータ
と、このステップS2602で保持されたデータとの比
較によって行われる。
On the other hand, if the previous write processing is completed, the next write data is prepared and stored in the DRAM 14. The determination of the end of writing in step S2601 described above is made by comparing the data written in the flash ROM with the data held in step S2602.

【0104】続いて、ステップS2603において、デ
ータの書込みを開始する。以上のような処理によれば、
複数のフラッシュROMチップに対して、複数のタスク
で書き込みを行うような場合に、いわゆるラウンドロビ
ン方式を適用した書き込み処理が可能となり、複数のR
OMチップに対して効率良くデータの書き込みが行え
る。なお、マルチタスクの管理プログラムは、上述のR
OM13に格納されている。組み込みようのリアルタイ
ムOSとしては、VxWorks(商標)やpSOS(商標)等が
市販されており、ROM13にこれらのようなリアルタ
イムOSが格納されている。
Then, in step S2603, data writing is started. According to the above processing,
In the case of writing to a plurality of flash ROM chips by a plurality of tasks, it becomes possible to perform a writing process to which a so-called round robin method is applied, and a plurality of R
Data can be efficiently written to the OM chip. Note that the multitask management program is
It is stored in the OM 13. VxWorks (trademark), pSOS (trademark) and the like are commercially available as real-time OSs to be incorporated, and the ROM 13 stores such real-time OSs.

【0105】<フラッシュROM書き込み電源の共有化
>データの書き込みや消去の際にPROM同様に12V
等の特別な書き込み電圧を必要とするチップや、書き込
み電圧を与えることで書き込みが高速になるチップがあ
る。この様なチップを使用する場合に専用のDC/DC
コンバータ等の電圧発生部を設けると電子カメラのコス
トアップにつながる。ところが、従来よりカメラにはス
トロボの充電や、機構部分やCCDの駆動等、特別な電
圧が必要な部分がありDC/DCコンバータ等を搭載し
ている。そこで、フラッシュROMの書き込み電圧とス
トロボ充電やメカ駆動を時分割多重で行うことで、少容
量のDC/DCコンバータでシステムを構築でき、シス
テムのコストを押さえることができる。
<Sharing of Flash ROM Writing Power Supply> At the time of writing and erasing data, 12V as in PROM
There is a chip that requires a special write voltage, such as a chip, or a chip that writes at a high speed by applying the write voltage. Dedicated DC / DC when using such a chip
Providing a voltage generator such as a converter increases the cost of the electronic camera. However, conventionally, a camera has a portion requiring a special voltage, such as charging a strobe, driving a mechanical portion or a CCD, and is equipped with a DC / DC converter or the like. Therefore, the writing voltage of the flash ROM, strobe charging, and mechanical driving are performed by time division multiplexing, so that the system can be constructed with a small capacity DC / DC converter, and the system cost can be suppressed.

【0106】図16は、DC/DCコンバータの出力容
量を越えない様に電源を管理するプログラムをC言語で
表現したものである。Line1〜6が1ステップのズ
ームアップ関数で、Line7〜13がフラッシュRO
Mへ1セクタ書き込む書き込み関数である。ズームアッ
プ関数はLine3でDC/DCコンバータの資源管理
用のセマフォ“SemDCDC”を獲得して、モータを
1ステップ動かす関数をLine4で呼び出す。モータ
駆動が終わるとDC/DCコンバータの資源管理用のセ
マフォ“SemDCDC”を開放する。セマフォはマル
チタスクのオペレーティングシステムで資源を管理する
為の一般的な方法であり、多くのオペレーティングシス
テムがシステムコールとして用意している。
FIG. 16 shows a program for managing the power supply in C language so as not to exceed the output capacity of the DC / DC converter. Lines 1 to 6 are one-step zoom-up functions, and Lines 7 to 13 are flash ROs.
This is a write function for writing one sector to M. As the zoom-up function, the semaphore “SemDCDC” for resource management of the DC / DC converter is acquired in Line3, and the function that moves the motor one step is called in Line4. When the motor driving is completed, the semaphore “SemDCDC” for resource management of the DC / DC converter is opened. A semaphore is a common method for managing resources in a multitasking operating system, and many operating systems provide it as a system call.

【0107】即ち、Line3で既に“SemDCD
C”が他のタスクによって使用されていたとすると、他
のタスクがセマフォ“SemDCDC”を開放するまで
ズームアップをしようとしたタスクの実行が保留され
る。
That is, in Line 3, “SemDCD” has already been entered.
If C "is being used by another task, execution of the task that tried to zoom up is suspended until the other task releases the semaphore" SemDCDC ".

【0108】書き込み関数はLine9でセマフォ“S
emDCDC”を獲得し、フラッシュROMへ1セクタ
のデータを書き込む。Line11でデータポーリング
を行い最後の書き込みが終了したことを確認したら、L
ine12でセマフォ“SemDCDC”を開放する。
このようにプログラムを構成すれば、ズームアップとフ
ラッシュROMの書き込みを同時に行うことは無くな
る。ズームは1ステップ単位であり、書き込みはセクタ
単位なので非常に短い保留時間の後に必ず電源を獲得で
きる。
The write function is Line 9 and the semaphore “S
emDCDC "and write one sector of data to the flash ROM. When line 11 performs data polling and confirms that the last write is completed, L
The semaphore "SemDCDC" is opened by ine12.
By configuring the program in this way, it is not necessary to perform zoom-in and writing to the flash ROM at the same time. Since the zoom is in 1-step units and the writing is in sector units, power can always be acquired after a very short hold time.

【0109】図16について更に説明すると、図16の
Line1はズームアップする関数の入り口である。本
関数には引数はない。Line3で電源の使用権利とし
て宣言したSemDCDCの権利を一つ獲得する。この時、使
用権利が1つもなければこの関数を呼び出したタスクの
実行は保留される。電源の使用権利を別のタスクが解放
すればZoomUpを呼び出したタスクが再び実行可能状態に
戻る。そして、Line4のモーターを動かす関数を呼
び出すことができる。そして、Line5で、電源使用
権利を返却してこの関数の仕事は終了する。Line7
は1セクタのデータをEEPROMに書き込む関数の入
り口であり、Line9de電源利用権利を獲得してL
ine12で返却している。
To further explain FIG. 16, Line 1 in FIG. 16 is an entrance of a function for zooming up. This function has no arguments. Acquire one right of SemDCDC declared as the right to use the power supply in Line3. At this time, if there is no usage right, execution of the task that called this function is suspended. If another task releases the right to use the power supply, the task that called ZoomUp returns to the executable state again. Then, it is possible to call a function that drives the Line 4 motor. Then, in Line 5, the power use right is returned and the work of this function ends. Line7
Is the entrance of the function to write the data of 1 sector to EEPROM.
It is returned at ine12.

【0110】図40は、上述した電源の共有手順を説明
するためのフローチャートである。同図において、ステ
ップS1701で、電源コントローラ9によるDC/D
Cコンバータ8の出力電力の供給が解放されたか否かを
判断する。ステップS1702では、電源確保のための
指示の内容を解析し、この指示結果に従って、ステップ
S1703、1705、1707、1709のいずれか
に分岐する。
FIG. 40 is a flow chart for explaining the above-described power sharing procedure. In the figure, in step S1701, DC / D by the power supply controller 9
It is determined whether or not the supply of the output power of C converter 8 is released. In step S1702, the content of the instruction to secure the power supply is analyzed, and in accordance with the instruction result, the process branches to one of steps S1703, 1705, 1707, and 1709.

【0111】指示の内容が、CCD駆動電力の供給であ
れば、ステップS1703へ進み、CCD2に対してC
CD駆動のための電力を供給する。そして、ステップS
1704にて、CCD駆動の終了(即ち撮影動作の終
了)を検出すると、ステップS1711へ進み、電源の
解放を行う。また、ストロボの充電要求であれば、ステ
ップS1705へ進み、電源コントローラ9に対してス
トロボ21に対する充電電力を提供させる。そして、ス
テップS1706でストロボの充電を完了したら、ステ
ップS1711へ進み、電源の解放を行う。なお、充電
の電力供給は、所定時間の充電を行う毎に他の電源供給
のために電源を解放する。即ち、ストロボ21への充電
を管理するプログラムは別個に所定のタスクに存在し、
充電の完了はそのタスクによって管理される。
If the content of the instruction is the supply of the CCD drive power, the flow advances to step S1703 to set C for CCD2.
It supplies power for CD drive. And step S
When the end of CCD driving (that is, the end of the shooting operation) is detected in 1704, the process advances to step S1711 to release the power supply. If it is a strobe charging request, the flow advances to step S1705 to cause the power supply controller 9 to provide charging power for the strobe 21. When the charging of the strobe is completed in step S1706, the process advances to step S1711 to release the power supply. Regarding the power supply for charging, the power supply is released to supply another power supply every time charging is performed for a predetermined time. That is, the program for managing the charging of the strobe 21 exists separately in a predetermined task,
The completion of charging is managed by that task.

【0112】指示の内容が、ズーム機構の駆動であれ
ば、ステップS1707へ進み、ズーム機構の駆動系
(不図示)へ電力供給を行う。そしてステップS170
8で、1ステップのズーム動作を終えたらステップS1
711へ進み、電源を解放する。更に、指示の内容がフ
ラッシュROMへの書込みであれば、ステップS170
9へ進み、フラッシュROM15への書込み電力を供給
する。1セクタ分の書込みが終えたら、ステップS17
10からステップS1711へ進み、電源を解放する。
If the content of the instruction is to drive the zoom mechanism, the flow advances to step S1707 to supply power to the drive system (not shown) of the zoom mechanism. And step S170
When the zoom operation of one step is completed in step 8, step S1
Proceed to 711 to release the power supply. Furthermore, if the content of the instruction is writing to the flash ROM, step S170.
9, the writing power to the flash ROM 15 is supplied. When the writing for one sector is completed, step S17
From step S1711, the power is released.

【0113】なお、ステップS1704、1706、1
708、1710において、各動作の終了を待つが、こ
の待ちループにおいて、他のタスクへの制御が移り、マ
ルチタスク処理が遂行される。この管理処理は、各タス
クから随時起動が可能であり、複数のタスクで同時に起
動される可能性もある為、ステップS1701で電源解
放のチェックを行っている。
Incidentally, steps S1704, 1706, 1
At 708 and 1710, the completion of each operation is awaited. In this waiting loop, control is transferred to another task and multitask processing is performed. This management process can be started from any task at any time, and may be started simultaneously by a plurality of tasks. Therefore, the power release is checked in step S1701.

【0114】以上の図40のフローチャートによれば時
分割で電源を利用することが可能となる。しかしなが
ら、すべてのシステム(CCD/ストロボ/ズーム/フ
ラッシュROM)が依存しあった1つのプログラムであ
る。このようなソフトウエアを開発すると、開発/デバ
ッグ/メンテナンスのコストが大きくなり、拡張性や柔
軟性を保つのが難しくなる。
According to the flow chart of FIG. 40 described above, it is possible to use the power supply in a time sharing manner. However, it is one program that all systems (CCD / strobe / zoom / flash ROM) depend on. When such software is developed, development / debugging / maintenance costs increase, and it becomes difficult to maintain expandability and flexibility.

【0115】そこで、電源を1つの資源に見立ててOS
の提供する資源管理機能を用いることで開発効率を向上
させることができる。そこで上述のセマフォによる資源
管理を行う。即ち、CCDの駆動部、ストロボの駆動
部、ズームの駆動部、フラッシュROMの駆動部のそれ
ぞれの制御プログラムが、電源という資源(セマフォ)
を獲得、解放することで、時分割された電源の割当てが
行える。
Therefore, the power source is regarded as one resource and the OS is
Development efficiency can be improved by using the resource management function provided by. Therefore, the resource management by the semaphore described above is performed. That is, the control programs for the CCD drive unit, strobe drive unit, zoom drive unit, and flash ROM drive unit are resources (semaphores) called power sources.
Power can be allocated in a time-sharing manner by acquiring and releasing.

【0116】図48は本実施形態による電源の時分割利
用を説明する図である。同図に示されるように、あるタ
スクA(例えばCCD)によって電源要求が発生したと
き、電源セマフォが解放された状態にあれば、そのセマ
フォを獲得して、電源を占有する(ステップS2001
〜S2003)。続いてステップS2004において、
当該電源よりの電力供給を得て所定の処理を行うと、ス
テップS2005へ進んでセマフォを解放する。
FIG. 48 is a diagram for explaining the time division use of the power source according to this embodiment. As shown in the figure, when a power request is generated by a certain task A (for example, CCD), if the power semaphore is in a released state, the semaphore is acquired and the power is occupied (step S2001).
~ S2003). Then, in step S2004,
When power is supplied from the power source and a predetermined process is performed, the process proceeds to step S2005 to release the semaphore.

【0117】一方タスクAより遅れて電源獲得を要求し
たタスクBでは、ステップS2011における電源要求
ではセマフォを獲得できず、ステップS2012によ
り、セマフォの解放待ちとなる。そして、タスクAより
セマフォが解放されると、このセマフォをタスクBが獲
得して、電源を占有する(ステップS2013)。その
後タスクBで所定の処理を実行し(ステップS201
4)、電源を解放する(ステップS2015)。
On the other hand, task B, which requested power acquisition later than task A, cannot acquire the semaphore by the power request in step S2011, and waits for release of the semaphore in step S2012. When the semaphore is released from task A, task B acquires this semaphore and occupies the power source (step S2013). After that, predetermined processing is executed in task B (step S201
4) The power is released (step S2015).

【0118】以上のようなセマフォによる電源資源の管
理により、電源の時分割利用が可能となる。
By managing the power source resource by the semaphore as described above, the power source can be used in a time-division manner.

【0119】なお、図48によれば、電源資源の利用権
利を示すセマフォが一つしかないが、複数個のセマフォ
が存在するようにしても良いことは言うまでもない。
According to FIG. 48, there is only one semaphore indicating the right to use the power source resource, but it goes without saying that a plurality of semaphores may exist.

【0120】<実施形態の電子カメラの動作説明>図1
7は、本実施形態のリブートからサービスの開始までの
動作手順を表わすフローチャートである。ステップS1
01でシステムがリブートすると、ステップS102で
フラッシュROM15の管理領域をスキャンし、DRA
M14上に記憶場所管理テーブル140を作成する。ま
た、この処理と並行して、DRAM14上の未使用セク
タカウンタ、使用済セクタカウンタ、使用中セクタカウ
ンタへ、それぞれの状態に対応するセクタがいくつ有る
かを数え、セットする。このカウンタは、後にフラッシ
ュROM15に対して操作を行ったときに更新され、記
憶効率を判断するのに用いられる。その後、ステップS
103へ進み、各種のサービスを開始する。
<Description of Operation of Electronic Camera of Embodiment> FIG. 1
FIG. 7 is a flowchart showing an operation procedure from the reboot of the present embodiment to the start of the service. Step S1
When the system reboots at 01, the management area of the flash ROM 15 is scanned at step S102, and the DRA
A storage location management table 140 is created on M14. In parallel with this processing, the unused sector counter, used sector counter, and in-use sector counter on the DRAM 14 are counted and set to the number of sectors corresponding to the respective states. This counter is updated later when the flash ROM 15 is operated, and is used to judge the storage efficiency. Then, step S
Proceed to 103 to start various services.

【0121】図18は、指定セクタの読み出しサービス
の手順を表わすフローチャートである。まず、ステップ
S201でNセクタの読み出しを開始する。ステップS
202では、Nセクタをロックする。セクタのロックは
ロック変数を使って行う。このロック変数は、記憶場所
管理テーブル140で各セクタの記憶場所とともに管理
される。ステップS202では、セクタが既に他のタス
クによってロックされている場合、他のタスクによって
アンロックされるのを待ち、他のタスクによってアンロ
ックされた後で当該セクタのロックを行う。ロックした
セクタはステップS206でアンロックするまでの間、
自タスクによって占有することが出来る。
FIG. 18 is a flow chart showing the procedure of the read service of the designated sector. First, in step S201, reading of N sectors is started. Step S
At 202, N sectors are locked. Sectors are locked using lock variables. This lock variable is managed in the memory location management table 140 together with the memory location of each sector. In step S202, if the sector is already locked by another task, it waits for it to be unlocked by another task, and then the sector is locked after being unlocked by another task. Until the locked sector is unlocked in step S206,
It can be occupied by its own task.

【0122】ステップS202で論理セクタをロックす
ると、ステップS203で記憶場所管理テーブルを参照
して、当該セクタに有効なデータ記憶されているかどう
かを確認する。有効なデータが記録されて無い場合は、
ステップS204へ分岐する。ステップS204では、
ダミーのデータ(例えば全部0など)をセクタの内容と
して読み出す。ステップS203で有効なデータが格納
されていると判断された場合は、ステップS205へ分
岐する。ステップS205では記録場所管理テーブルの
値を元にフラッシュROM(または主記憶)からデータ
を読み出す。
When the logical sector is locked in step S202, the storage location management table is referenced in step S203 to confirm whether valid data is stored in the sector. If no valid data is recorded,
It branches to step S204. In step S204,
Dummy data (for example, all 0s) is read as the contents of the sector. If it is determined in step S203 that valid data is stored, the process branches to step S205. In step S205, data is read from the flash ROM (or main memory) based on the values in the recording location management table.

【0123】ここで、ガベージコレクションを実行中で
Nセクタが主記憶(DRAM14)へ退避されていた場
合は、記憶場所管理テーブルのポインタは主記憶をポイ
ンティングとしている。また、図中点線で囲んだ部分は
Nセクタを占有している期間である。この様なロック機
構によって1つのセクタ操作の安全性を保証している
為、ガベージコレクションの途中でも操作中でないセク
タを自由に読み出すことが可能となっている。
Here, when garbage collection is in progress and N sectors have been saved to the main memory (DRAM 14), the pointer of the memory location management table points to the main memory. Further, the portion surrounded by the dotted line in the figure is a period in which N sectors are occupied. Since the security of one sector operation is guaranteed by such a lock mechanism, it is possible to freely read out the sector which is not being operated even during the garbage collection.

【0124】図19は論理セクタの書き込みサービスの
手順を表わすフローチャートである。ステップS301
でNセクタの書き込みを開始する。ステップS302で
ステップS202と同様に、論理セクタのロックを行
う。
FIG. 19 is a flow chart showing the procedure of the logical sector write service. Step S301
Then, writing of N sectors is started. In step S302, as in step S202, the logical sector is locked.

【0125】次に、ステップS303で、記憶場所管理
テーブルを検索して、Nセクタに有効なデータが記録さ
れているかどうかを判断する。有効なデータが記録され
ていればステップS304へ、記録されてないならばス
テップS305へそれぞれ分岐する。ステップS304
では、それまで有効なデータとして記録されていたフラ
ッシュROM(または主記憶)のデータを破棄する。ス
テップS304におけるデータ破棄の処理は、図21の
フローチャートを用いて詳しく説明を加える。ステップ
S304の後ステップS305へ制御が移る。
Next, in step S303, the storage location management table is searched to determine whether or not valid data is recorded in the N sector. If valid data is recorded, the process branches to step S304, and if not, the process branches to step S305. Step S304
Then, the data in the flash ROM (or main memory) that has been recorded as valid data until then is discarded. The data discarding process in step S304 will be described in detail with reference to the flowchart of FIG. After step S304, control proceeds to step S305.

【0126】ステップS305では、フラッシュROM
15においてNセクタを書き込むための記憶領域を獲得
する。ステップS305における記憶領域の獲得手順は
図23を用いて詳しく説明を加える。ステップS305
で正常に記憶領域の獲得に成功すれば、ステップS30
8へ制御を移す。ステップS308では獲得したフラッ
シュROM15の領域へNセクタのデータを書き込む。
In step S305, the flash ROM
At 15, a storage area for writing N sectors is acquired. The storage area acquisition procedure in step S305 will be described in detail with reference to FIG. Step S305
If the storage area is successfully acquired in step S30, step S30
Control is transferred to 8. In step S308, N sector data is written in the acquired area of the flash ROM 15.

【0127】一方、ステップS305でフラッシュRO
Mに記憶場所が無い場合、即ち記憶領域の獲得に失敗し
た場合はステップS306へ分岐する。ステップS30
6はデータの退避用に主記憶を獲得する。主記憶の領域
確保はオペレーティングシステムが提供するメモリ管理
機能によって行う。これはC言語でalloc関数に相
当する機能である。そして確保した領域を片方向線形リ
スト構造によって管理する。
On the other hand, in step S305, the flash RO
If there is no storage area in M, that is, if acquisition of the storage area fails, the process branches to step S306. Step S30
6 acquires main memory for saving data. The main memory area is secured by the memory management function provided by the operating system. This is a function corresponding to the alloc function in C language. Then, the secured area is managed by the one-way linear list structure.

【0128】図20は主記憶上に獲得した退避データリ
ストの様子である。(a)は退避データリストにデータ
が無い状態であり、リストには、END_OF_LIST が代入さ
れている。(b)は退避データリストに、セクタ番号
3,20,221の各セクタの内容が退避されている状
態である。
FIG. 20 shows the saved data list acquired on the main memory. In (a), there is no data in the saved data list, and END_OF_LIST is assigned to the list. (B) is a state where the contents of each sector of sector numbers 3, 20, and 221 are saved in the saved data list.

【0129】ステップS309で、記録場所管理テーブ
ルを更新する。ここで、記録したフラッシュROM(ま
たは主記憶)へのポインタが代入される。ステップS3
10で論理セクタのアンロックを行う。図中点線で囲ま
れた期間その論理セクタを占有できる。ステップS31
1で記憶効率の評価を行う。記憶効率の評価手順につい
ては、図21のフローチャートを用いて詳しく説明を加
える。記憶効率の評価の結果、記憶効率が悪化した場合
は、ステップS312へ制御を移す。ステップS312
では上述したガベージコレクションを行う。ガベージコ
レクションについては、図24のフローチャートを参照
して詳しく説明を加える。ステップS313でNセクタ
の書き込みが終了してメインのルーチンへ復帰する。
In step S309, the recording location management table is updated. Here, the pointer to the recorded flash ROM (or main memory) is substituted. Step S3
At 10, the logical sector is unlocked. The logical sector can be occupied during the period surrounded by the dotted line in the figure. Step S31
The memory efficiency is evaluated at 1. The storage efficiency evaluation procedure will be described in detail with reference to the flowchart of FIG. As a result of the evaluation of the storage efficiency, if the storage efficiency is deteriorated, the control is moved to step S312. Step S312
Then, the garbage collection described above is performed. The garbage collection will be described in detail with reference to the flowchart of FIG. In step S313, the writing of N sectors is completed, and the process returns to the main routine.

【0130】なお、記憶場所管理テーブルに納められる
のは、記憶場所のポインタ(バス空間上のアドレス)で
ある。図20の(b)の主記憶に待避されたデータの
「次のデータへのポインタ」の次のフィールド(図中で
はすぐ下に示されている)からは、図10の左側にある
フラッシュROM上のデータ構造と互換性がある。記憶
場所管理テーブルに納められるのはこの互換部分へのポ
インタである。このように構成することにより、データ
の読み出しプログラム側でフラッシュROMと主記憶を
単一のアルゴリズムで扱うことが可能となる。
It is to be noted that what is stored in the storage location management table is the pointer (address on the bus space) of the storage location. From the next field (shown immediately below in the figure) of the "pointer to the next data" of the data saved in the main memory of FIG. 20 (b), the flash ROM on the left side of FIG. Compatible with the above data structures. It is a pointer to this compatible part that is stored in the memory location management table. With this configuration, the flash ROM and the main memory can be handled by a single algorithm on the data reading program side.

【0131】次に、指定されたセクタの記憶を破棄する
手順(上述のステップS304)を説明する。図21
は、記憶を破棄する手順を表わすフローチャートであ
る。
Next, the procedure for discarding the storage of the designated sector (step S304 described above) will be described. FIG.
3 is a flowchart showing a procedure for discarding a memory.

【0132】ステップS401で指定領域の記憶破棄を
開始する。ステップS402では、指定されたセクタを
記憶する領域が主記憶上にあるかどうかを判断する。主
記憶上にあるならステップS405へ分岐する。ステッ
プS405で待避セクタリスト(本例では、図20で示
した片方向線形リスト)から指定領域を削除する。
In step S401, storage discard of the designated area is started. In step S402, it is determined whether the area for storing the designated sector is in the main memory. If it is in the main memory, the process branches to step S405. In step S405, the designated area is deleted from the save sector list (in this example, the one-way linear list shown in FIG. 20).

【0133】片方向線形リストからの指定領域の削除手
順は、まずリストの先頭から検索方向順にリストをたど
り、ポインタが自分をポインティングしている項を検出
する。そして、この検出された項のポインタに現在自分
がポインティングとしている値を代入することで実現す
る。そして、ステップS406で、リストから削除した
主記憶領域をオペレーティングシステムへ返却する。オ
ペレーティングシステムへの記憶領域の返却はC言語の
free関数に相当する機能である。
In the procedure for deleting the designated area from the one-way linear list, the list is first searched from the top of the list in the search direction, and the term in which the pointer points itself is detected. Then, it is realized by substituting the value currently pointed to by the pointer of the detected term. Then, in step S406, the main storage area deleted from the list is returned to the operating system. The return of the storage area to the operating system is a function equivalent to the C language free function.

【0134】一方、ステップS402で指定された領域
が主記憶上でない(すなわちフラッシュROM上)なら
ステップS403へ分岐する。ステップS403では、
指定されたフラッシュROM上のセクタの管理フラグを
“使用済”へ変更する。これは、使用済みフラグをTR
UEにセットすることで達成される。ステップS404
では主記憶上の未使用セクタカウンタの値を1つ減少さ
せる。ステップS407で復帰する。
On the other hand, if the area designated in step S402 is not on the main memory (that is, on the flash ROM), the process branches to step S403. In step S403,
The management flag of the sector on the specified flash ROM is changed to "used". This will TR the used flag
This is achieved by setting it in the UE. Step S404
Then, the value of the unused sector counter on the main memory is decreased by one. The process returns in step S407.

【0135】次に、記憶効率の評価手順(ステップS3
11)について説明する。図22は、記憶効率の評価手
順を表わすフローチャートである。
Next, the storage efficiency evaluation procedure (step S3
11) will be described. FIG. 22 is a flowchart showing the procedure for evaluating storage efficiency.

【0136】ステップS501で記憶効率の評価を開始
する。ステップS502では、主記憶に設定された未使
用セクタカウンタの値と使用済セクタカウンタの値を比
較する。ここで、使用済セクタカウンタの値が未使用セ
クタカウンタの値に対して同じか上回った場合、上位プ
ログラムに対して記憶効率の悪化をレポートする様に構
成している(ステップS502、S504)。また、未
使用セクタカウンタの値が使用済セクタカウンタの値よ
りも大きければ、評価結果を正常とし、正常復帰する
(ステップS503)。
In step S501, evaluation of storage efficiency is started. In step S502, the value of the unused sector counter set in the main memory is compared with the value of the used sector counter. Here, when the value of the used sector counter is equal to or more than the value of the unused sector counter, the deterioration of the storage efficiency is reported to the upper program (steps S502, S504). If the value of the unused sector counter is larger than the value of the used sector counter, the evaluation result is set to normal and the operation returns to normal (step S503).

【0137】次に、フラッシュROMの記憶領域の獲得
手順(ステップS305)について説明する。図23は
フラッシュROMの記憶領域の獲得手順を表わすフロー
チャートである。
Next, the procedure for acquiring the storage area of the flash ROM (step S305) will be described. FIG. 23 is a flowchart showing the procedure for acquiring the storage area of the flash ROM.

【0138】ステップS601でフラッシュROMの記
憶領域の獲得を開始する。ステップS602で未使用セ
クタの検索権利を獲得する。ここでは、オペレーティン
グシステムの提供するセマフォの機能を使用して未使用
セクタの検索権利を管理している。ここでは、ステップ
S602からステップS609/ステップS611まで
の点線で囲まれた処理期間だけ未使用セクタの検索権利
を独占出来る。複数のタスクが同時に同一領域を獲得す
る様な事態を防ぐ為のしくみである。
In step S601, acquisition of the storage area of the flash ROM is started. In step S602, a search right for an unused sector is acquired. Here, the semaphore function provided by the operating system is used to manage the search right for unused sectors. Here, the search right of the unused sector can be monopolized only during the processing period surrounded by the dotted line from step S602 to step S609 / step S611. This is a mechanism to prevent a situation where multiple tasks get the same area at the same time.

【0139】ステップS603でフラッシュROMの最
初のセクタへポインタを移動する。ステップS603で
そのセクタの管理フラグ(使用中フラグ、使用済みフラ
グ)を参照して、当該セクタの使用状態を判断する。使
用済みか使用中ならステップS605へ分岐する。ステ
ップS605で現在ポイントしているセクタが最後のセ
クタならステップS611へ分岐する。この場合、使用
可能な領域がフラッシュROM15に存在しないことに
なるので、ステップS611で未使用セクタの検索権利
を開放した後、ステップS612で異常復帰する。ま
た、ステップS605で現在ポイントしているセクタが
最後のセクタでなければ、ステップS606へ分岐す
る。ステップS606では、ポインタを次のセクタへ移
動させてからステップS604へ戻る。
In step S603, the pointer is moved to the first sector of the flash ROM. In step S603, the management flag (in-use flag, used flag) of the sector is referred to, and the use state of the sector is determined. If used or in use, the process branches to step S605. If the sector currently pointed to in step S605 is the last sector, the process branches to step S611. In this case, since the usable area does not exist in the flash ROM 15, the search right of the unused sector is released in step S611, and the process returns abnormally in step S612. If the sector currently pointed to is not the last sector in step S605, the process branches to step S606. In step S606, the pointer is moved to the next sector, and then the process returns to step S604.

【0140】ステップS604ポインタの示すセクタの
管理フラグが未使用となっていればステップS607へ
分岐する。ステップS607では、フラッシュROMの
管理フラグを“使用中”へ変更する(使用中フラグをT
RUEにする)。そして、ステップS608で、主記憶
に設けた未使用セクタカウンタの値を1つ減少させる。
この場合は、フラッシュROMへの記憶領域の獲得に成
功しているので、ステップS609で未使用セクタの検
索権利を開放し、ステップS610で正常復帰する。
Step S604 If the management flag of the sector indicated by the pointer is unused, the process branches to step S607. In step S607, the management flag of the flash ROM is changed to "in use" (the in-use flag is set to T).
RUE). Then, in step S608, the value of the unused sector counter provided in the main memory is decremented by one.
In this case, since the storage area in the flash ROM has been successfully acquired, the search right of the unused sector is released in step S609, and the normal operation is restored in step S610.

【0141】次に、ガベージコレクション(ステップS
312)の手順について説明する。図24はガベージコ
レクションの手順を表わすフローチャートである。
Next, garbage collection (step S
The procedure of (312) will be described. FIG. 24 is a flowchart showing the procedure of garbage collection.

【0142】ステップS701でガベージコレクション
を開始する。ステップS702では、整理対象のイレー
スブロック(以後、整理対象ブロック)を選出する。整
理対象ブロックの選出手順については、図25のフロー
チャートを用いて詳しく説明を加える。ステップS70
3では、整理対象ブロックの未使用セクタを使用済化す
る。この使用済化の手順については、図26のフローチ
ャートを用いて詳しく説明を加える。ここで、最初に整
理対象ブロック内の未使用セクタを使用済化させる目的
は、ガベージコレクション中であっても、他のタスクが
整理対象ブロック内のセクタを含むセクタへの読み書き
が可能な構成となっており、ガベージコレクション中に
他のタスクによって整理対象ブロック内のセクタへ新た
なデータが書き込まれることを防止する為である。
Garbage collection is started in step S701. In step S702, an erase block to be rearranged (hereinafter, rearrangement target block) is selected. The procedure for selecting the rearrangement target blocks will be described in detail with reference to the flowchart of FIG. Step S70
In 3, the unused sectors of the rearrangement target block are used up. A detailed description will be added to the procedure of this end of life using the flowchart of FIG. Here, the purpose of first disposing of unused sectors in the rearrangement target block is to make it possible for other tasks to read and write to sectors including the sector in the rearrangement target block even during garbage collection. This is to prevent new data from being written to the sector in the block to be sorted by another task during the garbage collection.

【0143】ステップS704では、整理対象ブロック
中の使用中セクタを他の記憶領域(即ち、他のイレース
ブロック)へ移動させる。使用中セクタを他の記憶領域
へ移動させる処理については、図27のフローチャート
を参照して詳しく説明を加える。
In step S704, the in-use sector in the block to be rearranged is moved to another storage area (that is, another erase block). The process of moving the in-use sector to another storage area will be described in detail with reference to the flowchart of FIG.

【0144】続くステップS705では、使用中セクタ
の移動を終了した整理対象ブロックの消去を実行する。
整理対象ブロックを消去する手順については、図28の
フローチャートを参照して詳しく説明を加える。なお、
この整理対象ブロックの消去において、消去回数カウン
タ152の内容を主記憶にコピーしておく。ステップS
705における整理対象ブロックの消去を終えると、ス
テップS706で主記憶に退避したデータをフラッシュ
ROMの当該イレースブロックの消去回数カウンタへ戻
す。そして、ステップS707でガベージコレクション
から復帰する。
In the following step S705, the rearrangement target block for which the movement of the in-use sector has been completed is erased.
The procedure for deleting the rearrangement target blocks will be described in detail with reference to the flowchart in FIG. In addition,
When erasing the blocks to be rearranged, the contents of the erase count counter 152 are copied to the main memory. Step S
After erasing the rearrangement target block in 705, the data saved in the main memory is returned to the erase count counter of the erase block in the flash ROM in step S706. Then, in step S707, the process returns from the garbage collection.

【0145】次に、ガベージコレクションにおける整理
対象ブロックの選出手順(ステップS702)について
説明する。図25は整理対象ブロック選出する手順を表
わすフローチャートである。
Next, the procedure for selecting the rearrangement target blocks in the garbage collection (step S702) will be described. FIG. 25 is a flowchart showing a procedure for selecting blocks to be sorted.

【0146】まず、ステップS801で整理対象ブロッ
クの選出を開始する。ステップS802で評価ポインタ
に最初のイレースブロックをセットする。同様に、ステ
ップS803で、整理対象候補ポインタを最初のイレー
スブロックにセットする。
First, in step S801, selection of blocks to be sorted is started. In step S802, the first erase block is set in the evaluation pointer. Similarly, in step S803, the rearrangement target candidate pointer is set to the first erase block.

【0147】次に、ステップS804で、評価ポインタ
の示すイレースブロックに使用済セクタが含まれている
かどうかを判断する。使用済セクタが含まれていなけれ
ばステップS804,ステップS805をスキップして
ステップS807へ制御を移す。
Next, in step S804, it is determined whether or not the erase block indicated by the evaluation pointer includes a used sector. If the used sector is not included, steps S804 and S805 are skipped and control is passed to step S807.

【0148】一方、ステップS804で評価ポインタの
示すイレースブロックに使用済セクタが含まれている場
合には、ステップS805へ制御を移す。ステップS8
05では、整理対象候補ポインタの示すイレースブロッ
クの消去回数カウンタの値と評価ポインタの示すイレー
スブロックの消去回数カウンタの値を比較する。もし評
価ポインタの示すイレースブロックの消去回数の方が少
なければステップS806へ制御を移す。ステップS8
06では、整理対象候補ポインタへ評価ポインタを代入
する。一方、ステップS805でもし評価ポインタの示
すイレースプロックの消去回数のほうが多ければそのま
まステップS807へ制御を移す。
On the other hand, if it is determined in step S804 that the erase block indicated by the evaluation pointer includes a used sector, control is passed to step S805. Step S8
In 05, the value of the erase count counter of the erase block indicated by the rearrangement candidate pointer is compared with the value of the erase count counter of the erase block indicated by the evaluation pointer. If the erased number of erase blocks indicated by the evaluation pointer is smaller, control is passed to step S806. Step S8
At 06, the evaluation pointer is assigned to the rearrangement candidate pointer. On the other hand, if it is determined in step S805 that the erase block is erased more times, the control proceeds to step S807.

【0149】ステップS807で評価ポインタが最後の
イレースブロックを示しているかどうかを判断する。も
し最後のイレースブロックでなければ、ステップS80
8で評価ポインタを次のイレースブロックへ移動させた
後、ステップS804へ戻る。以上のように、ステップ
S804〜S808の処理を繰り返すことで、整理対象
候補ポインタは、使用済みセクタを含み、消去回数の少
ないイレースブロックを示すようになる。
In step S807, it is determined whether the evaluation pointer points to the last erase block. If it is not the last erase block, step S80
After moving the evaluation pointer to the next erase block in step 8, the process returns to step S804. As described above, by repeating the processing of steps S804 to S808, the rearrangement target candidate pointer indicates an erase block including the used sector and having a small erase count.

【0150】ステップS807で評価ポインタが最後の
イレースブロックを示している場合はステップS809
へ分岐する。ステップS809ではガベージコレクショ
ン処理(図24の処理)に復帰する。この時点の整理対
象候補ポインタの示すイレースブロックが整理対象とし
て選出される。
If the evaluation pointer points to the last erase block in step S807, step S809.
Branch to. In step S809, the process returns to the garbage collection process (process of FIG. 24). The erase block indicated by the rearrangement target candidate pointer at this point is selected as the rearrangement target.

【0151】次に、選択された整理対象ブロック内の未
使用セクタを使用済み化する処理(ステップS703)
について説明する。図26は、整理対象ブロックの未使
用セクタを使用済み化する手順を表わすフローチャート
である。
Next, the processing for converting the unused sectors in the selected rearrangement target block into used (step S703).
Will be described. FIG. 26 is a flowchart showing a procedure of converting unused sectors of a rearrangement target block into used sectors.

【0152】ステップS901で処理を開始する。ステ
ップS902で、整理対象ブロックの最初のセクタへポ
インタを移動させる。次に、ステップS903で、未使
用セクタの検索権利を獲得する。これは、図23のフロ
ーチャートのステップS602と同様の効果があり、ス
テップS908までの点線で囲まれた間、未使用セクタ
の検索権利を独占する。即ち、整理対象ブロックの全セ
クタを対象にスキャンして未使用セクタを使用済セクタ
へ変更するまでの間、他のタスクが未使用セクタの検索
をすることを禁止する。しかし、管理フラグのみの操作
で未使用セクタを使用済セクタへ変更するので、検索権
利の独占時間は短く、全体のスループットが低下するこ
とはない。
The process starts in step S901. In step S902, the pointer is moved to the first sector of the rearrangement target block. Next, in step S903, a search right for an unused sector is acquired. This has the same effect as that of step S602 in the flowchart of FIG. 23, and monopolizes the unused sector search right while being surrounded by the dotted line up to step S908. In other words, it is prohibited for another task to search for unused sectors until all the sectors of the rearrangement target block are scanned and the unused sectors are changed to used sectors. However, since the unused sector is changed to the used sector only by the operation of the management flag, the monopolization time of the search right is short and the overall throughput is not lowered.

【0153】ステップS904で、現在のポインタが示
すセクタが未使用セクタかどうかを判断する。もし未使
用セクタならステップS905へ分岐する。ステップS
905でその記憶を廃棄する。ステップS905の処理
手順は図21のフローチャートで説明した通りである。
この処理により、未使用セクタが使用済みセクタに変更
される。ステップS906では、ポインタが整理対象ブ
ロックの最後のセクタを示しているかどうかを判断す
る。最後のセクタを示していればステップS908へ、
そうでないならステップS907へ分岐する。ステップ
S907ではポインタを次のセクタへ移動させてステッ
プS904へ制御を戻す。
In step S904, it is determined whether the sector indicated by the current pointer is an unused sector. If it is an unused sector, the process branches to step S905. Step S
At 905, the memory is discarded. The processing procedure of step S905 is as described in the flowchart of FIG.
By this process, the unused sector is changed to the used sector. In step S906, it is determined whether the pointer points to the last sector of the rearrangement target block. If the last sector is indicated, go to step S908,
If not, the process branches to step S907. In step S907, the pointer is moved to the next sector, and control is returned to step S904.

【0154】また、ステップS906でポインタが整理
対象ブロック最後のセクタならステップS908で未使
用セクタの検索権利を開放し、ステップS909でガベ
ージコレクション処理(図24のフローチャート)へ復
帰する。
If the pointer is the last sector of the rearrangement target block in step S906, the search right of the unused sector is released in step S908, and the process returns to the garbage collection process (flowchart in FIG. 24) in step S909.

【0155】次に、整理対象ブロックの使用中セクタを
他のイレースブロックの未使用セクタへ移動する処理
(ステップS704)について説明する。図27は、整
理対象ブロックの使用中セクタの移動手順を表わすフロ
ーチャートである。
Next, the process of moving the used sector of the rearrangement target block to the unused sector of another erase block (step S704) will be described. FIG. 27 is a flowchart showing the procedure of moving the used sector of the rearrangement target block.

【0156】ステップS1000で処理を開始する。ス
テップS1001で整理対象ブロックの最初のセクタへ
ポインタを移動させる。以下のステップS1002〜S
1012では、ポインタが指し示すセクタについて処理
を行う。
The process is started in step S1000. In step S1001, the pointer is moved to the first sector of the rearrangement target block. The following steps S1002-S
At 1012, processing is performed on the sector pointed to by the pointer.

【0157】ステップS1002で当該セクタの管理フ
ラグ(使用中フラグ、使用済みフラグ)を判断する。ス
テップS1002で管理フラグの値が「使用中」となっ
ていたらステップS1003へ制御を移し、「使用済」
となっていたらステップS1012へ制御を移す。ステ
ップS1003で、論理セクタをロックする。ロックし
たセクタはステップS1011でアンロックされるまで
の間、自タスクで占有される。
In step S1002, the management flag (in-use flag, used flag) of the sector is determined. If the value of the management flag is "in use" in step S1002, control is transferred to step S1003, and "used"
If so, control is transferred to step S1012. In step S1003, the logical sector is locked. The locked sector is occupied by the own task until it is unlocked in step S1011.

【0158】ステップS1004では記憶領域を獲得す
る。ステップS1004における記憶領域の確保の手順
は、図23のフローチャートで説明した通りである。こ
こで、整理対象ブロック内の各セクタは上記ステップS
703の処理で、全て使用済み化されているので、確保
される記憶領域は整理対象ブロック以外のイレースブロ
ックとなる。
In step S1004, a storage area is acquired. The procedure for securing the storage area in step S1004 is as described in the flowchart of FIG. Here, each sector in the rearrangement target block has the above-mentioned step S
In the processing of 703, since all the storage areas have been used, the secured storage area is an erase block other than the rearrangement target block.

【0159】記憶領域の獲得に成功すると、処理はステ
ップS1008へ進む。ステップS1008では、獲得
した領域へ当該セクタのデータをコピーする。そして、
セクタの移動に従って、ステップS1009で記憶場所
管理テーブル140を更新する。
When the acquisition of the storage area is successful, the process proceeds to step S1008. In step S1008, the data of the sector is copied to the acquired area. And
As the sector moves, the storage location management table 140 is updated in step S1009.

【0160】一方、ステップS1004で記憶領域の獲
得に失敗した場合は、ステップS1005へ分岐する。
ステップS1005では、データ退避用の記憶領域を主
記憶(DRAM)より獲得する。データ退避用記憶領域
の獲得は図19のフローチャートのステップS306で
説明した通りである。ステップS1006では、獲得し
た領域へ当該セクタのデータをコピーする。そして、ス
テップS1007で記憶管理テーブルを更新する。ステ
ップS1010で元の記憶を廃棄する。即ち、ポインタ
の指し示すセクタの使用済みフラグをTRUEにセット
する。そして、ステップS1011で当該論理セクタを
アンロックする。
On the other hand, if the acquisition of the storage area fails in step S1004, the process branches to step S1005.
In step S1005, a storage area for saving data is acquired from the main storage (DRAM). Acquisition of the data save storage area is as described in step S306 of the flowchart of FIG. In step S1006, the data of the sector is copied to the acquired area. Then, in step S1007, the storage management table is updated. In step S1010, the original storage is discarded. That is, the used flag of the sector pointed to by the pointer is set to TRUE. Then, in step S1011 the logical sector is unlocked.

【0161】ステップS1012で、ポインタの指し示
すセクタが、整理対象ブロックの最後のセクタかどうか
を判断する。最後のセクタであればステップS1014
へ、最後のセクタでなければステップS1013へそれ
ぞれ分岐する。ステップS1013では、ポインタを次
のセクタへ移動させて、ステップS1002へ戻り、次
のセクタについて上述の処理を繰り返す。また、ステッ
プS1014では、整理対象ブロック内の全てのセクタ
について処理を終えているので、ガベージコレクション
処理(図24のフローチャート)へ復帰する。
In step S1012, it is determined whether the sector pointed to by the pointer is the last sector of the rearrangement target block. If it is the last sector, step S1014
If not the last sector, the process branches to step S1013. In step S1013, the pointer is moved to the next sector, the process returns to step S1002, and the above process is repeated for the next sector. Further, in step S1014, since processing has been completed for all the sectors in the rearrangement target block, the process returns to the garbage collection processing (flowchart in FIG. 24).

【0162】次に、整理対象ブロックの消去処理(ステ
ップS705)について説明する。図28は、整理対象
となったイレースブロックの消去手順を表わすフローチ
ャートである。
Next, the erasing process of the blocks to be rearranged (step S705) will be described. FIG. 28 is a flow chart showing a procedure for erasing erase blocks that have been arranged.

【0163】ステップS1101で処理を開始する。ス
テップS1102で整理対象ブロックの消去回数カウン
タを主記憶へコピーする。ステップS1103では整理
対象ブロックの消去を実行する。ステップS1104で
は、主記憶へコピーした消去回数カウンタの値を1増加
させた値をフラッシュROMへ書き込む。即ち、当該整
理対象ブロックの消去カウンタの値を、消去処理前の値
より1増加させる。その後、ステップS1105でガベ
ージコレクション処理(図24のフローチャート)へ復
帰する。
The process is started in step S1101. In step S1102, the erase count counter of the rearrangement target block is copied to the main memory. In step S1103, the rearrangement target block is erased. In step S1104, the value obtained by incrementing the value of the erase count counter copied to the main memory by 1 is written to the flash ROM. That is, the value of the erase counter of the block to be rearranged is incremented by 1 from the value before the erase process. Then, in step S1105, the process returns to the garbage collection process (flowchart in FIG. 24).

【0164】上記図24で示されるガベージコレクショ
ン処理は、極力フラッシュROMを用いた処理であり、
退避データの安全性が高い。しかしながら、上述の<未
使用セクタが無い場合>の項で説明したように、積極的
に主記憶(DRAM14)を用いて使用中セクタのデー
タを待避し、複数個のイレースブロックを消去すると消
去処理の効率がよい。但し、DRAM14にデータを待
避するので、待避中のデータに関して安全性が低下する
(例えば電池が外れて電源供給が停止するとDRAMに
待避したデータが失われることになる)。そこで、電源
の種別を判断し、供給電源が電池の場合は待避データの
安全性を重視し、ACアダプタの場合は電源供給が停止
する危険性が少ないので消去処理の効率を重視するよう
に構成してもよい。この場合の処理について図36を参
照して説明する。
The garbage collection process shown in FIG. 24 is a process using the flash ROM as much as possible.
The safety of the saved data is high. However, as described in the above section <When there are no unused sectors>, when the data in the in-use sector is positively saved by using the main memory (DRAM 14) and a plurality of erase blocks are erased, the erase processing is performed. Is efficient. However, since the data is saved in the DRAM 14, the safety of the data being saved is lowered (for example, if the battery is removed and the power supply is stopped, the data saved in the DRAM will be lost). Therefore, the type of power supply is determined, and the safety of the saved data is emphasized when the power supply is a battery, and the efficiency of the erasing process is emphasized when the AC adapter is used because there is little risk of power supply interruption. You may. The processing in this case will be described with reference to FIG.

【0165】図36は、電源種別に基づいてガベージコ
レクション処理を切り換える場合の処理手順を説明する
フローチャートである。同図において、図24のフロー
チャートで示される処理と同じ処理を行うステップにつ
いては同一のステップ番号を付し、ここでは詳細な説明
を省略する。
FIG. 36 is a flow chart for explaining the processing procedure when switching the garbage collection processing based on the power source type. In the figure, steps that perform the same processing as the processing shown in the flowchart of FIG. 24 are assigned the same step numbers, and detailed description thereof is omitted here.

【0166】ステップS1300においてガベージコレ
クション処理が起動されると、ステップS1301へ進
み、当該装置への電源供給の形態を判断する。ここで
は、図1の電源コントローラ9が、電源の供給元が電池
7であるかACアダプタ23であるかを判断し、CPU
5に通知する。電源種別が電池7であった場合は、ステ
ップS1304へ進み、上述の図24で示したガベージ
コレクション処理を実行する。
When the garbage collection process is activated in step S1300, the flow advances to step S1301 to determine the form of power supply to the apparatus. Here, the power supply controller 9 of FIG. 1 determines whether the power supply source is the battery 7 or the AC adapter 23, and the CPU
Notify 5 If the power source type is the battery 7, the process advances to step S1304 to execute the garbage collection process shown in FIG.

【0167】一方、ステップS1301において電源種
別がACアダプタであった場合は、ステップS1302
へ進む。ステップS1302では、図24のステップS
702、S703、S704に相当する処理を実行し、
選出した整理対象ブロック内の未使用セクタの使用済み
化と使用中セクタの待避を行う。そして、ステップS1
303において、主記憶(DRAM14)にセクタの待
避を行うのに十分な空き領域があるか否かを判断し、十
分な空き領域があればステップS1302へ戻る。ステ
ップS1302では、前回の整理対象ブロックとは別の
整理対象ブロックを選出して、上述の処理を繰り返す。
On the other hand, if the power supply type is the AC adapter in step S1301, then step S1302.
Proceed to. In step S1302, step S in FIG.
702, S703, and S704 are executed,
The unused sectors in the selected blocks to be sorted out are used and the sectors in use are saved. Then, step S1
In 303, it is determined whether or not there is a sufficient free area in the main memory (DRAM 14) for saving the sector. If there is a sufficient free area, the process returns to step S1302. In step S1302, a rearrangement target block different from the previous rearrangement target block is selected, and the above processing is repeated.

【0168】DRAM14上に十分な空き領域が無くな
ると、ステップS1303からステップS1304へ進
み、上述の処理で選出された整理対象ブロックの消去を
行う。そして、ステップS706で主記憶に待避したデ
ータをフラッシュROM15に戻して本処理を終了す
る。
When the DRAM 14 has no free space, the process advances from step S1303 to step S1304 to erase the rearrangement target block selected in the above process. Then, in step S706, the data saved in the main memory is returned to the flash ROM 15 and the present processing ends.

【0169】以上のように、図36の処理によれば、電
源がACアダプタによって供給される場合は、主記憶の
空き容量を積極的に利用してデータの待避を行い、複数
の整理対象ブロックを選出して、一括して消去処理を行
うことができ、消去処理の効率が向上する。
As described above, according to the processing of FIG. 36, when the power is supplied by the AC adapter, the free space of the main storage is positively used to save the data, and the plurality of blocks to be sorted are arranged. Can be selected and collectively erased, and the efficiency of the erase processing is improved.

【0170】なお、上記の処理では、電源種別に基づい
て自動的にガベージコレクションの形態を切り換える
が、コントロールパネル12の操作により、マニュアル
で切り換えるようにすることもできることはいうまでも
ない。
In the above processing, the form of garbage collection is automatically switched based on the type of power source, but it goes without saying that the mode can be switched manually by operating the control panel 12.

【0171】次に、基本サービスの一つである論理セク
タの解放手順について説明する。図29は、論理セクタ
の解放手順を表すフローチャートである。
Next, the procedure for releasing the logical sector, which is one of the basic services, will be described. FIG. 29 is a flowchart showing the procedure for releasing a logical sector.

【0172】ステップS1201でNセクタの解放を開
始する。ステップS1202でNセクタをロックする。
この結果、ステップS1205でアンロックされるまで
の間、自タスクで論理セクタを占有出来る。続いて、ス
テップS1203で当該セクタの記憶を廃棄する。この
記憶の廃棄処理については、図21のフローチャートで
説明した通りである。ステップS1204では、DRA
M14の記憶場所管理テーブル140へ“不在”値を代
入する。ステップS1205では、論理セクタをアンロ
ックし、ステップS1206で復帰する。
In step S1201, release of N sectors is started. In step S1202, N sectors are locked.
As a result, the own task can occupy the logical sector until it is unlocked in step S1205. Subsequently, in step S1203, the storage of the sector is discarded. This storage discard processing is as described in the flowchart of FIG. In step S1204, DRA
The "absence" value is substituted into the storage location management table 140 of M14. The logical sector is unlocked in step S1205, and the process returns in step S1206.

【0173】例えばMS−DOS(商標)等の一般のフ
ァイルシステムでは、ファイルの消去に際しては、当該
ファイルに属するセクタをFATにおいて上書き可能と
するのみで、各セクタを解放するということは行われな
い。よって、このようなファイルシステムに本実施形態
のフラッシュROM管理システムを適用すると、ファイ
ルシステム上では無効となったデータが、有効なセクタ
として残されてしまうことになり、ガベージコレクショ
ン等の効率を低下させることになる。よって、ファイル
システムの指示(例えばファイル消去)に基づいて不要
となったセクタを検出し、これを解放するように構成す
れば、ガベージコレクションの効率をより向上させるこ
とができる。
In a general file system such as MS-DOS (trademark), for example, when erasing a file, the sectors belonging to the file can only be overwritten in the FAT, and each sector is not released. . Therefore, when the flash ROM management system according to the present embodiment is applied to such a file system, invalid data on the file system is left as a valid sector, which reduces the efficiency of garbage collection and the like. I will let you. Therefore, if the unnecessary sector is detected based on the file system instruction (for example, file deletion) and is released, the efficiency of garbage collection can be further improved.

【0174】図37は、ファイルシステムよりファイル
消去が指示された場合の、不要セクタの解放手順を表す
フローチャートである。同図において、ステップS14
01でファイルシステムよりファイル消去の指示があっ
たか否かを判断する。ファイル消去の指示があった場合
は、ステップS1402へ進み、消去すべく指示された
ファイルに含まれるセクタを抽出する。セクタの抽出
は、FATを参照することで抽出できる。そして、ステ
ップS1403で、先のステップS1402で抽出され
た各セクタについて、上記図29のフローチャートで説
明したセクタの解放処理を実行する。
FIG. 37 is a flow chart showing the procedure for releasing unnecessary sectors when a file erasing is instructed by the file system. In the figure, step S14
At 01, it is determined whether or not there is an instruction to delete a file from the file system. If there is an instruction to erase the file, the process advances to step S1402 to extract the sectors included in the file instructed to be erased. The sector can be extracted by referring to the FAT. Then, in step S1403, the sector releasing process described in the flowchart of FIG. 29 is executed for each sector extracted in the previous step S1402.

【0175】[実施形態2]次に実施形態2について説
明する。
[Second Embodiment] Next, a second embodiment will be described.

【0176】<ディスクコントローラエミュレーション
>上述の実施形態1で説明したフラッシュROMの記憶
管理システムは、上位層から見た特徴がディスク媒体と
良く似ている。従って、ディスクコントローラのエミュ
レーション機能を備えたシステムに組み込むことで、デ
ィスクコントローラとディスク媒体をディスクコントロ
ーラエミュレーションと本実施形態の記憶管理システム
(あるいは本実施形態の記憶管理システムを組み込んだ
ICカード)へ置き換えることが可能となる。近年PC
MCIAに代表されるICカードが普及しているが、I
Cカードへディスクコントローラエミュレーション機能
と上記実施形態1の記憶管理システムを組込むことによ
り、リムーバルな記憶媒体として利用することが可能と
なる。第2の実施形態では、実施形態1の記憶管理シス
テムをICカードへ組み込んだものについて説明する。
<Disk Controller Emulation> The flash ROM storage management system described in the first embodiment is similar to the disk medium in the characteristics seen from the upper layer. Therefore, the disk controller and the disk medium are replaced by the disk controller emulation and the storage management system of the present embodiment (or an IC card that incorporates the storage management system of the present embodiment) by incorporating the disk controller into the system having the emulation function of the disk controller. It becomes possible. PC in recent years
IC cards represented by MCIA are widely used.
By incorporating the disk controller emulation function and the storage management system of the first embodiment in the C card, it becomes possible to use it as a removable storage medium. In the second embodiment, an IC card incorporating the storage management system of the first embodiment will be described.

【0177】図30は実施形態2におけるICカードの
構成を表すブロック図である。同図において、200は
ICカード全体を示す。201はマイクロコンピュータ
であり、ディスクコントローラエミュレーション及び記
憶管理を行う。202はROMであり、マイクロコンピ
ュータ201のプログラムを格納する。203はRAM
であり、マイクロコンピュータ201の主記憶として機
能する。204はフラッシュROMであり、上記実施形
態1で説明した記憶管理システムによってデータを蓄積
する。即ち、フラッシュROM204は、図4で説明し
た管理領域とデータ領域とで管理される。
FIG. 30 is a block diagram showing the structure of the IC card according to the second embodiment. In the figure, 200 indicates the entire IC card. A microcomputer 201 performs disk controller emulation and storage management. A ROM 202 stores the program of the microcomputer 201. 203 is a RAM
And functions as the main memory of the microcomputer 201. A flash ROM 204 stores data by the storage management system described in the first embodiment. That is, the flash ROM 204 is managed by the management area and the data area described in FIG.

【0178】205はコマンド/データ・ラッチ部であ
り、ホスト装置より受信した外部バスからのコマンドと
シリンダ番号等を保持する。206はFIFOメモリで
あり、先入れ先出し方式でデータの入出力を行う。20
7はタプルROMであり、当該カードの特徴等を記憶し
ており、外部バスからのみ読み出しができる。
Reference numeral 205 denotes a command / data latch section, which holds a command from the external bus received from the host device, a cylinder number, and the like. A FIFO memory 206 inputs and outputs data in a first-in first-out system. 20
A tuple ROM 7 stores the characteristics of the card and can be read only from an external bus.

【0179】上述の各構成の機能は、以降の動作説明で
より明らかとなる。
The function of each configuration described above will become more apparent in the following description of the operation.

【0180】図31は、本実施形態2のICカードを利
用する為のホストシステムの簡単なブロック図である。
同図において、301はホストシステム側のマイクロコ
ンピュータである。302はカードインターフェースで
あり、ホストシステムの内部バスとICカード200の
外部バスを接続する。なお、カードインターフェース3
02は、ICカード200への電源供給を行うための電
源供給線や、ICカード200からの割り込み要求(I
RQ出力)を受け付けるための信号線も備えている。
FIG. 31 is a simple block diagram of a host system for using the IC card of the second embodiment.
In the figure, reference numeral 301 is a microcomputer on the host system side. A card interface 302 connects the internal bus of the host system and the external bus of the IC card 200. In addition, card interface 3
02 is a power supply line for supplying power to the IC card 200, and an interrupt request (I
It also has a signal line for receiving (RQ output).

【0181】図32は、図31のホストシステムがIC
カードを接続する際の手順を示すフローチャートであ
る。ステップS4100で処理を開始すると、ステップ
S4101でICカードへの電源供給を開始する。ステ
ップS4102では、ICカード200内のタプルRO
M7から、タプル形式で格納されているデータを解析す
る。タプルROM7の内容を解析することで、接続され
ているICカードの特徴が分かる。
In FIG. 32, the host system of FIG. 31 is an IC.
It is a flowchart which shows the procedure at the time of connecting a card. When the processing is started in step S4100, power supply to the IC card is started in step S4101. In step S4102, the tuple RO in the IC card 200
The data stored in the tuple format is analyzed from M7. By analyzing the contents of the tuple ROM 7, the characteristics of the connected IC card can be known.

【0182】ステップS4103では、ステップS41
02で解析したタプル情報によって、接続されているI
Cカードが内部バスへ接続可能かどうかを判断する。そ
して、接続可能ならステップS4104へ、接続不可能
ならステップS4105へとそれぞれ分岐する。ステッ
プS4104では、ICカード側のバスをホストの内蔵
バスのメモリ空間とIO空間へマッピングする。この時
点でホスト装置のバスの空間にディスクコントローラが
有るのと同じ状態になる。
In step S4103, step S41
I connected by the tuple information analyzed in 02.
Judge whether the C card can be connected to the internal bus. If the connection is possible, the process branches to step S4104, and if the connection is not possible, the process branches to step S4105. In step S4104, the bus on the IC card side is mapped to the memory space and IO space of the internal bus of the host. At this point, the state is the same as when there is a disk controller in the bus space of the host device.

【0183】図33はICカード200内のマイクロコ
ンピュータ1のメインシーケンスを示すフローチャート
である。ステップS4201でICカードの電源が投入
されると、ステップS4202で記憶管理システムの初
期化を行う。即ち、フラッシュROM204の全イレー
スブロックの論理セクタの状態を一旦読み出し、読み出
した情報に従って主記憶用のRAM203へ記憶場所管
理テーブルを作成する。ステップS4203で主記憶上
のコマンドバッファとしてリング状のバッファを用意し
て初期化し、割り込み処理を許可する。この処理以降割
り込みルーチンの動作が始まる。
FIG. 33 is a flow chart showing the main sequence of the microcomputer 1 in the IC card 200. When the IC card is powered on in step S4201, the storage management system is initialized in step S4202. That is, the states of the logical sectors of all erase blocks in the flash ROM 204 are read once, and a storage location management table is created in the RAM 203 for main storage according to the read information. In step S4203, a ring-shaped buffer is prepared and initialized as a command buffer on the main memory, and interrupt processing is permitted. After this processing, the operation of the interrupt routine starts.

【0184】割り込みルーチンのシーケンスを図34の
フローチャートに示す。割り込みルーチンの動作を理解
した方が、図33のフローチャートの説明が容易となる
為、ここで図34のフローチャートについて説明を行
う。
The sequence of the interrupt routine is shown in the flowchart of FIG. Understanding the operation of the interrupt routine facilitates the description of the flowchart of FIG. 33. Therefore, the flowchart of FIG. 34 will be described here.

【0185】ホストシステムがコマンド/データ・ラッ
チ205へのコマンドのアドレスへコマンドを書き込む
と、コマンド/データ・ラッチ205からマイクロコン
ピュータ201へ割り込みが発生する。コマンド/デー
タ・ラッチ205は、ホストバスとICカード内部のバ
スのIOアドレス空間にマッピングされていて、コマン
ド/データはそれぞれ図35に示すようにIOアドレス
が割り振られている。図35は、本実施形態のコマンド
/データ・ラッチにおけるIO割り付けを示す図であ
る。本例では、図35中のCommandのアドレスにコマン
ド(例えばデータの読出しを指示するReadSector(s))
を書き込むことでマイクロコンピュータ201へ割り込
みが発生する。
When the host system writes a command to the address of the command to the command / data latch 205, an interrupt is generated from the command / data latch 205 to the microcomputer 201. The command / data latch 205 is mapped in the IO address space of the host bus and the bus inside the IC card, and IO addresses are assigned to the command / data as shown in FIG. FIG. 35 is a diagram showing IO allocation in the command / data latch of this embodiment. In this example, a command (for example, ReadSector (s) for instructing to read data) is assigned to the command address in FIG.
Is written, an interrupt occurs in the microcomputer 201.

【0186】割り込みが発生すると、マイクロコンピュ
ータ201のソフトウェアは、図34のフローチャート
のステップS4301へ制御を移す。ステップS430
2では、コマンド/データ・ラッチ205に書き込まれ
たデータを読み出して、主記憶上のリングバッファへデ
ータを格納する。ステップS4303で割り込みルーチ
ンを終了して図33のフローチャートへ復帰する。
When the interruption occurs, the software of the microcomputer 201 shifts the control to the step S4301 of the flowchart of FIG. Step S430
In 2, the data written in the command / data latch 205 is read and the data is stored in the ring buffer on the main memory. In step S4303, the interrupt routine is ended and the process returns to the flowchart in FIG.

【0187】図33のフローチャートの説明に戻る。ス
テップS4204でマイクロコンピュータ201はコマ
ンドバッファの状態を判断する。コマンドバッファへデ
ータが格納されていれば、ステップS4205へ分岐
し、データが格納されていなければステップS4213
へ分岐する。ステップS4213ではCPUを休止状態
にする。多くのワンチップマイクロコンピュータは、命
令の実行を休止して消費電流を減らす機能を備えている
が、本実施形態のCPUもこの種の機能を備える。そし
て、IRQによる割り込み要求信号が入力されると、C
PU201は休止状態から復帰して上述の割り込みルー
チンを実行する。割り込みプログラムの実行が済んだ時
点でステップS4213から復帰してステップS420
4へ戻る。
Returning to the description of the flowchart in FIG. In step S4204, the microcomputer 201 determines the status of the command buffer. If data is stored in the command buffer, the process branches to step S4205, and if data is not stored, step S4213.
Branch to. In step S4213, the CPU is put into a sleep state. Many one-chip microcomputers have a function of suspending the execution of instructions to reduce current consumption, and the CPU of this embodiment also has this kind of function. When the interrupt request signal by IRQ is input, C
The PU 201 returns from the sleep state and executes the above-mentioned interrupt routine. When the execution of the interrupt program is completed, the process returns from step S4213 to step S420.
Return to 4.

【0188】ステップS4204でコマンドバッファへ
データが格納されていると、ステップS4205へ移行
する。ステップS4206では、リングバッファからデ
ータを読み出す。ステップS4206でコマンドを解釈
する。Seekコマンドの場合はステップS4207、Read
Sector(s)コマンドの場合はステップS4208へ、Wri
teSector(s)の場合はステップS4209へ、IdentifyD
rvコマンドの場合はステップS4210へそれぞれ分岐
する。他にもコマンドがあるが本実施形態の説明上重要
でないものは省き、フローチャートを簡略化している。
ステップS4207〜4210までのコマンドの実行を
終了したらステップS4204まで戻り、上記の処理を
繰り返す。
If the data is stored in the command buffer in step S4204, the process moves to step S4205. In step S4206, data is read from the ring buffer. The command is interpreted in step S4206. In the case of the Seek command, step S4207, Read
In the case of the Sector (s) command, go to step S4208 and Wri
In the case of teSector (s), go to Step S4209, and identify D
In the case of the rv command, the process branches to step S4210. Although there are other commands, those that are not important for the description of the present embodiment are omitted and the flowchart is simplified.
When the execution of the commands in steps S4207 to 4210 is completed, the process returns to step S4204 to repeat the above process.

【0189】ステップS4207では、Seekコマンドを
実行する。SeekといってもフラッシュROMには、ディ
スクデバイスと違ってヘッドが無いので、次のコマンド
に備えての妥当性等をチェックするだけである。ICカ
ードのサポートするヘッド数を超えるヘッド位置などを
指定された場合は、ディスク装置同様にエラーが発生す
る。
In step S4207, the Seek command is executed. Seek has no head in a flash ROM, unlike a disk device, so all you have to do is check the validity of the next command. If a head position that exceeds the number of heads supported by the IC card is specified, an error occurs as in the disk device.

【0190】ステップS4208はReadSector(s)コマ
ンドに対する処理を行う。ReadSector(s)コマンドは、
読み出すべきセクターの個数が図35のSectorCountで
指定される。よって、ステップS4208では、指定さ
れた場所のセクタをSectroCount個読み出す行為を行
う。本実施形態の記憶管理システムでは、リニアな論理
セクタ番号を使って管理を行っているので、シリンダ/
ヘッド/セクタ番号を元にリニアな論理セクタ番号を計
算し、論理セクタの内容をFIFOメモリ206へ転送
し、コマンド/データ・ラッチ205のSectorNumberの
インクリメントも行う。FIFOメモリ206は、IC
カード200の内部バスから書き込んだデータを外部バ
スから読み出すことができ、また外部バスから書き込ん
だデータをICカード内部バスから読み出す構成となっ
たFIFOメモリである。
In step S4208, processing for the ReadSector (s) command is performed. ReadSector (s) command
The number of sectors to be read is designated by SectorCount in FIG. Therefore, in step S4208, the sector at the designated location is read out in sectro counts. In the storage management system of this embodiment, since the management is performed using the linear logical sector number, the cylinder /
A linear logical sector number is calculated based on the head / sector number, the contents of the logical sector are transferred to the FIFO memory 206, and the SectorNumber of the command / data latch 205 is also incremented. The FIFO memory 206 is an IC
This is a FIFO memory configured so that the data written from the internal bus of the card 200 can be read from the external bus and the data written from the external bus can be read from the IC card internal bus.

【0191】ここで、上述のリニアな論理セクタ番号に
ついて説明する。一般にハードディスクに対して指定す
る番号は、セクタ、シリンダ、ヘッドのパラメータで決
まる3次元の不連続な番号である。例えば、シリンダ数
が1024個、ヘッド数が16個、セクタ数が63個の
ハードディスクの場合、セクタ数は1024×16×6
3=1032192個となる。
Now, the above-mentioned linear logical sector number will be described. Generally, the number specified for a hard disk is a three-dimensional discontinuous number determined by the parameters of sector, cylinder, and head. For example, in the case of a hard disk having 1024 cylinders, 16 heads, and 63 sectors, the number of sectors is 1024 × 16 × 6.
3 = 1032192.

【0192】このセクタを0番から1032192番と
してアクセスできると良いのであるが、上記の3つのパ
ラメータをすべて指定してアクセスするように設計され
ている。例えば、シリンダ500・ヘッド16・セクタ
63の次は、シリンダ501・ヘッド0・セクタ1をア
クセスするといった具合である。なお、これら3つのパ
ラメータをそれぞれの頭文字をとってCHSパラメータ
と呼ぶ。
It is desirable that this sector can be accessed from 0 to 1032192, but it is designed to access by designating all of the above three parameters. For example, next to the cylinder 500 / head 16 / sector 63, the cylinder 501 / head 0 / sector 1 is accessed. Note that these three parameters are called CHS parameters by taking their initials.

【0193】MS−DOS(商標)のようなオペレーテ
ィングシステムでは、内部ではリニア(連続的)なセク
タ番号を用いるが、デバイスドライバがこれをCHSパ
ラメータに変換する。本実施形態のシステムでは、リニ
アなセクタ番号を用いるのでCHSパラメータの値を元
にリニアなセクタ番号を求める。上記で挙げたハードデ
ィスクの場合は、 シリンダ番号×(16×63)+ヘッド番号×(63)
+セクタ番号 を計算することで、リニアな論理セクタ番号が求まる。
In an operating system such as MS-DOS (trademark), a linear (continuous) sector number is used internally, but the device driver converts this into a CHS parameter. In the system of the present embodiment, since a linear sector number is used, the linear sector number is obtained based on the CHS parameter value. In the case of the hard disks listed above, cylinder number x (16 x 63) + head number x (63)
By calculating + sector number, a linear logical sector number can be obtained.

【0194】ステップS4209はデータラッチで指定
された場所のセクタへデータを書き込む処理を行う。デ
ータは、FIFOメモリ206経由でホストシステムか
ら受け取る。
In step S4209, data is written to the sector at the location designated by the data latch. The data is received from the host system via the FIFO memory 206.

【0195】ステップS4210は、ICカード200
がどのようなハードディスクをエミュレーションしてい
るかという情報を返す処理を行う。すなわちシリンダ数
やModelNumberなどハードディスクとしてのスペックを
含むデータをFIFOメモリ206へ書き込む処理を行
う。
Step S4210 is for the IC card 200.
Process to return information about what hard disk is emulated by. That is, a process of writing data including specifications such as the number of cylinders and Model Number as a hard disk into the FIFO memory 206 is performed.

【0196】<ファイルシステムの解析>以上説明した
様に実施形態1で説明した記憶管理システムをICカー
ドに組み込むことで、ATAハードディスク等の置き換
え用途に使用できる。しかし、ATAコマンド等のFA
Tキャッシュやファイル消去によって生じた不要セクタ
の開放といった処理を行う為の情報を上位システムから
もらう手法が無い。ATAコマンドの空き部分を利用し
てセクタの開放コマンドとキャッシュするセクタ番号指
定コマンドを追加実装することで、FATキャッシュと
不要セクタ解放の機能が実現できる。そして、この様な
機能があることを想定していない現状のMS−DOS等
のシステムでも、FATキャッシュやセクタの開放を実
現できた方が良いことは言うまでもない。
<Analysis of File System> As described above, by incorporating the storage management system described in the first embodiment into an IC card, it can be used for replacing an ATA hard disk or the like. However, FA such as ATA command
There is no method for receiving information from the host system for performing processing such as releasing unnecessary sectors generated by T cache or file deletion. The FAT cache and unnecessary sector release functions can be realized by additionally mounting a sector release command and a sector number designation command to be cached by utilizing the empty portion of the ATA command. Needless to say, it is better to realize the release of the FAT cache and the sector even in the current system such as MS-DOS which is not supposed to have such a function.

【0197】FATシステムは論理セクタ番号0に相当
する部分にFATの場所やサイズといった情報を格納し
ている。本実施形態では、このセクタを読むことでFA
Tの場所やサイズを取得し、FATキャッシュの処理に
利用する。同様に本来書き込みデータの内容を理解しな
いはずのICカードであるが、ファイルシステムの為の
情報(ディレクトリエントリやFAT)を解析すること
でICカードが自立的に不要セクタを判断して開放する
等の処理に役立てることが出来る。もちろんFATに限
った話では無く、HPFSやマッキントッシュ(商標)
のファイルシステムでも書き込むデータの内容を解析す
れば、不要セクタの検出が可能である。この様に構成す
ることでATAハードディスクのインタフェースでも、
ファイルシステムの動作に合わせた最適化処理を行うこ
とを可能にする。
The FAT system stores information such as FAT location and size in the portion corresponding to logical sector number 0. In this embodiment, FA is read by reading this sector.
The location and size of T are acquired and used for FAT cache processing. Similarly, although it is an IC card that originally should not understand the contents of write data, by analyzing the information (directory entry or FAT) for the file system, the IC card autonomously determines and opens unnecessary sectors. Can be useful for processing. Of course, it is not limited to FAT, but HPFS and Macintosh (trademark).
Even with this file system, unnecessary sectors can be detected by analyzing the contents of the data to be written. With this configuration, even with an ATA hard disk interface,
It is possible to perform optimization processing that matches the operation of the file system.

【0198】上記装置の機能もしくは方法の機能によっ
て達成される本発明の目的は、前述の実施形態のプログ
ラムを記憶させた記憶媒体によっても達成できる。例え
ば、パーソナルコンピュータに、その記憶媒体を装着
し、その記憶媒体から読み出した以下に説明するような
フラッシュROM管理プログラムを実行することによ
り、フラッシュROMをディスクシステムと同等に使用
できるようになるとともに、書き換え耐久の分散化を図
れる。このための本発明にかかるプログラムの構造的特
徴は、図49に示す通りである。
The object of the present invention achieved by the function of the above apparatus or the function of the method can also be achieved by the storage medium in which the program of the above-described embodiment is stored. For example, by mounting the storage medium on a personal computer and executing the flash ROM management program read from the storage medium as described below, the flash ROM can be used in the same manner as the disk system, and Rewriting durability can be dispersed. The structural characteristics of the program according to the present invention for this purpose are as shown in FIG.

【0199】図49は本実施形態における記憶媒体に格
納される制御プログラムの制御手順、及び本記憶媒体の
メモリマップを示す図である。
FIG. 49 is a diagram showing a control procedure of the control program stored in the storage medium in the present embodiment and a memory map of the storage medium.

【0200】図49(a)において、350は管理処理
であり、データ領域、及びデータ領域に対応する管理領
域とで構成される複数のセクタをフラッシュROMに形
成し、各セクタにおいてデータ領域の記憶状態を示す状
態情報(セクタ番号154、使用中フラグ155、使用
済フラグ156)を管理領域に格納し、該状態情報に基
づいてフラッシュROM15のアクセスを管理する。例
えば、図18や図19のフローチャートで示したよう
に、セクタ単位でのフラッシュROMへのデータの書込
みや読出しを制御する。
In FIG. 49 (a), reference numeral 350 denotes a management process, in which a plurality of sectors including a data area and a management area corresponding to the data area are formed in the flash ROM, and the data area is stored in each sector. The status information (sector number 154, in-use flag 155, used flag 156) indicating the status is stored in the management area, and access to the flash ROM 15 is managed based on the status information. For example, as shown in the flowcharts of FIGS. 18 and 19, writing and reading of data to and from the flash ROM in units of sectors are controlled.

【0201】351は消去処理であり、フラッシュRO
M内のイレースブロックについて、状態情報に基づいて
データ領域に有効データが存在するセクタを抽出し、そ
の内容を移動させて当該イレースブロックを消去する。
これは、図24のフローチャートで示したガベージコレ
クション処理である。
Reference numeral 351 denotes an erasing process, which is a flash RO.
With respect to the erase block in M, a sector in which valid data exists in the data area is extracted based on the state information, and the content is moved to erase the erase block.
This is the garbage collection process shown in the flowchart of FIG.

【0202】352はカウント処理であり、消去処理3
51による消去が行われた回数を消去回数としてイレー
スブロック毎にカウントし、該消去回数を各イレースブ
ロックの消去回数カウンタ152に記憶する。これは、
図28のステップS1102、S1104で示される処
理である。
Reference numeral 352 denotes a count process, which is an erasing process 3
The number of erases performed by 51 is counted as the number of erases for each erase block, and the number of erases is stored in the erase count counter 152 of each erase block. this is,
This is the process shown in steps S1102 and S1104 of FIG.

【0203】353は決定処理であり、消去処理351
において消去対象となるべきイレースブロックを消去回
数カウンタの値に基づいて決定する。これは、図25の
フローチャートで示される処理である。
Reference numeral 353 represents a decision process, which is an erasing process 351.
The erase block to be erased is determined on the basis of the value of the erase count counter. This is the process shown in the flowchart of FIG.

【0204】実際の制御手順は、管理処理350によっ
てガベージコレクション処理の開始が指示されると、決
定処理353が消去回数カウンタ152を参照して消去
対象のイレースブロックを決定する。消去処理351
で、決定処理で決定された消去対象のイレースブロック
に対して消去処理を実行すると、カウント処理352に
よって、当該イレースブロックの消去回数カウンタ15
2が1つインクリメントされる。
In the actual control procedure, when the start of the garbage collection process is instructed by the management process 350, the decision process 353 refers to the erase count counter 152 to decide the erase block to be erased. Erasing process 351
Then, when the erase process is executed for the erase block to be erased determined in the determination process, the count process 352 causes the erase count counter 15 of the erase block to be erased.
2 is incremented by 1.

【0205】上記制御手順を実現するための制御プログ
ラムは、フロッピーディスクやハードディスク、あるい
はCD−ROM等の記憶媒体に、例えば図49の(b)
のメモリマップに示すような構成で格納される。上記制
御プログラムは、例えばパーソナルコンピュータ等の情
報処理装置によって読み出され、主記憶(RAM)上に
ロードされて、CPUにより実行される。なお、主記憶
上への上記制御プログラムのロードは、LANを介して
行われてもよい。
The control program for realizing the above control procedure is stored in a storage medium such as a floppy disk, a hard disk, or a CD-ROM, for example, in FIG. 49 (b).
The memory map of FIG. The control program is read by an information processing device such as a personal computer, loaded into the main memory (RAM), and executed by the CPU. The control program may be loaded into the main memory via the LAN.

【0206】なお、図49(b)において、管理処理モ
ジュール350’、決定処理モジュール353’、消去
処理モジュール351’、カウント処理モジュール35
2’は、それぞれ制御手順で示した管理処理350、決
定処理353、消去処理351、カウント処理352の
各処理を実行するプログラムモジュールである。
Incidentally, in FIG. 49B, the management processing module 350 ', the determination processing module 353', the deletion processing module 351 ', and the count processing module 35.
Reference numeral 2'denotes a program module that executes each of the management processing 350, the determination processing 353, the deletion processing 351, and the count processing 352 shown in the control procedure.

【0207】また、本発明は、複数の機器から構成され
るシステムに適用しても、1つの機器からなる装置に適
用してもよい。また、本発明はシステム或は装置にプロ
グラムを供給することによって達成される場合にも適用
できることは言うまでもない。この場合、本発明に係る
プログラムを格納した記憶媒体が、本発明を構成するこ
とになる。そして、該記憶媒体からそのプログラムをシ
ステム或は装置に読み出すことによって、そのシステム
或は装置が、予め定められた仕方で動作する。
The present invention may be applied to a system composed of a plurality of devices or an apparatus composed of a single device. Further, it goes without saying that the present invention can be applied to the case where it is achieved by supplying a program to a system or an apparatus. In this case, the storage medium storing the program according to the present invention constitutes the present invention. Then, by reading the program from the storage medium to the system or device, the system or device operates in a predetermined manner.

【0208】[0208]

【発明の効果】以上説明したように、本発明によれば、
フラッシュROMをファイルシステムに適応させること
が可能な管理方式において、各消去単位毎の消去回数の
ばらつきを減少させることが可能となる。
As described above, according to the present invention,
In the management system capable of adapting the flash ROM to the file system, it is possible to reduce the variation in the erase count for each erase unit.

【0209】[0209]

【図面の簡単な説明】[Brief description of drawings]

【図1】実施形態1におけるカメラシステムの構成を表
すブロック図である。
FIG. 1 is a block diagram illustrating a configuration of a camera system according to a first embodiment.

【図2】本実施形態の電子カメラにおけるファイルシス
テムの階層構造を表す図である。
FIG. 2 is a diagram showing a hierarchical structure of a file system in the electronic camera of this embodiment.

【図3】デバイスドライバの管理ブロックをC言語で記
述した宣言文を示す図である。
FIG. 3 is a diagram showing a declaration statement in which a management block of a device driver is described in C language.

【図4】フラッシュROM上のセクタ構造の例を示す図
である。
FIG. 4 is a diagram showing an example of a sector structure on a flash ROM.

【図5】管理領域用データと、データ領域とを分離して
格納する構成を表す図である。
FIG. 5 is a diagram illustrating a configuration in which management area data and a data area are separately stored.

【図6】各フラグの状態に対応した意味を示す図であ
る。
FIG. 6 is a diagram showing the meaning corresponding to the state of each flag.

【図7】フラッシュROMにおけるセクタの書き換え手
順を説明する図である。
FIG. 7 is a diagram illustrating a sector rewriting procedure in a flash ROM.

【図8】本実施形態におけるフラッシュROMのガベー
ジコレクション動作を説明する図である。
FIG. 8 is a diagram illustrating a garbage collection operation of the flash ROM according to the present embodiment.

【図9】未使用セクタが存在しない場合のガベージコレ
クションの動作を説明する図である。
FIG. 9 is a diagram for explaining the operation of garbage collection when there are no unused sectors.

【図10】DRAM上に作成された記憶場所管理テーブ
ルを説明する図である。
FIG. 10 is a diagram illustrating a storage location management table created on a DRAM.

【図11】キャッシュソフトウエアの階層的な位置付け
を表す図である。
FIG. 11 is a diagram showing a hierarchical positioning of cache software.

【図12】キャッシュの主記憶上のデータ構造を表わす
図である。
FIG. 12 is a diagram showing a data structure on a main memory of a cache.

【図13】FATキャッシュの読み出し手順を表すフロ
ーチャートである。
FIG. 13 is a flowchart showing a procedure for reading a FAT cache.

【図14】FATキャッシュの書込み手順を表すフロー
チャートである。
FIG. 14 is a flowchart showing a write procedure of a FAT cache.

【図15】データ書き込み完了を確認するための動作手
順をC言語で表現した図である。
FIG. 15 is a diagram expressing the operation procedure for confirming the completion of data writing in C language.

【図16】DC/DCコンバータの出力容量を越えない
様に電源を管理するプログラムをC言語で表現した図で
ある。
FIG. 16 is a diagram expressing a program for managing a power supply in C language so as not to exceed an output capacity of a DC / DC converter.

【図17】本実施形態のリブートからサービスの開始ま
での動作手順を表わすフローチャートである。
FIG. 17 is a flowchart showing an operation procedure from rebooting to starting a service according to the present embodiment.

【図18】指定セクタの読み出しサービスの手順を表わ
すフローチャートである。
FIG. 18 is a flowchart showing the procedure of a read service of a designated sector.

【図19】論理セクタの書き込みサービスの手順を表わ
すフローチャートである。
FIG. 19 is a flowchart showing the procedure of a logical sector write service.

【図20】主記憶上に獲得した退避データリストの様子
である。
FIG. 20 is a state of the saved data list acquired on the main memory.

【図21】記憶を破棄する手順を表わすフローチャート
である。
FIG. 21 is a flowchart showing a procedure for discarding storage.

【図22】記憶効率の評価手順を表わすフローチャート
である。
FIG. 22 is a flowchart showing a storage efficiency evaluation procedure.

【図23】フラッシュROMの記憶領域の獲得手順を表
わすフローチャートである。
FIG. 23 is a flowchart showing a procedure for acquiring a storage area of a flash ROM.

【図24】ガベージコレクションの手順を表わすフロー
チャートである。
FIG. 24 is a flowchart showing a procedure of garbage collection.

【図25】整理対象ブロック選出する手順を表わすフロ
ーチャートである。
FIG. 25 is a flowchart showing a procedure for selecting rearrangement target blocks.

【図26】整理対象ブロックの未使用セクタを使用済み
化する手順を表わすフローチャートである。
FIG. 26 is a flowchart showing a procedure of converting unused sectors of a rearrangement target block into used sectors.

【図27】整理対象ブロックの使用中セクタの移動手順
を表わすフローチャートである。
FIG. 27 is a flowchart showing a procedure of moving a used sector of a rearrangement target block.

【図28】整理対象となったイレースブロックの消去手
順を表わすフローチャートである。
FIG. 28 is a flowchart showing a procedure for erasing erase blocks that have been arranged.

【図29】論理セクタの解放手順を表すフローチャート
である。
FIG. 29 is a flowchart showing a procedure for releasing a logical sector.

【図30】実施形態2におけるICカードの構成を表す
ブロック図である。
FIG. 30 is a block diagram showing a configuration of an IC card according to the second embodiment.

【図31】本実施形態2のICカードを利用する為のホ
ストシステムの簡単なブロック図である。
FIG. 31 is a simple block diagram of a host system for using the IC card of the second embodiment.

【図32】図31のホストシステムがICカードを接続
する際の手順を示すフローチャートである。
32 is a flowchart showing a procedure when the host system in FIG. 31 connects an IC card.

【図33】ICカード内のマイクロコンピュータのメイ
ンシーケンスを示すフローチャートである。
FIG. 33 is a flowchart showing the main sequence of the microcomputer in the IC card.

【図34】ICカード内のマイクロコンピュータの割り
込み処理の手順を表すフローチャートである。
FIG. 34 is a flowchart showing the procedure of interrupt processing of the microcomputer in the IC card.

【図35】IOアドレスの割り付け状態を表す図であ
る。
FIG. 35 is a diagram showing an IO address allocation state.

【図36】電源種別に基づいてガベージコレクション処
理を切り換える場合の処理手順を説明するフローチャー
トである。
FIG. 36 is a flowchart illustrating a processing procedure for switching garbage collection processing based on a power source type.

【図37】ファイルシステムよりファイル消去が指示さ
れた場合の、不要セクタの解放手順を表すフローチャー
トである。
FIG. 37 is a flowchart showing a procedure of releasing unnecessary sectors when a file erase is instructed by the file system.

【図38】本実施形態における消去処理速度向上のため
の前処理の制御手順を表すフローチャートである。
FIG. 38 is a flow chart showing a control procedure of preprocessing for improving the erase processing speed in the present embodiment.

【図39】本実施形態におけるフラッシュROMへの1
バイトデータの書込み手順を表すフローチャートであ
る。
FIG. 39 shows a flash ROM 1 in the present embodiment.
It is a flow chart showing a writing procedure of byte data.

【図40】電源の共有手順を説明するためのフローチャ
ートである。
FIG. 40 is a flowchart illustrating a procedure for sharing a power supply.

【図41】本実施形態におけるフラッシュROMへの制
御プログラムの格納状態を説明する図である。
FIG. 41 is a diagram illustrating a storage state of a control program in a flash ROM according to the present embodiment.

【図42】相対アドレスで表現されたプログラムコード
の一例を表す図である。
FIG. 42 is a diagram showing an example of a program code expressed by a relative address.

【図43】図42のリロケーション情報レコードのデー
タを格納するテーブルを表す図である。
43 is a diagram showing a table storing data of the relocation information record of FIG. 42. FIG.

【図44】図41のプログラムを主記憶の8710番地
へマッピングした場合のプログラムコードを示す図であ
る。
44 is a diagram showing a program code when the program of FIG. 41 is mapped to address 8710 of the main memory.

【図45】ディレクトリスロットの特徴を表す図であ
る。
FIG. 45 is a diagram illustrating characteristics of a directory slot.

【図46】図45のディレクトリスロットにおいて、Fi
leB が削除された状態を示す図である。
FIG. 46 shows the Fi slot in the directory slot of FIG.
It is a figure which shows the state in which leB was deleted.

【図47】本実施形態のDOS互換ファイルシステムで
ファイルを消去した後の状態を表す図である。
FIG. 47 is a diagram showing a state after deleting a file in the DOS compatible file system of the present embodiment.

【図48】本実施形態による電源資源(セマフォ)の時
分割利用を説明するフローチャートである。
FIG. 48 is a flow chart illustrating time division use of power source resources (semaphores) according to the present embodiment.

【図49】本実施形態の制御を実現する制御プログラム
を提供する記憶媒体の内容を説明する図である。
FIG. 49 is a diagram illustrating the contents of a storage medium that provides a control program that realizes the control of the present embodiment.

Claims (5)

【特許請求の範囲】[Claims] 【請求項1】 データ領域、及びデータ領域に対応する
管理領域とで構成される複数の記憶ブロックをフラッシ
ュROMに形成し、各記憶ブロックにおいてデータ領域
の記憶状態を示す状態情報を管理領域に格納し、該状態
情報に基づいてフラッシュROMのアクセスを管理する
管理手段と、 前記フラッシュROM内の消去ブロックについて、前記
状態情報に基づいてデータ領域に有効データが存在する
記憶ブロックを抽出し、その内容を移動させて当該消去
ブロックを消去する消去手段と、 前記消去手段による消去が行われた回数を消去回数とし
て消去ブロック毎にカウントし、該消去回数を消去ブロ
ックの記憶領域に記憶するカウント手段と、 前記消去手段において消去対象となる消去ブロックを前
記消去回数に基づいて決定する決定手段とを備えること
を特徴とするフラッシュROM管理装置。
1. A plurality of storage blocks each comprising a data area and a management area corresponding to the data area are formed in a flash ROM, and status information indicating a storage status of the data area in each storage block is stored in the management area. Management means for managing access to the flash ROM based on the status information, and a memory block having valid data existing in the data area based on the status information, for the erase block in the flash ROM, and its contents Erasing means for moving the erasing block to erase the erasing block, and counting means for counting the number of times erasing by the erasing means is performed for each erasing block and storing the erasing number in the storage area of the erasing block. A deciding unit for deciding an erasing block to be erased by the erasing means based on the erasing count A flash ROM management device comprising: a step.
【請求項2】 前記決定手段は、無効データを含む消去
ブロックのうち前記消去回数の少ない消去ブロックを消
去対象に決定することを特徴とする請求項1に記載のフ
ラッシュROM管理装置。
2. The flash ROM management apparatus according to claim 1, wherein the determining unit determines an erase block having a small erase count among erase blocks including invalid data as an erase target.
【請求項3】 データ領域、及びデータ領域に対応する
管理領域とで構成される複数の記憶ブロックをフラッシ
ュROMに形成し、各記憶ブロックにおいてデータ領域
の記憶状態を示す状態情報を管理領域に格納し、該状態
情報に基づいてフラッシュROMのアクセスを管理する
管理工程と、 前記フラッシュROM内の消去ブロックについて、前記
状態情報に基づいてデータ領域に有効データが存在する
記憶ブロックを抽出し、その内容を移動させて当該消去
ブロックを消去する消去工程と、 前記消去工程による消去が行われた回数を消去回数とし
て消去ブロック毎にカウントし、該消去回数を消去ブロ
ックの記憶領域に記憶するカウント工程と、 前記消去工程において消去対象となる消去ブロックを前
記消去回数に基づいて決定する決定工程とを備えること
を特徴とするフラッシュROM管理方法。
3. A plurality of storage blocks each including a data area and a management area corresponding to the data area are formed in a flash ROM, and status information indicating a storage status of the data area in each storage block is stored in the management area. Then, a management step of managing access to the flash ROM based on the status information, and for an erase block in the flash ROM, a storage block in which valid data exists in a data area based on the status information is extracted, and the contents thereof are extracted. And an erasing step of erasing the erase block, and a counting step of counting the number of times of erasing in the erasing step as the erase number for each erase block and storing the erase number in the storage area of the erase block. A decision process for deciding an erase block to be erased in the erase step based on the erase count. And a flash ROM management method.
【請求項4】 前記決定工程は、無効データを含む消去
ブロックのうち前記消去回数の少ない消去ブロックを消
去対象に決定することを特徴とする請求項3に記載のフ
ラッシュROM管理方法。
4. The flash ROM management method according to claim 3, wherein the deciding step decides an erasing block having a small erasing frequency among erasing blocks including invalid data as an erasing target.
【請求項5】 メモリ媒体から所定のプログラムを読み
込んでコンピュータを制御するコンピュータ制御装置で
あって、前記メモリ媒体は、 データ領域、及びデータ領域に対応する管理領域とで構
成される複数の記憶ブロックをフラッシュROMに形成
し、各記憶ブロックにおいてデータ領域の記憶状態を示
す状態情報を管理領域に格納し、該状態情報に基づいて
フラッシュROMのアクセスを管理する管理工程の手順
コードと、 前記フラッシュROM内の消去ブロックについて、前記
状態情報に基づいてデータ領域に有効データが存在する
記憶ブロックを抽出し、その内容を移動させて当該消去
ブロックを消去する消去工程の手順コードと、 前記消去工程による消去が行われた回数を消去回数とし
て消去ブロック毎にカウントし、該消去回数を消去ブロ
ックの記憶領域に記憶するカウント工程の手順コード
と、 前記消去工程において消去対象となる消去ブロックを前
記消去回数に基づいて決定する決定工程の手順コードと
を備えることを特徴とするコンピュータ制御装置。
5. A computer controller for controlling a computer by reading a predetermined program from a memory medium, the memory medium comprising a plurality of storage blocks each comprising a data area and a management area corresponding to the data area. In a flash ROM, stores status information indicating a storage status of a data area in each storage block in a management area, and manages access to the flash ROM based on the status information. For the erase block in the memory block, a storage block in which valid data exists in the data area is extracted based on the status information, and the contents are moved to erase the erase block. Is performed for each erase block, and the number of erase times A computer comprising a procedure code of a counting step of storing a number in a storage area of an erase block and a procedure code of a determining step of determining an erase block to be erased in the erase step based on the erase count. Control device.
JP25123895A 1995-09-28 1995-09-28 Method and device for managing flash rom and computer control equipment Withdrawn JPH0997218A (en)

Priority Applications (3)

Application Number Priority Date Filing Date Title
JP25123895A JPH0997218A (en) 1995-09-28 1995-09-28 Method and device for managing flash rom and computer control equipment
US08/710,946 US5933847A (en) 1995-09-28 1996-09-24 Selecting erase method based on type of power supply for flash EEPROM
US09/350,188 US6604168B2 (en) 1995-09-28 1999-07-09 Flash eeprom management using ratio of used to unused sectors

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP25123895A JPH0997218A (en) 1995-09-28 1995-09-28 Method and device for managing flash rom and computer control equipment

Publications (1)

Publication Number Publication Date
JPH0997218A true JPH0997218A (en) 1997-04-08

Family

ID=17219784

Family Applications (1)

Application Number Title Priority Date Filing Date
JP25123895A Withdrawn JPH0997218A (en) 1995-09-28 1995-09-28 Method and device for managing flash rom and computer control equipment

Country Status (1)

Country Link
JP (1) JPH0997218A (en)

Cited By (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH11120085A (en) * 1997-10-15 1999-04-30 Matsushita Electric Works Ltd Control system
JP2003228513A (en) * 2001-11-28 2003-08-15 Access:Kk Memory control method and device
JPWO2005008499A1 (en) * 2003-07-16 2006-09-07 松下電器産業株式会社 Data area management method in information recording medium, and information processing apparatus using data area management method
JP2007018219A (en) * 2005-07-07 2007-01-25 Matsushita Electric Ind Co Ltd Nonvolatile storage device
JP2007519996A (en) * 2003-12-30 2007-07-19 サンディスク コーポレイション Nonvolatile memory and method with phased program fault handling
KR100789406B1 (en) * 2006-11-03 2007-12-28 삼성전자주식회사 Flash memory system and garbage collection method therof
US8065473B2 (en) 2004-06-21 2011-11-22 Kabushiki Kaisha Toshiba Method for controlling memory card and method for controlling nonvolatile semiconductor memory
US8111573B2 (en) 2008-11-04 2012-02-07 Sharp Kabushiki Kaisha Nonvolatile semiconductor memory device and method of controlling the same
CN102799535A (en) * 2012-06-29 2012-11-28 记忆科技(深圳)有限公司 Solid-state disk and data processing method thereof
US8400830B2 (en) 2008-11-26 2013-03-19 Sharp Kabushiki Kaisha Nonvolatile semiconductor memory device and driving method therefor

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH0527924A (en) * 1991-07-12 1993-02-05 Internatl Business Mach Corp <Ibm> External storage system using semiconductor memory and control method thereof
JPH06124596A (en) * 1991-11-28 1994-05-06 Hitachi Ltd Memory device using flash memory
JPH06139140A (en) * 1990-12-31 1994-05-20 Intel Corp File structure of nonvolatile semiconductor memory
JPH07219720A (en) * 1993-10-01 1995-08-18 Hitachi Maxell Ltd Semiconductor memory device and its control method

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH06139140A (en) * 1990-12-31 1994-05-20 Intel Corp File structure of nonvolatile semiconductor memory
JPH0527924A (en) * 1991-07-12 1993-02-05 Internatl Business Mach Corp <Ibm> External storage system using semiconductor memory and control method thereof
JPH06124596A (en) * 1991-11-28 1994-05-06 Hitachi Ltd Memory device using flash memory
JPH07219720A (en) * 1993-10-01 1995-08-18 Hitachi Maxell Ltd Semiconductor memory device and its control method

Cited By (15)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH11120085A (en) * 1997-10-15 1999-04-30 Matsushita Electric Works Ltd Control system
JP2003228513A (en) * 2001-11-28 2003-08-15 Access:Kk Memory control method and device
US7840749B2 (en) 2003-07-16 2010-11-23 Panasonic Corporation Data area managing method in information recording medium and information processor employing data area managing
JPWO2005008499A1 (en) * 2003-07-16 2006-09-07 松下電器産業株式会社 Data area management method in information recording medium, and information processing apparatus using data area management method
US8069306B2 (en) 2003-07-16 2011-11-29 Panasonic Corporation Data area managing method in information recording medium and information processor employing data area managing method
JP4551328B2 (en) * 2003-07-16 2010-09-29 パナソニック株式会社 Data area management method in information recording medium, and information processing apparatus using data area management method
JP2007519996A (en) * 2003-12-30 2007-07-19 サンディスク コーポレイション Nonvolatile memory and method with phased program fault handling
US8065473B2 (en) 2004-06-21 2011-11-22 Kabushiki Kaisha Toshiba Method for controlling memory card and method for controlling nonvolatile semiconductor memory
US8180956B2 (en) 2004-06-21 2012-05-15 Kabushiki Kaisha Toshiba Method for controlling memory card and method for controlling nonvolatile semiconductor memory
JP2007018219A (en) * 2005-07-07 2007-01-25 Matsushita Electric Ind Co Ltd Nonvolatile storage device
US7890550B2 (en) 2006-11-03 2011-02-15 Samsung Electronics Co., Ltd. Flash memory system and garbage collection method thereof
KR100789406B1 (en) * 2006-11-03 2007-12-28 삼성전자주식회사 Flash memory system and garbage collection method therof
US8111573B2 (en) 2008-11-04 2012-02-07 Sharp Kabushiki Kaisha Nonvolatile semiconductor memory device and method of controlling the same
US8400830B2 (en) 2008-11-26 2013-03-19 Sharp Kabushiki Kaisha Nonvolatile semiconductor memory device and driving method therefor
CN102799535A (en) * 2012-06-29 2012-11-28 记忆科技(深圳)有限公司 Solid-state disk and data processing method thereof

Similar Documents

Publication Publication Date Title
US5933847A (en) Selecting erase method based on type of power supply for flash EEPROM
US6115799A (en) Information processing apparatus and associated method for managing a memory using a next fit and for reducing a memory fragmentation problem
EP1686482B1 (en) File recording device
US4435752A (en) Allocation of rotating memory device storage locations
JP3878508B2 (en) Circuit group control system
KR100877448B1 (en) Nonvolatile storage system
US6857047B2 (en) Memory compression for computer systems
US20020078264A1 (en) System and method for capturing and storing trace data signals in system main storage
EP0522780A2 (en) Control method for a computer memory device
JP2004334419A (en) Magnetic disk device, file management system, and its method
US8244955B2 (en) Storage system and its controlling method
JP3727982B2 (en) Flash ROM management method and apparatus
JP3324572B2 (en) Information processing apparatus and recording medium recording program to be executed by computer
JPH06222999A (en) Swap-block assembling method and memory control mechanism
KR20080017292A (en) Storage architecture for embedded systems
US7376758B2 (en) I/O dependency graphs
JPH0997218A (en) Method and device for managing flash rom and computer control equipment
US20060036663A1 (en) Method and apparatus for effective data management of files
JPH0997207A (en) Method, device for managing flash rom and computer control equipment
JPH0997206A (en) Method, device for managing flash rom and computer control equipment
JPH0997205A (en) Method, device for managing flash rom and computer control equipment
JP3703181B2 (en) Flash ROM management method and apparatus
JPH0997199A (en) Method and device for flash rom management and computer controller
JP3727983B2 (en) Electronic camera
JPH0997314A (en) Ic card device

Legal Events

Date Code Title Description
A977 Report on retrieval

Free format text: JAPANESE INTERMEDIATE CODE: A971007

Effective date: 20050328

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20050415

A521 Written amendment

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20050614

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20050704

A761 Written withdrawal of application

Free format text: JAPANESE INTERMEDIATE CODE: A761

Effective date: 20050902