OS Interface provides Custom component that can be used to implement its functionality using code templates below.
Exposed OS Interface API is toolchain specific therefore make sure to select correct code template:
Arm Compiler
typedef void *mutex;
return 0;
}
}
}
}
GCC Newlib
Code template used to retarget locking routines
#include <stdio.h>
struct __lock {
};
struct __lock __lock___sinit_recursive_mutex = {0};
struct __lock __lock___sfp_recursive_mutex = {0};
struct __lock __lock___atexit_recursive_mutex = {0};
struct __lock __lock___at_quick_exit_mutex = {0};
struct __lock __lock___malloc_recursive_mutex = {0};
struct __lock __lock___env_recursive_mutex = {0};
struct __lock __lock___tz_mutex = {0};
struct __lock __lock___dd_hash_mutex = {0};
struct __lock __lock___arc4random_mutex = {0};
}
}
}
}
}
}
return -1;
}
return -1;
}
}
}
Code template used to retarget system calls
Note
- All system call functions are provided in this template although there may not be necessary to reimplement them all. Functions that are not necessary may be removed or kept depending on the linker settings.
- Reimplementing functions like
_open
, _close
,_write
, etc. breaks compatibility with the CMSIS-Compiler:IO component. Make sure to remove them from custom implementation when application does not require to reimplement them.
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
int _open (const char *path, int oflag, ...) {
return (-1);
}
int _close (int fildes) {
return (-1);
}
ssize_t _write (int fildes, const void *buf, size_t nbyte) {
return (-1);
}
ssize_t _read (int fildes, void *buf, size_t nbyte) {
return (-1);
}
off_t _lseek (int fildes, off_t offset, int whence) {
return (-1);
}
int _isatty (int fildes) {
return (0);
}
int _fstat (int fildes, struct stat *buf) {
return (-1);
}
int _link(const char *path1, const char *path2) {
return (-1);
}
int _unlink (const char *path) {
return (-1);
}
int _execve(const char *path, char *const argv[], char *const envp[]) {
return -1;
}
pid_t fork (void) {
return -1;
}
void _exit (int status) {
}
int _kill (pid_t pid, int sig) {
return -1;
}
pid_t _getpid (void) {
return 0;
}
pid_t _wait (int *stat_loc) {
return -1;
}
void *_sbrk (ptrdiff_t incr) {
return -1;
}