OSDN Git Service

add sh7262 sample
authorryuz <ryuz@users.sourceforge.jp>
Thu, 4 Nov 2010 15:59:01 +0000 (00:59 +0900)
committerryuz <ryuz@users.sourceforge.jp>
Thu, 4 Nov 2010 15:59:01 +0000 (00:59 +0900)
15 files changed:
.gitignore
sample/sh/sh7262/gcc/Makefile [new file with mode: 0644]
sample/sh/sh7262/gcc/crt0.S [new file with mode: 0644]
sample/sh/sh7262/gcc/ram.lds [new file with mode: 0644]
sample/sh/sh7262/gcc/rom.lds [new file with mode: 0644]
sample/sh/sh7262/gcc/vector.S [new file with mode: 0644]
sample/sh/sh7262/main.c [new file with mode: 0644]
sample/sh/sh7262/ostimer.c [new file with mode: 0644]
sample/sh/sh7262/ostimer.h [new file with mode: 0644]
sample/sh/sh7262/regs_sh7262.h [new file with mode: 0644]
sample/sh/sh7262/sample.c [new file with mode: 0644]
sample/sh/sh7262/sample.h [new file with mode: 0644]
sample/sh/sh7262/sci1.c [new file with mode: 0644]
sample/sh/sh7262/sci1.h [new file with mode: 0644]
sample/sh/sh7262/system.cfg [new file with mode: 0644]

index a8e1908..bcc89d6 100644 (file)
@@ -6,6 +6,7 @@ kernel_cfg.c
 # output files
 *.elf
 *.bin
+*.out
 *.hex
 *.mot
 *.map
