Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
btwise
OpenCorePKG_MOD
提交
c5797ab4
O
OpenCorePKG_MOD
项目概览
btwise
/
OpenCorePKG_MOD
通知
26
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
OpenCorePKG_MOD
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
c5797ab4
编写于
4月 03, 2020
作者:
V
vit9696
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
OcMemoryLib: Fix descriptor splitting and improve printing
上级
8c95b246
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
36 addition
and
13 deletion
+36
-13
Application/MmapDump/MmapDump.c
Application/MmapDump/MmapDump.c
+3
-2
Application/MmapDump/MmapDump.inf
Application/MmapDump/MmapDump.inf
+2
-0
Library/OcMemoryLib/MemoryMap.c
Library/OcMemoryLib/MemoryMap.c
+31
-11
未找到文件。
Application/MmapDump/MmapDump.c
浏览文件 @
c5797ab4
...
...
@@ -16,6 +16,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Library/UefiLib.h>
#include <Library/DebugLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/OcMemoryLib.h>
#include <Library/OcMiscLib.h>
#include <Library/UefiBootServicesTableLib.h>
...
...
@@ -69,8 +70,6 @@ UefiMain (
"MMDD: Note, that DEBUG version of the tool prints more
\n
"
));
OcPrintMemoryAttributesTable
();
MemoryMap
=
OcGetCurrentMemoryMap
(
&
MemoryMapSize
,
&
DescriptorSize
,
...
...
@@ -81,6 +80,7 @@ UefiMain (
);
if
(
MemoryMap
!=
NULL
)
{
OcPrintMemoryAttributesTable
();
OcSortMemoryMap
(
MemoryMapSize
,
MemoryMap
,
DescriptorSize
);
DEBUG
((
DEBUG_INFO
,
"MMDD: Dumping the original memory map
\n
"
));
OcPrintMemoryMap
(
MemoryMapSize
,
MemoryMap
,
DescriptorSize
);
...
...
@@ -92,6 +92,7 @@ UefiMain (
}
else
{
DEBUG
((
DEBUG_INFO
,
"MMDD: Cannot patch memory map - %r
\n
"
,
Status
));
}
FreePool
(
MemoryMap
);
}
else
{
DEBUG
((
DEBUG_INFO
,
"MMDD: Unable to obtain memory map
\n
"
));
}
...
...
Application/MmapDump/MmapDump.inf
浏览文件 @
c5797ab4
...
...
@@ -35,6 +35,7 @@
MmapDump.c
[Packages]
EfiPkg/EfiPkg.dec
MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec
OpenCorePkg/OpenCorePkg.dec
...
...
@@ -46,6 +47,7 @@
[LibraryClasses]
OcConsoleControlEntryModeGenericLib
OcMemoryLib
OcMiscLib
UefiApplicationEntryPoint
UefiLib
PcdLib
...
...
Library/OcMemoryLib/MemoryMap.c
浏览文件 @
c5797ab4
...
...
@@ -513,7 +513,7 @@ OcPrintMemoryDescritptor (
if
(
Desc
->
Type
<
ARRAY_SIZE
(
mEfiMemoryTypeDesc
))
{
Type
=
mEfiMemoryTypeDesc
[
Desc
->
Type
];
}
else
{
Type
=
"Invalid"
;
Type
=
"Invalid
"
;
}
SizeValue
=
EFI_PAGES_TO_SIZE
(
Desc
->
NumberOfPages
);
...
...
@@ -527,7 +527,7 @@ OcPrintMemoryDescritptor (
DEBUG
((
DEBUG_INFO
,
"%a [%a|%a|%a|%a|%a|%a|%a|%a|%a|%a|%a|%a|%a|%a] 0x%016LX-0x%016LX -> 0x%016X (%Lu %a)
\n
"
,
"
OCMM:
%a [%a|%a|%a|%a|%a|%a|%a|%a|%a|%a|%a|%a|%a|%a] 0x%016LX-0x%016LX -> 0x%016X (%Lu %a)
\n
"
,
Type
,
(
Desc
->
Attribute
&
EFI_MEMORY_RUNTIME
)
!=
0
?
"RUN"
:
" "
,
(
Desc
->
Attribute
&
EFI_MEMORY_CPU_CRYPTO
)
!=
0
?
"CRY"
:
" "
,
...
...
@@ -535,9 +535,9 @@ OcPrintMemoryDescritptor (
(
Desc
->
Attribute
&
EFI_MEMORY_RO
)
!=
0
?
"RO"
:
" "
,
(
Desc
->
Attribute
&
EFI_MEMORY_MORE_RELIABLE
)
!=
0
?
"MR"
:
" "
,
(
Desc
->
Attribute
&
EFI_MEMORY_NV
)
!=
0
?
"NV"
:
" "
,
(
Desc
->
Attribute
&
EFI_MEMORY_RP
)
!=
0
?
"RP"
:
" "
,
(
Desc
->
Attribute
&
EFI_MEMORY_XP
)
!=
0
?
"XP"
:
" "
,
(
Desc
->
Attribute
&
EFI_MEMORY_RO
)
!=
0
?
"RO"
:
" "
,
(
Desc
->
Attribute
&
EFI_MEMORY_RP
)
!=
0
?
"RP"
:
" "
,
(
Desc
->
Attribute
&
EFI_MEMORY_WP
)
!=
0
?
"WP"
:
" "
,
(
Desc
->
Attribute
&
EFI_MEMORY_UCE
)
!=
0
?
"UCE"
:
" "
,
(
Desc
->
Attribute
&
EFI_MEMORY_WB
)
!=
0
?
"WB"
:
" "
,
(
Desc
->
Attribute
&
EFI_MEMORY_WT
)
!=
0
?
"WT"
:
" "
,
...
...
@@ -557,15 +557,33 @@ OcPrintMemoryAttributesTable (
)
{
UINTN
Index
;
UINTN
RealSize
;
CONST
EFI_MEMORY_ATTRIBUTES_TABLE
*
MemoryAttributesTable
;
EFI_MEMORY_DESCRIPTOR
*
MemoryAttributesEntry
;
MemoryAttributesTable
=
OcGetMemoryAttributes
(
&
MemoryAttributesEntry
);
MemoryAttributesTable
=
OcGetMemoryAttributes
(
NULL
);
if
(
MemoryAttributesTable
==
NULL
)
{
DEBUG
((
DEBUG_INFO
,
"OCMM: MemoryAttributesTable is not present!
\n
"
));
return
;
}
//
// Printing may reallocate, so we create a copy of the memory attributes.
//
STATIC
UINT8
mMemoryAttributesTable
[
EFI_PAGE_SIZE
*
2
];
RealSize
=
(
UINTN
)
(
sizeof
(
EFI_MEMORY_ATTRIBUTES_TABLE
)
+
MemoryAttributesTable
->
NumberOfEntries
*
MemoryAttributesTable
->
DescriptorSize
);
if
(
RealSize
>
sizeof
(
mMemoryAttributesTable
))
{
DEBUG
((
DEBUG_INFO
,
"OCMM: MemoryAttributesTable has too large size %u!
\n
"
,
(
UINT32
)
RealSize
));
return
;
}
CopyMem
(
mMemoryAttributesTable
,
MemoryAttributesTable
,
RealSize
);
MemoryAttributesTable
=
(
EFI_MEMORY_ATTRIBUTES_TABLE
*
)
mMemoryAttributesTable
;
MemoryAttributesEntry
=
(
EFI_MEMORY_DESCRIPTOR
*
)
(
MemoryAttributesTable
+
1
);
DEBUG
((
DEBUG_INFO
,
"OCMM: MemoryAttributesTable:
\n
"
));
DEBUG
((
DEBUG_INFO
,
"OCMM: Version - 0x%08x
\n
"
,
MemoryAttributesTable
->
Version
));
DEBUG
((
DEBUG_INFO
,
"OCMM: NumberOfEntries - 0x%08x
\n
"
,
MemoryAttributesTable
->
NumberOfEntries
));
...
...
@@ -735,7 +753,7 @@ OcRealMemoryType (
//
// Use code for write-protected areas.
//
if
((
MemoryAttribte
->
Attribute
&
EFI_MEMORY_
WP
)
!=
0
)
{
if
((
MemoryAttribte
->
Attribute
&
EFI_MEMORY_
RO
)
!=
0
)
{
return
EfiRuntimeServicesCode
;
}
...
...
@@ -836,16 +854,15 @@ OcSplitMemoryEntryByAttribute (
}
NewMemoryMapEntry
=
NEXT_MEMORY_DESCRIPTOR
(
MemoryMapEntry
,
DescriptorSize
);
DiffPages
=
(
UINTN
)
(
MemoryMapEntry
->
NumberOfPages
-
MemoryAttribute
->
NumberOfPages
);
CopyMem
(
NewMemoryMapEntry
,
MemoryMapEntry
,
DescriptorSize
*
(
*
CurrentEntryCount
-
*
CurrentEntryIndex
)
);
MemoryMapEntry
->
Type
=
OcRealMemoryType
(
MemoryAttribute
);
MemoryMapEntry
->
NumberOfPages
=
Dif
fPages
;
NewMemoryMapEntry
->
PhysicalStart
+=
EFI_PAGES_TO_SIZE
(
Dif
fPages
);
NewMemoryMapEntry
->
NumberOfPages
-=
Dif
fPages
;
MemoryMapEntry
->
NumberOfPages
=
MemoryAttribute
->
NumberO
fPages
;
NewMemoryMapEntry
->
PhysicalStart
+=
EFI_PAGES_TO_SIZE
(
MemoryAttribute
->
NumberO
fPages
);
NewMemoryMapEntry
->
NumberOfPages
-=
MemoryAttribute
->
NumberO
fPages
;
//
// Current processed entry is now the one we need to process.
...
...
@@ -897,7 +914,8 @@ OcSplitMemoryMapByAttributes (
//
// We assume that the memory map and attribute table are sorted.
//
for
(
Index
=
0
;
Index
<
CurrentEntryCount
;
++
Index
)
{
Index
=
0
;
while
(
Index
<
CurrentEntryCount
)
{
//
// Split entry by as many attributes as possible.
//
...
...
@@ -969,6 +987,7 @@ OcSplitMemoryMapByAttributes (
*
MemoryMapSize
=
CurrentEntryCount
*
DescriptorSize
;
return
Status
;
}
continue
;
}
else
{
//
// Did not find a suitable attribute or processed all the attributes.
...
...
@@ -981,6 +1000,7 @@ OcSplitMemoryMapByAttributes (
MemoryMapEntry
,
DescriptorSize
);
++
Index
;
}
*
MemoryMapSize
=
CurrentEntryCount
*
DescriptorSize
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录