cpu.c 922 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * File : cpu.c
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2006, RT-Thread Develop Team
  5. *
  6. * The license and distribution terms for this file may be
  7. * found in the file LICENSE in this distribution or at
  8. * http://www.rt-thread.org/license/LICENSE
  9. *
  10. * Change Logs:
  11. * Date Author Notes
  12. * 2011-09-15 Bernard first version
  13. * 2018-11-22 Jesven add rt_hw_cpu_id()
  14. */
  15. #include <rthw.h>
  16. #include <rtthread.h>
  17. #include <board.h>
  18. #ifdef RT_USING_SMP
  19. int rt_hw_cpu_id(void)
  20. {
  21. int cpu_id;
  22. __asm__ volatile (
  23. "mrc p15, 0, %0, c0, c0, 5"
  24. :"=r"(cpu_id)
  25. );
  26. cpu_id &= 0xf;
  27. return cpu_id;
  28. };
  29. #endif
  30. /**
  31. * @addtogroup ARM CPU
  32. */
  33. /*@{*/
  34. /** shutdown CPU */
  35. void rt_hw_cpu_shutdown()
  36. {
  37. rt_uint32_t level;
  38. rt_kprintf("shutdown...\n");
  39. level = rt_hw_interrupt_disable();
  40. while (level)
  41. {
  42. RT_ASSERT(0);
  43. }
  44. }
  45. /*@}*/