diff --git a/sample/sh/sh7262/gcc/Makefile b/sample/sh/sh7262/gcc/Makefile
new file mode 100644 (file)
index 0000000..f757d03
--- /dev/null
@@ -0,0 +1,153 @@
+# ----------------------------------------------------------------------------
+# Hyper Operating System V4 Advance
+#  makefile for sh2-sample
+#
+# Copyright (C) 1998-2010 by Project HOS
+# http://sourceforge.jp/projects/hos/
+# ----------------------------------------------------------------------------
+
+
+
+# --------------------------------------
+#  %jp{各種設定}{setting}
+# --------------------------------------
+
+# %jp{ターゲット名}
+TARGET ?= sample
+
+
+# %jp{ツール定義}
+GCC_ARCH   ?= sh-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 ?= sh2
+ARCH_CC   ?= gcc
+
+
+# %jp{ディレクトリ定義}
+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/sh/sh2/gcc
+
+
+# %jp{コンフィギュレータ定義}
+KERNEL_CFGRTR = $(KERNEL_CFGRTR_DIR)/h4acfg-$(ARCH_NAME)
+
+
+# %jp{共通定義読込み}
+include $(KERNEL_MAKINC_DIR)/common.inc
+
+
+# %jp{リンカスクリプト}%en{linker script}
+LINK_SCRIPT = rom.lds
+
+# default ram
+MEMMAP ?= ram
+
+ifeq ($(MEMMAP),ram)
+# %jp{RAM実行(モニタプログラム利用を想定)}
+LINK_SCRIPT = ram.lds
+TARGET     := $(TARGET)_ram
+endif
+
+
+# %jp{パス設定}%en{add source directories}
+INC_DIRS += . ..
+SRC_DIRS += . ..
+
+
+# %jp{オプションフラグ}%en{option flags}
+CFLAGS  = -m2
+AFLAGS  = -m2
+LNFLAGS = -m2 -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)
+TARGETS    = $(TARGET_EXE) $(TARGET_MOT)
+
+
+# --------------------------------------
+#  %jp{ソースファイル}%en{source files}
+# --------------------------------------
+
+
+# %jp{アセンブラファイルの追加}%en{assembry sources}
+ASRCS += ./vector.S
+ASRCS += ./crt0.S
+
+# %jp{C言語ファイルの追加}%en{C sources}
+CSRCS += ../kernel_cfg.c
+CSRCS += ../main.c
+CSRCS += ../sample.c
+CSRCS += ../ostimer.c
+CSRCS += ../sci1.c
+
+
+# %jp{リンク制御対象制御}
+#LINK_RENESASSCI = Yes
+
+
+
+# --------------------------------------
+#  %jp{ルール定義}%en{rules}
+# --------------------------------------
+
+# %jp{ALL}%en{all}
+.PHONY : all
+all: kernel_make makeexe_all $(TARGETS)
+
+# %jp{クリーン}%en{clean}
+.PHONY : clean
+clean: makeexe_clean
+       rm -f $(TARGETS) $(OBJS) ../kernel_cfg.c ../kernel_id.h
+
+# %jp{依存関係更新}%en{depend}
+.PHONY : depend
+depend: makeexe_depend
+
+
+# %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{依存関係}
+# --------------------------------------
+
+$(OBJS_DIR)/sample.$(EXT_OBJ): ../sample.c ../kernel_id.h
+
+
+# end of file
+
diff --git a/sample/sh/sh7262/gcc/crt0.S b/sample/sh/sh7262/gcc/crt0.S
new file mode 100644 (file)
index 0000000..1c8a38f
--- /dev/null
@@ -0,0 +1,118 @@
+/* ------------------------------------------------------------------------ */
+/*  Hyper Operating System V4  サンプルプログラム                           */
+/*    スタートアップモジュール (日立 SH2 gcc 用)                            */
+/*                                                                          */
+/*                                  Copyright (C) 1998-2002 by Project HOS  */
+/*                                  http://sourceforge.jp/projects/hos/     */
+/* ------------------------------------------------------------------------ */
+
+
+                               .extern         _main
+                               .extern         __kernel_int_isp
+                               .extern         _DATA_ROM
+                               .extern         _DATA_START
+                               .extern         _DATA_END
+                               .extern         _BSS_START
+                               .extern         _BSS_END
+
+                               .global         _reset_handler
+                               .global         ___main
+
+
+                               .text
+
+
+/************************************************
+  リセットハンドラ
+************************************************/
+                               .align          4
+_reset_handler:
+                               mov.l   l_int_isp, r0
+                               mov.l   @r0, r15
+                               
+                               /* DATA領域のコピー */
+                               mov.l   l_data_rom, r0
+                               mov.l   l_data_start, r1
+                               mov.l   l_data_end, r2
+                               cmp/hs  r2, r1
+                               bt              data_end
+data_loop:             
+                               mov.l   @r0+, r3
+                               mov.l   r3, @r1
+                               add             #4, r1
+                               cmp/hs  r2, r1
+                               bf              data_loop
+data_end:              
+                               
+                               /* BSS領域の初期化 */
+                               mov.l   l_bss_start, r0
+                               mov.l   l_bss_end, r1
+                               cmp/hs  r1, r0
+                               bt              bss_end
+                               mov             #0, r2
+bss_loop:              
+                               mov.l   r2, @r0
+                               add             #4, r0
+                               cmp/hs  r1, r0
+                               bf              bss_loop
+bss_end:               
+                               
+                               /* main関数の呼び出し */
+                               mov.l   l_main, r8
+                               jsr             @r8
+                               nop
+end_loop:
+                               bra             end_loop
+                               nop
+
+                               /* __main */
+___main:
+                               rts             /* 何もしない */
+                               nop
+
+                               .align  2
+l_int_isp:             
+                               .long   __kernel_int_isp
+l_data_rom:            
+                               .long   ___data_rom
+l_data_start:  
+                               .long   ___data
+l_data_end:            
+                               .long   ___data_end
+l_bss_start:
+                               .long   ___bss
+l_bss_end:
+                               .long   ___bss_end
+l_main:                        
+                               .long   _main
+
+
+
+/************************************************
+  カーネル用スタックポインタ定義
+************************************************/
+                               .global         _kernel_int_sp
+                               .section        .rodata
+                               .align          4
+_kernel_int_sp:
+                               .long   _stack          /* 割り込み時の er7 保存用 */
+
+
+
+/************************************************
+  スタック領域
+************************************************/
+                               .section        .stack
+                               .global         _stack
+
+                               .align          4
+_stack:                        .long           1
+
+
+
+                               .end
+
+
+/* ------------------------------------------------------------------------ */
+/*  Copyright (C) 1998-2002 by Project HOS                                  */
+/* ------------------------------------------------------------------------ */
diff --git a/sample/sh/sh7262/gcc/ram.lds b/sample/sh/sh7262/gcc/ram.lds
new file mode 100644 (file)
index 0000000..9d2e93b
--- /dev/null
@@ -0,0 +1,53 @@
+OUTPUT_ARCH(sh)
+ENTRY(_reset_handler)
+
+MEMORY
+{
+       vector : o = 0x1c000000, l = 0x000800
+       ro     : o = 0x1c000800, l = 0x027800
+       rw     : o = 0x1c028000, l = 0x0d8000
+}
+
+SECTIONS
+{
+       .vector :
+       {
+               ___vector = . ; 
+               */vector.o(.text)
+               FILL(0xff)
+               ___vector_end = . ; 
+       } > vector
+       .text :
+       {
+                ___text = . ; 
+               *(.text)
+               *(.strings)
+               *(.rodata*)
+                ___text_end = . ; 
+       }  > ro
+       .tors :
+       {
+               . = ALIGN(4);
+               ___ctors = . ;
+               *(.ctors)
+               ___ctors_end = . ;
+               ___dtors = . ;
+               *(.dtors)
+               ___dtors_end = . ;
+       } > ro
+       data : AT (ADDR(.tors) + SIZEOF(.tors))
+       {
+           ___data_rom = ADDR(.tors) + SIZEOF(.tors);
+               ___data = . ;
+               *(.data)
+               ___data_end = . ;
+       } > rw
+       .bss :
+       {
+               ___bss = . ;
+               *(.bss)
+               *(COMMON)
+               ___bss_end = . ;  
+       }  >rw
+}
+
diff --git a/sample/sh/sh7262/gcc/rom.lds b/sample/sh/sh7262/gcc/rom.lds
new file mode 100644 (file)
index 0000000..6dd8122
--- /dev/null
@@ -0,0 +1,54 @@
+OUTPUT_ARCH(sh)
+ENTRY(_reset_handler)
+
+MEMORY
+{
+       vector : o = 0x00000000, l = 0x000400
+       ro     : o = 0x00000400, l = 0x007c00
+       rw     : o = 0x1c000000, l = 0x100000
+}
+
+SECTIONS
+{
+       .vector :
+       {
+               ___vector = . ; 
+               */vector.o(.text)
+               FILL(0xff)
+               ___vector_end = . ; 
+       } > vector
+       .text :
+       {
+                ___text = . ; 
+               *(.text)
+               *(.strings)
+               *(.rodata*)
+                ___text_end = . ; 
+       }  > ro
+       .tors :
+       {
+               . = ALIGN(4);
+               ___ctors = . ;
+               *(.ctors)
+               ___ctors_end = . ;
+               ___dtors = . ;
+               *(.dtors)
+               ___dtors_end = . ;
+       } > ro
+       data : AT (ADDR(.tors) + SIZEOF(.tors))
+       {
+           ___data_rom = ADDR(.tors) + SIZEOF(.tors);
+               ___data = . ;
+               *(.data)
+               ___data_end = . ;
+       } > rw
+       .bss :
+       {
+               ___bss = . ;
+               *(.bss)
+               *(COMMON)
+               ___bss_end = . ;  
+       }  >rw
+}
+
+
diff --git a/sample/sh/sh7262/gcc/vector.S b/sample/sh/sh7262/gcc/vector.S
new file mode 100644 (file)
index 0000000..7b26c51
--- /dev/null
@@ -0,0 +1,332 @@
+/* ------------------------------------------------------------------------ */
+/*  Hyper Operating System V4  サンプルプログラム                           */
+/*    割り込みベクタテーブル (日立 SH2 gcc 用)                              */
+/*                                                                          */
+/*                                  Copyright (C) 1998-2006 by Project HOS  */
+/*                                  http://sourceforge.jp/projects/hos/     */
+/* ------------------------------------------------------------------------ */
+
+
+                               .global _reset_handler
+                               .global __kernel_vector_004
+                               .global __kernel_vector_005
+                               .global __kernel_vector_006
+                               .global __kernel_vector_007
+                               .global __kernel_vector_008
+                               .global __kernel_vector_009
+                               .global __kernel_vector_010
+                               .global __kernel_vector_011
+                               .global __kernel_vector_012
+                               .global __kernel_vector_013
+                               .global __kernel_vector_014
+                               .global __kernel_vector_015
+                               .global __kernel_vector_016
+                               .global __kernel_vector_017
+                               .global __kernel_vector_018
+                               .global __kernel_vector_019
+                               .global __kernel_vector_020
+                               .global __kernel_vector_021
+                               .global __kernel_vector_022
+                               .global __kernel_vector_023
+                               .global __kernel_vector_024
+                               .global __kernel_vector_025
+                               .global __kernel_vector_026
+                               .global __kernel_vector_027
+                               .global __kernel_vector_028
+                               .global __kernel_vector_029
+                               .global __kernel_vector_030
+                               .global __kernel_vector_031
+                               .global __kernel_vector_032
+                               .global __kernel_vector_033
+                               .global __kernel_vector_034
+                               .global __kernel_vector_035
+                               .global __kernel_vector_036
+                               .global __kernel_vector_037
+                               .global __kernel_vector_038
+                               .global __kernel_vector_039
+                               .global __kernel_vector_040
+                               .global __kernel_vector_041
+                               .global __kernel_vector_042
+                               .global __kernel_vector_043
+                               .global __kernel_vector_044
+                               .global __kernel_vector_045
+                               .global __kernel_vector_046
+                               .global __kernel_vector_047
+                               .global __kernel_vector_048
+                               .global __kernel_vector_049
+                               .global __kernel_vector_050
+                               .global __kernel_vector_051
+                               .global __kernel_vector_052
+                               .global __kernel_vector_053
+                               .global __kernel_vector_054
+                               .global __kernel_vector_055
+                               .global __kernel_vector_056
+                               .global __kernel_vector_057
+                               .global __kernel_vector_058
+                               .global __kernel_vector_059
+                               .global __kernel_vector_060
+                               .global __kernel_vector_061
+                               .global __kernel_vector_062
+                               .global __kernel_vector_063
+                               .global __kernel_vector_064
+                               .global __kernel_vector_065
+                               .global __kernel_vector_066
+                               .global __kernel_vector_067
+                               .global __kernel_vector_068
+                               .global __kernel_vector_069
+                               .global __kernel_vector_070
+                               .global __kernel_vector_071
+                               .global __kernel_vector_072
+                               .global __kernel_vector_073
+                               .global __kernel_vector_074
+                               .global __kernel_vector_075
+                               .global __kernel_vector_076
+                               .global __kernel_vector_077
+                               .global __kernel_vector_078
+                               .global __kernel_vector_079
+                               .global __kernel_vector_080
+                               .global __kernel_vector_081
+                               .global __kernel_vector_082
+                               .global __kernel_vector_083
+                               .global __kernel_vector_084
+                               .global __kernel_vector_085
+                               .global __kernel_vector_086
+                               .global __kernel_vector_087
+                               .global __kernel_vector_088
+                               .global __kernel_vector_089
+                               .global __kernel_vector_090
+                               .global __kernel_vector_091
+                               .global __kernel_vector_092
+                               .global __kernel_vector_093
+                               .global __kernel_vector_094
+                               .global __kernel_vector_095
+                               .global __kernel_vector_096
+                               .global __kernel_vector_097
+                               .global __kernel_vector_098
+                               .global __kernel_vector_099
+                               .global __kernel_vector_100
+                               .global __kernel_vector_101
+                               .global __kernel_vector_102
+                               .global __kernel_vector_103
+                               .global __kernel_vector_104
+                               .global __kernel_vector_105
+                               .global __kernel_vector_106
+                               .global __kernel_vector_107
+                               .global __kernel_vector_108
+                               .global __kernel_vector_109
+                               .global __kernel_vector_110
+                               .global __kernel_vector_111
+                               .global __kernel_vector_112
+                               .global __kernel_vector_113
+                               .global __kernel_vector_114
+                               .global __kernel_vector_115
+                               .global __kernel_vector_116
+                               .global __kernel_vector_117
+                               .global __kernel_vector_118
+                               .global __kernel_vector_119
+                               .global __kernel_vector_120
+                               .global __kernel_vector_121
+                               .global __kernel_vector_122
+                               .global __kernel_vector_123
+                               .global __kernel_vector_124
+                               .global __kernel_vector_125
+                               .global __kernel_vector_126
+                               .global __kernel_vector_127
+                               .global __kernel_vector_128
+                               .global __kernel_vector_129
+                               .global __kernel_vector_130
+                               .global __kernel_vector_131
+                               .global __kernel_vector_132
+                               .global __kernel_vector_133
+                               .global __kernel_vector_134
+                               .global __kernel_vector_135
+                               .global __kernel_vector_136
+                               .global __kernel_vector_137
+                               .global __kernel_vector_138
+                               .global __kernel_vector_139
+                               .global __kernel_vector_140
+                               .global __kernel_vector_141
+                               .global __kernel_vector_142
+                               .global __kernel_vector_143
+                               .global __kernel_vector_144
+                               .global __kernel_vector_145
+                               .global __kernel_vector_146
+                               .global __kernel_vector_147
+                               .global __kernel_vector_148
+                               .global __kernel_vector_149
+                               .global __kernel_vector_150
+                               .global __kernel_vector_151
+                               .global __kernel_vector_152
+                               .global __kernel_vector_153
+                               .global __kernel_vector_154
+                               .global __kernel_vector_155
+                               .global __kernel_vector_156
+
+
+
+                               .text
+
+                               .long   _reset_handler          /* パワーオンリセット */
+                               .long   0
+                               .long   _reset_handler          /* マニュアルリセット */
+                               .long   0
+                               .long   __kernel_vector_004
+                               .long   __kernel_vector_005
+                               .long   __kernel_vector_006
+                               .long   __kernel_vector_007
+                               .long   __kernel_vector_008
+                               .long   __kernel_vector_009
+                               .long   __kernel_vector_010
+                               .long   __kernel_vector_011
+                               .long   __kernel_vector_012
+                               .long   __kernel_vector_013
+                               .long   __kernel_vector_014
+                               .long   __kernel_vector_015
+                               .long   __kernel_vector_016
+                               .long   __kernel_vector_017
+                               .long   __kernel_vector_018
+                               .long   __kernel_vector_019
+                               .long   __kernel_vector_020
+                               .long   __kernel_vector_021
+                               .long   __kernel_vector_022
+                               .long   __kernel_vector_023
+                               .long   __kernel_vector_024
+                               .long   __kernel_vector_025
+                               .long   __kernel_vector_026
+                               .long   __kernel_vector_027
+                               .long   __kernel_vector_028
+                               .long   __kernel_vector_029
+                               .long   __kernel_vector_030
+                               .long   __kernel_vector_031
+                               .long   __kernel_vector_032
+                               .long   __kernel_vector_033
+                               .long   __kernel_vector_034
+                               .long   __kernel_vector_035
+                               .long   __kernel_vector_036
+                               .long   __kernel_vector_037
+                               .long   __kernel_vector_038
+                               .long   __kernel_vector_039
+                               .long   __kernel_vector_040
+                               .long   __kernel_vector_041
+                               .long   __kernel_vector_042
+                               .long   __kernel_vector_043
+                               .long   __kernel_vector_044
+                               .long   __kernel_vector_045
+                               .long   __kernel_vector_046
+                               .long   __kernel_vector_047
+                               .long   __kernel_vector_048
+                               .long   __kernel_vector_049
+                               .long   __kernel_vector_050
+                               .long   __kernel_vector_051
+                               .long   __kernel_vector_052
+                               .long   __kernel_vector_053
+                               .long   __kernel_vector_054
+                               .long   __kernel_vector_055
+                               .long   __kernel_vector_056
+                               .long   __kernel_vector_057
+                               .long   __kernel_vector_058
+                               .long   __kernel_vector_059
+                               .long   __kernel_vector_060
+                               .long   __kernel_vector_061
+                               .long   __kernel_vector_062
+                               .long   __kernel_vector_063
+                               .long   __kernel_vector_064
+                               .long   __kernel_vector_065
+                               .long   __kernel_vector_066
+                               .long   __kernel_vector_067
+                               .long   __kernel_vector_068
+                               .long   __kernel_vector_069
+                               .long   __kernel_vector_070
+                               .long   __kernel_vector_071
+                               .long   __kernel_vector_072
+                               .long   __kernel_vector_073
+                               .long   __kernel_vector_074
+                               .long   __kernel_vector_075
+                               .long   __kernel_vector_076
+                               .long   __kernel_vector_077
+                               .long   __kernel_vector_078
+                               .long   __kernel_vector_079
+                               .long   __kernel_vector_080
+                               .long   __kernel_vector_081
+                               .long   __kernel_vector_082
+                               .long   __kernel_vector_083
+                               .long   __kernel_vector_084
+                               .long   __kernel_vector_085
+                               .long   __kernel_vector_086
+                               .long   __kernel_vector_087
+                               .long   __kernel_vector_088
+                               .long   __kernel_vector_089
+                               .long   __kernel_vector_090
+                               .long   __kernel_vector_091
+                               .long   __kernel_vector_092
+                               .long   __kernel_vector_093
+                               .long   __kernel_vector_094
+                               .long   __kernel_vector_095
+                               .long   __kernel_vector_096
+                               .long   __kernel_vector_097
+                               .long   __kernel_vector_098
+                               .long   __kernel_vector_099
+                               .long   __kernel_vector_100
+                               .long   __kernel_vector_101
+                               .long   __kernel_vector_102
+                               .long   __kernel_vector_103
+                               .long   __kernel_vector_104
+                               .long   __kernel_vector_105
+                               .long   __kernel_vector_106
+                               .long   __kernel_vector_107
+                               .long   __kernel_vector_108
+                               .long   __kernel_vector_109
+                               .long   __kernel_vector_110
+                               .long   __kernel_vector_111
+                               .long   __kernel_vector_112
+                               .long   __kernel_vector_113
+                               .long   __kernel_vector_114
+                               .long   __kernel_vector_115
+                               .long   __kernel_vector_116
+                               .long   __kernel_vector_117
+                               .long   __kernel_vector_118
+                               .long   __kernel_vector_119
+                               .long   __kernel_vector_120
+                               .long   __kernel_vector_121
+                               .long   __kernel_vector_122
+                               .long   __kernel_vector_123
+                               .long   __kernel_vector_124
+                               .long   __kernel_vector_125
+                               .long   __kernel_vector_126
+                               .long   __kernel_vector_127
+                               .long   __kernel_vector_128
+                               .long   __kernel_vector_129
+                               .long   __kernel_vector_130
+                               .long   __kernel_vector_131
+                               .long   __kernel_vector_132
+                               .long   __kernel_vector_133
+                               .long   __kernel_vector_134
+                               .long   __kernel_vector_135
+                               .long   __kernel_vector_136
+                               .long   __kernel_vector_137
+                               .long   __kernel_vector_138
+                               .long   __kernel_vector_139
+                               .long   __kernel_vector_140
+                               .long   __kernel_vector_141
+                               .long   __kernel_vector_142
+                               .long   __kernel_vector_143
+                               .long   __kernel_vector_144
+                               .long   __kernel_vector_145
+                               .long   __kernel_vector_146
+                               .long   __kernel_vector_147
+                               .long   __kernel_vector_148
+                               .long   __kernel_vector_149
+                               .long   __kernel_vector_150
+                               .long   __kernel_vector_151
+                               .long   __kernel_vector_152
+                               .long   __kernel_vector_153
+                               .long   __kernel_vector_154
+                               .long   __kernel_vector_155
+                               .long   __kernel_vector_156
+
+
+
+                               .end
+
+
+/* end of file */
diff --git a/sample/sh/sh7262/main.c b/sample/sh/sh7262/main.c
new file mode 100644 (file)
index 0000000..973fc50
--- /dev/null
@@ -0,0 +1,25 @@
+/** 
+ *  Sample program for Hyper Operating System V4 Advance
+ *
+ * @file  main.c
+ * @brief %jp{メイン関数}%en{main}
+ *
+ * Copyright (C) 1998-2010 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/sh/sh7262/ostimer.c b/sample/sh/sh7262/ostimer.c
new file mode 100644 (file)
index 0000000..1b051b6
--- /dev/null
@@ -0,0 +1,45 @@
+/** 
+ *  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"
+#include "regs_sh7262.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(INHNO_OSTIMER, &dfinh); */
+       
+       /* %jp{タイマ動作開始} */
+       
+       /* %jp{割込み許可} */
+}
+
+
+/** %jp{タイマ割込みハンドラ} */
+void OsTimer_IrqHandler(void)
+{
+       
+       isig_tim();
+}
+
+
+/* end of file */
diff --git a/sample/sh/sh7262/ostimer.h b/sample/sh/sh7262/ostimer.h
new file mode 100644 (file)
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/sh/sh7262/regs_sh7262.h b/sample/sh/sh7262/regs_sh7262.h
new file mode 100644 (file)
index 0000000..500b86a
--- /dev/null
@@ -0,0 +1,22 @@
+/* SH7262レジスタ定義ファイル */
+
+
+
+#ifndef __sh7262_regs_h__
+#define __sh7262_regs_h__
+
+
+/* SCI0 */
+#define        REG_SCI0_SMR            ((volatile UH*)0xffff8000)              /* シリアルモードレジスタ_0 */
+#define        REG_SCI0_BRR            ((volatile UB*)0xffff8004)              /* ビットレートレジスタ_0 */
+#define        REG_SCI0_SCR            ((volatile UH*)0xffff8008)              /* シリアルコントロールレジスタ_0 */
+#define        REG_SCI0_FTDR           ((volatile UB*)0xffff800c)              /* 送信FIFOデータレジスタ_0 */
+#define        REG_SCI0_SSR            ((volatile UH*)0xffff8010)              /* シリアルステータスレジスタ_0 */
+#define        REG_SCI0_FRDR           ((volatile UB*)0xffff8014)              /* 受信FIFOデータレジスタ_0 */
+
+
+
+#endif /* __sh7262_regs_h__ */
+
+
+/* end of file */
diff --git a/sample/sh/sh7262/sample.c b/sample/sh/sh7262/sample.c
new file mode 100644 (file)
index 0000000..f3434bf
--- /dev/null
@@ -0,0 +1,179 @@
+/** 
+ *  Sample program for Hyper Operating System V4 Advance
+ *
+ * @file  sample.c
+ * @brief %jp{サンプルプログラム}%en{Sample program}
+ *
+ * Copyright (C) 1998-2010 by Project HOS
+ * http://sourceforge.jp/projects/hos/
+ */
+
+
+#include <stdlib.h>
+#include <string.h>
+#include "kernel.h"
+#include "kernel_id.h"
+#include "sci1.h"
+#include "regs_sh7262.h"
+
+
+#define LEFT(num)      ((num) <= 1 ? 5 : (num) - 1)
+#define RIGHT(num)     ((num) >= 5 ? 1 : (num) + 1)
+
+
+ID mbxid;
+ID mpfid;
+
+
+/*const VP _kernel_int_isp = (VP)0xfffffff0;*/
+
+
+/* void sim_puts(void *addr); */
+
+
+
+/** %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{ハードウェア固有設定} */
+       
+       /* %jp{SCI1の初期化} */
+       Sci1_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)
+{
+       dly_tsk(rand() % 1000 + 100);   
+}
+
+
+/** %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;
+       
+       print_state(num, "start");
+       
+       /* %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;
+       
+       Sci1_Initialize();
+       
+       for ( ; ; )
+       {
+               rcv_mbx(mbxid, (T_MSG **)&msg);
+               Sci1_PutString(msg->text);
+               rel_mpf(mpfid, msg);
+       }
+}
+
+
+
+/* end of file */
diff --git a/sample/sh/sh7262/sample.h b/sample/sh/sh7262/sample.h
new file mode 100644 (file)
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/sh/sh7262/sci1.c b/sample/sh/sh7262/sci1.c
new file mode 100644 (file)
index 0000000..9a1593e
--- /dev/null
@@ -0,0 +1,46 @@
+/** 
+ *  Sample program for Hyper Operating System V4 Advance
+ *
+ * @file  sci1.c
+ * @brief %jp{SCI1への出力}%en{SCI1 device driver}
+ *
+ * Copyright (C) 1998-2010 by Project HOS
+ * http://sourceforge.jp/projects/hos/
+ */
+
+
+#include "kernel.h"
+#include "regs_sh7262.h"
+
+
+/* %jp{SCI1 の初期化} */
+void Sci1_Initialize(void)
+{
+}
+
+/* %jp{1文字出力} */
+void Sci1_PutChar(int c)
+{
+}
+
+/* %jp{文字列出力} */
+void Sci1_PutString(const char *text)
+{
+       while ( *text != '\0' )
+       {
+               if ( *text == '\n' )
+               {
+                       Sci1_PutChar('\r');
+                       Sci1_PutChar('\n');
+               }
+               else
+               {
+                       Sci1_PutChar(*text);
+               }
+               
+               text++;
+       }
+}
+
+
+/* end of file */
diff --git a/sample/sh/sh7262/sci1.h b/sample/sh/sh7262/sci1.h
new file mode 100644 (file)
index 0000000..cadcdd0
--- /dev/null
@@ -0,0 +1,32 @@
+/** 
+ *  Sample program for Hyper Operating System V4 Advance
+ *
+ * @file  sci1.h
+ * @brief %jp{SCI1への出力}%en{SCI1 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 Sci1_Initialize(void);                                    /* %jp{SCI1 の初期化} */
+void Sci1_PutChar(int c);                                      /* %jp{1文字出力} */
+void Sci1_PutString(const char *text);         /* %jp{文字列出力} */
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* __ostimer_h__ */
+
+
+/* end of file */
diff --git a/sample/sh/sh7262/system.cfg b/sample/sh/sh7262/system.cfg
new file mode 100644 (file)
index 0000000..d86a819
--- /dev/null
@@ -0,0 +1,43 @@
+/** 
+ *  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(512, NULL);
+KERNEL_INT_STK(512, NULL);
+KERNEL_MAX_TSKID(5);
+KERNEL_MAX_SEMID(5);
+KERNEL_MAX_FLGID(2);
+KERNEL_MAX_MBXID(2);
+KERNEL_MAX_MPFID(2);
+KERNEL_MAX_ISRID(2);
+
+
+/* %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, 256, NULL});
+CRE_TSK(TSKID_SAMPLE1, {TA_HLNG, 1, Sample_Task, 2, 256, NULL});
+CRE_TSK(TSKID_SAMPLE2, {TA_HLNG, 2, Sample_Task, 2, 256, NULL});
+CRE_TSK(TSKID_SAMPLE3, {TA_HLNG, 3, Sample_Task, 2, 256, NULL});
+CRE_TSK(TSKID_SAMPLE4, {TA_HLNG, 4, Sample_Task, 2, 256, NULL});
+CRE_TSK(TSKID_SAMPLE5, {TA_HLNG, 5, Sample_Task, 2, 256, 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});
+
+
+/* end of file */