secondary_cpu.c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. #include <interrupt.h>
  18. static void rt_hw_timer2_isr(int vector, void *param)
  19. {
  20. rt_tick_increase();
  21. /* clear interrupt */
  22. timer_clear_pending(0);
  23. }
  24. void rt_hw_secondary_cpu_up(void)
  25. {
  26. extern void set_secondary_cpu_boot_address(void);
  27. set_secondary_cpu_boot_address();
  28. __asm__ volatile ("dsb":::"memory");
  29. rt_hw_ipi_send(0, 1 << 1);
  30. }
  31. void secondary_cpu_c_start(void)
  32. {
  33. rt_hw_vector_init();
  34. rt_hw_spin_lock(&_cpus_lock);
  35. arm_gic_cpu_init(0, REALVIEW_GIC_CPU_BASE);
  36. arm_gic_set_cpu(0, IRQ_PBA8_TIMER0_1, 0x2);
  37. timer_init(0, 1000);
  38. rt_hw_interrupt_install(IRQ_PBA8_TIMER0_1, rt_hw_timer2_isr, RT_NULL, "tick");
  39. rt_hw_interrupt_umask(IRQ_PBA8_TIMER0_1);
  40. rt_system_scheduler_start();
  41. }
  42. void rt_hw_secondary_cpu_idle_exec(void)
  43. {
  44. asm volatile ("wfe":::"memory", "cc");
  45. }
  46. #endif