Updated to support passing PE/COFF and LZMA decompress up via HOBS. Currently turned...
[mirror_edk2.git] / EmbeddedPkg / DebugSupportDxe / DebugSupport.c
CommitLineData
2ef2b01e
A
1/** @file\r
2\r
3 Copyright (c) 2008-2009, Apple Inc. All rights reserved.\r
4 \r
5 All rights reserved. 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 <Uefi.h>\r
16\r
17#include <Library/CacheMaintenanceLib.h>\r
18#include <Library/DebugLib.h>\r
19#include <Library/UefiBootServicesTableLib.h>\r
20\r
21#include <Protocol/Cpu.h>\r
22#include <Protocol/DebugSupport.h>\r
23#include <Protocol/TimerDebugSupport.h>\r
24\r
25EFI_STATUS\r
26EFIAPI\r
27DebugSupportGetMaximumProcessorIndex (\r
28 IN EFI_DEBUG_SUPPORT_PROTOCOL *This,\r
29 OUT UINTN *MaxProcessorIndex\r
30 )\r
31{\r
32 if (MaxProcessorIndex == NULL) {\r
33 return EFI_INVALID_PARAMETER;\r
34 }\r
35\r
36 *MaxProcessorIndex = 0;\r
37\r
38 return EFI_SUCCESS;\r
39}\r
40\r
41EFI_STATUS\r
42EFIAPI\r
43DebugSupportRegisterPeriodicCallback (\r
44 IN EFI_DEBUG_SUPPORT_PROTOCOL *This,\r
45 IN UINTN ProcessorIndex,\r
46 IN EFI_PERIODIC_CALLBACK PeriodicCallback\r
47 )\r
48{\r
49 TIMER_DEBUG_SUPPORT_PROTOCOL *Timer;\r
50 EFI_STATUS Status;\r
51\r
52 Status = gBS->LocateProtocol(&gTimerDebugSupportProtocolGuid, NULL, (VOID **)&Timer);\r
53 if (EFI_ERROR(Status)) {\r
54 return Status;\r
55 }\r
56\r
57 Status = Timer->RegisterPeriodicCallback(Timer, PeriodicCallback);\r
58\r
59 return Status;\r
60}\r
61\r
62EFI_STATUS\r
63EFIAPI\r
64DebugSupportRegisterExceptionCallback (\r
65 IN EFI_DEBUG_SUPPORT_PROTOCOL *This,\r
66 IN UINTN ProcessorIndex,\r
67 IN EFI_EXCEPTION_CALLBACK ExceptionCallback,\r
68 IN EFI_EXCEPTION_TYPE ExceptionType\r
69 )\r
70{\r
71 EFI_CPU_ARCH_PROTOCOL *Cpu;\r
72 EFI_STATUS Status;\r
73\r
74 Status = gBS->LocateProtocol(&gEfiCpuArchProtocolGuid, NULL, (VOID **)&Cpu);\r
75 if (EFI_ERROR(Status)) {\r
76 return Status;\r
77 }\r
78\r
79 Status = Cpu->RegisterInterruptHandler(Cpu, ExceptionType, (EFI_CPU_INTERRUPT_HANDLER)ExceptionCallback);\r
80\r
81 return Status;\r
82}\r
83\r
84EFI_STATUS\r
85EFIAPI\r
86DebugSupportInvalidateInstructionCache (\r
87 IN EFI_DEBUG_SUPPORT_PROTOCOL *This,\r
88 IN UINTN ProcessorIndex,\r
89 IN VOID *Start,\r
90 IN UINT64 Length\r
91 )\r
92{\r
93 InvalidateInstructionCacheRange(Start, Length);\r
94 return EFI_SUCCESS;\r
95}\r
96\r
97EFI_DEBUG_SUPPORT_PROTOCOL mDebugSupport = {\r
98 IsaArm,\r
99 DebugSupportGetMaximumProcessorIndex,\r
100 DebugSupportRegisterPeriodicCallback,\r
101 DebugSupportRegisterExceptionCallback,\r
102 DebugSupportInvalidateInstructionCache\r
103};\r
104\r
105EFI_STATUS\r
106DebugSupportDxeInitialize (\r
107 IN EFI_HANDLE ImageHandle,\r
108 IN EFI_SYSTEM_TABLE *SystemTable\r
109 )\r
110{\r
111 EFI_STATUS Status;\r
112 EFI_HANDLE Handle = NULL;\r
113\r
114 ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiDebugSupportProtocolGuid);\r
115 Status = gBS->InstallMultipleProtocolInterfaces(&Handle, &gEfiDebugSupportProtocolGuid, &mDebugSupport, NULL);\r
116\r
117 return Status;\r
118}\r
119\r