MMgr v2.3.0
Zero-heap memory manager in C11. One borrowed buffer, carved by asserted offset.
Loading...
Searching...
No Matches
praet_descriptor.h
Go to the documentation of this file.
1/* MMgr - Copyright (C) 2026 Douglas Quigg (dstroy0) <dquigg123@gmail.com>
2 * SPDX-License-Identifier: AGPL-3.0-or-later OR LicenseRef-Commercial OR LicenseRef-Educational
3 *
4 * Every use falls under AGPL-3.0-or-later unless you hold explicit permission, which is either a
5 * negotiated commercial licensing contract or an educator's license issued to you personally.
6 */
7/**
8 * @file praet_descriptor.h
9 * @brief A transfer written down: where from, where to, how many bytes, how each address moves, and
10 * what runs after it.
11 * @author dstroy0 (Douglas Quigg) <dquigg123@gmail.com>
12 * @date 2026-09-01
13 *
14 * @note The shape three vendors already agree on. An ESP32 GDMA dma_descriptor_t, an i.MX RT eDMA
15 * TCD and a Zephyr dma_block_config each carry the same six things. Where from, where to, how
16 * much, how the addresses move, who holds it, and what is next. Three architectures, one
17 * descriptor.
18 * @note Descriptors link, and that is where the arrangements come from. Two whose next point at each
19 * other are ping-pong. One that points at itself is circular. A chain is scatter-gather. A next
20 * of NULL is one shot. No part has a ping-pong feature and neither does this.
21 * @note Who holds a descriptor is per descriptor and not per channel. A channel's own state is the
22 * quaternary core in its flag word, and that answers a different question. The core says what
23 * the channel does, and an owner says which link in the chain the engine is on.
24 * @note A peripheral end is an address that does not advance. Where that address is comes from the
25 * vendor's own header, which the compiler has already read. A caller names theirs and no
26 * number of any part appears in this tree.
27 */
28#ifndef MMGR_PRAET_DESCRIPTOR_H
29#define MMGR_PRAET_DESCRIPTOR_H
30
31/** @addtogroup mod_praet
32 * @{ */
33
35
36EMBED_BEGIN_DECLS
37
38/**
39 * @brief How an address behaves as a transfer runs.
40 *
41 * @note The one fact memcpy does not need. Memory to memory advances both sides. A peripheral is an
42 * address that stays where it is, and which side stays put makes a transfer a read or a
43 * write.
44 * @note Token ids, the same as the statuses and the regions. A mistyped name is an undeclared
45 * identifier that carries the name as written.
46 */
47typedef enum
48{
49 PRAET_ADDRESS_ADVANCES = 0, /**< The address moves on by the transfer width each step. */
50 PRAET_ADDRESS_FIXED = 1 /**< The address stays where it is, as a peripheral is. */
52
53/**
54 * @brief Bytes the engine moves in one step, the measure of everything else.
55 *
56 * @note Named in full for what it is. A transfer's offsets, its length and the boundary a recovery
57 * rounds to all count in this. So it is the measure and not a property beside the others.
58 * @note Carries the count itself, and so the assertions below divide a length by it
59 * and test an offset against it with no table in between.
60 * @note octetus and verbum are the tree's own words for a byte and a word, as in
61 * octetus_introitus_exitus and verba_scribo.
62 */
63typedef enum
64{
65 PRAET_MENSURA_OCTETUS = 1, /**< One byte a step. */
66 PRAET_MENSURA_SEMIVERBUM = 2, /**< Half a word a step. */
67 PRAET_MENSURA_VERBUM = 4 /**< A whole word a step. */
69
70/**
71 * @brief The largest measure this module knows about.
72 *
73 * @note Raise this with the addition of a wider step. The assertion on a descriptor's measure then
74 * stops a declaration of one that nothing here can carry.
75 */
76#define PRAET_MENSURA_MAXIMA PRAET_MENSURA_VERBUM
77
78/**
79 * @brief Which way a transfer walks the words it moves.
80 *
81 * @note Named in full, because a bare direction says nothing about what moves in it. This is the
82 * direction of the movement of the word, and the word is what the engine steps by.
83 * @note What memor already answers for a copy, and for the same reason. Where the two ends overlap,
84 * one direction reads words the other has already written over. Where they do not, neither
85 * direction is wrong and the engine takes whichever it likes.
86 * @note Settled once and then not asked again. Here it settles before anything runs, because both
87 * ends of a descriptor come from a declaration.
88 */
89typedef enum
90{
91 PRAET_MOTUS_NEUTRUM = 0, /**< Neither way. The ends do not overlap, and so nothing is at risk. */
92 PRAET_MOTUS_SURSUM = 1, /**< Upward, from the low word on, which is safe for a write downward. */
93 PRAET_MOTUS_DEORSUM = 2 /**< Downward, from the high word back, which is safe for a write upward. */
95
96/**
97 * @brief The direction of the movement of the word, for two spans of one pool.
98 *
99 * @param from_ Bytes into the pool the read starts at.
100 * @param to_ Bytes into the pool the write starts at.
101 * @param bytes_ Bytes moved.
102 * @return A DirectioMotusVerbi.
103 * @note Integers, and so this has its answer at compile time. Both spans are offsets into one declared
104 * object, and where they came from makes them comparable at all. Two addresses passed in as
105 * pointers would have no order at compile time. The language does not define a compare of
106 * pointers into separate objects.
107 * @note A write upward over a source means the high words must move first, and so the walk goes downward.
108 * A write downward is the mirror of it. Spans that start at the same place move nothing over
109 * anything and take neither.
110 */
111#define PRAET_DIRECTIO_MOTUS_VERBI_FOR(from_, to_, bytes_) \
112 ((((from_) < ((to_) + (bytes_))) && ((to_) < ((from_) + (bytes_))) && ((to_) != (from_))) \
113 ? (((to_) > (from_)) ? PRAET_MOTUS_DEORSUM : PRAET_MOTUS_SURSUM) \
114 : PRAET_MOTUS_NEUTRUM)
115
116/**
117 * @brief Who holds a descriptor.
118 *
119 * @note Per descriptor. An ESP32 descriptor calls this owner, an eDMA carries DONE and ACTIVE in its
120 * control word, and a Zephyr block config calls it busy. They are the same fact.
121 */
122typedef enum
123{
124 PRAET_OWNER_SOFTWARE = 0, /**< The program may read it and write it. */
125 PRAET_OWNER_ENGINE = 1 /**< The engine works from it, and it alone may touch it. */
127
128/**
129 * @brief One transfer, written down.
130 *
131 * @param source First byte read [BORROWS].
132 * @param destination First byte written [BORROWS].
133 * @param bytes How many bytes the transfer moves.
134 * @param next The descriptor that runs after this one, or NULL where nothing does
135 * [BORROWS].
136 * @param source_addressing Whether the source address advances, as a PraetAddressing.
137 * @param destination_addressing Whether the destination address advances.
138 * @param ego_sum_mensura Bytes moved in one step, as an EgoSumMensura. Every offset, every
139 * length and the boundary a recovery rounds to count in it.
140 * @param directio_motus_verbi Which way the words walk, as a DirectioMotusVerbi.
141 * @param owner Who holds it, as a PraetDescriptorOwner.
142 * @note Every field except owner settles at the declaration of the descriptor. A declaration emits it
143 * as initialized data, and so nothing runs to make one usable.
144 * @warning source and destination belong to whoever declared the pools they came from, and this holds
145 * neither. The declarator is what proves those pools exist and that the spans fit inside
146 * them.
147 */
148typedef struct PraetDescriptor PraetDescriptor;
149
151{
152 const uint8_t *source;
153 uint8_t *destination;
154 embed_word bytes;
155 PraetDescriptor *next;
156 uint8_t source_addressing;
157 uint8_t destination_addressing;
158 uint8_t ego_sum_mensura;
159 uint8_t directio_motus_verbi;
160 uint8_t owner;
161};
162
163/**
164 * @brief Fails the build where one end of a transfer does not sit whole steps inside its pool.
165 *
166 * @param what_ Text that names which end this is, for the message.
167 * @param pool_ Pool declared by ParsMemoriaeInternae or ParsMemoriaeExternum.
168 * @param offset_ Bytes into that pool the span starts at.
169 * @param bytes_ Bytes in the span.
170 * @param mensura_ Bytes the engine moves in one step.
171 * @note Three conditions in one assertion, because they fail for one reason and a caller at work on one
172 * wants to see the others. The span fits the pool, the offset lands on a step boundary, and the
173 * length is a whole number of steps.
174 * @note Static assertions, where PraetSubmit uses the expression form. A declarator is at file scope
175 * and a bare expression cannot sit there. The name of the end in the message is what
176 * replaces the member name the expression form prints.
177 * @warning Reads sizeof(mmgr_pars_storage_##pool_), and so it holds for a span whose offset, length and
178 * width are at compile time. Anything computed at run time has no bound from this and
179 * no bound anywhere else.
180 */
181#define PRAET_STEPS_FIT(what_, pool_, offset_, bytes_, mensura_) \
182 EMBED_STATIC_ASSERT(((offset_) + (bytes_)) <= sizeof(mmgr_pars_storage_##pool_), \
183 what_ " runs past the end of " #pool_); \
184 EMBED_STATIC_ASSERT(((offset_) % (mensura_)) == 0u, what_ " starts part way into a step of " #pool_); \
185 EMBED_STATIC_ASSERT(((bytes_) % (mensura_)) == 0u, what_ " is not a whole number of steps")
186
187/**
188 * @brief Declares one memory to memory transfer, and what runs after it.
189 *
190 * @param name_ Name of the descriptor.
191 * @param from_pool_ Pool the bytes come from.
192 * @param from_offset_ Bytes into that pool the read starts at.
193 * @param to_pool_ Pool the bytes go to.
194 * @param to_offset_ Bytes into that pool the write starts at.
195 * @param bytes_ Bytes to move.
196 * @param mensura_ Bytes moved in one step, as a EgoSumMensura.
197 * @param next_ The descriptor that runs after this one, or NULL.
198 * @note Both pools have names, and so both spans have a proof of fit before anything runs. Both
199 * addresses come from a declaration, and no caller states one. That is the same check
200 * PraetAttach makes, applied to each end.
201 * @note Both addresses advance, as memory to memory means. A side that stays put is a
202 * peripheral, and the name of one needs an address this has no way to take.
203 * @note Emitted as initialized data with the owner in software's passes. A descriptor the engine does
204 * not hold is one the program may still write.
205 * @note Two different pools are two separately declared objects, and so they cannot overlap and the
206 * direction settles as either. One pool at both ends collides on the enumerators this
207 * emits, because the two carry the same prefix and differ only by the pool. A transfer inside
208 * one pool is PraetDescriptorWithin, which has offsets it can compare.
209 * @warning direction_ appears here, and the two macros above this one derive it. A direct call
210 * here with the wrong answer is a transfer that reads bytes it already wrote over.
211 */
212#define PRAET_DESCRIPTOR_BODY(name_, source_, source_mode_, dest_, dest_mode_, bytes_, mensura_, motus_, next_) \
213 EMBED_STATIC_ASSERT((mensura_) <= (int)PRAET_MENSURA_MAXIMA, \
214 #name_ " asks for a step wider than anything this module carries"); \
215 EMBED_STATIC_ASSERT(((mensura_) & ((mensura_) - 1)) == 0, #name_ " asks for a step that is not a power of two"); \
216 static PraetDescriptor name_ EMBED_UNUSED = { \
217 .source = (source_), \
218 .destination = (dest_), \
219 .bytes = (embed_word)(bytes_), \
220 .next = (next_), \
221 .source_addressing = (uint8_t)(source_mode_), \
222 .destination_addressing = (uint8_t)(dest_mode_), \
223 .ego_sum_mensura = (uint8_t)(mensura_), \
224 .directio_motus_verbi = (uint8_t)(motus_), \
225 .owner = (uint8_t)PRAET_OWNER_SOFTWARE, \
226 }
227
228/**
229 * @brief Declares one memory to memory transfer, and what runs after it.
230 *
231 * @param name_ Name of the descriptor.
232 * @param from_pool_ Pool the bytes come from.
233 * @param from_offset_ Bytes into that pool the read starts at.
234 * @param to_pool_ Pool the bytes go to.
235 * @param to_offset_ Bytes into that pool the write starts at.
236 * @param bytes_ Bytes to move.
237 * @param mensura_ Bytes moved in one step, as a EgoSumMensura.
238 * @param motus_ Which way the words walk, as a DirectioMotusVerbi.
239 * @param next_ The descriptor that runs after this one, or NULL.
240 */
241#define PraetDescriptorDeclare(name_, from_pool_, from_offset_, to_pool_, to_offset_, bytes_, mensura_, motus_, next_) \
242 PRAET_STEPS_FIT(#name_ " reading from " #from_pool_, from_pool_, from_offset_, bytes_, mensura_); \
243 PRAET_STEPS_FIT(#name_ " writing to " #to_pool_, to_pool_, to_offset_, bytes_, mensura_); \
244 PRAET_DESCRIPTOR_BODY(name_, &mmgr_pars_storage_##from_pool_[from_offset_], PRAET_ADDRESS_ADVANCES, \
245 &mmgr_pars_storage_##to_pool_[to_offset_], PRAET_ADDRESS_ADVANCES, bytes_, mensura_, motus_, \
246 next_)
247
248/**
249 * @brief Fails the build where a transfer between two pools names one pool twice.
250 *
251 * @param name_ Name of the descriptor this belongs to.
252 * @param from_pool_ Pool the bytes come from.
253 * @param to_pool_ Pool the bytes go to.
254 * @note Two enumerators with one prefix that differ only by the pool. So one pool at both ends
255 * declares the same enumerator twice in one enum and the compiler refuses it. The same idiom
256 * MMGR_PARS_CLAIMED_ONCE uses, applied to a pair.
257 * @note The compiler refuses this for a reason: the direction a transfer between two pools takes settles as either.
258 * That answer is only true because two declared pools are two objects. One pool at both
259 * ends can overlap itself, and PraetDescriptorWithin is what has the offsets to work that out.
260 */
261#define PRAET_DESCRIPTOR_ENDS_DIFFER(name_, from_pool_, to_pool_) \
262 enum \
263 { \
264 name_##_end_##from_pool_ = 1, \
265 name_##_end_##to_pool_ = 2 \
266 }
267
268/**
269 * @brief Declares one transfer that runs once and stops.
270 *
271 * @param name_ Name of the descriptor.
272 * @param from_pool_ Pool the bytes come from.
273 * @param from_offset_ Bytes into that pool the read starts at.
274 * @param to_pool_ Pool the bytes go to.
275 * @param to_offset_ Bytes into that pool the write starts at.
276 * @param bytes_ Bytes to move.
277 * @param mensura_ Bytes moved in one step.
278 * @note A next of NULL, the entirety of of what makes a transfer one shot.
279 */
280#define PraetOneShot(name_, from_pool_, from_offset_, to_pool_, to_offset_, bytes_, mensura_) \
281 PRAET_DESCRIPTOR_ENDS_DIFFER(name_, from_pool_, to_pool_); \
282 PraetDescriptorDeclare(name_, from_pool_, from_offset_, to_pool_, to_offset_, bytes_, mensura_, \
283 PRAET_MOTUS_NEUTRUM, NULL)
284
285/**
286 * @brief Declares one transfer that moves bytes inside a single pool, and works out which way.
287 *
288 * @param name_ Name of the descriptor.
289 * @param pool_ Pool both ends sit in.
290 * @param from_offset_ Bytes into that pool the read starts at.
291 * @param to_offset_ Bytes into that pool the write starts at.
292 * @param bytes_ Bytes to move.
293 * @param mensura_ Bytes moved in one step, as a EgoSumMensura.
294 * @param next_ The descriptor that runs after this one, or NULL.
295 * @note Where the two spans overlap, the direction retains the transfer from reads of bytes it
296 * already wrote over. The offsets settle it here, once, and nothing asks again: a run of
297 * this descriptor has the answer in front of it.
298 * @note Both spans are offsets into one declared object, and that leaves them comparable at all.
299 * The same question about two pointers would have no answer at compile time. The language
300 * does not define a compare of pointers into separate objects.
301 */
302#define PraetDescriptorWithin(name_, pool_, from_offset_, to_offset_, bytes_, mensura_, next_) \
303 PraetDescriptorDeclare(name_, pool_, from_offset_, pool_, to_offset_, bytes_, mensura_, \
304 PRAET_DIRECTIO_MOTUS_VERBI_FOR(from_offset_, to_offset_, bytes_), next_)
305
306/**
307 * @brief Declares one transfer that runs itself again, forever.
308 *
309 * @param name_ Name of the descriptor.
310 * @param from_pool_ Pool the bytes come from.
311 * @param from_offset_ Bytes into that pool the read starts at.
312 * @param to_pool_ Pool the bytes go to.
313 * @param to_offset_ Bytes into that pool the write starts at.
314 * @param bytes_ Bytes to move.
315 * @param mensura_ Bytes moved in one step.
316 * @note A descriptor whose next is itself. This defines circular, and no part has a feature
317 * called that either.
318 * @note The forward declaration ahead of it is a tentative definition, which C merges with the real
319 * one below. It lets the initializer name an address the declaration still writes.
320 */
321#define PraetCircular(name_, from_pool_, from_offset_, to_pool_, to_offset_, bytes_, mensura_) \
322 PRAET_DESCRIPTOR_ENDS_DIFFER(name_, from_pool_, to_pool_); \
323 static PraetDescriptor name_; \
324 PraetDescriptorDeclare(name_, from_pool_, from_offset_, to_pool_, to_offset_, bytes_, mensura_, \
325 PRAET_MOTUS_NEUTRUM, &name_)
326
327/**
328 * @brief Declares two transfers that hand off to each other, forever.
329 *
330 * @param first_ Name of the first descriptor.
331 * @param second_ Name of the second descriptor.
332 * @param from_pool_ Pool both transfers read from.
333 * @param to_pool_ Pool both transfers write to.
334 * @param first_from_ Bytes into the source pool the first transfer reads at.
335 * @param first_to_ Bytes into the destination pool the first transfer writes at.
336 * @param second_from_ Bytes into the source pool the second transfer reads at.
337 * @param second_to_ Bytes into the destination pool the second transfer writes at.
338 * @param bytes_ Bytes each transfer moves.
339 * @param mensura_ Bytes moved in one step.
340 * @note Ping-pong, and it is two descriptors whose next point at each other. Nothing here is a mode
341 * and no part has a bit for it. The two write different halves, and that is what makes it a
342 * pair and not one transfer twice. The halves are the caller's to arrange by the offsets they pass.
343 * @note Both spans have their proofs against their pools apart. A pair whose halves overlap or run
344 * off the end fails at the declaration that wrote it.
345 */
346#define PraetPingPong(first_, second_, from_pool_, to_pool_, first_from_, first_to_, second_from_, second_to_, bytes_, \
347 mensura_) \
348 PRAET_DESCRIPTOR_ENDS_DIFFER(first_, from_pool_, to_pool_); \
349 PRAET_DESCRIPTOR_ENDS_DIFFER(second_, from_pool_, to_pool_); \
350 static PraetDescriptor second_; \
351 PraetDescriptorDeclare(first_, from_pool_, first_from_, to_pool_, first_to_, bytes_, mensura_, \
352 PRAET_MOTUS_NEUTRUM, &second_); \
353 PraetDescriptorDeclare(second_, from_pool_, second_from_, to_pool_, second_to_, bytes_, mensura_, \
354 PRAET_MOTUS_NEUTRUM, &first_)
355
356/**
357 * @brief Declares one peripheral register a transfer may reach.
358 *
359 * @param name_ Name of the peripheral.
360 * @param address_ Where the register is, as the vendor's own header gives it.
361 * @note The address is not this library's to know and it is not the caller's to invent. Every part
362 * ships a header that names its registers, the compiler read it, and what a caller writes here
363 * is that name. An ESP32 reaches one through its GDMA peripheral struct, an i.MX RT through
364 * LPUART1->DATA, and neither number appears in this tree.
365 * @note Emits a pointer under a mangled name and an enumerator that carries the peripheral's. A
366 * descriptor that names a peripheral pastes onto both. Anything with no declaration here fails
367 * on a name nobody wrote. The same proof a pool gives, for a thing that has no extent.
368 * @note volatile, because something other than this program reads and writes a register. A compiler
369 * that cached one would read a value the part left behind.
370 * @warning No extent, the point. A peripheral is one address that stays where it is. So there is
371 * nothing for a span check to measure, and the pool at its other end alone bounds a
372 * transfer's length.
373 */
374#define PraetPeripheralDeclare(name_, address_) \
375 static volatile uint8_t *const mmgr_praet_peripheral_##name_ EMBED_UNUSED = (volatile uint8_t *)(address_); \
376 enum \
377 { \
378 name_##_is_a_declared_peripheral = 1 \
379 }
380
381/**
382 * @brief Declares one transfer that reads a pool and writes a peripheral.
383 *
384 * @param name_ Name of the descriptor.
385 * @param from_pool_ Pool the bytes come from.
386 * @param from_offset_ Bytes into that pool the read starts at.
387 * @param peripheral_ Peripheral declared by PraetPeripheralDeclare.
388 * @param address_ Base of that peripheral, stated again here as the vendor's own name.
389 * @param at_offset_ Bytes into the peripheral block the transfer writes at.
390 * @param bytes_ Bytes to move.
391 * @param mensura_ Bytes moved in one step, as a EgoSumMensura.
392 * @param next_ The descriptor that runs after this one, or NULL.
393 * @note The source advances and the destination stays where it is. This alone makes a
394 * transfer a write to a peripheral, and it is the single one fact memcpy never needs.
395 * @note Neither way to walk. A pool and a register are not the same object, and a transfer
396 * between them cannot read what it wrote.
397 * @note The address appears at the declaration and again here, and that is how PraetSubmit
398 * already treats a pool. The pool appears a second time so the extent comes from the
399 * declaration and not from a carried value. The enumerator below is the lock and this expression
400 * is the key.
401 * @note The second statement is also what retains the initializer legal. An address constant plus an
402 * integer constant is still an address constant. The value read out of the pointer
403 * PraetPeripheralDeclare emits is not one at all, whatever a given compiler folds.
404 * @warning A base plus an offset, and so one declared peripheral covers every register in its block.
405 * Nothing here bounds the offset, because a peripheral has no extent to measure against.
406 */
407#define PraetToPeripheral(name_, from_pool_, from_offset_, peripheral_, address_, at_offset_, bytes_, mensura_, next_) \
408 PRAET_STEPS_FIT(#name_ " reading from " #from_pool_, from_pool_, from_offset_, bytes_, mensura_); \
409 PRAET_DESCRIPTOR_BODY(name_, &mmgr_pars_storage_##from_pool_[from_offset_], PRAET_ADDRESS_ADVANCES, \
410 ((uint8_t *)(address_) + (at_offset_)), PRAET_ADDRESS_FIXED, bytes_, mensura_, \
411 PRAET_MOTUS_NEUTRUM, next_); \
412 enum \
413 { \
414 name_##_writes_##peripheral_ = peripheral_##_is_a_declared_peripheral \
415 }
416
417/**
418 * @brief Declares one transfer that reads a peripheral and writes a pool.
419 *
420 * @param name_ Name of the descriptor.
421 * @param peripheral_ Peripheral declared by PraetPeripheralDeclare.
422 * @param address_ Base of that peripheral, stated again here as the vendor's own name.
423 * @param at_offset_ Bytes into the peripheral block the transfer reads at.
424 * @param to_pool_ Pool the bytes go to.
425 * @param to_offset_ Bytes into that pool the write starts at.
426 * @param bytes_ Bytes to move.
427 * @param mensura_ Bytes moved in one step, as a EgoSumMensura.
428 * @param next_ The descriptor that runs after this one, or NULL.
429 * @note The mirror of PraetToPeripheral. The source stays where it is and the destination advances,
430 * and that leaves a transfer a read from a peripheral.
431 * @note The address appears at the declaration and again here, for the reasons written out
432 * over PraetToPeripheral.
433 */
434#define PraetFromPeripheral(name_, peripheral_, address_, at_offset_, to_pool_, to_offset_, bytes_, mensura_, next_) \
435 PRAET_STEPS_FIT(#name_ " writing to " #to_pool_, to_pool_, to_offset_, bytes_, mensura_); \
436 PRAET_DESCRIPTOR_BODY(name_, ((const uint8_t *)(address_) + (at_offset_)), PRAET_ADDRESS_FIXED, \
437 &mmgr_pars_storage_##to_pool_[to_offset_], PRAET_ADDRESS_ADVANCES, bytes_, mensura_, \
438 PRAET_MOTUS_NEUTRUM, next_); \
439 enum \
440 { \
441 name_##_reads_##peripheral_ = peripheral_##_is_a_declared_peripheral \
442 }
443
444/**
445 * @brief Counts the descriptors a chain reaches before it repeats or ends.
446 *
447 * @param[in] first First descriptor in the chain [BORROWS].
448 * @param[in] limit How many links to follow before the walk stops.
449 * @return Descriptors reached, or @p limit where the chain is longer than that.
450 * @note What tells a one shot from a cycle and does not follow a cycle forever. A chain that ends
451 * returns its length; a chain that closes returns the number of distinct descriptors in it.
452 * @note Walks by pointer identity against the first descriptor alone. So it names a cycle that
453 * returns to the head and not one that closes further along. A chain that loops back to its
454 * middle reaches the limit, the honest answer for a walk that cannot see where it is.
455 */
456EMBED_HOST_DEVICE embed_word praet_descriptor_chain_length(const PraetDescriptor *first, embed_word limit);
457
458EMBED_END_DECLS
459
460/** @} */
461
462#endif
EMBED_HOST_DEVICE embed_word praet_descriptor_chain_length(const PraetDescriptor *first, embed_word limit)
Counts the descriptors a chain reaches before it repeats or ends.
EgoSumMensura
Bytes the engine moves in one step, the measure of everything else.
DirectioMotusVerbi
Which way a transfer walks the words it moves.
PraetDescriptorOwner
Who holds a descriptor.
PraetAddressing
How an address behaves as a transfer runs.
@ PRAET_MENSURA_VERBUM
@ PRAET_MENSURA_SEMIVERBUM
@ PRAET_MENSURA_OCTETUS
@ PRAET_MOTUS_DEORSUM
@ PRAET_MOTUS_SURSUM
@ PRAET_MOTUS_NEUTRUM
@ PRAET_OWNER_SOFTWARE
@ PRAET_OWNER_ENGINE
@ PRAET_ADDRESS_FIXED
@ PRAET_ADDRESS_ADVANCES
The schedule context: one flag word per channel, the two volatiles that coordinate the interrupt,...
One transfer, written down.