ASRCS += $(SRC_PROC_CC_DIR)/kcre_ctx.s \
$(SRC_PROC_CC_DIR)/kdis_int.s \
$(SRC_PROC_CC_DIR)/kena_int.s \
- $(SRC_PROC_CC_DIR)/kirq_hdr.s \
$(SRC_PROC_CC_DIR)/krst_ctx.s \
$(SRC_PROC_CC_DIR)/kswi_ctx.s \
- $(SRC_PROC_CC_DIR)/kwai_int.s
+ $(SRC_PROC_CC_DIR)/kwai_int.s \
+ $(SRC_PROC_CC_DIR)/kirq_hdr.s \
+ $(SRC_PROC_CC_DIR)/kfiq_hdr.s
#define _KERNEL_IRC_VICProtection ((volatile UW *)0xfffff020)
#define _KERNEL_IRC_VICVectAddr ((volatile UW *)0xfffff030)
#define _KERNEL_IRC_VICDefVectAddr ((volatile UW *)0xfffff034)
-#define _KERNEL_IRC_VICVectAddrN(n) ((volatile UW *)0xfffff100 + ((n) * 4)
-#define _KERNEL_IRC_VICVectCntlN(n) ((volatile UW *)0xfffff200 + ((n) * 4)
+#define _KERNEL_IRC_VICVectAddrN(n) ((volatile UW *)0xfffff100 + ((n) * 4))
+#define _KERNEL_IRC_VICVectCntlN(n) ((volatile UW *)0xfffff200 + ((n) * 4))
void _kernel_sta_ctx(_KERNEL_T_CTXCB *pk_ctxcb); /**< %jp{実行コンテキストの開始} */
void _kernel_swi_ctx(_KERNEL_T_CTXCB *pk_ctxinf_nxt, _KERNEL_T_CTXCB *pk_ctxcb_now); /**< %jp{実行コンテキストの切替} */
+void _kernel_und_hdr(void);
+void _kernel_swi_hdr(void);
+void _kernel_pre_hdr(void);
+void _kernel_abt_hdr(void);
+void _kernel_irq_hdr(void);
+void _kernel_fiq_hdr(void);
+
#ifdef __cplusplus
}
#endif
/** %jp{割込みコントローラの割込み処理} */
void _kernel_exe_irc(INHNO inhno)
{
+ INTNO intno;
+ UW intsta;
+
+ switch ( inhno )
+ {
+ case _KERNEL_ARM_INHNO_IRQ:
+ intsta = *_KERNEL_IRC_VICIRQStatus;
+ break;
+
+ case _KERNEL_ARM_INHNO_FIQ:
+ intsta = *_KERNEL_IRC_VICFIQStatus;
+ break;
+
+ default:
+ return;
+ }
+
+ /* %jp{割り込み番号取得} */
+ for ( intno = 0; intno <= 31; intno++ )
+ {
+ if ( intsta & 1 )
+ {
+ /* %jp{割込みサービスルーチン呼び出し} */
+ _kernel_exe_isr(intno);
+ }
+
+ intsta >>= 1;
+ }
}
/** %jp{割込みコントローラの初期化} */
void _kernel_ini_irc(void)
{
+ int i;
+
+ *_KERNEL_IRC_VICIntEnClr = 0xffffffff;
+
+ for ( i = _KERNEL_IRCATR_TMIN_INTNO; i <= _KERNEL_IRCATR_TMAX_INTNO; i++ )
+ {
+ *_KERNEL_IRC_VICVectAddrN(i) = (UW)_kernel_irq_hdr;
+ }
}
--- /dev/null
+/**
+ * Hyper Operating System V4 Advance
+ *
+ * @file ena_int.c
+ * @brief @brief %jp{Philips LPC2000ファミリ用}%en{Philips LPC2000 family}
+ * Copyright (C) 1998-2007 by Project HOS
+ * http://sourceforge.jp/projects/hos/
+ */
+
+
+#include "core/core.h"
+#include "object/inhobj.h"
+#include "object/isrobj.h"
+
+
+/* %jp{割り込みのクリア} */
+ER vclr_int(INTNO intno)
+{
+ *_KERNEL_IRC_VICSoftIntClear = (1 << intno);
+
+ return E_OK;
+}
+
+
+/* end of file */
--- /dev/null
+/**
+ * Sample program for Hyper Operating System V4 Advance
+ *
+ * @file main.c
+ * @brief %jp{メイン関数}%en{main}
+ *
+ * Copyright (C) 1998-2006 by Project HOS
+ * http://sourceforge.jp/projects/hos/
+ */
+
+
+#include "kernel.h"
+
+
+/** %jp{メイン関数} */
+int main()
+{
+
+ /* %jp{カーネルの動作開始} */
+ vsta_knl();
+
+ return 0;
+}
+
+
+
+/* end of file */
--- /dev/null
+/**
+ * Sample program for Hyper Operating System V4 Advance
+ *
+ * @file ostimer.c
+ * @brief %jp{OSタイマ}%en{OS timer}
+ *
+ * Copyright (C) 1998-2006 by Project HOS
+ * http://sourceforge.jp/projects/hos/
+ */
+
+
+#include "kernel.h"
+#include "ostimer.h"
+
+
+#define T0IR ((volatile UW *)0xe0004000)
+#define T0TCR ((volatile UW *)0xe0004004)
+#define T0TC ((volatile UW *)0xe0004008)
+#define T0PR ((volatile UW *)0xe000400c)
+#define T0PC ((volatile UW *)0xe0004010)
+#define T0MCR ((volatile UW *)0xe0004014)
+#define T0MR0 ((volatile UW *)0xe0004018)
+#define T0MR1 ((volatile UW *)0xe000401c)
+#define T0MR2 ((volatile UW *)0xe0004020)
+#define T0MR3 ((volatile UW *)0xe0004024)
+#define T0CCR ((volatile UW *)0xe0004028)
+#define T0CR0 ((volatile UW *)0xe000402c)
+#define T0CR1 ((volatile UW *)0xe0004030)
+#define T0CR2 ((volatile UW *)0xe0004034)
+#define T0CR3 ((volatile UW *)0xe0004038)
+#define T0EMR ((volatile UW *)0xe000403c)
+
+
+#define INTNO_TIMER0 4
+
+
+static void OsTimer_Isr(VP_INT exinf); /**< %jp{タイマ割込みサービスルーチン} */
+
+
+/** %jp{OS用タイマ初期化ルーチン} */
+void OsTimer_Initialize(VP_INT exinf)
+{
+ T_CISR cisr;
+
+ /* %jp{割り込みサービスルーチン生成} */
+ cisr.isratr = TA_HLNG;
+ cisr.exinf = 0;
+ cisr.intno = INTNO_TIMER0;
+ cisr.isr = (FP)OsTimer_Isr;
+ acre_isr(&cisr);
+ ena_int(INTNO_TIMER0);
+
+ /* %jp{タイマ動作開始} */
+ *T0MR0 = 142000;
+ *T0MCR = 0x0003;
+ *T0TCR = 1;
+
+}
+
+
+/** %jp{タイマ割り込みハンドラ} */
+void OsTimer_Isr(VP_INT exinf)
+{
+ /* %jp{割り込み要因クリア} */
+ *T0IR= 1;
+
+ /* %jp{タイムティック供給} */
+ isig_tim();
+}
+
+
+/* end of file */
--- /dev/null
+/**
+ * Sample program for Hyper Operating System V4 Advance
+ *
+ * @file ostimer.c
+ * @brief %jp{OSタイマ}%en{OS timer}
+ *
+ * Copyright (C) 1998-2006 by Project HOS
+ * http://sourceforge.jp/projects/hos/
+ */
+
+
+#ifndef __ostimer_h__
+#define __ostimer_h__
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** %jp{OS用タイマ初期化ルーチン} */
+void OsTimer_Initialize(VP_INT exinf);
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* __ostimer_h__ */
+
+
+/* end of file */
--- /dev/null
+/**
+ * Sample program for Hyper Operating System V4 Advance
+ *
+ * @file sample.c
+ * @brief %jp{サンプルプログラム}%en{Sample program}
+ *
+ * Copyright (C) 1998-2006 by Project HOS
+ * http://sourceforge.jp/projects/hos/
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include "kernel.h"
+#include "kernel_id.h"
+#include "uart.h"
+
+
+#define LEFT(num) ((num) <= 1 ? 5 : (num) - 1)
+#define RIGHT(num) ((num) >= 5 ? 1 : (num) + 1)
+
+
+ID mbxid;
+ID mpfid;
+
+
+/** %jp{メッセージ構造体} */
+typedef struct t_print_msg
+{
+ T_MSG msg;
+ char text[32];
+} T_PRINT_MSG;
+
+
+/** %jp{初期化ハンドラ} */
+void Sample_Initialize(VP_INT exinf)
+{
+ T_CMPF cmpf;
+ T_CMBX cmbx;
+
+ /* %jp{UART初期化} */
+ Uart_Initialize();
+
+ /* %jp{固定長メモリプール生成} */
+ cmpf.mpfatr = TA_TFIFO;
+ cmpf.blkcnt = 3;
+ cmpf.blksz = sizeof(T_PRINT_MSG);
+ cmpf.mpf = NULL;
+ mpfid = acre_mpf(&cmpf);
+
+ /* %jp{メールボックス生成} */
+ cmbx.mbxatr = TA_TFIFO | TA_TFIFO;
+ cmbx.maxmpri = 1;
+ cmbx.mprihd = NULL;
+ mbxid = acre_mbx(&cmbx);
+
+ /* %jp{タスク起動} */
+ act_tsk(TSKID_PRINT);
+ act_tsk(TSKID_SAMPLE1);
+ act_tsk(TSKID_SAMPLE2);
+ act_tsk(TSKID_SAMPLE3);
+ act_tsk(TSKID_SAMPLE4);
+ act_tsk(TSKID_SAMPLE5);
+}
+
+
+/** %jp{適当な時間待つ} */
+void rand_wait(void)
+{
+ int r;
+
+ wai_sem(SEMID_RAND);
+ r = rand();
+ sig_sem(SEMID_RAND);
+
+ dly_tsk((r % 1000) + 10);
+}
+
+
+/** %jp{状態表示} */
+void print_state(int num, char *text)
+{
+ T_PRINT_MSG *msg;
+ VP mem;
+
+ /* %jp{メモリ取得} */
+ get_mpf(mpfid, &mem);
+ msg = (T_PRINT_MSG *)mem;
+
+ /* %jp{文字列生成} */
+ msg->text[0] = '0' + num;
+ msg->text[1] = ' ';
+ msg->text[2] = ':';
+ msg->text[3] = ' ';
+ strcpy(&msg->text[4], text);
+ strcat(msg->text, "\n");
+
+ /* %jp{表示タスクに送信} */
+ snd_mbx(mbxid, (T_MSG *)msg);
+}
+
+
+/** %jp{サンプルタスク} */
+void Sample_Task(VP_INT exinf)
+{
+ int num;
+
+ num = (int)exinf;
+
+ /* %jp{いわゆる哲学者の食事の問題} */
+ for ( ; ; )
+ {
+ /* %jp{適当な時間考える} */
+ print_state(num, "thinking");
+ rand_wait();
+
+ /* %jp{左右のフォークを取るまでループ} */
+ for ( ; ; )
+ {
+ /* %jp{左から順に取る} */
+ wai_sem(LEFT(num));
+ if ( pol_sem(RIGHT(num)) == E_OK )
+ {
+ break; /* %jp{両方取れた} */
+ }
+ sig_sem(LEFT(num)); /* %jp{取れなければ離す} */
+
+ /* %jp{適当な時間待つ} */
+ print_state(num, "hungry");
+ rand_wait();
+
+ /* %jp{右から順に取る} */
+ wai_sem(RIGHT(num));
+ if ( pol_sem(LEFT(num)) == E_OK )
+ {
+ break; /* %jp{両方取れた} */
+ }
+ sig_sem(RIGHT(num)); /* %jp{取れなければ離す} */
+
+ /* %jp{適当な時間待つ} */
+ print_state(num, "hungry");
+ rand_wait();
+ }
+
+ /* %jp{適当な時間、食べる} */
+ print_state(num, "eating");
+ rand_wait();
+
+ /* %jp{フォークを置く} */
+ sig_sem(LEFT(num));
+ sig_sem(RIGHT(num));
+ }
+}
+
+
+/** %jp{表示タスク} */
+void Sample_Print(VP_INT exinf)
+{
+ T_PRINT_MSG *msg;
+
+ for ( ; ; )
+ {
+ rcv_mbx(mbxid, (T_MSG **)&msg);
+ Uart_PutString(msg->text);
+ rel_mpf(mpfid, msg);
+ }
+}
+
+
+
+/* end of file */
--- /dev/null
+/**
+ * Sample program for Hyper Operating System V4 Advance
+ *
+ * @file sample.c
+ * @brief %jp{サンプルプログラム}%en{Sample program}
+ *
+ * Copyright (C) 1998-2006 by Project HOS
+ * http://sourceforge.jp/projects/hos/
+ */
+
+
+
+#ifndef __sample_h__
+#define __sample_h__
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void Sample_Initialize(VP_INT exinf);
+void Sample_Task(VP_INT exinf);
+void Sample_Print(VP_INT exinf);
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* __sample_h__ */
+
+
+/* end of file */
--- /dev/null
+/**
+ * Sample program for Hyper Operating System V4 Advance
+ *
+ * @file system.cfg
+ * @brief %jp{サンプルのコンフィギュレーション}
+ *
+ * Copyright (C) 1998-2006 by Project HOS
+ * http://sourceforge.jp/projects/hos/
+ */
+
+
+/* %jp{カーネル独自の設定}%en{kernel} */
+KERNEL_HEP_MEM(256, NULL);
+KERNEL_SYS_STK(256, NULL);
+KERNEL_INT_STK(512, NULL);
+KERNEL_MAX_TSKID(5);
+KERNEL_MAX_SEMID(6);
+KERNEL_MAX_FLGID(2);
+KERNEL_MAX_MBXID(2);
+KERNEL_MAX_MPFID(2);
+KERNEL_MAX_ISRID(4);
+
+
+/* %jp{OSタイマの設定}%en{OS timer} */
+INCLUDE("\"ostimer.h\"");
+ATT_INI({TA_HLNG, 0, OsTimer_Initialize});
+
+/* %jp{サンプル}%en{Sample program} */
+INCLUDE("\"sample.h\"");
+ATT_INI({TA_HLNG, 0, Sample_Initialize});
+CRE_TSK(TSKID_PRINT, {TA_HLNG, 1, Sample_Print, 1, 512, NULL});
+CRE_TSK(TSKID_SAMPLE1, {TA_HLNG, 1, Sample_Task, 2, 512, NULL});
+CRE_TSK(TSKID_SAMPLE2, {TA_HLNG, 2, Sample_Task, 2, 512, NULL});
+CRE_TSK(TSKID_SAMPLE3, {TA_HLNG, 3, Sample_Task, 2, 512, NULL});
+CRE_TSK(TSKID_SAMPLE4, {TA_HLNG, 4, Sample_Task, 2, 512, NULL});
+CRE_TSK(TSKID_SAMPLE5, {TA_HLNG, 5, Sample_Task, 2, 512, NULL});
+CRE_SEM(1, {TA_TFIFO, 1, 1});
+CRE_SEM(2, {TA_TFIFO, 1, 1});
+CRE_SEM(3, {TA_TFIFO, 1, 1});
+CRE_SEM(4, {TA_TFIFO, 1, 1});
+CRE_SEM(5, {TA_TFIFO, 1, 1});
+CRE_SEM(SEMID_RAND, {TA_TFIFO, 1, 1});
+
+
+/* end of file */
--- /dev/null
+/**
+ * Sample program for Hyper Operating System V4 Advance
+ *
+ * @file uart.c
+ * @brief %jp{UARTへの出力}%en{UART device driver}
+ *
+ * Copyright (C) 1998-2006 by Project HOS
+ * http://sourceforge.jp/projects/hos/
+ */
+
+
+#include "kernel.h"
+
+#define PINSEL0 ((volatile UW *)0xe002c000)
+
+#define U0RBR ((volatile UB *)0xe000c000)
+#define U0THR ((volatile UB *)0xe000c000)
+#define U0LCR ((volatile UB *)0xe000c00c)
+#define U0LSR ((volatile UB *)0xe000c014)
+#define U0DLL ((volatile UB *)0xe000c000)
+#define U0DLM ((volatile UB *)0xe000c004)
+
+
+#define VPB_CLK (14700000/4)
+#define UART_BPS 38400
+
+
+/* %jp{UARTの初期化} */
+void Uart_Initialize(void)
+{
+ *PINSEL0 = (*PINSEL0 & 0xfffffff0) | 0x05;
+
+ *U0LCR = 0x80;
+ *U0DLL = (VPB_CLK / 16.0) / UART_BPS + 0.5;
+ *U0DLM = 0x00;
+ *U0LCR = 0x03;
+}
+
+
+/* %jp{1文字出力} */
+void Uart_PutChar(int c)
+{
+ while ( !(*U0LSR & 0x20) )
+ ;
+
+ *U0THR = c;
+}
+
+
+/* %jp{文字列出力} */
+void Uart_PutString(const char *text)
+{
+ while ( *text != '\0' )
+ {
+ if ( *text == '\n' )
+ {
+ Uart_PutChar('\r');
+ Uart_PutChar('\n');
+ }
+ else
+ {
+ Uart_PutChar(*text);
+ }
+
+ text++;
+ }
+}
+
+
+char Uart_hex2asc(int a)
+{
+ if ( a < 10 )
+ {
+ return '0' + a;
+ }
+ return 'a' + a - 10;
+}
+
+
+void Uart_PutHexByte(char c)
+{
+ Uart_PutChar(Uart_hex2asc((c >> 4) & 0xf));
+ Uart_PutChar(Uart_hex2asc((c >> 0) & 0xf));
+}
+
+void Uart_PutHexWord(int i)
+{
+ Uart_PutHexByte((i >> 8) & 0xff);
+ Uart_PutHexByte((i >> 0) & 0xff);
+}
+
+
+
+/* end of file */
--- /dev/null
+/**
+ * Sample program for Hyper Operating System V4 Advance
+ *
+ * @file uart.h
+ * @brief %jp{UARTへの出力}%en{UART device driver}
+ *
+ * Copyright (C) 1998-2006 by Project HOS
+ * http://sourceforge.jp/projects/hos/
+ */
+
+
+#ifndef __ostimer_h__
+#define __ostimer_h__
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void Uart_Initialize(void); /* %jp{UART の初期化} */
+void Uart_PutChar(int c); /* %jp{1文字出力} */
+void Uart_PutString(const char *text); /* %jp{文字列出力} */
+
+void Uart_PutHexByte(char c);
+void Uart_PutHexWord(int i);
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* __ostimer_h__ */
+
+
+/* end of file */