]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - sim/m32c/mem.c
Update years in copyright notice for the GDB files.
[thirdparty/binutils-gdb.git] / sim / m32c / mem.c
index a277787e3c65c2d1a77e65569bcf12fd36c91391..10c58b7396798d505cc3c15f149d12d9bae11852 100644 (file)
@@ -1,6 +1,6 @@
 /* mem.c --- memory for M32C simulator.
 
-Copyright (C) 2005, 2007, 2008 Free Software Foundation, Inc.
+Copyright (C) 2005-2013 Free Software Foundation, Inc.
 Contributed by Red Hat, Inc.
 
 This file is part of the GNU simulators.
@@ -19,6 +19,7 @@ You should have received a copy of the GNU General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
+#include "config.h"
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -26,8 +27,12 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 #include <sys/time.h>
 #include <sys/types.h>
 #include <unistd.h>
+#ifdef HAVE_SYS_SELECT_H
 #include <sys/select.h>
+#endif
+#ifdef HAVE_TERMIOS_H
 #include <termios.h>
+#endif
 
 #include "mem.h"
 #include "cpu.h"
@@ -48,8 +53,13 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 static unsigned char **pt[L1_LEN];
 
+#ifdef HAVE_TERMIOS_H
 int m32c_console_ifd = 0;
+#endif
 int m32c_console_ofd = 1;
+#ifdef HAVE_TERMIOS_H
+int m32c_use_raw_console = 0;
+#endif
 
 #ifdef TIMER_A
 Timer_A timer_a;
@@ -355,13 +365,13 @@ mem_put_si (int address, unsigned long value)
 }
 
 void
-mem_put_blk (int address, void *bufptr, int nbytes)
+mem_put_blk (int address, const void *bufptr, int nbytes)
 {
   S ("<=");
   if (enable_counting)
     mem_counters[1][1] += nbytes;
   while (nbytes--)
-    mem_put_byte (address++, *(unsigned char *) bufptr++);
+    mem_put_byte (address++, *(const unsigned char *) bufptr++);
   E ();
 }
 
@@ -373,8 +383,9 @@ mem_get_pc ()
   return *m;
 }
 
+#ifdef HAVE_TERMIOS_H
 static int console_raw = 0;
-static struct termios attr, oattr;
+static struct termios oattr;
 
 static int
 stdin_ready ()
@@ -394,9 +405,11 @@ stdin_ready ()
 void
 m32c_sim_restore_console ()
 {
-  tcsetattr (m32c_console_ifd, TCSANOW, &oattr);
+  if (console_raw)
+    tcsetattr (m32c_console_ifd, TCSANOW, &oattr);
   console_raw = 0;
 }
+#endif
 
 static unsigned char
 mem_get_byte (int address)
@@ -406,12 +419,13 @@ mem_get_byte (int address)
   m = mem_ptr (address);
   switch (address)
     {
+#ifdef HAVE_TERMIOS_H
     case 0x2ed:                /* m32c uart1c1 */
     case 0x3ad:                /* m16c uart1c1 */
 
-#if 0
-      if (!console_raw)
+      if (!console_raw && m32c_use_raw_console)
        {
+         struct termios attr;
          tcgetattr (m32c_console_ifd, &attr);
          tcgetattr (m32c_console_ifd, &oattr);
          /* We want each key to be sent as the user presses them.  */
@@ -420,7 +434,6 @@ mem_get_byte (int address)
          console_raw = 1;
          atexit (m32c_sim_restore_console);
        }
-#endif
 
       if (stdin_ready ())
        return 0x02;            /* tx empty and rx full */
@@ -446,6 +459,7 @@ mem_get_byte (int address)
          }
        return c;
       }
+#endif
 
 #ifdef TIMER_A
     case 0x346:                /* TA0low */
@@ -456,6 +470,9 @@ mem_get_byte (int address)
       return timer_a.count;
 #endif
 
+    default:
+      /* In case both cases above are not included.  */
+      ;
     }
 
   S ("=>");