JP5756413B2 - Control device - Google Patents

Control device Download PDF

Info

Publication number
JP5756413B2
JP5756413B2 JP2012007804A JP2012007804A JP5756413B2 JP 5756413 B2 JP5756413 B2 JP 5756413B2 JP 2012007804 A JP2012007804 A JP 2012007804A JP 2012007804 A JP2012007804 A JP 2012007804A JP 5756413 B2 JP5756413 B2 JP 5756413B2
Authority
JP
Japan
Prior art keywords
safety
stack
access
register
address
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.)
Active
Application number
JP2012007804A
Other languages
Japanese (ja)
Other versions
JP2013148999A (en
Inventor
浩二 江場
浩二 江場
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Okuma Corp
Original Assignee
Okuma Corp
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 Okuma Corp filed Critical Okuma Corp
Priority to JP2012007804A priority Critical patent/JP5756413B2/en
Publication of JP2013148999A publication Critical patent/JP2013148999A/en
Application granted granted Critical
Publication of JP5756413B2 publication Critical patent/JP5756413B2/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Description

本発明は、安全機能を実行する安全関連部を有する制御装置において、安全設計された特定のプログラムのみが、安全関連部レジスタに対してアクセスできるように集積回路内の論理を構成した、書き込み保護機能を備えた制御装置に関するものである。   The present invention relates to a write protection in which a logic in an integrated circuit is configured so that only a specific safety-designed program can access a safety-related part register in a control device having a safety-related part that executes a safety function. The present invention relates to a control device having a function.

機能安全に関する国際規格、ISO013849やIEC61508では、安全機能を実行する安全関連部が通常の機能を実行している非安全関連部の故障や、設計ミスの影響を受けないようにシステム設計することを求めている。   International standards for functional safety, ISO013849 and IEC61508, make it necessary to design a system so that safety-related parts that perform safety functions are not affected by failures of non-safety-related parts that perform normal functions or design errors. Looking for.

このため、安全関連部を備えた制御装置において、CPUが集積回路内の安全関連レジスタ、または安全処理用のワークRAMに書き込みを伴うアクセスを行う際は、特権レベルを取得した特定のサブルーチンか、所定の特殊な手順で書き込みシーケンスを実行するサブルーチンにのみ、アクセスを許可するよう、集積回路の論理を構築するのが一般的である。   For this reason, in a control device having a safety-related unit, when a CPU accesses a safety-related register in an integrated circuit or a work RAM for safety processing with writing, a specific subroutine that acquires a privilege level, In general, the logic of an integrated circuit is constructed so as to allow access only to a subroutine that executes a write sequence in a predetermined special procedure.

一方、近年の組込用途CPUのほとんどの品種は、システム管理のための特権モードを有していないため、特権モードによる保護手法を容易に利用することができない。   On the other hand, since most types of embedded use CPUs in recent years do not have a privileged mode for system management, the protection method using the privileged mode cannot be easily used.

図4は、従来の書き込み保護機能を備えた制御装置の一構成例を示すブロック図である。この例では、CPU1に、特権レベルを管理するハードウエアを内蔵しており、ハードウエア割り込みの種類毎に、呼び出される割り込み処理ルーチンに、異なる特権レベルが与えられる。また、実行中の割り込み処理ルーチンに与えられた特権レベルは、特権レベル信号17を用いて外部に伝達するよう構成されている。このような機能を有したCPU1の例として、旧モトローラ社製の68000などが挙げられる。集積回路6内には、安全関連レジスタ81から8Nが実装されており、これらのレジスタに対する書き込み信号WRS1からWRSNまでは、アドレスデコーダ15が、CPU1のアドレスバス3とライト制御信号WRN4、リード制御信号RDN5に基づいて生成している。   FIG. 4 is a block diagram showing a configuration example of a control device having a conventional write protection function. In this example, the CPU 1 incorporates hardware for managing the privilege level, and a different privilege level is given to the interrupt processing routine to be called for each type of hardware interrupt. Further, the privilege level given to the interrupt processing routine being executed is transmitted to the outside using the privilege level signal 17. An example of the CPU 1 having such a function is 68000 manufactured by the former Motorola. Safety-related registers 81 to 8N are mounted in the integrated circuit 6, and for the write signals WRS1 to WRSN for these registers, the address decoder 15 performs the address bus 3 of the CPU 1, the write control signal WRN4, and the read control signal. It is generated based on RDN5.

また、アドレスデコーダ15は、後述する保護解除判定部16からのアクセス保護解除信号が入力されている期間のみ、安全関連レジスタ81から安全関連レジスタ8Nに対する書き込み信号を出力可能なように構成されている。   The address decoder 15 is configured to be able to output a write signal from the safety-related register 81 to the safety-related register 8N only during a period in which an access protection cancellation signal from the protection cancellation determination unit 16 described later is input. .

集積回路内には、アクセス保護に関する設定を行うためのレジスタとして、アクセス保護開始レジスタ11、アクセス保護解除レジスタ12、特権レベル設定レジスタ18が設けられている。前述のCPU1の特権レベル信号17は、CPU特権レベル比較部19に入力され、特権レベル設定レジスタ18の設定値と一致している場合のみ、後段の保護解除判定部16に論理値“1”が出力される。一方、保護解除判定部16内のセットリセットフリップフロップ16aには、アクセス保護開始レジスタ11に、予め定めたデータバス2上のビットパターンを書き込むことでセットパルスが供給され、また、アクセス保護解除レジスタ12に、予め定めたデータバス2上のビットパターンを書き込むことでリセットパルスが供給されるように構成されている。セットリセットフリップフロップ16aの出力は、CPU特権レベル比較部19の出力と論理和ゲート16bで論理和がとられ、前述のアクセス保護解除信号が生成される。   In the integrated circuit, an access protection start register 11, an access protection release register 12, and a privilege level setting register 18 are provided as registers for performing settings related to access protection. The privilege level signal 17 of the CPU 1 described above is input to the CPU privilege level comparison unit 19, and only when the set value of the privilege level setting register 18 matches the logical value “1” in the protection release determination unit 16 at the subsequent stage. Is output. On the other hand, the set reset flip-flop 16a in the protection release determination unit 16 is supplied with a set pulse by writing a predetermined bit pattern on the data bus 2 to the access protection start register 11, and the access protection release register 12 is configured such that a reset pulse is supplied by writing a predetermined bit pattern on the data bus 2. The output of the set / reset flip-flop 16a is logically ORed with the output of the CPU privilege level comparison unit 19 by the OR gate 16b to generate the above access protection release signal.

図5は、図4の実施例におけるCPU内の安全関連処理ルーチンの実行内容と、図4のブロック図各部の動作をフローチャートで示したものである。
図5のフローチャートにおいて、左側の安全関連部処理ルーチンは、特権レベルおよび、割り込み優先レベルが低い状態で実行されている。例えば、安全関連部処理ルーチンを、特権レベル2、割り込み優先レベル2に割り付けたとして説明する。安全関連部処理ルーチンは、処理の開始時に、図4の特権レベル設定レジスタ18に特権レベル2を書き込み、次にアクセス保護解除レジスタ12に書き込みを行う。このことにより、安全関連レジスタ81から安全関連レジスタ8Nに対する書き込み保護が解除され、安全関連部処理ルーチンは、その後の安全関連処理を実行する。
FIG. 5 is a flowchart showing the execution contents of the safety-related processing routine in the CPU and the operation of each part of the block diagram of FIG. 4 in the embodiment of FIG.
In the flowchart of FIG. 5, the safety-related part processing routine on the left is executed in a state where the privilege level and the interrupt priority level are low. For example, it is assumed that the safety-related part processing routine is assigned to privilege level 2 and interrupt priority level 2. At the start of processing, the safety-related part processing routine writes the privilege level 2 in the privilege level setting register 18 of FIG. 4 and then writes in the access protection release register 12. As a result, the write protection for the safety-related register 8N is released from the safety-related register 81, and the safety-related part processing routine executes the subsequent safety-related processing.

一方、このルーチンよりも割り込み優先順位ならびに特権レベルが高い、例えば特権レベル4の割り込みが発生すると、図5のフローチャート中央に示す処理が開始される。CPU1内のハードウエアが割り込み信号を受け付けると、ハードウエアによる特権レベル切替処理が実行され、特権レベル信号17は、特権レベル2から特権レベル4に変化する。このことにより、CPU特権レベル比較部19は一致判定から不一致判定に変化し、論理レベルは1から0に変化する。このため、割り込み受付後の割り込み処理ルーチンにおいては、保護解除判定部16の保護解除信号がオフし、安全関連保護レジスタ群に対する書き込みは、一時的に保護され、非安全関連処理ルーチン内で、誤って書き込み処理が行われる事を防止する。   On the other hand, when an interrupt having a higher interrupt priority and privilege level than this routine, eg, privilege level 4, occurs, the process shown in the center of the flowchart of FIG. 5 is started. When the hardware in the CPU 1 accepts an interrupt signal, the privilege level switching process by the hardware is executed, and the privilege level signal 17 changes from the privilege level 2 to the privilege level 4. As a result, the CPU privilege level comparison unit 19 changes from match determination to mismatch determination, and the logic level changes from 1 to 0. For this reason, in the interrupt processing routine after acceptance of the interrupt, the protection cancellation signal of the protection cancellation determination unit 16 is turned off, and writing to the safety-related protection register group is temporarily protected, and an error occurs in the non-safety-related processing routine. To prevent the writing process from being performed.

次に、非安全関連処理ルーチンの処理が終了し、割り込み復帰処理が開始されると、CPU1の出力する特権レベル信号17は、特権レベル4から特権レベル2に回復するため、再びアクセス保護解除信号が1に変化して、安全関連レジスタ群への書き込みが許可される。   Next, when the processing of the non-safety related processing routine is finished and the interrupt return processing is started, the privilege level signal 17 output from the CPU 1 is restored from the privilege level 4 to the privilege level 2, so Changes to 1 to allow writing to the safety-related registers.

このように、図4の構成をとることで、任意のタイミングで特権レベルの高い、割り込み優先レベルが上位の割り込みが起動されても、割り込み処理に移行した期間では、一時的に保護処理が再開され、割り込み処理内において安全関連レジスタに、誤って書き込みアクセスすることが防止される。   In this way, by adopting the configuration of FIG. 4, even if an interrupt with a high privilege level and a higher interrupt priority level is activated at any timing, protection processing is temporarily resumed during the transition to interrupt processing. Thus, erroneous access to the safety-related registers in the interrupt processing is prevented.

特開2009−020880号公報JP 2009-020880 A 特開2008−047129号公報JP 2008-047129 A

図4に示すような従来の制御装置においては、CPU1からCPU1の現在の特権モードを出力する外部ピンが必要であるが、近年の高性能な組み込み用途CPUは、特権モード自体を有しない。また、複数の割り込みの優先順位を持つものの、現在の割り込みマスクレベルを外部ピンに出力する機能を有しないため、割り込みマスクレベルを、特権レベルの代替えとして外部回路が用いることもできない。   In the conventional control device as shown in FIG. 4, an external pin for outputting the current privilege mode of the CPU 1 from the CPU 1 is necessary, but recent high performance embedded use CPUs do not have the privilege mode itself. In addition, although it has a plurality of interrupt priorities, it does not have a function of outputting the current interrupt mask level to an external pin, so that the interrupt mask level cannot be used by an external circuit as a substitute for the privilege level.

この発明の目的は、特権モードを出力する外部ピンを有しないCPUにおいて、安全機能を実行する処理ルーチンより割り込み優先順位が高い非安全関連処理ルーチンが起動された場合において、非安全関連処理ルーチンに対して、安全関連レジスタへのアクセス解除状態が引き継がれないように保護する制御装置を提供することにある。   An object of the present invention is to provide a non-safety-related processing routine when a non-safety-related processing routine having a higher interrupt priority than a processing routine that executes a safety function is activated in a CPU that does not have an external pin that outputs a privileged mode. On the other hand, it is an object of the present invention to provide a control device that protects an access release state to a safety-related register from being taken over.

本発明に係る制御装置は、安全関連処理ルーチンが集積回路内の安全関連レジスタに対するアクセス保護を解除する直前に、現在のスタックポインタの値を、集積回路のスタックアドレス設定レジスタに設定し、保護解除中の期間、集積回路がCPUがスタックにアクセスする事を監視することによって、上位の割り込みが動作してスタックポインタが退避された場合には、同一アドレスがリードされ、スタック復帰するまでの間、一時的にアクセス保護を再開するよう構成することによって、所望の動作を実現する。   The control device according to the present invention sets the current stack pointer value in the stack address setting register of the integrated circuit and releases the protection immediately before the safety-related processing routine releases the access protection to the safety-related register in the integrated circuit. During the middle period, when the integrated circuit monitors that the CPU accesses the stack, when the upper interrupt is operated and the stack pointer is saved, the same address is read and until the stack returns. A desired operation is realized by temporarily resuming access protection.

本発明によれば、CPUが特権レベルを管理する構成を備えていなくても、優先順位の高い割り込みの処理による安全関連レジスタへのアクセスを防止することができる。   According to the present invention, even if the CPU does not have a configuration for managing the privilege level, it is possible to prevent access to safety-related registers due to interrupt processing with a high priority.

本発明に係る制御装置の実施形態の一例を示す図である。It is a figure which shows an example of embodiment of the control apparatus which concerns on this invention. 本実施形態におけるCPU処理アルゴリズムの一例を示す図である。It is a figure which shows an example of the CPU processing algorithm in this embodiment. 本実施形態におけるアクセス保護判定部の状態遷移図の一例を示す図である。It is a figure which shows an example of the state transition diagram of the access protection determination part in this embodiment. 従来のアクセス保護回路の一例を示す図である。It is a figure which shows an example of the conventional access protection circuit. 従来のアクセス保護回路におけるCPU処理アルゴリズムの一例を示す図である。It is a figure which shows an example of the CPU processing algorithm in the conventional access protection circuit.

以下、図面に基づいて、本発明の好適な実施の形態について説明する。   Hereinafter, preferred embodiments of the present invention will be described with reference to the drawings.

本発明の非安全関連部からの書き込み保護機能を備えた制御装置の一実施形態の例を、図1のブロック図と、図2のフローチャートに基づいて説明する。集積回路6内には、安全機能に関連する制御用レジスタとして、安全関連レジスタ1から安全関連レジスタN(符号81から8N)までのN個のレジスタが搭載されており、CPU1が実行する非安全関連処理ルーチンが誤ってこれらの安全関連レジスタ81〜8Nにライトアクセスすることを防止しなければならない。ここで、本実施の形態において、「安全関連処理ルーチン」というのは、安全設計された特定のプログラムであり、安全関連レジスタ81〜8Nへのアクセスが許可されているルーチンのことをいう。一方、「非安全関連処理ルーチン」というのは、安全関連処理ルーチン以外のプログラムであり、安全関連レジスタ81〜8Nへのアクセスが許可されていないルーチンのことをいう。   An example of an embodiment of a control device having a write protection function from a non-safety related part of the present invention will be described based on the block diagram of FIG. 1 and the flowchart of FIG. In the integrated circuit 6, N registers from safety-related registers 1 to safety-related registers N (reference numerals 81 to 8N) are mounted as control registers related to safety functions, and are non-safety executed by the CPU 1. It is necessary to prevent the related processing routine from performing write access to these safety related registers 81 to 8N by mistake. Here, in the present embodiment, the “safety-related processing routine” is a specific program designed to be safe and refers to a routine that is permitted to access the safety-related registers 81 to 8N. On the other hand, the “non-safety-related processing routine” is a program other than the safety-related processing routine and refers to a routine that is not permitted to access the safety-related registers 81 to 8N.

集積回路6の内部には、前述した安全関連レジスタ81〜8Nが実装されており、これらの安全関連レジスタ81〜8Nそれぞれに対する書き込み信号WRS1〜WRSNは、CPU1のアドレスバス3とライト制御信号WRN4、リード制御信号RDN5に基づいてアドレスデコーダ15により生成される。また、アドレスデコーダ15は、後述する保護解除判定部7からのアクセス保護解除信号が入力されている期間のみ安全関連レジスタ81〜8Nに対する書き込み信号を出力可能なように構成されている。   The above-described safety-related registers 81 to 8N are mounted inside the integrated circuit 6, and the write signals WRS1 to WRSN for each of these safety-related registers 81 to 8N are the address bus 3 of the CPU 1 and the write control signal WRN4, It is generated by the address decoder 15 based on the read control signal RDN5. The address decoder 15 is configured to be able to output a write signal for the safety-related registers 81 to 8N only during a period in which an access protection cancellation signal from the protection cancellation determination unit 7 described later is input.

集積回路6の内部には、更にアクセス保護に関する設定を行うためのレジスタとしてスタックアドレス設定レジスタ10、アクセス保護開始レジスタ11及びアクセス保護解除レジスタ12が設けられている。スタックアドレス設定レジスタ10では、CPU1が書き込んだ現在のスタックポインタの値に、スタックを1段積んだ際の増分値(32bitCPUでは4)を加算して、スタックアドレス書き込み判定部13と、スタックアドレス読み出し判定部14に比較アドレス値を供給している。   Inside the integrated circuit 6, a stack address setting register 10, an access protection start register 11, and an access protection release register 12 are provided as registers for performing settings related to access protection. In the stack address setting register 10, an increment value (4 for a 32-bit CPU) when the stack is stacked by 1 is added to the current stack pointer value written by the CPU 1, and the stack address write determination unit 13 and the stack address read The comparison address value is supplied to the determination unit 14.

スタックアドレス書き込み判定部13は、CPU1が割り込み処理を開始し、スタックアドレスにステータスレジスタを退避したことを検出し、保護解除判定部7内の上位割り込み検出用フリップフロップ7aのセット端子にセットパルスを供給する。スタックアドレス読み出し判定部14は、CPU1が割り込み復帰処理を開始し、スタックアドレスからステータスレジスタの復帰動作を行ったことを検出し、保護解除判定部7内の上位割り込み検出用フリップフロップ7aのリセット端子に論理和ゲート7Cを介してリセットパルスを供給する。   The stack address write determination unit 13 detects that the CPU 1 starts interrupt processing, saves the status register to the stack address, and sends a set pulse to the set terminal of the upper interrupt detection flip-flop 7a in the protection release determination unit 7. Supply. The stack address read determination unit 14 detects that the CPU 1 has started the interrupt recovery process and has performed the status register recovery operation from the stack address, and the reset terminal of the upper interrupt detection flip-flop 7a in the protection release determination unit 7 Is supplied with a reset pulse via an OR gate 7C.

保護解除判定部7の内部のセットリセットフリップフロップ7bには、予め定めたデータバス2上のビットパターンをアクセス保護開始レジスタ11に書き込むことでセットパルスが供給され、予め定めたデータバス2上のビットパターンをアクセス保護解除レジスタ12に書き込むことでリセットパルスが供給されるように構成されている。セットリセットフリップフロップ7bの出力は、上位割り込み検出用フリップフロップ7aの負論理出力と論理積ゲート7dで論理積がとられ、前述のアクセス保護解除信号が生成される。   A set pulse is supplied to the set / reset flip-flop 7b in the protection release determination unit 7 by writing a predetermined bit pattern on the data bus 2 to the access protection start register 11, and the set pulse on the predetermined data bus 2 The reset pulse is supplied by writing the bit pattern into the access protection cancellation register 12. The output of the set / reset flip-flop 7b is logically ANDed with the negative logic output of the higher-order interrupt detection flip-flop 7a by the AND gate 7d to generate the access protection release signal.

図2は、本実施形態におけるCPU1内の安全関連処理ルーチンの実行内容と、図1のブロック図各部の動作をフローチャートで示したものである。図2のフローチャートにおいて、左側の安全関連部処理ルーチンは、非安全関連部処理ルーチンに比して割り込み優先レベルが低い状態で実行される。安全関連処理ルーチンは、安全関連レジスタ群81〜8Nにライトアクセスする直前に、現在のCPU1内のスタックポインタのアドレスを読み出して、集積回路6内のスタックアドレス設定レジスタ10に書き込む。次に、アクセス保護解除レジスタ12に書き込みアクセスする。このことにより、上位割り込み検出用フリップフロップ7aはリセットされ、フリップフロップ7bはセットされる。論理積ゲート7dの入力は共に“1”に変化するため、アクセス保護解除信号は“1”に変化する。アドレスデコーダ15は、“1”のアクセス保護解除信号が入力されている間のみ安全関連レジスタ群に対するライトアクセス信号WRS1からWRSNのマスク処理を解除することで安全関連レジスタ81〜8Nへのアクセスを許可する。   FIG. 2 is a flowchart showing the execution contents of the safety-related processing routine in the CPU 1 and the operation of each part of the block diagram of FIG. In the flowchart of FIG. 2, the left safety-related part processing routine is executed in a state where the interrupt priority level is lower than that of the non-safety-related part processing routine. The safety-related processing routine reads the address of the current stack pointer in the CPU 1 and writes it in the stack address setting register 10 in the integrated circuit 6 immediately before write access to the safety-related register groups 81 to 8N. Next, the access protection release register 12 is accessed for writing. As a result, the upper interrupt detecting flip-flop 7a is reset and the flip-flop 7b is set. Since both inputs of the AND gate 7d change to “1”, the access protection release signal changes to “1”. The address decoder 15 permits access to the safety related registers 81 to 8N by canceling the mask processing of the write access signals WRS1 to WRSN for the safety related register group only while the access protection release signal of “1” is input. To do.

安全関連処理ルーチンは、安全関連レジスタ81〜8Nに対する1回目のライトアクセスを開始してから、n回目のアクセスを行うまでの間に安全関連処理ルーチンを実行している割り込みレベルよりも、割り込み優先順位が高い割り込み要求信号が入力されると、図2の左から2列目の処理が実行開始される。上位優先順位の割り込みをCPU1が受け付けると、CPU1のハードウエアが割り込みベクターテーブルを読み出し、スタックポインタを減算した後に、ステータスレジスタをスタックポインタのアドレスに書き込む。このスタックポインタアドレスに対する非安全関連処理ルーチンによる外部アドレス空間への書き込みアクセスを、集積回路6内のスタックアドレス書き込み判定部13が、スタックアドレス設定レジスタ10の設定値とアドレスバス3とを比較することで検出する。スタックへの書き込み処理が検出されると、上位割り込み検出用フリップフロップ7aがセットされ、論理積ゲート7dの出力であるアクセス保護解除信号が“0”に変化することで、安全関連レジスタ81〜8Nへの書き込みアクセスが、再び、一時的にマスクされる。次に、プログラムカウンタをスタックに退避した後、非安全関連部のソフト処理ルーチン、すなわち非安全関連処理ルーチンが実行されるが、この処理ルーチン内では、安全関連レジスタ群に対するライトアクセスは禁止されているために、これらのレジスタに誤ってライトアクセスが行われても、安全機能に障害が発生することは無い。   The safety-related processing routine has priority over the interrupt level at which the safety-related processing routine is executed after the first write access to the safety-related registers 81 to 8N until the n-th access is performed. When an interrupt request signal having a higher rank is input, the processing in the second column from the left in FIG. 2 is started. When the CPU 1 accepts an interrupt with a higher priority, the hardware of the CPU 1 reads the interrupt vector table, subtracts the stack pointer, and then writes the status register to the address of the stack pointer. The stack address write determination unit 13 in the integrated circuit 6 compares the set value of the stack address setting register 10 with the address bus 3 for the write access to the external address space by the non-safety related processing routine for the stack pointer address. Detect with. When the write processing to the stack is detected, the upper interrupt detection flip-flop 7a is set, and the access protection release signal that is the output of the logical product gate 7d changes to “0”, so that the safety related registers 81 to 8N Write access to is again temporarily masked. Next, after saving the program counter to the stack, a non-safety related part software processing routine, that is, a non-safety related processing routine is executed. Within this processing routine, write access to the safety related registers is prohibited. Therefore, even if a write access is erroneously performed to these registers, no trouble occurs in the safety function.

非安全関連処理ルーチンの実行が終了すると、退避したプログラムカウンタの値がスタックポインタのアドレスから読み出され、次に、ステータスレジスタの値が、スタックポインタのアドレスから読み出される。この時、集積回路6内のスタックアドレス読み出し判定部14は、スタックアドレス設定レジスタ10の設定値とアドレスバス3の値を比較することで、割り込み復帰処理が行われていることを検出し、上位割り込み検出用フリップフロップ7aをリセットする。これにより、論理積ゲート7dの出力であるアクセス保護解除信号が再び“1”に変化し、書き込み保護が解除される。   When the execution of the non-safety related processing routine is completed, the saved program counter value is read from the stack pointer address, and then the status register value is read from the stack pointer address. At this time, the stack address read determination unit 14 in the integrated circuit 6 compares the set value of the stack address setting register 10 with the value of the address bus 3 to detect that the interrupt return processing is being performed, The interrupt detection flip-flop 7a is reset. As a result, the access protection release signal, which is the output of the AND gate 7d, changes to “1” again, and the write protection is released.

一方、割り込みからの復帰処理が完了し、安全関連処理ルーチンの実行が再開されると、書き込み保護が解除された状態であるので、安全関連レジスタ81〜8Nへのライトアクセスが正常に再開され、所望のn回目のライトアクセスが終了した時点で、安全関連処理ルーチンは、アクセス保護開始レジスタ11をライトして、他のルーチンが安全関連レジスタ81〜8Nにライトアクセスすることを禁止する。以降、再び安全関連処理ルーチン内で、アクセス保護解除レジスタ12がライトアクセスされるか、安全関連処理ルーチンが再び呼び出されるまでは、他の非安全関連処理ルーチンにおいて安全関連レジスタ81〜8Nにライトアクセスが行われないように保護が継続する。   On the other hand, when the return processing from the interrupt is completed and the execution of the safety-related processing routine is resumed, the write protection is released, so that the write access to the safety-related registers 81 to 8N is resumed normally. When the desired n-th write access is completed, the safety-related processing routine writes the access protection start register 11 and prohibits other routines from performing write access to the safety-related registers 81 to 8N. Thereafter, until the access protection release register 12 is write-accessed again in the safety-related processing routine or until the safety-related processing routine is called again, write access to the safety-related registers 81 to 8N is performed in other non-safety-related processing routines. Protection continues so that no attempt is made.

図2の右側の列は集積回路6内の保護解除判定部7の状態を表しており、この状態を状態遷移図で書き表したものが、図3である。図3において、アクセス保護判定部7には、3つの状態S1からS3があり、電源投入時は、アクセス保護状態S1にいる。安全関連処理ルーチンが、アクセス保護解除レジスタ12とスタックアドレス設定レジスタ10に書き込みを行うことで保護解除状態S2に遷移し、安全関連処理ルーチンがアクセス保護開始レジスタ11に書き込みを行うことでアクセス保護状態S1に戻る。   The right column in FIG. 2 represents the state of the protection cancellation determination unit 7 in the integrated circuit 6, and FIG. 3 shows this state as a state transition diagram. In FIG. 3, the access protection determination unit 7 has three states S1 to S3, and is in the access protection state S1 when the power is turned on. The safety-related processing routine makes a transition to the protection release state S2 by writing to the access protection cancellation register 12 and the stack address setting register 10, and the safety-related processing routine writes to the access protection start register 11 to access protection state. Return to S1.

一方、保護解除状態S2にある期間に、CPU1により上位の割り込み優先順位の割り込みが受け付けられ、スタック退避が行われると、一時保護状態S3に遷移し、保護を実行する。一時保護状態S3は、同一スタックアドレスからのスタック復帰処理を検出することで、保護解除状態S2に自動復帰するように構成されている。なお、異常状態からの復帰処理のため、S3からS1に遷移させるためのパスが用意されている。   On the other hand, when an interrupt having a higher interrupt priority is accepted by the CPU 1 during the period in the protection release state S2 and the stack is saved, the state transits to the temporary protection state S3 to execute protection. The temporary protection state S3 is configured to automatically return to the protection release state S2 by detecting stack return processing from the same stack address. A path for making a transition from S3 to S1 is prepared for the recovery process from the abnormal state.

以上のように図1の構成をとることで、スタックアドレス設定レジスタ10に設定されたスタックポインタのアドレスをスタックアドレス書き込み判定部13が監視し、上位の割り込み優先順位の割り込みが受け付けられた場合には、保護解除判定部7に対し、アクセス保護を一時的に再開する信号が送られる。また、この状態で上位の割り込み処理が終了した場合には、スタックアドレス読み出し判定部14が割り込み終了時のスタックの読み出しを検出して、アクセス保護を再び解除するよう動作するため、上位割り込みの起動タイミングによらず、安全処理ルーチンでは任意の処理区間、アクセス保護を解除する動作が実行できるとともに、上位割り込みの実行中は、アクセス保護が解除された状態は発生しない。従って、任意のタイミングで上位の割り込みが起動されても、割り込み処理に移行した期間では、一時的に保護処理が再開され、割り込み処理内において安全関連レジスタが誤ってアクセスされることから防止できる。   As described above, the stack address write determination unit 13 monitors the address of the stack pointer set in the stack address setting register 10 by the configuration shown in FIG. Sends a signal for temporarily resuming access protection to the protection cancellation determination unit 7. In addition, when the upper interrupt processing is completed in this state, the stack address read determination unit 14 detects the reading of the stack at the end of the interrupt and operates to release the access protection again. Regardless of the timing, the safe processing routine can execute an operation for canceling access protection in an arbitrary processing section, and the state in which access protection is canceled does not occur during execution of the upper interrupt. Therefore, even if a higher-level interrupt is activated at an arbitrary timing, the protection process is temporarily resumed during the period of transition to the interrupt process, and the safety-related registers can be prevented from being erroneously accessed in the interrupt process.

1 CPU、2 データバス、3 アドレスバス、4 ライト制御信号(WRN)、5 リード制御信号(RDN)、6.集積回路、7 保護解除判定部、81〜8N 安全関連レジスタ、91〜9M 通常レジスタ、10 スタックアドレス設定レジスタ、11 アクセス保護開始レジスタ、12 アクセス保護解除レジスタ、13 スタックアドレス書き込み判定部、14 スタックアドレス読み出し判定部、15 アドレスデコーダ。   1 CPU, 2 data bus, 3 address bus, 4 write control signal (WRN), 5 read control signal (RDN), Integrated circuit, 7 Protection release determination unit, 81 to 8N Safety related register, 91 to 9M Normal register, 10 Stack address setting register, 11 Access protection start register, 12 Access protection release register, 13 Stack address write determination unit, 14 Stack address Read determination unit, 15 address decoder.

Claims (4)

安全機能に関連する制御用の安全関連レジスタに対するアクセス保護機能を内蔵した集積回路を搭載する制御装置において、
前記集積回路は、
CPUが前記安全関連レジスタへのアクセスが許可されている安全関連処理ルーチンを実行しているアクセス保護解除中に、前記安全関連処理ルーチンより優先順位の高い割り込みを受け付けた場合に行うスタックへの退避動作を検出することによりアクセス保護を一時的に再開するスタックアドレス書き込み判定部と、
前記CPUが前記優先順位の高い割り込みの処理が終了した場合に行う前記スタックからの復帰動作を検出することにより前記安全関連レジスタへのアクセス保護を解除するスタックアドレス読み出し判定部と、
を備えることを特徴とする制御装置。
In a control device equipped with an integrated circuit having an access protection function for a safety-related register for control related to a safety function,
The integrated circuit comprises:
Saving access to the stack when an interrupt with a higher priority than the safety-related processing routine is accepted while the access protection is released while the CPU is executing a safety-related processing routine in which access to the safety-related register is permitted A stack address write determination unit that temporarily resumes access protection by detecting an operation;
A stack address read determination unit for canceling access protection to the safety-related register by detecting a return operation from the stack that is performed when the processing of the high priority interrupt is completed by the CPU;
A control device comprising:
請求項1に記載の制御装置において、
前記集積回路は、
アクセス保護解除信号が入力されている間のみ前記安全関連レジスタへのアクセスを許可するアドレスデコーダと、
前記スタックアドレス読み出し判定部による前記スタックからの復帰動作の検出に応じてアクセス保護解除信号を前記アドレスデコーダへ出力する保護解除判定部と、
を備えることを特徴とする制御装置。
The control device according to claim 1,
The integrated circuit comprises:
An address decoder that permits access to the safety-related registers only while an access protection release signal is input;
A protection cancellation determination unit that outputs an access protection cancellation signal to the address decoder in response to detection of a return operation from the stack by the stack address read determination unit;
A control device comprising:
請求項1に記載の制御装置において、
前記集積回路は、前記CPUが前記安全関連レジスタにアクセスする際のスタックポインタの値が設定されるスタックアドレス設定レジスタを備え、
前記スタックアドレス書き込み判定部は、前記スタックアドレス設定レジスタの設定値と前記CPUのアドレスバスの値とを比較することでスタックへの退避動作を検出することを特徴とする制御装置。
The control device according to claim 1,
The integrated circuit includes a stack address setting register in which a stack pointer value is set when the CPU accesses the safety-related register,
The control device, wherein the stack address write determination unit detects a save operation to the stack by comparing a set value of the stack address setting register with a value of the address bus of the CPU.
請求項1に記載の制御装置において、
前記集積回路は、前記CPUが前記安全関連レジスタにアクセスする際のスタックポインタの値が設定されるスタックアドレス設定レジスタを備え、
前記スタックアドレス読み出し判定部は、前記スタックアドレス設定レジスタの設定値と前記CPUのアドレスバスの値とを比較することでスタックからの復帰動作を検出することを特徴とする制御装置。
The control device according to claim 1,
The integrated circuit includes a stack address setting register in which a stack pointer value is set when the CPU accesses the safety-related register,
The control apparatus according to claim 1, wherein the stack address read determination unit detects a return operation from the stack by comparing a set value of the stack address setting register with a value of the address bus of the CPU.
JP2012007804A 2012-01-18 2012-01-18 Control device Active JP5756413B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2012007804A JP5756413B2 (en) 2012-01-18 2012-01-18 Control device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2012007804A JP5756413B2 (en) 2012-01-18 2012-01-18 Control device

Publications (2)

Publication Number Publication Date
JP2013148999A JP2013148999A (en) 2013-08-01
JP5756413B2 true JP5756413B2 (en) 2015-07-29

Family

ID=49046459

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2012007804A Active JP5756413B2 (en) 2012-01-18 2012-01-18 Control device

Country Status (1)

Country Link
JP (1) JP5756413B2 (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP6955858B2 (en) 2016-10-17 2021-10-27 オークマ株式会社 Control device

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH05100847A (en) * 1991-10-07 1993-04-23 Nec Ibaraki Ltd Memory protection system for information processor
JPH09293020A (en) * 1996-04-26 1997-11-11 Oki Electric Ind Co Ltd Interface circuit
JP4605871B2 (en) * 2000-08-25 2011-01-05 富士通セミコンダクター株式会社 Microprocessor
JP4514066B2 (en) * 2008-04-28 2010-07-28 ルネサスエレクトロニクス株式会社 Data processing apparatus and access control method in data processing apparatus

Also Published As

Publication number Publication date
JP2013148999A (en) 2013-08-01

Similar Documents

Publication Publication Date Title
CN109558277B (en) Microcontroller and control method thereof
JP2008009721A (en) Evaluation system and evaluation method thereof
US10366018B2 (en) Control apparatus with access monitoring unit configured to request interrupt process
JP6341795B2 (en) Microcomputer and microcomputer system
US8255769B2 (en) Control apparatus and control method
JP5975923B2 (en) Vehicle control device
JP5756413B2 (en) Control device
US20100293314A1 (en) Computer system and method of controlling computer system
JP2011008702A (en) Fault processor
JPH03175537A (en) Error controller for debugging microprocessor
US8032720B2 (en) Memory access monitoring apparatus and related method
JP4340669B2 (en) INPUT / OUTPUT CONTROL DEVICE, INPUT / OUTPUT CONTROL METHOD, PROCESS CONTROL DEVICE, AND PROCESS CONTROL METHOD
JP4647276B2 (en) Semiconductor circuit device
JP6645467B2 (en) Microcomputer
JP7120957B2 (en) semiconductor equipment
JP2019020869A (en) Vehicle control device
KR102475879B1 (en) Apparatus and method for MDPS MCU core fault detection
JP2009289119A (en) Watchdog timer and microcomputer
JP3110222B2 (en) Microcomputer
JPH1069398A (en) Microcomputer for software debugging
JP2014225110A (en) Safety controller
JP2002091826A (en) Information processor
JP2008204087A (en) Operation mode control circuit for information processor and information processor
JP2008242592A (en) Memory monitoring circuit, information processing apparatus and memory monitoring method
JPH0436841A (en) Microcomputer

Legal Events

Date Code Title Description
A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20140828

A977 Report on retrieval

Free format text: JAPANESE INTERMEDIATE CODE: A971007

Effective date: 20150424

TRDD Decision of grant or rejection written
A01 Written decision to grant a patent or to grant a registration (utility model)

Free format text: JAPANESE INTERMEDIATE CODE: A01

Effective date: 20150526

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20150529

R150 Certificate of patent (=grant) or registration of utility model

Ref document number: 5756413

Country of ref document: JP

Free format text: JAPANESE INTERMEDIATE CODE: R150