diff options
author | Vic Yang <victoryang@chromium.org> | 2013-05-02 00:37:07 +0800 |
---|---|---|
committer | ChromeBot <chrome-bot@google.com> | 2013-05-07 09:09:50 -0700 |
commit | 0a45fa17086d4556b7cb4ea0a9f53894197bc897 (patch) | |
tree | f2363f2a2320000404125bb36225e1420929d45d /chip/host/uart.c | |
parent | b02c7b461740c457c6904a5d9d9f445afaa849cb (diff) | |
download | chrome-ec-0a45fa17086d4556b7cb4ea0a9f53894197bc897.tar.gz |
Pthread-based emulator for unit testingstabilize-4100.38.B
This is the first version of pthread-based RTOS emulator. With this, we
will be able to test high-level modules entirely on the host machine.
BUG=chrome-os-partner:19325
TEST='make runtests' and see tests passing.
BRANCH=None
Change-Id: I1f5fcd76aa84bdb46c7d35c5e60ae5d92fd3a319
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/49954
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'chip/host/uart.c')
-rw-r--r-- | chip/host/uart.c | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/chip/host/uart.c b/chip/host/uart.c new file mode 100644 index 0000000000..cbae79974b --- /dev/null +++ b/chip/host/uart.c @@ -0,0 +1,86 @@ +/* Copyright (c) 2013 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* UART driver for emulator */ + +#include <stdio.h> + +#include "board.h" +#include "config.h" +#include "task.h" +#include "uart.h" + +static int stopped; +static int int_disabled; +static int init_done; + +static void trigger_interrupt(void) +{ + if (!int_disabled) + uart_process(); +} + +int uart_init_done(void) +{ + return init_done; +} + +void uart_tx_start(void) +{ + stopped = 0; + trigger_interrupt(); +} + +void uart_tx_stop(void) +{ + stopped = 1; +} + +int uart_tx_stopped(void) +{ + return stopped; +} + +void uart_tx_flush(void) +{ + /* Nothing */ +} + +int uart_tx_ready(void) +{ + return 1; +} + +int uart_rx_available(void) +{ + return 0; +} + +void uart_write_char(char c) +{ + printf("%c", c); + fflush(stdout); +} + +int uart_read_char(void) +{ + /* Should never be called for now */ + return 0; +} + +void uart_disable_interrupt(void) +{ + int_disabled = 1; +} + +void uart_enable_interrupt(void) +{ + int_disabled = 0; +} + +void uart_init(void) +{ + init_done = 1; +} |