2007-12-11 Joel Sherrill <joel.sherrill@OARcorp.com>

* thumb_isr.c: Style.
This commit is contained in:
Joel Sherrill
2007-12-11 23:03:29 +00:00
parent 1c62f16987
commit c922ec6c65
2 changed files with 99 additions and 89 deletions

View File

@@ -1,3 +1,7 @@
2007-12-11 Joel Sherrill <joel.sherrill@OARcorp.com>
* thumb_isr.c: Style.
2007-11-26 Ray Xu <rayx.cn@gmail.com> 2007-11-26 Ray Xu <rayx.cn@gmail.com>
* thumb_isr.c: Remove extra debug information, Change function * thumb_isr.c: Remove extra debug information, Change function

View File

@@ -1,5 +1,5 @@
/* /*
* The thumb mode do not support multi-level ISR, only disable and enable * Thumb mode does not support multi-level ISR, only disable and enable.
* *
* The license and distribution terms for this file may be * The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at * found in the file LICENSE in this distribution or at
@@ -32,7 +32,6 @@ void _CPU_ISR_Set_level_Thumb(int new_level ) __attribute__ ((naked));
* Set the CPSR bit 6,7 to 0 enables FIQ and IRQ * Set the CPSR bit 6,7 to 0 enables FIQ and IRQ
*/ */
#define str(x) #x #define str(x) #x
#define xstr(x) str(x) #define xstr(x) str(x)
#define L(x) #x "_" xstr(__LINE__) #define L(x) #x "_" xstr(__LINE__)
@@ -64,40 +63,45 @@ void _CPU_ISR_Set_level_Thumb(int new_level ) __attribute__ ((naked));
*/ */
uint32_t _CPU_ISR_Disable_Thumb(void ) uint32_t _CPU_ISR_Disable_Thumb(void )
{ {
int reg=0; int reg=0;
TO_ARM_MODE(disable); TO_ARM_MODE(disable);
asm volatile ( \ asm volatile(
".code 32 \n" \ ".code 32 \n"
"STMDB sp!, {r1} \n" \ "STMDB sp!, {r1} \n"
"MRS r0, CPSR \n" \ "MRS r0, CPSR \n"
"DISABLE_ARM: \n" \ "DISABLE_ARM: \n"
"ORR r1, r0, #0xc0 \n" \ "ORR r1, r0, #0xc0 \n"
"MSR CPSR, r1 \n" \ "MSR CPSR, r1 \n"
"pop {r1} \n" \ "pop {r1} \n"
"BX LR \n" \ "BX LR \n"
".code 16 \n" ); ".code 16 \n"
} );
}
/* /*
* Enable interrupts to the previous level (returned by _CPU_ISR_Disable_Thumb). * Enable interrupts to the previous level (returned by
* _CPU_ISR_Disable_Thumb).
* This indicates the end of an RTEMS critical section. The parameter * This indicates the end of an RTEMS critical section. The parameter
* _level is not modified. I do not think _level is useful in this * _level is not modified. I do not think _level is useful in this
*/ */
void _CPU_ISR_Enable_Thumb(int _level ) void _CPU_ISR_Enable_Thumb(int _level )
{ {
int reg=0; int reg=0;
TO_ARM_MODE(enable); TO_ARM_MODE(enable);
asm volatile ( \ asm volatile(
".code 32 \n" \ ".code 32 \n"
"ENABLE_ARM: \n" \ "ENABLE_ARM: \n"
"MSR CPSR, %0 \n" \ "MSR CPSR, %0 \n"
/* Return back to thumb.*/ \ /* Return back to thumb.*/
"BX R14 \n" \ "BX R14 \n"
".code 16 \n" \ ".code 16 \n"
: : "r"(_level)); : : "r"(_level)
} );
}
/* /*
* This temporarily restores the interrupt to _level before immediately * This temporarily restores the interrupt to _level before immediately
@@ -106,22 +110,24 @@ void _CPU_ISR_Enable_Thumb(int _level )
* modified. * modified.
*/ */
void _CPU_ISR_Flash_Thumb(int _level ) void _CPU_ISR_Flash_Thumb(int _level )
{ {
int reg=0; int reg=0;
TO_ARM_MODE(flash); TO_ARM_MODE(flash);
asm volatile ( \ asm volatile(
".code 32 \n" \ ".code 32 \n"
"FLASH_ARM: \n" \ "FLASH_ARM: \n"
"MRS %0, CPSR \n" \ "MRS %0, CPSR \n"
"BIC %0, %0, #0xC0 \n" \ "BIC %0, %0, #0xC0 \n"
/* enable the irq*/ \ /* enable the irq*/
"MSR CPSR_c, %0 \n" \ "MSR CPSR_c, %0 \n"
"ORR %0, %0, #0xc0 \n" \ "ORR %0, %0, #0xc0 \n"
"MSR CPSR_c, %0 \n" \ "MSR CPSR_c, %0 \n"
"BX R14 \n" \ "BX R14 \n"
".code 16 \n" \ ".code 16 \n"
:"=&r"(reg) : "r" (_level)); :"=&r"(reg) : "r" (_level)
} );
}
/* /*
* Map interrupt level in task mode onto the hardware that the CPU * Map interrupt level in task mode onto the hardware that the CPU
@@ -137,10 +143,10 @@ void _CPU_ISR_Flash_Thumb(int _level )
* ARM/Thumb dont distinguishd the interrupt levels * ARM/Thumb dont distinguishd the interrupt levels
*/ */
void _CPU_ISR_Set_level_Thumb(int new_level ) void _CPU_ISR_Set_level_Thumb(int new_level)
{ {
int reg = 0; /* to avoid warning */ \ int reg = 0; /* to avoid warning */
TO_ARM_MODE(SetISR); \ TO_ARM_MODE(SetISR);
asm volatile (\ asm volatile (\
".code 32 \n" \ ".code 32 \n" \
"SET_LEVEL_ARM: \n" \ "SET_LEVEL_ARM: \n" \