secondary_cpu.c 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. * Copyright (c) 2006-2018, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2018-11-22 Jesven first version
  9. */
  10. #include <rthw.h>
  11. #include <rtthread.h>
  12. #include <stdint.h>
  13. #include "board.h"
  14. #include "gic.h"
  15. #include "drv_timer.h"
  16. #ifdef RT_USING_SMP
  17. static void rt_hw_timer2_isr(int vector, void *param)
  18. {
  19. rt_tick_increase();
  20. /* clear interrupt */
  21. timer_clear_pending(0);
  22. }
  23. void rt_hw_secondary_cpu_up(void)
  24. {
  25. extern void set_secondary_cpu_boot_address(void);
  26. set_secondary_cpu_boot_address();
  27. __asm__ volatile ("dsb":::"memory");
  28. rt_hw_ipi_send(0, 1 << 1);
  29. }
  30. void secondary_cpu_c_start(void)
  31. {
  32. rt_hw_vector_init();
  33. rt_hw_spin_lock(&_cpus_lock);
  34. arm_gic_cpu_init(0, REALVIEW_GIC_CPU_BASE);
  35. arm_gic_set_cpu(0, IRQ_PBA8_TIMER0_1, 0x2);
  36. timer_init(0, 1000);
  37. rt_hw_interrupt_install(IRQ_PBA8_TIMER0_1, rt_hw_timer2_isr, RT_NULL, "tick");
  38. rt_hw_interrupt_umask(IRQ_PBA8_TIMER0_1);
  39. rt_system_scheduler_start();
  40. }
  41. void rt_hw_secondary_cpu_idle_exec(void)
  42. {
  43. asm volatile ("wfe":::"memory", "cc");
  44. }
  45. #endif