Index: asp3_wo_tecs/trunk/arch/arm_gcc/common/core_support.S
===================================================================
--- asp3_wo_tecs/trunk/arch/arm_gcc/common/core_support.S	(revision 302)
+++ asp3_wo_tecs/trunk/arch/arm_gcc/common/core_support.S	(revision 306)
@@ -6,5 +6,5 @@
  *  Copyright (C) 2000-2004 by Embedded and Real-Time Systems Laboratory
  *                              Toyohashi Univ. of Technology, JAPAN
- *  Copyright (C) 2006-2015 by Embedded and Real-Time Systems Laboratory
+ *  Copyright (C) 2006-2016 by Embedded and Real-Time Systems Laboratory
  *              Graduate School of Information Science, Nagoya Univ., JAPAN
  * 
@@ -53,5 +53,5 @@
  *  ã®è²¬ä»»ãè² ããªãï¼
  * 
- *  $Id: core_support.S 459 2015-08-29 13:03:42Z ertl-hiro $
+ *  $Id: core_support.S 733 2016-04-03 09:10:54Z ertl-hiro $
  */
 
@@ -72,5 +72,6 @@
  *  ä¾å¤ãã¯ã¿
  */
-	ASECTION(vector)
+	ASECTION(.vector)
+	AALIGN(5)
 	AGLOBAL(vector_table)
 ALABEL(vector_table)
@@ -122,5 +123,5 @@
 ã§å¼ã³åºãããï¼
 	 */
-	push	{lr}					/* æ»ãçªå°ãä¿å­ */
+	push	{r12,lr}				/* æ»ãçªå°ãä¿å­ï¼r12ã¯ããã¼ */
 #ifdef TOPPERS_SUPPORT_OVRHDR
 	bl		ovrtimer_stop
@@ -139,5 +140,5 @@
 	bl		ovrtimer_start
 #endif /* TOPPERS_SUPPORT_OVRHDR */
-	pop		{lr}					/* æ»ãçªå°ãå¾©å¸° */
+	pop		{r12,lr}				/* æ»ãçªå°ãå¾©å¸° */
 	bx		lr
 
@@ -325,5 +326,5 @@
 	 */
 	msr		cpsr_c, #(CPSR_SVC_MODE AOR CPSR_IRQ_BIT)
-	stmfd	sp!, {r0-r4,r12,lr,pc}		/* pcã¯ã¹ãã¼ã¹ç¢ºä¿ã®ãã */
+	stmfd	sp!, {r0-r5,r12,lr,pc}		/* pcã¯ã¹ãã¼ã¹ç¢ºä¿ã®ãã */
 
 	/*
@@ -339,5 +340,5 @@
 	 */
 	msr		cpsr_c, #(CPSR_SVC_MODE AOR CPSR_IRQ_BIT)
