OSDN Git Service

(none)
authorryuz <ryuz>
Mon, 19 Mar 2007 15:55:36 +0000 (15:55 +0000)
committerryuz <ryuz>
Mon, 19 Mar 2007 15:55:36 +0000 (15:55 +0000)
sample/arm/ADuC7019/armcc/gmake.mak [new file with mode: 0755]
sample/arm/ADuC7019/main.c [new file with mode: 0755]
sample/arm/ADuC7019/ostimer.c [new file with mode: 0755]
sample/arm/ADuC7019/ostimer.h [new file with mode: 0755]
sample/arm/ADuC7019/sample.c [new file with mode: 0755]
sample/arm/ADuC7019/sample.h [new file with mode: 0755]
sample/arm/ADuC7019/system.cfg [new file with mode: 0755]
sample/arm/ADuC7019/uart.c [new file with mode: 0755]
sample/arm/ADuC7019/uart.h [new file with mode: 0755]

diff --git a/sample/arm/ADuC7019/armcc/gmake.mak b/sample/arm/ADuC7019/armcc/gmake.mak
new file mode 100755 (executable)
index 0000000..9e732b8
--- /dev/null
@@ -0,0 +1,100 @@
+# ----------------------------------------------------------------------------
+# Hyper Operating System V4 Advance
+#
+# Copyright (C) 1998-2007 by Project HOS
+# http://sourceforge.jp/projects/hos/
+# ----------------------------------------------------------------------------
+
+
+# %jp{ターゲット名}
+TARGET ?= sample
+
+# %jp{ディレクトリ定義}
+OS_DIR            = ../../../..
+KERNEL_DIR        = $(OS_DIR)/kernel
+KERNEL_CFGRTR_DIR = $(OS_DIR)/cfgrtr/build/gcc
+KERNEL_MAKINC_DIR = $(KERNEL_DIR)/build/common/gmake
+KERNEL_BUILD_DIR  = $(KERNEL_DIR)/build/arm/ADuC7019/armcc
+OBJS_DIR          = objs_$(TARGET)
+
+# %jp{共通定義読込み}
+include $(KERNEL_MAKINC_DIR)/common.inc
+
+
+# デバッグ版のターゲット名変更
+ifeq ($(DEBUG),Yes)
+TARGET := $(TARGET)dbg
+endif
+
+# %jp{メモリマップ}
+SECTION_ROM  ?= 0x00000000
+SECTION_RAM  ?= 0x00010000
+
+
+# %jp{フラグ設定}
+CFLAGS  = --cpu=ARM7TDMI --apcs=inter --thumb
+AFLAGS  = --cpu=ARM7TDMI --apcs=inter --thumb
+LNFLAGS = 
+
+
+# %jp{コンフィギュレータ定義}
+KERNEL_CFGRTR = $(KERNEL_CFGRTR_DIR)/h4acfg-ADuC7019
+
+
+# 出力ファイル名
+TARGET_EXE = $(TARGET).axf
+TARGET_MOT = $(TARGET).mot
+TARGET_HEX = $(TARGET).hex
+
+
+# %jp{armcc用の設定読込み}
+include $(KERNEL_MAKINC_DIR)/armcc_def.inc
+
+# ソースディレクトリ
+SRC_DIRS += . ..
+
+# アセンブラファイルの追加
+ASRCS += ./vectors.s           \
+         ./startup.s           \
+
+
+# %jp{C言語ファイルの追加}
+CSRCS += ../kernel_cfg.c       \
+         ../main.c                     \
+         ../sample.c           \
+         ../ostimer.c          \
+         ../uart.c
+
+
+# --------------------------------------
+#  %jp{ルール}
+# --------------------------------------
+
+.PHONY : all
+all: makeexe_all $(TARGET_EXE) $(TARGET_MOT) $(TARGET_HEX)
+
+clean: makeexe_clean
+       rm -f $(TARGET_EXE) $(TARGET_EXE) $(OBJS) ../kernel_cfg.c ../kernel_id.h
+
+../kernel_cfg.c ../kernel_id.h: ../system.cfg
+       cpp -E ../system.cfg ../system.i
+       $(KERNEL_CFGRTR) ../system.i -c ../kernel_cfg.c -i ../kernel_id.h
+
+
+# %jp{ライブラリ生成用設定読込み}
+include $(KERNEL_MAKINC_DIR)/makeexe.inc
+
+# %jp{armcc用のルール定義読込み}
+include $(KERNEL_MAKINC_DIR)/armcc_rul.inc
+
+
+
+# --------------------------------------
+#  %jp{依存関係}
+# --------------------------------------
+
+$(OBJS_DIR)/sample.obj: ../sample.c ../kernel_id.h
+
+
+# end of file
+
diff --git a/sample/arm/ADuC7019/main.c b/sample/arm/ADuC7019/main.c
new file mode 100755 (executable)
index 0000000..75e7919
--- /dev/null
@@ -0,0 +1,27 @@
+/** 
+ *  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 */
diff --git a/sample/arm/ADuC7019/ostimer.c b/sample/arm/ADuC7019/ostimer.c
new file mode 100755 (executable)
index 0000000..0baa25c
--- /dev/null
@@ -0,0 +1,40 @@
+/** 
+ *  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"
+
+
+static void OsTimer_IrqHandler(void);          /**< %jp{タイマ割り込みハンドラ} */
+
+
+/** %jp{OS用タイマ初期化ルーチン} */
+void OsTimer_Initialize(VP_INT exinf)
+{
+       T_DINH dfinh;
+       
+       /* %jp{割り込みハンドラ定義} */
+       dfinh.inthdr = (FP)OsTimer_IrqHandler;
+       def_inh(1, &dfinh);
+       
+       /* %jp{タイマ動作開始} */
+}
+
+
+/** %jp{タイマ割り込みハンドラ} */
+void OsTimer_IrqHandler(void)
+{
+       /* 割り込み要因クリア */
+       isig_tim();
+}
+
+
+/* end of file */
diff --git a/sample/arm/ADuC7019/ostimer.h b/sample/arm/ADuC7019/ostimer.h
new file mode 100755 (executable)
index 0000000..e741bb1
--- /dev/null
@@ -0,0 +1,31 @@
+/** 
+ *  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 */
diff --git a/sample/arm/ADuC7019/sample.c b/sample/arm/ADuC7019/sample.c
new file mode 100755 (executable)
index 0000000..9acb7dc
--- /dev/null
@@ -0,0 +1,167 @@
+/** 
+ *  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{固定長メモリプール生成} */
+       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 */
diff --git a/sample/arm/ADuC7019/sample.h b/sample/arm/ADuC7019/sample.h
new file mode 100755 (executable)
index 0000000..104d175
--- /dev/null
@@ -0,0 +1,33 @@
+/** 
+ *  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 */
diff --git a/sample/arm/ADuC7019/system.cfg b/sample/arm/ADuC7019/system.cfg
new file mode 100755 (executable)
index 0000000..d0d5cca
--- /dev/null
@@ -0,0 +1,45 @@
+/** 
+ *  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 */
diff --git a/sample/arm/ADuC7019/uart.c b/sample/arm/ADuC7019/uart.c
new file mode 100755 (executable)
index 0000000..0e789d5
--- /dev/null
@@ -0,0 +1,69 @@
+/** 
+ *  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"
+
+
+/* %jp{UARTの初期化} */
+void Uart_Initialize(void)
+{
+}
+
+/* %jp{1文字出力} */
+void Uart_PutChar(int 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 */
diff --git a/sample/arm/ADuC7019/uart.h b/sample/arm/ADuC7019/uart.h
new file mode 100755 (executable)
index 0000000..242c01e
--- /dev/null
@@ -0,0 +1,35 @@
+/** 
+ *  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 */