kosmos/source/firmware/arch/stm32f4xx/syscalls.c

92 lines
1.2 KiB
C
Raw Normal View History

2016-07-28 19:02:54 +00:00
/*
* syscalls.c
*
* Created on: 03.12.2009
* Author: Martin Thomas, 3BSD license
*/
#include <reent.h>
#include <errno.h>
2016-07-29 06:17:59 +00:00
#include <stdlib.h>
2016-07-28 19:02:54 +00:00
#include <sys/types.h>
#include <sys/stat.h>
#include <string.h>
#include <stdio.h>
2016-07-29 06:17:59 +00:00
#include "stm32f4xx.h"
2016-07-28 19:02:54 +00:00
#undef errno
extern int errno;
int _kill(int pid, int sig)
{
errno = EINVAL;
return -1;
}
void _exit(int status)
{
2016-07-29 06:17:59 +00:00
while(1);
2016-07-28 19:02:54 +00:00
}
int _getpid(void)
{
return 1;
}
extern char _end; /* Defined by the linker */
static char *heap_end;
char* get_heap_end(void)
{
return (char*) heap_end;
}
char* get_stack_top(void)
{
return (char*) __get_MSP();
}
caddr_t _sbrk(int incr)
{
char *prev_heap_end;
if (heap_end == 0) {
heap_end = &_end;
}
prev_heap_end = heap_end;
if (heap_end + incr > get_stack_top()) {
abort();
}
heap_end += incr;
return (caddr_t) prev_heap_end;
}
int _close(int file)
{
return -1;
}
int _fstat(int file, struct stat *st)
{
st->st_mode = S_IFCHR;
return 0;
}
int _isatty(int file)
{
return 1;
}
int _lseek(int file, int ptr, int dir) {
return 0;
}
int _read(int file, char *ptr, int len)
{
return 0;
}
int _write(int file, char *ptr, int len) {
return len;
}