From 5499674333d021f159ad27d4267f6d43a0c64552 Mon Sep 17 00:00:00 2001 From: OmniaX-Dev Date: Sat, 16 May 2026 06:45:28 +0200 Subject: [PATCH] Sync push --- src/assembler/assembler_main.cpp | 20 ++++++ src/debugger/debugger_main.cpp | 20 ++++++ src/hardware/VirtualCPU.cpp | 20 ++++++ src/hardware/VirtualCPU.hpp | 20 ++++++ src/runtime/runtime_main.cpp | 20 ++++++ src/tools/Serial.cpp | 19 ++++++ src/tools/Serial.hpp | 114 +++++++++++++++++++++++++++++++ 7 files changed, 233 insertions(+) create mode 100644 src/tools/Serial.cpp create mode 100644 src/tools/Serial.hpp diff --git a/src/assembler/assembler_main.cpp b/src/assembler/assembler_main.cpp index 61b07cd..0836ae1 100644 --- a/src/assembler/assembler_main.cpp +++ b/src/assembler/assembler_main.cpp @@ -1,3 +1,23 @@ +/* + DragonV2 - A collection of useful functionality + Copyright (C) 2026 OmniaX-Dev + + This file is part of DragonV2. + + DragonV2 is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + DragonV2 is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DragonV2. If not, see . +*/ + #include int main(int argc, char** argv) diff --git a/src/debugger/debugger_main.cpp b/src/debugger/debugger_main.cpp index a940750..1c720d7 100644 --- a/src/debugger/debugger_main.cpp +++ b/src/debugger/debugger_main.cpp @@ -1,3 +1,23 @@ +/* + DragonV2 - A collection of useful functionality + Copyright (C) 2026 OmniaX-Dev + + This file is part of DragonV2. + + DragonV2 is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + DragonV2 is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DragonV2. If not, see . +*/ + #include int main(int argc, char** argv) diff --git a/src/hardware/VirtualCPU.cpp b/src/hardware/VirtualCPU.cpp index 2e17312..87adbf1 100644 --- a/src/hardware/VirtualCPU.cpp +++ b/src/hardware/VirtualCPU.cpp @@ -1,3 +1,23 @@ +/* + DragonV2 - A collection of useful functionality + Copyright (C) 2026 OmniaX-Dev + + This file is part of DragonV2. + + DragonV2 is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + DragonV2 is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DragonV2. If not, see . +*/ + #include "VirtualCPU.hpp" namespace dragon diff --git a/src/hardware/VirtualCPU.hpp b/src/hardware/VirtualCPU.hpp index 48680b7..ed74387 100644 --- a/src/hardware/VirtualCPU.hpp +++ b/src/hardware/VirtualCPU.hpp @@ -1,3 +1,23 @@ +/* + DragonV2 - A collection of useful functionality + Copyright (C) 2026 OmniaX-Dev + + This file is part of DragonV2. + + DragonV2 is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + DragonV2 is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DragonV2. If not, see . +*/ + #pragma once #include diff --git a/src/runtime/runtime_main.cpp b/src/runtime/runtime_main.cpp index 2f97398..03bd023 100644 --- a/src/runtime/runtime_main.cpp +++ b/src/runtime/runtime_main.cpp @@ -1,3 +1,23 @@ +/* + DragonV2 - A collection of useful functionality + Copyright (C) 2026 OmniaX-Dev + + This file is part of DragonV2. + + DragonV2 is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + DragonV2 is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DragonV2. If not, see . +*/ + #include int main(int argc, char** argv) diff --git a/src/tools/Serial.cpp b/src/tools/Serial.cpp new file mode 100644 index 0000000..14142b8 --- /dev/null +++ b/src/tools/Serial.cpp @@ -0,0 +1,19 @@ +/* + OmniaFramework - A collection of useful functionality + Copyright (C) 2026 OmniaX-Dev + + This file is part of OmniaFramework. + + OmniaFramework is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OmniaFramework is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with OmniaFramework. If not, see . +*/ diff --git a/src/tools/Serial.hpp b/src/tools/Serial.hpp new file mode 100644 index 0000000..bfc1e91 --- /dev/null +++ b/src/tools/Serial.hpp @@ -0,0 +1,114 @@ +/* + OmniaFramework - A collection of useful functionality + Copyright (C) 2026 OmniaX-Dev + + This file is part of OmniaFramework. + + OmniaFramework is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OmniaFramework is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with OmniaFramework. If not, see . +*/ + +#pragma once + +#include +#include + +namespace ostd +{ + class Serial + { + public: enum class Endianness : u8 { LittleEndian = 0, BigEndian }; + public: using StreamEdit = std::span; + public: using StreamView = std::span; + public: class Stream + { + public: + inline Stream(u64 size, Endianness endianness = Endianness::LittleEndian, bool preInitialize = false, i8 initialValue = 0) { + if (size < 1) return; + if constexpr (sizeof(size_t) < sizeof(uint64_t)) + { + if (size > std::numeric_limits::max()) + throw "Serial::Stream size can't excede UINT32_MAX on a 32bit system."; + } + m_data = new i8[size]; + m_size = size; + m_endianness = endianness; + if (preInitialize) + { + for (u64 i = 0; i < size; i++) + m_data[i] = initialValue; + } + } + inline ~Stream(void) { + if (isValid()) + { + delete[] m_data; + m_data = nullptr; + } + } + inline bool isValid(void) const { return m_size > 0 && m_data != nullptr; } + inline StreamEdit data() { + if (isValid()) + return { m_data, cast(m_size) }; + return {}; + } + inline StreamView data() const { + if (isValid()) + return { m_data, cast(m_size) }; + return {}; + } + + private: + i8* m_data { nullptr }; + u64 m_size { 0 }; + Endianness m_endianness { Endianness::LittleEndian }; + }; + + public: + inline static void attachStream(Stream& stream) { s_openStream = stream.data(); } + inline static void detachStrean(void) { s_openStream = {}; } + inline static bool isStreamAttached(void) { return !s_openStream.empty(); } + + public: struct read + { + std::pair int8(u64 addr); + inline i8 int8d(u64 addr, bool* outError = nullptr) { auto val = int8(addr); if (outError) *outError = val.second; return val.first; } + std::pair uint8(u64 addr); + inline u8 uint8d(u64 addr, bool* outError = nullptr) { auto val = uint8(addr); if (outError) *outError = val.second; return val.first; } + + std::pair int16(u64 addr); + inline i16 int16d(u64 addr, bool* outError = nullptr) { auto val = int16(addr); if (outError) *outError = val.second; return val.first; } + std::pair uint16(u64 addr); + inline u16 uint16d(u64 addr, bool* outError = nullptr) { auto val = uint16(addr); if (outError) *outError = val.second; return val.first; } + + std::pair int32(u64 addr); + inline i32 int32d(u64 addr, bool* outError = nullptr) { auto val = int32(addr); if (outError) *outError = val.second; return val.first; } + std::pair uint32(u64 addr); + inline u32 uint32d(u64 addr, bool* outError = nullptr) { auto val = uint32(addr); if (outError) *outError = val.second; return val.first; } + + std::pair int64(u64 addr); + inline i64 int64d(u64 addr, bool* outError = nullptr) { auto val = int64(addr); if (outError) *outError = val.second; return val.first; } + std::pair uint64(u64 addr); + inline u64 uint64d(u64 addr, bool* outError = nullptr) { auto val = uint64(addr); if (outError) *outError = val.second; return val.first; } + + private: + read(void) = default; + }; + + private: + Serial(void) = default; + + private: + inline static StreamEdit s_openStream { }; + }; +}