]>
git.proxmox.com Git - mirror_edk2.git/blob - ArmPkg/Library/ArmTrustZoneLib/ArmTrustZone.c
1e4809bc8118723c658da6c132fa0e5837d87613
3 * Copyright (c) 2011, 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>
17 #include <Library/ArmTrustZoneLib.h>
19 #define TZPC_DECPROT0_STATUS_REG 0x800
20 #define TZPC_DECPROT0_SET_REG 0x804
21 #define TZPC_DECPROT0_CLEAR_REG 0x808
23 #define TZASC_CONFIGURATION_REG 0x000
24 #define TZASC_REGIONS_REG 0x100
25 #define TZASC_REGION0_LOW_ADDRESS_REG 0x100
26 #define TZASC_REGION0_HIGH_ADDRESS_REG 0x104
27 #define TZASC_REGION0_ATTRIBUTES 0x108
30 FIXME: Need documentation
32 EFI_STATUS
TZPCSetDecProtBits(UINTN TzpcBase
, UINTN TzpcId
, UINTN Bits
) {
33 if (TzpcId
> TZPC_DECPROT_MAX
) {
34 return EFI_INVALID_PARAMETER
;
37 MmioWrite32((UINTN
)TzpcBase
+ TZPC_DECPROT0_SET_REG
+ (TzpcId
* 0x0C), Bits
);
43 FIXME: Need documentation
45 EFI_STATUS
TZPCClearDecProtBits(UINTN TzpcBase
, UINTN TzpcId
, UINTN Bits
) {
46 if (TzpcId
> TZPC_DECPROT_MAX
) {
47 return EFI_INVALID_PARAMETER
;
50 MmioWrite32((UINTN
)TzpcBase
+ TZPC_DECPROT0_CLEAR_REG
+ (TzpcId
* 0x0C), Bits
);
56 FIXME: Need documentation
58 UINT32
TZASCGetNumRegions(UINTN TzascBase
) {
59 return (MmioRead32((UINTN
)TzascBase
+ TZASC_CONFIGURATION_REG
) & 0xF);
63 FIXME: Need documentation
65 EFI_STATUS
TZASCSetRegion(UINTN TzascBase
, UINTN RegionId
, UINTN Enabled
, UINTN LowAddress
, UINTN HighAddress
, UINTN Size
, UINTN Security
) {
68 if (RegionId
> TZASCGetNumRegions(TzascBase
)) {
69 return EFI_INVALID_PARAMETER
;
72 Region
= (UINT32
*)((UINTN
)TzascBase
+ TZASC_REGIONS_REG
+ (RegionId
* 0x10));
74 MmioWrite32((UINTN
)(Region
), LowAddress
&0xFFFF8000);
75 \s\
sMmioWrite32((UINTN
)(Region
+1), HighAddress
);
76 \s\
sMmioWrite32((UINTN
)(Region
+2), ((Security
& 0xF) <<28) | ((Size
& 0x3F) << 1) | (Enabled
& 0x1));