cpuport.c 651 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /*
  2. * Copyright (c) 2011-2024, Shanghai Real-Thread Electronic Technology Co.,Ltd
  3. *
  4. * Change Logs:
  5. * Date Author Notes
  6. * 2022-08-29 RT-Thread first version
  7. */
  8. #include <rthw.h>
  9. #include <rtthread.h>
  10. int rt_hw_cpu_id(void)
  11. {
  12. int cpu_id;
  13. __asm volatile (
  14. "mrc p15, 0, %0, c0, c0, 5"
  15. :"=r"(cpu_id)
  16. );
  17. cpu_id &= 0xf;
  18. return cpu_id;
  19. }
  20. /**
  21. * @addtogroup ARM CPU
  22. */
  23. /*@{*/
  24. /** shutdown CPU */
  25. void rt_hw_cpu_shutdown()
  26. {
  27. rt_uint32_t level;
  28. rt_kprintf("shutdown...\n");
  29. level = rt_hw_interrupt_disable();
  30. while (level)
  31. {
  32. RT_ASSERT(0);
  33. }
  34. }
  35. /*@}*/