3 * Copyright (c) 2011-2012, ARM Limited. All rights reserved.
5 * This program and the accompanying materials
6 * are licensed and made available under the terms and conditions of the BSD License
7 * which accompanies this distribution. The full text of the license may be found at
8 * http://opensource.org/licenses/bsd-license.php
10 * THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #include <Library/BaseLib.h>
16 #include <Library/IoLib.h>
18 #include <Drivers/ArmTrustzone.h>
20 #define TZPC_DECPROT0_STATUS_REG 0x800
21 #define TZPC_DECPROT0_SET_REG 0x804
22 #define TZPC_DECPROT0_CLEAR_REG 0x808
24 #define TZASC_CONFIGURATION_REG 0x000
25 #define TZASC_REGIONS_REG 0x100
26 #define TZASC_REGION0_LOW_ADDRESS_REG 0x100
27 #define TZASC_REGION0_HIGH_ADDRESS_REG 0x104
28 #define TZASC_REGION0_ATTRIBUTES 0x108
31 FIXME: Need documentation
40 if (TzpcId
> TZPC_DECPROT_MAX
) {
41 return EFI_INVALID_PARAMETER
;
44 MmioWrite32 ((UINTN
)TzpcBase
+ TZPC_DECPROT0_SET_REG
+ (TzpcId
* 0x0C), Bits
);
50 FIXME: Need documentation
53 TZPCClearDecProtBits (
59 if (TzpcId
> TZPC_DECPROT_MAX
) {
60 return EFI_INVALID_PARAMETER
;
63 MmioWrite32 ((UINTN
)TzpcBase
+ TZPC_DECPROT0_CLEAR_REG
+ (TzpcId
* 0x0C), Bits
);
69 FIXME: Need documentation
76 return (MmioRead32 ((UINTN
)TzascBase
+ TZASC_CONFIGURATION_REG
) & 0xF);
80 FIXME: Need documentation
91 IN UINTN SubregionDisableMask
95 UINT32 RegionAttributes
;
97 if (RegionId
> TZASCGetNumRegions(TzascBase
)) {
98 return EFI_INVALID_PARAMETER
;
101 RegionAttributes
= TZASC_REGION_ATTR_SECURITY(Security
) |
102 TZASC_REGION_ATTR_SUBREG_DISABLE(SubregionDisableMask
) |
103 TZASC_REGION_ATTR_SIZE(Size
) |
104 TZASC_REGION_ATTR_ENABLE(Enabled
);
106 Region
= (UINT32
*)((UINTN
)TzascBase
+ TZASC_REGIONS_REG
+ (RegionId
* 0x10));
108 MmioWrite32((UINTN
)(Region
), TZASC_REGION_SETUP_LO_ADDR(LowAddress
));
109 MmioWrite32((UINTN
)(Region
+1), HighAddress
);
110 MmioWrite32((UINTN
)(Region
+2), RegionAttributes
);