-
Notifications
You must be signed in to change notification settings - Fork 0
Feat/mdma packet #540
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
FoniksFox
wants to merge
155
commits into
development
Choose a base branch
from
feat/MdmaPacket2
base: development
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+296
−9
Open
Feat/mdma packet #540
Changes from all commits
Commits
Show all changes
155 commits
Select commit
Hold shift + click to select a range
384e079
feat(MdmaPacket): Implement API and base structure, lacks integration…
FoniksFox e57cee7
feat(MdmaPacket): Drop support for containers and add mdma instance a…
FoniksFox 3c79d80
feat(MdmaPacket): Now can specify Mdma instance
FoniksFox 14fe90b
feat(MdmaPacket): MDMA manages buffers, can now change mdma instance
FoniksFox 0f96017
Fist draft of the MDMA
Cantonplas 714eeaa
Some fixes, there are some problems with linking i think
Cantonplas 31ac058
Second draft of the mdma, now creates linked list (I think?)
Cantonplas 5adf7d4
Fixed some stuff :)
Cantonplas b1cd562
More changes, i think the api is finally done (hope so)
Cantonplas 06fa58c
More changes, this fucking sucks
Cantonplas 6d527ee
feat(Promises): Add Arena memory pool implementation
FoniksFox 4d94ea3
fix(Primises): Remove move semantics from Arena class, since they can…
FoniksFox f676757
feat(Promises): Implement Promises with fixed-size arenas
FoniksFox 4c40984
chore(Promises): Add Promises to HALAL.
FoniksFox b4df6ca
fix(Promises): Fix circular dependency and incorrect RingBuffer usage
FoniksFox 7b775b0
fix(Promises): Fix possible race condition in destroy method
FoniksFox fb50fe3
fix(Promises): Fix all and any methods to check correctly for existin…
FoniksFox fa61a28
Merge branch 'feat/Promises' of https://github.com/HyperloopUPV-H8/ST…
FoniksFox 56912d3
style(Promises): Double free detection in Arena is now in another if
FoniksFox 0771a11
fix(Promises): Use atomic operations for isResolved flag
FoniksFox 8e2297c
fix(Promises): Add critical sections and maximum updates per cycle
FoniksFox 93e8c7a
MDMA v1.0 baby
Cantonplas ffa7ebc
Merge remote-tracking branch 'origin/feat/Promises' into feat/MDMA
Cantonplas ee32863
Merged the promises, testing on course
Cantonplas 2749970
fix(Promises): Revert mistake change in sntp_opts.h in commit b4df6ca…
FoniksFox 440bcec
Fixes
Cantonplas abd7dec
style(Promises): Make maximums overwrittable in Promises.hpp
FoniksFox d74809a
fix(Promises): Ensure no memroy leaks in Promise::all and Promise::any
FoniksFox c078faf
fix(Promises): Disable interrupts when adding to ready list
FoniksFox 7101a17
fix(Promises): Remove Promise::update() from HALAL::start()
FoniksFox bc7b36f
feat(Promises): Add Stack class utility, doesn't use heap
FoniksFox 930c31f
feat(Promises): Use Stack for Arena (better locality), and add iterat…
FoniksFox 0fd30a8
Merge branch 'feat/Promises' of https://github.com/HyperloopUPV-H8/ST…
FoniksFox 17de1f9
feat(Promises): Update Promises handling to avoid synchronization iss…
FoniksFox f86c7ab
fix(Promises): Defer release of chained promises in update method
FoniksFox 132960d
fix(Promises): Defer chained promise cleanup to update
FoniksFox 881d87a
Packets now work, merge_packets now on progress
Cantonplas 9f5a3d2
Merge remote-tracking branch 'origin/feat/Promises' into feat/MDMA
Cantonplas 9937ec5
Promises to be tested, the rest works just fine :p
Cantonplas 3717503
Now checking if the mdma_id exists
Cantonplas a7f1408
Copy paste typo, oops
Cantonplas ea8d642
Now using array for the instances instead of unordered_maps
Cantonplas 7009edb
feat(Promises): Improve Stack
FoniksFox dd26669
style(Promises): rename Arena to Pool and apply some style fixes
FoniksFox 8415bb1
fix(Promises): Fix Pool pointer checing
FoniksFox bd3eb7f
feat(Promises): Fix Stack naming collision
FoniksFox 9e3ccb7
feat(Promises): Use bitset in Pool. Not using bitmap to allow larger …
FoniksFox 5a0bf6c
chore(Promises): Add Stack and Pool to CppUtils
FoniksFox 45df687
fix(Promises): Change naming in Promises to acutally use Pool, instea…
FoniksFox 7894b59
fix(Promises): Bug fixes and changes in the releasing to ensure prope…
FoniksFox 97db984
Merge branch 'development' into feat/Promises
FoniksFox bfb28ad
fix(Promises): Avoid unnecessary copies of elements in Stack
FoniksFox bf03a1e
fix(Promises): Fix pointer arithmetic in Pool
FoniksFox 69a0970
doc(Promises): Add some better comments in Promise
FoniksFox bede8e6
feat(Promises): Add null checks in Promise chaining and combinators
FoniksFox 5f89522
fix(Promises): Fix signed and unsigned comparison in Pool
FoniksFox 2ce52cb
feat(Promises): Add optimized bitmap iteration for Pool class when S …
FoniksFox 52cbec9
feat(Promises): Add Promise::update() call in ST-LIB main update loop
FoniksFox 6ebb5ab
fix(Promises): Include Promises header in HALAL.hpp whith SIM_ON
FoniksFox 866a39c
feat(Promises): Add wait() method for easier busy-waiting, to use onl…
FoniksFox 37acef8
Merge branch 'feat/Promises' into feat/MdmaPacket
FoniksFox 015093a
Merge remote-tracking branch 'origin/feat/MDMA' into feat/MdmaPacket
FoniksFox 4498203
Merge remote-tracking branch 'origin/development' into feat/MdmaPacket
FoniksFox 4fb9c67
refactor(MdmaPacket): Make MdmaPacket inherit directly from Packet an…
FoniksFox 38fafa4
chore(MdmaPacket): Add MdmaPacket to HALAL
FoniksFox e2af8c5
Initial structure
jorgesg82 3eec305
no need to have an id for instance
jorgesg82 adb6ccd
Merge branch 'feat/Promises' into MDMA-linked-list-proposal
FoniksFox 644c34e
feat(MDMA)!: Make MDMA use a pool of linked list nodes managed extern…
FoniksFox 257c199
Merge remote-tracking branch 'origin/development' into MDMA-linked-li…
FoniksFox e870d55
fix(MDMA): Fix bugs with instance
FoniksFox ef95c66
fix(MDMA): Too many linked list nodes, not enough memory
FoniksFox fa3498b
erased no longer needed code
jorgesg82 343c100
Merge branch 'feat/MdmaPacket' into MDMA-linked-list-proposal
FoniksFox c92a738
Added DigitalInput and DigitalOutput Services, and added support for …
jorgesg82 42df50f
feat(MdmaPacket): Make MdmaPacket compatible with MDMA linked list tr…
FoniksFox db7596c
fix(MDMA): Fixes
FoniksFox 9dc516b
Replaced throw by undefined function
jorgesg82 d9263fe
Implemented alternate functions
jorgesg82 4cd2796
Added linker script and startup code, and fixed using hal template conf
jorgesg82 25edffc
Working on making the mdma work
Cantonplas 79bbcd5
Still not working the mdma packets
Cantonplas ee27a82
Esto es peor que el sida de testear
Cantonplas 61d4f34
Work to be done, the auxilary buffer recieves data but crashes when i…
Cantonplas 6571b3b
Oops forgot to comment a thing :p
Cantonplas 5ab710e
Now working yipeee
Cantonplas c4748dd
Added initial GPIO mock
jorgesg82 922379c
mdma V2.0
Cantonplas be515a2
Some errors fixed
Cantonplas 815ba89
Cosas
Cantonplas c440540
feat(MPU): Initial structure && design of the API
FoniksFox 3286140
fix(MPU): Bug fixing (MPU subregion calculation, throws and alignment…
FoniksFox 755fd4b
fix(MPU): Minor bug fixes (missing std::, incorrect subregion mask)
FoniksFox 1b5c8fe
feat(MPU): Initial implementation of MPUManager refactor
FoniksFox ed0a65a
feat(MPU)!: Bug fixing and changes on the infrastructure to allow pro…
FoniksFox aa7dddc
reafactor(MPU): Support legacy MPUManager without conflicts
FoniksFox 3f826bd
fix(MPU): Remove MPUManager start call from HALAL init
FoniksFox 6c28294
feat(MPU): Modify linker scripts for MPU configuration
FoniksFox 4352de3
fix(MPU): Remove legacy things
FoniksFox 5d0dbd0
fix(MPU): Fix legacy MPUManager
FoniksFox a365558
fix(MPU): Fix no buffer array of size zero issue
FoniksFox d40a213
fix(MPU): Fix ST-LIB so that it accepts templated objects for MPU buf…
FoniksFox 6e8eac8
feat(MPU): Add concepts and safer interface
FoniksFox f0f99ec
feat(MPU): Make construct method return a reference instead of pointer
FoniksFox 6410c72
fix(MPU): Relax constraints on MPU buffers to allow trivially destruc…
FoniksFox 2a291dc
style(MPU): Better wording and documentation
FoniksFox 846d52d
feat(MPU): Make MPU ultra restrictive, should check that there's no r…
FoniksFox 76f1df8
Changed Promise to bool pointer, and now working properly
Cantonplas 7ccf5dc
Deleted promises and mdma packets from this branch
Cantonplas daf47b9
Now it compiles oops :p
Cantonplas 3bae59f
Some suggested changed changes donde, ty clanker
Cantonplas 80d49aa
Update Src/HALAL/Models/MDMA/MDMA.cpp
Cantonplas cd37953
Forgot to add the false condition to the data transfer
Cantonplas 0913ba2
Damn
Cantonplas 67f5322
Coño con los conflictos
Cantonplas fc698f6
Merge branch 'refactor/MPUManager' into feat/MdmaPacket2
FoniksFox 904b815
Fix condition to check if instance.done is not null, now it generates…
Cantonplas d07302d
feat(MdmaPacket): Implement MdmaPacket
FoniksFox 6760c3b
fix(MdmaPacket): Small fixes
FoniksFox 6643561
MDMA packet bug fixed, now if you change the destination the bus will…
Cantonplas 9a27d73
Merge remote-tracking branch 'origin/feat/MDMA2' into feat/MdmaPacket2
FoniksFox 6829a60
fix(MdmaPacket): Fix alignment issues
FoniksFox 4b44df6
fix(MdmaPacket): Small fixes
FoniksFox 9bb3aa8
fix(MDMA): Small fixes to MDMA
FoniksFox 20d2b63
Merge branch 'development' into refactor/MPUManager
FoniksFox 291fca4
Change MDMA node alignment and transfer settings
Cantonplas f4f754f
Merge remote-tracking branch 'origin/feat/MDMA2' into feat/MdmaPacket2
FoniksFox ad4bda0
fixed getting wrong instance
jorgesg82 328cca0
marked indexs as mutable
jorgesg82 285ee2c
Merge remote-tracking branch 'origin/fix/compile-infrastructure' into…
FoniksFox 804e7b9
fix(MPU): Implemente st-lib fix
FoniksFox 3063a02
Merge branch 'refactor/MPUManager' into feat/MdmaPacket2
FoniksFox b724892
fix(MPU): Fix merge
FoniksFox 13f048f
feat(MdmaPacket): Add a MdmaPacketBase
FoniksFox 2188ccb
Remove NODES_MAX definition from MDMA.hpp
Cantonplas f27035c
Fixed instance_of method. Now add interface needs the Device
jorgesg82 7250221
Merge branch 'fix/compile-infrastructure' into refactor/MPUManager
FoniksFox ae95584
fix(MPU): Apply the fix of the fix
FoniksFox 7d03281
fix(MdmaPacket): Fix something went wrong somewhere in a merge
FoniksFox 9963e1a
Merge branch 'refactor/MPUManager' into feat/MdmaPacket2
FoniksFox 7ee058f
fix(MdmaPacket): Apply the fix of the fix
FoniksFox fd1e579
fix(MdmaPacket): Fix merge things that went wrong
FoniksFox 59cac34
Now it compiles jeje
Cantonplas 33bb954
fix(MPU): Make the MPUManager take it's buffer pointer from a linker …
FoniksFox b6c2c43
Merge remote-tracking branch 'origin/feat/MDMA2' into feat/MdmaPacket2
FoniksFox 8342e73
Merge branch 'refactor/MPUManager' into feat/MdmaPacket2
FoniksFox c434028
style(MdmaPacket): Forgot to rename a @param
FoniksFox 7d67f07
style(MdmaPacket): Fix typo
FoniksFox 42a3b99
style(MPU): Remove comment
FoniksFox a138ed2
Merge branch 'refactor/MPUManager' into feat/MdmaPacket2
FoniksFox 447466d
Merge remote-tracking branch 'origin/development' into feat/MdmaPacket2
FoniksFox 7eaaa01
feat(MdmaPacket): Move id to non-cached memory
FoniksFox 89bb95b
fix(MDMA): Correct bus selection based on address ranges
FoniksFox 2383b8d
feat(MDMA): Add alignment handling for nodes
FoniksFox e31f44d
chore(MdmaPacket): Undo changes that are not relevant to the pr
FoniksFox File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,274 @@ | ||
| /* | ||
| * MdmaPacket.hpp | ||
| * | ||
| * Created on: 06 nov. 2025 | ||
| * Author: Boris | ||
| */ | ||
|
|
||
| #ifndef MDMA_PACKET_HPP | ||
| #define MDMA_PACKET_HPP | ||
|
|
||
| #include "HALAL/Models/Packets/Packet.hpp" | ||
| #include "HALAL/Models/MDMA/MDMA.hpp" | ||
| #include "HALAL/Models/MPUManager/MPUManager.hpp" | ||
| #include "HALAL/Models/MPU.hpp" | ||
| #include "C++Utilities/CppImports.hpp" | ||
|
|
||
| #ifndef MDMA_PACKET_MAX_INSTANCES | ||
| #define MDMA_PACKET_MAX_INSTANCES 50 | ||
| #endif | ||
|
|
||
| struct MdmaPacketDomain { | ||
| struct Entry { | ||
| size_t packet_mpu_index; | ||
| size_t nodes_mpu_index; | ||
| size_t id_mpu_index; | ||
| }; | ||
|
|
||
| struct Config { | ||
| size_t packet_mpu_index; | ||
| size_t nodes_mpu_index; | ||
| size_t id_mpu_index; | ||
| }; | ||
|
|
||
| struct Instance { | ||
| uint8_t* packet_buffer; | ||
| MDMA::LinkedListNode* nodes; | ||
| uint16_t* id; | ||
| }; | ||
|
|
||
| static constexpr size_t max_instances = MDMA_PACKET_MAX_INSTANCES; | ||
|
|
||
| template <std::size_t N> | ||
| static consteval std::array<Config, N> build(std::span<const Entry> entries) { | ||
| std::array<Config, N> cfgs{}; | ||
| for (std::size_t i = 0; i < N; i++) { | ||
| cfgs[i].packet_mpu_index = entries[i].packet_mpu_index; | ||
| cfgs[i].nodes_mpu_index = entries[i].nodes_mpu_index; | ||
| cfgs[i].id_mpu_index = entries[i].id_mpu_index; | ||
| } | ||
| return cfgs; | ||
| } | ||
|
|
||
| template <std::size_t N> | ||
| struct Init { | ||
| static inline std::array<Instance, N> instances{}; | ||
|
|
||
| template <std::size_t MPU_N> | ||
| static void init(const std::array<Config, N>& cfgs, std::array<MPUDomain::Instance, MPU_N>& mpu_instances) { | ||
| for (std::size_t i = 0; i < N; i++) { | ||
| instances[i].packet_buffer = static_cast<uint8_t*>(mpu_instances[cfgs[i].packet_mpu_index].ptr); | ||
| instances[i].nodes = static_cast<MDMA::LinkedListNode*>(mpu_instances[cfgs[i].nodes_mpu_index].ptr); | ||
| instances[i].id = static_cast<uint16_t*>(mpu_instances[cfgs[i].id_mpu_index].ptr); | ||
| } | ||
| } | ||
| }; | ||
|
|
||
| /** | ||
| * @brief A Packet class that uses MDMA for building and parsing packets. | ||
| * @tparam Types The types of the values in the packet. | ||
| * @note It uses non-cached memory for MDMA operations. | ||
| */ | ||
| class MdmaPacketBase : public Packet { | ||
| public: | ||
| virtual uint8_t* build(bool* done, uint8_t* destination_address = nullptr) = 0; | ||
| using Packet::build; | ||
| }; | ||
|
|
||
| template<class... Types> | ||
| class MdmaPacket : public MdmaPacketBase { | ||
| public: | ||
| uint16_t* id; | ||
| uint8_t* buffer; | ||
| size_t size; | ||
| std::tuple<uint16_t*, Types*...> value_pointers; | ||
|
|
||
| MdmaPacket(const MdmaPacket&) = delete; | ||
| MdmaPacket& operator=(const MdmaPacket&) = delete; | ||
|
|
||
| struct Request { | ||
| using domain = MdmaPacketDomain; | ||
|
|
||
| static constexpr size_t packet_size_bytes = (sizeof(Types) + ...) + sizeof(uint16_t); | ||
| static constexpr size_t nodes_size = (2 * (sizeof...(Types) + 1) + 2); | ||
|
|
||
| using PacketMem = std::array<uint8_t, packet_size_bytes>; | ||
| using NodesMem = std::array<MDMA::LinkedListNode, nodes_size>; | ||
| using IdMem = uint16_t; | ||
|
|
||
| MPUDomain::Buffer<PacketMem> packet_req; | ||
| MPUDomain::Buffer<NodesMem> nodes_req; | ||
| MPUDomain::Buffer<IdMem> id_req; | ||
|
|
||
| consteval Request() : | ||
| packet_req(MPUDomain::MemoryType::NonCached, MPUDomain::MemoryDomain::D1), | ||
| nodes_req(MPUDomain::MemoryType::NonCached, MPUDomain::MemoryDomain::D1), | ||
| id_req(MPUDomain::MemoryType::NonCached, MPUDomain::MemoryDomain::D1) | ||
| {} | ||
|
|
||
| template <class Ctx> | ||
| consteval void inscribe(Ctx &ctx) const { | ||
| size_t p_idx = packet_req.inscribe(ctx); | ||
| size_t n_idx = nodes_req.inscribe(ctx); | ||
| size_t i_idx = id_req.inscribe(ctx); | ||
| ctx.template add<MdmaPacketDomain>({p_idx, n_idx, i_idx}, this); | ||
| } | ||
| }; | ||
|
|
||
| MdmaPacket(Instance& instance, uint16_t id, Types*... values) | ||
| : id(instance.id), size((sizeof(Types) + ...) + sizeof(uint16_t)) , value_pointers(this->id, values...) { | ||
|
|
||
| *this->id = id; | ||
| packets[*this->id] = this; | ||
| this->buffer = instance.packet_buffer; | ||
| MDMA::LinkedListNode* nodes = instance.nodes; | ||
|
|
||
| MDMA::LinkedListNode* prev_node = nullptr; | ||
| uint32_t offset = 0; | ||
| uint32_t idx = 0; | ||
| size_t node_idx = 0; | ||
|
|
||
| std::apply([&](auto&&... args) { (([&]() { | ||
| using PointerType = std::decay_t<decltype(args)>; | ||
| using UnderlyingType = std::remove_pointer_t<PointerType>; | ||
|
|
||
| constexpr size_t type_size = sizeof(UnderlyingType); | ||
| MDMA::LinkedListNode* node = new (&nodes[node_idx++]) MDMA::LinkedListNode(args, buffer + offset,type_size); // Placement new | ||
| build_nodes[idx++] = node; | ||
| offset += type_size; | ||
|
|
||
| if (prev_node != nullptr) { | ||
| prev_node->set_next(node->get_node()); | ||
| } | ||
| prev_node = node; | ||
| }()), ...); }, value_pointers); | ||
|
|
||
| prev_node = nullptr; | ||
| offset = 0; | ||
| idx = 0; | ||
|
|
||
| std::apply([&](auto&&... args) { (([&]() { | ||
| using PointerType = std::decay_t<decltype(args)>; | ||
| using UnderlyingType = std::remove_pointer_t<PointerType>; | ||
|
|
||
| constexpr size_t type_size = sizeof(UnderlyingType); | ||
| MDMA::LinkedListNode* node = new (&nodes[node_idx++]) MDMA::LinkedListNode(buffer + offset, args, type_size); // Placement new | ||
| parse_nodes[idx++] = node; | ||
| offset += type_size; | ||
|
|
||
| if (prev_node != nullptr) { | ||
| prev_node->set_next(node->get_node()); | ||
| } | ||
| prev_node = node; | ||
| }()), ...); }, value_pointers); | ||
|
|
||
| build_transfer_node = new (&nodes[node_idx++]) MDMA::LinkedListNode(buffer, nullptr, size); | ||
| parse_transfer_node = new (&nodes[node_idx++]) MDMA::LinkedListNode(buffer, buffer, size); | ||
| } | ||
|
|
||
| /** | ||
| * @brief Build the packet and transfer data into non-cached buffer using MDMA | ||
| * @param destination_address Optional destination address for the built packet (should be non-cached, else you will need to manage cache coherency). It isn't optional here because there's a specific overload without parameters for compliance with Packet interface. | ||
| * @return Pointer to the built packet data (internal buffer or destination address) | ||
| */ | ||
| uint8_t* build(uint8_t* destination_address) { | ||
| set_build_destination(destination_address); | ||
| bool done = false; | ||
| MDMA::transfer_list(build_nodes[0], &done); | ||
| while (!done) { | ||
| MDMA::update(); | ||
| } | ||
| return destination_address ? destination_address : buffer; | ||
| } | ||
|
|
||
| /** | ||
| * @brief Build the packet and transfer data into non-cached buffer using MDMA with a promise | ||
| * @param done Promise to be fulfilled upon transfer completion | ||
| * @param destination_address Optional destination address for the built packet (should be non-cached, else you will need to manage cache coherency) | ||
| * @return Pointer to the built packet data (internal buffer or destination address) | ||
| */ | ||
| uint8_t* build(bool* done, uint8_t* destination_address = nullptr) { | ||
| set_build_destination(destination_address); | ||
| MDMA::transfer_list(build_nodes[0], done); | ||
| return destination_address ? destination_address : buffer; | ||
| } | ||
|
|
||
| // Just for interface compliance | ||
| uint8_t* build() override { | ||
| uint8_t* destination_address = nullptr; | ||
| return build(destination_address); | ||
| } | ||
|
|
||
| /** | ||
| * @brief Parse the packet data from non-cached buffer using MDMA | ||
| * @param data Optional source data address to parse from (should be non-cached, else you will need to manage cache coherency). It isn't optional here becasue there's a specific overload without parameters for compliance with Packet interface. | ||
| * @param done Optional pointer to a boolean that will be set to true when parsing is done. | ||
| */ | ||
| void parse(uint8_t* data) override { | ||
| bool done = false; | ||
| auto source_node = set_parse_source(data); | ||
| MDMA::transfer_list(source_node, &done); | ||
| while (!done) { | ||
| MDMA::update(); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * @brief Parse the packet data from non-cached buffer using MDMA with a promise | ||
| * @param done Pointer to a boolean that will be set to true when parsing is done. | ||
| * @param data Optional source data address to parse from (should be non-cached, else you will need to manage cache coherency). | ||
| */ | ||
| void parse(bool* done, uint8_t* data = nullptr) { | ||
| auto source_node = set_parse_source(data); | ||
| MDMA::transfer_list(source_node, done); | ||
| } | ||
|
|
||
| size_t get_size() override { | ||
| return size; | ||
| } | ||
|
|
||
| uint16_t get_id() override { | ||
| return *id; | ||
| } | ||
|
|
||
| // Just for interface compliance, this is not efficient for MdmaPacket as it is. | ||
| // Could be optimized by using a map of index to pointer or similar structure created at compile time, but doesn't seem worthy now. | ||
| void set_pointer(size_t index, void* pointer) override { | ||
| size_t current_idx = 0; | ||
|
|
||
| std::apply([&](auto&&... args) { | ||
| ((current_idx++ == index ? | ||
| (args = reinterpret_cast<std::remove_reference_t<decltype(args)>>(pointer)) | ||
| : nullptr), ...); | ||
| }, value_pointers); | ||
| } | ||
|
|
||
| private: | ||
| MDMA::LinkedListNode* build_transfer_node; // Node used for destination address | ||
| MDMA::LinkedListNode* parse_transfer_node; // Node used for source address | ||
| MDMA::LinkedListNode* build_nodes[sizeof...(Types) + 1]; | ||
| MDMA::LinkedListNode* parse_nodes[sizeof...(Types) + 1]; | ||
|
|
||
| void set_build_destination(uint8_t* external_buffer) { | ||
| if (external_buffer != nullptr) { | ||
| build_transfer_node->set_destination(external_buffer); | ||
| build_nodes[sizeof...(Types)]->set_next(build_transfer_node->get_node()); | ||
| } else { | ||
| build_nodes[sizeof...(Types)]->set_next(nullptr); | ||
| } | ||
| } | ||
|
|
||
| MDMA::LinkedListNode* set_parse_source(uint8_t* external_buffer) { | ||
| if (external_buffer != nullptr) { | ||
| parse_transfer_node->set_source(external_buffer); | ||
| parse_transfer_node->set_next(parse_nodes[0]->get_node()); | ||
| return parse_transfer_node; | ||
| } else { | ||
| parse_nodes[0]->set_next(nullptr); | ||
| return parse_nodes[0]; | ||
| } | ||
| } | ||
| }; | ||
| }; | ||
|
|
||
| #endif // MDMA_PACKET_HPP | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same busy-waiting issue as in the build method. This defeats the asynchronous nature of MDMA transfers by blocking the CPU.