mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-18 12:52:44 +01:00
* mc1322x specifics syscalls
This commit is contained in:
parent
24300304f3
commit
0add4cad21
19
cpu/mc1322x/cpu.c
Normal file
19
cpu/mc1322x/cpu.c
Normal file
@ -0,0 +1,19 @@
|
||||
/*
|
||||
* cpu.c - MC1322X architecture common support functions
|
||||
* Copyright (C) 2013 Oliver Hahm <oliver.hahm@inria.fr>
|
||||
*
|
||||
* This source code is licensed under the GNU General Public License,
|
||||
* Version 3. See the file LICENSE for more details.
|
||||
*
|
||||
* This file is part of RIOT.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "mc1322x.h"
|
||||
|
||||
__attribute__((naked,noreturn)) void arm_reset(void)
|
||||
{
|
||||
dINT();
|
||||
CRM->SW_RST = SW_RST_VAL;
|
||||
while(1);
|
||||
}
|
56
cpu/mc1322x/mc1322x_syscalls.c
Normal file
56
cpu/mc1322x/mc1322x_syscalls.c
Normal file
@ -0,0 +1,56 @@
|
||||
/*
|
||||
* mc1322x_syscalls.c - MCU dependent syscall implementation
|
||||
* Copyright (C) 2013 Oliver Hahm <oliver.hahm@inria.fr>
|
||||
*
|
||||
* This source code is licensed under the GNU General Public License,
|
||||
* Version 3. See the file LICENSE for more details.
|
||||
*
|
||||
* This file is part of RIOT.
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#include "irq.h"
|
||||
|
||||
extern uintptr_t __heap_start; ///< start of heap memory space
|
||||
extern uintptr_t __heap_end; ///< maximum for end of heap memory space
|
||||
|
||||
/// current position in heap
|
||||
static caddr_t heap = (caddr_t)&__heap_start;
|
||||
/// maximum position in heap
|
||||
static const caddr_t heap_max = (caddr_t)&__heap_end;
|
||||
// start position in heap
|
||||
static const caddr_t heap_start = (caddr_t)&__heap_start;
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
caddr_t _sbrk_r(struct _reent *r, size_t incr)
|
||||
{
|
||||
uint32_t cpsr = disableIRQ();
|
||||
|
||||
/* check all heaps for a chunk of the requested size */
|
||||
caddr_t new_heap = heap + incr;
|
||||
|
||||
#ifdef MODULE_TRACELOG
|
||||
trace_pointer(TRACELOG_EV_MEMORY, heap);
|
||||
#endif
|
||||
if( new_heap <= heap_max ) {
|
||||
caddr_t prev_heap = heap;
|
||||
#ifdef MODULE_TRACELOG
|
||||
trace_pointer(TRACELOG_EV_MEMORY, new_heap);
|
||||
#endif
|
||||
heap = new_heap;
|
||||
|
||||
r->_errno = 0;
|
||||
restoreIRQ(cpsr);
|
||||
return prev_heap;
|
||||
}
|
||||
restoreIRQ(cpsr);
|
||||
#ifdef MODULE_TRACELOG
|
||||
trace_string(TRACELOG_EV_MEMORY, "heap!"); // heap full
|
||||
#endif
|
||||
|
||||
r->_errno = ENOMEM;
|
||||
return NULL;
|
||||
}
|
Loading…
Reference in New Issue
Block a user