secondary_cpu.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. /* install IPI interrupt */
  40. rt_hw_interrupt_install(RT_SCHEDULE_IPI_IRQ, rt_scheduler_ipi_handler, RT_NULL, "ipi");
  41. rt_hw_interrupt_umask(RT_SCHEDULE_IPI_IRQ);
  42. rt_system_scheduler_start();
  43. }
  44. void rt_hw_secondary_cpu_idle_exec(void)
  45. {
  46. asm volatile ("wfe":::"memory", "cc");
  47. }
  48. #endif