git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@149 35acf78f-673a-0410-8e92-d51de3d6d3f4

This commit is contained in:
gdisirio 2007-12-18 14:00:01 +00:00
parent 51d9a97993
commit 8afb5785a1
6 changed files with 72 additions and 59 deletions

View File

@ -127,16 +127,16 @@ ODFLAGS = -x --syms
# Thumb interwork enabled only if needed because it kills performance.
ifneq ($(TSRC),)
CPFLAGS += -D THUMB_PRESENT
ifneq ($(ASRC),)
# Both ARM and THUMB case
CPFLAGS += -mthumb-interwork -D THUMB
# Mixed ARM and THUMB case.
CPFLAGS += -mthumb-interwork
LDFLAGS += -mthumb-interwork
ASFLAGS += -mthumb-interwork -D THUMB
else
# Pure THUMB case, THUMB C code cannot be called by ARM asm code directly
CPFLAGS += -D THUMB
# Pure THUMB case, THUMB C code cannot be called by ARM asm code directly.
CPFLAGS += -D THUMB_NO_INTERWORKING
LDFLAGS += -mthumb
ASFLAGS += -mthumb-interwork -D THUMB -D THUMB_NO_INTERWORKING
ASFLAGS += -D THUMB_NO_INTERWORKING
endif
endif

View File

@ -91,7 +91,7 @@ ULIBS =
AOPT =
# THUMB-specific options here
TOPT = -mthumb
TOPT = -mthumb -D THUMB
# Common options here
# NOTE: -ffixed-r7 is only needed if you enabled CH_CURRP_REGISTER_CACHE in
@ -127,16 +127,16 @@ ODFLAGS = -x --syms
# Thumb interwork enabled only if needed because it kills performance.
ifneq ($(TSRC),)
CPFLAGS += -D THUMB_PRESENT
ifneq ($(ASRC),)
# Both ARM and THUMB case
CPFLAGS += -mthumb-interwork -D THUMB
# Mixed ARM and THUMB case.
CPFLAGS += -mthumb-interwork
LDFLAGS += -mthumb-interwork
ASFLAGS += -mthumb-interwork -D THUMB
else
# Pure THUMB case, THUMB C code cannot be called by ARM asm code directly
CPFLAGS += -D THUMB -D THUMB_NO_INTERWORKING
# Pure THUMB case, THUMB C code cannot be called by ARM asm code directly.
CPFLAGS += -D THUMB_NO_INTERWORKING
LDFLAGS += -mthumb
ASFLAGS += -mthumb-interwork -D THUMB -D THUMB_NO_INTERWORKING
ASFLAGS += -D THUMB_NO_INTERWORKING
endif
endif

View File

@ -130,16 +130,16 @@ ODFLAGS = -x --syms
# Thumb interwork enabled only if needed because it kills performance.
ifneq ($(TSRC),)
CPFLAGS += -D THUMB_PRESENT
ifneq ($(ASRC),)
# Both ARM and THUMB case
CPFLAGS += -mthumb-interwork -D THUMB
# Mixed ARM and THUMB case.
CPFLAGS += -mthumb-interwork
LDFLAGS += -mthumb-interwork
ASFLAGS += -mthumb-interwork -D THUMB
else
# Pure THUMB case, THUMB C code cannot be called by ARM asm code directly
CPFLAGS += -D THUMB
# Pure THUMB case, THUMB C code cannot be called by ARM asm code directly.
CPFLAGS += -D THUMB_NO_INTERWORKING
LDFLAGS += -mthumb
ASFLAGS += -mthumb-interwork -D THUMB -D THUMB_NO_INTERWORKING
ASFLAGS += -D THUMB_NO_INTERWORKING
endif
endif
@ -158,7 +158,7 @@ $(AOBJS) : %.o : %.c
$(TOBJS) : %.o : %.c
@echo
$(CC) -c $(CPFLAGS) $(TOPT) -mthumb -I . $(INCDIR) $< -o $@
$(CC) -c $(CPFLAGS) $(TOPT) -I . $(INCDIR) $< -o $@
$(ASMOBJS) : %.o : %.s
@echo

View File

@ -94,7 +94,7 @@ ULIBS =
AOPT =
# THUMB-specific options here
TOPT = -mthumb
TOPT = -mthumb -D THUMB
# Common options here
# NOTE: -ffixed-r7 is only needed if you enabled CH_CURRP_REGISTER_CACHE in
@ -130,16 +130,16 @@ ODFLAGS = -x --syms
# Thumb interwork enabled only if needed because it kills performance.
ifneq ($(TSRC),)
CPFLAGS += -D THUMB_PRESENT
ifneq ($(ASRC),)
# Both ARM and THUMB case
CPFLAGS += -mthumb-interwork -D THUMB
# Mixed ARM and THUMB case.
CPFLAGS += -mthumb-interwork
LDFLAGS += -mthumb-interwork
ASFLAGS += -mthumb-interwork -D THUMB
else
# Pure THUMB case, THUMB C code cannot be called by ARM asm code directly
CPFLAGS += -D THUMB -D THUMB_NO_INTERWORKING
# Pure THUMB case, THUMB C code cannot be called by ARM asm code directly.
CPFLAGS += -D THUMB_NO_INTERWORKING
LDFLAGS += -mthumb
ASFLAGS += -mthumb-interwork -D THUMB -D THUMB_NO_INTERWORKING
ASFLAGS += -D THUMB_NO_INTERWORKING
endif
endif

View File

