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-2025 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 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 33 34 /* Variables */ 35 extern int __io_putchar(int ch) __attribute__((weak)); 36 extern int __io_getchar(void) __attribute__((weak)); 37 38 39 char *__env[1] = { 0 }; 40 char **environ = __env; 41 42 43 /* Functions */ 44 void initialise_monitor_handles() 45 { 46 } 47 48 int _getpid(void) 49 { 50 return 1; 51 } 52 53 int _kill(int pid, int sig) 54 { 55 (void)pid; 56 (void)sig; 57 errno = EINVAL; 58 return -1; 59 } 60 61 void _exit (int status) 62 { 63 _kill(status, -1); 64 while (1) {} /* Make sure we hang here */ 65 } 66 67 __attribute__((weak)) int _read(int file, char *ptr, int len) 68 { 69 (void)file; 70 int DataIdx; 71 72 for (DataIdx = 0; DataIdx < len; DataIdx++) 73 { 74 *ptr++ = __io_getchar(); 75 } 76 77 return len; 78 } 79 80 __attribute__((weak)) int _write(int file, char *ptr, int len) 81 { 82 (void)file; 83 int DataIdx; 84 85 for (DataIdx = 0; DataIdx < len; DataIdx++) 86 { 87 __io_putchar(*ptr++); 88 } 89 return len; 90 } 91 92 int _close(int file) 93 { 94 (void)file; 95 return -1; 96 } 97 98 99 int _fstat(int file, struct stat *st) 100 { 101 (void)file; 102 st->st_mode = S_IFCHR; 103 return 0; 104 } 105 106 int _isatty(int file) 107 { 108 (void)file; 109 return 1; 110 } 111 112 int _lseek(int file, int ptr, int dir) 113 { 114 (void)file; 115 (void)ptr; 116 (void)dir; 117 return 0; 118 } 119 120 int _open(char *path, int flags, ...) 121 { 122 (void)path; 123 (void)flags; 124 /* Pretend like we always fail */ 125 return -1; 126 } 127 128 int _wait(int *status) 129 { 130 (void)status; 131 errno = ECHILD; 132 return -1; 133 } 134 135 int _unlink(char *name) 136 { 137 (void)name; 138 errno = ENOENT; 139 return -1; 140 } 141 142 int _times(struct tms *buf) 143 { 144 (void)buf; 145 return -1; 146 } 147 148 int _stat(char *file, struct stat *st) 149 { 150 (void)file; 151 st->st_mode = S_IFCHR; 152 return 0; 153 } 154 155 int _link(char *old, char *new) 156 { 157 (void)old; 158 (void)new; 159 errno = EMLINK; 160 return -1; 161 } 162 163 int _fork(void) 164 { 165 errno = EAGAIN; 166 return -1; 167 } 168 169 int _execve(char *name, char **argv, char **env) 170 { 171 (void)name; 172 (void)argv; 173 (void)env; 174 errno = ENOMEM; 175 return -1; 176 }
