Christina Quast | b0a0570 | 2014-11-28 10:27:32 +0100 | [diff] [blame] | 1 | /* ----------------------------------------------------------------------------
|
| 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
|
| 54 | extern int errno ;
|
| 55 | extern int _end ;
|
| 56 |
|
| 57 | /*----------------------------------------------------------------------------
|
| 58 | * Exported functions
|
| 59 | *----------------------------------------------------------------------------*/
|
| 60 | extern void _exit( int status ) ;
|
| 61 | extern void _kill( int pid, int sig ) ;
|
| 62 | extern int _getpid ( void ) ;
|
| 63 |
|
| 64 | extern 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 |
|
| 80 | extern int link( char *old, char *new )
|
| 81 | {
|
| 82 | return -1 ;
|
| 83 | }
|
| 84 |
|
| 85 | extern int _close( int file )
|
| 86 | {
|
| 87 | return -1 ;
|
| 88 | }
|
| 89 |
|
| 90 | extern int _fstat( int file, struct stat *st )
|
| 91 | {
|
| 92 | st->st_mode = S_IFCHR ;
|
| 93 |
|
| 94 | return 0 ;
|
| 95 | }
|
| 96 |
|
| 97 | extern int _isatty( int file )
|
| 98 | {
|
| 99 | return 1 ;
|
| 100 | }
|
| 101 |
|
| 102 | extern int _lseek( int file, int ptr, int dir )
|
| 103 | {
|
| 104 | return 0 ;
|
| 105 | }
|
| 106 |
|
| 107 | extern int _read(int file, char *ptr, int len)
|
| 108 | {
|
| 109 | return 0 ;
|
| 110 | }
|
| 111 |
|
| 112 | extern int _write( int file, char *ptr, int len )
|
| 113 | {
|
Christina Quast | 5958587 | 2015-04-06 19:47:22 +0200 | [diff] [blame] | 114 | int iIndex ;
|
Christina Quast | b0a0570 | 2014-11-28 10:27:32 +0100 | [diff] [blame] | 115 |
|
Christina Quast | 8be71e4 | 2014-12-02 13:06:01 +0100 | [diff] [blame] | 116 | for ( iIndex=0 ; iIndex < len ; iIndex++, ptr++ )
|
Christina Quast | b0a0570 | 2014-11-28 10:27:32 +0100 | [diff] [blame] | 117 | {
|
| 118 | UART_PutChar( *ptr ) ;
|
| 119 | }
|
Christina Quast | b0a0570 | 2014-11-28 10:27:32 +0100 | [diff] [blame] | 120 | return iIndex ;
|
Christina Quast | b0a0570 | 2014-11-28 10:27:32 +0100 | [diff] [blame] | 121 | }
|
| 122 |
|
| 123 | extern void _exit( int status )
|
| 124 | {
|
| 125 | printf( "Exiting with status %d.\n", status ) ;
|
| 126 |
|
| 127 | for ( ; ; ) ;
|
| 128 | }
|
| 129 |
|
| 130 | extern void _kill( int pid, int sig )
|
| 131 | {
|
| 132 | return ;
|
| 133 | }
|
| 134 |
|
| 135 | extern int _getpid ( void )
|
| 136 | {
|
| 137 | return -1 ;
|
| 138 | }
|