1 /*********************************************************************************************************//**
2 * @file syscalls.c
3 * @version $Rev:: 6830 $
4 * @date $Date:: 2023-03-27 #$
5 * @brief Implementation of system call related functions.
6 *************************************************************************************************************
7 * @attention
8 *
9 * Firmware Disclaimer Information
10 *
11 * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the
12 * code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the
13 * proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and
14 * other intellectual property laws.
15 *
16 * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the
17 * code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties
18 * other than HOLTEK and the customer.
19 *
20 * 3. The program technical documentation, including the code, is provided "as is" and for customer reference
21 * only. After delivery by HOLTEK, the customer shall use the program technical documentation, including
22 * the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including
23 * the warranties of merchantability, satisfactory quality and fitness for a particular purpose.
24 *
25 * <h2><center>Copyright (C) Holtek Semiconductor Inc. All rights reserved</center></h2>
26 ************************************************************************************************************/
27
28 /* Includes ------------------------------------------------------------------------------------------------*/
29 #include <stdio.h>
30 #include <stdarg.h>
31 #include <sys/types.h>
32 #include <sys/stat.h>
33
34 /** @addtogroup HT32_Peripheral_Driver HT32 Peripheral Driver
35 * @{
36 */
37
38 /** @defgroup SYSCALLS System call functions
39 * @brief System call functions for GNU toolchain
40 * @{
41 */
42
43
44 /* Global variables ----------------------------------------------------------------------------------------*/
45 /** @defgroup SYSCALLS_Global_Variable System call global variables
46 * @{
47 */
48 #undef errno
49 extern int errno;
50 extern int _end;
51 /**
52 * @}
53 */
54
55 /* Global functions ----------------------------------------------------------------------------------------*/
56 /** @defgroup SYSCALLS_Exported_Functions System call exported functions
57 * @{
58 */
_sbrk(int incr)59 caddr_t _sbrk(int incr)
60 {
61 static unsigned char *heap = NULL;
62 unsigned char *prev_heap;
63
64 if (heap == NULL)
65 {
66 heap = (unsigned char *)&_end;
67 }
68 prev_heap = heap;
69
70 heap += incr;
71
72 return (caddr_t) prev_heap;
73 }
74
link(char * old,char * new)75 int link(char *old, char *new) {
76 return -1;
77 }
78
_close(int fd)79 int _close(int fd)
80 {
81 return -1;
82 }
83
_fstat(int fd,struct stat * st)84 int _fstat(int fd, struct stat *st)
85 {
86 st->st_mode = S_IFCHR;
87 return 0;
88 }
89
_isatty(int fd)90 int _isatty(int fd)
91 {
92 return 1;
93 }
94
_lseek(int fd,int ptr,int dir)95 int _lseek(int fd, int ptr, int dir)
96 {
97 return 0;
98 }
99
_read(int fd,char * ptr,int len)100 int _read(int fd, char *ptr, int len)
101 {
102 return 0;
103 }
104
_write(int fd,char * ptr,int len)105 int _write(int fd, char *ptr, int len)
106 {
107 return len;
108 }
109
abort(void)110 void abort(void)
111 {
112 /* Abort called */
113 while (1);
114 }
115
116 /**
117 * @}
118 */
119
120
121 /**
122 * @}
123 */
124
125 /**
126 * @}
127 */
128