syscalls.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. /**
  2. ******************************************************************************
  3. * @file syscalls.c
  4. * @author Auto-generated by STM32CubeMX
  5. * @brief Minimal System calls file
  6. *
  7. * For more information about which c-functions
  8. * need which of these lowlevel functions
  9. * please consult the Newlib libc-manual
  10. ******************************************************************************
  11. * @attention
  12. *
  13. * Copyright (c) 2020-2024 STMicroelectronics.
  14. * All rights reserved.
  15. *
  16. * This software is licensed under terms that can be found in the LICENSE file
  17. * in the root directory of this software component.
  18. * If no LICENSE file comes with this software, it is provided AS-IS.
  19. *
  20. ******************************************************************************
  21. */
  22. /* Includes */
  23. #include <errno.h>
  24. #include <signal.h>
  25. #include <stdio.h>
  26. #include <stdlib.h>
  27. #include <sys/stat.h>
  28. #include <sys/time.h>
  29. #include <sys/times.h>
  30. #include <time.h>
  31. /* Variables */
  32. extern int __io_putchar(int ch) __attribute__((weak));
  33. extern int __io_getchar(void) __attribute__((weak));
  34. char *__env[1] = {0};
  35. char **environ = __env;
  36. /* Functions */
  37. void initialise_monitor_handles()
  38. {
  39. }
  40. int _getpid(void)
  41. {
  42. return 1;
  43. }
  44. int _kill(int pid, int sig)
  45. {
  46. (void)pid;
  47. (void)sig;
  48. errno = EINVAL;
  49. return -1;
  50. }
  51. void _exit(int status)
  52. {
  53. _kill(status, -1);
  54. while (1)
  55. {
  56. } /* Make sure we hang here */
  57. }
  58. __attribute__((weak)) int _read(int file, char *ptr, int len)
  59. {
  60. (void)file;
  61. int DataIdx;
  62. for (DataIdx = 0; DataIdx < len; DataIdx++)
  63. {
  64. *ptr++ = __io_getchar();
  65. }
  66. return len;
  67. }
  68. __attribute__((weak)) int _write(int file, char *ptr, int len)
  69. {
  70. (void)file;
  71. int DataIdx;
  72. for (DataIdx = 0; DataIdx < len; DataIdx++)
  73. {
  74. __io_putchar(*ptr++);
  75. }
  76. return len;
  77. }
  78. int _close(int file)
  79. {
  80. (void)file;
  81. return -1;
  82. }
  83. int _fstat(int file, struct stat *st)
  84. {
  85. (void)file;
  86. st->st_mode = S_IFCHR;
  87. return 0;
  88. }
  89. int _isatty(int file)
  90. {
  91. (void)file;
  92. return 1;
  93. }
  94. int _lseek(int file, int ptr, int dir)
  95. {
  96. (void)file;
  97. (void)ptr;
  98. (void)dir;
  99. return 0;
  100. }
  101. int _open(char *path, int flags, ...)
  102. {
  103. (void)path;
  104. (void)flags;
  105. /* Pretend like we always fail */
  106. return -1;
  107. }
  108. int _wait(int *status)
  109. {
  110. (void)status;
  111. errno = ECHILD;
  112. return -1;
  113. }
  114. int _unlink(char *name)
  115. {
  116. (void)name;
  117. errno = ENOENT;
  118. return -1;
  119. }
  120. int _times(struct tms *buf)
  121. {
  122. (void)buf;
  123. return -1;
  124. }
  125. int _stat(char *file, struct stat *st)
  126. {
  127. (void)file;
  128. st->st_mode = S_IFCHR;
  129. return 0;
  130. }
  131. int _link(char *old, char *new)
  132. {
  133. (void)old;
  134. (void)new;
  135. errno = EMLINK;
  136. return -1;
  137. }
  138. int _fork(void)
  139. {
  140. errno = EAGAIN;
  141. return -1;
  142. }
  143. int _execve(char *name, char **argv, char **env)
  144. {
  145. (void)name;
  146. (void)argv;
  147. (void)env;
  148. errno = ENOMEM;
  149. return -1;
  150. }