mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2026-01-02 05:05:09 +00:00
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>
87 lines
1.1 KiB
C
87 lines
1.1 KiB
C
/* 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;
|
|
}
|