From 011ff9ede6fab86ccba5de8eb08f4bd02d7d7522 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Niccol=C3=B2=20Betto?= <niccolo.betto@kywarder.eu>
Date: Wed, 31 Jul 2024 12:42:42 +0200
Subject: [PATCH] Add missing impl header files

---
 interfaces-impl/arch_registers_impl.h | 29 +++++++++++++++
 interfaces-impl/bsp_impl.h            | 51 +++++++++++++++++++++++++++
 interfaces-impl/gpio_impl.h           | 43 ++++++++++++++++++++++
 interfaces-impl/portability_impl.h    | 44 +++++++++++++++++++++++
 kernel/kernel.h                       | 10 ++++--
 5 files changed, 174 insertions(+), 3 deletions(-)
 create mode 100644 interfaces-impl/arch_registers_impl.h
 create mode 100644 interfaces-impl/bsp_impl.h
 create mode 100644 interfaces-impl/gpio_impl.h
 create mode 100644 interfaces-impl/portability_impl.h

diff --git a/interfaces-impl/arch_registers_impl.h b/interfaces-impl/arch_registers_impl.h
new file mode 100644
index 0000000..f0e2225
--- /dev/null
+++ b/interfaces-impl/arch_registers_impl.h
@@ -0,0 +1,29 @@
+/* Copyright (c) 2024 Skyward Experimental Rocketry
+ * Author: Niccolò Betto
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#pragma once
+
+#ifndef COMPILE_FOR_HOST
+#error "Unsupported"
+#endif
+
+#define RCC_SYNC()
diff --git a/interfaces-impl/bsp_impl.h b/interfaces-impl/bsp_impl.h
new file mode 100644
index 0000000..4badd43
--- /dev/null
+++ b/interfaces-impl/bsp_impl.h
@@ -0,0 +1,51 @@
+/* Copyright (c) 2024 Skyward Experimental Rocketry
+ * Author: Niccolò Betto
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#pragma once
+
+#ifndef COMPILE_FOR_HOST
+#error "Unsupported"
+#endif
+
+namespace miosix
+{
+
+inline void configureSdram() {}
+
+inline void led1On() {}
+inline void led1Off() {}
+
+inline void led2On() {}
+inline void led2Off() {}
+
+inline void led3On() {}
+inline void led3Off() {}
+
+inline void led4On() {}
+inline void led4Off() {}
+
+inline void ledOn() {}
+inline void ledOff() {}
+
+inline bool sdCardSense() { return true; }
+
+}  // namespace miosix
\ No newline at end of file
diff --git a/interfaces-impl/gpio_impl.h b/interfaces-impl/gpio_impl.h
new file mode 100644
index 0000000..1aca3c2
--- /dev/null
+++ b/interfaces-impl/gpio_impl.h
@@ -0,0 +1,43 @@
+/* Copyright (c) 2024 Skyward Experimental Rocketry
+ * Author: Niccolò Betto
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#pragma once
+
+#ifndef COMPILE_FOR_HOST
+#error "Unsupported"
+#endif
+
+namespace miosix
+{
+
+class GpioPin
+{
+public:
+    GpioPin(unsigned int p, unsigned char n) {}
+};
+
+template <unsigned int P, unsigned char N>
+class Gpio
+{
+};
+
+}  // namespace miosix
diff --git a/interfaces-impl/portability_impl.h b/interfaces-impl/portability_impl.h
new file mode 100644
index 0000000..0340ac7
--- /dev/null
+++ b/interfaces-impl/portability_impl.h
@@ -0,0 +1,44 @@
+/* Copyright (c) 2024 Skyward Experimental Rocketry
+ * Author: Niccolò Betto
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#pragma once
+
+#include <thread>
+
+#ifndef COMPILE_FOR_HOST
+#error "Unsupported"
+#endif
+
+#define saveContext()
+#define restoreContext()
+
+namespace miosix_private
+{
+
+inline void doYield() { std::this_thread::yield(); }
+
+inline void doDisableInterrupts() {}
+inline void doEnableInterrupts() {}
+
+inline bool checkAreInterruptsEnabled() { return true; }
+
+}  // namespace miosix_private
\ No newline at end of file
diff --git a/kernel/kernel.h b/kernel/kernel.h
index af4f1d3..1ae02d2 100644
--- a/kernel/kernel.h
+++ b/kernel/kernel.h
@@ -33,8 +33,12 @@
 #include <functional>
 #include <new>
 
-#include "interfaces/portability.h"
-#include "kernel/scheduler/sched_types.h"
+#include "scheduler/sched_types.h"
+
+namespace miosix_private
+{
+class FaultData;
+}
 
 namespace miosix
 {
@@ -173,7 +177,7 @@ public:
     static bool IRQreportFault(const miosix_private::FaultData &fault);
 };
 
-class LowerPriority : public std::binary_function<Thread *, Thread *, bool>
+class LowerPriority
 {
 public:
     bool operator()(Thread *a, Thread *b);
-- 
GitLab