summaryrefslogtreecommitdiff
path: root/bsp/qemu-vexpress-a9
diff options
context:
space:
mode:
authorBernard Xiong <[email protected]>2018-12-18 14:02:04 +0800
committerGitHub <[email protected]>2018-12-18 14:02:04 +0800
commita74a3031f036aedcfb7c4516e7ef43bcb967b2c0 (patch)
treea8b77a8183a6830875d8f91fef256e0e8f5849f4 /bsp/qemu-vexpress-a9
parentdcf74bce45f8caf2a3209f498f2675dee5df8500 (diff)
parenteff767a0742b25116f4d0ac766107d4a21ed19cb (diff)
Merge pull request #2081 from jesven/sync_smp_skeleton
Sync smp skeleton
Diffstat (limited to 'bsp/qemu-vexpress-a9')
-rw-r--r--bsp/qemu-vexpress-a9/cpu/cpu.c51
-rw-r--r--bsp/qemu-vexpress-a9/cpu/cpuport.c89
-rw-r--r--bsp/qemu-vexpress-a9/drivers/board.c48
-rw-r--r--bsp/qemu-vexpress-a9/drivers/secondary_cpu.c4
4 files changed, 93 insertions, 99 deletions
diff --git a/bsp/qemu-vexpress-a9/cpu/cpu.c b/bsp/qemu-vexpress-a9/cpu/cpu.c
deleted file mode 100644
index 10099809a3..0000000000
--- a/bsp/qemu-vexpress-a9/cpu/cpu.c
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * File : cpu.c
- * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006, RT-Thread Develop Team
- *
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rt-thread.org/license/LICENSE
- *
- * Change Logs:
- * Date Author Notes
- * 2011-09-15 Bernard first version
- * 2018-11-22 Jesven add rt_hw_cpu_id()
- */
-
-#include <rthw.h>
-#include <rtthread.h>
-#include <board.h>
-
-#ifdef RT_USING_SMP
-int rt_hw_cpu_id(void)
-{
- int cpu_id;
- __asm__ volatile (
- "mrc p15, 0, %0, c0, c0, 5"
- :"=r"(cpu_id)
- );
- cpu_id &= 0xf;
- return cpu_id;
-};
-#endif
-
-/**
- * @addtogroup ARM CPU
- */
-/*@{*/
-
-/** shutdown CPU */
-void rt_hw_cpu_shutdown()
-{
- rt_uint32_t level;
- rt_kprintf("shutdown...\n");
-
- level = rt_hw_interrupt_disable();
- while (level)
- {
- RT_ASSERT(0);
- }
-}
-
-/*@}*/
diff --git a/bsp/qemu-vexpress-a9/cpu/cpuport.c b/bsp/qemu-vexpress-a9/cpu/cpuport.c
new file mode 100644
index 0000000000..22ba8346da
--- /dev/null
+++ b/bsp/qemu-vexpress-a9/cpu/cpuport.c
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2006-2018, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Change Logs:
+ * Date Author Notes
+ * 2011-09-15 Bernard first version
+ * 2018-11-22 Jesven add rt_hw_cpu_id()
+ */
+
+#include <rthw.h>
+#include <rtthread.h>
+#include <board.h>
+
+#ifdef RT_USING_SMP
+int rt_hw_cpu_id(void)
+{
+ int cpu_id;
+ __asm__ volatile (
+ "mrc p15, 0, %0, c0, c0, 5"
+ :"=r"(cpu_id)
+ );
+ cpu_id &= 0xf;
+ return cpu_id;
+};
+
+void rt_hw_spin_lock(rt_hw_spinlock_t *lock)
+{
+ unsigned long tmp;
+ unsigned long newval;
+ rt_hw_spinlock_t lockval;
+
+ __asm__ __volatile__(
+ "pld [%0]"
+ ::"r"(&lock->slock)
+ );
+
+ __asm__ __volatile__(
+ "1: ldrex %0, [%3]\n"
+ " add %1, %0, %4\n"
+ " strex %2, %1, [%3]\n"
+ " teq %2, #0\n"
+ " bne 1b"
+ : "=&r" (lockval), "=&r" (newval), "=&r" (tmp)
+ : "r" (&lock->slock), "I" (1 << 16)
+ : "cc");
+
+ while (lockval.tickets.next != lockval.tickets.owner) {
+ __asm__ __volatile__("wfe":::"memory");
+ lockval.tickets.owner = *(volatile unsigned short *)(&lock->tickets.owner);
+ }
+
+ __asm__ volatile ("dmb":::"memory");
+}
+
+void rt_hw_spin_unlock(rt_hw_spinlock_t *lock)
+{
+ __asm__ volatile ("dmb":::"memory");
+ lock->tickets.owner++;
+ __asm__ volatile ("dsb ishst\nsev":::"memory");
+}
+
+#endif /*RT_USING_SMP*/
+
+void idle_wfi(void)
+{
+ asm volatile ("wfi");
+}
+
+/**
+ * @addtogroup ARM CPU
+ */
+/*@{*/
+
+/** shutdown CPU */
+void rt_hw_cpu_shutdown()
+{
+ rt_uint32_t level;
+ rt_kprintf("shutdown...\n");
+
+ level = rt_hw_interrupt_disable();
+ while (level)
+ {
+ RT_ASSERT(0);
+ }
+}
+
+/*@}*/
diff --git a/bsp/qemu-vexpress-a9/drivers/board.c b/bsp/qemu-vexpress-a9/drivers/board.c
index 26aad5bda1..26445d33f1 100644
--- a/bsp/qemu-vexpress-a9/drivers/board.c
+++ b/bsp/qemu-vexpress-a9/drivers/board.c
@@ -19,10 +19,8 @@
#define SYS_CTRL __REG32(REALVIEW_SCTL_BASE)
-void idle_wfi(void)
-{
- asm volatile ("wfi");
-}
+extern void idle_wfi(void);
+extern void rt_hw_ipi_handler_install(int ipi_vector, rt_isr_handler_t ipi_isr_handler);
/**
* This function will initialize beaglebone board
@@ -40,46 +38,8 @@ void rt_hw_board_init(void)
rt_thread_idle_sethook(idle_wfi);
#ifdef RT_USING_SMP
- /* install IPI interrupt */
- rt_hw_interrupt_install(RT_SCHEDULE_IPI_IRQ, rt_scheduler_ipi_handler, RT_NULL, "ipi");
- rt_hw_interrupt_umask(RT_SCHEDULE_IPI_IRQ);
+ /* install IPI handle */
+ rt_hw_ipi_handler_install(RT_SCHEDULE_IPI, rt_scheduler_ipi_handler);
#endif
}
-#ifdef RT_USING_SMP
-void rt_hw_spin_lock(rt_hw_spinlock_t *lock)
-{
- unsigned long tmp;
- unsigned long newval;
- rt_hw_spinlock_t lockval;
-
- __asm__ __volatile__(
- "pld [%0]"
- ::"r"(&lock->slock)
- );
-
- __asm__ __volatile__(
- "1: ldrex %0, [%3]\n"
- " add %1, %0, %4\n"
- " strex %2, %1, [%3]\n"
- " teq %2, #0\n"
- " bne 1b"
- : "=&r" (lockval), "=&r" (newval), "=&r" (tmp)
- : "r" (&lock->slock), "I" (1 << 16)
- : "cc");
-
- while (lockval.tickets.next != lockval.tickets.owner) {
- __asm__ __volatile__("wfe":::"memory");
- lockval.tickets.owner = *(volatile unsigned short *)(&lock->tickets.owner);
- }
-
- __asm__ volatile ("dmb":::"memory");
-}
-
-void rt_hw_spin_unlock(rt_hw_spinlock_t *lock)
-{
- __asm__ volatile ("dmb":::"memory");
- lock->tickets.owner++;
- __asm__ volatile ("dsb ishst\nsev":::"memory");
-}
-#endif /*RT_USING_SMP*/
diff --git a/bsp/qemu-vexpress-a9/drivers/secondary_cpu.c b/bsp/qemu-vexpress-a9/drivers/secondary_cpu.c
index b8b5436929..29bb9ec895 100644
--- a/bsp/qemu-vexpress-a9/drivers/secondary_cpu.c
+++ b/bsp/qemu-vexpress-a9/drivers/secondary_cpu.c
@@ -46,10 +46,6 @@ void secondary_cpu_c_start(void)
rt_hw_interrupt_install(IRQ_PBA8_TIMER0_1, rt_hw_timer2_isr, RT_NULL, "tick");
rt_hw_interrupt_umask(IRQ_PBA8_TIMER0_1);
- /* install IPI interrupt */
- rt_hw_interrupt_install(RT_SCHEDULE_IPI_IRQ, rt_scheduler_ipi_handler, RT_NULL, "ipi");
- rt_hw_interrupt_umask(RT_SCHEDULE_IPI_IRQ);
-
rt_system_scheduler_start();
}