]> git.proxmox.com Git - mirror_edk2.git/blame - ArmPkg/Library/ArmTrustZoneLib/ArmTrustZone.c
Fix issue with fixing tabs.
[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
32EFI_STATUS TZPCSetDecProtBits(UINTN TzpcBase, UINTN TzpcId, UINTN Bits) {\r
33 if (TzpcId > TZPC_DECPROT_MAX) {\r
34 return EFI_INVALID_PARAMETER;\r
35 }\r
36\r
37 MmioWrite32((UINTN)TzpcBase + TZPC_DECPROT0_SET_REG + (TzpcId * 0x0C), Bits);\r
38\r
39 return EFI_SUCCESS;\r
40}\r
41\r
42/**\r
43 FIXME: Need documentation\r
44**/\r
45EFI_STATUS TZPCClearDecProtBits(UINTN TzpcBase, UINTN TzpcId, UINTN Bits) {\r
46 if (TzpcId> TZPC_DECPROT_MAX) {\r
47 return EFI_INVALID_PARAMETER;\r
48 }\r
49\r
50 MmioWrite32((UINTN)TzpcBase + TZPC_DECPROT0_CLEAR_REG + (TzpcId * 0x0C), Bits);\r
51\r
52 return EFI_SUCCESS;\r
53}\r
54\r
55/**\r
56 FIXME: Need documentation\r
57**/\r
58UINT32 TZASCGetNumRegions(UINTN TzascBase) {\r
59 return (MmioRead32((UINTN)TzascBase + TZASC_CONFIGURATION_REG) & 0xF);\r
60}\r
61\r
62/**\r
63 FIXME: Need documentation\r
64**/\r
65EFI_STATUS TZASCSetRegion(UINTN TzascBase, UINTN RegionId, UINTN Enabled, UINTN LowAddress, UINTN HighAddress, UINTN Size, UINTN Security) {\r
66 UINT32* Region;\r
67\r
68 if (RegionId > TZASCGetNumRegions(TzascBase)) {\r
69 return EFI_INVALID_PARAMETER;\r
70 }\r
71\r
72 Region = (UINT32*)((UINTN)TzascBase + TZASC_REGIONS_REG + (RegionId * 0x10));\r
73\r
74 MmioWrite32((UINTN)(Region), LowAddress&0xFFFF8000);\r
2ac288f9 75 MmioWrite32((UINTN)(Region+1), HighAddress);\r
76 MmioWrite32((UINTN)(Region+2), ((Security & 0xF) <<28) | ((Size & 0x3F) << 1) | (Enabled & 0x1));\r
1bfda055 77\r
78 return EFI_SUCCESS;\r
79}\r