syscalls.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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) 2022 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. errno = EINVAL;
  47. return -1;
  48. }
  49. void _exit (int status)
  50. {
  51. _kill(status, -1);
  52. while (1) {} /* Make sure we hang here */
  53. }
  54. __attribute__((weak)) int _read(int file, char *ptr, int len)
  55. {
  56. int DataIdx;
  57. for (DataIdx = 0; DataIdx < len; DataIdx++)
  58. {
  59. *ptr++ = __io_getchar();
  60. }
  61. return len;
  62. }
  63. __attribute__((weak)) int _write(int file, char *ptr, int len)
  64. {
  65. int DataIdx;
  66. for (DataIdx = 0; DataIdx < len; DataIdx++)
  67. {
  68. // __io_putchar(*ptr++);
  69. ITM_SendChar(*ptr++);
  70. }
  71. return len;
  72. }
  73. int _close(int file)
  74. {
  75. return -1;
  76. }
  77. int _fstat(int file, struct stat *st)
  78. {
  79. st->st_mode = S_IFCHR;
  80. return 0;
  81. }
  82. int _isatty(int file)
  83. {
  84. return 1;
  85. }
  86. int _lseek(int file, int ptr, int dir)
  87. {
  88. return 0;
  89. }
  90. int _open(char *path, int flags, ...)
  91. {
  92. /* Pretend like we always fail */
  93. return -1;
  94. }
  95. int _wait(int *status)
  96. {
  97. errno = ECHILD;
  98. return -1;
  99. }
  100. int _unlink(char *name)
  101. {
  102. errno = ENOENT;
  103. return -1;
  104. }
  105. int _times(struct tms *buf)
  106. {
  107. return -1;
  108. }
  109. int _stat(char *file, struct stat *st)
  110. {
  111. st->st_mode = S_IFCHR;
  112. return 0;
  113. }
  114. int _link(char *old, char *new)
  115. {
  116. errno = EMLINK;
  117. return -1;
  118. }
  119. int _fork(void)
  120. {
  121. errno = EAGAIN;
  122. return -1;
  123. }
  124. int _execve(char *name, char **argv, char **env)
  125. {
  126. errno = ENOMEM;
  127. return -1;
  128. }