diff options
Diffstat (limited to 'firmware/include')
-rw-r--r-- | firmware/include/buflib.h | 20 | ||||
-rw-r--r-- | firmware/include/core_alloc.h | 3 |
2 files changed, 23 insertions, 0 deletions
diff --git a/firmware/include/buflib.h b/firmware/include/buflib.h index 45446c3b86..d2231ab79d 100644 --- a/firmware/include/buflib.h +++ b/firmware/include/buflib.h | |||
@@ -38,6 +38,7 @@ union buflib_data | |||
38 | intptr_t val; /* length of the block in n*sizeof(union buflib_data). | 38 | intptr_t val; /* length of the block in n*sizeof(union buflib_data). |
39 | Includes buflib metadata overhead. A negative value | 39 | Includes buflib metadata overhead. A negative value |
40 | indicates block is unallocated */ | 40 | indicates block is unallocated */ |
41 | volatile unsigned pincount; /* number of pins */ | ||
41 | struct buflib_callbacks* ops; /* callback functions for move and shrink. Can be NULL */ | 42 | struct buflib_callbacks* ops; /* callback functions for move and shrink. Can be NULL */ |
42 | char* alloc; /* start of allocated memory area */ | 43 | char* alloc; /* start of allocated memory area */ |
43 | union buflib_data *handle; /* pointer to entry in the handle table. | 44 | union buflib_data *handle; /* pointer to entry in the handle table. |
@@ -292,6 +293,25 @@ static inline void* buflib_get_data(struct buflib_context *ctx, int handle) | |||
292 | bool buflib_shrink(struct buflib_context *ctx, int handle, void* newstart, size_t new_size); | 293 | bool buflib_shrink(struct buflib_context *ctx, int handle, void* newstart, size_t new_size); |
293 | 294 | ||
294 | /** | 295 | /** |
296 | * Increment the pin count for a handle. When pinned the handle will not | ||
297 | * be moved and move callbacks will not be triggered, allowing a pointer | ||
298 | * to the buffer to be kept across yields or used for I/O. | ||
299 | * | ||
300 | * Note that shrink callbacks can still be invoked for pinned handles. | ||
301 | */ | ||
302 | void buflib_pin(struct buflib_context *ctx, int handle); | ||
303 | |||
304 | /** | ||
305 | * Decrement the pin count for a handle. | ||
306 | */ | ||
307 | void buflib_unpin(struct buflib_context *ctx, int handle); | ||
308 | |||
309 | /** | ||
310 | * Get the current pin count of a handle. Zero means the handle is not pinned. | ||
311 | */ | ||
312 | unsigned buflib_pin_count(struct buflib_context *ctx, int handle); | ||
313 | |||
314 | /** | ||
295 | * Frees memory associated with the given handle | 315 | * Frees memory associated with the given handle |
296 | * | 316 | * |
297 | * Returns: 0 (to invalidate handles in one line, 0 is not a valid handle) | 317 | * Returns: 0 (to invalidate handles in one line, 0 is not a valid handle) |
diff --git a/firmware/include/core_alloc.h b/firmware/include/core_alloc.h index f535fc1f6e..87246bcbd6 100644 --- a/firmware/include/core_alloc.h +++ b/firmware/include/core_alloc.h | |||
@@ -14,6 +14,9 @@ int core_alloc(const char* name, size_t size); | |||
14 | int core_alloc_ex(const char* name, size_t size, struct buflib_callbacks *ops); | 14 | int core_alloc_ex(const char* name, size_t size, struct buflib_callbacks *ops); |
15 | int core_alloc_maximum(const char* name, size_t *size, struct buflib_callbacks *ops); | 15 | int core_alloc_maximum(const char* name, size_t *size, struct buflib_callbacks *ops); |
16 | bool core_shrink(int handle, void* new_start, size_t new_size); | 16 | bool core_shrink(int handle, void* new_start, size_t new_size); |
17 | void core_pin(int handle); | ||
18 | void core_unpin(int handle); | ||
19 | unsigned core_pin_count(int handle); | ||
17 | int core_free(int handle); | 20 | int core_free(int handle); |
18 | size_t core_available(void); | 21 | size_t core_available(void); |
19 | size_t core_allocatable(void); | 22 | size_t core_allocatable(void); |