Repository navigation
Expand file tree
/
Copy pathsyscalls.c
More file actions
113 lines (89 loc) · 1.84 KB
/
Copy pathsyscalls.c
File metadata and controls
113 lines (89 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/**************************************************************************//*****
* @file stdio.c
* @brief Implementation of newlib syscall
********************************************************************************/
#include <stdio.h>
#include <stdarg.h>
#include <sys/types.h>
#include <sys/stat.h>
#undef errno
extern int errno;
extern int _end;
/*This function is used for handle heap option*/
__attribute__ ((used))
caddr_t _sbrk ( int incr )
{
static unsigned char *heap = NULL;
unsigned char *prev_heap;
if (heap == NULL) {
heap = (unsigned char *)&_end;
}
prev_heap = heap;
heap += incr;
return (caddr_t) prev_heap;
}
__attribute__ ((used))
int link(char *old, char *new)
{
return -1;
}
__attribute__ ((used))
int _close(int file)
{
return -1;
}
__attribute__ ((used))
int _fstat(int file, struct stat *st)
{
st->st_mode = S_IFCHR;
return 0;
}
__attribute__ ((used))
int _isatty(int file)
{
return 1;
}
__attribute__ ((used))
int _lseek(int file, int ptr, int dir)
{
return 0;
}
/*Low layer read(input) function*/
__attribute__ ((used))
int _read(int file, char *ptr, int len)
{
#if 0
//user code example
int i;
(void)file;
for(i = 0; i < len; i++)
{
// UART_GetChar is user's basic input function
*ptr++ = UART_GetChar();
}
#endif
return len;
}
/*Low layer write(output) function*/
__attribute__ ((used))
int _write(int file, char *ptr, int len)
{
#if 0
//user code example
int i;
(void)file;
for(i = 0; i < len; i++)
{
// UART_PutChar is user's basic output function
UART_PutChar(*ptr++);
}
#endif
return len;
}
__attribute__ ((used))
void abort(void)
{
/* Abort called */
while(1);
}
/* --------------------------------- End Of File ------------------------------ */