Defect: Fix path
Code: Select all
--- os/common/ports/ARMv6-M/compilers/GCC/mk/port_rp2.mk (revision 17689)
+++ os/common/ports/ARMv6-M/compilers/GCC/mk/port_rp2.mk (working copy)
@@ -10,7 +10,7 @@
PORTASM = $(CHIBIOS)/os/common/ports/ARMv6-M/compilers/GCC/chcoreasm.S
PORTINC = $(CHIBIOS)/os/common/ports/ARMv6-M \
- $(CHIBIOS)/os/common/ports/ARMv6-M\smp\rp2
+ $(CHIBIOS)/os/common/ports/ARMv6-M/smp/rp2
# Shared variables
ALLXASMSRC += $(PORTASM)Defect: Conditionally include SMP timer
Code: Select all
--- os/common/ports/ARMv6-M/chcore.h (revision 17689)
+++ os/common/ports/ARMv6-M/chcore.h (working copy)
@@ -603,7 +603,11 @@
#if !defined(_FROM_ASM_)
#if CH_CFG_ST_TIMEDELTA > 0
+#if (CH_CFG_SMP_MODE == TRUE) && defined(PORT_CORES_NUMBER) && (PORT_CORES_NUMBER > 1)
+#include "chcoresmp_timer.h"
+#else
#include "chcore_timer.h"
+#endif
#endif /* CH_CFG_ST_TIMEDELTA > 0 */
#endif /* !defined(_FROM_ASM_) */Feature: Add weak reference to allow device specific init
Code: Select all
--- os/common/ports/ARMv6-M/chcore.c (revision 17689)
+++ os/common/ports/ARMv6-M/chcore.c (working copy)
@@ -103,12 +103,13 @@
/**
* @brief Port-related initialization code.
+ * @note Weak function that can be overridden by SMP-specific implementations
*
* @param[in, out] oip pointer to the @p os_instance_t structure
*
* @notapi
*/
-void port_init(os_instance_t *oip) {
+__attribute__((weak)) void port_init(os_instance_t *oip) {
(void)oip;
Feature: RP2040 device specific
Code: Select all
--- os/common/ports/ARMv6-M/smp/rp2/chcoresmp.c (revision 17689)
+++ os/common/ports/ARMv6-M/smp/rp2/chcoresmp.c (working copy)
@@ -46,15 +46,116 @@
/* Module local functions. */
/*===========================================================================*/
+static void port_local_halt(void) {
+ const char *reason = "remote panic";
+
+ port_disable();
+
+ __trace_halt("remote panic");
+
+ currcore->dbg.panic_msg = reason;
+
+ CH_CFG_SYSTEM_HALT_HOOK(reason);
+
+ while (true) {
+ }
+}
+
/*===========================================================================*/
/* Module interrupt handlers. */
/*===========================================================================*/
+/**
+ * @brief FIFO interrupt handler for core 0.
+ *
+ * @isr
+ */
+CH_IRQ_HANDLER(Vector7C) {
+
+ CH_IRQ_PROLOGUE();
+
+ SIO->FIFO_ST = SIO_FIFO_ST_ROE | SIO_FIFO_ST_WOF;
+
+ while ((SIO->FIFO_ST & SIO_FIFO_ST_VLD) != 0U) {
+ uint32_t message = SIO->FIFO_RD;
+#if defined(PORT_HANDLE_FIFO_MESSAGE)
+ if (message != PORT_FIFO_RESCHEDULE_MESSAGE) {
+ PORT_HANDLE_FIFO_MESSAGE(1U, message);
+ }
+#else
+ (void)message;
+#endif
+ }
+
+ __SEV();
+
+ CH_IRQ_EPILOGUE();
+}
+
+/**
+ * @brief FIFO interrupt handler for core 1.
+ *
+ * @isr
+ */
+CH_IRQ_HANDLER(Vector80) {
+
+ CH_IRQ_PROLOGUE();
+
+ SIO->FIFO_ST = SIO_FIFO_ST_ROE | SIO_FIFO_ST_WOF;
+
+ while ((SIO->FIFO_ST & SIO_FIFO_ST_VLD) != 0U) {
+ uint32_t message = SIO->FIFO_RD;
+ if (message == PORT_FIFO_PANIC_MESSAGE) {
+ port_local_halt();
+ }
+#if defined(PORT_HANDLE_FIFO_MESSAGE)
+ if (message != PORT_FIFO_RESCHEDULE_MESSAGE) {
+ PORT_HANDLE_FIFO_MESSAGE(0U, message);
+ }
+#endif
+ }
+
+ __SEV();
+
+ CH_IRQ_EPILOGUE();
+}
+
/*===========================================================================*/
/* Module exported functions. */
/*===========================================================================*/
/**
+ * @brief RP2040 initialization code for SMP.
+ * @details Overrides the weak port_init() in chcore.c.
+ *
+ * @param[in, out] oip pointer to the @p os_instance_t structure
+ *
+ * @notapi
+ */
+void port_init(os_instance_t *oip) {
+
+#if CH_CFG_ST_TIMEDELTA > 0
+ /* Activating timer for this instance */
+ port_timer_enable(oip);
+#endif
+
+ SIO->FIFO_ST = SIO_FIFO_ST_ROE | SIO_FIFO_ST_WOF;
+ if (oip->core_id == 0U) {
+ NVIC_SetPriority(15, CORTEX_MINIMUM_PRIORITY);
+ NVIC_EnableIRQ(15);
+ }
+ else if (oip->core_id == 1U) {
+ NVIC_SetPriority(16, CORTEX_MINIMUM_PRIORITY);
+ NVIC_EnableIRQ(16);
+ }
+ else {
+ chDbgAssert(false, "unexpected core id");
+ }
+
+ NVIC_SetPriority(PendSV_IRQn, CORTEX_PRIORITY_PENDSV);
+}
+
+/**
* @brief Takes the kernel spinlock.
*/
void __port_spinlock_take(void) {