]> git.proxmox.com Git - mirror_edk2.git/blame - ArmPkg/Library/ArmTrustZoneLib/ArmTrustZone.c
Arm Packages: Fixed coding style/Line endings to follow EDK2 coding convention
[mirror_edk2.git] / ArmPkg / Library / ArmTrustZoneLib / ArmTrustZone.c
CommitLineData
1bfda055 1/** @file\r
2*\r
3* Copyright (c) 2011, ARM Limited. All rights reserved.\r
4* \r
5* This program and the accompanying materials \r
6* are licensed and made available under the terms and conditions of the BSD License \r
7* which accompanies this distribution. The full text of the license may be found at \r
8* http://opensource.org/licenses/bsd-license.php \r
9*\r
10* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
11* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
12*\r
13**/\r
14\r
15#include <Library/BaseLib.h>\r
16#include <Library/IoLib.h>\r
17#include <Library/ArmTrustZoneLib.h>\r
18\r
19#define TZPC_DECPROT0_STATUS_REG 0x800\r
20#define TZPC_DECPROT0_SET_REG 0x804\r
21#define TZPC_DECPROT0_CLEAR_REG 0x808\r
22\r
23#define TZASC_CONFIGURATION_REG 0x000\r
24#define TZASC_REGIONS_REG 0x100\r
25#define TZASC_REGION0_LOW_ADDRESS_REG 0x100\r
26#define TZASC_REGION0_HIGH_ADDRESS_REG 0x104\r
27#define TZASC_REGION0_ATTRIBUTES 0x108\r
28\r
29/**\r
30 FIXME: Need documentation\r
31**/\r
11c20f4e 32EFI_STATUS\r
33TZPCSetDecProtBits (\r
34 IN UINTN TzpcBase,\r
35 IN UINTN TzpcId,\r
36 IN UINTN Bits\r
37 )\r
38{\r
39 if (TzpcId > TZPC_DECPROT_MAX) {\r
40 return EFI_INVALID_PARAMETER;\r
41 }\r
1bfda055 42\r
11c20f4e 43 MmioWrite32 ((UINTN)TzpcBase + TZPC_DECPROT0_SET_REG + (TzpcId * 0x0C), Bits);\r
1bfda055 44\r
11c20f4e 45 return EFI_SUCCESS;\r
1bfda055 46}\r
47\r
48/**\r
49 FIXME: Need documentation\r
50**/\r
11c20f4e 51EFI_STATUS\r
52TZPCClearDecProtBits (\r
53 IN UINTN TzpcBase,\r
54 IN UINTN TzpcId,\r
55 IN UINTN Bits\r
56 )\r
57{\r
58 if (TzpcId> TZPC_DECPROT_MAX) {\r
59 return EFI_INVALID_PARAMETER;\r
60 }\r
1bfda055 61\r
11c20f4e 62 MmioWrite32 ((UINTN)TzpcBase + TZPC_DECPROT0_CLEAR_REG + (TzpcId * 0x0C), Bits);\r
1bfda055 63\r
11c20f4e 64 return EFI_SUCCESS;\r
1bfda055 65}\r
66\r
67/**\r
68 FIXME: Need documentation\r
69**/\r
11c20f4e 70UINT32\r
71TZASCGetNumRegions (\r
72 IN UINTN TzascBase\r
73 )\r
74{\r
75 return (MmioRead32 ((UINTN)TzascBase + TZASC_CONFIGURATION_REG) & 0xF);\r
1bfda055 76}\r
77\r
78/**\r
79 FIXME: Need documentation\r
80**/\r
11c20f4e 81EFI_STATUS\r
82TZASCSetRegion (\r
83 IN INTN TzascBase,\r
84 IN UINTN RegionId,\r
85 IN UINTN Enabled,\r
86 IN UINTN LowAddress,\r
87 IN UINTN HighAddress,\r
88 IN UINTN Size,\r
89 IN UINTN Security\r
90 )\r
91{\r
92 UINT32* Region;\r
1bfda055 93\r
11c20f4e 94 if (RegionId > TZASCGetNumRegions(TzascBase)) {\r
95 return EFI_INVALID_PARAMETER;\r
96 }\r
1bfda055 97\r
11c20f4e 98 Region = (UINT32*)((UINTN)TzascBase + TZASC_REGIONS_REG + (RegionId * 0x10));\r
1bfda055 99\r
11c20f4e 100 MmioWrite32((UINTN)(Region), LowAddress&0xFFFF8000);\r
2ac288f9 101 MmioWrite32((UINTN)(Region+1), HighAddress);\r
102 MmioWrite32((UINTN)(Region+2), ((Security & 0xF) <<28) | ((Size & 0x3F) << 1) | (Enabled & 0x1));\r
1bfda055 103\r
11c20f4e 104 return EFI_SUCCESS;\r
1bfda055 105}\r