#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
#if defined(CFG_ARM_CM3)\r
#include "irq_types.h"\r
-#include "core_cm3.h"\r
+#include "stm32f10x.h"\r
#endif\r
\r
#ifdef USE_TTY_TCF_STREAMS\r
#if defined(MC912DG128A)\r
static volatile unsigned char g_TWBuffer[TWBUFF_LEN];\r
static volatile unsigned char g_TRBuffer[TRBUFF_LEN];\r
-static volatile char g_TConn __attribute__ ((section (".winidea_port")));\r
+volatile char g_TConn __attribute__ ((section (".winidea_port")));\r
\r
#else\r
static volatile unsigned char g_TWBuffer[TWBUFF_LEN] __attribute__ ((aligned (0x100))); // Transmit to WinIDEA terminal\r
static volatile unsigned char g_TRBuffer[TRBUFF_LEN] __attribute__ ((aligned (0x100)));\r
-static volatile char g_TConn __attribute__ ((section (".winidea_port")));\r
+volatile char g_TConn __attribute__ ((section (".winidea_port")));\r
\r
#endif\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
#endif\r
\r
+#ifdef USE_TTY_TMS570_KEIL\r
+#include "GLCD.h"\r
+#endif\r
+\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
return -1;\r
}\r
\r
-int fork() {\r
+pid_t fork() {\r
errno=EAGAIN;\r
return -1;\r
}\r
(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
\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
unsigned char nCnt,nLen;\r
for(nCnt=0; nCnt<nbytes; nCnt++)\r
{\r
- while(TWBUFF_FULL());\r
+ while(TWBUFF_FULL()) ;\r
nLen=TWBUFF_TPTR;\r
g_TWBuffer[nLen]=buf[nCnt];\r
nLen=TWBUFF_INC(nLen);\r
HOSTwrite(fd, _buf, nbytes);\r
#endif\r
\r
+#ifdef USE_TTY_TMS570_KEIL\r
+ for (int i = 0; i < nbytes; i++) {\r
+ GLCD_PrintChar((char *)(_buf + i));\r
+ }\r
+#endif\r
+\r
#if defined(USE_RAMLOG)\r
{\r
char *buf = (char *)_buf;\r
\r
/* If we use malloc and it runs out of memory it calls sbrk()\r
*/\r
-#if 1\r
\r
+#if defined(CFG_PPC)\r
+\r
+/* linker symbols */\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 = _heap_start;\r
+\r
+ if( nextAvailMemPtr + incr > _heap_end) {\r
+ write( 2, "Heap overflow!\n", 15 );\r
+ abort();\r
+ }\r
+ prevEnd = nextAvailMemPtr;\r
+ nextAvailMemPtr += incr;\r
+ return prevEnd;\r
+}\r
+#else\r
extern char _end[];\r
\r
//static char *curbrk = _end;\r
unsigned char *prev_heap_end;\r
\r
/* initialize */\r
- if( heap_end == 0 )\r
+ if( heap_end == 0 ){\r
heap_end = _heap;\r
-\r
- prev_heap_end = heap_end;\r
+ }\r
+ prev_heap_end = heap_end;\r
\r
if( heap_end + incr - _heap > HEAPSIZE ) {\r
/* heap overflow - announce on stderr */\r
\r
return (caddr_t) prev_heap_end;\r
}\r
-#else\r
-void *sbrk(int inc )\r
-{\r
- /* We use our own malloc */\r
- return (void *)(-1);\r
-}\r
#endif\r
\r
int stat( const char *file, struct stat *st ) {\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
__asm(" .global C$$EXIT");\r
__asm("C$$EXIT: nop");\r
#endif\r
- while(1);\r
+ while(1) ;\r
}\r
#endif\r
\r