mon.c 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * K2HK: secure kernel command file
  3. *
  4. * (C) Copyright 2012-2014
  5. * Texas Instruments Incorporated, <www.ti.com>
  6. *
  7. * SPDX-License-Identifier: GPL-2.0+
  8. */
  9. #include <common.h>
  10. #include <command.h>
  11. #include <mach/mon.h>
  12. asm(".arch_extension sec\n\t");
  13. int mon_install(u32 addr, u32 dpsc, u32 freq)
  14. {
  15. int result;
  16. __asm__ __volatile__ (
  17. "stmfd r13!, {lr}\n"
  18. "mov r0, %1\n"
  19. "mov r1, %2\n"
  20. "mov r2, %3\n"
  21. "blx r0\n"
  22. "ldmfd r13!, {lr}\n"
  23. : "=&r" (result)
  24. : "r" (addr), "r" (dpsc), "r" (freq)
  25. : "cc", "r0", "r1", "r2", "memory");
  26. return result;
  27. }
  28. int mon_power_on(int core_id, void *ep)
  29. {
  30. int result;
  31. asm volatile (
  32. "stmfd r13!, {lr}\n"
  33. "mov r1, %1\n"
  34. "mov r2, %2\n"
  35. "mov r0, #0\n"
  36. "smc #0\n"
  37. "ldmfd r13!, {lr}\n"
  38. : "=&r" (result)
  39. : "r" (core_id), "r" (ep)
  40. : "cc", "r0", "r1", "r2", "memory");
  41. return result;
  42. }
  43. int mon_power_off(int core_id)
  44. {
  45. int result;
  46. asm volatile (
  47. "stmfd r13!, {lr}\n"
  48. "mov r1, %1\n"
  49. "mov r0, #1\n"
  50. "smc #1\n"
  51. "ldmfd r13!, {lr}\n"
  52. : "=&r" (result)
  53. : "r" (core_id)
  54. : "cc", "r0", "r1", "memory");
  55. return result;
  56. }