]> rtime.felk.cvut.cz Git - arc.git/blobdiff - common/newlib_port.c
Fixed warning in Code Composer terminal code.
[arc.git] / common / newlib_port.c
index e0cd45c5900dda88571a72da6d01ab8199e85eed..0a9ca794057f8ee7c5921bf5824e8bed11f3862e 100644 (file)
@@ -107,9 +107,11 @@ volatile char g_TConn __attribute__ ((section (".winidea_port")));
 \r
 \r
 static unsigned char parmbuf[8];\r
-#define BUFSIZ 512\r
-#define CC_BUFFER_SIZE ((BUFSIZ)+32)\r
+#define CC_BUFSIZ 512\r
+#define CC_BUFFER_SIZE ((CC_BUFSIZ)+32)\r
 volatile unsigned int _CIOBUF_[CC_BUFFER_SIZE] __attribute__ ((section (".cio")));\r
+static unsigned char CIOTMPBUF[CC_BUFSIZ];\r
+static uint16 cio_tmp_buf_index = 0;\r
 \r
 /***************************************************************************/\r
 /*                                                                         */\r
@@ -179,15 +181,29 @@ int HOSTwrite(int dev_fd, const char *buf, unsigned count)
 {\r
    int result;\r
 \r
-   if (count > BUFSIZ) count = BUFSIZ;\r
+   // WARNING. Can only handle count == 1!\r
+   if (count != 1) _exit(1);\r
+\r
+   if (count > CC_BUFSIZ) count = CC_BUFSIZ;\r
+\r
+   if (cio_tmp_buf_index < CC_BUFSIZ) {\r
+          CIOTMPBUF[cio_tmp_buf_index++] = *buf;\r
+\r
+          if (*buf != 0xA) { // Only flush if newline\r
+                  return 0;\r
+          }\r
+   }\r
+\r
 \r
    LOADSHORT(parmbuf,dev_fd,0);\r
-   LOADSHORT(parmbuf,count,2);\r
-   writemsg(_DTWRITE,parmbuf,(char *)buf,count);\r
+   LOADSHORT(parmbuf,cio_tmp_buf_index,2);\r
+   writemsg(_DTWRITE,parmbuf,(char *)CIOTMPBUF,cio_tmp_buf_index);\r
    readmsg(parmbuf,NULL);\r
 \r
    result = UNLOADSHORT(parmbuf,0);\r
 \r
+   cio_tmp_buf_index = 0;\r
+\r
    return result;\r
 }\r
 \r
@@ -452,18 +468,18 @@ int arc_putchar(int fd, int c) {
 /* If we use malloc and it runs out of memory it calls sbrk()\r
  */\r
 \r
-#if defined(PPC)\r
+#if defined(CFG_PPC)\r
 \r
 /* linker symbols */\r
-extern char _heap_start;\r
-extern char _heap_end;         // same as _end?\r
+extern char _heap_start[];  // incomplete array to ensure not placed in small-data\r
+extern char _heap_end[];\r
 \r
 void * sbrk( ptrdiff_t incr )\r
 {\r
     char *prevEnd;\r
-    static char *nextAvailMemPtr = (char *)&_heap_start;\r
+    static char *nextAvailMemPtr = _heap_start;\r
 \r
-    if( nextAvailMemPtr + incr >  (char*)&_heap_end) {\r
+    if( nextAvailMemPtr + incr >  _heap_end) {\r
                write( 2, "Heap overflow!\n", 15 );\r
                abort();\r
        }\r