OSDN Git Service

(none)
authorryuz <ryuz>
Sat, 24 May 2008 09:17:53 +0000 (09:17 +0000)
committerryuz <ryuz>
Sat, 24 May 2008 09:17:53 +0000 (09:17 +0000)
17 files changed:
test/twai_sem/lpc2000/armcc/gmake.mak [new file with mode: 0755]
test/twai_sem/lpc2000/armcc/startup.s [new file with mode: 0755]
test/twai_sem/lpc2000/armcc/uish.s [new file with mode: 0755]
test/twai_sem/lpc2000/armcc/vectors.s [new file with mode: 0755]
test/twai_sem/lpc2000/gcc/crt0.S [new file with mode: 0755]
test/twai_sem/lpc2000/gcc/gmake.mak [new file with mode: 0755]
test/twai_sem/lpc2000/gcc/link.x [new file with mode: 0755]
test/twai_sem/lpc2000/gcc/linkext.x [new file with mode: 0755]
test/twai_sem/lpc2000/gcc/vectors.S [new file with mode: 0755]
test/twai_sem/lpc2000/main.c [new file with mode: 0755]
test/twai_sem/lpc2000/ostimer.c [new file with mode: 0755]
test/twai_sem/lpc2000/ostimer.h [new file with mode: 0755]
test/twai_sem/lpc2000/sample.c [new file with mode: 0755]
test/twai_sem/lpc2000/sample.h [new file with mode: 0755]
test/twai_sem/lpc2000/system.cfg [new file with mode: 0755]
test/twai_sem/lpc2000/uart.c [new file with mode: 0755]
test/twai_sem/lpc2000/uart.h [new file with mode: 0755]