@ -33,64 +33,71 @@ void _IdleThread(void *p) {
}
}
#ifdef THUMB
/*
* The following functions are present only if there is in the system any
* code compiled as THUMB that may invoke them.
* NOTE: The undefs are there in case this module is compiled in ARM mode but
* there are THUMB modules in the system.
*/
#ifdef THUMB_PRESENT
#undef chSysLock
void chSysLock(void) {
#ifdef THUMB
asm(".p2align 2,, \n\t" \
"mov r0, pc \n\t" \
"bx r0 \n\t" \
".code 32 \n\t" \
"msr CPSR_c, #0x9F \n\t" \
".code 32 \n\t");
#endif
asm("msr CPSR_c, #0x9F \n\t" \
"bx lr \n\t");
}
#undef chSysUnlock
void chSysUnlock(void) {
#ifdef THUMB
asm(".p2align 2,, \n\t" \
"mov r0, pc \n\t" \
"bx r0 \n\t" \
".code 32 \n\t" \
"msr CPSR_c, #0x1F \n\t" \
".code 32 \n\t");
#endif
asm("msr CPSR_c, #0x1F \n\t" \
"bx lr \n\t");
}
#endif
void chSysSwitchI(Context *oldp, Context *newp) {
#ifdef CH_CURRP_REGISTER_CACHE
#ifdef THUMB
asm(".p2align 2,, \n\t" \
"mov r2, pc \n\t" \
"bx r2 \n\t" \
".code 32 \n\t" \
"stmfd sp!, {r4, r5, r6, r8, r9, r10, r11, lr} \n\t" \
"str sp, [r0, #0] \n\t" \
"ldr sp, [r1, #0] \n\t" \
"ldmfd sp!, {r4, r5, r6, r8, r9, r10, r11, lr} \n\t" \
"bx lr \n\t");
#else /* !THUMB */
".code 32 \n\t");
#endif
#ifdef CH_CURRP_REGISTER_CACHE
asm("stmfd sp!, {r4, r5, r6, r8, r9, r10, r11, lr} \n\t" \
"str sp, [r0, #0] \n\t" \
"ldr sp, [r1, #0] \n\t" \
"ldmfd sp!, {r4, r5, r6, r8, r9, r10, r11, pc} \n\t");
#endif /* !THUMB */
#else /* !CH_CURRP_REGISTER_CACHE */
#ifdef THUMB
asm(".p2align 2,, \n\t" \
"mov r2, pc \n\t" \
"bx r2 \n\t" \
".code 32 \n\t" \
"stmfd sp!, {r4, r5, r6, r7, r8, r9, r10, r11, lr} \n\t" \
"str sp, [r0, #0] \n\t" \
"ldr sp, [r1, #0] \n\t" \
"ldmfd sp!, {r4, r5, r6, r7, r8, r9, r10, r11, lr} \n\t" \
"ldr sp, [r1, #0] \n\t");
#ifdef THUMB_PRESENT
asm("ldmfd sp!, {r4, r5, r6, r8, r9, r10, r11, lr} \n\t" \
"bx lr \n\t");
#else /* !THUMB */
#else /* !THUMB_PRESENT */
asm("ldmfd sp!, {r4, r5, r6, r8, r9, r10, r11, pc} \n\t");
#endif /* !THUMB_PRESENT */
#else /* !CH_CURRP_REGISTER_CACHE */
asm("stmfd sp!, {r4, r5, r6, r7, r8, r9, r10, r11, lr} \n\t" \
"str sp, [r0, #0] \n\t" \
"ldr sp, [r1, #0] \n\t" \
"ldmfd sp!, {r4, r5, r6, r7, r8, r9, r10, r11, pc} \n\t");
#endif /* !THUMB */
"ldr sp, [r1, #0] \n\t");
#ifdef THUMB_PRESENT
asm("ldmfd sp!, {r4, r5, r6, r7, r8, r9, r10, r11, lr} \n\t" \
"bx lr \n\t");
#else /* !THUMB_PRESENT */
asm("ldmfd sp!, {r4, r5, r6, r7, r8, r9, r10, r11, pc} \n\t");
#endif /* !THUMB_PRESENT */
#endif /* !CH_CURRP_REGISTER_CACHE */
}
@ -151,7 +158,7 @@ void IrqCommon(void) {
*/
asm(".set MODE_IRQ, 0x12 \n\t" \
".set MODE_SYS, 0x1F \n\t" \
".set F_BIT, 0x40 \n\t" \
".set F_BIT, 0x40 \n\t" \
".set I_BIT, 0x80 \n\t" \
"ldmfd sp!, {r0-r3, r12, lr} \n\t" \
"msr CPSR_c, #MODE_SYS | I_BIT \n\t" \

View File

@ -50,16 +50,22 @@ AVR-AT90CANx-GCC - Port on AVR AT90CAN128, not complete yet.
various mechanisms and the correct use cases.
- RT Semaphores subsystem removed, the Mutexes implements a better solution
for the same problem.
- Added mutexes test cases to the test suite.
- Modified the test suite in order to have each test case to have the same
alignment enforced on functions. This is done to reduce MAM/Cache alignment
effects on the measurement.
- IRQ entry/exit code is now encapsulated into two new macros, see chcore.h
for details.
- All the asm code previously in chcore2.s is now inline asm code in chcore.c
(ARM port).
(ARM port), chcore2.s removed.
- Moved all the board specific definitions/code into two new files: board.c
and board.h. Moved all the files no more board-dependent under ports/
(ARM port).
- Improved the kernel performance in THUMB mode by better exploiting MAM
locality in some critical functions. The context switch benchmark shows 5%
improved speed.
NOTE: The interworking code generated by GCC (or any other compiler as far
I know) is not MAM-aware.
*** 0.4.5 ***
- Moved the serial IRQ handlers and VIC vectors initialization inside the