-	str		r2, [sp,#0x1c]			/* æ»ãçªå°ãã¹ã¿ãã¯ã«ä¿å­ */
+	str		r2, [sp,#0x20]			/* æ»ãçªå°ãã¹ã¿ãã¯ã«ä¿å­ */
 	push	{r1}					/* spsrãã¹ã¿ãã¯ã«ä¿å­ */
 #else /* __TARGET_ARCH_ARM < 6 */
@@ -354,6 +355,13 @@
 	 */
 	cps		#CPSR_SVC_MODE
-	stmfd	sp!, {r0-r4,r12,lr}
+	stmfd	sp!, {r0-r5,r12,lr}
 #endif /* __TARGET_ARCH_ARM < 6 */
+
+	/*
+	 *  ã¹ã¿ãã¯ãã¤ã³ã¿ã®èª¿æ´
+	 */
+	and		r1, sp, #4
+	sub		sp, sp, r1
+	push	{r0,r1}					/* r0ã¯ã¹ãã¼ã¹ç¢ºä¿ã®ãã */
 
 	/*
@@ -378,9 +386,9 @@
 	 *  éã¿ã¹ã¯ã³ã³ãã­ã¹ãç¨ã®ã¹ã¿ãã¯ã«åãæããï¼
 	 */
-	mov		r1, sp					/* ãã®æç¹ã®ã¹ã¿ãã¯ãã¤ã³ã¿ãr1ã« */
+	mov		r3, sp					/* ãã®æç¹ã®ã¹ã¿ãã¯ãã¤ã³ã¿ãr3ã« */
 	ldr		r2, =istkpt				/* éã¿ã¹ã¯ã³ã³ãã­ã¹ãç¨ã®ã¹ã¿ãã¯ã« */
 	ldr		sp, [r2]
-	push	{r1}					/* åæãåã®ã¹ã¿ãã¯ãã¤ã³ã¿ãä¿å­ */
-
+	push	{r0,r3}					/* åæãåã®ã¹ã¿ãã¯ãã¤ã³ã¿ãä¿å­ */
+									/* r0ã¯ã¹ãã¼ã¹ç¢ºä¿ã®ãã */
 ALABEL(irq_handler_1)
 	/*
@@ -388,7 +396,12 @@
 	 */
 	bl		irc_begin_int
-	cmp		r4, #TNUM_INHNO			/* ã¹ããªã¢ã¹å²è¾¼ã¿ãªã */
-	bhs		irq_handler_2			/*  irq_handler_2ã«åå² */
-
+#if TNUM_INHNO <= 256 || __TARGET_ARCH_ARM <= 6
+	cmp		r4, #TNUM_INHNO			/* TNUM_INHNOã®å¤ã«ãã£ã¦ã¯ã¨ã©ã¼ã«ãªã */
+#else /* TNUM_INHNO <= 256 || __TARGET_ARCH_ARM <= 6 */
+	movw	r3, #TNUM_INHNO
+	cmp		r4, r3			
+#endif /* TNUM_INHNO <= 256 || __TARGET_ARCH_ARM <= 6 */
+	bhs		irq_handler_2			/* ã¹ããªã¢ã¹å²è¾¼ã¿ãªã */
+									/*  irq_handler_2ã«åå² */
 	/*
 	 *  CPUã­ãã¯è§£é¤ç¶æ
@@ -447,5 +460,4 @@
 ALABEL(irq_handler_2)
 	bl		irc_end_int
-#endif /* OMIT_IRQ_HANDLER */
 
 	/*
@@ -462,6 +474,6 @@
 	 *  ã¿ã¹ã¯ç¨ã®ã¹ã¿ãã¯ã«æ»ãï¼
 	 */
-	pop		{r1}
-	mov   	sp, r1
+	pop		{r0,r3}
+	mov   	sp, r3
 
 	/*
@@ -469,5 +481,4 @@
 è¦ãå¤å®ããï¼
 	 */
-ALABEL(ret_int_1)
 	ldr		r0, =p_runtsk			/* p_runtsk â r0 */
 	ldr		r0, [r0]
@@ -482,5 +493,5 @@
 	tst		r0, r0					/* p_runtskãNULLãªãdispatcher_0ã¸ */
 	beq		dispatcher_0
-	stmfd	sp!, {r5-r11}			/* éã¹ã¯ã©ããã¬ã¸ã¹ã¿ã®ä¿å­ */
+	stmfd	sp!, {r6-r11}			/* éã¹ã¯ã©ããã¬ã¸ã¹ã¿ã®ä¿å­ */
 	str		sp, [r0,#TCB_sp]		/* ã¹ã¿ãã¯ãã¤ã³ã¿ãä¿å­ */
 	adr		r1, ret_int_r			/* å®è¡åéçªå°ãä¿å­ */
@@ -492,5 +503,5 @@
 	 *  ã³ã³ãã­ã¹ããå¾©å¸°ããï¼
 	 */
-	ldmfd	sp!, {r5-r11}			/* éã¹ã¯ã©ããã¬ã¸ã¹ã¿ã®å¾©å¸° */
+	ldmfd	sp!, {r6-r11}			/* éã¹ã¯ã©ããã¬ã¸ã¹ã¿ã®å¾©å¸° */
 
 #ifdef TOPPERS_SUPPORT_OVRHDR
@@ -516,12 +527,14 @@
 #endif /* TOPPERS_SUPPORT_OVRHDR */
 ALABEL(irq_handler_3)
+	pop		{r0,r1}					/* ã¹ã¿ãã¯ãã¤ã³ã¿ã®èª¿æ´ */
+	add		sp, sp, r1
 #if __TARGET_ARCH_ARM < 6
 	ldmfd	sp!, {r0}				/* æ»ãå
 ã®cpsrãspsrã«è¨­å® */
 	msr		spsr_cxsf, r0
-	ldmfd	sp!, {r0-r4,r12,lr,pc}^	/* ã³ã³ãã­ã¹ãã®å¾©å¸° */
+	ldmfd	sp!, {r0-r5,r12,lr,pc}^	/* ã³ã³ãã­ã¹ãã®å¾©å¸° */
 									/* ^ä»ããªã®ã§ï¼spsr â cpsr */
 #else /* __TARGET_ARCH_ARM < 6 */
-	ldmfd	sp!, {r0-r4,r12,lr}
+	ldmfd	sp!, {r0-r5,r12,lr}
 	rfefd	sp!
 #endif /* __TARGET_ARCH_ARM < 6 */
@@ -536,4 +549,5 @@
 	b		irq_handler_3
 #endif /* TOPPERS_SUPPORT_OVRHDR */
+#endif /* OMIT_IRQ_HANDLER */
 
 /*
@@ -560,5 +574,5 @@
 	 */
 	msr		cpsr_c, #(CPSR_SVC_MODE AOR CPSR_FIQ_IRQ_BIT)
-	stmfd	sp!, {r0-r4,r12,lr,pc}		/* pcã¯ã¹ãã¼ã¹ç¢ºä¿ã®ãã */
+	stmfd	sp!, {r0-r5,r12,lr,pc}		/* pcã¯ã¹ãã¼ã¹ç¢ºä¿ã®ãã */
 
 	/*
@@ -573,5 +587,5 @@
 	 */
 	msr		cpsr_c, #(CPSR_SVC_MODE AOR CPSR_FIQ_IRQ_BIT)
-	str		r2, [sp,#0x1c]			/* æ»ãçªå°ãã¹ã¿ãã¯ã«ä¿å­ */
+	str		r2, [sp,#0x20]			/* æ»ãçªå°ãã¹ã¿ãã¯ã«ä¿å­ */
 	push	{r1}					/* spsrãã¹ã¿ãã¯ã«ä¿å­ */
 #else /* __TARGET_ARCH_ARM < 6 */
@@ -587,5 +601,5 @@
 	 */
 	cps		#CPSR_SVC_MODE
-	stmfd	sp!, {r0-r4,r12,lr}
+	stmfd	sp!, {r0-r5,r12,lr}
 #endif /* __TARGET_ARCH_ARM < 6 */
 	mov		r4, #EXCNO_UNDEF
@@ -609,5 +623,5 @@
 	 */
 	msr		cpsr_c, #(CPSR_SVC_MODE AOR CPSR_FIQ_IRQ_BIT)
-	stmfd	sp!, {r0-r4,r12,lr,pc}		/* pcã¯ã¹ãã¼ã¹ç¢ºä¿ã®ãã */
+	stmfd	sp!, {r0-r5,r12,lr,pc}		/* pcã¯ã¹ãã¼ã¹ç¢ºä¿ã®ãã */
 
 	/*
@@ -620,5 +634,5 @@
 	 *  æ»ãçªå°ã¨spsrãä¿å­ããï¼
 	 */
-	str		r2, [sp,#0x1c]			/* æ»ãçªå°ãã¹ã¿ãã¯ã«ä¿å­ */
+	str		r2, [sp,#0x20]			/* æ»ãçªå°ãã¹ã¿ãã¯ã«ä¿å­ */
 	push	{r1}					/* spsrãã¹ã¿ãã¯ã«ä¿å­ */
 #else /* __TARGET_ARCH_ARM < 6 */
@@ -634,5 +648,5 @@
 	 */
 	cps		#CPSR_SVC_MODE			/* ä¸è¦ã¨æããã */
-	stmfd	sp!, {r0-r4,r12,lr}
+	stmfd	sp!, {r0-r5,r12,lr}
 #endif /* __TARGET_ARCH_ARM < 6 */
 	mov		r4, #EXCNO_SVC
@@ -657,5 +671,5 @@
 	 */
 	msr		cpsr_c, #(CPSR_SVC_MODE AOR CPSR_FIQ_IRQ_BIT)
-	stmfd	sp!, {r0-r4,r12,lr,pc}		/* pcã¯ã¹ãã¼ã¹ç¢ºä¿ã®ãã */
+	stmfd	sp!, {r0-r5,r12,lr,pc}		/* pcã¯ã¹ãã¼ã¹ç¢ºä¿ã®ãã */
 
 	/*
@@ -670,5 +684,5 @@
 	 */
 	msr		cpsr_c, #(CPSR_SVC_MODE AOR CPSR_FIQ_IRQ_BIT)
-	str		r2, [sp,#0x1c]			/* æ»ãçªå°ãã¹ã¿ãã¯ã«ä¿å­ */
+	str		r2, [sp,#0x20]			/* æ»ãçªå°ãã¹ã¿ãã¯ã«ä¿å­ */
 	push	{r1}					/* spsrãã¹ã¿ãã¯ã«ä¿å­ */
 #else /* __TARGET_ARCH_ARM < 6 */
@@ -684,5 +698,5 @@
 	 */
 	cps		#CPSR_SVC_MODE
-	stmfd	sp!, {r0-r4,r12,lr}
+	stmfd	sp!, {r0-r5,r12,lr}
 #endif /* __TARGET_ARCH_ARM < 6 */
 	mov		r4, #EXCNO_PABORT
@@ -720,5 +734,5 @@
 	 */
 	msr		cpsr_c, #(CPSR_SVC_MODE AOR CPSR_FIQ_IRQ_BIT)
-	stmfd	sp!, {r0-r4,r12,lr,pc}		/* pcã¯ã¹ãã¼ã¹ç¢ºä¿ã®ãã */
+	stmfd	sp!, {r0-r5,r12,lr,pc}		/* pcã¯ã¹ãã¼ã¹ç¢ºä¿ã®ãã */
 
 	/*
@@ -733,5 +747,5 @@
 	 */
 	msr		cpsr_c, #(CPSR_SVC_MODE AOR CPSR_FIQ_IRQ_BIT)
-	str		r2, [sp,#0x1c]			/* æ»ãçªå°ãã¹ã¿ãã¯ã«ä¿å­ */
+	str		r2, [sp,#0x20]			/* æ»ãçªå°ãã¹ã¿ãã¯ã«ä¿å­ */
 	push	{r1}					/* spsrãã¹ã¿ãã¯ã«ä¿å­ */
 #else /* __TARGET_ARCH_ARM < 6 */
@@ -747,5 +761,5 @@
 	 */
 	cps		#CPSR_SVC_MODE
-	stmfd	sp!, {r0-r4,r12,lr}
+	stmfd	sp!, {r0-r5,r12,lr}
 #endif /* __TARGET_ARCH_ARM < 6 */
 	mov		r4, #EXCNO_DABORT
@@ -766,5 +780,5 @@
 	ldr		sp, =istkpt
 	ldr		sp, [sp]
-	stmfd	sp!, {r0-r4,r12,lr,pc}		/* pcã¯ã¹ãã¼ã¹ç¢ºä¿ã®ãã */
+	stmfd	sp!, {r0-r5,r12,lr,pc}		/* pcã¯ã¹ãã¼ã¹ç¢ºä¿ã®ãã */
 
 	/*
@@ -779,5 +793,5 @@
 	 */
 	msr		cpsr_c, #(CPSR_SVC_MODE AOR CPSR_FIQ_IRQ_BIT)
-	str		r2, [sp,#0x1c]			/* æ»ãçªå°ãã¹ã¿ãã¯ã«ä¿å­ */
+	str		r2, [sp,#0x20]			/* æ»ãçªå°ãã¹ã¿ãã¯ã«ä¿å­ */
 	push	{r1}					/* spsrãã¹ã¿ãã¯ã«ä¿å­ */
 #else /* __TARGET_ARCH_ARM < 6 */
@@ -786,5 +800,5 @@
 	 *  ã¯ãã¤ã³ã¿ãåæåããï¼
 	 */
-	cpsid	if,#CPSR_SVC_MODE
+	cpsid	if, #CPSR_SVC_MODE
 	ldr		sp, =istkpt
 	ldr		sp, [sp]
@@ -802,5 +816,5 @@
 	 */
 	cps		#CPSR_SVC_MODE
-	stmfd	sp!, {r0-r4,r12,lr}
+	stmfd	sp!, {r0-r5,r12,lr}
 #endif /* __TARGET_ARCH_ARM < 6 */
 
@@ -833,5 +847,5 @@
 	 */
 	msr		cpsr_c, #(CPSR_SVC_MODE AOR CPSR_FIQ_IRQ_BIT)
-	stmfd	sp!, {r0-r4,r12,lr,pc}		/* pcã¯ã¹ãã¼ã¹ç¢ºä¿ã®ãã */
+	stmfd	sp!, {r0-r5,r12,lr,pc}		/* pcã¯ã¹ãã¼ã¹ç¢ºä¿ã®ãã */
 
 	/*
@@ -846,5 +860,5 @@
 	 */
 	msr		cpsr_c, #(CPSR_SVC_MODE AOR CPSR_FIQ_IRQ_BIT)
-	str		r2, [sp,#0x1c]			/* æ»ãçªå°ãã¹ã¿ãã¯ã«ä¿å­ */
+	str		r2, [sp,#0x20]			/* æ»ãçªå°ãã¹ã¿ãã¯ã«ä¿å­ */
 	push	{r1}					/* spsrãã¹ã¿ãã¯ã«ä¿å­ */
 #else /* __TARGET_ARCH_ARM < 6 */
@@ -860,5 +874,5 @@
 	 */
 	cps		#CPSR_SVC_MODE
-	stmfd	sp!, {r0-r4,r12,lr}
+	stmfd	sp!, {r0-r5,r12,lr}
 #endif /* __TARGET_ARCH_ARM < 6 */
 	mov		r4, #EXCNO_FIQ
@@ -875,5 +889,5 @@
  * ããã®æç¹ã®ã¬ã¸ã¹ã¿ç¶æ
 ã
- *  r0ï¼CPUä¾å¤ãã³ãã©çªå·
+ *  r4ï¼CPUä¾å¤ãã³ãã©çªå·
  */
 ALABEL(exc_handler_1)
@@ -889,8 +903,15 @@
 	ldr		r3, [r2]
 	push	{r3}					/* ä¾å¤ãã¹ãã«ã¦ã³ããä¿å­ */
-	mov		r12, sp					/* CPUä¾å¤ã®æ
+	mov		r5, sp					/* CPUä¾å¤ã®æ
 å ±ãè¨æ¶ãã¦ããé åã® */
-									/*				å
-é ­çªå°ãr12ã«ä¿å­ */
+									/*				  å
+é ­çªå°ãr5ã«ä¿å­ */
+	/*
+	 *  ã¹ã¿ãã¯ãã¤ã³ã¿ã®èª¿æ´
+	 */
+	and		r1, sp, #4
+	sub		sp, sp, r1
+	push	{r0,r1}					/* r0ã¯ã¹ãã¼ã¹ç¢ºä¿ã®ãã */
+
 	/*
 	 *  ã«ã¼ãã«ç®¡çå¤ã®CPUä¾å¤ãå¤å®ãã
@@ -905,5 +926,5 @@
 	 *  ã®ãããããã»ããããã¦ãããªãï¼ããè©²å½ããï¼
 	 */
-	ldr		r1, [r12,#T_EXCINF_cpsr]	/* ä¾å¤ãã¬ã¼ã ããcpsrãåå¾ */
+	ldr		r1, [r5,#T_EXCINF_cpsr]		/* ä¾å¤ãã¬ã¼ã ããcpsrãåå¾ */
 	ands	r1, r1, #CPSR_FIQ_IRQ_BIT
 	bne		nk_exc_handler_1		/* ã«ã¼ãã«ç®¡çå¤ã®CPUä¾å¤ã®å¦çã¸ */
@@ -915,5 +936,5 @@
 	 *  r3ï¼excpt_nest_countã®å¤
 	 *  r4ï¼CPUä¾å¤ãã³ãã©çªå·
-	 *  r12ï¼CPUä¾å¤ã®æ
+	 *  r5ï¼CPUä¾å¤ã®æ
 å ±ãè¨æ¶ãã¦ããé åã®å
 é ­çªå°
@@ -932,7 +953,5 @@
 	 *  ãªã¼ãã©ã³ã¿ã¤ããåæ­¢ããï¼
 	 */
-	push	{r12}
 	bl		ovrtimer_stop
-	pop		{r12}
 #endif /* TOPPERS_SUPPORT_OVRHDR */
 
@@ -943,6 +962,6 @@
 	ldr		r2, =istkpt				/* éã¿ã¹ã¯ã³ã³ãã­ã¹ãç¨ã®ã¹ã¿ãã¯ã« */
 	ldr		sp, [r2]
-	push	{r3}					/* åæãåã®ã¹ã¿ãã¯ãã¤ã³ã¿ãä¿å­ */
-
+	push	{r0,r3}					/* åæãåã®ã¹ã¿ãã¯ãã¤ã³ã¿ãä¿å­ */
+									/* r0ã¯ã¹ãã¼ã¹ç¢ºä¿ã®ãã */
 ALABEL(exc_handler_2)
 	/*
@@ -950,5 +969,5 @@
 ã
 	 *  r4ï¼CPUä¾å¤ãã³ãã©çªå·
-	 *  r12ï¼CPUä¾å¤ã®æ
+	 *  r5ï¼CPUä¾å¤ã®æ
 å ±ãè¨æ¶ãã¦ããé åã®å
 é ­çªå°
@@ -982,8 +1001,6 @@
 	 */
 #ifdef LOG_EXC_ENTER
-	push	{r12}
 	mov		r0, r4					/* CPUä¾å¤çªå·ããã©ã¡ã¼ã¿ã«æ¸¡ã */
 	bl		log_exc_enter
-	pop		{r12}
 #endif /* LOG_EXC_ENTER */
 
@@ -993,5 +1010,5 @@
 	ldr		r2, =exc_table			/* CPUä¾å¤ãã³ãã©ãã¼ãã«ã®èª­è¾¼ã¿ */
 	ldr		r3, [r2,r4,lsl #2]		/* CPUä¾å¤ãã³ãã©ã®çªå° â r3 */
-	mov		r0, r12					/* CPUä¾å¤ã®æ
+	mov		r0, r5					/* CPUä¾å¤ã®æ
 å ±ãè¨æ¶ãã¦ããé åã® */
 									/*		å
@@ -1035,30 +1052,88 @@
 	ldr		r3, [r2]
 	subs	r3, r3, #1
-	str		r3, [r2]
+	str		r3, [r2]				/* æ»ãå
+ãéã¿ã¹ã¯ã³ã³ãã­ã¹ããªã */
+	bne		exc_handler_3			/*				exc_handler_3ã«åå² */
 
 	/*
 	 *  ã¿ã¹ã¯ç¨ã®ã¹ã¿ãã¯ã«æ»ãï¼
 	 */
-	popeq	{r1}					/* æ»ãå
-ãã¿ã¹ã¯ã³ã³ãã­ã¹ããªã */
-	moveq	sp, r1					/*		 ã¿ã¹ã¯ç¨ã®ã¹ã¿ãã¯ã«æ»ã */
+	pop		{r0,r3}
+	mov		sp, r3
+
+	/*
+	 *  ãã£ã¹ããããå¿
+è¦ãå¤å®ããï¼
+	 */
+	ldr		r0, =p_runtsk			/* p_runtsk â r0 */
+	ldr		r0, [r0]
+	ldr		r1, =p_schedtsk			/* p_schedtsk â r1 */
+	ldr		r1, [r1]
+	teq		r0, r1					/* p_runtskã¨p_schedtskãåããªã */
+	beq		exc_handler_4			/*				  exc_handler_4ã¸ */
+
+	/*
+	 *  ã³ã³ãã­ã¹ããä¿å­ããï¼
+	 */
+	tst		r0, r0					/* p_runtskãNULLãªãdispatcher_0ã¸ */
+	beq		dispatcher_0
+	stmfd	sp!, {r6-r11}			/* éã¹ã¯ã©ããã¬ã¸ã¹ã¿ã®ä¿å­ */
+	str		sp, [r0,#TCB_sp]		/* ã¹ã¿ãã¯ãã¤ã³ã¿ãä¿å­ */
+	adr		r1, ret_exc_r			/* å®è¡åéçªå°ãä¿å­ */
+	str		r1, [r0,#TCB_pc]
+	b		dispatcher				/* r0ã«ã¯p_runtskãæ ¼ç´ããã¦ãã */
+
+ALABEL(ret_exc_r)
+	/*
+	 *  ã³ã³ãã­ã¹ããå¾©å¸°ããï¼
+	 */
+	ldmfd	sp!, {r6-r11}			/* éã¹ã¯ã©ããã¬ã¸ã¹ã¿ã®å¾©å¸° */
+
+#ifdef TOPPERS_SUPPORT_OVRHDR
+	/*
+	 *  ãªã¼ãã©ã³ã¿ã¤ããåä½éå§ããï¼
+	 */
+	bl		ovrtimer_start
+#endif /* TOPPERS_SUPPORT_OVRHDR */
+
+	/*
+	 *  CPUä¾å¤å¦çããã®ãªã¿ã¼ã³
+	 *
+	 *  CPUä¾å¤å¦çããã®ãªã¿ã¼ã³ã«ããï¼CPUã­ãã¯è§£é¤ç¶æ
+ã«é·ç§»ããã
+	 *  ãã«ããå¿
+è¦ããããï¼ARMã¯CPSRã®ãããã«ãã£ã¦CPUã­ãã¯ç¶æ
+ã
+	 *  è¡¨ãã¦ããããï¼CPSRãå
+ã«æ»ãã¦ãªã¿ã¼ã³ããã°ããï¼
+	 */
+#ifndef TOPPERS_SUPPORT_OVRHDR
+ALABEL(exc_handler_4)
+#endif /* TOPPERS_SUPPORT_OVRHDR */
+ALABEL(exc_handler_3)
+	pop		{r0,r1}					/* ã¹ã¿ãã¯ãã¤ã³ã¿ã®èª¿æ´ */
+	add		sp, sp, r1
 	add		sp, sp, #8				/* ã¹ã¿ãã¯ä¸ã®æ
 å ±ãæ¨ã¦ã */
-	beq		ret_int_1				/* ret_int_1ã«åå² */
-
-	/*
-	 *  CPUä¾å¤å¦çããã®ãªã¿ã¼ã³ï¼irq_handler_3ã¨åãå¦çå
-å®¹ï¼
-	 */
 #if __TARGET_ARCH_ARM < 6
 	ldmfd	sp!, {r0}				/* æ»ãå
 ã®cpsrãspsrã«è¨­å® */
 	msr		spsr_cxsf, r0
-	ldmfd	sp!, {r0-r4,r12,lr,pc}^	/* ã³ã³ãã­ã¹ãã®å¾©å¸° */
+	ldmfd	sp!, {r0-r5,r12,lr,pc}^	/* ã³ã³ãã­ã¹ãã®å¾©å¸° */
 									/* ^ä»ããªã®ã§ï¼spsr â cpsr */
 #else /* __TARGET_ARCH_ARM < 6 */
-	ldmfd	sp!, {r0-r4,r12,lr}
+	ldmfd	sp!, {r0-r5,r12,lr}
 	rfefd	sp!
 #endif /* __TARGET_ARCH_ARM < 6 */
+
+#ifdef TOPPERS_SUPPORT_OVRHDR
+ALABEL(exc_handler_4)
+	/*
+	 *  ãªã¼ãã©ã³ã¿ã¤ããåä½éå§ããï¼
+	 */
+	tst		r0, r0					/* p_runtskãNULLã§ãªãå ´å */
+	blne	ovrtimer_start
+	b		exc_handler_3
+#endif /* TOPPERS_SUPPORT_OVRHDR */
 
 /*
@@ -1074,5 +1149,5 @@
 	 *  r3ï¼excpt_nest_countã®å¤
 	 *  r4ï¼CPUä¾å¤ãã³ãã©çªå·
-	 *  r12ï¼CPUä¾å¤ã®æ
+	 *  r5ï¼CPUä¾å¤ã®æ
 å ±ãè¨æ¶ãã¦ããé åã®å
 é ­çªå°
@@ -1093,6 +1168,6 @@
 	ldr		r2, =istkpt				/* éã¿ã¹ã¯ã³ã³ãã­ã¹ãç¨ã®ã¹ã¿ãã¯ã« */
 	ldr		sp, [r2]
-	push	{r3}					/* åæãåã®ã¹ã¿ãã¯ãã¤ã³ã¿ãä¿å­ */
-
+	push	{r0,r3}					/* åæãåã®ã¹ã¿ãã¯ãã¤ã³ã¿ãä¿å­ */
+									/* r0ã¯ã¹ãã¼ã¹ç¢ºä¿ã®ãã */
 ALABEL(nk_exc_handler_2)
 	/*
@@ -1109,5 +1184,5 @@
 	ldr		r2, =exc_table			/* CPUä¾å¤ãã³ãã©ãã¼ãã«ã®èª­è¾¼ã¿ */
 	ldr		r3, [r2,r4,lsl #2]		/* CPUä¾å¤ãã³ãã©ã®çªå° â r3 */
-	mov		r0, r12					/* CPUä¾å¤ã®æ
+	mov		r0, r5					/* CPUä¾å¤ã®æ
 å ±ãè¨æ¶ãã¦ããé åã® */
 									/*		å
@@ -1123,44 +1198,14 @@
 	ldr		r3, [r2]
 	subs	r3, r3, #1
-	str		r3, [r2]
+	str		r3, [r2]				/* æ»ãå
+ãéã¿ã¹ã¯ã³ã³ãã­ã¹ããªã */
+	bne		exc_handler_3			/*				exc_handler_3ã«åå² */
 
 	/*
 	 *  ã¿ã¹ã¯ç¨ã®ã¹ã¿ãã¯ã«æ»ãï¼
 	 */
-	popeq	{r1}					/* æ»ãå
-ãã¿ã¹ã¯ã³ã³ãã­ã¹ããªã */
-	moveq	sp, r1					/*		 ã¿ã¹ã¯ç¨ã®ã¹ã¿ãã¯ã«æ»ã */
-	add		sp, sp, #8				/* ã¹ã¿ãã¯ä¸ã®æ
-å ±ãæ¨ã¦ã */
-
-	/*
-	 *  CPUä¾å¤å¦çããã®ãªã¿ã¼ã³ï¼irq_handler_3ã¨åãå¦çå
-å®¹ï¼
-	 */
-#if __TARGET_ARCH_ARM < 6
-	ldmfd	sp!, {r0}				/* æ»ãå
-ã®cpsrãspsrã«è¨­å® */
-	msr		spsr_cxsf, r0
-	ldmfd	sp!, {r0-r4,r12,lr,pc}^	/* ã³ã³ãã­ã¹ãã®å¾©å¸° */
-									/* ^ä»ããªã®ã§ï¼spsr â cpsr */
-#else /* __TARGET_ARCH_ARM < 6 */
-	ldmfd	sp!, {r0-r4,r12,lr}
-	rfefd	sp!
-#endif /* __TARGET_ARCH_ARM < 6 */
-
-/*
- *  å¾®å°æéå¾
-ã¡
- */
-	ATEXT
-	AALIGN(2)
-	AGLOBAL(_sil_dly_nse)
-ALABEL(_sil_dly_nse)
-	subs	r0, r0, #SIL_DLY_TIM1
-	bxls	lr
-ALABEL(_sil_dly_nse1)
-	subs	r0, r0, #SIL_DLY_TIM2
-	bhi		_sil_dly_nse1
-	bx		lr
+	pop		{r0,r3}
+	mov		sp, r3
+	b		exc_handler_3
 
 /*
@@ -1186,2 +1231,27 @@
 
 #endif /* __thumb__ */
+
+/*
+ *  å¾®å°æéå¾
+ã¡
+ *
+ *  ã­ã£ãã·ã¥ã©ã¤ã³ã®ã©ã®å ´æã«ãããã®ãã£ã¦å®è¡æéãå¤ããããï¼å¤§
+ *  ããã®åä½ã§ã¢ã©ã¤ã³ãã¦ããï¼
+ */
+	ATEXT
+	AALIGN(8)
+	AGLOBAL(sil_dly_nse)
+ALABEL(sil_dly_nse)
+	mov		r1, #0
+	mcr		p15, 0, r1, c7, c5, 6		/* åå²äºæ¸¬å
+¨ä½ã®ç¡å¹å */
+	asm_inst_sync_barrier r3
+	subs	r0, r0, #SIL_DLY_TIM1
+	bxls	lr
+ALABEL(sil_dly_nse1)
+	mcr		p15, 0, r1, c7, c5, 6		/* åå²äºæ¸¬å
+¨ä½ã®ç¡å¹å */
+	asm_inst_sync_barrier r3
+	subs	r0, r0, #SIL_DLY_TIM2
+	bhi		sil_dly_nse1
+	bx		lr
