]> git.sur5r.net Git - freertos/blob - Demo/MCF5235_GCC/system/newlib.c
Update version numbers to V4.8.0
[freertos] / Demo / MCF5235_GCC / system / newlib.c
1 /*\r
2     FreeRTOS MCF5235 port - Copyright (C) 2006 Christian Walter.\r
3 \r
4     This file is part of the FreeRTOS distribution.\r
5 \r
6     FreeRTOS is free software; you can redistribute it and/or modify\r
7     it under the terms of the GNU General Public License as published by\r
8     the Free Software Foundation; either version 2 of the License, or\r
9     (at your option) any later version.\r
10 \r
11     FreeRTOS is distributed in the hope that it will be useful,\r
12     but WITHOUT ANY WARRANTY; without even the implied warranty of\r
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
14     GNU General Public License for more details.\r
15 \r
16     You should have received a copy of the GNU General Public License\r
17     along with FreeRTOS; if not, write to the Free Software\r
18     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
19 \r
20     A special exception to the GPL can be applied should you wish to distribute\r
21     a combined work that includes FreeRTOS, without being obliged to provide\r
22     the source code for any proprietary components.  See the licensing section\r
23     of http://www.FreeRTOS.org for full details of how and when the exception\r
24     can be applied.\r
25 \r
26         ***************************************************************************\r
27         ***************************************************************************\r
28         *                                                                                                                                                 *\r
29         * SAVE TIME AND MONEY!  Why not get us to quote to get FreeRTOS.org               *\r
30         * running on your hardware - or even write all or part of your application*\r
31         * for you?  See http://www.OpenRTOS.com for details.                                      *\r
32         *                                                                                                                                                 *\r
33         ***************************************************************************\r
34         ***************************************************************************\r
35 \r
36         Please ensure to read the configuration and relevant port sections of the\r
37         online documentation.\r
38 \r
39         http://www.FreeRTOS.org - Documentation, latest information, license and \r
40         contact details.\r
41 \r
42         http://www.SafeRTOS.com - A version that is certified for use in safety \r
43         critical systems.\r
44 \r
45         http://www.OpenRTOS.com - Commercial support, development, porting, \r
46         licensing and training services.\r
47 */\r
48 \r
49 /* ------------------------ System includes ------------------------------- */\r
50 #include <sys/types.h>\r
51 #include <sys/stat.h>\r
52 #include <unistd.h>\r
53 #include <errno.h>\r
54 \r
55 /* ------------------------ FreeRTOS includes ----------------------------- */\r
56 #include <FreeRTOS.h>\r
57 #include <serial.h>\r
58 \r
59 /* ------------------------ Prototypes ------------------------------------ */\r
60 void vSerialPutStringNOISR( xComPortHandle pxPort,\r
61                             const signed portCHAR * const pcString,\r
62                             unsigned portSHORT usStringLength );\r
63 \r
64 /* ------------------------ Start implementation -------------------------- */\r
65 void\r
66 _exit( int status )\r
67 {\r
68     asm volatile    ( "halt" );\r
69 \r
70     for( ;; );\r
71 }\r
72 \r
73 pid_t\r
74 getpid( void )\r
75 {\r
76     return 0;\r
77 }\r
78 \r
79 int\r
80 kill( pid_t pid, int sig )\r
81 {\r
82     _exit( 0 );\r
83 }\r
84 \r
85 int\r
86 close( int fd )\r
87 {\r
88     return 0;\r
89 }\r
90 \r
91 int\r
92 fstat( int fd, struct stat *buf )\r
93 {\r
94     buf->st_mode = S_IFCHR;\r
95     buf->st_blksize = 0;\r
96     return 0;\r
97 }\r
98 \r
99 ssize_t\r
100 write( int fd, const void *buf, size_t nbytes )\r
101 {\r
102     ssize_t res = nbytes;\r
103     extern xComPortHandle xSTDComPort;\r
104     switch ( fd )\r
105     {\r
106         case STDERR_FILENO:\r
107             vSerialPutStringNOISR( xSTDComPort,\r
108                                    ( const signed portCHAR * const )buf,\r
109                                    ( unsigned portSHORT )nbytes );\r
110             break;\r
111         case STDOUT_FILENO:\r
112             vSerialPutString( xSTDComPort,\r
113                               ( const signed portCHAR * const)buf,\r
114                               ( unsigned portSHORT )nbytes );\r
115             break;\r
116         default:\r
117             errno = EIO;\r
118             res = -1;\r
119             break;\r
120     }\r
121     return res;\r
122 }\r
123 \r
124 int\r
125 read( int fd, void *buf, size_t nbytes )\r
126 {\r
127     switch ( fd )\r
128     {\r
129         default:\r
130             errno = EIO;\r
131             return -1;\r
132     }\r
133 }\r
134 \r
135 int\r
136 isatty( int fd )\r
137 {\r
138     return 0;\r
139 }\r
140 \r
141 off_t\r
142 lseek( int fd, off_t offset, int whence )\r
143 {\r
144     errno = EIO;\r
145     return ( off_t ) - 1;\r
146 }\r
147 \r
148 extern char     _end[];\r
149 char           *heap_ptr;\r
150 \r
151 void           *\r
152 sbrk( ptrdiff_t nbytes )\r
153 {\r
154     char           *base;\r
155 \r
156     if( !heap_ptr )\r
157         heap_ptr = ( char * )&_end;\r
158     base = heap_ptr;\r
159     heap_ptr += nbytes;\r
160 \r
161     return base;\r
162 }\r