nrfxlib API 3.3.99
Loading...
Searching...
No Matches
nrf_802154_bsmap.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2026, Nordic Semiconductor ASA
3 * All rights reserved.
4 *
5 * SPDX-License-Identifier: BSD-3-Clause
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions are met:
9 *
10 * 1. Redistributions of source code must retain the above copyright notice, this
11 * list of conditions and the following disclaimer.
12 *
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 *
17 * 3. Neither the name of Nordic Semiconductor ASA nor the names of its
18 * contributors may be used to endorse or promote products derived from this
19 * software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
25 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 * POSSIBILITY OF SUCH DAMAGE.
32 *
33 */
34
51#ifndef NRF_802154_BSMAP_H_
52#define NRF_802154_BSMAP_H_
53
54#include <nrfx.h>
55#include <stdbool.h>
56#include <stdint.h>
57#include <stddef.h>
58
65
71typedef struct nrf_802154_bsmap_s nrf_802154_bsmap_t;
72
78typedef struct
79{
83 int32_t index;
87 bool forward;
91 bool deleted;
95 nrf_802154_bsmap_t * p_bsmap;
97
104{
108 uint16_t key_size;
109
113 uint16_t value_size;
114
118 uint16_t entry_size;
119
123 uint16_t capacity;
124
128 uint16_t keys_count;
129
133 void * p_memory;
134
138 nrfx_atomic_t entry_idx_in_aux;
139
144
149};
150
159#define NRF_802154_BSMAP_ENTRY_SIZE(key_size, value_size) ((key_size) + (value_size))
160
168#define NRF_802154_BSMAP_MEMORY_SIZE(key_size, value_size, capacity) \
169 (NRF_802154_BSMAP_ENTRY_SIZE((key_size), (value_size)) * (capacity))
170
177#define NRF_802154_BSMAP_AUX_MEMORY_SIZE(key_size, value_size) \
178 NRF_802154_BSMAP_ENTRY_SIZE((key_size), (value_size))
179
195void nrf_802154_bsmap_init(nrf_802154_bsmap_t * p_bsmap,
196 size_t key_size,
197 size_t value_size,
198 size_t capacity,
199 void * p_memory);
200
222bool nrf_802154_bsmap_rec_get(const nrf_802154_bsmap_t * p_bsmap,
223 const void * p_key,
224 void * p_value);
225
251bool nrf_802154_bsmap_rec_write(nrf_802154_bsmap_t * p_bsmap,
252 const void * p_key,
253 const void * p_value,
254 void * p_aux_memory);
255
275bool nrf_802154_bsmap_rec_delete(nrf_802154_bsmap_t * p_bsmap,
276 const void * p_key,
277 void * p_aux_memory);
278
284void nrf_802154_bsmap_clear(nrf_802154_bsmap_t * p_bsmap);
285
311void nrf_802154_bsmap_iterator_begin(nrf_802154_bsmap_t * p_bsmap,
313 bool forward);
314
326
336 void * p_key);
337
350 void * p_value);
351
366 const nrf_802154_bsmap_iterator_t * p_iter,
367 const void * p_value,
368 void * p_aux_memory);
369
382 void * p_aux_memory);
383
390
397
398#endif /* NRF_802154_BSMAP_H_ */
bool nrf_802154_bsmap_rec_delete(nrf_802154_bsmap_t *p_bsmap, const void *p_key, void *p_aux_memory)
Delete a record associated with a key from the BSMAP.
void nrf_802154_bsmap_iterator_finish(nrf_802154_bsmap_iterator_t *p_iter)
Finish the iteration over a BSMAP the iterator is bound to.
void nrf_802154_bsmap_iterator_rec_delete(nrf_802154_bsmap_iterator_t *p_iter, void *p_aux_memory)
Delete a record at given iterator.
bool nrf_802154_bsmap_iterator_is_valid(const nrf_802154_bsmap_iterator_t *p_iter)
Check if iterator points to an existing item in the BSMAP.
void nrf_802154_bsmap_iterator_next(nrf_802154_bsmap_iterator_t *p_iter)
Move the BSMAP iterator to the next position.
void nrf_802154_bsmap_iterator_rec_value_get(const nrf_802154_bsmap_iterator_t *p_iter, void *p_value)
Get the value part of record at given iterator.
void nrf_802154_bsmap_clear(nrf_802154_bsmap_t *p_bsmap)
Remove all entries from the BSMAP.
void nrf_802154_bsmap_iterator_rec_key_get(const nrf_802154_bsmap_iterator_t *p_iter, void *p_key)
Get the key part of record at given iterator.
void nrf_802154_bsmap_iterator_rec_value_write(const nrf_802154_bsmap_iterator_t *p_iter, const void *p_value, void *p_aux_memory)
Write the value part of record at given iterator.
void nrf_802154_bsmap_init(nrf_802154_bsmap_t *p_bsmap, size_t key_size, size_t value_size, size_t capacity, void *p_memory)
Initialize the BSMAP object.
bool nrf_802154_bsmap_rec_get(const nrf_802154_bsmap_t *p_bsmap, const void *p_key, void *p_value)
Search for a record associated with the key in the BSMAP and copy the associated value into p_value i...
void nrf_802154_bsmap_iterator_begin(nrf_802154_bsmap_t *p_bsmap, nrf_802154_bsmap_iterator_t *p_iter, bool forward)
Start iteration over the BSMAP.
bool nrf_802154_bsmap_rec_write(nrf_802154_bsmap_t *p_bsmap, const void *p_key, const void *p_value, void *p_aux_memory)
Write a record associated with a key into the BSMAP.
bool forward
Indicates if direction of iteration is forward.
Definition nrf_802154_bsmap.h:87
int32_t index
Index to an internal array.
Definition nrf_802154_bsmap.h:83
nrf_802154_bsmap_t * p_bsmap
Pointer to the BSMAP the iterator is iterating over.
Definition nrf_802154_bsmap.h:95
bool deleted
Indicates if entry at index has been deleted.
Definition nrf_802154_bsmap.h:91
Type of an iterator used to iterate over the BSMAP.
Definition nrf_802154_bsmap.h:79
nrfx_atomic_t entry_idx_in_aux
Index of the entry staged in p_aux_memory, or a sentinel when no entry is staged.
Definition nrf_802154_bsmap.h:138
uint16_t keys_count
Backing memory for all entries (each entry is key and value combined).
Definition nrf_802154_bsmap.h:128
uint16_t value_size
Size of each value associated with a key, in bytes.
Definition nrf_802154_bsmap.h:113
nrf_802154_bsmap_iterator_t * p_iter
Iterator registered for this map, or NULL when no iteration is active.
Definition nrf_802154_bsmap.h:148
uint16_t entry_size
Size of one stored entry (key and value combined), in bytes.
Definition nrf_802154_bsmap.h:118
void * p_memory
Pointer to a memory storage for entries.
Definition nrf_802154_bsmap.h:133
uint16_t key_size
Size of each key, in bytes.
Definition nrf_802154_bsmap.h:108
void * p_aux_memory
Pointer to a temporary buffer used while modifying entries.
Definition nrf_802154_bsmap.h:143
uint16_t capacity
Maximum number of entries the map can hold.
Definition nrf_802154_bsmap.h:123
Type of a structure holding the BSMAP object.
Definition nrf_802154_bsmap.h:104