source:
rtems-tools/tools/4.11/gdb/lm32/gdb-sim-lm32uart.diff
@
47d652c
Last change on this file since 47d652c was 47d652c, checked in by Chris Johns <chrisj@…>, on 05/08/14 at 12:39:07 | |
---|---|
|
|
File size: 2.2 KB |
-
sim/lm32/dv-lm32uart.c
old new 1 1 /* Lattice Mico32 UART model. 2 2 Contributed by Jon Beniston <jon@beniston.com> 3 3 4 4 Copyright (C) 2009-2014 Free Software Foundation, Inc. 5 5 6 6 This file is part of GDB. … … 22 22 #include "hw-main.h" 23 23 #include "sim-assert.h" 24 24 25 #include <stdio.h>26 #include <sys/time.h>27 28 25 struct lm32uart 29 26 { 30 27 unsigned base; /* Base address of this UART. */ … … 38 35 unsigned char lsr; 39 36 unsigned char msr; 40 37 unsigned char div; 38 int saved_count; 39 char saved_byte; 41 40 struct hw_event *event; 42 41 }; 43 42 … … 83 82 static void 84 83 do_uart_tx_event (struct hw *me, void *data) 85 84 { 85 SIM_DESC sd = hw_system (me); 86 86 struct lm32uart *uart = hw_data (me); 87 87 char c; 88 88 … … 115 115 c &= 0x7f; 116 116 break; 117 117 } 118 printf ("%c", c); 118 sim_io_write_stdout (sd, &c, 1); 119 sim_io_flush_stdout (sd); 119 120 } 120 121 121 122 static unsigned … … 200 201 void *dest, 201 202 int space, unsigned_word base, unsigned nr_bytes) 202 203 { 204 SIM_DESC sd = hw_system (me); 203 205 struct lm32uart *uart = hw_data (me); 204 206 int uart_reg; 205 207 int value; 206 208 unsigned char *dest_bytes = dest; 207 fd_set fd;208 struct timeval tv;209 209 210 210 HW_TRACE ((me, "read 0x%08lx length %d", (long) base, (int) nr_bytes)); 211 211 … … 214 214 switch (uart_reg) 215 215 { 216 216 case LM32_UART_RBR: 217 value = getchar (); 217 value = uart->saved_byte; 218 --uart->saved_count;; 218 219 uart->lsr &= ~LM32_UART_LSR_RX_RDY; 219 220 break; 220 221 case LM32_UART_IER: … … 231 232 break; 232 233 case LM32_UART_LSR: 233 234 /* Check to see if any data waiting in stdin. */ 234 FD_ZERO (&fd); 235 FD_SET (fileno (stdin), &fd); 236 tv.tv_sec = 0; 237 tv.tv_usec = 1; 238 if (select (fileno (stdin) + 1, &fd, NULL, NULL, &tv)) 239 uart->lsr |= LM32_UART_LSR_RX_RDY; 235 if (uart->saved_count <= 0) 236 uart->saved_count = sim_io_poll_read (sd, 0/*STDIN*/, 237 &uart->saved_byte, 1); 238 uart->lsr |= uart->saved_count ? LM32_UART_LSR_RX_RDY : 0; 240 239 value = uart->lsr; 241 240 break; 242 241 case LM32_UART_MSR:
Note: See TracBrowser
for help on using the repository browser.