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 #include <Library/CacheMaintenanceLib.h>
18 #include <Library/DebugLib.h>
19 #include <Library/UefiBootServicesTableLib.h>
21 #include <Protocol/Cpu.h>
22 #include <Protocol/DebugSupport.h>
23 #include <Protocol/TimerDebugSupport.h>
27 DebugSupportGetMaximumProcessorIndex (
28 IN EFI_DEBUG_SUPPORT_PROTOCOL
*This
,
29 OUT UINTN
*MaxProcessorIndex
32 if (MaxProcessorIndex
== NULL
) {
33 return EFI_INVALID_PARAMETER
;
36 *MaxProcessorIndex
= 0;
43 DebugSupportRegisterPeriodicCallback (
44 IN EFI_DEBUG_SUPPORT_PROTOCOL
*This
,
45 IN UINTN ProcessorIndex
,
46 IN EFI_PERIODIC_CALLBACK PeriodicCallback
49 TIMER_DEBUG_SUPPORT_PROTOCOL
*Timer
;
52 Status
= gBS
->LocateProtocol(&gTimerDebugSupportProtocolGuid
, NULL
, (VOID
**)&Timer
);
53 if (EFI_ERROR(Status
)) {
57 Status
= Timer
->RegisterPeriodicCallback(Timer
, PeriodicCallback
);
64 DebugSupportRegisterExceptionCallback (
65 IN EFI_DEBUG_SUPPORT_PROTOCOL
*This
,
66 IN UINTN ProcessorIndex
,
67 IN EFI_EXCEPTION_CALLBACK ExceptionCallback
,
68 IN EFI_EXCEPTION_TYPE ExceptionType
71 EFI_CPU_ARCH_PROTOCOL
*Cpu
;
74 Status
= gBS
->LocateProtocol(&gEfiCpuArchProtocolGuid
, NULL
, (VOID
**)&Cpu
);
75 if (EFI_ERROR(Status
)) {
79 Status
= Cpu
->RegisterInterruptHandler(Cpu
, ExceptionType
, (EFI_CPU_INTERRUPT_HANDLER
)ExceptionCallback
);
86 DebugSupportInvalidateInstructionCache (
87 IN EFI_DEBUG_SUPPORT_PROTOCOL
*This
,
88 IN UINTN ProcessorIndex
,
93 InvalidateInstructionCacheRange(Start
, Length
);
97 EFI_DEBUG_SUPPORT_PROTOCOL mDebugSupport
= {
99 DebugSupportGetMaximumProcessorIndex
,
100 DebugSupportRegisterPeriodicCallback
,
101 DebugSupportRegisterExceptionCallback
,
102 DebugSupportInvalidateInstructionCache
106 DebugSupportDxeInitialize (
107 IN EFI_HANDLE ImageHandle
,
108 IN EFI_SYSTEM_TABLE
*SystemTable
112 EFI_HANDLE Handle
= NULL
;
114 ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL
, &gEfiDebugSupportProtocolGuid
);
115 Status
= gBS
->InstallMultipleProtocolInterfaces(&Handle
, &gEfiDebugSupportProtocolGuid
, &mDebugSupport
, NULL
);