diff options
-rw-r--r-- | chip/host/uart.c | 27 | ||||
-rw-r--r-- | core/host/task.c | 9 |
2 files changed, 25 insertions, 11 deletions
diff --git a/chip/host/uart.c b/chip/host/uart.c index ce8310f171..b39232833b 100644 --- a/chip/host/uart.c +++ b/chip/host/uart.c @@ -13,6 +13,7 @@ #include "common.h" #include "queue.h" #include "task.h" +#include "test_util.h" #include "uart.h" #include "util.h" @@ -66,16 +67,20 @@ const char *test_get_captured_console(void) return (const char *)capture_buf; } +static void uart_interrupt(void) +{ + uart_process_input(); + uart_process_output(); +} + static void trigger_interrupt(void) { - /* - * TODO(crosbug.com/p/23804): Check global interrupt status when we - * have interrupt support. - */ - if (!int_disabled) { - uart_process_input(); - uart_process_output(); - } + if (int_disabled) + return; + if (task_start_called()) + task_trigger_test_interrupt(uart_interrupt); + else + uart_interrupt(); } int uart_init_done(void) @@ -177,9 +182,9 @@ void *uart_monitor_stdin(void *d) } tcsetattr(0, TCSANOW, &org_settings); /* - * TODO(crosbug.com/p/23804): Trigger emulated interrupt when - * we have interrupt support. Also, we will need a condition - * variable to indicate the character has been read. + * Trigger emulated interrupt to process input. Keyboard + * input while interrupt handler runs is queued by the + * system. */ trigger_interrupt(); } diff --git a/core/host/task.c b/core/host/task.c index 23d16bd802..bb4b073997 100644 --- a/core/host/task.c +++ b/core/host/task.c @@ -13,6 +13,7 @@ #include "atomic.h" #include "common.h" +#include "console.h" #include "task.h" #include "task_id.h" #include "test_util.h" @@ -35,6 +36,7 @@ static struct emu_task_t tasks[TASK_ID_COUNT]; static pthread_cond_t scheduler_cond; static pthread_mutex_t run_lock; static task_id_t running_task_id; +static int task_started; static sem_t interrupt_sem; static pthread_mutex_t interrupt_lock; @@ -280,11 +282,18 @@ static int fast_forward(void) } } +int task_start_called(void) +{ + return task_started; +} + void task_scheduler(void) { int i; timestamp_t now; + task_started = 1; + while (1) { now = get_time(); i = TASK_ID_COUNT - 1; |