Made set_irq_level() an inline function, and optimized it by removing the bit shifts
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@4330 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
aa5b23d616
commit
111a972b65
8 changed files with 25 additions and 22 deletions
3
docs/API
3
docs/API
|
@ -227,7 +227,8 @@ Various
|
|||
int set_irq_level(int level)
|
||||
|
||||
Sets the interrupt level (0 = lowest, 15 = highest) and returns the
|
||||
previous level.
|
||||
previous level. Note that you must shift the argument 4 bits to the left:
|
||||
set_irq_level(level << 4);
|
||||
|
||||
void queue_init(struct event_queue *q)
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include "adc.h"
|
||||
#include "serial.h"
|
||||
#include "power.h"
|
||||
#include "system.h"
|
||||
|
||||
struct event_queue button_queue;
|
||||
|
||||
|
@ -256,10 +257,10 @@ static int button_flip(int button)
|
|||
*/
|
||||
void button_set_flip(bool flip)
|
||||
{
|
||||
if (flip != flipped) /* not the curent setting */
|
||||
if (flip != flipped) /* not the current setting */
|
||||
{
|
||||
/* avoid race condition with the button_tick() */
|
||||
int oldlevel = set_irq_level(15);
|
||||
int oldlevel = set_irq_level(HIGHEST_IRQ_LEVEL);
|
||||
lastbtn = button_flip(lastbtn);
|
||||
flipped = flip;
|
||||
set_irq_level(oldlevel);
|
||||
|
|
|
@ -118,7 +118,7 @@ bool ide_powered(void)
|
|||
|
||||
void power_off(void)
|
||||
{
|
||||
set_irq_level(15);
|
||||
set_irq_level(HIGHEST_IRQ_LEVEL);
|
||||
#ifdef HAVE_POWEROFF_ON_PBDR
|
||||
and_b(~0x10, &PBDRL);
|
||||
or_b(0x10, &PBIORL);
|
||||
|
|
|
@ -172,7 +172,7 @@ static void screen_dump(void)
|
|||
|
||||
serial_enable_tx();
|
||||
|
||||
level = set_irq_level(15);
|
||||
level = set_irq_level(HIGHEST_IRQ_LEVEL);
|
||||
for(y = 0;y < LCD_HEIGHT/8;y++)
|
||||
{
|
||||
for(x = 0;x < LCD_WIDTH;x++)
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
|
||||
extern void system_reboot (void);
|
||||
extern void system_init(void);
|
||||
extern int set_irq_level(int level);
|
||||
|
||||
#define FREQ CPU_FREQ
|
||||
#define BAUDRATE 9600
|
||||
|
@ -73,6 +72,20 @@ extern int set_irq_level(int level);
|
|||
|
||||
#ifndef SIMULATOR
|
||||
|
||||
/****************************************************************************
|
||||
* Interrupt level setting
|
||||
* The level is left shifted 4 bits
|
||||
****************************************************************************/
|
||||
#define HIGHEST_IRQ_LEVEL (15<<4)
|
||||
static inline int set_irq_level(int level)
|
||||
{
|
||||
int i;
|
||||
/* Read the old level and set the new one */
|
||||
asm volatile ("stc sr, %0" : "=r" (i));
|
||||
asm volatile ("ldc %0, sr" : : "r" (level));
|
||||
return i;
|
||||
}
|
||||
|
||||
static inline short SWAB16(short value)
|
||||
/*
|
||||
result[15..8] = value[ 7..0];
|
||||
|
|
|
@ -118,7 +118,7 @@ void queue_post(struct event_queue *q, int id, void *data)
|
|||
int wr;
|
||||
int oldlevel;
|
||||
|
||||
oldlevel = set_irq_level(15);
|
||||
oldlevel = set_irq_level(HIGHEST_IRQ_LEVEL);
|
||||
wr = (q->write++) & QUEUE_LENGTH_MASK;
|
||||
|
||||
q->events[wr].id = id;
|
||||
|
@ -201,7 +201,7 @@ void IMIA0(void)
|
|||
int tick_add_task(void (*f)(void))
|
||||
{
|
||||
int i;
|
||||
int oldlevel = set_irq_level(15);
|
||||
int oldlevel = set_irq_level(HIGHEST_IRQ_LEVEL);
|
||||
|
||||
/* Add a task if there is room */
|
||||
for(i = 0;i < MAX_NUM_TICK_TASKS;i++)
|
||||
|
@ -221,7 +221,7 @@ int tick_add_task(void (*f)(void))
|
|||
int tick_remove_task(void (*f)(void))
|
||||
{
|
||||
int i;
|
||||
int oldlevel = set_irq_level(15);
|
||||
int oldlevel = set_irq_level(HIGHEST_IRQ_LEVEL);
|
||||
|
||||
/* Remove a task if it is there */
|
||||
for(i = 0;i < MAX_NUM_TICK_TASKS;i++)
|
||||
|
|
|
@ -338,7 +338,7 @@ static void postpone_dma_tick(void)
|
|||
#ifdef HAVE_MAS3587F
|
||||
void demand_irq_enable(bool on)
|
||||
{
|
||||
int oldlevel = set_irq_level(15);
|
||||
int oldlevel = set_irq_level(HIGHEST_IRQ_LEVEL);
|
||||
|
||||
if(on)
|
||||
{
|
||||
|
|
|
@ -318,18 +318,6 @@ void system_reboot (void)
|
|||
"r"(*(int*)0),"r"(4));
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Interrupt level setting
|
||||
****************************************************************************/
|
||||
int set_irq_level(int level)
|
||||
{
|
||||
int i;
|
||||
/* Read the old level and set the new one */
|
||||
asm volatile ("stc sr, %0" : "=r" (i));
|
||||
asm volatile ("ldc %0, sr" : : "r" (level << 4));
|
||||
return (i >> 4) & 0x0f;
|
||||
}
|
||||
|
||||
void UIE (unsigned int pc) /* Unexpected Interrupt or Exception */
|
||||
{
|
||||
bool state = true;
|
||||
|
|
Loading…
Reference in a new issue