diff options
author | Harald Welte <laforge@gnumonks.org> | 2010-02-28 17:37:47 +0100 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2010-03-01 23:48:45 +0100 |
commit | f3685191f642bc772e9b7f17cfe66fb62d0a44ae (patch) | |
tree | 4c07faa6c1463dcb858d05b51f55ea22ed32baec /src/target/firmware/comm/sercomm_cons.c | |
parent | 80409074d92fa351ae88880a371cf54e16c10b5f (diff) |
SERCOMM: make sure to disable IRQ/FIQ to avoid race conditions
Diffstat (limited to 'src/target/firmware/comm/sercomm_cons.c')
-rw-r--r-- | src/target/firmware/comm/sercomm_cons.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/target/firmware/comm/sercomm_cons.c b/src/target/firmware/comm/sercomm_cons.c index 5b481bcb..6d31a9f7 100644 --- a/src/target/firmware/comm/sercomm_cons.c +++ b/src/target/firmware/comm/sercomm_cons.c @@ -24,6 +24,8 @@ #include <errno.h> #include <string.h> +#include <asm/system.h> + #include <calypso/uart.h> #include <console.h> @@ -50,6 +52,7 @@ static void raw_puts(const char *s) int sercomm_puts(const char *s) { + unsigned long flags; const int len = strlen(s) + 1; unsigned int bytes_left = len; @@ -59,6 +62,12 @@ int sercomm_puts(const char *s) return len - 1; } + /* This function is called from any context: Supervisor, IRQ, FIQ, ... + * as such, we need to ensure re-entrant calls are either supported or + * avoided. */ + local_irq_save(flags); + local_fiq_disable(); + while (bytes_left > 0) { unsigned int write_num, space_left, flush; uint8_t *data; @@ -110,6 +119,8 @@ int sercomm_puts(const char *s) } } + local_irq_restore(flags); + return len - 1; } |