mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-09 01:18:29 -04:00
HAL_ChibiOS: fixed bootloader build with gcc 4.9
This commit is contained in:
parent
723e8a23fc
commit
70930cca29
@ -70,7 +70,8 @@ static memory_heap_t dma_reserve_heap;
|
|||||||
*/
|
*/
|
||||||
void malloc_init(void)
|
void malloc_init(void)
|
||||||
{
|
{
|
||||||
for (uint8_t i=1; i<NUM_MEMORY_REGIONS; i++) {
|
uint8_t i;
|
||||||
|
for (i=1; i<NUM_MEMORY_REGIONS; i++) {
|
||||||
chHeapObjectInit(&heaps[i], memory_regions[i].address, memory_regions[i].size);
|
chHeapObjectInit(&heaps[i], memory_regions[i].address, memory_regions[i].size);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,6 +93,7 @@ static void *malloc_flags(size_t size, uint32_t flags)
|
|||||||
}
|
}
|
||||||
const uint8_t alignment = (flags&MEM_REGION_FLAG_DMA_OK?DMA_ALIGNMENT:MIN_ALIGNMENT);
|
const uint8_t alignment = (flags&MEM_REGION_FLAG_DMA_OK?DMA_ALIGNMENT:MIN_ALIGNMENT);
|
||||||
void *p = NULL;
|
void *p = NULL;
|
||||||
|
uint8_t i;
|
||||||
|
|
||||||
if (flags & MEM_REGION_FLAG_DMA_OK) {
|
if (flags & MEM_REGION_FLAG_DMA_OK) {
|
||||||
// allocate multiple of DMA alignment
|
// allocate multiple of DMA alignment
|
||||||
@ -109,7 +111,7 @@ static void *malloc_flags(size_t size, uint32_t flags)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// try with matching flags
|
// try with matching flags
|
||||||
for (uint8_t i=1; i<NUM_MEMORY_REGIONS; i++) {
|
for (i=1; i<NUM_MEMORY_REGIONS; i++) {
|
||||||
if ((flags & MEM_REGION_FLAG_DMA_OK) &&
|
if ((flags & MEM_REGION_FLAG_DMA_OK) &&
|
||||||
!(memory_regions[i].flags & MEM_REGION_FLAG_DMA_OK)) {
|
!(memory_regions[i].flags & MEM_REGION_FLAG_DMA_OK)) {
|
||||||
continue;
|
continue;
|
||||||
@ -126,7 +128,7 @@ static void *malloc_flags(size_t size, uint32_t flags)
|
|||||||
|
|
||||||
// if this is a not a DMA request then we can fall back to any heap
|
// if this is a not a DMA request then we can fall back to any heap
|
||||||
if (!(flags & MEM_REGION_FLAG_DMA_OK)) {
|
if (!(flags & MEM_REGION_FLAG_DMA_OK)) {
|
||||||
for (uint8_t i=1; i<NUM_MEMORY_REGIONS; i++) {
|
for (i=1; i<NUM_MEMORY_REGIONS; i++) {
|
||||||
p = chHeapAllocAligned(&heaps[i], size, alignment);
|
p = chHeapAllocAligned(&heaps[i], size, alignment);
|
||||||
if (p) {
|
if (p) {
|
||||||
goto found;
|
goto found;
|
||||||
@ -197,6 +199,7 @@ void free(void *ptr)
|
|||||||
size_t mem_available(void)
|
size_t mem_available(void)
|
||||||
{
|
{
|
||||||
size_t totalp = 0;
|
size_t totalp = 0;
|
||||||
|
uint8_t i;
|
||||||
|
|
||||||
// get memory available on main heap
|
// get memory available on main heap
|
||||||
chHeapStatus(NULL, &totalp, NULL);
|
chHeapStatus(NULL, &totalp, NULL);
|
||||||
@ -205,7 +208,7 @@ size_t mem_available(void)
|
|||||||
totalp += chCoreGetStatusX();
|
totalp += chCoreGetStatusX();
|
||||||
|
|
||||||
// now our own heaps
|
// now our own heaps
|
||||||
for (uint8_t i=1; i<NUM_MEMORY_REGIONS; i++) {
|
for (i=1; i<NUM_MEMORY_REGIONS; i++) {
|
||||||
size_t available = 0;
|
size_t available = 0;
|
||||||
chHeapStatus(&heaps[i], &available, NULL);
|
chHeapStatus(&heaps[i], &available, NULL);
|
||||||
totalp += available;
|
totalp += available;
|
||||||
@ -229,7 +232,8 @@ size_t mem_available(void)
|
|||||||
*/
|
*/
|
||||||
void memory_flush_all(void)
|
void memory_flush_all(void)
|
||||||
{
|
{
|
||||||
for (uint8_t i=0; i<NUM_MEMORY_REGIONS; i++) {
|
uint8_t i;
|
||||||
|
for (i=0; i<NUM_MEMORY_REGIONS; i++) {
|
||||||
cacheBufferFlush(memory_regions[i].address, memory_regions[i].size);
|
cacheBufferFlush(memory_regions[i].address, memory_regions[i].size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user