#include <errno.h>
#include <string.h>
+#include <asm/system.h>
+
#include <calypso/uart.h>
#include <console.h>
-#include <comm/msgb.h>
+#include <osmocom/core/msgb.h>
#include <comm/sercomm.h>
#include <comm/sercomm_cons.h>
int sercomm_puts(const char *s)
{
- const int len = strlen(s) + 1;
+ unsigned long flags;
+ const int len = strlen(s);
unsigned int bytes_left = len;
if (!sercomm_initialized()) {
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;
{
unsigned int i;
for (i = 0; i < write_num; i++) {
- /* flush buffer at end of line */
- if (*s == '\n')
+ /* flush buffer at end of line, but skip
+ * flushing if we have a backlog in order to
+ * increase efficiency of msgb filling */
+ if (*s == '\n' &&
+ sercomm_tx_queue_depth(SC_DLCI_CONSOLE) < 4)
flush = 1;
*data++ = *s++;
}
}
}
+ local_irq_restore(flags);
+
return len - 1;
}