source: rtems-tools/tools/4.11/gdb/lm32/gdb-7.9-lm32uart.diff @ b6b784c

4.104.115
Last change on this file since b6b784c was bbad85e, checked in by Joel Sherrill <joel.sherrill@…>, on 04/02/15 at 14:52:42

Update gdb-sim-lm32uart.diff to gdb-7.9

  • Property mode set to 100644
File size: 1.9 KB
  • sim/lm32/dv-lm32uart.c

    diff -ur gdb-7.9.orig/sim/lm32/dv-lm32uart.c gdb-7.9/sim/lm32/dv-lm32uart.c
    old new  
    2222#include "hw-main.h"
    2323#include "sim-assert.h"
    2424
    25 #include <stdio.h>
    26 #include <sys/time.h>
    27 
    2825struct lm32uart
    2926{
    3027  unsigned base;                /* Base address of this UART.  */
     
    3835  unsigned char lsr;
    3936  unsigned char msr;
    4037  unsigned char div;
     38  int saved_count;
     39  char saved_byte;
    4140  struct hw_event *event;
    4241};
    4342
     
    8382static void
    8483do_uart_tx_event (struct hw *me, void *data)
    8584{
     85  SIM_DESC sd = hw_system (me);
    8686  struct lm32uart *uart = hw_data (me);
    8787  char c;
    8888
     
    115115      c &= 0x7f;
    116116      break;
    117117    }
    118   printf ("%c", c);
     118  sim_io_write_stdout (sd, &c, 1);
     119  sim_io_flush_stdout (sd);
    119120}
    120121
    121122static unsigned
     
    200201                         void *dest,
    201202                         int space, unsigned_word base, unsigned nr_bytes)
    202203{
     204  SIM_DESC sd = hw_system (me);
    203205  struct lm32uart *uart = hw_data (me);
    204206  int uart_reg;
    205207  int value;
     
    214216  switch (uart_reg)
    215217    {
    216218    case LM32_UART_RBR:
    217       value = getchar ();
     219      value = uart->saved_byte;
     220      --uart->saved_count;
    218221      uart->lsr &= ~LM32_UART_LSR_RX_RDY;
    219222      break;
    220223    case LM32_UART_IER:
     
    231234      break;
    232235    case LM32_UART_LSR:
    233236      /* 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;
     237      if (uart->saved_count <= 0)
     238        uart->saved_count = sim_io_poll_read (sd, 0/*STDIN*/,
     239                                              &uart->saved_byte, 1);
     240      uart->lsr |= uart->saved_count ? LM32_UART_LSR_RX_RDY : 0;
    240241      value = uart->lsr;
    241242      break;
    242243    case LM32_UART_MSR:
Note: See TracBrowser for help on using the repository browser.