3 Copyright (c) 2008-2009, Apple Inc. All rights reserved.
5 All rights reserved. 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.
17 BOOLEAN gExceptionContext
= FALSE
;
18 BOOLEAN mInterruptState
= FALSE
;
22 CpuFlushCpuDataCache (
23 IN EFI_CPU_ARCH_PROTOCOL
*This
,
24 IN EFI_PHYSICAL_ADDRESS Start
,
26 IN EFI_CPU_FLUSH_TYPE FlushType
30 case EfiCpuFlushTypeWriteBack
:
31 WriteBackDataCacheRange ((VOID
*)(UINTN
)Start
, (UINTN
)Length
);
33 case EfiCpuFlushTypeInvalidate
:
34 InvalidateDataCacheRange ((VOID
*)(UINTN
)Start
, (UINTN
)Length
);
36 case EfiCpuFlushTypeWriteBackInvalidate
:
37 WriteBackInvalidateDataCacheRange ((VOID
*)(UINTN
)Start
, (UINTN
)Length
);
40 return EFI_INVALID_PARAMETER
;
49 IN EFI_CPU_ARCH_PROTOCOL
*This
52 if (!gExceptionContext
) {
53 ArmEnableInterrupts ();
56 mInterruptState
= TRUE
;
64 IN EFI_CPU_ARCH_PROTOCOL
*This
67 if (!gExceptionContext
) {
68 ArmDisableInterrupts ();
71 mInterruptState
= FALSE
;
77 CpuGetInterruptState (
78 IN EFI_CPU_ARCH_PROTOCOL
*This
,
83 return EFI_INVALID_PARAMETER
;
86 *State
= mInterruptState
;
93 IN EFI_CPU_ARCH_PROTOCOL
*This
,
94 IN EFI_CPU_INIT_TYPE InitType
97 return EFI_UNSUPPORTED
;
102 CpuRegisterInterruptHandler (
103 IN EFI_CPU_ARCH_PROTOCOL
*This
,
104 IN EFI_EXCEPTION_TYPE InterruptType
,
105 IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler
108 return RegisterInterruptHandler (InterruptType
, InterruptHandler
);
114 IN EFI_CPU_ARCH_PROTOCOL
*This
,
115 IN UINT32 TimerIndex
,
116 OUT UINT64
*TimerValue
,
117 OUT UINT64
*TimerPeriod OPTIONAL
120 return EFI_UNSUPPORTED
;
125 CpuSetMemoryAttributes (
126 IN EFI_CPU_ARCH_PROTOCOL
*This
,
127 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
132 return EFI_UNSUPPORTED
;
136 // Globals used to initialize the protocol
138 EFI_HANDLE mCpuHandle
= NULL
;
139 EFI_CPU_ARCH_PROTOCOL mCpu
= {
140 CpuFlushCpuDataCache
,
143 CpuGetInterruptState
,
145 CpuRegisterInterruptHandler
,
147 CpuSetMemoryAttributes
,
149 4, // DmaBufferAlignment
154 IN EFI_HANDLE ImageHandle
,
155 IN EFI_SYSTEM_TABLE
*SystemTable
158 InitializeExceptions (&mCpu
);
159 return gBS
->InstallMultipleProtocolInterfaces (&mCpuHandle
, &gEfiCpuArchProtocolGuid
, &mCpu
, NULL
);