Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
Baitboat
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
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
OpenSource
Baitboat
Commits
36e06a17
Commit
36e06a17
authored
11 years ago
by
Andrew Tridgell
Browse files
Options
Downloads
Patches
Plain Diff
HAL_AVR: moved memcheck into HAL_AVR
parent
efc7f88e
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
libraries/AP_HAL_AVR/memcheck.cpp
+8
-8
8 additions, 8 deletions
libraries/AP_HAL_AVR/memcheck.cpp
libraries/AP_HAL_AVR/memcheck.h
+0
-2
0 additions, 2 deletions
libraries/AP_HAL_AVR/memcheck.h
with
8 additions
and
10 deletions
libraries/
memcheck
/memcheck.cpp
→
libraries/
AP_HAL_AVR
/memcheck.cpp
+
8
−
8
View file @
36e06a17
/// -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*-
/// -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*-
/*
keep track of available memory on AVR
*/
/*
/*
* note that we use a 32 bit sentinel to reduce the chance
* note that we use a 32 bit sentinel to reduce the chance
...
@@ -7,7 +10,8 @@
...
@@ -7,7 +10,8 @@
#include
<stdlib.h>
#include
<stdlib.h>
#include
<stdint.h>
#include
<stdint.h>
#include
<AP_HAL_Boards.h>
#if (CONFIG_HAL_BOARD == HAL_BOARD_APM1 || CONFIG_HAL_BOARD == HAL_BOARD_APM2)
static
const
uint32_t
*
stack_low
;
static
const
uint32_t
*
stack_low
;
extern
unsigned
__brkval
;
extern
unsigned
__brkval
;
...
@@ -28,7 +32,7 @@ static __attribute__((noinline)) const uint32_t *current_stackptr(void)
...
@@ -28,7 +32,7 @@ static __attribute__((noinline)) const uint32_t *current_stackptr(void)
* deep stack usage. It should be caught by the sentinel, but this
* deep stack usage. It should be caught by the sentinel, but this
* is an added protection
* is an added protection
*/
*/
void
memcheck_update_stackptr
(
void
)
static
void
memcheck_update_stackptr
(
void
)
{
{
if
(
current_stackptr
()
<
stack_low
)
{
if
(
current_stackptr
()
<
stack_low
)
{
uintptr_t
s
=
(
uintptr_t
)(
current_stackptr
()
-
STACK_OFFSET
);
uintptr_t
s
=
(
uintptr_t
)(
current_stackptr
()
-
STACK_OFFSET
);
...
@@ -41,7 +45,6 @@ void memcheck_update_stackptr(void)
...
@@ -41,7 +45,6 @@ void memcheck_update_stackptr(void)
*/
*/
void
memcheck_init
(
void
)
void
memcheck_init
(
void
)
{
{
#if CONFIG_HAL_BOARD == HAL_BOARD_APM1 || CONFIG_HAL_BOARD == HAL_BOARD_APM2
uint32_t
*
p
;
uint32_t
*
p
;
free
(
malloc
(
1
));
// ensure heap is initialised
free
(
malloc
(
1
));
// ensure heap is initialised
stack_low
=
current_stackptr
();
stack_low
=
current_stackptr
();
...
@@ -49,7 +52,6 @@ void memcheck_init(void)
...
@@ -49,7 +52,6 @@ void memcheck_init(void)
for
(
p
=
(
uint32_t
*
)(
stack_low
-
1
);
p
>
(
uint32_t
*
)
__brkval
;
p
--
)
{
for
(
p
=
(
uint32_t
*
)(
stack_low
-
1
);
p
>
(
uint32_t
*
)
__brkval
;
p
--
)
{
*
p
=
SENTINEL
;
*
p
=
SENTINEL
;
}
}
#endif
}
}
/*
/*
...
@@ -58,13 +60,11 @@ void memcheck_init(void)
...
@@ -58,13 +60,11 @@ void memcheck_init(void)
*/
*/
unsigned
memcheck_available_memory
(
void
)
unsigned
memcheck_available_memory
(
void
)
{
{
#if CONFIG_HAL_BOARD == HAL_BOARD_APM1 || CONFIG_HAL_BOARD == HAL_BOARD_APM2
memcheck_update_stackptr
();
memcheck_update_stackptr
();
while
(
*
stack_low
!=
SENTINEL
&&
stack_low
>
(
const
uint32_t
*
)
__brkval
)
{
while
(
*
stack_low
!=
SENTINEL
&&
stack_low
>
(
const
uint32_t
*
)
__brkval
)
{
stack_low
--
;
stack_low
--
;
}
}
return
(
uintptr_t
)(
stack_low
)
-
__brkval
;
return
(
uintptr_t
)(
stack_low
)
-
__brkval
;
#else
return
0x1000
;
#endif
}
}
#endif // CONFIG_HAL_BOARD
This diff is collapsed.
Click to expand it.
libraries/
memcheck
/memcheck.h
→
libraries/
AP_HAL_AVR
/memcheck.h
+
0
−
2
View file @
36e06a17
...
@@ -2,5 +2,3 @@
...
@@ -2,5 +2,3 @@
unsigned
memcheck_available_memory
(
void
);
unsigned
memcheck_available_memory
(
void
);
void
memcheck_init
(
void
);
void
memcheck_init
(
void
);
void
memcheck_update_stackptr
(
void
);
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