Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
btwise
OpenCorePKG_MOD
提交
5fcf850a
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,发现更多精彩内容 >>
提交
5fcf850a
编写于
4月 02, 2020
作者:
V
vit9696
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
OcMemoryLib: Introduce attribute manipulation code
上级
1fea2ad3
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
110 addition
and
0 deletion
+110
-0
Include/Library/OcMemoryLib.h
Include/Library/OcMemoryLib.h
+46
-0
Library/OcMemoryLib/MemoryMap.c
Library/OcMemoryLib/MemoryMap.c
+64
-0
未找到文件。
Include/Library/OcMemoryLib.h
浏览文件 @
5fcf850a
...
...
@@ -220,6 +220,52 @@ OcPrintMemoryAttributesTable (
VOID
);
/**
Refresh memory descriptor containing the specified address.
@param[in] MemoryMapSize Memory map size in bytes.
@param[in] MemoryMap Memory map to refresh.
@param[in] DescriptorSize Memory map descriptor size in bytes.
@param[in] Address Address contained in the updated entry.
@param[in] Type Memory type to assign to the entry.
@param[in] SetAttribues Attributes to set.
@param[in] DropAttributes Attributes to remove.
@retval EFI_SUCCESS on success.
@retval EFI_NOT_FOUND no entry contains the specified address.
@retval EFI_UNSUPPORTED memory attributes are not supported by the platform.
**/
EFI_STATUS
OcUpdateDescriptors
(
IN
UINTN
MemoryMapSize
,
IN
EFI_MEMORY_DESCRIPTOR
*
MemoryMap
,
IN
UINTN
DescriptorSize
,
IN
EFI_PHYSICAL_ADDRESS
Address
,
IN
EFI_MEMORY_TYPE
Type
,
IN
UINT64
SetAttributes
,
IN
UINT64
DropAttributes
);
/**
Refresh memory attributes entry containing the specified address.
@param[in] Address Address contained in the updated entry.
@param[in] Type Memory type to assign to the entry.
@param[in] SetAttribues Attributes to set.
@param[in] DropAttributes Attributes to remove.
@retval EFI_SUCCESS on success.
@retval EFI_NOT_FOUND no entry contains the specified address.
@retval EFI_UNSUPPORTED memory attributes are not supported by the platform.
**/
EFI_STATUS
OcUpdateAttributes
(
IN
EFI_PHYSICAL_ADDRESS
Address
,
IN
EFI_MEMORY_TYPE
Type
,
IN
UINT64
SetAttributes
,
IN
UINT64
DropAttributes
);
/**
Return pointer to PML4 table in PageTable and PWT and PCD flags in Flags.
...
...
Library/OcMemoryLib/MemoryMap.c
浏览文件 @
5fcf850a
...
...
@@ -476,3 +476,67 @@ OcPrintMemoryAttributesTable (
DEBUG
((
DEBUG_INFO
,
"OCMM: MemoryAttributesTable is not present!
\n
"
));
}
EFI_STATUS
OcUpdateDescriptors
(
IN
UINTN
MemoryMapSize
,
IN
EFI_MEMORY_DESCRIPTOR
*
MemoryMap
,
IN
UINTN
DescriptorSize
,
IN
EFI_PHYSICAL_ADDRESS
Address
,
IN
EFI_MEMORY_TYPE
Type
,
IN
UINT64
SetAttributes
,
IN
UINT64
DropAttributes
)
{
UINTN
Index
;
UINTN
EntryCount
;
EntryCount
=
MemoryMapSize
/
DescriptorSize
;
for
(
Index
=
0
;
Index
<
EntryCount
;
++
Index
)
{
if
(
AREA_WITHIN_DESCRIPTOR
(
MemoryMap
,
Address
,
1
))
{
MemoryMap
->
Attribute
=
Type
;
MemoryMap
->
Attribute
|=
SetAttributes
;
MemoryMap
->
Attribute
&=
~
DropAttributes
;
return
EFI_SUCCESS
;
}
MemoryMap
=
NEXT_MEMORY_DESCRIPTOR
(
MemoryMap
,
DescriptorSize
);
}
return
EFI_NOT_FOUND
;
}
EFI_STATUS
OcUpdateAttributes
(
IN
EFI_PHYSICAL_ADDRESS
Address
,
IN
EFI_MEMORY_TYPE
Type
,
IN
UINT64
SetAttributes
,
IN
UINT64
DropAttributes
)
{
UINTN
Index
;
CONST
EFI_MEMORY_ATTRIBUTES_TABLE
*
MemoryAttributesTable
;
EFI_MEMORY_DESCRIPTOR
*
MemoryAttributesEntry
;
for
(
Index
=
0
;
Index
<
gST
->
NumberOfTableEntries
;
++
Index
)
{
if
(
CompareGuid
(
&
gST
->
ConfigurationTable
[
Index
].
VendorGuid
,
&
gEfiMemoryAttributesTableGuid
))
{
MemoryAttributesTable
=
(
CONST
EFI_MEMORY_ATTRIBUTES_TABLE
*
)
gST
->
ConfigurationTable
[
Index
].
VendorTable
;
MemoryAttributesEntry
=
(
EFI_MEMORY_DESCRIPTOR
*
)
(
MemoryAttributesTable
+
1
);
return
OcUpdateDescriptors
(
MemoryAttributesTable
->
NumberOfEntries
*
MemoryAttributesTable
->
DescriptorSize
,
MemoryAttributesEntry
,
MemoryAttributesTable
->
DescriptorSize
,
Address
,
Type
,
SetAttributes
,
DropAttributes
);
}
}
return
EFI_UNSUPPORTED
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录