Skip to content

Commit 3b426f7

Browse files
committed
Add missing syscalls
1 parent 9b82dd3 commit 3b426f7

File tree

1 file changed

+85
-32
lines changed

1 file changed

+85
-32
lines changed

hardware/lm4f/cores/lm4f/startup_gcc.c

Lines changed: 85 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
#include "Energia.h"
3939
#include "inc/hw_types.h"
4040
#include "inc/hw_nvic.h"
41-
41+
#include "syscalls.h"
4242
//*****************************************************************************
4343
//
4444
// Forward declaration of the default fault handlers.
@@ -329,37 +329,6 @@ void ResetISR(void) {
329329
main();
330330
}
331331

332-
void *__dso_handle = 0;
333-
334-
/**
335-
* _sbrk - newlib memory allocation routine
336-
*/
337-
typedef char *caddr_t;
338-
339-
caddr_t _sbrk (int incr)
340-
{
341-
double current_sp;
342-
extern char end asm ("end"); /* Defined by linker */
343-
static char * heap_end;
344-
char * prev_heap_end;
345-
346-
if (heap_end == NULL) {
347-
heap_end = &end; /* first ram address after bss and data */
348-
}
349-
350-
prev_heap_end = heap_end;
351-
352-
// simplistic approach to prevent the heap from corrupting the stack
353-
// TBD: review for alternatives
354-
if ( heap_end + incr < (caddr_t)&current_sp ) {
355-
heap_end += incr;
356-
return (caddr_t) prev_heap_end;
357-
}
358-
else {
359-
return NULL;
360-
}
361-
}
362-
363332
//*****************************************************************************
364333
//
365334
// This is the code that gets called when the processor receives a NMI. This
@@ -407,3 +376,87 @@ static void IntDefaultHandler(void) {
407376
; // trap any handler not defined
408377
}
409378
}
379+
380+
/* syscall stuff */
381+
void *__dso_handle = 0;
382+
383+
/**
384+
* _sbrk - newlib memory allocation routine
385+
*/
386+
typedef char *caddr_t;
387+
388+
caddr_t _sbrk (int incr)
389+
{
390+
double current_sp;
391+
extern char end asm ("end"); /* Defined by linker */
392+
static char * heap_end;
393+
char * prev_heap_end;
394+
395+
if (heap_end == NULL) {
396+
heap_end = &end; /* first ram address after bss and data */
397+
}
398+
399+
prev_heap_end = heap_end;
400+
401+
// simplistic approach to prevent the heap from corrupting the stack
402+
// TBD: review for alternatives
403+
if ( heap_end + incr < (caddr_t)&current_sp ) {
404+
heap_end += incr;
405+
return (caddr_t) prev_heap_end;
406+
}
407+
else {
408+
return NULL;
409+
}
410+
}
411+
412+
extern int link( char *cOld, char *cNew )
413+
{
414+
return -1 ;
415+
}
416+
417+
extern int _close( int file )
418+
{
419+
return -1 ;
420+
}
421+
422+
extern int _fstat( int file, struct stat *st )
423+
{
424+
st->st_mode = S_IFCHR ;
425+
426+
return 0 ;
427+
}
428+
429+
extern int _isatty( int file )
430+
{
431+
return 1 ;
432+
}
433+
434+
extern int _lseek( int file, int ptr, int dir )
435+
{
436+
return 0 ;
437+
}
438+
439+
extern int _read(int file, char *ptr, int len)
440+
{
441+
return 0 ;
442+
}
443+
444+
extern int _write( int file, char *ptr, int len )
445+
{
446+
return len;
447+
}
448+
449+
extern void _kill( int pid, int sig )
450+
{
451+
return ;
452+
}
453+
454+
extern int _getpid ( void )
455+
{
456+
return -1 ;
457+
}
458+
459+
extern void _exit (void)
460+
{
461+
462+
}

0 commit comments

Comments
 (0)