diff options
author | Josh Rahm <joshuarahm@gmail.com> | 2020-11-21 21:24:04 -0700 |
---|---|---|
committer | Josh Rahm <joshuarahm@gmail.com> | 2020-11-21 21:24:04 -0700 |
commit | b073c19f9ec330423fa07c66d1c0604883044f6b (patch) | |
tree | 476959ae1e0691d4c8175112e4189133db2be54b /02-usart/include/arch | |
parent | 14a651cda0bd8dfb992d2a6a1544300c39492ca3 (diff) | |
download | stm32l4-b073c19f9ec330423fa07c66d1c0604883044f6b.tar.gz stm32l4-b073c19f9ec330423fa07c66d1c0604883044f6b.tar.bz2 stm32l4-b073c19f9ec330423fa07c66d1c0604883044f6b.zip |
Added halloc for allocating memory on the heap.
The new halloc() call allocates memory on the
STM32l's SRAM2 starting right above the DATA
section.
The implementation uses a very-dense, albeit slower, linked-list
allocation as opposed to fancy B-trees or something. However, the
overhead is just 1 32-bit word per allocation and thus allows for
reasonably dense memory-packing on the small 16K memory chip.
Diffstat (limited to '02-usart/include/arch')
-rw-r--r-- | 02-usart/include/arch/arm/arch.h | 3 | ||||
-rw-r--r-- | 02-usart/include/arch/x86_64/arch.h | 6 |
2 files changed, 9 insertions, 0 deletions
diff --git a/02-usart/include/arch/arm/arch.h b/02-usart/include/arch/arm/arch.h index 569ca77..f140c97 100644 --- a/02-usart/include/arch/arm/arch.h +++ b/02-usart/include/arch/arm/arch.h @@ -33,4 +33,7 @@ _Static_assert(sizeof(void*) == sizeof(uint32_t), "Pointers must be 32 bits"); #endif +extern uint32_t DATA_SEGMENT_START; +extern uint32_t DATA_SEGMENT_STOP; + #endif /* ARCH_H_ */ diff --git a/02-usart/include/arch/x86_64/arch.h b/02-usart/include/arch/x86_64/arch.h index 258214e..accc449 100644 --- a/02-usart/include/arch/x86_64/arch.h +++ b/02-usart/include/arch/x86_64/arch.h @@ -24,4 +24,10 @@ #define SYSTEM_CONFIG_BLOCK_BASE (load_fake_scb__()) #define NVIC_BASE (load_fake_nvic__()) +// Pretend there's a data segement at the start of SRAM1 for more accurate +// testing. +#define GHOST_DATA_SEGMENT_SIZE 1234 +#define DATA_SEGMENT_START SRAM1_BASE +#define DATA_SEGMENT_STOP (SRAM1_BASE + GHOST_DATA_SEGMENT_SIZE) + #endif /* ARCH_H_ */ |