You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

syscalls.c 2.6KB

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