heap: Fix regression in heap_caps_add_region API related to address range checks

Regression was introduced in 32408b718f, which disallowed
addition of heap region with following condition:

`new_start < start && new_end == start`

This caused issues in Bluetooth APIs `esp_bt_mem_release` or `esp_bt_controller_mem_release`.

This commit fixes the problem and also adds API documentation for supported memory address
ranges in heap add region APIs.
This commit is contained in:
Mahavir Jain
2022-03-24 12:25:37 +05:30
parent 8ce997f02c
commit f13e25d156
2 changed files with 51 additions and 18 deletions

View File

@@ -49,6 +49,20 @@ void heap_caps_enable_nonos_stack_heaps(void);
*
* Use heap_caps_add_region_with_caps() to register a region with custom capabilities.
*
* @note Please refer to following example for memory regions allowed for addition to heap based on an existing region
* (address range for demonstration purpose only):
@verbatim
Existing region: 0x1000 <-> 0x3000
New region: 0x1000 <-> 0x3000 (Allowed)
New region: 0x1000 <-> 0x2000 (Allowed)
New region: 0x0000 <-> 0x1000 (Allowed)
New region: 0x3000 <-> 0x4000 (Allowed)
New region: 0x0000 <-> 0x2000 (NOT Allowed)
New region: 0x0000 <-> 0x4000 (NOT Allowed)
New region: 0x1000 <-> 0x4000 (NOT Allowed)
New region: 0x2000 <-> 0x4000 (NOT Allowed)
@endverbatim
*
* @param start Start address of new region.
* @param end End address of new region.
*
@@ -63,6 +77,20 @@ esp_err_t heap_caps_add_region(intptr_t start, intptr_t end);
*
* Similar to heap_caps_add_region(), only custom memory capabilities are specified by the caller.
*
* @note Please refer to following example for memory regions allowed for addition to heap based on an existing region
* (address range for demonstration purpose only):
@verbatim
Existing region: 0x1000 <-> 0x3000
New region: 0x1000 <-> 0x3000 (Allowed)
New region: 0x1000 <-> 0x2000 (Allowed)
New region: 0x0000 <-> 0x1000 (Allowed)
New region: 0x3000 <-> 0x4000 (Allowed)
New region: 0x0000 <-> 0x2000 (NOT Allowed)
New region: 0x0000 <-> 0x4000 (NOT Allowed)
New region: 0x1000 <-> 0x4000 (NOT Allowed)
New region: 0x2000 <-> 0x4000 (NOT Allowed)
@endverbatim
*
* @param caps Ordered array of capability masks for the new region, in order of priority. Must have length
* SOC_MEMORY_TYPE_NO_PRIOS. Does not need to remain valid after the call returns.
* @param start Start address of new region.