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 May need some porting work for platform specifics.
19 Copyright (c) 2008, Apple Inc
20 All rights reserved. This program and the accompanying materials
21 are licensed and made available under the terms and conditions of the BSD License
22 which accompanies this distribution. The full text of the license may be found at
23 http://opensource.org/licenses/bsd-license.php
25 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
26 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
32 EFI_PERIODIC_CALLBACK gPeriodicCallBack
= (EFI_PERIODIC_CALLBACK
)NULL
;
34 EFI_DEBUG_SUPPORT_PERIODIC_CALLBACK_PROTOCOL
*gDebugSupportCallback
= NULL
;
39 DebugSupportGetMaximumProcessorIndex (
40 IN EFI_DEBUG_SUPPORT_PROTOCOL
*This
,
41 OUT UINTN
*MaxProcessorIndex
45 Routine Description: This is a DebugSupport protocol member function.
48 This - The DebugSupport instance
49 MaxProcessorIndex - The maximuim supported processor index
52 Always returns EFI_SUCCESS with *MaxProcessorIndex set to 0
56 *MaxProcessorIndex
= 0;
62 DebugSupportRegisterPeriodicCallback (
63 IN EFI_DEBUG_SUPPORT_PROTOCOL
*This
,
64 IN UINTN ProcessorIndex
,
65 IN EFI_PERIODIC_CALLBACK PeriodicCallback
69 Routine Description: This is a DebugSupport protocol member function.
72 This - The DebugSupport instance
73 ProcessorIndex - Which processor the callback applies to.
74 PeriodicCallback - Callback function
79 EFI_INVALID_PARAMETER - requested uninstalling a handler from a vector that has
80 no handler registered for it
81 EFI_ALREADY_STARTED - requested install to a vector that already has a handler registered.
83 Other possible return values are passed through from UnHookEntry and HookEntry.
87 if (ProcessorIndex
!= 0) {
88 return EFI_INVALID_PARAMETER
;
91 if ((gPeriodicCallBack
!= (EFI_PERIODIC_CALLBACK
)NULL
) && (PeriodicCallback
!= (EFI_PERIODIC_CALLBACK
)NULL
)) {
92 return EFI_ALREADY_STARTED
;
95 gPeriodicCallBack
= PeriodicCallback
;
97 if (gDebugSupportCallback
!= NULL
) {
99 // We can only update this protocol if the Register Protocol Notify has fired. If it fires
100 // after this call it will update with gPeriodicCallBack value.
102 gDebugSupportCallback
->PeriodicCallback
= gPeriodicCallBack
;
111 DebugSupportRegisterExceptionCallback (
112 IN EFI_DEBUG_SUPPORT_PROTOCOL
*This
,
113 IN UINTN ProcessorIndex
,
114 IN EFI_EXCEPTION_CALLBACK NewCallback
,
115 IN EFI_EXCEPTION_TYPE ExceptionType
120 This is a DebugSupport protocol member function.
122 This code executes in boot services context.
125 This - The DebugSupport instance
126 ProcessorIndex - Which processor the callback applies to.
127 NewCallback - Callback function
128 ExceptionType - Which exception to hook
133 EFI_INVALID_PARAMETER - requested uninstalling a handler from a vector that has
134 no handler registered for it
135 EFI_ALREADY_STARTED - requested install to a vector that already has a handler registered.
137 Other possible return values are passed through from UnHookEntry and HookEntry.
141 if (ProcessorIndex
!= 0) {
142 return EFI_INVALID_PARAMETER
;
145 return RegisterDebuggerInterruptHandler (ExceptionType
, NewCallback
);
151 DebugSupportInvalidateInstructionCache (
152 IN EFI_DEBUG_SUPPORT_PROTOCOL
*This
,
153 IN UINTN ProcessorIndex
,
160 This is a DebugSupport protocol member function.
161 Calls assembly routine to flush cache.
164 This - The DebugSupport instance
165 ProcessorIndex - Which processor the callback applies to.
166 Start - Physical base of the memory range to be invalidated
167 Length - mininum number of bytes in instruction cache to invalidate
171 EFI_SUCCESS - always return success
175 if (ProcessorIndex
!= 0) {
176 return EFI_INVALID_PARAMETER
;
179 InvalidateInstructionCache();
185 // This is a global that is the actual interface
187 EFI_DEBUG_SUPPORT_PROTOCOL gDebugSupportProtocolInterface
= {
188 IsaArm
, // Fixme to be more generic
189 DebugSupportGetMaximumProcessorIndex
,
190 DebugSupportRegisterPeriodicCallback
,
191 DebugSupportRegisterExceptionCallback
,
192 DebugSupportInvalidateInstructionCache
198 DebugSupportPeriodicCallbackEventProtocolNotify (
205 Status
= gBS
->LocateProtocol (&gEfiDebugSupportPeriodicCallbackProtocolGuid
, NULL
, (VOID
**)&gDebugSupportCallback
);
206 if (!EFI_ERROR (Status
)) {
207 gDebugSupportCallback
->PeriodicCallback
= gPeriodicCallBack
;
211 VOID
*gRegistration
= NULL
;
214 EFI_DEBUG_SUPPORT_PROTOCOL
*
215 InitilaizeDebugSupport (
219 // RPN gEfiDebugSupportPeriodicCallbackProtocolGuid
223 if (!FeaturePcdGet (PcdCpuDxeProduceDebugSupport
)) {
224 // Don't include this code unless Feature Flag is set
229 Status
= gBS
->CreateEvent (
232 DebugSupportPeriodicCallbackEventProtocolNotify
,
236 ASSERT_EFI_ERROR (Status
);
238 Status
= gBS
->RegisterProtocolNotify (&gEfiDebugSupportPeriodicCallbackProtocolGuid
, Event
, &gRegistration
);
239 ASSERT_EFI_ERROR (Status
);
242 // We assume the Timer must depend on our driver to register interrupts so we don't need to do
243 // a gBS->SignalEvent (Event) here to check to see if the protocol allready exists
246 return &gDebugSupportProtocolInterface
;