]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/CapsulePei/Capsule.h
Correct 1G page table generation.
[mirror_edk2.git] / MdeModulePkg / Universal / CapsulePei / Capsule.h
1 /** @file
2
3 Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
4
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions
7 of the BSD License which accompanies this distribution. The
8 full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
10
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13
14 **/
15
16 #ifndef _CAPSULE_PEIM_H_
17 #define _CAPSULE_PEIM_H_
18
19 #include <PiPei.h>
20 #include <Uefi/UefiSpec.h>
21
22 #include <Ppi/Capsule.h>
23 #include <Ppi/LoadFile.h>
24 #include <Ppi/ReadOnlyVariable2.h>
25 #include <Guid/CapsuleVendor.h>
26
27 #include <Library/DebugLib.h>
28 #include <Library/PeimEntryPoint.h>
29 #include <Library/PeiServicesLib.h>
30 #include <Library/BaseMemoryLib.h>
31 #include <Library/HobLib.h>
32 #include <Library/PeiServicesTablePointerLib.h>
33 #include <Library/PrintLib.h>
34 #include <Library/PeCoffLib.h>
35 #include <Library/PeCoffGetEntryPointLib.h>
36 #include <Library/PcdLib.h>
37 #include <Library/ReportStatusCodeLib.h>
38 #include <IndustryStandard/PeImage.h>
39 #include "Common/CommonHeader.h"
40
41 #ifdef MDE_CPU_IA32
42
43 #pragma pack(1)
44
45 //
46 // Page-Map Level-4 Offset (PML4) and
47 // Page-Directory-Pointer Offset (PDPE) entries 4K & 2MB
48 //
49
50 typedef union {
51 struct {
52 UINT64 Present:1; // 0 = Not present in memory, 1 = Present in memory
53 UINT64 ReadWrite:1; // 0 = Read-Only, 1= Read/Write
54 UINT64 UserSupervisor:1; // 0 = Supervisor, 1=User
55 UINT64 WriteThrough:1; // 0 = Write-Back caching, 1=Write-Through caching
56 UINT64 CacheDisabled:1; // 0 = Cached, 1=Non-Cached
57 UINT64 Accessed:1; // 0 = Not accessed, 1 = Accessed (set by CPU)
58 UINT64 Reserved:1; // Reserved
59 UINT64 MustBeZero:2; // Must Be Zero
60 UINT64 Available:3; // Available for use by system software
61 UINT64 PageTableBaseAddress:40; // Page Table Base Address
62 UINT64 AvabilableHigh:11; // Available for use by system software
63 UINT64 Nx:1; // No Execute bit
64 } Bits;
65 UINT64 Uint64;
66 } PAGE_MAP_AND_DIRECTORY_POINTER;
67
68 //
69 // Page Table Entry 2MB
70 //
71 typedef union {
72 struct {
73 UINT64 Present:1; // 0 = Not present in memory, 1 = Present in memory
74 UINT64 ReadWrite:1; // 0 = Read-Only, 1= Read/Write
75 UINT64 UserSupervisor:1; // 0 = Supervisor, 1=User
76 UINT64 WriteThrough:1; // 0 = Write-Back caching, 1=Write-Through caching
77 UINT64 CacheDisabled:1; // 0 = Cached, 1=Non-Cached
78 UINT64 Accessed:1; // 0 = Not accessed, 1 = Accessed (set by CPU)
79 UINT64 Dirty:1; // 0 = Not Dirty, 1 = written by processor on access to page
80 UINT64 MustBe1:1; // Must be 1
81 UINT64 Global:1; // 0 = Not global page, 1 = global page TLB not cleared on CR3 write
82 UINT64 Available:3; // Available for use by system software
83 UINT64 PAT:1; //
84 UINT64 MustBeZero:8; // Must be zero;
85 UINT64 PageTableBaseAddress:31; // Page Table Base Address
86 UINT64 AvabilableHigh:11; // Available for use by system software
87 UINT64 Nx:1; // 0 = Execute Code, 1 = No Code Execution
88 } Bits;
89 UINT64 Uint64;
90 } PAGE_TABLE_ENTRY;
91
92 //
93 // Page Table Entry 1GB
94 //
95 typedef union {
96 struct {
97 UINT64 Present:1; // 0 = Not present in memory, 1 = Present in memory
98 UINT64 ReadWrite:1; // 0 = Read-Only, 1= Read/Write
99 UINT64 UserSupervisor:1; // 0 = Supervisor, 1=User
100 UINT64 WriteThrough:1; // 0 = Write-Back caching, 1=Write-Through caching
101 UINT64 CacheDisabled:1; // 0 = Cached, 1=Non-Cached
102 UINT64 Accessed:1; // 0 = Not accessed, 1 = Accessed (set by CPU)
103 UINT64 Dirty:1; // 0 = Not Dirty, 1 = written by processor on access to page
104 UINT64 MustBe1:1; // Must be 1
105 UINT64 Global:1; // 0 = Not global page, 1 = global page TLB not cleared on CR3 write
106 UINT64 Available:3; // Available for use by system software
107 UINT64 PAT:1; //
108 UINT64 MustBeZero:17; // Must be zero;
109 UINT64 PageTableBaseAddress:22; // Page Table Base Address
110 UINT64 AvabilableHigh:11; // Available for use by system software
111 UINT64 Nx:1; // 0 = Execute Code, 1 = No Code Execution
112 } Bits;
113 UINT64 Uint64;
114 } PAGE_TABLE_1G_ENTRY;
115
116 #pragma pack()
117
118 typedef
119 EFI_STATUS
120 (*COALESCE_ENTRY) (
121 IN EFI_PEI_SERVICES **PeiServices,
122 IN EFI_CAPSULE_BLOCK_DESCRIPTOR *BlockList,
123 IN OUT VOID **MemoryBase,
124 IN OUT UINTN *MemorySize
125 );
126
127 #endif
128
129 #endif