stubs.c 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. /*
  2. ChibiOS - Copyright (C) 2006..2016 Giovanni Di Sirio
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. /*
  14. * **** This file incorporates work covered by the following copyright and ****
  15. * **** permission notice: ****
  16. *
  17. * Copyright (c) 2009 by Michael Fischer. All rights reserved.
  18. *
  19. * Redistribution and use in source and binary forms, with or without
  20. * modification, are permitted provided that the following conditions
  21. * are met:
  22. *
  23. * 1. Redistributions of source code must retain the above copyright
  24. * notice, this list of conditions and the following disclaimer.
  25. * 2. Redistributions in binary form must reproduce the above copyright
  26. * notice, this list of conditions and the following disclaimer in the
  27. * documentation and/or other materials provided with the distribution.
  28. * 3. Neither the name of the author nor the names of its contributors may
  29. * be used to endorse or promote products derived from this software
  30. * without specific prior written permission.
  31. *
  32. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  33. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  34. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  35. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
  36. * THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  37. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  38. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  39. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  40. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  41. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  42. * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  43. * SUCH DAMAGE.
  44. *
  45. ****************************************************************************
  46. * History:
  47. *
  48. * 28.03.09 mifi First Version, based on the original syscall.c from
  49. * newlib version 1.17.0
  50. * 17.08.09 gdisirio Modified the file for use under ChibiOS/RT
  51. * 15.11.09 gdisirio Added read and write handling
  52. ****************************************************************************/
  53. /*
  54. * This file is free software: you can redistribute it and/or modify it
  55. * under the terms of the GNU General Public License as published by the
  56. * Free Software Foundation, either version 3 of the License, or
  57. * (at your option) any later version.
  58. *
  59. * This file is distributed in the hope that it will be useful, but
  60. * WITHOUT ANY WARRANTY; without even the implied warranty of
  61. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  62. * See the GNU General Public License for more details.
  63. *
  64. * You should have received a copy of the GNU General Public License along
  65. * with this program. If not, see <http://www.gnu.org/licenses/>.
  66. *
  67. * Modified for use in AP_HAL by Andrew Tridgell and Siddharth Bharat Purohit
  68. */
  69. #include <sys/unistd.h>
  70. #include <errno.h>
  71. #include <string.h>
  72. #include <sys/stat.h>
  73. #include <sys/types.h>
  74. #include "ch.h"
  75. #if defined(STDOUT_SD) || defined(STDIN_SD)
  76. #include "hal.h"
  77. #endif
  78. uint8_t _before_main = 1;
  79. /***************************************************************************/
  80. __attribute__((used))
  81. int _read(struct _reent *r, int file, char * ptr, int len)
  82. {
  83. (void)r;
  84. (void)file;
  85. (void)ptr;
  86. (void)len;
  87. return -1;
  88. }
  89. /***************************************************************************/
  90. __attribute__((used))
  91. int _lseek(struct _reent *r, int file, int ptr, int dir)
  92. {
  93. (void)r;
  94. (void)file;
  95. (void)ptr;
  96. (void)dir;
  97. return 0;
  98. }
  99. /***************************************************************************/
  100. __attribute__((used))
  101. int _write(struct _reent *r, int file, char * ptr, int len)
  102. {
  103. (void)r;
  104. (void)file;
  105. (void)ptr;
  106. (void)len;
  107. return -1;
  108. }
  109. /***************************************************************************/
  110. __attribute__((used))
  111. int _close(struct _reent *r, int file)
  112. {
  113. (void)r;
  114. (void)file;
  115. return 0;
  116. }
  117. /***************************************************************************/
  118. __attribute__((used))
  119. caddr_t _sbrk(struct _reent *r, int incr)
  120. {
  121. #if CH_CFG_USE_MEMCORE && CH_CFG_USE_HEAP == TRUE
  122. void *p;
  123. chDbgCheck(incr >= 0);
  124. p = chHeapAlloc(NULL, (size_t)incr);
  125. if (p == NULL) {
  126. __errno_r(r) = ENOMEM;
  127. return (caddr_t)-1;
  128. }
  129. return (caddr_t)p;
  130. #else
  131. (void)incr;
  132. __errno_r(r) = ENOMEM;
  133. return (caddr_t)-1;
  134. #endif
  135. }
  136. /***************************************************************************/
  137. __attribute__((used))
  138. int _fstat(struct _reent *r, int file, struct stat * st)
  139. {
  140. (void)r;
  141. (void)file;
  142. (void)st;
  143. return -1;
  144. }
  145. /***************************************************************************/
  146. __attribute__((used))
  147. int _isatty(struct _reent *r, int fd)
  148. {
  149. (void)r;
  150. (void)fd;
  151. return 1;
  152. }
  153. __attribute__((used))
  154. pid_t _getpid(void)
  155. {
  156. return 0;
  157. }
  158. __attribute__((used))
  159. void _exit( int status )
  160. {
  161. (void)status;
  162. while ( 1 );
  163. }
  164. __attribute__((used))
  165. void _fini(void)
  166. {
  167. }
  168. __attribute__((used))
  169. int _kill( int pid, int sig )
  170. {
  171. (void)pid;
  172. (void)sig;
  173. return -1;
  174. }
  175. /*** EOF ***/