/* * TOPPERS/JSP Kernel * Toyohashi Open Platform for Embedded Real-Time Systems/ * Just Standard Profile Kernel * * Copyright (C) 2006-2010 by Witz Corporation, JAPAN * * The above copyright holders grant permission gratis to use, * duplicate, modify, or redistribute (hereafter called use) this * software (including the one made by modifying this software), * provided that the following four conditions (1) through (4) are * satisfied. * * (1) When this software is used in the form of source code, the above * copyright notice, this use conditions, and the disclaimer shown * below must be retained in the source code without modification. * * (2) When this software is redistributed in the forms usable for the * development of other software, such as in library form, the above * copyright notice, this use conditions, and the disclaimer shown * below must be shown without modification in the document provided * with the redistributed software, such as the user manual. * * (3) When this software is redistributed in the forms unusable for the * development of other software, such as the case when the software * is embedded in a piece of equipment, either of the following two * conditions must be satisfied: * * (a) The above copyright notice, this use conditions, and the * disclaimer shown below must be shown without modification in * the document provided with the redistributed software, such as * the user manual. * * (b) How the software is to be redistributed must be reported to the * TOPPERS Project according to the procedure described * separately. * * (4) The above copyright holders and the TOPPERS Project are exempt * from responsibility for any type of damage directly or indirectly * caused from the use of this software and are indemnified by any * users or end users of this software from any and all causes of * action whatsoever. * * THIS SOFTWARE IS PROVIDED "AS IS." THE ABOVE COPYRIGHT HOLDERS AND * THE TOPPERS PROJECT DISCLAIM ANY EXPRESS OR IMPLIED WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, ITS APPLICABILITY TO A PARTICULAR * PURPOSE. IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS AND THE * TOPPERS PROJECT BE LIABLE FOR ANY TYPE OF DAMAGE DIRECTLY OR * INDIRECTLY CAUSED FROM THE USE OF THIS SOFTWARE. * * 上記著作権者は,以下の (1)〜(4) の条件を満たす場合に限り,本ソフトウェ * ア(本ソフトウェアを改変したものを含む.以下同じ)を使用・複製・改変・ * 再配布(以下,利用と呼ぶ)することを無償で許諾する. * (1) 本ソフトウェアをソースコードの形で利用する場合には,上記の著作権 * 表示,この利用条件および下記の無保証規定が,そのままの形でソース * コード中に含まれていること. * (2) 本ソフトウェアを,ライブラリ形式など,他のソフトウェア開発に使用 * できる形で再配布する場合には,再配布に伴うドキュメント(利用者マ * ニュアルなど)に,上記の著作権表示,この利用条件および下記の無保 * 証規定を掲載すること. * (3) 本ソフトウェアを,機器に組み込むなど,他のソフトウェア開発に使用 * できない形で再配布する場合には,次のいずれかの条件を満たすこと. * (a) 再配布に伴うドキュメント(利用者マニュアルなど)に,上記の著作 * 権表示,この利用条件および下記の無保証規定を掲載すること. * (b) 再配布の形態を,別に定める方法によって,TOPPERSプロジェクトに報 * 告すること. * (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損害 * からも,上記著作権者およびTOPPERSプロジェクトを免責すること.また, * 本ソフトウェアのユーザまたはエンドユーザからのいかなる理由に基づ * く請求からも,上記著作権者およびTOPPERSプロジェクトを免責すること. * * 本ソフトウェアは,無保証で提供されているものである.上記著作権者およ * びTOPPERSプロジェクトは,本ソフトウェアに関して,特定の使用目的に対す * る適合性も含めて,いかなる保証も行わない.また,本ソフトウェアの利用 * により直接的または間接的に生じたいかなる損害に関しても,その責任を負 * わない. * * @(#) $Id: cpu_config.c,v 1.1 2006/04/10 08:19:25 honda Exp $ */ /* * プロセッサ依存モジュール(TLCS-900L1用) */ #include "jsp_kernel.h" #include "check.h" #include "task.h" /* * 割込み/CPU例外ネストカウンタ */ UINT intcnt; /* * タスクコンテキストでの割込みマスク */ #ifdef SUPPORT_CHG_IPM UH task_intmask; #endif /* SUPPORT_CHG_IPM */ /* * 非タスクコンテキストでの割込みマスク */ UH int_intmask; /* * プロセッサ依存の初期化 */ void cpu_initialize() { /* 割込みネストカウント初期化(割込みコンテキスト) */ intcnt = 1; /* * タスクコンテキストでの割込みマスクの初期化 */ #ifdef SUPPORT_CHG_IPM task_intmask = 0x0000; #endif /* SUPPORT_CHG_IPM */ } /* * プロセッサ依存の終了処理 */ void cpu_terminate() { } #ifdef SUPPORT_CHG_IPM /* * 割込みマスクの変更 * * chg_ipm を使って IPM を 7(NMI 以外のすべての割込みを禁止)に変更 * することはできない.NMI 以外のすべての割込みを禁止したい場合には, * loc_cpu によりCPUロック状態にすればよい. * IPM が 0 以外の時にも,タスクディスパッチは保留されない.IPM は, * タスクディスパッチによって,新しく実行状態になったタスクへ引き継が * れる.そのため,タスクが実行中に,別のタスクによって IPM が変更さ * れる場合がある.JSPカーネルでは,IPM の変更はタスク例外処理ルーチ * ンによっても起こるので,これによって扱いが難しくなる状況は少ないと * 思われる.IPM の値によってタスクディスパッチを禁止したい場合には, * dis_dsp を併用すればよい. */ SYSCALL ER chg_ipm(IPM ipm) { ER ercd; LOG_CHG_IPM_ENTER(ipm); CHECK_TSKCTX_UNL(); CHECK_PAR(0 <= ipm && ipm <= 6); t_lock_cpu(); task_intmask = (ipm << 12); ercd = E_OK; t_unlock_cpu(); exit: LOG_CHG_IPM_LEAVE(ercd); return(ercd); } /* * 割込みマスクの参照 */ SYSCALL ER get_ipm(IPM *p_ipm) { ER ercd; LOG_GET_IPM_ENTER(p_ipm); CHECK_TSKCTX_UNL(); t_lock_cpu(); *p_ipm = (task_intmask >> 12); ercd = E_OK; t_unlock_cpu(); exit: LOG_GET_IPM_LEAVE(ercd, *p_ipm); return(ercd); } #endif /* SUPPORT_CHG_IPM */