]> rtime.felk.cvut.cz Git - arc.git/blobdiff - common/newlib_port.c
Merge with default.
[arc.git] / common / newlib_port.c
index e039002a2f4b4e9444d99e160d6b9ab4ea875a14..28d7a11c25e1affc31360f79867f486b3d620156 100644 (file)
@@ -198,6 +198,13 @@ int HOSTwrite(int dev_fd, const char *buf, unsigned count)
 \r
 #define FILE_RAMLOG            3\r
 \r
+/* Location MUST match NoICE configuration */\r
+#ifdef USE_TTY_NOICE\r
+static volatile char VUART_TX __attribute__ ((section (".noice_port")));\r
+static volatile char VUART_RX __attribute__ ((section (".noice_port")));\r
+volatile unsigned char START_VUART = 0;\r
+#endif\r
+\r
 /*\r
  * T32 stuff\r
  */\r
@@ -310,6 +317,17 @@ int read( int fd, void *buf, size_t nbytes )
        (void)g_TRBuffer[0];\r
 #endif\r
 \r
+#ifdef USE_TTY_NOICE\r
+       // Not tested at all\r
+    int retval;\r
+    while (VUART_RX != 0)\r
+    {\r
+    }\r
+\r
+    retval = VUART_RX;\r
+    VUART_RX = 0;\r
+#endif\r
+\r
        /* Only support write for now, return 0 read */\r
        return 0;\r
 }\r
@@ -322,6 +340,30 @@ int write(  int fd, const void *_buf, size_t nbytes)
 \r
 \r
        if( fd <= STDERR_FILENO ) {\r
+#ifdef USE_TTY_NOICE\r
+       char *buf1 = (char *)_buf;\r
+       if (START_VUART)\r
+       {\r
+          for (int i = 0; i < nbytes; i++) {\r
+                  char c = buf1[i];\r
+                  if (c == '\n')\r
+                  {\r
+                          while (VUART_TX != 0)\r
+                          {\r
+                          }\r
+\r
+                          VUART_TX = '\r';\r
+                  }\r
+\r
+                  while (VUART_TX != 0)\r
+                  {\r
+                  }\r
+\r
+                  VUART_TX = c;\r
+          }\r
+       }\r
+#endif\r
+\r
 #ifdef USE_TTY_WINIDEA\r
                if (g_TConn)\r
                {\r