sec-common.c 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. *
  3. * Common security related functions for OMAP devices
  4. *
  5. * (C) Copyright 2016
  6. * Texas Instruments, <www.ti.com>
  7. *
  8. * Daniel Allred <d-allred@ti.com>
  9. * Andreas Dannenberg <dannenberg@ti.com>
  10. *
  11. * SPDX-License-Identifier: GPL-2.0+
  12. */
  13. #include <common.h>
  14. #include <stdarg.h>
  15. #include <asm/arch/sys_proto.h>
  16. #include <asm/omap_common.h>
  17. #include <asm/omap_sec_common.h>
  18. static uint32_t secure_rom_call_args[5] __aligned(ARCH_DMA_MINALIGN);
  19. u32 secure_rom_call(u32 service, u32 proc_id, u32 flag, ...)
  20. {
  21. int i;
  22. u32 num_args;
  23. va_list ap;
  24. va_start(ap, flag);
  25. num_args = va_arg(ap, u32);
  26. if (num_args > 4)
  27. return 1;
  28. /* Copy args to aligned args structure */
  29. for (i = 0; i < num_args; i++)
  30. secure_rom_call_args[i + 1] = va_arg(ap, u32);
  31. secure_rom_call_args[0] = num_args;
  32. va_end(ap);
  33. /* if data cache is enabled, flush the aligned args structure */
  34. flush_dcache_range(
  35. (unsigned int)&secure_rom_call_args[0],
  36. (unsigned int)&secure_rom_call_args[0] +
  37. roundup(sizeof(secure_rom_call_args), ARCH_DMA_MINALIGN));
  38. return omap_smc_sec(service, proc_id, flag, secure_rom_call_args);
  39. }