]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_M4_ATSAM4L_Atmel_Studio/src/asf/sam/utils/syscalls/gcc/syscalls.c
Add SAM4L demo.
[freertos] / FreeRTOS / Demo / CORTEX_M4_ATSAM4L_Atmel_Studio / 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-2012 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 #include <stdio.h>\r
45 #include <stdarg.h>\r
46 #include <sys/types.h>\r
47 #include <sys/stat.h>\r
48 \r
49 /// @cond 0\r
50 /**INDENT-OFF**/\r
51 #ifdef __cplusplus\r
52 extern "C" {\r
53 #endif\r
54 /**INDENT-ON**/\r
55 /// @endcond\r
56 \r
57 #undef errno\r
58 extern int errno;\r
59 extern int _end;\r
60 \r
61 extern caddr_t _sbrk(int incr);\r
62 extern int link(char *old, char *new);\r
63 extern int _close(int file);\r
64 extern int _fstat(int file, struct stat *st);\r
65 extern int _isatty(int file);\r
66 extern int _lseek(int file, int ptr, int dir);\r
67 extern void _exit(int status);\r
68 extern void _kill(int pid, int sig);\r
69 extern int _getpid(void);\r
70 \r
71 extern caddr_t _sbrk(int incr)\r
72 {\r
73         static unsigned char *heap = NULL;\r
74         unsigned char *prev_heap;\r
75 \r
76         if (heap == NULL) {\r
77                 heap = (unsigned char *)&_end;\r
78         }\r
79         prev_heap = heap;\r
80 \r
81         heap += incr;\r
82 \r
83         return (caddr_t) prev_heap;\r
84 }\r
85 \r
86 extern int link(char *old, char *new)\r
87 {\r
88         return -1;\r
89 }\r
90 \r
91 extern int _close(int file)\r
92 {\r
93         return -1;\r
94 }\r
95 \r
96 extern int _fstat(int file, struct stat *st)\r
97 {\r
98         st->st_mode = S_IFCHR;\r
99 \r
100         return 0;\r
101 }\r
102 \r
103 extern int _isatty(int file)\r
104 {\r
105         return 1;\r
106 }\r
107 \r
108 extern int _lseek(int file, int ptr, int dir)\r
109 {\r
110         return 0;\r
111 }\r
112 \r
113 extern void _exit(int status)\r
114 {\r
115         printf("Exiting with status %d.\n", status);\r
116 \r
117         for (;;);\r
118 }\r
119 \r
120 extern void _kill(int pid, int sig)\r
121 {\r
122         return;\r
123 }\r
124 \r
125 extern int _getpid(void)\r
126 {\r
127         return -1;\r
128 }\r
129 \r
130 /// @cond 0\r
131 /**INDENT-OFF**/\r
132 #ifdef __cplusplus\r
133 }\r
134 #endif\r
135 /**INDENT-ON**/\r
136 /// @endcond\r