]> git.proxmox.com Git - mirror_edk2.git/blame - UefiCpuPkg/Library/SmmCpuFeaturesLib/Ia32/SmmStmSupport.c
UefiCpuPkg/SmmCpuFeaturesLibStm: Add STM library instance
[mirror_edk2.git] / UefiCpuPkg / Library / SmmCpuFeaturesLib / Ia32 / SmmStmSupport.c
CommitLineData
09119a00
MK
1/** @file\r
2 SMM STM support functions\r
3\r
4 Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.<BR>\r
5 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 <PiSmm.h>\r
16#include <Library/DebugLib.h>\r
17\r
18#include "SmmStm.h"\r
19\r
20///\r
21/// Page Table Entry\r
22///\r
23#define IA32_PG_P BIT0\r
24#define IA32_PG_RW BIT1\r
25#define IA32_PG_PS BIT7\r
26\r
27/**\r
28\r
29 Create 4G page table for STM.\r
30 4M Non-PAE page table in IA32 version.\r
31\r
32 @param PageTableBase The page table base in MSEG\r
33\r
34**/\r
35VOID\r
36StmGen4GPageTable (\r
37 IN UINTN PageTableBase\r
38 )\r
39{\r
40 UINTN Index;\r
41 UINT32 *Pte;\r
42 UINT32 Address;\r
43\r
44 Pte = (UINT32*)(UINTN)PageTableBase;\r
45\r
46 Address = 0;\r
47 for (Index = 0; Index < SIZE_4KB / sizeof (*Pte); Index++) {\r
48 *Pte = Address | IA32_PG_PS | IA32_PG_RW | IA32_PG_P;\r
49 Pte++;\r
50 Address += SIZE_4MB;\r
51 }\r
52}\r
53\r
54/**\r
55 This is SMM exception handle.\r
56 Consumed by STM when exception happen.\r
57\r
58 @param Context STM protection exception stack frame\r
59\r
60 @return the EBX value for STM reference.\r
61 EBX = 0: resume SMM guest using register state found on exception stack.\r
62 EBX = 1 to 0x0F: EBX contains a BIOS error code which the STM must record in the\r
63 TXT.ERRORCODE register and subsequently reset the system via\r
64 TXT.CMD.SYS_RESET. The value of the TXT.ERRORCODE register is calculated as\r
65 follows: TXT.ERRORCODE = (EBX & 0x0F) | STM_CRASH_BIOS_PANIC\r
66 EBX = 0x10 to 0xFFFFFFFF - reserved, do not use.\r
67\r
68**/\r
69UINT32\r
70EFIAPI\r
71SmmStmExceptionHandler (\r
72 IN OUT STM_PROTECTION_EXCEPTION_STACK_FRAME Context\r
73 )\r
74{\r
75 // TBD - SmmStmExceptionHandler, record information\r
76 DEBUG ((DEBUG_ERROR, "SmmStmExceptionHandler ...\n"));\r
77 //\r
78 // Skip this instruction and continue;\r
79 //\r
80 Context.Ia32StackFrame->Rip += Context.Ia32StackFrame->VmcsExitInstructionLength;\r
81\r
82 return 0;\r
83}\r