Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
RIOT
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cm-projects
RIOT
Commits
81dea364
Commit
81dea364
authored
10 years ago
by
Ian Martin
Browse files
Options
Downloads
Patches
Plain Diff
cpu/cc2538: sbrk() checks if the requested memory is really available.
parent
6b4ac477
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
cpu/cc2538/Makefile.include
+4
-0
4 additions, 0 deletions
cpu/cc2538/Makefile.include
cpu/cc2538/syscalls.c
+21
-10
21 additions, 10 deletions
cpu/cc2538/syscalls.c
with
25 additions
and
10 deletions
cpu/cc2538/Makefile.include
+
4
−
0
View file @
81dea364
...
...
@@ -10,6 +10,10 @@ export CORTEX_COMMON = $(RIOTCPU)/cortex-m3_common/
# Define the linker script to use for this CPU:
export
LINKERSCRIPT
=
$(
RIOTCPU
)
/
$(
CPU
)
/
$(
CPU_MODEL
)
_linkerscript.ld
# Export the CPU model:
MODEL
=
$(
shell
echo
$(
CPU_MODEL
)
|
tr
'a-z'
'A-Z'
)
export
CFLAGS
+=
-DCPU_MODEL_
$(
MODEL
)
# Include CPU specific includes:
export
INCLUDES
+=
-I
$(
RIOTCPU
)
/
$(
CPU
)
/include
...
...
This diff is collapsed.
Click to expand it.
cpu/cc2538/syscalls.c
+
21
−
10
View file @
81dea364
...
...
@@ -39,6 +39,13 @@
#ifdef MODULE_UART0
#include
"board_uart0.h"
#endif
#ifdef CPU_MODEL_CC2538NF11
#define SRAM_LENGTH (16 * 1024)
/**< The CC2538NF11 has 16 Kb of RAM */
#else
#define SRAM_LENGTH (32 * 1024)
/**< All other existing models of the CC2538 have 32 Kb of RAM */
#endif
/**
* manage the heap
*/
...
...
@@ -113,21 +120,25 @@ void _exit(int n)
* @brief Allocate memory from the heap.
*
* The current heap implementation is very rudimentary, it is only able to allocate
* memory. But it does not
* - check if the returned address is valid (no check if the memory very exists)
* - have any means to free memory again
* memory. It does not have any means to free memory again.
*
* TODO: check if the requested memory is really available
*
* @return [description]
* @return a pointer to the successfully allocated memory
* @return -1 on error, and errno is set to ENOMEM
*/
caddr_t
_sbrk_r
(
struct
_reent
*
r
,
size_t
incr
)
{
unsigned
int
state
=
disableIRQ
();
caddr_t
res
=
heap_top
;
heap_top
+=
incr
;
restoreIRQ
(
state
);
return
res
;
if
((
uintptr_t
)
heap_top
+
incr
>
SRAM_BASE
+
SRAM_LENGTH
)
{
restoreIRQ
(
state
);
r
->
_errno
=
ENOMEM
;
return
(
caddr_t
)
-
1
;
}
else
{
caddr_t
res
=
heap_top
;
heap_top
+=
incr
;
restoreIRQ
(
state
);
return
res
;
}
}
/**
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment