Ia32/VirtualMemory.c\r
Ia32/DxeLoadFunc.c\r
Ia32/ImageRead.c\r
+ Ia32/IdtVectorAsm.asm\r
+ Ia32/IdtVectorAsm.S | GCC\r
\r
[Sources.X64]\r
X64/DxeLoadFunc.c\r
gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplBuildShareCodeHobs\r
\r
[FeaturePcd.IA32]\r
+ gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplEnableIdt\r
gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode\r
\r
\r
(UINTN) gGdtEntries\r
};\r
\r
+GLOBAL_REMOVE_IF_UNREFERENCED IA32_DESCRIPTOR gLidtDescriptor = {\r
+ sizeof (X64_IDT_GATE_DESCRIPTOR) * 32 - 1,\r
+ 0\r
+};\r
+\r
VOID\r
HandOffToDxeCore (\r
IN EFI_PHYSICAL_ADDRESS DxeCoreEntryPoint,\r
EFI_PHYSICAL_ADDRESS BaseOfStack;\r
EFI_PHYSICAL_ADDRESS TopOfStack;\r
UINTN PageTables;\r
+ X64_IDT_GATE_DESCRIPTOR *IdtTable;\r
+ UINTN SizeOfTemplate;\r
+ VOID *TemplateBase;\r
+ EFI_PHYSICAL_ADDRESS VectorAddress;\r
+ UINT32 Index;\r
\r
Status = PeiServicesAllocatePages (EfiBootServicesData, EFI_SIZE_TO_PAGES (STACK_SIZE), &BaseOfStack);\r
ASSERT_EFI_ERROR (Status);\r
ASSERT_EFI_ERROR (Status);\r
\r
AsmWriteCr3 (PageTables);\r
- //\r
+\r
+\r
+ if (FeaturePcdGet (PcdDxeIplEnableIdt)) {\r
+ SizeOfTemplate = AsmGetVectorTemplatInfo (&TemplateBase);\r
+ \r
+ Status = PeiServicesAllocatePages (\r
+ EfiBootServicesData, \r
+ EFI_SIZE_TO_PAGES((SizeOfTemplate + sizeof (X64_IDT_GATE_DESCRIPTOR)) * 32), \r
+ &VectorAddress\r
+ );\r
+ \r
+ ASSERT_EFI_ERROR (Status);\r
+ \r
+ IdtTable = (X64_IDT_GATE_DESCRIPTOR *) (UINTN) (VectorAddress + SizeOfTemplate * 32);\r
+ for (Index = 0; Index < 32; Index++) {\r
+ IdtTable[Index].Ia32IdtEntry.Bits.GateType = 0x8e;\r
+ IdtTable[Index].Ia32IdtEntry.Bits.Reserved_0 = 0;\r
+ IdtTable[Index].Ia32IdtEntry.Bits.Selector = SYS_CODE64_SEL;\r
+ \r
+ IdtTable[Index].Ia32IdtEntry.Bits.OffsetLow = (UINT16) VectorAddress;\r
+ IdtTable[Index].Ia32IdtEntry.Bits.OffsetHigh = (UINT16) (VectorAddress >> 16);\r
+ IdtTable[Index].Offset32To63 = (UINT32) (VectorAddress >> 32);\r
+ IdtTable[Index].Reserved = 0;\r
+ \r
+ CopyMem ((VOID *) (UINTN) VectorAddress, TemplateBase, SizeOfTemplate);\r
+ AsmVectorFixup ((VOID *) (UINTN) VectorAddress, (UINT8) Index);\r
+ \r
+ VectorAddress += SizeOfTemplate;\r
+ }\r
+ \r
+ gLidtDescriptor.Base = (UINTN) IdtTable;\r
+ AsmWriteIdtr (&gLidtDescriptor);\r
+ }\r
+ //\r
// Go to Long Mode. Interrupts will not get turned on until the CPU AP is loaded.\r
// Call x64 drivers passing in single argument, a pointer to the HOBs.\r
// \r
--- /dev/null
+/*\r
+;-------------------------------------------------------------------------------\r
+;\r
+; Copyright (c) 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
+; 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
+; Module Name:\r
+;\r
+; IdtVectorAsm.S\r
+; \r
+; Abstract:\r
+; \r
+;\r
+;-------------------------------------------------------------------- --------\r
+*/\r
+\r
+ .text\r
+ .code32\r
+\r
+\r
+ .align 8\r
+ .globl ASM_PFX(AsmGetVectorTemplatInfo)\r
+ .globl ASM_PFX(AsmVectorFixup)\r
+/*\r
+;\r
+;-----------------------------------------------------------------------\r
+; Template of IDT Vector Handlers. \r
+;\r
+;-----------------------------------------------------------------------\r
+*/\r
+@VectorTemplateBase:\r
+ pushl %eax\r
+ .byte 0x6a # push #VectorNum\r
+@VectorNum:\r
+ .byte 0\r
+ movl CommonInterruptEntry, %eax\r
+ jmp *%eax\r
+@VectorTemplateEnd:\r
+\r
+\r
+ASM_PFX(AsmGetVectorTemplatInfo):\r
+ movl 4(%esp), %ecx\r
+ movl $@VectorTemplateBase, (%ecx)\r
+ movl $(@VectorTemplateEnd - @VectorTemplateBase), %eax\r
+ ret\r
+\r
+ASM_PFX(AsmVectorFixup):\r
+ movl 8(%esp), %eax\r
+ movl 4(%esp), %ecx\r
+ movb %al, (@VectorNum - @VectorTemplateBase)(%ecx)\r
+ ret\r
+\r
+/*\r
+; The follow algorithm is used for the common interrupt routine.\r
+\r
+;\r
+; +---------------------+ <-- 16-byte aligned ensured by processor\r
+; + Old SS +\r
+; +---------------------+\r
+; + Old RSP +\r
+; +---------------------+\r
+; + RFlags +\r
+; +---------------------+\r
+; + CS +\r
+; +---------------------+\r
+; + RIP +\r
+; +---------------------+\r
+; + Error Code +\r
+; +---------------------+\r
+; + Vector Number +\r
+; +---------------------+\r
+*/\r
+\r
+CommonInterruptEntry: \r
+ cli\r
+@@:\r
+ jmp @@\r
+\r
+\r
+\r
+\r
--- /dev/null
+;-------------------------------------------------------------------------------\r
+;\r
+; Copyright (c) 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
+; 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
+; Module Name:\r
+;\r
+; IdtVectorAsm.asm\r
+; \r
+; Abstract:\r
+; \r
+;\r
+;-------------------------------------------------------------------------------\r
+\r
+\r
+ .686p\r
+ .model flat,C\r
+ .code\r
+\r
+;\r
+;------------------------------------------------------------------------------\r
+; Generic IDT Vector Handlers for the Host. \r
+;\r
+;------------------------------------------------------------------------------\r
+\r
+ALIGN 8\r
+PUBLIC AsmGetVectorTemplatInfo\r
+PUBLIC AsmVectorFixup\r
+\r
+PUBLIC AsmVectorFixup\r
+\r
+@VectorTemplateBase:\r
+ push eax\r
+ db 6ah ; push #VectorNumber\r
+@VectorNum:\r
+ db 0\r
+ mov eax, CommonInterruptEntry\r
+ jmp eax\r
+@VectorTemplateEnd:\r
+\r
+\r
+AsmGetVectorTemplatInfo PROC\r
+ mov ecx, [esp + 4]\r
+ mov [ecx], @VectorTemplateBase\r
+ mov eax, (@VectorTemplateEnd - @VectorTemplateBase)\r
+ ret\r
+AsmGetVectorTemplatInfo ENDP\r
+\r
+\r
+AsmVectorFixup PROC\r
+ mov eax, dword ptr [esp + 8]\r
+ mov ecx, [esp + 4]\r
+ mov [ecx + (@VectorNum - @VectorTemplateBase)], al\r
+ ret\r
+AsmVectorFixup ENDP\r
+\r
+\r
+;---------------------------------------;\r
+; CommonInterruptEntry ;\r
+;---------------------------------------;\r
+; The follow algorithm is used for the common interrupt routine.\r
+\r
+;\r
+; +---------------------+ <-- 16-byte aligned ensured by processor\r
+; + Old SS +\r
+; +---------------------+\r
+; + Old RSP +\r
+; +---------------------+\r
+; + RFlags +\r
+; +---------------------+\r
+; + CS +\r
+; +---------------------+\r
+; + RIP +\r
+; +---------------------+\r
+; + Error Code +\r
+; +---------------------+\r
+; + Vector Number +\r
+; +---------------------+\r
+\r
+CommonInterruptEntry PROC \r
+ cli\r
+ \r
+ jmp $\r
+CommonInterruptEntry ENDP\r
+\r
+END\r
+\r
+\r
UINT64 Uint64;\r
} IA32_GDT;\r
\r
+typedef struct {\r
+ IA32_IDT_GATE_DESCRIPTOR Ia32IdtEntry;\r
+ UINT32 Offset32To63;\r
+ UINT32 Reserved;\r
+} X64_IDT_GATE_DESCRIPTOR;\r
+\r
//\r
// Page-Map Level-4 Offset (PML4) and\r
// Page-Directory-Pointer Offset (PDPE) entries 4K & 2MB\r
)\r
;\r
\r
+\r
+/**\r
+ \r
+ Fix up the vector number in the vector code.\r
+ \r
+ @param VectorBase Base address of the vector handler.\r
+ \r
+ @param VectorNum Index of vector.\r
+ \r
+**/\r
+VOID\r
+EFIAPI\r
+AsmVectorFixup (\r
+ VOID *VectorBase,\r
+ UINT8 VectorNum\r
+ );\r
+\r
+\r
+/**\r
+ \r
+ Get the information of vector template.\r
+ \r
+ @param TemplateBase Base address of the template code.\r
+ \r
+ @return Size of the Template code.\r
+ \r
+**/\r
+UINTN\r
+EFIAPI\r
+AsmGetVectorTemplatInfo (\r
+ OUT VOID **TemplateBase\r
+ );\r
+\r
+\r
#endif \r
\r
[PcdsFeatureFlag.IA32]\r
gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode|TRUE|BOOLEAN|0x0001003b\r
+ gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplEnableIdt|FALSE|BOOLEAN|0x0001003d\r
\r
\r
\r
[PcdsFeatureFlag.IA32]\r
gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode|TRUE\r
+ gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplEnableIdt|FALSE\r
\r
[PcdsFixedAtBuild.common]\r
gEfiMdePkgTokenSpaceGuid.PcdMaximumUnicodeStringLength|1000000\r
gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdStatusCodeUseMemory|FALSE\r
gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdStatusCodeUseOEM|TRUE\r
gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode|FALSE\r
+ gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplEnableIdt|FALSE\r
gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSupportEfiDecompress|TRUE\r
gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSupportTianoDecompress|TRUE\r
gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSupportCustomDecompress|TRUE\r