From 2c91f58d0f0baf6b75a20b46d20bdeb524aa356f Mon Sep 17 00:00:00 2001 From: gdisirio Date: Tue, 18 Dec 2007 10:46:23 +0000 Subject: [PATCH] git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@146 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- demos/ARM7-LPC214x-GCC/Makefile | 2 +- demos/ARM7-LPC214x-GCC/Makefile.thumb | 2 +- ports/ARM7-LPC214x/GCC/chcore.c | 61 +++++++++++++++++++++++ ports/ARM7-LPC214x/GCC/chcore2.s | 72 --------------------------- readme.txt | 4 +- 5 files changed, 65 insertions(+), 76 deletions(-) delete mode 100644 ports/ARM7-LPC214x/GCC/chcore2.s diff --git a/demos/ARM7-LPC214x-GCC/Makefile b/demos/ARM7-LPC214x-GCC/Makefile index a267ac184..13c32b4dc 100644 --- a/demos/ARM7-LPC214x-GCC/Makefile +++ b/demos/ARM7-LPC214x-GCC/Makefile @@ -79,7 +79,7 @@ ASRC = ../../ports/ARM7-LPC214x/GCC/chcore.c \ TSRC = # List ASM source files here -ASMSRC = ../../ports/ARM7-LPC214x/GCC/crt0.s ../../ports/ARM7-LPC214x/GCC/chcore2.s +ASMSRC = ../../ports/ARM7-LPC214x/GCC/crt0.s # List all user directories here UINCDIR = ../../src/include ../../src/lib ../../ports/ARM7-LPC214x/GCC diff --git a/demos/ARM7-LPC214x-GCC/Makefile.thumb b/demos/ARM7-LPC214x-GCC/Makefile.thumb index 4b14088c8..93188a528 100644 --- a/demos/ARM7-LPC214x-GCC/Makefile.thumb +++ b/demos/ARM7-LPC214x-GCC/Makefile.thumb @@ -79,7 +79,7 @@ TSRC = ../../ports/ARM7-LPC214x/GCC/chcore.c \ board.c buzzer.c mmcsd.c main.c # List ASM source files here -ASMSRC = ../../ports/ARM7-LPC214x/GCC/crt0.s ../../ports/ARM7-LPC214x/GCC/chcore2.s +ASMSRC = ../../ports/ARM7-LPC214x/GCC/crt0.s # List all user directories here UINCDIR = ../../src/include ../../src/lib ../../ports/ARM7-LPC214x/GCC diff --git a/ports/ARM7-LPC214x/GCC/chcore.c b/ports/ARM7-LPC214x/GCC/chcore.c index 51ead6542..c8e2c61f7 100644 --- a/ports/ARM7-LPC214x/GCC/chcore.c +++ b/ports/ARM7-LPC214x/GCC/chcore.c @@ -33,6 +33,67 @@ void _IdleThread(void *p) { } } +#ifdef THUMB +void chSysLock(void) { + + asm(".p2align 2,, \n\t" \ + "mov r0, pc \n\t" \ + "bx r0 \n\t" \ + ".code 32 \n\t" \ + "msr CPSR_c, #0x9F \n\t" \ + "bx lr \n\t"); +} + +void chSysUnlock(void) { + + asm(".p2align 2,, \n\t" \ + "mov r0, pc \n\t" \ + "bx r0 \n\t" \ + ".code 32 \n\t" \ + "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 */ + 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" \ + "bx lr \n\t"); +#else /* !THUMB */ + 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 */ +#endif /* !CH_CURRP_REGISTER_CACHE */ +} + /* * System console message (not implemented). */ diff --git a/ports/ARM7-LPC214x/GCC/chcore2.s b/ports/ARM7-LPC214x/GCC/chcore2.s deleted file mode 100644 index a31422cea..000000000 --- a/ports/ARM7-LPC214x/GCC/chcore2.s +++ /dev/null @@ -1,72 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2006-2007 Giovanni Di Sirio. - - This file is part of ChibiOS/RT. - - ChibiOS/RT is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS/RT is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include - -.set MODE_USR, 0x10 -.set MODE_FIQ, 0x11 -.set MODE_IRQ, 0x12 -.set MODE_SVC, 0x13 -.set MODE_ABT, 0x17 -.set MODE_UND, 0x1B -.set MODE_SYS, 0x1F - -.equ I_BIT, 0x80 -.equ F_BIT, 0x40 - -.text -.code 32 - -#ifdef THUMB -.balign 16 -.globl chSysLock -chSysLock: - msr CPSR_c, #MODE_SYS | I_BIT - bx lr - -.globl chSysUnlock -chSysUnlock: - msr CPSR_c, #MODE_SYS - bx lr -#endif - -.balign 16 -.globl chSysSwitchI -chSysSwitchI: -#ifdef CH_CURRP_REGISTER_CACHE - stmfd sp!, {r4, r5, r6, r8, r9, r10, r11, lr} - str sp, [r0, #0] - ldr sp, [r1, #0] -#ifdef THUMB - ldmfd sp!, {r4, r5, r6, r8, r9, r10, r11, lr} - bx lr -#else - ldmfd sp!, {r4, r5, r6, r8, r9, r10, r11, pc} -#endif -#else - stmfd sp!, {r4, r5, r6, r7, r8, r9, r10, r11, lr} - str sp, [r0, #0] - ldr sp, [r1, #0] -#ifdef THUMB - ldmfd sp!, {r4, r5, r6, r7, r8, r9, r10, r11, lr} - bx lr -#else - ldmfd sp!, {r4, r5, r6, r7, r8, r9, r10, r11, pc} -#endif -#endif /* CH_CURRP_REGISTER_CACHE */ diff --git a/readme.txt b/readme.txt index cf0e4791a..5b9082822 100644 --- a/readme.txt +++ b/readme.txt @@ -55,8 +55,8 @@ AVR-AT90CANx-GCC - Port on AVR AT90CAN128, not complete yet. effects on the measurement. - IRQ entry/exit code is now encapsulated into two new macros, see chcore.h for details. -- Most of the asm code previously in chcore2.s is now inline asm code in - chcore.c (ARM port). +- All the asm code previously in chcore2.s is now inline asm code in chcore.c + (ARM port). - 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).