blob: 71cc69a8443c2e907ca64a82eddb95d0548ce178 [file] [log] [blame]
Christina Quastb0a05702014-11-28 10:27:32 +01001/* ----------------------------------------------------------------------------
2 * ATMEL Microcontroller Software Support
3 * ----------------------------------------------------------------------------
4 * Copyright (c) 2009, Atmel Corporation
5 *
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are met:
10 *
11 * - Redistributions of source code must retain the above copyright notice,
12 * this list of conditions and the disclaimer below.
13 *
14 * Atmel's name may not be used to endorse or promote products derived from
15 * this software without specific prior written permission.
16 *
17 * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
20 * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
23 * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
24 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
26 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 * ----------------------------------------------------------------------------
28 */
29
30/**
31 * \file syscalls.c
32 *
33 * Implementation of newlib syscall.
34 *
35 */
36
37/*----------------------------------------------------------------------------
38 * Headers
39 *----------------------------------------------------------------------------*/
40
41
42#include "board.h"
43
44#include <stdio.h>
45#include <stdarg.h>
46#include <sys/types.h>
47#include <sys/stat.h>
48
49/*----------------------------------------------------------------------------
50 * Exported variables
51 *----------------------------------------------------------------------------*/
52
53#undef errno
54extern int errno ;
55extern int _end ;
56
57/*----------------------------------------------------------------------------
58 * Exported functions
59 *----------------------------------------------------------------------------*/
60extern void _exit( int status ) ;
61extern void _kill( int pid, int sig ) ;
62extern int _getpid ( void ) ;
63
64extern caddr_t _sbrk ( int incr )
65{
66 static unsigned char *heap = NULL ;
67 unsigned char *prev_heap ;
68
69 if ( heap == NULL )
70 {
71 heap = (unsigned char *)&_end ;
72 }
73 prev_heap = heap;
74
75 heap += incr ;
76
77 return (caddr_t) prev_heap ;
78}
79
80extern int link( char *old, char *new )
81{
82 return -1 ;
83}
84
85extern int _close( int file )
86{
87 return -1 ;
88}
89
90extern int _fstat( int file, struct stat *st )
91{
92 st->st_mode = S_IFCHR ;
93
94 return 0 ;
95}
96
97extern int _isatty( int file )
98{
99 return 1 ;
100}
101
102extern int _lseek( int file, int ptr, int dir )
103{
104 return 0 ;
105}
106
107extern int _read(int file, char *ptr, int len)
108{
109 return 0 ;
110}
111
112extern int _write( int file, char *ptr, int len )
113{
Christina Quast59585872015-04-06 19:47:22 +0200114 int iIndex ;
Christina Quastb0a05702014-11-28 10:27:32 +0100115
Christina Quast8be71e42014-12-02 13:06:01 +0100116 for ( iIndex=0 ; iIndex < len ; iIndex++, ptr++ )
Christina Quastb0a05702014-11-28 10:27:32 +0100117 {
118 UART_PutChar( *ptr ) ;
119 }
Christina Quastb0a05702014-11-28 10:27:32 +0100120 return iIndex ;
Christina Quastb0a05702014-11-28 10:27:32 +0100121}
122
123extern void _exit( int status )
124{
125 printf( "Exiting with status %d.\n", status ) ;
126
127 for ( ; ; ) ;
128}
129
130extern void _kill( int pid, int sig )
131{
132 return ;
133}
134
135extern int _getpid ( void )
136{
137 return -1 ;
138}