#include <stdlib.h>\r
#include <string.h>\r
#include <stdio.h>\r
+#include <stddef.h>\r
#include "Std_Types.h"\r
#include "Ramlog.h"\r
\r
\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
{\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
return -1;\r
}\r
\r
-int fork() {\r
+pid_t fork() {\r
errno=EAGAIN;\r
return -1;\r
}\r
/* 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
}\r
\r
\r
-int getpid() {\r
+pid_t getpid() {\r
return 1;\r
}\r
\r
}\r
\r
\r
+#if defined(__GNUC__)\r
void __init( void )\r
{\r
-\r
}\r
+#endif\r
+\r
#if defined(CFG_ARM)\r
void _exit( int status ) {\r
#ifdef USE_TTY_CODE_COMPOSER\r