summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
authorLinus Nielsen Feltzing <linus@haxx.se>2004-03-02 11:32:59 +0000
committerLinus Nielsen Feltzing <linus@haxx.se>2004-03-02 11:32:59 +0000
commit111a972b65f5fcc2ef98a5164d0367e7e50f4b09 (patch)
tree84cdb473f8c439575ac99d90f94d636e7f25e731 /firmware
parentaa5b23d6162a5ac6cbfc1d871ed9360ffa946c56 (diff)
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
Diffstat (limited to 'firmware')
-rw-r--r--firmware/drivers/button.c5
-rw-r--r--firmware/drivers/power.c2
-rw-r--r--firmware/drivers/serial.c2
-rw-r--r--firmware/export/system.h15
-rw-r--r--firmware/kernel.c6
-rw-r--r--firmware/mp3_playback.c2
-rw-r--r--firmware/system.c12
7 files changed, 23 insertions, 21 deletions
diff --git a/firmware/drivers/button.c b/firmware/drivers/button.c
index 66c7e978fb..cbb6d58f7b 100644
--- a/firmware/drivers/button.c
+++ b/firmware/drivers/button.c
@@ -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);
diff --git a/firmware/drivers/power.c b/firmware/drivers/power.c
index 563ff3e25c..621f53e11e 100644
--- a/firmware/drivers/power.c
+++ b/firmware/drivers/power.c
@@ -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);
diff --git a/firmware/drivers/serial.c b/firmware/drivers/serial.c
index 5aae38e58c..2badf2e39f 100644
--- a/firmware/drivers/serial.c
+++ b/firmware/drivers/serial.c
@@ -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++)
diff --git a/firmware/export/system.h b/firmware/export/system.h
index 5886145d7b..038d9567e0 100644
--- a/firmware/export/system.h
+++ b/firmware/export/system.h
@@ -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];
diff --git a/firmware/kernel.c b/firmware/kernel.c
index 1c37f004a4..84fb438b49 100644
--- a/firmware/kernel.c
+++ b/firmware/kernel.c
@@ -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++)
diff --git a/firmware/mp3_playback.c b/firmware/mp3_playback.c
index 422a0e6822..a775ba4ff5 100644
--- a/firmware/mp3_playback.c
+++ b/firmware/mp3_playback.c
@@ -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)
{
diff --git a/firmware/system.c b/firmware/system.c
index 3ec56f7c15..cb0cb29778 100644
--- a/firmware/system.c
+++ b/firmware/system.c
@@ -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;