28#ifndef MMGR_PRAET_DESCRIPTOR_H
29#define MMGR_PRAET_DESCRIPTOR_H
76#define PRAET_MENSURA_MAXIMA PRAET_MENSURA_VERBUM
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)
152 const uint8_t *source;
153 uint8_t *destination;
156 uint8_t source_addressing;
157 uint8_t destination_addressing;
158 uint8_t ego_sum_mensura;
159 uint8_t directio_motus_verbi;
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")
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_), \
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, \
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_, \
261#define PRAET_DESCRIPTOR_ENDS_DIFFER(name_, from_pool_, to_pool_) \
264 name_##_end_##from_pool_ = 1, \
265 name_##_end_##to_pool_ = 2 \
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)
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_)
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_)
346#define PraetPingPong(first_, second_, from_pool_, to_pool_, first_from_, first_to_, second_from_, second_to_, bytes_, \
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_)
374#define PraetPeripheralDeclare(name_, address_) \
375 static volatile uint8_t *const mmgr_praet_peripheral_##name_ EMBED_UNUSED = (volatile uint8_t *)(address_); \
378 name_##_is_a_declared_peripheral = 1 \
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_); \
414 name_##_writes_##peripheral_ = peripheral_##_is_a_declared_peripheral \
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_); \
441 name_##_reads_##peripheral_ = peripheral_##_is_a_declared_peripheral \
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_SEMIVERBUM
The schedule context: one flag word per channel, the two volatiles that coordinate the interrupt,...
One transfer, written down.