]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_M7_SAME70_Xplained_AtmelStudio/src/ASF/sam/utils/syscalls/gcc/syscalls.c
Rename DummyTCB_t to StaticTCB_t.
[freertos] / FreeRTOS / Demo / CORTEX_M7_SAME70_Xplained_AtmelStudio / src / ASF / sam / utils / syscalls / gcc / syscalls.c
1 /**\r
2  * \file\r
3  *\r
4  * \brief Syscalls for SAM (GCC).\r
5  *\r
6  * Copyright (c) 2011-2015 Atmel Corporation. All rights reserved.\r
7  *\r
8  * \asf_license_start\r
9  *\r
10  * \page License\r
11  *\r
12  * Redistribution and use in source and binary forms, with or without\r
13  * modification, are permitted provided that the following conditions are met:\r
14  *\r
15  * 1. Redistributions of source code must retain the above copyright notice,\r
16  *    this list of conditions and the following disclaimer.\r
17  *\r
18  * 2. Redistributions in binary form must reproduce the above copyright notice,\r
19  *    this list of conditions and the following disclaimer in the documentation\r
20  *    and/or other materials provided with the distribution.\r
21  *\r
22  * 3. The name of Atmel may not be used to endorse or promote products derived\r
23  *    from this software without specific prior written permission.\r
24  *\r
25  * 4. This software may only be redistributed and used in connection with an\r
26  *    Atmel microcontroller product.\r
27  *\r
28  * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED\r
29  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\r
30  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE\r
31  * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR\r
32  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\r
33  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\r
34  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\r
35  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\r
36  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN\r
37  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
38  * POSSIBILITY OF SUCH DAMAGE.\r
39  *\r
40  * \asf_license_stop\r
41  *\r
42  */\r
43 /*\r
44  * Support and FAQ: visit <a href="http://www.atmel.com/design-support/">Atmel Support</a>\r
45  */\r
46 \r
47 #include <stdio.h>\r
48 #include <stdarg.h>\r
49 #include <sys/types.h>\r
50 #include <sys/stat.h>\r
51 \r
52 /// @cond 0\r
53 /**INDENT-OFF**/\r
54 #ifdef __cplusplus\r
55 extern "C" {\r
56 #endif\r
57 /**INDENT-ON**/\r
58 /// @endcond\r
59 \r
60 #undef errno\r
61 extern int errno;\r
62 extern int _end;\r
63 extern int __ram_end__;\r
64 \r
65 extern caddr_t _sbrk(int incr);\r
66 extern int link(char *old, char *new);\r
67 extern int _close(int file);\r
68 extern int _fstat(int file, struct stat *st);\r
69 extern int _isatty(int file);\r
70 extern int _lseek(int file, int ptr, int dir);\r
71 extern void _exit(int status);\r
72 extern void _kill(int pid, int sig);\r
73 extern int _getpid(void);\r
74 \r
75 extern caddr_t _sbrk(int incr)\r
76 {\r
77         static unsigned char *heap = NULL;\r
78         unsigned char *prev_heap;\r
79         int ramend = (int)&__ram_end__;\r
80 \r
81         if (heap == NULL) {\r
82                 heap = (unsigned char *)&_end;\r
83         }\r
84         prev_heap = heap;\r
85 \r
86         if (((int)prev_heap + incr) > ramend) {\r
87                 return (caddr_t) -1;    \r
88         }\r
89 \r
90         heap += incr;\r
91 \r
92         return (caddr_t) prev_heap;\r
93 }\r
94 \r
95 extern int link(char *old, char *new)\r
96 {\r
97         ( void ) old;\r
98         ( void ) new;\r
99         return -1;\r
100 }\r
101 \r
102 extern int _close(int file)\r
103 {\r
104         ( void ) file;\r
105         return -1;\r
106 }\r
107 \r
108 extern int _fstat(int file, struct stat *st)\r
109 {\r
110         st->st_mode = S_IFCHR;\r
111         ( void ) file;\r
112 \r
113         return 0;\r
114 }\r
115 \r
116 extern int _isatty(int file)\r
117 {\r
118         ( void ) file;\r
119         return 1;\r
120 }\r
121 \r
122 extern int _lseek(int file, int ptr, int dir)\r
123 {\r
124         ( void ) file;\r
125         ( void ) ptr;\r
126         ( void ) dir;\r
127         return 0;\r
128 }\r
129 \r
130 extern void _exit(int status)\r
131 {\r
132         printf("Exiting with status %d.\n", status);\r
133 \r
134         for (;;);\r
135 }\r
136 \r
137 extern void _kill(int pid, int sig)\r
138 {\r
139         ( void ) pid;\r
140         ( void ) sig;\r
141         return;\r
142 }\r
143 \r
144 extern int _getpid(void)\r
145 {\r
146         return -1;\r
147 }\r
148 \r
149 /// @cond 0\r
150 /**INDENT-OFF**/\r
151 #ifdef __cplusplus\r
152 }\r
153 #endif\r
154 /**INDENT-ON**/\r
155 /// @endcond\r