secHw_inline.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*****************************************************************************
  2. * Copyright 2003 - 2008 Broadcom Corporation. All rights reserved.
  3. *
  4. * Unless you and Broadcom execute a separate written software license
  5. * agreement governing use of this software, this software is licensed to you
  6. * under the terms of the GNU General Public License version 2, available at
  7. * http://www.broadcom.com/licenses/GPLv2.php (the "GPL").
  8. *
  9. * Notwithstanding the above, under no circumstances may you combine this
  10. * software in any way with any other Broadcom software provided under a
  11. * license other than the GPL, without Broadcom's express prior written
  12. * consent.
  13. *****************************************************************************/
  14. /****************************************************************************/
  15. /**
  16. * @file secHw_inline.h
  17. *
  18. * @brief Definitions for configuring/testing secure blocks
  19. *
  20. * @note
  21. * None
  22. */
  23. /****************************************************************************/
  24. #ifndef SECHW_INLINE_H
  25. #define SECHW_INLINE_H
  26. /****************************************************************************/
  27. /**
  28. * @brief Configures a device as a secure device
  29. *
  30. */
  31. /****************************************************************************/
  32. static inline void secHw_setSecure(uint32_t mask /* mask of type secHw_BLK_MASK_XXXXXX */
  33. ) {
  34. secHw_REGS_t *regp = (secHw_REGS_t *) MM_IO_BASE_TZPC;
  35. if (mask & 0x0000FFFF) {
  36. regp->reg[secHw_IDX_LS].setSecure = mask & 0x0000FFFF;
  37. }
  38. if (mask & 0xFFFF0000) {
  39. regp->reg[secHw_IDX_MS].setSecure = mask >> 16;
  40. }
  41. }
  42. /****************************************************************************/
  43. /**
  44. * @brief Configures a device as a non-secure device
  45. *
  46. */
  47. /****************************************************************************/
  48. static inline void secHw_setUnsecure(uint32_t mask /* mask of type secHw_BLK_MASK_XXXXXX */
  49. ) {
  50. secHw_REGS_t *regp = (secHw_REGS_t *) MM_IO_BASE_TZPC;
  51. if (mask & 0x0000FFFF) {
  52. regp->reg[secHw_IDX_LS].setUnsecure = mask & 0x0000FFFF;
  53. }
  54. if (mask & 0xFFFF0000) {
  55. regp->reg[secHw_IDX_MS].setUnsecure = mask >> 16;
  56. }
  57. }
  58. /****************************************************************************/
  59. /**
  60. * @brief Get the trustzone status for all components. 1 = non-secure, 0 = secure
  61. *
  62. */
  63. /****************************************************************************/
  64. static inline uint32_t secHw_getStatus(void)
  65. {
  66. secHw_REGS_t *regp = (secHw_REGS_t *) MM_IO_BASE_TZPC;
  67. return (regp->reg[1].status << 16) + regp->reg[0].status;
  68. }
  69. #endif /* SECHW_INLINE_H */