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. * <h2><center>&copy; Copyright (c) 2020 STMicroelectronics.
  14. * All rights reserved.</center></h2>
  15. *
  16. * This software component is licensed by ST under BSD 3-Clause license,
  17. * the "License"; You may not use this file except in compliance with the
  18. * License. You may obtain a copy of the License at:
  19. * opensource.org/licenses/BSD-3-Clause
  20. *
  21. ******************************************************************************
  22. */
  23. /* Includes */
  24. #include <sys/stat.h>
  25. #include <stdlib.h>
  26. #include <errno.h>
  27. #include <stdio.h>
  28. #include <signal.h>
  29. #include <time.h>
  30. #include <sys/time.h>
  31. #include <sys/times.h>
  32. /* Variables */
  33. extern int __io_putchar(int ch) __attribute__((weak));
  34. extern int __io_getchar(void) __attribute__((weak));
  35. char *__env[1] = { 0 };
  36. char **environ = __env;
  37. /* Functions */
  38. void initialise_monitor_handles()
  39. {
  40. }
  41. int _getpid(void)
  42. {
  43. return 1;
  44. }
  45. int _kill(int pid, int sig)
  46. {
  47. errno = EINVAL;
  48. return -1;
  49. }
  50. void _exit (int status)
  51. {
  52. _kill(status, -1);
  53. while (1) {} /* Make sure we hang here */
  54. }
  55. __attribute__((weak)) int _read(int file, char *ptr, int len)
  56. {
  57. int DataIdx;
  58. for (DataIdx = 0; DataIdx < len; DataIdx++)
  59. {
  60. *ptr++ = __io_getchar();
  61. }
  62. return len;
  63. }
  64. __attribute__((weak)) int _write(int file, char *ptr, int len)
  65. {
  66. int DataIdx;
  67. for (DataIdx = 0; DataIdx < len; DataIdx++)
  68. {
  69. __io_putchar(*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. }