From f9c780ccc146fd883374f8f89c14c9ce5968ee51 Mon Sep 17 00:00:00 2001 From: Linus Nielsen Feltzing Date: Wed, 25 Feb 2004 13:00:36 +0000 Subject: The cli()/sti() functions are not safe. We should have removed them long ago. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@4314 a1c6a512-1295-4272-9138-f99709370657 --- firmware/drivers/button.c | 5 +++-- firmware/drivers/lcd.c | 22 +++++++++++++--------- 2 files changed, 16 insertions(+), 11 deletions(-) (limited to 'firmware/drivers') diff --git a/firmware/drivers/button.c b/firmware/drivers/button.c index 06c24e0e45..66c7e978fb 100644 --- a/firmware/drivers/button.c +++ b/firmware/drivers/button.c @@ -258,10 +258,11 @@ void button_set_flip(bool flip) { if (flip != flipped) /* not the curent setting */ { - cli(); /* avoid race condition with the button_tick() */ + /* avoid race condition with the button_tick() */ + int oldlevel = set_irq_level(15); lastbtn = button_flip(lastbtn); flipped = flip; - sti(); + set_irq_level(oldlevel); } } diff --git a/firmware/drivers/lcd.c b/firmware/drivers/lcd.c index 5c2c514f10..950f8b5057 100644 --- a/firmware/drivers/lcd.c +++ b/firmware/drivers/lcd.c @@ -188,14 +188,16 @@ void lcd_write_data(unsigned char* p_bytes, int count) { do { - unsigned byte; - unsigned sda1; /* precalculated SC=low,SD=1 */ - unsigned clk0sda0; /* precalculated SC and SD low */ + unsigned int byte; + unsigned int sda1; /* precalculated SC=low,SD=1 */ + unsigned int clk0sda0; /* precalculated SC and SD low */ + unsigned int oldlevel; byte = *p_bytes++ << 24; /* fetch to MSB position */ - cli(); /* make port modifications atomic, in case an IRQ uses PBDRL */ - /* (currently not the case, so this could be optimized away) */ + /* make port modifications atomic, in case an IRQ uses PBDRL */ + /* (currently not the case, so this could be optimized away) */ + oldlevel = set_irq_level(15); /* precalculate the values for later bit toggling, init data write */ asm ( @@ -285,7 +287,7 @@ void lcd_write_data(unsigned char* p_bytes, int count) : "r0" ); - sti(); + set_irq_level(oldlevel); } while (--count); /* tail loop is faster */ } @@ -298,13 +300,15 @@ void lcd_write_data(unsigned char* p_bytes, int count) { unsigned byte; unsigned sda1; /* precalculated SC=low,SD=1 */ + unsigned int oldlevel; /* take inverse data, so I can use the NEGC instruction below, it is the only carry add/sub which does not destroy a source register */ byte = ~(*p_bytes++ << 24); /* fetch to MSB position */ - cli(); /* make port modifications atomic, in case an IRQ uses PBDRL */ - /* (currently not the case, so this could be optimized away) */ + /* make port modifications atomic, in case an IRQ uses PBDRL */ + /* (currently not the case, so this could be optimized away) */ + oldlevel = set_irq_level(15); /* precalculate the values for later bit toggling, init data write */ asm ( @@ -386,7 +390,7 @@ void lcd_write_data(unsigned char* p_bytes, int count) "r0" ); - sti(); /* end of atomic port modifications */ + set_irq_level(oldlevel); } while (--count); /* tail loop is faster */ } -- cgit v1.2.3