diff --git a/test/twai_sem/lpc2000/armcc/gmake.mak b/test/twai_sem/lpc2000/armcc/gmake.mak
new file mode 100755 (executable)
index 0000000..baff393
--- /dev/null
@@ -0,0 +1,116 @@
+# ----------------------------------------------------------------------------
+# 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/lpc2000/armcc
+OBJS_DIR          = objs_$(TARGET)
+
+# %jp{共通定義読込み}
+include $(KERNEL_MAKINC_DIR)/common.inc
+
+
+# デバッグ版のターゲット名変更
+ifeq ($(DEBUG),Yes)
+TARGET := $(TARGET)dbg
+endif
+
+# %jp{メモリマップ}
+ifeq ($(MEMMAP),ext)
+# %jp{外部メモリ}
+TARGET       := $(TARGET)ext
+SECTION_ROM  ?= 0x80000000
+SECTION_RAM  ?= 0x80010000
+else
+ifeq ($(MEMMAP),ram)
+# %jp{内蔵RAM}
+SECTION_ROM  ?= 0x00000000
+SECTION_RAM  ?= 0x80010000
+else
+# %jp{内蔵ROM}
+SECTION_ROM  ?= 0x00000000
+SECTION_RAM  ?= 0x80010000
+endif
+endif
+
+
+# %jp{フラグ設定}
+CFLAGS  = --cpu=ARM7TDMI-S --apcs=inter --thumb
+AFLAGS  = --cpu=ARM7TDMI-S --apcs=inter --thumb
+LNFLAGS = --ro_base=$(SECTION_ROM) --rw_base=$(SECTION_RAM) --first=vectors.o --entry=$(SECTION_ROM)
+
+
+# %jp{コンフィギュレータ定義}
+KERNEL_CFGRTR = $(KERNEL_CFGRTR_DIR)/h4acfg-lpc2000
+
+
+# 出力ファイル名
+TARGET_EXE = $(TARGET).axf
+TARGET_MOT = $(TARGET).mot
+TARGET_HEX = $(TARGET).hex
+
+
+# %jp{armcc用の設定読込み}
+include $(KERNEL_MAKINC_DIR)/armcc_d.inc
+
+# ソースディレクトリ
+SRC_DIRS += . ..
+
+# アセンブラファイルの追加
+ASRCS += ./vectors.s           \
+         ./startup.s           \
+         ./uish.s
+
+
+# %jp{C言語ファイルの追加}
+CSRCS += ../kernel_cfg.c       \
+         ../main.c                     \
+         ../sample.c           \
+         ../ostimer.c          \
+         ../uart.c
+
+
+
+# --------------------------------------
+#  %jp{ルール}
+# --------------------------------------
+
+.PHONY : all
+all: kernel_make 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_r.inc
+
+
+
+# --------------------------------------
+#  %jp{依存関係}
+# --------------------------------------
+
+$(OBJS_DIR)/sample.obj: ../sample.c ../kernel_id.h
+
+
+# end of file
+
diff --git a/test/twai_sem/lpc2000/armcc/startup.s b/test/twai_sem/lpc2000/armcc/startup.s
new file mode 100755 (executable)
index 0000000..727bb02
--- /dev/null
@@ -0,0 +1,76 @@
+
+                               EXPORT  Reset_Handler
+                               EXPORT  Undefined_Handler
+                               EXPORT  Swi_Handler
+                               EXPORT  Prefetch_Handler
+                               EXPORT  Abort_Handler
+                               IMPORT  _kernel_int_isp
+
+
+
+; %jp{プロセッサモード定義}
+Mode_USR               EQU     0x10            ; USR モード
+Mode_FIQ               EQU             0x11            ; FIQ モード
+Mode_IRQ               EQU     0x12            ; IRQ モード
+Mode_SVC               EQU             0x13            ; SVC モード
+Mode_ABT               EQU             0x17            ; ABT モード
+Mode_UND               EQU             0x1b            ; UND モード
+Mode_SYS               EQU     0x1f            ; SYS モード
+Mode_MASK              EQU     0x1f            ; モードビットマスク
+
+; %jp{フラグ定義}
+T_Bit                  EQU             0x20            ; T ビット
+F_Bit                  EQU     0x40            ; F ビット
+I_Bit                  EQU     0x80            ; I ビット
+
+
+
+                               CODE32
+
+                               PRESERVE8
+                               AREA    Init, CODE, READONLY
+
+
+; リセットハンドラ
+Reset_Handler
+               ; --- SYSモード移行
+                               msr             cpsr_c, #Mode_SYS:OR:F_Bit:OR:I_Bit
+
+               ; --- スタック仮設定
+                               ldr             r0, =_kernel_int_isp
+                               ldr     sp, [r0]
+                               
+               ; --- C言語コードにジャンプ
+                               IMPORT  __main
+                               bl              __main
+end_loop
+                               b               end_loop
+
+
+
+
+;  SWIハンドラ
+Swi_Handler
+                               movs    pc, lr
+
+
+;  Undefined ハンドラ
+Undefined_Handler
+                               b               Undefined_Handler
+
+
+;  Prefetch ハンドラ
+Prefetch_Handler
+                               b               Prefetch_Handler
+
+
+;  Abort ハンドラ
+Abort_Handler
+                               b               Abort_Handler
+
+
+
+                               END
+
+
+; end of file                                            
diff --git a/test/twai_sem/lpc2000/armcc/uish.s b/test/twai_sem/lpc2000/armcc/uish.s
new file mode 100755 (executable)
index 0000000..9309dcb
--- /dev/null
@@ -0,0 +1,38 @@
+
+HEAP_SIZE              EQU             256
+
+
+                               EXPORT  __user_initial_stackheap
+                               IMPORT  __use_two_region_memory
+                               
+                               IMPORT  _kernel_int_stkblk
+                               IMPORT  _kernel_int_isp
+
+
+                               PRESERVE8
+                               AREA    UISH, CODE, READONLY
+                               CODE32
+
+__user_initial_stackheap       FUNCTION
+                               
+                               ldr             r0, =User_Heap                          ; Heap Base
+                               ldr             r2, =HEAP_SIZE
+                               add             r2, r2, r0                                      ; Heap Limit
+                               
+                               ldr             r1, =_kernel_int_isp
+                               ldr             r1, [r1]                                        ; Stack Base
+                               ldr             r3, =_kernel_int_stkblk         ; Stack Limit
+
+                               bx              lr
+
+                               ENDFUNC
+
+
+
+                               AREA    ||.bss||, NOINIT, ALIGN=2
+User_Heap
+                               %       HEAP_SIZE
+
+
+
+                               END
diff --git a/test/twai_sem/lpc2000/armcc/vectors.s b/test/twai_sem/lpc2000/armcc/vectors.s
new file mode 100755 (executable)
index 0000000..d5528a4
--- /dev/null
@@ -0,0 +1,42 @@
+
+
+                               IMPORT  Reset_Handler
+                               IMPORT  Undefined_Handler
+                               IMPORT  Swi_Handler
+                               IMPORT  Prefetch_Handler
+                               IMPORT  Abort_Handler
+                               IMPORT  _kernel_irq_hdr
+                               IMPORT  _kernel_fiq_hdr
+
+
+                               CODE32
+
+                               PRESERVE8
+                               AREA    Init, CODE, READONLY
+
+                               ENTRY
+
+                               ldr     pc, Reset_Addr
+                               ldr     pc, Undefined_Addr
+                               ldr     pc, Swi_Addr
+                               ldr     pc, Prefetch_Addr
+                               ldr     pc, Abort_Addr
+                               nop
+                               ldr     pc, IRQ_Addr
+                               ldr     pc, FIQ_Addr
+
+
+Reset_Addr             dcd             Reset_Handler
+Undefined_Addr dcd             Undefined_Handler
+Swi_Addr               dcd             Swi_Handler
+Prefetch_Addr  dcd             Prefetch_Handler
+Abort_Addr             dcd             Abort_Handler
+IRQ_Addr               dcd             _kernel_irq_hdr
+FIQ_Addr               dcd             _kernel_fiq_hdr
+
+
+                               END
+
+
+
+; end of file
diff --git a/test/twai_sem/lpc2000/gcc/crt0.S b/test/twai_sem/lpc2000/gcc/crt0.S
new file mode 100755 (executable)
index 0000000..e270d74
--- /dev/null
@@ -0,0 +1,82 @@
+/* ------------------------------------------------------------------------ */
+/*  Hyper Operating System V4 Advance                                       */
+/*    Sample program for ADuC7000 series                                    */
+/*                                                                          */
+/*                                  Copyright (C) 1998-2007 by Project HOS  */
+/*                                  http://sourceforge.jp/projects/hos/     */
+/* ------------------------------------------------------------------------ */
+
+
+                               .extern         __kernel_int_isp
+                               .extern         ___data
+                               .extern         ___data_end
+                               .extern         ___bss
+                               .extern         ___bss_end
+                               .extern         main
+
+                               .global         _reset_handler
+                               .global         __main
+
+
+                               .text
+
+#define Mode_USR               0x10
+#define Mode_IRQ               0x12
+#define Mode_FIQ               0x11
+#define Mode_SVC               0x13
+#define Mode_UND               0x1b
+#define Mode_SYS               0x1f
+#define I_Bit                  0x80
+#define F_Bit                  0x40
+#define T_Bit                  0x20
+
+
+/************************************************
+  リセットハンドラ
+************************************************/
+                               .align          4
+_reset_handler:        
+                               /* モード設定 */
+                               msr             cpsr_c, #(Mode_SYS | F_Bit | I_Bit)
+                               
+                               /* スタック仮設定 */
+                               ldr             r0, =_kernel_int_isp
+                               ldr     sp, [r0]
+                               
+                               
+                               /* DATA領域のコピー */
+                               ldr             r0, =___data_rom
+                               ldr             r1, =___data
+                               ldr             r2, =___data_end
+data_loop:             
+                               cmp             r1, r2
+                               ldrcc   r3, [r0], #4
+                               strcc   r3, [r1], #4
+                               bcc             data_loop
+                               
+                               
+                               /* BSS領域の初期化 */
+                               ldr             r0, =___bss
+                               ldr             r1, =___bss_end
+                               mov             r2, #0
+bss_loop:              
+                               cmp             r0, r1
+                               strcc   r2, [r0], #4
+                               bcc             bss_loop
+                               
+                               
+                               /* main関数の呼び出し */
+                               bl              main
+end_loop:
+                               b               end_loop
+
+
+__main:
+                               bx              lr
+
+
+
+                               .end
+
+
+/* end of file */
diff --git a/test/twai_sem/lpc2000/gcc/gmake.mak b/test/twai_sem/lpc2000/gcc/gmake.mak
new file mode 100755 (executable)
index 0000000..11eb939
--- /dev/null
@@ -0,0 +1,158 @@
+# ----------------------------------------------------------------------------
+# Hyper Operating System V4 Advance
+#
+# Copyright (C) 1998-2008 by Project HOS
+# http://sourceforge.jp/projects/hos/
+# ----------------------------------------------------------------------------
+
+
+
+# --------------------------------------
+#  %jp{各種設定}{setting}
+# --------------------------------------
+
+# %jp{ターゲット名}%en{target name}
+TARGET ?= sample
+
+
+# %jp{ツール定義}%en{tools}
+GCC_ARCH   ?= arm-elf-
+CMD_CC     ?= $(GCC_ARCH)gcc
+CMD_ASM    ?= $(GCC_ARCH)gcc
+CMD_LINK   ?= $(GCC_ARCH)gcc
+CMD_OBJCNV ?= $(GCC_ARCH)objcopy
+
+
+# %jp{アーキテクチャ定義}%en{architecture}
+ARCH_NAME ?= lpc2000
+ARCH_CC   ?= gcc
+
+
+# %jp{ディレクトリ定義}%en{directories}
+TOP_DIR           = ../../../..
+KERNEL_DIR        = $(TOP_DIR)/kernel
+KERNEL_CFGRTR_DIR = $(TOP_DIR)/cfgrtr/build/gcc
+KERNEL_MAKINC_DIR = $(KERNEL_DIR)/build/common/gmake
+KERNEL_BUILD_DIR  = $(KERNEL_DIR)/build/arm/lpc2000/gcc
+
+
+# %jp{コンフィギュレータ定義}
+KERNEL_CFGRTR = $(KERNEL_CFGRTR_DIR)/h4acfg-$(ARCH_NAME)
+
+
+# %jp{共通定義読込み}%jp{common setting}
+include $(KERNEL_MAKINC_DIR)/common.inc
+
+
+# %jp{リンカスクリプト}%en{linker script}
+LINK_SCRIPT = link.x
+
+# %jp{外部メモリ}%en{external memory}
+ifeq ($(MEMMAP),ext)
+TARGET     := $(TARGET)_ext
+LINK_SCRIPT = linkext.x
+endif
+
+# %jp{内蔵RAM}%en{internal RAM}
+ifeq ($(MEMMAP),ram)
+LINK_SCRIPT = linkram.x
+endif
+
+
+# %jp{パス設定}%en{add source directories}
+INC_DIRS += . ..
+SRC_DIRS += . ..
+
+
+# %jp{オプションフラグ}%en{option flags}
+AFLAGS  = -mcpu=arm7tdmi -mthumb-interwork
+CFLAGS  = -mcpu=arm7tdmi -mthumb-interwork
+LNFLAGS = -mcpu=arm7tdmi -mthumb-interwork -nostartfiles -Wl,-Map,$(TARGET).map,-T$(LINK_SCRIPT)
+
+
+# %jp{コンパイラ依存の設定読込み}%en{compiler dependent definitions}
+include $(KERNEL_MAKINC_DIR)/$(ARCH_CC)_d.inc
+
+# %jp{実行ファイル生成用設定読込み}%en{definitions for exection file}
+include $(KERNEL_MAKINC_DIR)/makexe_d.inc
+
+
+# %jp{出力ファイル名}%en{output files}
+TARGET_EXE = $(TARGET).$(EXT_EXE)
+TARGET_MOT = $(TARGET).$(EXT_MOT)
+TARGET_HEX = $(TARGET).$(EXT_HEX)
+TARGET_BIN = $(TARGET).$(EXT_BIN)
+
+
+
+
+# --------------------------------------
+#  %jp{ソースファイル}%en{source files}
+# --------------------------------------
+
+# %jp{アセンブラファイルの追加}%en{assembry sources}
+ASRCS += ./vectors.S
+ASRCS += ./crt0.S
+
+
+# %jp{C言語ファイルの追加}%en{C sources}
+CSRCS += ../kernel_cfg.c
+CSRCS += ../main.c
+CSRCS += ../sample.c
+CSRCS += ../ostimer.c
+CSRCS += ../uart.c
+
+
+
+
+# --------------------------------------
+#  %jp{ルール定義}%en{rules}
+# --------------------------------------
+
+# %jp{ALL}%en{all}
+.PHONY : all
+all: kernel_make makeexe_all $(TARGET_EXE) $(TARGET_MOT) $(TARGET_HEX) $(TARGET_BIN)
+
+# %jp{クリーン}%en{clean}
+.PHONY : clean
+clean: makeexe_clean
+       rm -f $(TARGET_EXE) $(TARGET_EXE) $(OBJS) ../kernel_cfg.c ../kernel_id.h
+
+# %jp{依存関係更新}%en{depend}
+.PHONY : depend
+depend: makeexe_depend
+
+# %jp{ソース一括コピー}%en{source files copy}
+.PHONY : srccpy
+srccpy: makeexe_srccpy
+
+# %jp{カーネルごとクリーン}%en{mostlyclean}
+.PHONY : mostlyclean
+mostlyclean: clean kernel_clean
+
+
+# %jp{コンフィギュレータ実行}%en{configurator}
+../kernel_cfg.c ../kernel_id.h: ../system.cfg $(KERNEL_CFGRTR)
+       cpp -E ../system.cfg ../system.i
+       $(KERNEL_CFGRTR) ../system.i -c ../kernel_cfg.c -i ../kernel_id.h
+
+
+# %jp{実行ファイル生成用設定読込み}%en{rules for exection file}
+include $(KERNEL_MAKINC_DIR)/makexe_r.inc
+
+# %jp{コンパイラ依存のルール定義読込み}%en{rules for compiler}
+include $(KERNEL_MAKINC_DIR)/$(ARCH_CC)_r.inc
+
+
+
+
+# --------------------------------------
+#  %jp{依存関係}%en{dependency}
+# --------------------------------------
+
+$(OBJS_DIR)/sample.$(EXT_OBJ) : ../kernel_id.h
+
+
+
+# end of file
+
diff --git a/test/twai_sem/lpc2000/gcc/link.x b/test/twai_sem/lpc2000/gcc/link.x
new file mode 100755 (executable)
index 0000000..24f4b63
--- /dev/null
@@ -0,0 +1,54 @@
+OUTPUT_ARCH(arm)
+ENTRY(_reset_handler)
+
+MEMORY
+{
+       vector : o = 0x00000000, l = 0x00000040
+       rom    : o = 0x00000040, l = 0x0000ffc0
+       ram    : o = 0x40000000, l = 0x00004000
+}
+
+SECTIONS
+{
+       .vector :
+       {
+               ___vector = . ; 
+               */vectors.o(.text)
+               FILL(0xff)
+               ___vector_end = . ; 
+       } > vector
+       .text :
+       {
+                ___text = . ; 
+               *(.text)
+               *(.strings)
+               *(.rodata*)
+               *(.glue*)
+                ___text_end = . ; 
+       }  > rom
+       .tors :
+       {
+               . = ALIGN(4);
+               ___ctors = . ;
+               *(.ctors)
+               ___ctors_end = . ;
+               ___dtors = . ;
+               *(.dtors)
+               ___dtors_end = . ;
+       } > rom
+       data : AT (ADDR(.tors) + SIZEOF(.tors))
+       {
+           ___data_rom = ADDR(.tors) + SIZEOF(.tors);
+               ___data = . ;
+               *(.data)
+               ___data_end = . ;
+       } > ram
+       .bss :
+       {
+               ___bss = . ;
+               *(.bss)
+               *(COMMON)
+               ___bss_end = . ;  
+       }  >ram
+}
+
diff --git a/test/twai_sem/lpc2000/gcc/linkext.x b/test/twai_sem/lpc2000/gcc/linkext.x
new file mode 100755 (executable)
index 0000000..466bea7
--- /dev/null
@@ -0,0 +1,54 @@
+OUTPUT_ARCH(arm)
+ENTRY(_reset_handler)
+
+MEMORY
+{
+       vector : o = 0x80000000, l = 0x00000040
+       rom    : o = 0x80000040, l = 0x0000ffc0
+       ram    : o = 0x80010000, l = 0x00002000
+}
+
+SECTIONS
+{
+       .vector :
+       {
+               ___vector = . ; 
+               */vectors.o(.text)
+               FILL(0xff)
+               ___vector_end = . ; 
+       } > vector
+       .text :
+       {
+                ___text = . ; 
+               *(.text)
+               *(.strings)
+               *(.rodata*)
+               *(.glue*)
+                ___text_end = . ; 
+       }  > rom
+       .tors :
+       {
+               . = ALIGN(4);
+               ___ctors = . ;
+               *(.ctors)
+               ___ctors_end = . ;
+               ___dtors = . ;
+               *(.dtors)
+               ___dtors_end = . ;
+       } > rom
+       data : AT (ADDR(.tors) + SIZEOF(.tors))
+       {
+           ___data_rom = ADDR(.tors) + SIZEOF(.tors);
+               ___data = . ;
+               *(.data)
+               ___data_end = . ;
+       } > ram
+       .bss :
+       {
+               ___bss = . ;
+               *(.bss)
+               *(COMMON)
+               ___bss_end = . ;  
+       }  >ram
+}
+
diff --git a/test/twai_sem/lpc2000/gcc/vectors.S b/test/twai_sem/lpc2000/gcc/vectors.S
new file mode 100755 (executable)
index 0000000..c0f5a86
--- /dev/null
@@ -0,0 +1,55 @@
+/* ------------------------------------------------------------------------ */
+/*  Hyper Operating System V4  サンプルプログラム                           */
+/*    ベクタテーブル                                                        */
+/*                                                                          */
+/*                                  Copyright (C) 1998-2007 by Project HOS  */
+/*                                  http://sourceforge.jp/projects/hos/     */
+/* ------------------------------------------------------------------------ */
+
+
+               /* --- 外部定数宣言 */
+                               .global _reset_handler
+                               .global _kernel_und_hdr
+                               .global _kernel_swi_hdr
+                               .global _kernel_pre_hdr
+                               .global _kernel_abt_hdr
+                               .global _kernel_irq_hdr
+                               .global _kernel_fiq_hdr
+
+
+                               .text
+                               .align  2
+
+/* --------------------------------------- */
+/*            ベクタ定義                   */
+/* --------------------------------------- */
+                               ldr             pc, adr_rst_hdr
+                               ldr             pc, adr_und_hdr
+                               ldr             pc, adr_swi_hdr
+                               ldr             pc, adr_pre_hdr
+                               ldr             pc, adr_abt_hdr
+                               nop
+                               ldr             pc, adr_irq_hdr
+                               ldr             pc, adr_fiq_hdr
+
+
+adr_rst_hdr:   
+                               .long   _reset_handler
+adr_und_hdr:           
+                               .long   _kernel_und_hdr
+adr_swi_hdr:   
+                               .long   _kernel_swi_hdr
+adr_pre_hdr:           
+                               .long   _kernel_pre_hdr
+adr_abt_hdr:
+                               .long   _kernel_abt_hdr
+adr_irq_hdr:
+                               .long   _kernel_irq_hdr
+adr_fiq_hdr:
+                               .long   _kernel_fiq_hdr
+
+
+                               .end
+
+
+/* end of file */
diff --git a/test/twai_sem/lpc2000/main.c b/test/twai_sem/lpc2000/main.c
new file mode 100755 (executable)
index 0000000..77a22b7
--- /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/test/twai_sem/lpc2000/ostimer.c b/test/twai_sem/lpc2000/ostimer.c
new file mode 100755 (executable)
index 0000000..bf499b5
--- /dev/null
@@ -0,0 +1,72 @@
+/** 
+ *  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 / 4;
+       *T0MCR = 0x0003;
+       *T0TCR = 1; 
+       
+}
+
+
+/** %jp{タイマ割り込みハンドラ} */
+void OsTimer_Isr(VP_INT exinf)
+{
+       /* %jp{割り込み要因クリア} */
+       *T0IR= 1; 
+       
+       /* %jp{タイムティック供給} */
+       isig_tim();
+}
+
+
+/* end of file */
diff --git a/test/twai_sem/lpc2000/ostimer.h b/test/twai_sem/lpc2000/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/test/twai_sem/lpc2000/sample.c b/test/twai_sem/lpc2000/sample.c
new file mode 100755 (executable)
index 0000000..bbe649e
--- /dev/null
@@ -0,0 +1,92 @@
+/** 
+ *  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"
+
+
+
+/** %jp{初期化ハンドラ} */
+void Sample_Initialize(VP_INT exinf)
+{
+       /* %jp{UART初期化} */
+       Uart_Initialize();
+
+       /* %jp{タスク起動} */
+       act_tsk(TSKID_WAIT);
+       act_tsk(TSKID_SIGNAL);
+}
+
+
+/** %jp{乱数取得} */
+int GetRand(void)
+{
+       int r;
+
+       wai_sem(SEMID_RAND);
+       r = rand();
+       sig_sem(SEMID_RAND);
+       
+       return r;
+}
+
+
+
+/** %jp{待ちタスク} */
+void Sample_WaitTask(VP_INT exinf)
+{
+       TMO     tmo;
+       ER      ercd;
+
+       for ( ; ; )
+       {
+               /* 待ち時間を決める */
+               tmo = GetRand() % 5;
+               
+               /* 待つ */
+               ercd = twai_sem(SEMID_TEST, tmo);
+               switch ( ercd )
+               {
+               case E_OK:
+                       Uart_PutString("OK\n");
+                       break;
+               
+               case E_TMOUT:
+                       Uart_PutString("TMOUT\n");
+                       break;
+
+               default:
+                       Uart_PutString("error!\n");
+                       for ( ; ; ) ;
+               }
+       }
+}
+
+
+/** %jp{sig_semタスク} */
+void Sample_SignalTask(VP_INT exinf)
+{
+       RELTIM tim;
+       
+       for ( ; ; )
+       {
+               tim = GetRand() % 5;
+               dly_tsk(tim);
+               
+               sig_sem(SEMID_TEST);
+       }
+}
+
+
+
+/* end of file */
diff --git a/test/twai_sem/lpc2000/sample.h b/test/twai_sem/lpc2000/sample.h
new file mode 100755 (executable)
index 0000000..1cb91c7
--- /dev/null
@@ -0,0 +1,34 @@
+/** 
+ *  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_WaitTask(VP_INT exinf);
+void Sample_SignalTask(VP_INT exinf);
+void Sample_Print(VP_INT exinf);
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* __sample_h__ */
+
+
+/* end of file */
diff --git a/test/twai_sem/lpc2000/system.cfg b/test/twai_sem/lpc2000/system.cfg
new file mode 100755 (executable)
index 0000000..40ec70f
--- /dev/null
@@ -0,0 +1,37 @@
+/** 
+ *  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_WAIT,    {TA_HLNG, 2, Sample_WaitTask, 2, 512, NULL});
+CRE_TSK(TSKID_SIGNAL,  {TA_HLNG, 2, Sample_SignalTask, 2, 512, NULL});
+CRE_SEM(SEMID_TEST, {TA_TFIFO, 1, 1});
+CRE_SEM(SEMID_RAND, {TA_TFIFO, 1, 1});
+
+
+/* end of file */
diff --git a/test/twai_sem/lpc2000/uart.c b/test/twai_sem/lpc2000/uart.c
new file mode 100755 (executable)
index 0000000..590774b
--- /dev/null
@@ -0,0 +1,94 @@
+/** 
+ *  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 */
diff --git a/test/twai_sem/lpc2000/uart.h b/test/twai_sem/lpc2000/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 */