syscalls.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. /**
  2. ******************************************************************************
  3. * @file syscalls.c
  4. * @author Auto-generated by STM32CubeIDE
  5. * @brief STM32CubeIDE 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 <sys/stat.h>
  24. #include <stdlib.h>
  25. #include <errno.h>
  26. #include <stdio.h>
  27. #include <signal.h>
  28. #include <time.h>
  29. #include <sys/time.h>
  30. #include <sys/times.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) {} /* Make sure we hang here */
  55. }
  56. __attribute__((weak)) int _read(int file, char *ptr, int len)
  57. {
  58. (void)file;
  59. int DataIdx;
  60. for (DataIdx = 0; DataIdx < len; DataIdx++)
  61. {
  62. *ptr++ = __io_getchar();
  63. }
  64. return len;
  65. }
  66. __attribute__((weak)) int _write(int file, char *ptr, int len)
  67. {
  68. (void)file;
  69. int DataIdx;
  70. for (DataIdx = 0; DataIdx < len; DataIdx++)
  71. {
  72. __io_putchar(*ptr++);
  73. // ITM_SendChar(*ptr++);
  74. }
  75. return len;
  76. }
  77. int _close(int file)
  78. {
  79. (void)file;
  80. return -1;
  81. }
  82. int _fstat(int file, struct stat *st)
  83. {
  84. (void)file;
  85. st->st_mode = S_IFCHR;
  86. return 0;
  87. }
  88. int _isatty(int file)
  89. {
  90. (void)file;
  91. return 1;
  92. }
  93. int _lseek(int file, int ptr, int dir)
  94. {
  95. (void)file;
  96. (void)ptr;
  97. (void)dir;
  98. return 0;
  99. }
  100. int _open(char *path, int flags, ...)
  101. {
  102. (void)path;
  103. (void)flags;
  104. /* Pretend like we always fail */
  105. return -1;
  106. }
  107. int _wait(int *status)
  108. {
  109. (void)status;
  110. errno = ECHILD;
  111. return -1;
  112. }
  113. int _unlink(char *name)
  114. {
  115. (void)name;
  116. errno = ENOENT;
  117. return -1;
  118. }
  119. int _times(struct tms *buf)
  120. {
  121. (void)buf;
  122. return -1;
  123. }
  124. int _stat(char *file, struct stat *st)
  125. {
  126. (void)file;
  127. st->st_mode = S_IFCHR;
  128. return 0;
  129. }
  130. int _link(char *old, char *new)
  131. {
  132. (void)old;
  133. (void)new;
  134. errno = EMLINK;
  135. return -1;
  136. }
  137. int _fork(void)
  138. {
  139. errno = EAGAIN;
  140. return -1;
  141. }
  142. int _execve(char *name, char **argv, char **env)
  143. {
  144. (void)name;
  145. (void)argv;
  146. (void)env;
  147. errno = ENOMEM;
  148. return -1;
  149. }