From c1635602240148a7653dda27022141b7a7ffdee3 Mon Sep 17 00:00:00 2001 From: "Kwabena W. Agyeman" Date: Sun, 7 Mar 2021 15:48:05 -0800 Subject: [PATCH] Cleanup FB_ALLOC_OVERLAY pointers --- src/omv/alloc/fb_alloc.c | 10 +++++----- src/omv/boards/OPENMV4P/omv_boardconfig.h | 1 - src/omv/boards/OPENMVPT/omv_boardconfig.h | 1 - src/omv/boards/PORTENTA/omv_boardconfig.h | 1 - src/omv/ports/stm32/stm32fxxx.ld.S | 1 - src/uvc/stm32fxxx.ld.S | 1 - 6 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/omv/alloc/fb_alloc.c b/src/omv/alloc/fb_alloc.c index 3e3ee8777..a6ab91be4 100644 --- a/src/omv/alloc/fb_alloc.c +++ b/src/omv/alloc/fb_alloc.c @@ -28,8 +28,8 @@ static uint32_t alloc_bytes_peak; #if defined(OMV_FB_OVERLAY_MEMORY) #define FB_OVERLAY_MEMORY_FLAG 0x1 -extern char _fballoc_overlay; -static char *pointer_overlay = &_fballoc_overlay; +extern char _fballoc_overlay_end, _fballoc_overlay_start; +static char *pointer_overlay = &_fballoc_overlay_end; #endif // fb_alloc_free_till_mark() will not free past this. @@ -57,7 +57,7 @@ void fb_alloc_init0() { pointer = &_fballoc; #if defined(OMV_FB_OVERLAY_MEMORY) - pointer_overlay = &_fballoc_overlay; + pointer_overlay = &_fballoc_overlay_end; #endif } @@ -167,7 +167,7 @@ void *fb_alloc(uint32_t size, int hints) #if defined(OMV_FB_OVERLAY_MEMORY) if ((!(hints & FB_ALLOC_PREFER_SIZE)) - && (((uint32_t) (pointer_overlay - OMV_FB_OVERLAY_MEMORY_ORIGIN)) >= size)) { + && (((uint32_t) (pointer_overlay - &_fballoc_overlay_start)) >= size)) { // Return overlay memory instead. pointer_overlay -= size; result = pointer_overlay; @@ -204,7 +204,7 @@ void *fb_alloc_all(uint32_t *size, int hints) #if defined(OMV_FB_OVERLAY_MEMORY) if (!(hints & FB_ALLOC_PREFER_SIZE)) { - *size = (uint32_t) (pointer_overlay - OMV_FB_OVERLAY_MEMORY_ORIGIN); + *size = (uint32_t) (pointer_overlay - &_fballoc_overlay_start); temp = IM_MIN(temp, *size); } #endif diff --git a/src/omv/boards/OPENMV4P/omv_boardconfig.h b/src/omv/boards/OPENMV4P/omv_boardconfig.h index a5d2ae95d..92344fc7c 100644 --- a/src/omv/boards/OPENMV4P/omv_boardconfig.h +++ b/src/omv/boards/OPENMV4P/omv_boardconfig.h @@ -179,7 +179,6 @@ #define OMV_AXI_SRAM_LENGTH 512K #define OMV_DRAM_ORIGIN 0xC0000000 #define OMV_DRAM_LENGTH 32M -#define OMV_FB_OVERLAY_MEMORY_ORIGIN OMV_AXI_SRAM_ORIGIN // Domain 1 DMA buffers region. #define OMV_DMA_MEMORY_D1 AXI_SRAM diff --git a/src/omv/boards/OPENMVPT/omv_boardconfig.h b/src/omv/boards/OPENMVPT/omv_boardconfig.h index 2e9493ebc..16562384e 100644 --- a/src/omv/boards/OPENMVPT/omv_boardconfig.h +++ b/src/omv/boards/OPENMVPT/omv_boardconfig.h @@ -176,7 +176,6 @@ #define OMV_AXI_SRAM_LENGTH 512K #define OMV_DRAM_ORIGIN 0xC0000000 #define OMV_DRAM_LENGTH 64M -#define OMV_FB_OVERLAY_MEMORY_ORIGIN OMV_AXI_SRAM_ORIGIN // Domain 1 DMA buffers region. #define OMV_DMA_MEMORY_D1 AXI_SRAM diff --git a/src/omv/boards/PORTENTA/omv_boardconfig.h b/src/omv/boards/PORTENTA/omv_boardconfig.h index 8b32e2aa7..ca4fb7373 100644 --- a/src/omv/boards/PORTENTA/omv_boardconfig.h +++ b/src/omv/boards/PORTENTA/omv_boardconfig.h @@ -179,7 +179,6 @@ #define OMV_DRAM_LENGTH 8M #define OMV_FLASH_EXT_ORIGIN 0x90000000 #define OMV_FLASH_EXT_LENGTH 16M -#define OMV_FB_OVERLAY_MEMORY_ORIGIN OMV_AXI_SRAM_ORIGIN // Domain 1 DMA buffers region. #define OMV_DMA_MEMORY_D1 AXI_SRAM diff --git a/src/omv/ports/stm32/stm32fxxx.ld.S b/src/omv/ports/stm32/stm32fxxx.ld.S index 2191d19cd..34309985b 100755 --- a/src/omv/ports/stm32/stm32fxxx.ld.S +++ b/src/omv/ports/stm32/stm32fxxx.ld.S @@ -126,7 +126,6 @@ SECTIONS . = ALIGN(4); _fballoc_overlay_start = .; . = . + OMV_FB_OVERLAY_MEMORY_OFFSET; - _fballoc_overlay = .; _fballoc_overlay_end = .; } >OMV_FB_OVERLAY_MEMORY #endif diff --git a/src/uvc/stm32fxxx.ld.S b/src/uvc/stm32fxxx.ld.S index d095254f6..e3f6f3d9e 100755 --- a/src/uvc/stm32fxxx.ld.S +++ b/src/uvc/stm32fxxx.ld.S @@ -107,7 +107,6 @@ SECTIONS . = ALIGN(4); _fballoc_overlay_start = .; . = . + OMV_FB_OVERLAY_MEMORY_OFFSET; - _fballoc_overlay = .; _fballoc_overlay_end = .; } >OMV_FB_OVERLAY_MEMORY #endif