-/*++\r
-\r
-Copyright (c) 2006, Intel Corporation \r
-All rights reserved. This program and the accompanying materials \r
-are licensed and made available under the terms and conditions of the BSD License \r
-which accompanies this distribution. The full text of the license may be found at \r
-http://opensource.org/licenses/bsd-license.php \r
- \r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
-\r
-Module Name:\r
-\r
- plDebugSupport.c\r
-\r
-Abstract:\r
+/**@file\r
+ IA32 specific debug support functions\r
\r
- IA32 specific debug support functions\r
+Copyright (c) 2006 - 2007, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution. The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
\r
-Revision History\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
\r
---*/\r
+**/\r
\r
//\r
// private header files\r
IDT_ENTRY *IdtEntryTable = NULL;\r
DESCRIPTOR NullDesc = 0;\r
\r
-#ifndef EFI_NT_EMULATOR\r
STATIC\r
EFI_STATUS\r
CreateEntryStub (\r
\r
--*/\r
{\r
- EFI_STATUS Status;\r
UINT8 *StubCopy;\r
\r
//\r
// First, allocate a new buffer and copy the stub code into it\r
//\r
- Status = gBS->AllocatePool (EfiBootServicesData, StubSize, Stub);\r
- if (Status == EFI_SUCCESS) {\r
+ *Stub = AllocatePool (StubSize);\r
+ if (*Stub != NULL) {\r
StubCopy = *Stub;\r
- gBS->CopyMem (StubCopy, InterruptEntryStub, StubSize);\r
+ CopyMem (StubCopy, InterruptEntryStub, StubSize);\r
\r
//\r
// Next fixup the stub code for this vector\r
// fixup the jump target to point to the common entry\r
//\r
*(UINT32 *) &StubCopy[0x0e] = (UINT32) CommonIdtEntry - (UINT32) &StubCopy[StubSize];\r
+\r
+ return EFI_SUCCESS;\r
}\r
\r
- return Status;\r
+ return EFI_OUT_OF_RESOURCES;\r
}\r
\r
STATIC\r
Other possibilities are passed through by CreateEntryStub\r
\r
--*/\r
-// TODO: ) - add argument and description to function comment\r
{\r
BOOLEAN OldIntFlagState;\r
EFI_STATUS Status;\r
\r
Returns:\r
EFI_SUCCESS\r
- Other values are passed through from FreePool\r
\r
--*/\r
{\r
BOOLEAN OldIntFlagState;\r
- EFI_STATUS Status;\r
\r
OldIntFlagState = WriteInterruptFlag (0);\r
WriteIdt (ExceptionType, &(IdtEntryTable[ExceptionType].OrigDesc));\r
- Status = gBS->FreePool ((VOID *) (UINTN) IdtEntryTable[ExceptionType].StubEntry);\r
+ FreePool ((VOID *) (UINTN) IdtEntryTable[ExceptionType].StubEntry);\r
ZeroMem (&IdtEntryTable[ExceptionType], sizeof (IDT_ENTRY));\r
WriteInterruptFlag (OldIntFlagState);\r
\r
- return (Status);\r
+ return EFI_SUCCESS;\r
}\r
-#endif\r
\r
EFI_STATUS\r
ManageIdtEntryTable (\r
Other possible return values are passed through from UnHookEntry and HookEntry.\r
\r
--*/\r
-// TODO: ) - add argument and description to function comment\r
{\r
EFI_STATUS Status;\r
\r
Status = EFI_SUCCESS;\r
\r
-#ifndef EFI_NT_EMULATOR\r
- if (CompareDescriptor (&IdtEntryTable[ExceptionType].NewDesc, &NullDesc)) {\r
- //\r
- // we've already installed to this vector\r
- //\r
- if (NewCallback != NULL) {\r
+ if (FeaturePcdGet (PcdNtEmulatorEnable)) {\r
+ if (CompareDescriptor (&IdtEntryTable[ExceptionType].NewDesc, &NullDesc)) {\r
//\r
- // if the input handler is non-null, error\r
+ // we've already installed to this vector\r
//\r
- Status = EFI_ALREADY_STARTED;\r
+ if (NewCallback != NULL) {\r
+ //\r
+ // if the input handler is non-null, error\r
+ //\r
+ Status = EFI_ALREADY_STARTED;\r
+ } else {\r
+ Status = UnhookEntry (ExceptionType);\r
+ }\r
} else {\r
- Status = UnhookEntry (ExceptionType);\r
- }\r
- } else {\r
- //\r
- // no user handler installed on this vector\r
- //\r
- if (NewCallback == NULL) {\r
//\r
- // if the input handler is null, error\r
+ // no user handler installed on this vector\r
//\r
- Status = EFI_INVALID_PARAMETER;\r
- } else {\r
- Status = HookEntry (ExceptionType, NewCallback);\r
+ if (NewCallback == NULL) {\r
+ //\r
+ // if the input handler is null, error\r
+ //\r
+ Status = EFI_INVALID_PARAMETER;\r
+ } else {\r
+ Status = HookEntry (ExceptionType, NewCallback);\r
+ }\r
}\r
}\r
-#endif\r
+\r
return Status;\r
}\r
\r
Routine Description: This is a DebugSupport protocol member function.\r
\r
Arguments:\r
+ This - The DebugSupport instance\r
+ MaxProcessorIndex - The maximuim supported processor index\r
\r
-Returns: Always returns EFI_SUCCESS with *MaxProcessorIndex set to 0\r
+Returns:\r
+ Always returns EFI_SUCCESS with *MaxProcessorIndex set to 0\r
\r
--*/\r
-// TODO: This - add argument and description to function comment\r
-// TODO: MaxProcessorIndex - add argument and description to function comment\r
{\r
*MaxProcessorIndex = 0;\r
return (EFI_SUCCESS);\r
Routine Description: This is a DebugSupport protocol member function.\r
\r
Arguments:\r
+ This - The DebugSupport instance\r
+ ProcessorIndex - Which processor the callback applies to.\r
+ PeriodicCallback - Callback function\r
\r
Returns:\r
\r
+ EFI_SUCCESS\r
+ EFI_INVALID_PARAMETER - requested uninstalling a handler from a vector that has\r
+ no handler registered for it\r
+ EFI_ALREADY_STARTED - requested install to a vector that already has a handler registered.\r
+\r
+ Other possible return values are passed through from UnHookEntry and HookEntry.\r
+\r
--*/\r
-// TODO: This - add argument and description to function comment\r
-// TODO: ProcessorIndex - add argument and description to function comment\r
-// TODO: PeriodicCallback - add argument and description to function comment\r
{\r
return ManageIdtEntryTable (PeriodicCallback, SYSTEM_TIMER_VECTOR);\r
}\r
This code executes in boot services context.\r
\r
Arguments:\r
+ This - The DebugSupport instance\r
+ ProcessorIndex - Which processor the callback applies to.\r
+ NewCallback - Callback function\r
+ ExceptionType - Which exception to hook\r
\r
Returns:\r
\r
- None\r
+ EFI_SUCCESS\r
+ EFI_INVALID_PARAMETER - requested uninstalling a handler from a vector that has\r
+ no handler registered for it\r
+ EFI_ALREADY_STARTED - requested install to a vector that already has a handler registered.\r
+\r
+ Other possible return values are passed through from UnHookEntry and HookEntry.\r
\r
--*/\r
-// TODO: This - add argument and description to function comment\r
-// TODO: ProcessorIndex - add argument and description to function comment\r
-// TODO: NewCallback - add argument and description to function comment\r
-// TODO: ExceptionType - add argument and description to function comment\r
{\r
return ManageIdtEntryTable (NewCallback, ExceptionType);\r
}\r
\r
Routine Description:\r
This is a DebugSupport protocol member function.\r
- For IA32, this is a no-op since the instruction and data caches are coherent.\r
+ Calls assembly routine to flush cache.\r
\r
Arguments:\r
+ This - The DebugSupport instance\r
+ ProcessorIndex - Which processor the callback applies to.\r
+ Start - Physical base of the memory range to be invalidated\r
+ Length - mininum number of bytes in instruction cache to invalidate\r
\r
Returns:\r
\r
- None\r
+ EFI_SUCCESS - always return success\r
\r
--*/\r
-// TODO: This - add argument and description to function comment\r
-// TODO: ProcessorIndex - add argument and description to function comment\r
-// TODO: Start - add argument and description to function comment\r
-// TODO: Length - add argument and description to function comment\r
-// TODO: EFI_SUCCESS - add return value to function comment\r
{\r
+ AsmWbinvd ();\r
return EFI_SUCCESS;\r
}\r
\r
EFI_SUCCESS\r
EFI_UNSUPPORTED - if IA32 processor does not support FXSTOR/FXRSTOR instructions,\r
the context save will fail, so these processor's are not supported.\r
+ EFI_OUT_OF_RESOURCES - not resource to finish initialization\r
\r
--*/\r
-// TODO: EFI_OUT_OF_RESOURCES - add return value to function comment\r
{\r
if (!FxStorSupport ()) {\r
return EFI_UNSUPPORTED;\r
\r
Returns:\r
\r
- None\r
+ EFI_SUCCESS - always return success\r
\r
--*/\r
-// TODO: EFI_SUCCESS - add return value to function comment\r
{\r
EFI_EXCEPTION_TYPE ExceptionType;\r
\r
ManageIdtEntryTable (NULL, ExceptionType);\r
}\r
\r
- gBS->FreePool (IdtEntryTable);\r
+ FreePool (IdtEntryTable);\r
return EFI_SUCCESS;\r
}\r
\r
This code executes in exception context so no efi calls are allowed.\r
\r
Arguments:\r
+ ExceptionType - exception type\r
+ ContextRecord - system context\r
\r
Returns:\r
\r
None\r
\r
--*/\r
-// TODO: ExceptionType - add argument and description to function comment\r
-// TODO: ContextRecord - add argument and description to function comment\r
{\r
if (IdtEntryTable[ExceptionType].RegisteredCallback != NULL) {\r
if (ExceptionType != SYSTEM_TIMER_VECTOR) {\r