Compare commits

..

391 Commits

Author SHA1 Message Date
6acd6781ba SecurityPkg/OpalPasswordExtraInfoVariable.h: Remove the deprecated guid and variable.
After Opal solution enhance BlockSid solution to consume the TCG PP. This variable and guid definition is deprecated.

Signed-off-by: Eric Dong <eric.dong@intel.com>
2019-05-08 11:30:02 +08:00
54d5ab6a73 SecurityPkg/OpalPasswordSmm: Fix get BlockSid value error.
OpalDxe driver already enhanced to use TCG PP to send BlockSid request, so the old variable OPAL_EXTRA_INFO_VAR_NAME is not used by OpalDxe driver. But OpalSmm driver still consume this variable to decide whether need to send BlockSid when S3 resume. This patch fixed this issue by change OpalSmm driver to consume Tcg PP actions.

Signed-off-by: Eric Dong <eric.dong@intel.com>
2019-05-08 11:30:01 +08:00
833f9f2696 SecurityPkg/SmmTcg2PhysicalPresenceLib: Add Tcg2PhysicalPresenceLibGetManagementFlags support.
OpalPasswordSmm driver need to use this API from this library, so enable this API.

Signed-off-by: Eric Dong <eric.dong@intel.com>
2019-05-08 11:30:01 +08:00
9ae0b48624 UefiCpuPkg/MpInitLib: Avoid call PcdGet* in Ap & Bsp.
MicrocodeDetect function will run by every threads, and it will
use PcdGet to get PcdCpuMicrocodePatchAddress and
PcdCpuMicrocodePatchRegionSize, if change both PCD default to dynamic,
system will in non-deterministic behavior.

By design, UEFI/PI services are single threaded and not re-entrant
so Multi processor code should not use UEFI/PI services. Here, Pcd
protocol/PPI is used to access dynamic PCDs so it would result in
non-deterministic behavior.

This code get PCD value in BSP and save them in CPU_MP_DATA for Ap.

https://bugzilla.tianocore.org/show_bug.cgi?id=726

Cc: Crystal Lee <CrystalLee@ami.com.tw>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Eric Dong <eric.dong@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
(cherry picked from commit 1e3f7a3782)
2018-11-26 10:07:36 +08:00
785e1699ac SecurityPkg/OpalPWSupportLib: [CVE-2017-5753] Fix bounds check bypass
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1194

Speculative execution is used by processor to avoid having to wait for
data to arrive from memory, or for previous operations to finish, the
processor may speculate as to what will be executed.

If the speculation is incorrect, the speculatively executed instructions
might leave hints such as which memory locations have been brought into
cache. Malicious actors can use the bounds check bypass method (code
gadgets with controlled external inputs) to infer data values that have
been used in speculative operations to reveal secrets which should not
otherwise be accessed.

This commit will focus on the SMI handler(s) registered within the
OpalPasswordSupportLib and insert AsmLfence API to mitigate the bounds
check bypass issue.

For SMI handler SmmOpalPasswordHandler():

Under "case SMM_FUNCTION_SET_OPAL_PASSWORD:",
'&DeviceBuffer->OpalDevicePath' can points to a potential cross boundary
access of the 'CommBuffer' (controlled external inputs) during speculative
execution. This cross boundary access pointer is later passed as parameter
'DevicePath' into function OpalSavePasswordToSmm().

Within function OpalSavePasswordToSmm(), 'DevicePathLen' is an access to
the content in 'DevicePath' and can be inferred by code:
"CompareMem (&List->OpalDevicePath, DevicePath, DevicePathLen)". One can
observe which part of the content within either '&List->OpalDevicePath' or
'DevicePath' was brought into cache to possibly reveal the value of
'DevicePathLen'.

Hence, this commit adds a AsmLfence() after the boundary/range checks of
'CommBuffer' to prevent the speculative execution.

A more detailed explanation of the purpose of commit is under the
'Bounds check bypass mitigation' section of the below link:
https://software.intel.com/security-software-guidance/insights/host-firmware-speculative-execution-side-channel-mitigation

And the document at:
https://software.intel.com/security-software-guidance/api-app/sites/default/files/337879-analyzing-potential-bounds-Check-bypass-vulnerabilities.pdf

Cc: Star Zeng <star.zeng@intel.com>
Cc: Chao Zhang <chao.b.zhang@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
2018-11-21 09:28:21 +08:00
ddd7bc4ccb MdeModulePkg/SmmCorePerfLib: [CVE-2017-5753] Fix bounds check bypass
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1194

Speculative execution is used by processor to avoid having to wait for
data to arrive from memory, or for previous operations to finish, the
processor may speculate as to what will be executed.

If the speculation is incorrect, the speculatively executed instructions
might leave hints such as which memory locations have been brought into
cache. Malicious actors can use the bounds check bypass method (code
gadgets with controlled external inputs) to infer data values that have
been used in speculative operations to reveal secrets which should not
otherwise be accessed.

This commit will focus on the SMI handler(s) registered within the
SmmCorePerformanceLib and insert AsmLfence API to mitigate the bounds
check bypass issue.

For SMI handler SmmPerformanceHandlerEx():

Under "case SMM_PERF_FUNCTION_GET_GAUGE_DATA :",
'SmmPerfCommData->LogEntryKey' can be a potential cross boundary access of
the 'CommBuffer' (controlled external inputs) during speculative
execution. This cross boundary access is then assign to parameter
'LogEntryKey'. And the value of 'LogEntryKey' can be inferred by code:

  CopyMem (
    (UINT8 *) &GaugeDataEx[Index],
    (UINT8 *) &GaugeEntryExArray[LogEntryKey++],
    sizeof (GAUGE_DATA_ENTRY_EX)
    );

One can observe which part of the content within 'GaugeEntryExArray' was
brought into cache to possibly reveal the value of 'LogEntryKey'.

Hence, this commit adds a AsmLfence() after the boundary/range checks of
'CommBuffer' to prevent the speculative execution.

And there is 1 similar case for SMI handler SmmPerformanceHandler() as
well. This commit also handles it.

A more detailed explanation of the purpose of commit is under the
'Bounds check bypass mitigation' section of the below link:
https://software.intel.com/security-software-guidance/insights/host-firmware-speculative-execution-side-channel-mitigation

And the document at:
https://software.intel.com/security-software-guidance/api-app/sites/default/files/337879-analyzing-potential-bounds-Check-bypass-vulnerabilities.pdf

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
2018-11-21 09:27:39 +08:00
e997f66e75 UefiCpuPkg/PiSmmCpuDxeSmm: [CVE-2017-5753] Fix bounds check bypass
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1194

Speculative execution is used by processor to avoid having to wait for
data to arrive from memory, or for previous operations to finish, the
processor may speculate as to what will be executed.

If the speculation is incorrect, the speculatively executed instructions
might leave hints such as which memory locations have been brought into
cache. Malicious actors can use the bounds check bypass method (code
gadgets with controlled external inputs) to infer data values that have
been used in speculative operations to reveal secrets which should not
otherwise be accessed.

It is possible for SMI handler(s) to call EFI_SMM_CPU_PROTOCOL service
ReadSaveState() and use the content in the 'CommBuffer' (controlled
external inputs) as the 'CpuIndex'. So this commit will insert AsmLfence
API to mitigate the bounds check bypass issue within SmmReadSaveState().

For SmmReadSaveState():

The 'CpuIndex' will be passed into function ReadSaveStateRegister(). And
then in to ReadSaveStateRegisterByIndex().

With the call:
ReadSaveStateRegisterByIndex (
  CpuIndex,
  SMM_SAVE_STATE_REGISTER_IOMISC_INDEX,
  sizeof(IoMisc.Uint32),
  &IoMisc.Uint32
  );

The 'IoMisc' can be a cross boundary access during speculative execution.
Later, 'IoMisc' is used as the index to access buffers 'mSmmCpuIoWidth'
and 'mSmmCpuIoType'. One can observe which part of the content within
those buffers was brought into cache to possibly reveal the value of
'IoMisc'.

Hence, this commit adds a AsmLfence() after the check of 'CpuIndex'
within function SmmReadSaveState() to prevent the speculative execution.

A more detailed explanation of the purpose of commit is under the
'Bounds check bypass mitigation' section of the below link:
https://software.intel.com/security-software-guidance/insights/host-firmware-speculative-execution-side-channel-mitigation

And the document at:
https://software.intel.com/security-software-guidance/api-app/sites/default/files/337879-analyzing-potential-bounds-Check-bypass-vulnerabilities.pdf

Cc: Michael D Kinney <michael.d.kinney@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
Acked-by: Laszlo Ersek <lersek@redhat.com>
Regression-tested-by: Laszlo Ersek <lersek@redhat.com>
(cherry picked from commit 5b02be4d9a)
2018-11-14 09:09:57 +08:00
07e17a6278 MdeModulePkg/Variable: [CVE-2017-5753] Fix bounds check bypass
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1194

Speculative execution is used by processor to avoid having to wait for
data to arrive from memory, or for previous operations to finish, the
processor may speculate as to what will be executed.

If the speculation is incorrect, the speculatively executed instructions
might leave hints such as which memory locations have been brought into
cache. Malicious actors can use the bounds check bypass method (code
gadgets with controlled external inputs) to infer data values that have
been used in speculative operations to reveal secrets which should not
otherwise be accessed.

This commit will focus on the SMI handler(s) registered within the
Variable\RuntimeDxe driver and insert AsmLfence API to mitigate the
bounds check bypass issue.

For SMI handler SmmVariableHandler():

Under "case SMM_VARIABLE_FUNCTION_GET_VARIABLE:",
'SmmVariableHeader->NameSize' can be a potential cross boundary access of
the 'CommBuffer' (controlled external input) during speculative execution.

This cross boundary access is later used as the index to access array
'SmmVariableHeader->Name' by code:
"SmmVariableHeader->Name[SmmVariableHeader->NameSize/sizeof (CHAR16) - 1]"
One can observe which part of the content within array was brought into
cache to possibly reveal the value of 'SmmVariableHeader->NameSize'.

Hence, this commit adds a AsmLfence() after the boundary/range checks of
'CommBuffer' to prevent the speculative execution.

And there are 2 similar cases under
"case SMM_VARIABLE_FUNCTION_SET_VARIABLE:" and
"case SMM_VARIABLE_FUNCTION_VAR_CHECK_VARIABLE_PROPERTY_GET:" as well.
This commits also handles them.

Also, under "case SMM_VARIABLE_FUNCTION_SET_VARIABLE:",
'(UINT8 *)SmmVariableHeader->Name + SmmVariableHeader->NameSize' points to
the 'CommBuffer' (with some offset) and then passed as parameter 'Data' to
function VariableServiceSetVariable().

Within function VariableServiceSetVariable(), there is a sanity check for
EFI_VARIABLE_AUTHENTICATION_2 descriptor for the data pointed by 'Data'.
If this check is speculatively bypassed, potential cross-boundary data
access for 'Data' is possible to be revealed via the below function calls
sequence during speculative execution:

AuthVariableLibProcessVariable()
ProcessVarWithPk() or ProcessVarWithKek()

Within function ProcessVarWithPk() or ProcessVarWithKek(), for the code
"PayloadSize = DataSize - AUTHINFO2_SIZE (Data);", 'AUTHINFO2_SIZE (Data)'
can be a cross boundary access during speculative execution.

Then, 'PayloadSize' is possible to be revealed by the function call
sequence:

AuthServiceInternalUpdateVariableWithTimeStamp()
mAuthVarLibContextIn->UpdateVariable()
VariableExLibUpdateVariable()
UpdateVariable()
CopyMem()

Hence, this commit adds a AsmLfence() after the sanity check for
EFI_VARIABLE_AUTHENTICATION_2 descriptor upon 'Data' within function
VariableServiceSetVariable() to prevent the speculative execution.

Also, please note that the change made within function
VariableServiceSetVariable() will affect DXE as well. However, since we
only focuses on the SMM codes, the commit will introduce a new module
internal function called VariableLoadFence() to handle this. This internal
function will have 2 implementations (1 for SMM, 1 for DXE). For the SMM
implementation, it is a wrapper to call the AsmLfence() API; for the DXE
implementation, it is empty.

A more detailed explanation of the purpose of commit is under the
'Bounds check bypass mitigation' section of the below link:
https://software.intel.com/security-software-guidance/insights/host-firmware-speculative-execution-side-channel-mitigation

And the document at:
https://software.intel.com/security-software-guidance/api-app/sites/default/files/337879-analyzing-potential-bounds-Check-bypass-vulnerabilities.pdf

Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
Acked-by: Laszlo Ersek <lersek@redhat.com>
Regression-tested-by: Laszlo Ersek <lersek@redhat.com>
(cherry picked from commit e83d841fdc)
2018-11-14 09:09:57 +08:00
2cfea54e05 MdeModulePkg/SmmLockBox: [CVE-2017-5753] Fix bounds check bypass
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1194

Speculative execution is used by processor to avoid having to wait for
data to arrive from memory, or for previous operations to finish, the
processor may speculate as to what will be executed.

If the speculation is incorrect, the speculatively executed instructions
might leave hints such as which memory locations have been brought into
cache. Malicious actors can use the bounds check bypass method (code
gadgets with controlled external inputs) to infer data values that have
been used in speculative operations to reveal secrets which should not
otherwise be accessed.

This commit will focus on the SMI handler(s) registered within the
SmmLockBox driver and insert AsmLfence API to mitigate the
bounds check bypass issue.

For SMI handler SmmLockBoxHandler():

Under "case EFI_SMM_LOCK_BOX_COMMAND_SAVE:", the 'CommBuffer' (controlled
external inputs) is passed to function SmmLockBoxSave().

'TempLockBoxParameterSave.Length' can be a potential cross boundary access
of the 'CommBuffer' during speculative execution. This cross boundary
access is later passed as parameter 'Length' into function SaveLockBox().

Within function SaveLockBox(), the value of 'Length' can be inferred by
code:
"CopyMem ((VOID *)(UINTN)SmramBuffer, (VOID *)(UINTN)Buffer, Length);".
One can observe which part of the content within 'Buffer' was brought into
cache to possibly reveal the value of 'Length'.

Hence, this commit adds a AsmLfence() after the boundary/range checks of
'CommBuffer' to prevent the speculative execution.

And there is a similar case under "case EFI_SMM_LOCK_BOX_COMMAND_UPDATE:"
function SmmLockBoxUpdate() as well. This commits also handles it.

A more detailed explanation of the purpose of commit is under the
'Bounds check bypass mitigation' section of the below link:
https://software.intel.com/security-software-guidance/insights/host-firmware-speculative-execution-side-channel-mitigation

And the document at:
https://software.intel.com/security-software-guidance/api-app/sites/default/files/337879-analyzing-potential-bounds-Check-bypass-vulnerabilities.pdf

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
Acked-by: Laszlo Ersek <lersek@redhat.com>
Regression-tested-by: Laszlo Ersek <lersek@redhat.com>
(cherry picked from commit ee65b84e76)
2018-11-14 09:09:57 +08:00
5cb3ae7a54 MdeModulePkg/FaultTolerantWrite:[CVE-2017-5753]Fix bounds check bypass
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1194

Speculative execution is used by processor to avoid having to wait for
data to arrive from memory, or for previous operations to finish, the
processor may speculate as to what will be executed.

If the speculation is incorrect, the speculatively executed instructions
might leave hints such as which memory locations have been brought into
cache. Malicious actors can use the bounds check bypass method (code
gadgets with controlled external inputs) to infer data values that have
been used in speculative operations to reveal secrets which should not
otherwise be accessed.

This commit will focus on the SMI handler(s) registered within the
FaultTolerantWriteDxe driver and insert AsmLfence API to mitigate the
bounds check bypass issue.

For SMI handler SmmFaultTolerantWriteHandler():

Under "case FTW_FUNCTION_WRITE:", 'SmmFtwWriteHeader->Length' can be a
potential cross boundary access of the 'CommBuffer' (controlled external
inputs) during speculative execution. This cross boundary access is later
passed as parameter 'Length' into function FtwWrite().

Within function FtwWrite(), the value of 'Length' can be inferred by code:
"CopyMem (MyBuffer + Offset, Buffer, Length);". One can observe which part
of the content within 'Buffer' was brought into cache to possibly reveal
the value of 'Length'.

Hence, this commit adds a AsmLfence() after the boundary/range checks of
'CommBuffer' to prevent the speculative execution.

A more detailed explanation of the purpose of commit is under the
'Bounds check bypass mitigation' section of the below link:
https://software.intel.com/security-software-guidance/insights/host-firmware-speculative-execution-side-channel-mitigation

And the document at:
https://software.intel.com/security-software-guidance/api-app/sites/default/files/337879-analyzing-potential-bounds-Check-bypass-vulnerabilities.pdf

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
Acked-by: Laszlo Ersek <lersek@redhat.com>
Regression-tested-by: Laszlo Ersek <lersek@redhat.com>
(cherry picked from commit cb54cd2463)
2018-11-14 09:09:57 +08:00
84f5807928 MdePkg/BaseLib: Add new AsmLfence API
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1193

This commit will add a new BaseLib API AsmLfence(). This API will perform
a serializing operation on all load-from-memory instructions that were
issued prior to the call of this function. Please note that this API is
only available on IA-32 and x64.

The purpose of adding this API is to mitigate of the [CVE-2017-5753]
Bounds Check Bypass issue when untrusted data are being processed within
SMM. More details can be referred at the 'Bounds check bypass mitigation'
section at the below link:

https://software.intel.com/security-software-guidance/insights/host-firmware-speculative-execution-side-channel-mitigation

Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Leif Lindholm <leif.lindholm@linaro.org>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
Acked-by: Laszlo Ersek <lersek@redhat.com>
Regression-tested-by: Laszlo Ersek <lersek@redhat.com>
(cherry picked from commit 2ecd829972)
2018-11-14 09:09:57 +08:00
dc52d24609 UefiCpuPkg/SmmCpuFeaturesLib: [CVE-2017-5715] Stuff RSB before RSM
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1093

Return Stack Buffer (RSB) is used to predict the target of RET
instructions. When the RSB underflows, some processors may fall back to
using branch predictors. This might impact software using the retpoline
mitigation strategy on those processors.

This commit will add RSB stuffing logic before returning from SMM (the RSM
instruction) to avoid interfering with non-SMM usage of the retpoline
technique.

After the stuffing, RSB entries will contain a trap like:

@SpecTrap:
    pause
    lfence
    jmp     @SpecTrap

A more detailed explanation of the purpose of commit is under the
'Branch target injection mitigation' section of the below link:
https://software.intel.com/security-software-guidance/insights/host-firmware-speculative-execution-side-channel-mitigation

Please note that this commit requires further actions (BZ 1091) to remove
the duplicated 'StuffRsb.inc' files and merge them into one under a
UefiCpuPkg package-level directory (such as UefiCpuPkg/Include/).

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1091

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
(cherry picked from commit 0df5056012)
2018-11-14 09:09:57 +08:00
34a5f0e3e3 UefiCpuPkg/PiSmmCpuDxeSmm: [CVE-2017-5715] Stuff RSB before RSM
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1093

Return Stack Buffer (RSB) is used to predict the target of RET
instructions. When the RSB underflows, some processors may fall back to
using branch predictors. This might impact software using the retpoline
mitigation strategy on those processors.

This commit will add RSB stuffing logic before returning from SMM (the RSM
instruction) to avoid interfering with non-SMM usage of the retpoline
technique.

After the stuffing, RSB entries will contain a trap like:

@SpecTrap:
    pause
    lfence
    jmp     @SpecTrap

A more detailed explanation of the purpose of commit is under the
'Branch target injection mitigation' section of the below link:
https://software.intel.com/security-software-guidance/insights/host-firmware-speculative-execution-side-channel-mitigation

Please note that this commit requires further actions (BZ 1091) to remove
the duplicated 'StuffRsb.inc' files and merge them into one under a
UefiCpuPkg package-level directory (such as UefiCpuPkg/Include/).

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1091

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Acked-by: Laszlo Ersek <lersek@redhat.com>
Regression-tested-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
(cherry picked from commit 02f7fd158e)
2018-11-14 09:09:57 +08:00
ba09813128 IntelFrameworkModulePkg: Fix UEFI and Tiano Decompression logic issue
https://bugzilla.tianocore.org/show_bug.cgi?id=1317

This is a regression issue caused by 684db6da64.
In Decode() function, once mOutBuf is fully filled, Decode() should return.
Current logic misses the checker of mOutBuf after while() loop.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
(cherry picked from commit ade71c52a4)
2018-11-14 08:39:50 +08:00
66566e28b5 MdePkg BaseUefiDecompressLib: Fix UEFI Decompression logic issue
https://bugzilla.tianocore.org/show_bug.cgi?id=1317

This is a regression issue caused by 2ec7953d49.
In Decode() function, once mOutBuf is fully filled, Decode() should return.
Current logic misses the checker of mOutBuf after while() loop.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Cc: Michael Kinney <michael.d.kinney@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
(cherry picked from commit 1c4cecc9fd)
2018-11-14 08:39:49 +08:00
b633c7357d BaseTools: Fix UEFI and Tiano Decompression logic issue
https://bugzilla.tianocore.org/show_bug.cgi?id=1317

This is a regression issue caused by 041d89bc0f.
In Decode() function, once mOutBuf is fully filled, Decode() should return.
Current logic misses the checker of mOutBuf after while() loop.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
(cherry picked from commit 5e45a1fdcf)
2018-11-14 08:39:48 +08:00
c924df7ccf IntelSiliconPkg IntelVTdDxe: Check HeaderType if func 0 is implemented
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1169

Current code checks HeaderType of Function 0 even Function 0 is not
implemented. HeaderType value will be 0xFF if Function 0 is not
implemented, then MaxFunction will be set to PCI_MAX_FUNC + 1.

The code can be optimized to only check HeaderType if Function 0 is
implemented.

Test done:
With this patch, the result is same with the result after the patch at
https://lists.01.org/pipermail/edk2-devel/2018-September/029623.html.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Rangasai V Chaganty <rangasai.v.chaganty@intel.com>
Cc: Tomson Chang <tomson.chang@intel.com>
Cc: Jenny Huang <jenny.huang@intel.com>
Cc: Amy Chan <amy.chan@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
(cherry picked from commit b06dfd40bb)
2018-11-07 22:07:01 +08:00
935c402311 IntelSiliconPkg IntelVTdDxe: Optimize when func 0 is not implemented
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1169

PCI spec:
They are also required to always implement function 0 in the device.
Implementing other functions is optional and may be assigned in any
order (i.e., a two-function device must respond to function 0 but
can choose any of the other possible function numbers (1-7) for the
second function).

This patch updates ScanPciBus() to not scan other functions if
function 0 is not implemented.

Test done:
Added debug code below in the second loop of ScanPciBus(),
compared the debug logs with and without this patch, many
non-0 unimplemented functions are skipped correctly.

  DEBUG ((
    DEBUG_INFO,
    "%a() B%02xD%02xF%02x VendorId: %04x DeviceId: %04x\n",
    __FUNCTION__,
    Bus,
    Device,
    Function,
    VendorID,
    DeviceID
    ));

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Rangasai V Chaganty <rangasai.v.chaganty@intel.com>
Cc: Tomson Chang <tomson.chang@intel.com>
Cc: Jenny Huang <jenny.huang@intel.com>
Cc: Amy Chan <amy.chan@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
(cherry picked from commit e69d7e99e7)
2018-11-07 22:06:59 +08:00
1d707a02d8 BaseTools: Add more checker in Decompress algorithm to access the valid buffer (CVE FIX)
Fix CVE-2017-5731,CVE-2017-5732,CVE-2017-5733,CVE-2017-5734,CVE-2017-5735
https://bugzilla.tianocore.org/show_bug.cgi?id=686

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Holtsclaw Brent <brent.holtsclaw@intel.com>
Signed-off-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
Acked-by: Laszlo Ersek <lersek@redhat.com>
(cherry picked from commit 041d89bc0f)
2018-10-24 09:44:07 +08:00
5f0a27fcf9 IntelFrameworkModulePkg: Add more checker in UefiTianoDecompressLib (CVE FIX)
Fix CVE-2017-5731,CVE-2017-5732,CVE-2017-5733,CVE-2017-5734,CVE-2017-5735
https://bugzilla.tianocore.org/show_bug.cgi?id=686
To make sure the valid buffer be accessed only.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Holtsclaw Brent <brent.holtsclaw@intel.com>
Signed-off-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
Acked-by: Laszlo Ersek <lersek@redhat.com>
(cherry picked from commit 684db6da64)
2018-10-24 09:44:06 +08:00
167e6e48af MdePkg: Add more checker in UefiDecompressLib to access the valid buffer only (CVE FIX)
Fix CVE-2017-5731,CVE-2017-5732,CVE-2017-5733,CVE-2017-5734,CVE-2017-5735
https://bugzilla.tianocore.org/show_bug.cgi?id=686

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Holtsclaw Brent <brent.holtsclaw@intel.com>
Signed-off-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
Acked-by: Laszlo Ersek <lersek@redhat.com>
(cherry picked from commit 2ec7953d49)
2018-10-24 09:44:05 +08:00
5c693e581e MdeModulePkg Variable: Fix Timestamp zeroing issue on APPEND_WRITE
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=415

When SetVariable() to a time based auth variable with APPEND_WRITE
attribute, and if the EFI_VARIABLE_AUTHENTICATION_2.TimeStamp in
the input Data is earlier than current value, it will cause timestamp
zeroing.

This issue may bring time based auth variable downgrade problem.
For example:
A vendor released three certs at 2014, 2015, and 2016, and system
integrated the 2016 cert. User can SetVariable() with 2015 cert and
APPEND_WRITE attribute to cause timestamp zeroing first, then
SetVariable() with 2014 cert to downgrade the cert.

This patch fixes this issue.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Chao Zhang <chao.b.zhang@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
(cherry picked from commit b7dc8888f3)
2018-10-17 11:30:42 +08:00
acaa5d7382 MdeModulePkg/NvmExpressDxe: fix error status override
Commit f6b139b added return status handling to PciIo->Mem.Write.
However, the second status handling will override EFI_DEVICE_ERROR
returned in this branch:

  //
  // Check the NVMe cmd execution result
  //
  if (Status != EFI_TIMEOUT) {
    if ((Cq->Sct == 0) && (Cq->Sc == 0)) {
      Status = EFI_SUCCESS;
    } else {
      Status = EFI_DEVICE_ERROR;
               ^^^^^^^^^^^^^^^^

Since PciIo->Mem.Write will probably return SUCCESS, it causes
NvmExpressPassThru to return SUCCESS even when DEVICE_ERROR occurs.
Callers of NvmExpressPassThru will then continue executing which may
cause further unexpected results, e.g. DiscoverAllNamespaces couldn't
break out the loop.

So we save previous status before calling PciIo->Mem.Write and restore
the previous one if it already contains error.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Heyi Guo <heyi.guo@linaro.org>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit 9a77210b43)
2018-09-20 15:21:29 +08:00
87acb6e298 SecurityPkg OpalPasswordSupportLib: Add check to avoid potential buffer overflow.
Current code not check the CommunicationBuffer size before use it. Attacker can
read beyond the end of the (untrusted) commbuffer into controlled memory. Attacker
can get access outside of valid SMM memory regions. This patch add check before
use it.

bugz: https://bugzilla.tianocore.org/show_bug.cgi?id=198

Cc: Yao Jiewen <jiewen.yao@intel.com>
Cc: Wu Hao <hao.a.wu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Eric Dong <eric.dong@intel.com>
Reviewed-by: Yao Jiewen <jiewen.yao@intel.com>
2018-08-01 19:11:00 +08:00
c4c7fb388e UefiCpuPkg/PiSmmCpu: Check GCD and UEFI mem attrib table.
1) UefiCpuPkg/PiSmmCpu: Check for untested memory in GCD

It treats GCD untested memory as invalid SMM
communication buffer.

2) UefiCpuPkg/PiSmmCpu: Check EFI_RUNTIME_RO in UEFI mem attrib table.

It treats the UEFI runtime page with EFI_MEMORY_RO attribute as
invalid SMM communication buffer.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
2018-07-26 23:06:45 +08:00
dcfd55d97a MdeModulePkg/DxeCore: Not update RtCode in MemAttrTable after EndOfDxe
We want to provide precise info in MemAttribTable
to both OS and SMM, and SMM only gets the info at EndOfDxe.
So we do not update RtCode entry in EndOfDxe.

The impact is that if 3rd part OPROM is runtime, it cannot be executed
at UEFI runtime phase.
Currently, we do not see compatibility issue, because the only runtime
OPROM we found before in UNDI, and UEFI OS will not use UNDI interface
in OS.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
2018-07-26 23:06:44 +08:00
818d60f48b MdeModulePkg/DxeCore: Install UEFI mem attrib table at EndOfDxe.
So that the SMM can consume it to set page protection for
the UEFI runtime page with EFI_MEMORY_RO attribute.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
2018-07-26 23:06:43 +08:00
1f71fd55b3 MdePkg/SmmMemLib: Check EFI_MEMORY_RO in UEFI mem attrib table.
It treats the UEFI runtime page with EFI_MEMORY_RO attribute as
invalid SMM communication buffer.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
2018-07-26 23:06:42 +08:00
c127d3953b MdePkg/SmmMemLib: Check for untested memory in GCD
It treats GCD untested memory as invalid SMM
communication buffer.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
2018-07-26 23:06:41 +08:00
993fb9ee22 SignedCapsulePkg SystemFirmwareUpdateDxe: Fix failure caused by d69d922
d69d9227d0 caused system firmware update
failure. It is because FindMatchingFmpHandles() is expected to return
handles matched, but the function returns all handles found.

This patch is to fix the issue.
This patch also assigns mSystemFmpPrivate->Handle for "case 1:" path
in case the Handle is needed by other place in future.

Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
(cherry picked from commit 665bfd41ac)
2018-07-13 09:44:13 +08:00
c3e2883788 SignedCapsulePkg/SystemFirmwareReportDxe: Pass thru on same handle
https://bugzilla.tianocore.org/show_bug.cgi?id=928

Use HandleProtocol() to pass thru a SetImage() call to the
System FMP Protocol that must be on the same handle as the
FMP Protocol.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
(cherry picked from commit 153f5c7a93)
2018-07-13 09:44:11 +08:00
688829df30 SignedCapsulePkg/SystemFirmwareUpdateDxe: Single FMP
https://bugzilla.tianocore.org/show_bug.cgi?id=928

Uninstall all System FMP Protocols for the current FW device.

If an FMP Protocol for the current FW device is already present,
then install the new System FMP protocol onto the same handle as
the FMP Protocol.  Otherwise, install the FMP protocol onto a
new handle.

This supports use cases where multiple capsules for the
same system firmware device are processed on the same
boot of the platform.  It guarantees there is at most one
FMP protocol for each system firmware device.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
(cherry picked from commit d69d9227d0)
2018-07-13 09:44:10 +08:00
2b22fe75c4 MdeModulePkg/PciHostBridgeDxe: Make bitwise operands of the same size
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
(cherry picked from commit 8df95dd04f)
2018-06-06 16:28:04 +08:00
ac8d86234d MdeModulePkg/PciHostBridgeDxe: Fix EBC build failure
Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
(cherry picked from commit 7a85e84741)
2018-06-06 16:28:02 +08:00
f09d6323b1 SecurityPkg:Tcg2Smm: Update TcgNvs info after memory is allocated
Update package format info in _PRS to TcgNvs after memory is allocated.

Change-Id: Icfadb350e60d3ed2df332e92c257ce13309c0018
Contributed-under: TianoCore Contribution Agreement 1.1
Cc: Yao Jiewen <jiewen.yao@intel.com>
Cc: Long Qin <qin.long@intel.com>
Signed-off-by: Zhang, Chao B <chao.b.zhang@intel.com>
Reviewed-by: Long Qin <qin.long@intel.com>
(cherry picked from commit 1ea08a3dcd)
(cherry picked from commit fb8254478f7259d22d8433f6729307e001b81bdd)
2018-05-25 22:14:46 +08:00
5b529feaaa MdePkg/ResetNotification: Rename to UnregisterResetNotify
UEFI Spec uses UnRegisterResetNotify in protocol structure
definition but uses UnregisterResetNotify in the function
prototype definition.

By searching the entire spec, Unregister* is used for
SIMPLE_TEXT_INPUT_EX_PROTOCOL.UnregisterKeyNotify(). So choose
to use UnregisterResetNotify for consistency.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit fcccba378b)
2018-05-25 12:53:25 +08:00
3adc5a5fcd MdePkg: Add ResetNotification protocol definition
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit 342470a6f8)
2018-05-25 12:53:24 +08:00
0960db18cf MdePkg/SmmPeriodicSmiLib: Get Periodic SMI Context More Robustly
The PeriodicSmiDispatchFunction() in SmmPeriodicSmiLib may assert
with "Bad CR signature".

Currently, the SetActivePeriodicSmiLibraryHandler() function
(invoked at the beginning of the PeriodicSmiDispatchFunction()
function) attempts to locate the PERIODIC_SMI_LIBRARY_HANDLER_CONTEXT
structure pointer for the current periodic SMI from a given
EFI_SMM_PERIODIC_TIMER_REGISTER_CONTEXT (RegiserContext) structure
pointer (using the CR macro).

The RegisterContext structure pointer passed to the
PeriodicSmiDispatchFunction() is assumed to point to the same
RegisterContext structure address given to the
SmmPeriodicTimerDispatch2 protocol Register() API in
PeriodicSmiEnable().

However, certain SmmPeriodicTimerDispatch2 implementation may copy
the RegisterContext to a local buffer and pass that address as the
context to PeriodicSmiDispatchFunction() in which case usage of the
CR macro to find the parent structure base fails.

The patch uses the LookupPeriodicSmiLibraryHandler() function to
find the PERIODIC_SMI_LIBRARY_HANDLER_CONTEXT structure pointer.
This works even in this scenario since the DispatchHandle returned
from the SmmPeriodicTimerDispatch2 Register() function uniquely
identifies that registration.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit 1e35fcc9ee)
2018-05-21 12:49:20 +08:00
f78e28426d SourceLevelDebugPkg DebugCommUsb3: Return error when debug cap is reset
When source level debug is enabled, but debug cable is not connected,
XhcResetHC() in XhciReg.c will reset the host controller, the debug
capability registers will be also reset. After the code in
InitializeUsbDebugHardware() sets DCE bit and LSE bit to "1" in DCCTRL,
there will be DMA on 0 (the value of some debug capability registers
for data transfer is 0) address buffer, fault info like below will
appear when IOMMU based on VTd is enabled.

  VER_REG     - 0x00000010
  CAP_REG     - 0x00D2008C40660462
  ECAP_REG    - 0x0000000000F050DA
  GSTS_REG    - 0xC0000000
  RTADDR_REG  - 0x0000000086512000
  CCMD_REG    - 0x2800000000000000
  FSTS_REG    - 0x00000002
  FECTL_REG   - 0xC0000000
  FEDATA_REG  - 0x00000000
  FEADDR_REG  - 0x00000000
  FEUADDR_REG - 0x00000000
  FRCD_REG[0] - 0xC0000006000000A0 0000000000000000
    Fault Info - 0x0000000000000000
    Source - B00 D14 F00
    Type - 1 (read)
    Reason - 6
  IVA_REG     - 0x0000000000000000
  IOTLB_REG   - 0x1200000000000000

This patch is to return error for the case.

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Hao Wu <hao.a.wu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Hao Wu <hao.a.wu@intel.com>
(cherry picked from commit df67a480eb)
2018-05-11 17:50:10 +08:00
bc3aba79b8 SourceLevelDebugPkg DebugUsb3: Re-Support IOMMU
de8373fa07 could not handle two cases.
1. For the case that the USB3 debug port instance and DMA buffers are
from PEI HOB with IOMMU enabled, it was to reallocate the DMA buffers
by AllocateAddress with the memory type accessible by SMM environment.
But reallocating the DMA buffers by AllocateAddress may fail.

2. At S3 resume, after the code is transferred to PiSmmCpuDxeSmm from
S3Resume2Pei, HOB is still needed to be used for DMA operation, but
PiSmmCpuDxeSmm has no way to get the HOB at S3 resume.

The patch is to re-support IOMMU.
For PEI, allocate granted DMA buffer from IOMMU PPI, register IOMMU PPI
notification to reinitialize hardware with granted DMA buffer if IOMMU
PPI is not present yet.
For DXE, map DMA buffer by PciIo in PciIo notification for early DXE,
and register DxeSmmReadyToLock notification to reinitialize hardware
with granted DXE DMA buffer accessible by SMM environment for late DXE.

DebugAgentLib has been managing the instance as Handle in
HOB/SystemTable. The Handle(instance) from DebugAgentLib can be used
directly in DebugCommunicationLibUsb3. Then DebugCommunicationLibUsb3
could get consistent Handle(instance) from DebugAgentLib.

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Hao Wu <hao.a.wu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Hao Wu <hao.a.wu@intel.com>
(cherry picked from commit 75787f6580)
2018-05-11 17:50:08 +08:00
2fe3f4d969 SourceLevelDebugPkg DebugCommUsb3: Refine some formats/comments
Refine some formats/comments and remove some unused prototypes.

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Hao Wu <hao.a.wu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Hao Wu <hao.a.wu@intel.com>
(cherry picked from commit f0c562761f)
2018-05-11 17:50:06 +08:00
fe7868f81c SourceLevelDebugPkg DebugUsb3: Re-Fix GCC build failures
Fix GCC build failures below.
variable 'EvtTrb' set but not used [-Werror=unused-but-set-variable]
variable 'Index' set but not used [-Werror=unused-but-set-variable]

The build failure could only be caught with -D SOURCE_DEBUG_USE_USB3
build flag.

ad6040ec9b needs to be also reverted
when reverting IOMMU support patches, otherwise there will be conflict.
This patch is to re-do ad6040ec9b.

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Hao Wu <hao.a.wu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Hao Wu <hao.a.wu@intel.com>
(cherry picked from commit 3ecca00330)
2018-05-11 17:50:04 +08:00
8dcbc07d34 Revert "DebugUsb3: Support IOMMU"
This reverts commit de8373fa07.

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Hao Wu <hao.a.wu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Hao Wu <hao.a.wu@intel.com>
(cherry picked from commit 1f279e7a53)
2018-05-11 17:50:03 +08:00
f56e828595 Revert "DebugUsb3: Fix GCC build failures"
This reverts commit ad6040ec9b.

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Hao Wu <hao.a.wu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Hao Wu <hao.a.wu@intel.com>
(cherry picked from commit 373b1d0ee3)
2018-05-11 17:50:02 +08:00
df2b9b73fc Revert "DebugUsb3: Check mUsb3Instance before dereferencing it"
This reverts commit 6ef394ffe2.

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Hao Wu <hao.a.wu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Hao Wu <hao.a.wu@intel.com>
(cherry picked from commit abea3bca82)
2018-05-11 17:50:01 +08:00
80654b7e45 SourceLevelDebugPkg DebugUsb3: Check mUsb3Instance before dereferencing it
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Hao Wu <hao.a.wu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Hao Wu <hao.a.wu@intel.com>
(cherry picked from commit 6ef394ffe2)
2018-05-11 17:50:01 +08:00
4ebdd4432b SourceLevelDebugPkg DebugUsb3: Fix GCC build failures
Fix GCC build failures below.
variable 'EvtTrb' set but not used [-Werror=unused-but-set-variable]
variable 'Index' set but not used [-Werror=unused-but-set-variable]

The build failure could only be caught with -D SOURCE_DEBUG_USE_USB3
build flag.

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Hao Wu <hao.a.wu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Hao Wu <hao.a.wu@intel.com>
(cherry picked from commit ad6040ec9b)
2018-05-11 17:50:00 +08:00
de761fb41c SourceLevelDebugPkg DebugUsb3: Support IOMMU
For PEI, allocate granted DMA buffer from IOMMU PPI.
For DXE, map DMA buffer by PciIo.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Hao Wu <hao.a.wu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
(cherry picked from commit de8373fa07)
2018-05-11 17:49:59 +08:00
7b49d5f26b SourceLevelDebugPkg DebugUsb3: Fix some typos
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Hao Wu <hao.a.wu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Hao Wu <hao.a.wu@intel.com>
(cherry picked from commit f4043414da)
2018-05-11 17:49:57 +08:00
38ce9cd510 SourceLevelDebugPkg DebugAgentLib: Rename IsBsp to DebugAgentIsBsp
For avoiding function name confliction,
rename IsBsp to DebugAgentIsBsp.

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Hao Wu <hao.a.wu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
(cherry picked from commit a2acb04ca6)
2018-05-11 17:49:20 +08:00
3bc7ae9d7d SourceLevelDebugPkg/DebugCommLibUsb3: Remove IntelFrameworkPkg.dec
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Hao Wu <hao.a.wu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Hao Wu <hao.a.wu@intel.com>
(cherry picked from commit 9c6a26d643)
2018-05-11 17:49:19 +08:00
1a114b3f79 SourceLevelDebugPkg/DebugCommLibUsb3Pei: Make sure alloc physical mem
PI 1.6 has supported pre permanent memory page allocation,
to make sure the allocated memory is physical memory for DMA,
the patch is to check memory discovered PPI installed or not first
before calling AllocatePages.

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Hao Wu <hao.a.wu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Hao Wu <hao.a.wu@intel.com>
(cherry picked from commit 364f63c065)
2018-05-11 17:49:18 +08:00
b7fc17ce1f IntelFramdworkModulePkg/LegacyBios: Add IoMmu Support.
If IOMMU is enabled, the legacy BIOS need allow the legacy memory
access by the legacy device.
The legacy memory is below 1M memory and HighPmm memory.

Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit 60794ee6b0)
2018-05-10 14:23:55 +08:00
332b4e030e IntelSiliconPkg/Vtd: Add more debug info.
Add more debug info for reason code.

Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit 8d8c487fb9)
2018-05-10 14:23:54 +08:00
bb45812e3b IntelSiliconPkg/Vtd: Add missing dump in ExtContext.
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit 224f87932d)
2018-05-10 14:23:53 +08:00
d006fad08b IntelSiliconPkg/Vtd: Add DMA_CTRL_PLATFORM_OPT_IN_FLAG dump
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit 6cea3c1b51)
2018-05-10 14:23:53 +08:00
8d8b9af9d8 IntelSiliconPkg/Vtd: Add MapHandleInfo in VtdDxe.
This information is to record which device requested which DMA buffer.
It can be used for DMA buffer analysis.

Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit 6d2d2e6e5b)
2018-05-10 14:23:52 +08:00
b0898ad483 IntelSiliconPkg VTdPmrPei: Add PcdVTdPeiDmaBufferSize(S3)
Add PcdVTdPeiDmaBufferSize(S3) to replace the hard coded value
TOTAL_DMA_BUFFER_SIZE and TOTAL_DMA_BUFFER_SIZE_S3 in IntelVTdPmrPei.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
(cherry picked from commit 339cb0af96)
2018-05-10 14:23:51 +08:00
f8c8e99c9e IntelSiliconPkg VTdPmrPei: Return SUCCESS when Mapping == NULL in Unmap
NULL is returned to Mapping when Operation is BusMasterCommonBuffer or
BusMasterCommonBuffer64 in PeiIoMmuMap().
So Mapping == NULL is valid when calling PeiIoMmuUnmap().

940dbd071e wrongly changed EFI_SUCCESS
to EFI_INVALID_PARAMETER when Mapping == NULL in PeiIoMmuUnmap().
This patch is to correct it.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
(cherry picked from commit abe63fa7dc)
2018-05-10 14:23:51 +08:00
7ebe491ca6 IntelSiliconPkg IntelVTdPmrPei: Install IOMMU PPI for pre-memory phase
Install IOMMU PPI for pre-memory phase and return
EFI_NOT_AVAILABLE_YET to indicate that DMA protection has been enabled,
but DMA buffer are not available to be allocated yet.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
(cherry picked from commit 940dbd071e)
2018-05-10 14:23:50 +08:00
0e7879ad7b IntelSiliconPkg IntelVTdPmrPei: Install IoMmu PPI before enabling PMR
Then the consumer of IoMmu PPI has opportunity to get granted DMA
buffer (by callback) to replace old buffer before it is forbidden
by enabling PMR.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
(cherry picked from commit ed0e52fc9a)
2018-05-10 14:23:50 +08:00
3c4cb3ca51 IntelSiliconPkg PlatformVTdSampleDxe: State it is only for dev/debug
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Michael Kinney <michael.d.kinney@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
(cherry picked from commit 17ac6b23dc)
2018-05-10 14:23:49 +08:00
8927f4683b IntelSiliconPkg IntelVTdDxe: Fix flush cache issue
The patch fixes flush cache issue in
CreateSecondLevelPagingEntryTable().

We found some video cards still not work even they have
been added to the exception list.

In CreateSecondLevelPagingEntryTable(), the check
"(BaseAddress >= MemoryLimit)" may be TRUE and "goto Done"
will be executed, then the FlushPageTableMemory operations
at the end of the function will be skipped.

Instead of "goto Done", this patch uses "break" to break
the for loops, then the FlushPageTableMemory operations
at the end of the function could have opportunity to be
executed.

The patch also fixes a miscalculation for Lvl3End.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
(cherry picked from commit bac7f02365)
2018-05-10 14:23:48 +08:00
0f6641efed IntelSiliconPkg IntelVTdDxe: Fix DMA does not work issue
Fix DMA does not work issue when system memory is not
greater than 4G.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
(cherry picked from commit 1d4c17a6ef)
2018-05-10 14:23:47 +08:00
8bb7fa235f IntelSiliconPkg IntelVTdPmrPei: Get high top by host address width
Get high top by host address width instead of resource HOB.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
(cherry picked from commit b2725f57c7)
2018-05-10 14:23:47 +08:00
1cc04b839b IntelSiliconPkg IntelVTdDxe: Remove mVtdHostAddressWidthMask
mVtdHostAddressWidthMask is not been used at all,
its definition and related code could be removed.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
(cherry picked from commit 9eaa902a52)
2018-05-10 14:23:46 +08:00
487719e458 IntelSiliconPkg IntelVTdPmrPei: Use HostAddressWidth in DMAR correctly
According to VTd spec, HostAddressWidth + 1 should be used as the real
host address width value.

Host Address Width:
This field indicates the maximum DMA physical
addressability supported by this platform. The
system address map reported by the BIOS
indicates what portions of this addresses are
populated.
The Host Address Width (HAW) of the platform is
computed as (N+1), where N is the value
reported in this field. For example, for a platform
supporting 40 bits of physical addressability, the
value of 100111b is reported in this field.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
(cherry picked from commit 9dd8b1908e)
2018-05-10 14:23:45 +08:00
3c8012fff3 IntelSiliconPkg IntelVTdPmrPei: Refine comments about PHMR/PLMR.Limit
According to VTd spec, the real hardware decoded limit should be
PHMR/PLMR.Limit value + alignment value.

"Bits N:0 of the limit register are
decoded by hardware as all 1s."

Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
(cherry picked from commit e8097a74b7)
2018-05-10 14:23:45 +08:00
b6da5e3823 IntelSiliconPkg IntelVTdDxe: Fix potential NULL pointer dereference
The implementation of MdeModulePkg\Universal\Acpi\AcpiTableDxe reserves
first entry of RSDT/XSDT to FADT, the first entry value is 0 when FADT
is not installed. So the RSDT/XSDT parsing code should check the entry
value first before checking the table signature.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
(cherry picked from commit 01bd1c98fa)
2018-05-10 14:23:44 +08:00
af1b85332b IntelSiliconPkg IntelVTdDxe: Support early SetAttributes()
Support early SetAttributes() before DMAR table is installed.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
(cherry picked from commit 0bc94c748b)
2018-05-10 14:23:43 +08:00
48008d5f59 IntelSiliconPkg IntelVTdDxe: Use TPL to protect list/engine operation
Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
(cherry picked from commit 3a71670618)
2018-05-10 14:23:42 +08:00
12afa343ef IntelSiliconPkg IntelVTdDxe: Signal AcpiNotificationFunc() initially
Signal AcpiNotificationFunc() initially for the case that
DMAR table has been installed when creating event.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
(cherry picked from commit dcd39e09ff)
2018-05-10 14:23:41 +08:00
6b4b6a36ab IntelSilicon: Correct function description for AllocateBuffer
DUAL_ADDRESS_CYCLE is missing in the EFI_UNSUPPORTED
return status description.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
(cherry picked from commit 34e18d1758)
2018-05-10 14:23:41 +08:00
058a50daf5 IntelSiliconPkg IntelVTdDxe: Do not SetupVtd again
Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Tested-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
(cherry picked from commit 7729e3c448)
2018-05-10 14:23:40 +08:00
d7989c70aa IntelSiliconPkg IntelVTdDxe: Use ACPI table event to get DMAR table
Use ACPI table event to get DMAR table instead of using ACPI SDT
notification as ACPI SDT is optional and the default value of
PcdInstallAcpiSdtProtocol is FALSE in MdeModulePkg.dec.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
(cherry picked from commit f6f486e7bf)
2018-05-10 14:23:39 +08:00
af28682757 IntelSiliconPkg/VtdPeiSample: Add premem support.
Before memory is ready, this sample produces one VTd engine.
After memory and silicon is initialized, this sample produces
both IGD VTd engine and all-rest VTd engine by reinstall the
FV_INFO_PPI.

This update is to demonstrate how to support pre-mem VTd usage.

Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit af807bb986)
2018-05-10 14:23:38 +08:00
b2b89fe3fb IntelSiliconPkg/VtdPmrPei: Add premem support.
Remove memory discovered dependency to support both premem
VTD_INFO_PPI and postmem VTD_INFO_PPI.

If VTD_INFO_PPI is installed before memory is ready, this
driver protects all memory region.
If VTD_INFO_PPI is installed or reinstalled after memory
is ready, this driver allocates DMA buffer and protect rest.

Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
(cherry picked from commit a1e7cd0b02)
2018-05-10 14:23:37 +08:00
21b9d72426 IntelSiliconPkg/VTdDxe: return unsupported for exceptionlist
Since the exception list is not a recommended way, we returns
EFI_UNSUPPORTED in the sample code.

Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit e5d847476a)
2018-05-10 14:23:37 +08:00
22d1ad2be9 IntelSiliconPkg/VTdDxe: Change EBS Event TPL to CALLBACK.
Change ExitBootServices TPL to CALLBACK, so that a device
can disable BME before IOMMU grants access right.

Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit 01df510319)
2018-05-10 14:23:36 +08:00
985e2707a0 IntelSiliconPkg IntelVTdDxe: use gEfiAcpi10TableGuid for ACPI 1.0
According to definition (Acpi.h and MdePkg.dec),
gEfiAcpiTableGuid = gEfiAcpi20TableGuid, and the code is trying
to parse ACPI 2.0 first and then ACPI 1.0, but it uses
gEfiAcpiTableGuid wrongly for ACPI 1.0, this patch is to fix it.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
(cherry picked from commit 118f1657b9)
2018-05-10 14:23:35 +08:00
3d06e18988 IntelSiliconPkg/VtdInfoSample: Fix IGD RMRR memory.
Fix a calculation problem in IGD RMRR memory.

Cc: Zeng Star <zeng.star@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Zeng Star <zeng.star@intel.com>
(cherry picked from commit c13cb4aebf)
2018-05-10 14:23:35 +08:00
1c8bdffe4f IntelSiliconPkg/VTdPmrPei: Add EndOfPei callback for S3
In S3 resume, before system transfer to waking vector,
the VTdPmr need turn off VTd protection based upon VTdPolicy.

Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit fc8be1ad9a)
2018-05-10 14:23:34 +08:00
864f8a3217 IntelSiliconPkg/dec: Clarify VTdPolicy.
Clarify the VTdPolicy is for both PEI and DXE.

Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit 8be3ff8fb8)
2018-05-10 14:23:33 +08:00
9f293688f8 IntelSiliconPkg/VTdDxe: Clean up DXE flush memory.
Make sure the context table are flush to memory.

Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit 73a2fe8b87)
2018-05-10 14:23:33 +08:00
a91808083b IntelSiliconPkg/VTdInfoSample: Add RMRR table.
Let system report RMRR table for the platform support
PEI graphic.

Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit 70dc3ec5a7)
2018-05-10 14:23:32 +08:00
692bb97767 IntelSiliconPkg/IntelVTdPmrPei: Parse RMRR table.
In order to support PEI graphic, we let VTdPmrPei driver
parse DMAR table RMRR entry and allow the UMA access.

If a system has no PEI IGD, no RMRR is needed. The behavior
is unchanged.

If a system has PEI IGD, it must report RMRR in PEI phase.
The PeiVTdPrm will program the IGD VTd engine to skip the
RMRR region, and program the rest PCI VTd engine to skip
the another DMA buffer allocated in PEI phase for other
device driver.

Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit 8e9da4ba3c)
2018-05-10 14:23:31 +08:00
076d0030a0 IntelSiliconPkg/VTdInfoPpi: Let it follow DMAR table.
We notice that there is real usage in PEI to show
the graphic out. As such we need report RMRR table
in PEI to let VTdPmrPei driver skip the IGD UMA region.

Now the VTD_INFO PPI uses the same DMAR data structure.

Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit f02c531967)
2018-05-10 14:23:31 +08:00
95a84049eb IntelSiliconPkg/VTdPei: Fix Linux build error.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
(cherry picked from commit 4084ccfa22)
2018-05-10 14:23:30 +08:00
6e7b7c0c51 IntelSiliconPkg/PlatformIntelVTdInfoSamplePei: Move to feature dir.
Move PlatformIntelVTdInfoSamplePei to Feature/VTd/.

Suggested-by: Star Zeng <star.zeng@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit bec7a86c70)
2018-05-10 14:23:29 +08:00
b8d87b6177 IntelSiliconPkg/IntelVTdPmrPei: Move to feature dir.
Move IntelVTdPmrPei to Feature/VTd/IntelVTdPmrPei.

Suggested-by: Star Zeng <star.zeng@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit db5c75863d)
2018-05-10 14:23:28 +08:00
f0599c8c2d IntelSiliconPkg/PlatformVTdSampleDxe: Move to feature dir.
Move PlatformVTdSampleDxe to Feature/VTd/PlatformVTdSampleDxe.

Suggested-by: Star Zeng <star.zeng@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit e4c9ac648d)
2018-05-10 14:23:28 +08:00
f899049159 IntelSiliconPkg/IntelVTdDxe: Move to feature dir.
Move IntelVTdDxe to Feature/VTd/IntelVTdDxe.

Suggested-by: Star Zeng <star.zeng@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit 9010459c9a)
2018-05-10 14:23:27 +08:00
8f334a80b3 IntelSiliconPkg/dsc: Add PlatformVTdInfoSamplePei.
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit 8a4ed1188b)
2018-05-10 14:23:26 +08:00
f9605f5da3 IntelSiliconPkg: Add PlatformVTdInfoSamplePei.
This is a sample driver to produce VTD_INFO PPI.

Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit 53269009cb)
2018-05-10 14:23:25 +08:00
28f9a14a08 IntelSiliconPkg/dsc: Add IntelVTdPmrPeim.
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit 71cfa709ed)
2018-05-10 14:23:25 +08:00
62c07ae89f IntelSiliconPkg: Add IntelVTdPmrPei.
This PEIM is to produce IOMMU_PPI, so that PEI device
driver can have better DAM management.

This PEIM will setup VTD PMR register to protect
most DRAM. It allocates a big chunk DMA buffer in
the entrypoint, and only use this buffer for DMA.
Any other region is DMA protected.

Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit 3f5ed3fa13)
2018-05-10 14:23:24 +08:00
a6845dfa70 IntelSiliconPkg/dec: Add VTD_INFO PPI GUID
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit 0b7df50021)
2018-05-10 14:23:23 +08:00
678932e524 IntelSiliconPkg/include: Add VTD_INFO PPI.
This VTD_INFO_PPI is to provide VTD information in PEI.
As such, we can have a generic VTd driver.

It is a lightweight version DMAR table, but it does
not contain PCI device information.

Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit 77562d13ac)
2018-05-10 14:23:22 +08:00
4b0a612f4b IntelSiliconPkg/VTdDxe: Disable PMR
When VTd translation is enabled, PMR can be disable.
Or the DMA will be blocked by PMR.

Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit ffe77707a3)
2018-05-10 14:23:22 +08:00
9a1aafdc9f IntelSiliconPkg/Vtd.h: Add definition for PMR.
Add missing PMR definition in VTd spec.

Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit 40cc227055)
2018-05-10 14:23:21 +08:00
e9c75d4aed IntelSiliconPkg/IntelVtd: Consume VTd policy PCD
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit c50596a701)
2018-05-10 14:23:21 +08:00
16d682ef75 IntelSiliconPkg/dec: Add VTd policy PCD
BIT0: This is to control if a platform wants to enable VTd
based protection during boot.
BIT1: This is to control if a platform wants to keep VTd
enabled at ExitBootService.

The default configuration is BIT0:1, BIT1:0.

Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit 0d12b73306)
2018-05-10 14:23:20 +08:00
4c12040ba5 IntelSiliconPkg/VTd: improve debug message.
Add /n for debug message to make error more
readable.

Suggested-by: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit 4d150848c5)
2018-05-10 14:23:19 +08:00
9c5247f1fd IntelSiliconPkg/Vtd: Support CSM usage.
Remove zero address check in IoMmuMap.
The reason is that a CSM legacy driver may use legacy memory for DMA.
As such, the legacyBios need allow below 1M to the legacy device.

This patch also fixed some typo.

Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit 94fb621d37)
2018-05-10 14:23:18 +08:00
0618ee43a1 IntelSiliconPkg/PlatformVTdSample: Avoid using constant result 'if'
In this sample driver, if (0) {...} else {...} statements were used to
illustrate two different using scenarios.

This comment refines the coding style by substituting the 'if (0)'
statement with comments to select sample codes for different cases.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
(cherry picked from commit 7046a2739a)
2018-05-10 14:23:18 +08:00
2b91b830b6 IntelSiliconPkg/PlatformVTdSample: update ExceptionDevice
Add sample for device scope based exception list
and PCI vendor id based exception list.

Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit 5f5bdf4ab5)
2018-05-10 14:23:17 +08:00
52764f7867 IntelSiliconPkg/IntelVTd: update PlatformVtdPolicy
1. Handle flexible exception list format.
1.1 Handle DeviceScope based device info.
1.2 Handle PciDeviceId based device info.
2. Reorg the PCI_DEVICE_INFORMATION
2.1 Merge data pointer reduce allocation times
2.2 Add PCI device id to PCI_DEVICE_INFORMATION
2.3 Rename PciDescriptor to avoid confusing.
3. Fix the debug message too long issue.

Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit f77d35c7f0)
2018-05-10 14:23:16 +08:00
94467009ec IntelSiliconPkg/header: update PlatformVtdPolicy
Add flexible exception list format:
1) Support Device scope based reporting:
Such as, Seg:0/StartBus:0/(Dev:1C|Func:0)/(Dev:0|Func:0)

2) Support PCI VendorId/DeviceId based reporting
Such as, VID:8086|DID:9D2F|Rev:21|SVID:8086|SDID:7270

Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit 71872f7cda)
2018-05-10 14:23:15 +08:00
a63a6dccf7 IntelSiliconPkg/IntelVTdDxe: Update function comments
In commit 4ad5f59715, the parameters
of some functions have been updated, but miss to update the comments
accordingly. This patch is to update the function comments.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
(cherry picked from commit d654bf852f)
2018-05-10 14:23:15 +08:00
6a80fbf6ff IntelSiliconPkg/IntelVTdDxe: Improve performance.
This patch is to improve IOMMU performance.
All WBINVD is removed due to performance issue.
CLFLUSH by WriteBackDataCacheRange() is used to
only flush the context table or
second level page table if they are changed.

This patch also removed some unused functions.

Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit 4ad5f59715)
2018-05-10 14:23:14 +08:00
0444b43b3b IntelSiliconPkg/dsc: Add CacheMaintenanceLib.
It will be used by IntelVTdDxe.

Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit 3ccf5a8a41)
2018-05-10 14:23:13 +08:00
44bea14670 IntelSiliconPkg: Fix VS2015 NOOPT IA32 build failure in IntelVTdDxe
There are VS2015 NOOPT IA32 build failure like below in IntelVTdDxe.
XXX.lib(XXX.obj) : error LNK2001: unresolved external symbol __allshl
XXX.lib(XXX.obj) : error LNK2001: unresolved external symbol __aullshr

This patch is to update Vtd.h to use UINT32 instead of UINT64 for
bitfields in structure definition, and also update IntelVTdDxe code
accordingly.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
(cherry picked from commit 76c6f69cca)
2018-05-10 14:23:12 +08:00
c4c2eb888f IntelSiliconPkg/IntelVTdDxe: Add explicit NULL pointer checks
Add explicit NULL pointer check to make the codes more straight-forward.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
(cherry picked from commit be61fcd2b0)
2018-05-10 14:23:11 +08:00
76240a9bfd IntelSiliconPkg/IntelVTdDxe: Fix typo for VTd IOTLB domain ID
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
(cherry picked from commit f5046945b6)
2018-05-10 14:23:11 +08:00
1b0ad0628c IntelSiliconPkg/dsc: Add PlatformVtd sample driver.
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit 9745ddcf8a)
2018-05-10 14:23:10 +08:00
268c34c0fc IntelSiliconPkg: Add PlatformVTdSample driver.
It provides sample on Platform VTd policy protocol.
This protocol is optional.

Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit 5071fb9cd9)
2018-05-10 14:23:09 +08:00
97b40e6eb2 IntelSiliconPkg/dsc: Add Vtd driver.
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit 642d22424c)
2018-05-10 14:23:09 +08:00
b79d8da0ef IntelSiliconPkg: Add VTd driver.
It provides AllocateBuffer/FreeBuffer/Map/Unmap function.
It also provides VTd capability yet.

Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit c049fc9909)
2018-05-10 14:23:08 +08:00
68b7aeaf22 IntelSiliconPkg/Dec: Add ProtocolGuid.
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit b7ff5027fe)
2018-05-10 14:23:07 +08:00
685dfb6dc3 IntelSiliconPkg/Include: Add PlatformVtdPolicy Protocol
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit 4fd8eda9a3)
2018-05-10 14:23:07 +08:00
1b9c0ef81a IntelSiliconPkg/Include: Add VTD industry standard.
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit e2d81fb12a)
2018-05-10 14:23:06 +08:00
4e7317f367 IntelSiliconPkg: Add package DSC file
https://bugzilla.tianocore.org/show_bug.cgi?id=608

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
(cherry picked from commit 578dbd52b7)
2018-05-10 14:23:06 +08:00
3b4d3e06e6 MdePkg/DMAR: Add the definition for DMA_CTRL_PLATFORM_OPT_IN_FLAG bit
For the support of VTd 2.5, add the BIT definition of
DMA_CTRL_PLATFORM_OPT_IN_FLAG

Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
(cherry picked from commit 8ab0bd2397)
2018-05-10 14:23:05 +08:00
138867bfce MdePkg/include: Add Acpi.h to DMAR table.
Suggested-by: Star Zeng <star.zeng@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit 83a457840e)
2018-05-10 14:23:04 +08:00
7742a8dd23 MdeModulePkg/PciBusDxe: Fix VS2012 build failure
Initialize local variable to suppress warning C4703:
potentially uninitialized local pointer variable.

Both reads (dereferences) of "PciRootBridgeIo" in
PciBusDriverBindingStart() are only reached if
"gFullEnumeration" is TRUE on entry *and* we successfully
open the EfiPciRootBridgeIoProtocol interface.

Cc: Star Zeng <star.zeng@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
(cherry picked from commit a012bf6e3e)
2018-05-10 14:23:03 +08:00
92cf6c91d0 MdeModulePkg Ppi/IoMmu.h: Add EFI_NOT_AVAILABLE_YET return status code
Install IOMMU PPI for pre-memory phase and return
EFI_NOT_AVAILABLE_YET to indicate that DMA protection has been enabled,
but DMA buffer are not available to be allocated yet.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
(cherry picked from commit 20b58eb850)
2018-05-10 11:50:27 +08:00
dfe8c91990 MdeModulePkg/NvmExpressDxe: Fix data buffer not mapped for Write cmd
Within function NvmExpressPassThru():

The data buffer for the below 2 Admin command:
Create I/O Completion Queue command (Opcode 01h)
Create I/O Submission Queue command (Opcode 05h)

are not mapped to the PCI controller specific addresses.

But the current code logic also prevents the below NVM command:
Write (Opcode 01h)

from mapping its data buffer.

Hence, this commit refine the logic to resolve this issue.

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Feng Tian <feng.tian@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit 748cd9a680)
2018-05-10 11:50:26 +08:00
ec6efda3aa MdeModulePkg/PciBusDxe: Install PciEnumerationComplete after PciIo
Per PI spec, the PciEnumerationComplete protocol installation
should be after PciIo installation.
Today's implementation installs the PciEnumerationComplete
after hardware enumeration is completed, but before PciIo
installation.
The change corrects the spec/implementation gap.
The change also benefits certain implementation that depends on
the PciIo handle in PciEnumerationComplete callback.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit 42e8bc7d16)
2018-05-10 11:50:26 +08:00
1d6b6d1e5a MdeModulePkg/PciBusDxe: reference gFullEnumeration in one file
The patch is just a code cleanup with no functionality impact.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit 2632981783)
2018-05-10 11:50:25 +08:00
e267ab290b MdeModulePkg/EhciDxe: call EhcFreeUrb when int-transfer completes
It didn't cause big issues when VT-d was disabled.
But in VT-d enabled platform, lack of EhcFreeUrb call caused
the DMA data was not moved back to user's buffer.
It caused the correct data cannot be got through sync interrupt
transfer.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit c74805f1e7)
2018-05-10 11:50:24 +08:00
193748cbe4 MdeModulePkg: Correct function description for AllocateBuffer
DUAL_ADDRESS_CYCLE is missing in the EFI_UNSUPPORTED
return status description.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
(cherry picked from commit b02f14f36f)
2018-05-10 11:50:23 +08:00
e854ca76b7 MdeModulePkg UhciPei: Also check TempPtr against NULL to return error
Cc: Hao Wu <hao.a.wu@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Hao Wu <hao.a.wu@intel.com>
(cherry picked from commit 56fb9faa60)
2018-05-10 11:50:22 +08:00
9f93bc870d MdeModulePkg UhciPei: Support IoMmu
Update the UhciPei driver to consume IOMMU_PPI to allocate DMA buffer.

If no IOMMU_PPI exists, this driver still calls PEI service to allocate
DMA buffer, with assumption that DRAM==DMA.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
(cherry picked from commit 8284b1791e)
2018-05-10 11:48:40 +08:00
c6d1b85c40 MdeModulePkg EhciPei: Minor refinement about IOMMU
This patch is following 2c656af04d.
1. Fix typo "XHC" to "EHC".
2. Reinitialize Request(Phy/Map) and Data(Phy/Map)
in Urb, otherwise the last time value of them may
be used in error handling when error happens.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
(cherry picked from commit c34a5aab53)
2018-05-10 11:48:40 +08:00
1ccb42d900 MdeModulePkg EhciPei: Also check Buf against NULL to return error
Cc: Hao Wu <hao.a.wu@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Hao Wu <hao.a.wu@intel.com>
(cherry picked from commit a89b923ea9)
2018-05-10 11:48:39 +08:00
d8f8cb70af MdeModulePkg XhciPei: Minor refinement about IoMmu
1. Call IoMmuInit() after locating gPeiUsbControllerPpiGuid.
2. Call XhcPeiFreeSched() to do cleanup in XhcEndOfPei.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
(cherry picked from commit 0aa1794118)
2018-05-10 11:48:38 +08:00
6cf2ca6913 MdeModulePkg EhciPei: Support IoMmu
V2: Halt HC at EndOfPei.

Update the EhciPei driver to consume IOMMU_PPI to allocate DMA buffer.

If no IOMMU_PPI exists, this driver still calls PEI service to allocate
DMA buffer, with assumption that DRAM==DMA.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
(cherry picked from commit 2c656af04d)
2018-05-10 11:48:38 +08:00
e4961ec4a2 MdeModulePkg/SdBlockIoPei: Support IoMmu
Update the SdBlockIoPei driver to consume IOMMU_PPI to allocate DMA
buffer.

If no IOMMU_PPI exists, this driver still calls PEI service
to allocate DMA buffer, with assumption that DRAM==DMA.

This is a compatible change.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit 77af86688c)
2018-05-10 11:48:37 +08:00
b16a16d30c MdeModulePkg/EmmcBlockIoPei: Support IoMmu
Update the EmmcBlockIoPei driver to consume IOMMU_PPI to allocate DMA
buffer.

If no IOMMU_PPI exists, this driver still calls PEI service
to allocate DMA buffer, with assumption that DRAM==DMA.

This is a compatible change.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit 85ad9a6e0a)
2018-05-10 11:48:36 +08:00
702a585f6d MdeModulePkg/UfsBlockIoPei: Support IoMmu
V2 changes:
Resource cleanup logic update in UfsEndOfPei().

V1 history:
Update the UfsBlockIoPei driver to consume IOMMU_PPI to allocate DMA
buffer.

If no IOMMU_PPI exists, this driver still calls PEI service
to allocate DMA buffer, with assumption that DRAM==DMA.

This is a compatible change.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit 44a0857ec6)
2018-05-10 11:48:35 +08:00
776788926c MdeModulePkg/XhciPei: Support IoMmu.
Update XHCI driver to consume IOMMU_PPI to allocate DMA buffer.

If no IOMMU_PPI exists, this driver still calls PEI service
to allocate DMA buffer, with assumption that DRAM==DMA.

This is a compatible change.

Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit b575ca32c8)
2018-05-09 16:20:49 +08:00
8c36c0df58 MdeModulePkg/Dec: Add IOMMU_PPI GUID.
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit 915a3a82e0)
2018-05-09 16:20:48 +08:00
e9d7b97c5b MdeModulePkg/Include: Add IOMMU_PPI.
This IOMMU_PPI is to provide IOMMU abstraction in PEI.

Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit 2b620ee1ff)
2018-05-09 16:20:48 +08:00
1cf1eebf69 MdeModulePkg XhciDxe: Fix Map and Unmap inconsistency
We found there are loops of *2* Maps and only *1* Unmap and
the DMA buffer address is decreasing.

It is caused by the below code flow.
XhcAsyncInterruptTransfer ->
  XhcCreateUrb ->
    XhcCreateTransferTrb ->
      Map Urb->DataMap           (1)

Timer: loops of *2* Maps and only *1* Unmap
XhcMonitorAsyncRequests ->
  XhcFlushAsyncIntMap ->
    Unmap and Map Urb->DataMap   (2)
  XhcUpdateAsyncRequest ->
    XhcCreateTransferTrb ->
      Map Urb->DataMap           (3)

This patch is to eliminate (3).

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
(cherry picked from commit 0b9c0c6540)
2018-05-09 16:20:47 +08:00
d4fd304f8e MdeModulePkg/PciBus: Add IOMMU support.
If IOMMU protocol is installed, PciBus need call IOMMU
to set access attribute for the PCI device in Map/Ummap.

Only after the access attribute is set, the PCI device can
access the DMA memory.

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Leo Duran <leo.duran@amd.com>
Cc: Brijesh Singh <brijesh.singh@amd.com>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>

Previous patch Tested-by: Brijesh Singh <brijesh.singh@amd.com>
Previous patch Tested-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Leo Duran <leo.duran@amd.com>

(cherry picked from commit 11a6cc5bda)
2018-05-09 16:20:47 +08:00
87ed293135 MdeModulePkg/PciHostBridge: Add IOMMU support.
If IOMMU protocol is installed, PciHostBridge just calls
IOMMU AllocateBuffer/FreeBuffer/Map/Unmap.

PciHostBridge does not set IOMMU access attribute,
because it does not know which device request the DMA.
This work is done by PciBus driver.

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Leo Duran <leo.duran@amd.com>
Cc: Brijesh Singh <brijesh.singh@amd.com>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>

Previous patch Tested-by: Brijesh Singh <brijesh.singh@amd.com>
Previous patch Tested-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Leo Duran <leo.duran@amd.com>

(cherry picked from commit c15da8eb35)
2018-05-09 16:20:46 +08:00
42ff47c96d MdeModulePkg/Include: Add IOMMU protocol definition.
This protocol is to abstract DMA access from IOMMU.
1) Intel "DMAR" ACPI table.
2) AMD "IVRS" ACPI table
3) ARM "IORT" ACPI table.

There might be multiple IOMMU engines on one platform.
For example, one for graphic and one for rest PCI devices
(such as ATA/USB).
All IOMMU engines are reported by one ACPI table.

All IOMMU protocol provider should be based upon ACPI table.
This single IOMMU protocol can handle multiple IOMMU engines on one system.

This IOMMU protocol provider can use UEFI device path to distinguish
if the device is graphic or ATA/USB, and find out corresponding
IOMMU engine.

The IOMMU protocol provides 2 capabilities:
A) Set DMA access attribute - such as write/read control.
B) Remap DMA memory - such as remap above 4GiB system memory address
to below 4GiB device address.
It provides AllocateBuffer/FreeBuffer/Map/Unmap for DMA memory.
The remapping can be static (fixed at build time) or dynamic (allocate
at runtime).

4) AMD "SEV" feature.
We can have an AMD SEV specific IOMMU driver to produce IOMMU protocol,
and manage SEV bit.

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Leo Duran <leo.duran@amd.com>
Cc: Brijesh Singh <brijesh.singh@amd.com>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>

Previous patch Tested-by: Brijesh Singh <brijesh.singh@amd.com>
Previous patch Tested-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Leo Duran <leo.duran@amd.com>

(cherry picked from commit d1fddc4533)
2018-05-09 16:20:45 +08:00
72d1ebc5bc BaseTools: Update Rsa2048Sha256Sign to use openssl dgst option
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Cc: Qin Long <qin.long@intel.com>
Reviewed-by: Qin Long <qin.long@intel.com>
(cherry picked from commit d1b777440b)
2018-04-11 09:37:49 +08:00
a0fb938ec3 BaseTools: Update Rsa2048Sha256Sign to use openssl standard options
sha256 is not the standard option. It should be replaced by sha -sha256.
Otherwise, it doesn't work in MAC OS.

In V2, update the option to sha1 -sha256.
In late openssl version >= 1.1, there is no sha option, but has sha1,sha256.
In previous openssl version < 1.1, there is no sha256, but has sha,sha1.
To work with all openssl version, use sha1 -sha256 for it.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liao Jui-peng <jui-pengx.liao@intel.com>
Signed-off-by: Liming Gao <liming.gao@intel.com>
Cc: Michael Kinney <michael.d.kinney@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
(cherry picked from commit 1d574dfc15)
2018-04-11 09:37:48 +08:00
ebded73573 IntelFsp2Pkg: Fix build error with WHOLEARCHIVE option
Add empty TempRamInitApi function to fix
build error with WHOLEARCHIVE option

Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Bell Song <binx.song@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
(cherry picked from commit c69071bd7e)
2018-04-11 09:37:47 +08:00
38cbff6597 IntelFsp2WrapperPkg: Update BaseFspWrapperApiLib to pass XCODE5 build
XCODE5 doesn't support absolute addressing in the assembly code.
This change uses lea instruction to get the address.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
(cherry picked from commit c45f4c5e75)
2018-04-11 09:37:46 +08:00
25ce9e1beb OvmfPkg: Don't add -mno-mmx -mno-sse option for XCODE5 tool chain
Ovmf appended option -mno-mmx -mno-sse, but these two options were enabled
in Openssl. The compiler option becomes -mmmx ?msse -mno-mmx -mno-sse. It
trig mac clang compiler hang when compile one source file in openssl.
This issue is found when SECURE_BOOT_ENABLE is TRUE. This may be the compiler
issue. To work around it, don't add these two options for XCODE5 tool chain.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Cc: Andrew Fish <afish@apple.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
(cherry picked from commit 4a64cbda86)
2018-04-11 09:37:46 +08:00
ccf8184ac3 UefiCpuPkg: Update PiSmmCpuDxeSmm pass XCODE5 tool chain
https://bugzilla.tianocore.org/show_bug.cgi?id=849

In V2, use "mov rax, strict qword 0" to replace the hard code db.

1. Use lea instruction to get the address instead of mov instruction.
2. Use the dummy address as jmp destination, and add the logic to fix up
the address to the absolute address at boot time.
3. On MpFuncs.nasm, use ExchangeInfo to record InitializeFloatingPointUnits.
This way is same to MpInitLib.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Cc: Andrew Fish <afish@apple.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Michael Kinney <michael.d.kinney@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
(cherry picked from commit e21e355e2c)

# Conflicts:
#	UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h
2018-04-11 09:37:45 +08:00
bcda835b36 UefiCpuPkg: Update SmmCpuFeatureLib pass XCODE5 tool chain
https://bugzilla.tianocore.org/show_bug.cgi?id=849

In V2, use "mov rax, strict qword 0" to replace the hard code db.

1. Use lea instruction to get the address instead of mov instruction.
2. Use the dummy address as jmp destination, and add the logic to fix up
the address to the absolute address at boot time.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Cc: Andrew Fish <afish@apple.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Michael Kinney <michael.d.kinney@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
(cherry picked from commit 1c7a65eba7)
2018-04-11 09:37:44 +08:00
d64577ac0a UefiCpuPkg: SmmCpuFeaturesLib Add the missing ASM_PFX in nasm code
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
(cherry picked from commit 3ff8b0c2bd)
2018-04-11 09:37:42 +08:00
e2a6326db6 UefiCpuPkg: PiSmmCpuDxeSmm Add the missing ASM_PFX in nasm code
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
(cherry picked from commit 8764ed57b4)
2018-04-11 09:37:42 +08:00
61699a3247 UefiCpuPkg: Update CpuExceptionHandlerLib pass XCODE5 tool chain
https://bugzilla.tianocore.org/show_bug.cgi?id=849

In V2, use mov rax, strict qword 0 to replace the hard code db.

Use the dummy address as jmp destination, and add the logic to fix up
the address to the absolute address at boot time.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Cc: Andrew Fish <afish@apple.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Michael Kinney <michael.d.kinney@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
(cherry picked from commit 2db0ccc2d7)
2018-04-11 09:37:41 +08:00
24dae408e5 MdeModulePkg: Update DebugSupportDxe to pass XCODE5 build
XCODE5 doesn't support absolute addressing in the assembly code.
This change uses lea instruction to get the address.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Cc: Andrew Fish <afish@apple.com>
Cc: Star Zeng <star.zeng@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit 62382925c9)
2018-04-11 09:37:40 +08:00
cf0277ed78 BaseTools: Use nasm as the preferred assembly source files for XCODE5 tool
https://bugzilla.tianocore.org/show_bug.cgi?id=850

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Cc: Andrew Fish <afish@apple.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
(cherry picked from commit 2583352f24)
2018-04-11 09:37:39 +08:00
ce3997f0ba BaseTools: Disable -Wno-unused-const-variable in XCODE5 RELEASE target
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Cc: Andrew Fish <afish@apple.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
(cherry picked from commit db408fa3c1)
2018-04-11 09:37:38 +08:00
800004bf97 BaseTools: Disable warning varargs in XCODE5 align to CLANG38
https://bugzilla.tianocore.org/show_bug.cgi?id=741

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
(cherry picked from commit 24a105a7d8)
2018-04-11 09:37:37 +08:00
39db198dae NetworkPkg: Update IScsiDxe to pass XCODE build
Fix the warning equality comparison with extraneous parentheses
[-Werror,-Wparentheses-equality].

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liang Vincent <vincent.liang@intel.com>
Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>
(cherry picked from commit cf260a47be)
2018-04-11 09:37:37 +08:00
c1599f3e4f MdeModulePkg: Update PeiCore to pass XCODE tool chain
It fixes the warning for loop has empty body [-Werror,-Wempty-body].

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liang Vincent <vincent.liang@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit be18cb0305)
2018-04-11 09:37:36 +08:00
3b4c8c5f97 BaseTools: parse map file generated by Xcode on Mac
Add support to parse map file generated by Xcode on Mac to get
variable offset and Patchable Pcd info in current EFI file.

Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit 14239ee077)
2018-04-11 09:37:35 +08:00
3ce826f8df BaseTools: Fix Segmentation fault: 11 when build AppPkg with XCODE5
it is a bug in mtoc setting the size of the debug directory entry to
the size of the .debug section, not the size of the
EFI_IMAGE_DEBUG_DIRECTORY_ENTRY. It was causing a loop to iterate and
get bogus EFI_IMAGE_DEBUG_DIRECTORY_ENTRY data and pass that to memset() and boom.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Andrew Fish <afish@apple.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit 0024172d90)
2018-04-11 09:37:34 +08:00
4adfe6c82f MdePkg: Fix Xcode 9 Beta treating 32-bit left shift as undefined
Bug: https://bugzilla.tianocore.org/show_bug.cgi?id=635

Cc: Liming Gao <liming.gao@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Andrew Fish <afish@apple.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit 9169c6e818)
2018-04-11 09:37:33 +08:00
23b91293bd IntelFrameworkModulePkg: Fix Xcode 9 Beta treating 32-bit left shift as undefined
Bug: https://bugzilla.tianocore.org/show_bug.cgi?id=635

Cc: Liming Gao <liming.gao@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Jeff Fan <jeff.fan@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Andrew Fish <afish@apple.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit 9458afa337)
2018-04-11 09:37:33 +08:00
e3e92db8c5 DuetPkg: Fix Xcode 9 Beta treating 32-bit left shift as undefined
Bug: https://bugzilla.tianocore.org/show_bug.cgi?id=635

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Hao Wu <hao.a.wu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Andrew Fish <afish@apple.com>
Reviewed-by: Hao Wu <hao.a.wu@intel.com>
(cherry picked from commit aa1d330b22)
2018-04-11 09:37:32 +08:00
0824202952 BaseTools: Fix Xcode 9 Beta treating 32-bit left shift as undefined
Bug: https://bugzilla.tianocore.org/show_bug.cgi?id=635

Cc: Liming Gao <liming.gao@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Andrew Fish <afish@apple.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit 59bc913c10)
2018-04-11 09:37:31 +08:00
000b430124 BaseTools: Update tools_def.template to remove old XCLANG and XCODE32
https://bugzilla.tianocore.org/show_bug.cgi?id=562
https://bugzilla.tianocore.org/show_bug.cgi?id=563

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Liming Gao <liming.gao@intel.com>
Cc: Andrew Fish <afish@apple.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Andrew Fish <afish@apple.com>
(cherry picked from commit f7bd152c2a)
2018-04-11 09:37:30 +08:00
6c6958ce8a SourceLevelDebugPkg/SecPeiDebugAgentLib: Fix duplicate symbol
https://bugzilla.tianocore.org/show_bug.cgi?id=573
https://bugzilla.tianocore.org/show_bug.cgi?id=796

The same issue is reported again by GCC. Resend this patch again.
This patch renames the duplicated function name to fix it.

The SecPeiDebugAgentLib uses the global variable
mMemoryDiscoveredNotifyList for a PPI notification on
the Memory Discovered PPI.  This same variable name is
used in the DxeIplPeim for the same PPI notification.

The XCODE5 tool chain detects this duplicate symbol
when the OVMF platform is built with the flag
-D SOURCE_DEBUG_ENABLE.

The fix is to rename this global variable in the
SecPeiDebugAgentLib library.

Cc: Andrew Fish <afish@apple.com>
Cc: Jeff Fan <jeff.fan@intel.com>
Cc: Hao Wu <hao.a.wu@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Jeff Fan <jeff.fan@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
(cherry picked from commit 2b55daaef0)
2018-04-11 09:37:29 +08:00
28e7f3b4d0 MdeModulePkg/RegularExpressionDxe: Fix XCODE5 build failure
https://bugzilla.tianocore.org/show_bug.cgi?id=572

The ErrorMessage local variable in OnigurumaMatch() should
be type OnigUChar instead of type CHAR8.  This resolves
a build failure with the XCODE5 tool chain.

Cc: Andrew Fish <afish@apple.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Andrew Fish <afish@apple.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit c8206f22fd)
2018-04-11 09:37:23 +08:00
1bbc25874b Nt32Pkg: Add VS2017 support in SecMain
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
(cherry picked from commit 102d2768a9)
2018-04-10 11:06:18 +08:00
93cd52af55 BaseTools: Update VS batch file to auto detect VS2017
This way depends on VS vswhere.exe to find VS2017 installed directory.
vswhere.exe starts in Visual Studio 2017 version 15.2.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Signed-off-by: Pete Batard <pete@akeo.ie>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
(cherry picked from commit 7dddedc8b2)
2018-04-10 11:06:17 +08:00
242fc42229 BaseTools: Add VS2017 tool chain in BaseTools tools_def.template
VS2017 tool chain enables /WHOLEARCHIVE linker option
Split host-related and arch-related elements

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Signed-off-by: Pete Batard <pete@akeo.ie>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
(cherry picked from commit 1d0d15522a)
2018-04-10 11:06:16 +08:00
5b68bc7db1 MdePkg: Disable VS warning 4701 & 4703 for VS2017
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
(cherry picked from commit c0f7a5d4b3)
2018-04-10 11:06:16 +08:00
e195fcd1c4 SecurityPkg Tpm12CommandLib: Fix TPM12 GetCapability response error
TPM12 command lib doesn't convert Response Size before using. Add logic
to fix the issue.

Cc: Long Qin <qin.long@intel.com>
Cc: Yao Jiewen <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Chao Zhang <chao.b.zhang@intel.com>
Reviewed-by: Long Qin <qin.long@intel.com>
Reviewed-by: Yao Jiewen <jiewen.yao@intel.com>
(cherry picked from commit 28892d768b)
2018-04-09 22:08:25 +08:00
08bd0bcbda SecurityPkg Tpm2CommandLib: Fix TPM2.0 response memory overflow
TPM2.0 command lib always assumes TPM device and transmission channel can
respond correctly. But it is not true when communication channel is exploited
and wrong data is spoofed. Add more logic to prohibit memory overflow attack.

Cc: Long Qin <qin.long@intel.com>
Cc: Yao Jiewen <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Chao Zhang <chao.b.zhang@intel.com>
Reviewed-by: Long Qin <qin.long@intel.com>
Reviewed-by: Yao Jiewen <jiewen.yao@intel.com>
(cherry picked from commit dd577319e8)
2018-04-09 22:08:24 +08:00
3ae5a3f64a MdePkg/UefiDevicePathLib: Add DevPathFromTextDns and DevPathToTextDns libraries
V3:
* Fix the bug in DevPathFromTextDns()

V2:
* Add no IP instance case check.

Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Ye Ting <ting.ye@intel.com>
(cherry picked from commit 9b9d0655c1)
2018-04-08 15:26:49 +08:00
4a387664ca MdePkg/DevicePath.h: Add DNS Device Path definition
This patch adds the DNS device path node definition.

Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com>
Reviewed-by: Ye Ting <ting.ye@intel.com>
(cherry picked from commit ecbabb7f8b)
2018-04-08 15:26:48 +08:00
ec7485fa89 NetworkPkg/Dhcp6Dxe: Check Media status before starting DHCP process.
This patch is to resolve the issue reported @
https://bugzilla.tianocore.org/show_bug.cgi?id=804.

Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Karunakar P <karunakarp@amiindia.co.in>
Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
(cherry picked from commit 8a5ef41ebb)
2018-04-08 15:16:12 +08:00
3a357bf404 MdeModulePkg/Dhcp4Dxe: Check Media status before starting DHCP process.
This patch is to resolve the issue reported @
https://bugzilla.tianocore.org/show_bug.cgi?id=804.

Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Karunakar P <karunakarp@amiindia.co.in>
Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com>
Reviewed-by: Ye Ting <ting.ye@intel.com>
(cherry picked from commit 5d34573df9)
2018-04-08 15:16:10 +08:00
c1e6864d35 MdeModulePkg/Ip4Dxe: Cleanup the resource after error happen during Ip4StartAutoConfig().
Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Cc: Wang Fan <fan.wang@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com>
Reviewed-by: Ye Ting <ting.ye@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
(cherry picked from commit f3b108a8ef)
2018-04-08 15:16:07 +08:00
0f63da7c61 MdeModulePkg/Ip4Dxe: Add an independent timer for reconfig checking
* Since wireless network can switch at very short time, the time interval
  of reconfig event checking is too long for this case. To achieve better
  performance and scalability, separate this task from Ip4 tick timer.

Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wang Fan <fan.wang@intel.com>
Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
(cherry picked from commit 018432f0ce)
2018-04-08 15:04:28 +08:00
07dce6fb78 BaseTools: extend FFS alignment to 16M
Current FFS only supports 64KiB alignment for data, Per PI 1.6
requirement, we extend FFS alignment to 16M.

Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit e921f58d44)
2018-04-04 11:01:12 +08:00
64f81ce7bd ShellBinPkg: Ia32/X64 Shell binary update.
The binary is built from UDK2017 Shell source.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
2018-04-02 11:32:43 +08:00
a638395fa4 ShellPkg: Add error message if failed to place receive token in ping command.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Wu Jiaxin <jiaxin.wu@intel.com>
Reviewed-by: Ye Ting <ting.ye@intel.com>
(cherry picked from commit 5d8aa7eb6f)
2018-04-02 11:21:02 +08:00
f0e5329b94 UefiCpuPkg/MpInitLib: Make sure AP uses correct StartupApSignal
Every processor's StartupApSignal is initialized in
MpInitLibInitialize() before calling CollectProcessorCount().
When SortApicId() is called from CollectProcessorCount(), AP Index
is re-assigned by APIC ID. But SortApicId() forgets to set the
correct StartupApSignal when sorting the AP.

The patch fixes this issue.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
Cc: Chasel Chiu <chasel.chiu@intel.com>
(cherry picked from commit bafa76ef5b)
2018-04-02 11:08:30 +08:00
2704b8dd89 UefiCpuPkg/PeiMpLib: Fix a system hang-in-pei issue.
GetWakeupBuffer() tries to find a below-1M free memory, it checks
whether the memory is allocated already in
CheckOverlapWithAllocatedBuffer(). When there is a memory allocation
hob (base = 0xff_00000000, size = 0x10000000),
CheckOverlapWithAllocateBuffer() truncates the base to 0 which causes
it always returns TRUE so GetWakeupBuffer() fails to find a below-1MB
memory.

The patch fixes this issue by using UINT64 type.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Jeff Fan <vanjeff_919@hotmail.com>
(cherry picked from commit 5986cf382e)
2018-04-02 11:07:48 +08:00
698739e887 MdeModulePkg/CapsuleApp: Fix logic bug in CleanGatherList()
https://bugzilla.tianocore.org/show_bug.cgi?id=905

Fix pointer math when more than one capsule is passed
to the CapsuleApp.  Use the ContinuationPointer from
the last array entry instead of the first array entry.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
(cherry picked from commit 845f7cfef2)
2018-03-28 15:23:07 +08:00
258f7de25e MdeModulePkg/DxeCapsuleLibFmp: Verify nested capsule with FMP
https://bugzilla.tianocore.org/show_bug.cgi?id=873

Update IsNestedFmpCapsule() to verify the CapsuleGuid in
the CapsuleHeader against the installed Firmware Management
Protocol instances.  The current logic that uses the ESRT
Table does not work because capsules are processed before
the ESRT Table is published at the Ready To Boot event.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Bret Barkelew <Bret.Barkelew@microsoft.com>
(cherry picked from commit 7f0301e39a)
2018-03-21 20:58:25 +08:00
13370226c9 MdeModulePkg PiSmmCore: Set ForwardLink to NULL in RemoveOldEntry()
"Entry->Link.ForwardLink = NULL;" is present in RemoveMemoryMapEntry()
for DxeCore, that is correct.
"Entry->Link.ForwardLink = NULL;" is absent in RemoveOldEntry()
for PiSmmCore, that is incorrect.

Without this fix, when FromStack in Entry is TRUE,
the "InsertTailList (&mMapStack[mMapDepth].Link, &Entry->Link);" in
following calling to CoreFreeMemoryMapStack() will fail as the entry
at mMapStack[mMapDepth] actually has been removed from the list.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
(cherry picked from commit e434be3c9c)
2018-03-21 20:57:36 +08:00
007386ef63 SecurityPkg: Tcg2Smm: Refine type cast in pointer abstraction
Pointer subtraction is not performed by pointers to elements of the same
array object. Such behavior is undefined by C11 standard and might lead to
potential issues, Refine pointer subtraction by first casting each pointer
to UINTN.

Cc: Hao Wu <hao.a.wu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Chao Zhang <chao.b.zhang@intel.com>
Reviewed-by: Hao Wu <hao.a.wu@intel.com>
(cherry picked from commit 28fd7b090d)
(cherry picked from commit 1c65ddbf24)
2018-03-16 13:11:09 +08:00
d207ef6f5a SecurityPkg:Tcg2Smm: Fix compile issue
Update Tcg2Smm _PRS patching logic to fix compile issue

Cc: Liming Gao <liming.gao@intel.com>
Cc: Dandan Bi <dandan.bi@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Chao Zhang <chao.b.zhang@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit 449083a3f8)
(cherry picked from commit abb0427276)
2018-03-16 13:10:58 +08:00
db9d1fa56c SecurityPkg: Add UNI string for 2 PCDs
Add prompt & help string for PcdTpm2CurrentIrqNum, PcdTpm2PossibleIrqNumBuf

Cc: Dandan Bi <dandan.bi@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Chao Zhang <chao.b.zhang@intel.com>
(cherry picked from commit ce58945513)
2018-03-16 13:10:38 +08:00
e890056bb8 SecurityPkg: Disable TPM interrupt in DEC
Disable TPM interrupt support in DEC by default to keep compatibility

Cc: Yao Jiewen <jiewen.yao@intel.com>
Cc: Long Qin <qin.long@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Chao Zhang <chao.b.zhang@intel.com>
Reviewed-by: Yao Jiewen <jiewen.yao@intel.com>
Reviewed-by: Long Qin <qin.long@intel.com>
(cherry picked from commit 5552ac4231)
(cherry picked from commit 14553a2e5d)
2018-03-16 13:10:10 +08:00
4445bb29b3 SecurityPkg: Tcg2Smm: Enable TPM2.0 interrupt support
1. Expose _CRS, _SRS, _PRS control method to support TPM interrupt
2. Provide 2 PCDs to configure _CRS and _PRS returned data

Cc: Yao Jiewen <jiewen.yao@intel.com>
Cc: Ronald Aigner <Ronald.Aigner@microsoft.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Chao Zhang <chao.b.zhang@intel.com>
Reviewed-by: Yao Jiewen <jiewen.yao@intel.com>
(cherry picked from commit c4122dcaad)
(cherry picked from commit 1ed328a0d7)
2018-03-16 13:09:46 +08:00
1eff644477 SecurityPkg:Tcg2Smm: Update Interrupt resource name
Update TPM interrupt resource descriptor name for better compatibility to
old ASL compiler.

Cc: Long Qin <qin.long@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Chao Zhang <chao.b.zhang@intel.com>
Reviewed-by: Long Qin <qin.long@intel.com>
(cherry picked from commit 73d777329f)
2018-03-16 12:56:15 +08:00
3d41e7b48d SecurityPkg:Tcg2Smm: Add MSFT copyright
Add MSFT copyright for TPM SIRQ feature.

Cc: Long Qin <qin.long@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Chao Zhang <chao.b.zhang@intel.com>
Reviewed-by: Long Qin <qin.long@intel.com>
(cherry picked from commit af9743ef44)
2018-03-16 12:50:45 +08:00
c3abd1c7a5 SecurityPkg:Tcg2Smm:Enabling TPM SIRQ interrupt support
1. Report TPM SIRQ interrupt resource through _CRS
2. Expose _SRS to update interrupt resource & FIFO/TIS interrupt related registers
   defined in TCG PC Client Platform TPM Profile (PTP) Specification spec
https://trustedcomputinggroup.org/wp-content/uploads/PC-Client-Specific-Platform-TPM-Profile-for-TPM-2-0-v43-150126.pdf
Note: IHV/OEM need to carefully verify this feature with OS TPM driver to make sure there is no impact to system/HW

Cc: Long Qin <qin.long@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Chao Zhang <chao.b.zhang@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Long Qin <qin.long@intel.com>
(cherry picked from commit edf7647bae)
2018-03-16 12:50:30 +08:00
f71a70e7a4 MdeModulePkg CapsulePei: Sort and merge memory resource entries
Sort and merge memory resource entries to handle the case that
the memory resource HOBs are reported differently between
BOOT_ON_FLASH_UPDATE boot mode and normal boot mode, and the
capsule buffer from UpdateCapsule at normal boot sits across
two memory resource descriptors at BOOT_ON_FLASH_UPDATE boot mode.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Chasel Chiu <chasel.chiu@intel.com>
Cc: Dakota Chiang <dakota.chiang@intel.com>
Tested-by: Dakota Chiang <dakota.chiang@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Chasel Chiu <chasel.chiu@intel.com>
(cherry picked from commit 032de38a07)
2017-12-05 10:28:42 +08:00
8fd313ab9d BaseTools: Update C tools top GNUMakefile to adjust tool order
Place the tool that takes much build time at the first. This can improve
build performance when make -j N used.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
(cherry picked from commit 81fa5ad028)
2017-12-05 00:02:38 +08:00
54cbe51db4 BaseTools: Update BaseTools top GNUMakefile with the clear dependency
https://bugzilla.tianocore.org/show_bug.cgi?id=786

After GNUmakefile dependency is fixed up, it can make with -j N to enable
multiple thread build in base tools C source and save build time.

In my linux host machine, make -j 4 to compile BaseTools and save ~60% time.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
(cherry picked from commit 9e1131b70b)
2017-12-05 00:02:36 +08:00
582225d2f3 BaseTools: Replace ARCH with HOST_ARCH in C Makefile to avoid conflict
https://bugzilla.tianocore.org/show_bug.cgi?id=793

ARCH is too generic. It may cause confuse of target arch or host arch.
To be clarified, replace it with HOST_ARCH in BaseTools C Makefile.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
(cherry picked from commit a9f6e0a4dc)
2017-12-05 00:02:35 +08:00
5d577844f0 MdePkg/PciExpress21.h: Fix typo in PCI_REG_PCIE_SLOT_CONTROL
PCI_REG_PCIE_SLOT_CONTROL contains a typo. It is defined as:
typedef union {
  struct {
    UINT32 AttentionButtonPressed : 1;
    UINT32 ...
    ...
  } Bits;
  UINT16   Uint16;
} PCI_REG_PCIE_SLOT_CONTROL;

The bit field data type should be UINT16 instead of UINT32,
results sizeof (PCI_REG_PCIE_SLOT_CONTROL) equals to 4 instead of 2.

Because this structure is used in PCI_CAPABILITY_PCIEXP as below:
typedef struct {
  ...
  PCI_REG_PCIE_SLOT_CONTROL       SlotControl;
  PCI_REG_PCIE_SLOT_STATUS        SlotStatus;
} PCI_CAPABILITY_PCIEXP;

It cause the OFFSET_OF (PCI_CAPABILITY_PCIEXP, SlotStatus) equal
to a wrong value.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit 400a59737f)
2017-11-08 12:48:44 +08:00
eea98eea4c UefiCpuPkg/MpLib: fix potential overflow issue.
Current calculate timeout logic may have overflow if the input
timeout value too large. This patch fix this potential overflow
issue.

V2: Use local variable instead of call GetPerformanceCounterProperties
twice. Also correct some comments.

Cc: Michael Kinney <michael.d.kinney@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Eric Dong <eric.dong@intel.com>
Reviewed-by: Michael Kinney <michael.d.kinney@intel.com>
(cherry picked from commit 48cfb7c0f4)
2017-09-13 08:50:27 +08:00
8b2fc8bd87 UefiCpuPkg/Mplib.c: Perform complete initialization when enable AP.
PI has description said If an AP is enabled, then the implementation must
guarantee that a complete initialization sequence is performed on the AP,
so the AP is in a state that is compatible with an MP operating system.
Current implementation just set the AP to idle state when enable this AP
which is not follow spec. This patch fix it.

Cc: Michael Kinney <michael.d.kinney@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Eric Dong <eric.dong@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
(cherry picked from commit d5fdae96e2)
2017-09-13 08:49:51 +08:00
5a40103e40 UefiCpuPkg: Remove deprecated CPU feature.
Senter feature could not be a single feature,
it has been merge to Smx feature, so remove it.

Cc: Jeff Fan <jeff.fan@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Eric Dong <eric.dong@intel.com>
Reviewed-by: Jeff Fan <jeff.fan@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
(cherry picked from commit 79aac4dd75)
2017-07-20 14:15:54 +08:00
a7bf24ea3d UefiCpuPkg CpuCommonFeaturesLib: Fix smx/vmx enable logic error.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Eric Dong <eric.dong@intel.com>
Reviewed: Jeff Fan <jeff.fan@intel.com>
(cherry picked from commit b1fe2029fa)
2017-07-12 13:26:21 +08:00
9466ebf4ba UefiCpuPkg RegisterCpuFeaturesLib: Add error handling code.
Add error handling code when initialize the CPU feature failed.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Eric Dong <eric.dong@intel.com>
Reviewed-by: Jeff Fan <jeff.fan@intel.com>
(cherry picked from commit 05973f9e8a)
2017-07-12 13:26:21 +08:00
51bf49ee53 MdePkg/IndustryStandard: update ACPI/IORT definitions to revision C
This updates the IORT header to include the definitions that were added
in revision C of the IORT spec that was made public recently.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit 157fb7bf29)
2017-06-27 10:27:17 +00:00
b21ac25c06 MdePkg/IndustryStandard: add definitions for ACPI 6.0 IORT
This adds #defines and struct typedefs for the various node types in
the ACPI 6.0 IO Remapping Table (IORT).

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Jiewen Yao <yiewen.yao@intel.com>
Reviewed-by: Michael Kinney <michael.d.kinney@intel.com>
(cherry picked from commit 75ce7ef7cf)
2017-06-27 10:24:13 +00:00
324a4c9d7d ShellBinPkg: Ia32/X64 Shell binary update.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
(cherry picked from commit 46e2632b4e)
2017-06-13 16:26:05 +08:00
37a0c27fe1 MdeModulePkg/BMMUiLib: Fix incorrect variable name
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=592

In function UpdateConsoleContent, we compare console name
with "ErrOut" string to check whether the content in console
Error device page has been changed. But when call function
UpdateConsoleContent, we pass console name as "ConErr" by mistake.
This patch is to fix the inconsistent issue.

Cc: Eric Dong <eric.dong@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
(cherry picked from commit 983f59932d)
2017-06-13 10:48:07 +08:00
2447ae30ac SecurityPkg TcgDxe: Simplify debug msg when "TPM not working properly"
Current code for case "TPM not working properly" uses the predefined
macro __FILE__ in debug format string, but uses predefined macro
__LINE__ as parameter, and it also uses multiple pairs of "" in debug
format string.

To be simple and clear, this patch is to update the code to just use
"DriverEntry: TPM not working properly\n" as the debug message.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Amy Chan <amy.chan@intel.com>
Cc: Chasel Chiu <chasel.chiu@intel.com>
Cc: Chao Zhang <chao.b.zhang@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Chasel Chiu <chasel.chiu@intel.com>
Reviewed-by: Chao Zhang <chao.b.zhang@intel.com>
(cherry picked from commit ec4910cd33)
2017-06-10 13:25:25 +08:00
9e0da2fa43 ShellPkg: Fix typo errors in ifconfig help output
Found few instances where IPv4 and DHCPv4 spelled incorrectly
as IP4 and DHCP4 respectively.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Tapan Shah <tapandshah@hpe.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
(cherry picked from commit 97f1cd597e)
2017-06-10 10:25:53 +08:00
0a92412e8f Shell/alias: Print detailed error when deleting alias
STR_GEN_ERR_NOT_FOUND is added and currently is only
used by alias command. This string template can be used
by other commands as well.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Tapan Shah <tapandshah@hpe.com>
(cherry picked from commit 937bc66e1e)
2017-06-10 10:25:52 +08:00
a54759c134 ShellPkg/ifconfig: Update help message
Couple of instances had IP4 mentioned, instead of IPv4.
Changing all to IPv4 to maintain consistency.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hegde Nagaraj P <nagaraj-p.hegde@hpe.com>
Reviewed-by: Tapan Shah <tapandshah@hpe.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Wu Jiaxin <jiaxin.wu@intel.com>
(cherry picked from commit c1f4b86ba7)
2017-06-09 10:52:20 +08:00
ed6ff8b7d4 ShellPkg: Remove unnecessary Readme.txt
The Readme.txt contains instructions about how to integrate Shell
into Nt32. Actually Nt32 already contains a macro USE_OLD_SHELL to
choose OLD or NEW Shell.

So remove this txt file.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
(cherry picked from commit 752234768e)
2017-06-09 10:32:53 +08:00
872c124c6f BaseTools/Bin: Update the BaseTools Win32 binaries version information
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
2017-06-08 08:47:24 +08:00
ec198f52fc MdePkg: update Wi-Fi/Supplicant header files to meet UEFI 2.7.
This patch is used to update supplicant.h and wifi2.h
to meet UEFI 2.7 definition. Add EfiSupplicant80211PMK
field in EFI_SUPPLICANT_DATA_TYPE and change **NetworkDesc
to NetworkDesc[1] in EFI_80211_GET_NETWORKS_RESULT.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wang Fan <fan.wang@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Ye Ting <ting.ye@intel.com>
(cherry picked from commit b941c34ef8)
2017-06-07 16:19:47 +08:00
d615a3a136 BaseTools: Fix the bug use same FMP_PAYLOAD in different capsule file
Fix the bug that use same FMP_PAYLOAD in different capsule file. Because
in previous FMP generation, the FMP already be generated, so we don't
need to regenerate again.

Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit d4c558e83d)
2017-06-07 16:16:16 +08:00
41e13d1056 BaseTools: Fix incremental build failure that override file be removed
Fix a Incremental build failure. The case is: Both A and B package will
include a same .h file, and in the driver's packages section, A
package is listed before B package, so we will use the .h file in the A
package and build success, then we directly delete the .h file in package
A, it cause increment build failure since in the AutoGenTimeStamp file
the .h file in A can't be found.

Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit 4a1167dfef)
2017-06-07 16:16:16 +08:00
a12787c356 ShellBinPkg: Ia32/X64 Shell binary update.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
(cherry picked from commit b9f1625193)
2017-06-07 09:50:44 +08:00
a5765eec77 ShellPkg/parse: Handle Unicode stream from pipe correctly
The original code expects the Unicode stream from pipe doesn't
contains the Unicode BOM.
But that's not true.
Commit [9ed21946c7] changes
CreateFileInterfaceMem() to add the BOM for Unicode stream.

When parse pipe support was firstly added, a private implementation
ParseReturnStdInLine() was created to specially handle
the Unicode stream without BOM. Since now the Unicode steam contains
BOM, the private implementation can be removed and
ShellFileHandleReturnLine() can be used directly.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Tapan Shah <tapandshah@hpe.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
(cherry picked from commit 4e6394455a)
2017-06-07 08:53:05 +08:00
0164fa8f43 ShellPkg/alias: Return status for alias deletion
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Tapan Shah <tapandshah@hpe.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
(cherry picked from commit 7bd5a2c81e)
2017-06-07 08:53:05 +08:00
695d419c4c ShellPkg/alias: Fix bug to support upper-case alias
alias in UEFI Shell is case insensitive.
Old code saves the alias to variable storage without
converting the alias to lower-case, which results
upper case alias setting doesn't work.
The patch converts the alias to lower case before saving
to variable storage.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Tapan Shah <tapandshah@hpe.com>
(cherry picked from commit 7ec69844b8)
2017-06-07 08:53:04 +08:00
a56bfec25f MdePkg: Add BluetoothAttribute.h and BluetoothLeConfig.h
UEFI Spec 2.7 introduces BluetoothAttribute and BluetoothLeConfig
protocols. The patch adds the definitions for them.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
(cherry picked from commit 9c94cc2ca2)
2017-06-07 08:49:33 +08:00
756065c328 MdePkg/BluetoothIo: Formalize function header comments.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
(cherry picked from commit 1e4547668e)
2017-06-07 08:49:32 +08:00
d82ea26664 MdePkg/BluetoothHc: Add detailed function header comments
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
(cherry picked from commit 5a39f404f3)
2017-06-07 08:49:30 +08:00
f9a4814a2d MdePkg/BluetoothConfig: Add new EFI_BLUETOOTH_CONFIG_DATA_TYPE types
UEFI spec 2.7 adds new EFI_BLUETOOTH_CONFIG_DATA_TYPE types.
The patch adds them to the header file.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
(cherry picked from commit 0cbd5830b4)
2017-06-07 08:49:30 +08:00
c26c4067f3 MdePkg/DevicePath: Add BluetoothLe device path node support
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
(cherry picked from commit ff5623e990)
2017-06-07 08:49:29 +08:00
3e47c01c85 ShellPkg/UefiShellLib: Avoid reading undefined content before string
https://bugzilla.tianocore.org/show_bug.cgi?id=566

In function InternalShellPrintWorker(), if the string in variable
'mPostReplaceFormat2' starts with character L'%', the following
expression:

*(ResumeLocation-1) == L'^' at line 2831

will read an undefined value before the starting of string
'mPostReplaceFormat2'.

This commit adds additional logic to avoid reading undefined content.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
(cherry picked from commit d727614c91)
2017-06-02 15:58:27 +08:00
fc2ef2115f MdeModulePkg/Xhci: Correct the indention of comments
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit b0b626ea2f)
2017-06-02 15:57:04 +08:00
121e15a578 ShellPkg/UefiShellLib: Check correct variable for NULL
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Jaben Carsey <jaben.carsey@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Westfahl <jeff.westfahl@ni.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
(cherry picked from commit 5220897839)
2017-06-02 15:18:04 +08:00
14bb6567c7 MdeModulePkg/Xhci: Remove TRB when canceling Async Int Transfer
Some USB devices don't report data periodically through Int
Transfer. They report data only when be asked. If the TRB
is not removed from the XHCI HW, when next time HOST asks
data again, the data is reported but consumed by the previous
TRB, which results the HOST thinks data never comes.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao A Wu <hao.a.wu@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit b33b1055b0)
2017-06-02 14:25:26 +08:00
8f0dea41bc MdeModulePkg/MnpDxe: Fix EBC build hang issue.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
(cherry picked from commit 54d7177c78)
2017-06-02 13:19:23 +08:00
0e3899bed8 MdeModulePkg/UsbBus: Correct debug message
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit 76d1c752cb)
2017-06-02 13:02:01 +08:00
0b5813b95d MdeModulePkg/UsbBus: Fix system hang when failed to uninstall UsbIo
When "reconnect -r" is typed in shell, UsbFreeInterface() is called
to uninstall the UsbIo and DevicePath. But When a UsbIo is opened
by a driver and that driver rejects to close the UsbIo in Stop(),
the uninstall doesn't succeed.
But UsbFreeInterface () frees the DevicePath memory without check
whether the uninstall succeeds.
It leads to the DXE core database contain a DevicePath instance but
that instance's memory is freed.
Assertion happens when someone calls InstallProtocol(DevicePath)
because the InstallProtocol() checks all DevicePath instance to
find whether the same one exits in database.

We haven't seen any USB device driver which rejects to close UsbIo
in Stop(), but it's very likely.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Feng Tian <feng.tian@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
(cherry picked from commit b659b503fa)
2017-06-02 13:02:01 +08:00
8ecee3850d BaseTools/Bin: Update the BaseTools Win32 binaries version information
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
2017-05-31 15:20:21 +08:00
508dc16eae MdePkg/DevicePathLib: Reverse the byte order of BD_ADDR for Bluetooth
For the following two functions:
DevPathFromTextBluetooth()
DevPathToTextBluetooth()

The Bluetooth device address "UINT8  Address[6]" is displayed with the
order from Address[5] to Address[0]. This commit reverses the order.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
(cherry picked from commit 4fc8277133)
2017-05-31 10:33:23 +08:00
ed500f9ed0 UefiCpuPkg/MpInitLib: Force to enable X2APIC if CPU number > 255
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan <jeff.fan@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
(cherry picked from commit 71d8226ac6)
2017-05-27 14:10:55 +08:00
537b39af13 UefiCpuPkg/MpInitLib: Check APIC mode change around AP function
If APIC ID values are changed during AP functions execution, we need to update
new APIC ID values in local data structure accordingly.

But if APIC mode change happened during AP function execution, we do not support
APIC ID value changed.

Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan <jeff.fan@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
(cherry picked from commit c6b0feb396)
2017-05-27 14:10:54 +08:00
dc834fb544 UefiCpuPkg/CpuCommonFeaturesLib: Support X2APIC enable
Current X2APIC is enabled in MpInitLib (used by CpuMpPei and CpuDxe) to follow
SDM suggestion. That means we only enable X2APIC if we found there are any
initial CPU ID value >= 255.

This patch is to provide one chance for platform to enable X2APIC even there is
no any initial CPU ID value >= 255.

Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan <jeff.fan@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
(cherry picked from commit 6661abb695)
2017-05-27 14:10:53 +08:00
60b6b38cde BaseTools: Correct if condition expression for DatumType == 'VOID*'
Correct the if condition expression for DatumType == 'VOID*'. Current
this condition is not work since the DatumType is changed before we do
the value judgement.

Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit 687bde9cac)
2017-05-25 11:32:40 +08:00
d3b84e02eb BaseTools: Fix the bug that different DSC file use same build output
We meet a corner case that build different DSC file, but the DSC file use
same build output directory, and the different DSC file use a same PCD
with different Pcd Type, it cause build failure.

Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit 2d49938845)
2017-05-25 11:32:40 +08:00
60ea76dd3a BaseTools: Fix incremental build bug on DynamicPcd Token Generation
During incremental build, we meet the bug that the different drivers use
the different token for the same DynamicPcd.

Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit 99adfe9f51)
2017-05-25 11:32:39 +08:00
931f669d81 UefiCpuPkg/MpInitLib: Fix X64 XCODE5/NASM compatibility issues
https://bugzilla.tianocore.org/show_bug.cgi?id=565

Fix NASM compatibility issues with XCODE5 tool chain.
The XCODE5 tool chain for X64 builds using PIE (Position
Independent Executable).  For most assembly sources using
PIE mode does not cause any issues.

However, if assembly code is copied to a different address
(such as AP startup code in the MpInitLib), then the
X64 assembly source must be implemented to be compatible
with PIE mode that uses RIP relative addressing.

The specific changes in this patch are:

* Use LEA instruction instead of MOV instruction to lookup
  the addresses of functions.

* The assembly function RendezvousFunnelProc() is copied
  below 1MB so it can be executed as part of the MpInitLib
  AP startup sequence.  RendezvousFunnelProc() calls the
  external function InitializeFloatingPointUnits().  The
  absolute address of InitializeFloatingPointUnits() is
  added to the MP_CPU_EXCHANGE_INFO structure that is passed
  to RendezvousFunnelProc().

Cc: Andrew Fish <afish@apple.com>
Cc: Jeff Fan <jeff.fan@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Jeff Fan <jeff.fan@intel.com>
Reviewed-by: Andrew Fish <afish@apple.com>
(cherry picked from commit 3b2928b469)
2017-05-24 15:07:00 -07:00
8bb0a06208 MdeModulePkg/LogoDxe: Return error if HII Package not present
https://bugzilla.tianocore.org/show_bug.cgi?id=554

Update LogoDxe module to print a DEBUG() message and exit
with an error instead of ASSERT_EFI_ERROR() if the HII
Image Package with the logo image is not present.

If a tool chain does not support generation of PE/COFF
resource sections, then this module can not produce the logo
from an HII Image Package.  XCODE5 is an example of a tool
chain that does not currently support generation of PE/COFF
resource sections.

Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Andrew Fish <afish@apple.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Michael Kinney <michael.d.kinney@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit 1c020add31)
2017-05-24 15:06:35 -07:00
cfab632610 edk2: Add .DS_Store to .gitignore for macOS
https://bugzilla.tianocore.org/show_bug.cgi?id=558

macOS may generate .DS_Store files in directories.
The .gitignore file is updated to ignore these
.DS_Store files.

Cc: Andrew Fish <afish@apple.com>
Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Andrew Fish <afish@apple.com>
(cherry picked from commit 112f4ada2e)
2017-05-24 15:06:14 -07:00
4dae0b6999 BaseTools: Clean up tools_def.template for XCODE5
Reorganize the statements for XCODE5 to match other tool
chains and remove dependency on XCLANG and XCODE32

Cc: Andrew Fish <afish@apple.com>
Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Andrew Fish <afish@apple.com>
(cherry picked from commit 3e1d93c32e)
2017-05-24 15:06:01 -07:00
4f953cca20 BaseTools: Add -D NO_MSABI_VARGS to X64 XCODE5 CC_FLAGS
https://bugzilla.tianocore.org/show_bug.cgi?id=561

Update BaseTools/Conf/tools_def.template to add the define

-D NO_MSABI_VAARGS

To CC_FLAGS for X64 XCODE5 builds.

The llvm/clang compiler used in XCODE5 builds supports the
_ms_ versions of the vararg builtins, but the compiler
generates build errors.

The recommendation from the XCODE5 experts is to never use
the _ms_ version of the vararg builtins.  The define
NO_MSABI_VARARGS is already supported in MdePkg/Include/Base.h
and forces the use the standard vararg builtins.

Cc: Andrew Fish <afish@apple.com>
Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Andrew Fish <afish@apple.com>
(cherry picked from commit bdaced0bcf)
2017-05-24 15:05:45 -07:00
6933eb824a OvmfPkg: Add XCODE5 statements to fix build break
https://bugzilla.tianocore.org/show_bug.cgi?id=559

The XCODE5 tool chain has a FAMILY of GCC.  The
GCC statements in the [BuildOptions] section add
flags that are not compatible with XCODE5.  Add
empty XCODE5 statements in [BuildOptions] sections
to prevent the use of the GCC flags in XCODE5
builds.

Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Andrew Fish <afish@apple.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
(cherry picked from commit 01e9597540)
2017-05-24 15:05:32 -07:00
e10f7f1bae UefiCpuPkg: Use FINIT instead of hex values
https://bugzilla.tianocore.org/show_bug.cgi?id=560

Update X64 NASM file to match IA32 NASM file
and use FINIT instruction instead of hand
assembled hex values for the FINIT instruction.

Cc: Jeff Fan <jeff.fan@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Jeff Fan <jeff.fan@intel.com>
(cherry picked from commit b9dbc03e5a)
2017-05-24 15:05:18 -07:00
19b5379a3c UefiCpuPkg/BaseUefiCpuLib: Use NASM read-only data section name
https://bugzilla.tianocore.org/show_bug.cgi?id=556

NASM requires read-only data sections to use the section
name .rodata.  This fix changes .rdata to .rodata.

The build failure from use of .rdata is seen when using
the XCODE5 tool chain.

Section "7.8.1 macho extensions to the SECTION Directive"
of the NASM documentation at http://www.nasm.us/doc/
describes the section name requirements.

Cc: Jeff Fan <jeff.fan@intel.com>
Cc: Andrew Fish <afish@apple.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Michael Kinney <michael.d.kinney@intel.com>
Reviewed-by: Jeff Fan <jeff.fan@intel.com>
(cherry picked from commit 5b78f30d81)
2017-05-24 15:05:08 -07:00
66a539b5d4 UefiCpuPkg/PiSmmCpuDxeSmm: Add missing JMP instruction
https://bugzilla.tianocore.org/show_bug.cgi?id=555

Add JMP instruction in SmiEntry.S file that is missing.  This
updates SmiEntry.S to match the logic in SmiEntry.asm and
SmiEntry.nasm.

The default BUILDRULEORDER has .nasm higher priority than
.asm or .S, so this issue was not seen with MSFT or GCC
tool chain families.  The XCODE5 tool chain overrides the
BUILDRULEORDER with .S higher than .nasm, so this issue
was only seen when using XCODE5 tool chain when IA32 SMM
is enabled.

Cc: Jeff Fan <jeff.fan@intel.com>
Cc: Andrew Fish <afish@apple.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Michael Kinney <michael.d.kinney@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
(cherry picked from commit 0d0a19cb14)
2017-05-24 15:04:55 -07:00
cb053bb8a3 PcAtChipsetPkg/SerialIoLib: Remove negative value shift
https://bugzilla.tianocore.org/show_bug.cgi?id=553

Remove left shift of negative values that always evaluate
to 0 to address build errors from the llvm/clang compiler
used in the XCODE5 tool chain.

Clang rightfully complains about left-shifting ~DLAB. DLAB is #defined
as 0x01 (an "int"), hence ~DLAB has value (-2) on all edk2 platforms.
Left-shifting a negative int is undefined behavior.

Rather than replacing ~DLAB with ~(UINT32)DLAB, realize that the nonzero
bits of (~(UINT32)DLAB << 7) would all be truncated away in the final
conversion to UINT8 anyway. So just remove (~DLAB << 7).

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Andrew Fish <afish@apple.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
(cherry picked from commit bbd61de5db)
2017-05-24 15:04:16 -07:00
1a6ed43a07 MdeModulePkg SmiHandlerProfile: Use fixed data type in data structure
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=568

Use fixed data type in data structure and make the structure
be natural aligned.
Without this update, the code must assume DXE and SMM are using
same data type (same size of UINTN), but it may be not true at
some case, for example, after standalone SMM feature is enabled.
With this update, the data structure will be phase independent
and convenient for consumer to parse the data.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
(cherry picked from commit f248539538)
2017-05-24 15:29:02 +08:00
93637612c0 MdeModulePkg SmiHandlerProfile: Fix no PDB case handling incorrectly
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=569

The PdbStringOffset should be set to 0 for no PDB case,
then SmiHandlerProfileInfo can use it to know whether
there is PCD info or not.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
(cherry picked from commit 8ced192d5c)
2017-05-24 15:29:01 +08:00
d58f502728 UefiCpuPkg/DxeMpInitLib.inf: Add missing SynchronizationLib
Contributed-under: TianoCore Contribution Agreement 1.0
Cc: Eric Dong <eric.dong@intel.com>
Signed-off-by: Jeff Fan <jeff.fan@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
(cherry picked from commit ac63e9392e)
2017-05-23 14:48:27 +08:00
7ecf635971 MdeModulePkg/BDS: Fix a buffer overflow bug
KeyOption points to a buffer holding the content of Key####.
So its size is smaller than EFI_BOOT_MANAGER_KEY_OPTION.
Old code to assign value to KeyOption->OptionNumber modifies
the memory outside of the KeyOption buffer.

The patch fixes this bug.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Steven Shi <steven.shi@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Jeff Fan <jeff.fan@intel.com>
(cherry picked from commit 7320b8ed18)
2017-05-22 09:51:18 +08:00
454d99de04 CryptoPkg/BaseCryptLib: Add NULL pointer checks in DH and P7Verify
Add more NULL pointer checks before using them in DhGenerateKey and
Pkcs7GetCertificatesList functions to eliminate possible dereferenced
pointer issue.

Cc: Ting Ye <ting.ye@intel.com>
Cc: Hao Wu <hao.a.wu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Qin Long <qin.long@intel.com>
Reviewed-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Ting Ye <ting.ye@intel.com>
(cherry picked from commit a9fb7b7803)
2017-05-22 09:00:16 +08:00
3ecfa5668f MdeModulePkg PCD: Fix TmpTokenSpaceBufferCount not assigned correctly
When DynamicEx PCD is only used in PEI code, but not DXE code,
current implementation of DxePcdGetNextTokenSpace does not assign
TmpTokenSpaceBufferCount correctly, but leaves it as initial value,
then DxePcdGetNextTokenSpace may return incorrect token space guid
and status.

This patch is to fix this issue.

Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit da0df6ca8f)
2017-05-19 11:36:34 +08:00
2d18c3a917 MdeModulePkg/UfsPassThruDxe: Fix typo in UfsPassThruGetTargetLun()
For function UfsPassThruGetTargetLun(), the length of the input device
node specified by 'DevicePath' should be compared with the size of
'UFS_DEVICE_PATH' rather than the size of 'SCSI_DEVICE_PATH'.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit a8321feebb)
2017-05-17 15:30:44 +08:00
ceaf8ece84 BaseTools/Bin: Update the BaseTools Win32 binaries version information
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
2017-05-13 09:52:45 +08:00
b46e49e70d BaseTools: Fix the bug for CArray PCD override in command line
This patch updated the CArray PCD override format from B"{}" to H"{}"
which align to build spec. Besides, it also do the clean up for the
function BuildOptionPcdValueFormat.

Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit db55dac775)
2017-05-12 16:45:50 +08:00
b0cfe7bb57 ShellBinPkg: Ia32/X64 Shell binary update.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
(cherry picked from commit 7607599627)
2017-05-12 14:54:20 +08:00
6358c320ad BaseTools: Fix the bug that FixedPcdGetPtr failure for CArray Pcd
This patch for the bug FixedPcdGetPtr report failure for the CArray type
Pcd. 1) correct the Fixed Pcd list; 2) correct the Fixed Pcd in Library
AutoGen file to same with Driver AutoGen file format.

Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
2017-05-12 13:37:49 +08:00
1d22d00766 MdeModulePkg SmiHandlerProfile: Fix memory leak in DumpSmiChildContext
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=530

In DumpSmiChildContext() of SmiHandlerProfile.c and
SmiHandlerProfileInfo.c, the return buffer from
ConvertDevicePathToText() should be freed after used.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
(cherry picked from commit fb1c81a1e5)
2017-05-12 13:09:12 +08:00
219fee13c8 ShellPkg/memmap: Dump memory map information for all memory types
The patch dumps memory map information for all memory types.
But to follow the SFO format of "memmap" defined in Shell 2.2 spec,
the patch doesn't dump the memory map information for OEM/OS
memory types. But it does include the OEM/OS memory in the total
size in SFO format.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
(cherry picked from commit 8bb61740d4)
2017-05-12 10:51:43 +08:00
14ddca5afe ShellPkg/memmap: Refine code
The patch changes Buffer to Descriptors, changes
(UINT8 *Walker) to (EFI_MEMORY_DESCRIPTOR *Walker).
The change makes lots of type conversion unnecessary.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
(cherry picked from commit ac25ebdccc)
2017-05-12 10:51:43 +08:00
afd7109b1c ShellPkg/HandleParsingLib: Show LoadedImageProtocol file name
This patch adds support for showing the file name associated with a
LoadedImageProtocol file path. This is a behavior that was present in
the old shell but has been lost in the new shell.

For example, using 'dh -v' in the old shell:

    Handle D3 (3A552218)
    Image (3A54C918)   File:MicrocodeUpdate
        ParentHandle..: 3A666398

vs. the new shell:

    D3: 3A552218
    LoadedImage
        Revision......: 0x00001000
        ParentHandle..: 3A666398

Here's what the output of 'dh -v' looks like after this patch:

    D3: 3A552218
    LoadedImage
        Name..........: MicrocodeUpdate
        Revision......: 0x00001000
        ParentHandle..: 3A666398

This seems like useful information for the shell to display.

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Jaben Carsey <jaben.carsey@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Westfahl <jeff.westfahl@ni.com>
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
(cherry picked from commit f4ac435465)
2017-05-11 19:17:16 +08:00
b6adb11163 ShellPkg/HandleParsingLib: Open LoadedImageProtocol first
This patch changes the order of operations to make sure we can open the
LoadedImageProtocol before getting the format string. This should not
affect functionality, and makes the next patch easier to review.

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Jaben Carsey <jaben.carsey@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Westfahl <jeff.westfahl@ni.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
(cherry picked from commit bbb212afa0)
2017-05-11 19:17:16 +08:00
9107fb6f55 ShellPkg/HandleParsingLib: Show LoadedImageProtocol file path as text
This patch adds support for displaying a text representation of the file
path associated with a LoadedImageProtocol. This is a behavior that was
present in the old shell but has been lost in the new shell.

For example, using 'dh -v' in the old shell:

    FilePath......: FvFile(F3331DE6-4A55-44E4-B767-7453F7A1A021)
    FilePath......: \EFI\BOOT\BOOTX64.EFI

vs. the new shell:

    FilePath......: 3A539018
    FilePath......: 3A728718

This seems like useful information for the shell to display.

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Jaben Carsey <jaben.carsey@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Westfahl <jeff.westfahl@ni.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
(cherry picked from commit c15323ae2e)
2017-05-11 19:17:15 +08:00
d30c0e3f5a ShellPkg/ShellCommandLib: Update DumpHex to print {|}~
ASCII characters {|}~ should be printed by DumpHex. The problem is that
if you have a string like

    {xizzy}~{foo|bar}~{quux}

in the dumped data, it will not appear as such in the *-delimited ASCII
column to the right, but as

    .xizzy...foo.bar...quux.

which is less than ideal.

Most of the commit message was inspired by/shamelessly stolen from
Laszlo's example:

    https://lists.01.org/pipermail/edk2-devel/2017-April/010266.html

Cc: Jaben Carsey <jaben.carsey@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Westfahl <jeff.westfahl@ni.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
(cherry picked from commit 4bf3b994e8)
2017-05-11 19:17:15 +08:00
9f7e9a0687 UefiCpuPkg/PiSmmCpuDxeSmm: Fix logic check error
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan <jeff.fan@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
(cherry picked from commit 29dc8aa861)
2017-05-11 16:34:58 +08:00
a08c8afa4c UefiCpuPkg/PiSmmCpuDxeSmm: Check ProcessorId == INVALID_APIC_ID
If PcdCpuHotPlugSupport is TRUE, gSmst->NumberOfCpus will be the
PcdCpuMaxLogicalProcessorNumber. If gSmst->SmmStartupThisAp() is invoked for
those un-existed processors, ASSERT() happened in ConfigSmmCodeAccessCheck().

This fix is to check if ProcessorId is valid before invoke
gSmst->SmmStartupThisAp() in ConfigSmmCodeAccessCheck() and to check if
ProcessorId is valid in InternalSmmStartupThisAp() to avoid unexpected DEBUG
error message displayed.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan <jeff.fan@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
(cherry picked from commit b7025df8f9)
2017-05-11 16:34:57 +08:00
c345ecbb9b UefiCpuPkg/SmmCpuFeaturesLib: Correct print level
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan <jeff.fan@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
(cherry picked from commit 5d0933f9ba)
2017-05-11 16:34:56 +08:00
166481dabf UefiCpuPkg/SmmCpuFeaturesLib: Fix Ia32/SmiEntry.asm build issue
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan <jeff.fan@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
(cherry picked from commit 6afc643ce0)
2017-05-11 16:34:56 +08:00
52dd44ec92 SecurityPkg: Add TCG Spec info to TCG related modules
Add TCG Spec compliance info to TCG related module INFs.

Cc: Qin Long <qin.long@intel.com>
Cc: Yao Jiewen <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Chao Zhang <chao.b.zhang@intel.com>
Reviewed-by: Qin Long <qin.long@intel.com>
Reviewed-by: Yao Jiewen <jiewen.yao@intel.com>
(cherry picked from commit 6d92ae11d1)
2017-05-11 16:23:41 +08:00
103f53b650 BaseTools: Correct VOID* PatchPcd Size in Library Autogen
This patch correct the VOID* PatchPcd Size info generated in the
Library's autogen file. Update it to use the MaxDatumSize.

Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
2017-05-11 14:32:12 +08:00
0ebc1fa295 MdeModulePkg CapsuleApp: Fix mixed EOL format issue
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit 8ecb1e9bef)
2017-05-11 12:59:49 +08:00
dee4573998 NetworkPkg/IScsiDxe: Switch IP4 configuration policy to Static before DHCP
DHCP4 service allows only one of its children to be configured in the active
state. If the DHCP4 D.O.R.A started by IP4 auto configuration and has not
been completed, the Dhcp4 state machine will not be in the right state for
the iSCSI to start a new round D.O.R.A. So, we need to switch it's policy to
static.

Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com>
Reviewed-by: Ye Ting <ting.ye@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
(cherry picked from commit ef810bc807)
2017-05-11 10:54:46 +08:00
1316cced3e MdeModulePkg/FormDisplay: Make the LineWidth of option consistent
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=529

LineWidth of option in funcrion UpdateSkipInfoForMenu and DisplayOneMenu
are inconsistent. Now fix this issue to avoid incorrect UI display.

Cc: Eric Dong <eric.dong@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
(cherry picked from commit df5914993c)
2017-05-11 10:51:03 +08:00
72d014cd18 BaseTools/Ecc: Add line break support for exception list
Add line break support for exception list.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hess Chen <hesheng.chen@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
2017-05-11 09:31:50 +08:00
ca89f36940 BaseTools: Sync BrotliCompress script the same style
- Sync BrotliCompress script the same style with BrotliCompress.bat

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Bell Song <binx.song@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit 8ee193e898)
2017-05-10 16:30:59 +08:00
96f3ca2307 BaseTools: Add --version option in Brotli and BrotliCompress
https://bugzilla.tianocore.org/show_bug.cgi?id=464
V2:
- Add build version

V1:
- Add --version option in Brotli and BrotliCompress

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Bell Song <binx.song@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit 98cb468435)
2017-05-10 16:30:57 +08:00
c95b7d8ee1 Nt32Pkg/SnpNt32Dxe: Fix hang issue when multiple network interfaces existed
Currently all the network interfaces share the one recycled transmit buffer
array, which is used to store the recycled buffer address. However, those
recycled buffers are allocated by the different MNP interface if the multiple
network interfaces existed. Then, SNP GetStatus may return one recycled transmit
buffer address to the another MNP interface, which may result in the MNP driver
hang after 'reconnect -r' operation.

Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
(cherry picked from commit d547b32dcc)
2017-05-09 14:36:39 +08:00
1531c7bd82 NetworkPkg: Fix issue in dns driver when building DHCP packet.
Currently, DNS driver configure the dhcp message type to inform
when building dhcp packet to get dns info from, but it not works
with dhcp server deployed on linux system. However it works well
when changed to request type.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo <lubo.zhang@intel.com>
Cc: Wu Jiaxin <jiaxin.wu@intel.com>
Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Wu Jiaxin <jiaxin.wu@intel.com>
(cherry picked from commit b61fda1129)
2017-05-09 14:36:31 +08:00
82729eef4c MdeModulePkg: Addressing TCP Window Retraction when window scale factor is used.
The RFC1323 which defines the TCP window scale option has been obsoleted by RFC7323.
This patch is to follow the RFC7323 to address the TCP window retraction problem
when a non-zero scale factor is used.
The changes has been test in high packet loss rate network by using HTTP boot and
iSCSI file read/write.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Wu Jiaxin <jiaxin.wu@intel.com>
Reviewed-by: Ye Ting <ting.ye@intel.com>
(cherry picked from commit ca12a0c83b)
2017-05-09 08:53:03 +08:00
a28adad906 NetworkPkg: Addressing TCP Window Retraction when window scale factor is used.
The RFC1323 which defines the TCP window scale option has been obsoleted by RFC7323.
This patch is to follow the RFC7323 to address the TCP window retraction problem
when a non-zero scale factor is used.
The changes has been test in high packet loss rate network by using HTTP boot and
iSCSI file read/write.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Wu Jiaxin <jiaxin.wu@intel.com>
Reviewed-by: Ye Ting <ting.ye@intel.com>
(cherry picked from commit 3696ceaecb)
2017-05-09 08:53:01 +08:00
66dcf570a6 MdeModulePkg: Add wnd scale check before shrinking window.
Moving Right window edge to the left on sender side without additional check
can lead to the TCP deadlock, when receiver ACKs proper segment, while sender
discards it for future ACK. To prevent this add check if usable window (or
shrink amount in this case) is bigger then receiver's window scale factor.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Andrey Tepin <atepin@kraftway.ru>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
(cherry picked from commit 207b3d2b0b)
2017-05-09 08:52:58 +08:00
b583486b14 NetworkPkg: Add wnd scale check before shrinking window.
Moving Right window edge to the left on sender side without additional check
can lead to the TCP deadlock, when receiver ACKs proper segment, while sender
discards it for future ACK. To prevent this add check if usable window (or
shrink amount in this case) is bigger then receiver's window scale factor.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Andrey Tepin <atepin@kraftway.ru>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
(cherry picked from commit 2d5afbdad1)
2017-05-09 08:52:55 +08:00
85426bd106 UefiCpuPkg/MtrrLib: Don't report OutOfResource when MTRR is enough
The MTRR calculation algorithm contains a bug that when left
subtraction cannot produce better MTRR solution, it forgets
to restore the BaseAddress/Length so that MtrrLibGetMtrrNumber()
returns bigger value of actual required MTRR numbers.
As a result, the MtrrLib reports OutOfResource but actually the
MTRR is enough.

MEMORY_RANGE mC[] = {
  0, 0x100000, CacheUncacheable,
  0x100000, 0x89F00000, CacheWriteBack,
  0x8A000000, 0x75000000, CacheUncacheable,
  0xFF000000, 0x01000000, CacheWriteProtected,
  0x100000000, 0x7F00000000, CacheUncacheable,
  0xFC240000, 0x2000, CacheWriteCombining // <-- trigger the error
};

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Jeff Fan <jeff.fan@intel.com>
(cherry picked from commit 3654c4623c)
2017-05-08 13:36:50 +08:00
455af1049f UefiCpuPkg: Update package version to 0.80
Cc: Feng Tian <feng.tian@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan <jeff.fan@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
(cherry picked from commit 007b51e180)
2017-05-08 13:32:22 +08:00
08f2c8fd3a UefiCpuPkg: Update package version to 0.80
Cc: Feng Tian <feng.tian@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan <jeff.fan@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
(cherry picked from commit 9304197261)
2017-05-08 13:25:00 +08:00
69a8a9ee20 MdePkg DxeServicesLib: Handle potential NULL FvHandle
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=514

The FvHandle input to InternalGetSectionFromFv() may be NULL,
then ASSERT will appear. It is because the LoadedImage->DeviceHandle
returned from InternalImageHandleToFvHandle() may be NULL.
For example for DxeCore, there is LoadedImage protocol installed
for it, but the LoadedImage->DeviceHandle could not be initialized
before the FV2 (contain DxeCore) protocol is installed.

This patch is to update InternalGetSectionFromFv() to return
EFI_NOT_FOUND directly for NULL FvHandle.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Michael Kinney <michael.d.kinney@intel.com>
Cc: Michael Turner <Michael.Turner@microsoft.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit d7b96017cc)
2017-05-08 09:02:03 +08:00
bd49174d05 BaseTools: PCD can only use single access method by source build
Add the error check that A PCD can only use one type for all source
modules.

Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
2017-05-08 07:56:49 +08:00
91751a0825 BaseTools: remove the hardcoded /bin/bash for PreBuild/PostBuild
This patch remove the hardcoded /bin/bash for PreBuild/PostBuild
scripts.

Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
2017-05-08 07:56:02 +08:00
f30c40618b MdeModulePkg: Update DEC/DSC version from 0.96 to 0.97
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Feng Tian <feng.tian@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit 717ba86de7)
2017-05-05 15:56:08 +08:00
e399d6ff56 SecurityPkg/Pkcs7VerifyDxe: Add format check in DB list contents
Add the size check for invalid format detection in AllowedDb,
RevokedDb and TimeStampDb list contents.

Cc: Chao Zhang <chao.b.zhang@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Qin Long <qin.long@intel.com>
Reviewed-by: Chao Zhang <chao.b.zhang@intel.com>
(cherry picked from commit 76b35710b9)
2017-05-05 15:07:40 +08:00
fd9e6ee972 SecurityPkg: Update package version to 0.97
Update package version of SecurityPkg to 0.97.

Cc: Qin Long <qin.long@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Chao Zhang <chao.b.zhang@intel.com>
Reviewed-by: Qin Long <qin.long@intel.com>
(cherry picked from commit de8e4dc4df)
2017-05-05 13:30:15 +08:00
32c1d95881 NetworkPkg: Update package version to 0.97.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Ye Ting <ting.ye@intel.com>
(cherry picked from commit 9ee3283bfb)
2017-05-05 11:46:50 +08:00
3b530b3896 CryptoPkg: Update package version to 0.97
Update package version of CryptoPkg to 0.97.

Cc: Ting Ye <ting.ye@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Qin Long <qin.long@intel.com>
Reviewed-by: Ting Ye <ting.ye@intel.com>
(cherry picked from commit b5a9dc8beb)
2017-05-05 11:30:58 +08:00
c54144f512 MdePkg: Update DEC and DSC version from 1.06 to 1.07
UEFI2.6 have been added in MdePkg. Update DEC and DSC version to
reflect those changes in MdePkg.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit 908a47c5f6)
2017-05-05 11:17:22 +08:00
7903b6d2b0 ShellPkg: Update package version to 1.01
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
(cherry picked from commit cc43244842)
2017-05-04 15:55:56 +08:00
929246cc03 ShellPkg/UefiHandleParsingLib: Fix memory leak
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Signed-off-by: Chen A Chen <chen.a.chen@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
(cherry picked from commit 00324f3fce)
2017-05-04 15:55:56 +08:00
7ff98a2f77 ShellPkg/Shell: eliminate double-free in RunSplitCommand()
Commit bd3fc8133b ("ShellPkg/App: Fix memory leak and save resources.",
2016-05-20) added a FreePool() call for Split->SplitStdIn, near end of the
RunSplitCommand(), right after the same shell file was closed with
CloseFile(). The argument was:

> 1) RunSplitCommand() allocates the initial SplitStdOut via
>    CreateFileInterfaceMem(). Free SplitStdIn after the swap to fix
>    the memory leak.

There is no memory leak actually, and the FreePool() call in question
constitutes a double-free:

(a) This is how the handle is established:

    ConvertEfiFileProtocolToShellHandle (
      CreateFileInterfaceMem (Unicode),
      NULL
      );

    CreateFileInterfaceMem() allocates an EFI_FILE_PROTOCOL_MEM object and
    populates it fully. ConvertEfiFileProtocolToShellHandle() allocates
    some administrative structures and links the EFI_FILE_PROTOCOL_MEM
    object into "mFileHandleList".

(b) EFI_SHELL_PROTOCOL.CloseFile() is required to close the
    SHELL_FILE_HANDLE and to release all associated data. Accordingly,
    near the end of RunSplitCommand(), we have:

    EfiShellClose()
      ShellFileHandleRemove()
        //
        // undoes the effects of ConvertEfiFileProtocolToShellHandle()
        //
      ConvertShellHandleToEfiFileProtocol()
        //
        // note that this does not adjust the pointer value; it's a pure
        // type cast
        //
      FileHandleClose()
        FileInterfaceMemClose()
          //
          // tears down EFI_FILE_PROTOCOL_MEM completely, undoing the
          // effects of CreateFileInterfaceMem ()
          //

The FreePool() call added by bd3fc8133b conflicts with

  SHELL_FREE_NON_NULL(This);

in FileInterfaceMemClose(), so remove it.

This error can be reproduced for example with:

> Shell> map | more
> 'more' is not recognized as an internal or external command, operable
> program, or script file.

which triggers:

> ASSERT MdeModulePkg/Core/Dxe/Mem/Pool.c(624): CR has Bad Signature

with the following stack dump:

> #0  0x000000007f6dc094 in CpuDeadLoop () at
>     MdePkg/Library/BaseLib/CpuDeadLoop.c:37
> #1  0x000000007f6dd1b4 in DebugAssert (FileName=0x7f6ed9f0
>     "MdeModulePkg/Core/Dxe/Mem/Pool.c", LineNumber=624,
>     Description=0x7f6ed9d8 "CR has Bad Signature") at
>     OvmfPkg/Library/PlatformDebugLibIoPort/DebugLib.c:153
> #2  0x000000007f6d075d in CoreFreePoolI (Buffer=0x7e232c98,
>     PoolType=0x7f6bc1c4) at MdeModulePkg/Core/Dxe/Mem/Pool.c:624
> #3  0x000000007f6d060e in CoreInternalFreePool (Buffer=0x7e232c98,
>     PoolType=0x7f6bc1c4) at MdeModulePkg/Core/Dxe/Mem/Pool.c:529
> #4  0x000000007f6d0648 in CoreFreePool (Buffer=0x7e232c98) at
>     MdeModulePkg/Core/Dxe/Mem/Pool.c:552
> #5  0x000000007d49fbf8 in FreePool (Buffer=0x7e232c98) at
>     MdePkg/Library/UefiMemoryAllocationLib/MemoryAllocationLib.c:818
> #6  0x000000007d4875c3 in RunSplitCommand (CmdLine=0x7d898398,
>     StdIn=0x0, StdOut=0x0) at ShellPkg/Application/Shell/Shell.c:1813
> #7  0x000000007d487d59 in ProcessNewSplitCommandLine
>     (CmdLine=0x7d898398) at ShellPkg/Application/Shell/Shell.c:2121
> #8  0x000000007d488937 in RunShellCommand (CmdLine=0x7e233018,
>     CommandStatus=0x0) at ShellPkg/Application/Shell/Shell.c:2670
> #9  0x000000007d488b0b in RunCommand (CmdLine=0x7e233018) at
>     ShellPkg/Application/Shell/Shell.c:2732
> #10 0x000000007d4867c8 in DoShellPrompt () at
>     ShellPkg/Application/Shell/Shell.c:1349
> #11 0x000000007d48524d in UefiMain (ImageHandle=0x7e24c898,
>     SystemTable=0x7f5b6018) at ShellPkg/Application/Shell/Shell.c:631

Cc: Jaben Carsey <jaben.carsey@intel.com>
Cc: Marvin Häuser <Marvin.Haeuser@outlook.com>
Cc: Qiu Shumin <shumin.qiu@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Fixes: bd3fc8133b
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Marvin Häuser <Marvin.Haeuser@outlook.com>
(cherry picked from commit 227fe49d5d)
2017-05-04 15:55:55 +08:00
c2fb3cd166 ShellPkg/Shell: clean up bogus member types in SPLIT_LIST
The "SPLIT_LIST.SplitStdOut" and "SPLIT_LIST.SplitStdIn" members currently
have type (SHELL_FILE_HANDLE *). This is wrong; SHELL_FILE_HANDLE is
already a pointer, there's no need to store a pointer to a pointer.

The error is obvious if we check where and how these members are used:

- In the RunSplitCommand() function, these members are used (populated)
  extensively; this function has to be updated in sync.

  ConvertEfiFileProtocolToShellHandle() already returns the temporary
  memory file created with CreateFileInterfaceMem() as SHELL_FILE_HANDLE,
  not as (SHELL_FILE_HANDLE *).

- In particular, the ConvertShellHandleToEfiFileProtocol() calls need to
  be dropped as well in RunSplitCommand(), since
  EFI_SHELL_PROTOCOL.SetFilePosition() and EFI_SHELL_PROTOCOL.CloseFile()
  take SHELL_FILE_HANDLE parameters, not (EFI_FILE_PROTOCOL *).

  Given that ConvertShellHandleToEfiFileProtocol() only performs a
  type-cast (it does not adjust any pointer values), *and*
  SHELL_FILE_HANDLE -- taken by EFI_SHELL_PROTOCOL member functions -- is
  actually a typedef to (VOID *) -- see more on this later --, this
  conversion error hasn't been caught by compilers.

- In the ProcessNewSplitCommandLine() function, RunSplitCommand() is
  called either initially (passing in NULL / NULL; no update needed), or
  recursively (passing in Split->SplitStdIn / Split->SplitStdOut; again no
  update is necessary beyond the RunSplitCommand() modification above).

- In the UpdateStdInStdOutStdErr() and RestoreStdInStdOutStdErr()
  functions, said structure members are compared and assigned to
  "EFI_SHELL_PARAMETERS_PROTOCOL.StdIn" and
  "EFI_SHELL_PARAMETERS_PROTOCOL.StdOut", both of which have type
  SHELL_FILE_HANDLE, *not* (SHELL_FILE_HANDLE *).

  The compiler hasn't caught this error because of the fatally flawed type
  definition of SHELL_FILE_HANDLE, namely

    typedef VOID *SHELL_FILE_HANDLE;

  Pointer-to-void silently converts to and from most other pointer types;
  among them, pointer-to-pointer-to-void. That is also why no update is
  necessary for UpdateStdInStdOutStdErr() and RestoreStdInStdOutStdErr()
  in this fix.

(

Generally speaking, using (VOID *) typedefs for opaque handles is a tragic
mistake in all of the UEFI-related specifications; this practice defeats
any type checking that compilers might help programmers with. The right
way to define an opaque handle is as follows:

  //
  // Introduce the incomplete structure type, and the derived pointer
  // type, in both the specification and the public edk2 headers. Note
  // that the derived pointer type itself is a complete type, and it can
  // be used freely by client code.
  //
  typedef struct SHELL_FILE *SHELL_FILE_HANDLE;

  //
  // Complete the structure type in the edk2 internal C source files.
  //
  struct SHELL_FILE {
    //
    // list fields
    //
  };

This way the structure size and members remain hidden from client code,
but the C compiler can nonetheless catch any invalid conversions between
incompatible XXX_HANDLE types.

)

Cc: Jaben Carsey <jaben.carsey@intel.com>
Cc: Marvin Häuser <Marvin.Haeuser@outlook.com>
Cc: Qiu Shumin <shumin.qiu@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
(cherry picked from commit 1bd0bf153e)
2017-05-04 15:55:55 +08:00
f567743825 ShellPkg SmbiosView: Display Type 0 BIOS segment in hexadecimal
The SMBIOS Type 0 BIOS segment field is currently displayed in decimal.
Since this field is likely to have a value like 0xE800 or 0xF000, using
hexadecimal seems like a better choice.

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Jaben Carsey <jaben.carsey@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Westfahl <jeff.westfahl@ni.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit fed709deb4)
2017-05-04 15:55:55 +08:00
09a0dbeb3f SecurityPkg: Consume SmmIoLib.
Update code to consume SmmIoLib to pass build.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Eric Dong <eric.dong@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
(cherry picked from commit 350e9150cc)
2017-05-04 10:08:22 +08:00
7154167901 SecurityPkg OpalPasswordSmm: Consume SmmIoLib.
Update code to consume SmmIoLib to check Mmio validation.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Eric Dong <eric.dong@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
(cherry picked from commit 50e6bb98ee)
2017-05-04 10:08:22 +08:00
2078ead60d NetworkPkg: Fix PXEv6 boot failure when DhcpBinl offer received.
In case of the DHCP and PXE services on different servers,PXEv6 boot will
failure when DhcpBinl offer received. The issue is caused by the following
reasons:
* PXE Client doesn't append VENDOR_CLASS request parameter, so the
offer replied from DHCP service will not contain VENDOR_CLASS option
(16).
* Once the DhcpBinl offer is selected, the boot discover message should
be sent out to request the bootfile by this offer. Current implementation
always use servers multi-cast address instead of BootFileUrl address in
dhcp6 offer. we should check it first, then decide whether use multi-cast
address or not.
* If DhcpBinl offer is selected, the boot discover message shouldn't
find server ID Option from DhcpBinl offer. That's incorrect because DHCP
service and PXE service on different servers. In such a case, we can ignore
the Server ID Option.

With the above fix in the patch, PXEv6 can boot successfully when DhcpBinl
offer received.

Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Ye Ting <ting.ye@intel.com>
(cherry picked from commit be37315a08)
2017-05-03 11:31:08 +08:00
efbf0349e7 NetworkPkg: Fix bug in iSCSI mode ipv6 when enabling target DHCP.
if the server name expressed as a site local address begain with FEC0
when retrieving from dhcpv6 option 59 boot file url, it incorrectly process it
as a dns name.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo <lubo.zhang@intel.com>
Cc: Wu Jiaxin <jiaxin.wu@intel.com>
Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Wu Jiaxin <jiaxin.wu@intel.com>
(cherry picked from commit 91cdd20f70)
2017-05-02 11:14:37 +08:00
eb7506f76d NetworkPkg: Fix issue the iSCSI client can not send reset packet.
if we already established a iSCSI connection from initiator to target
based on IPv4 stack, after using reconnect -r command, we can not rebuild
the session with the windows target, since the server thought the session
is still exist.  This issue is caused by wrong place of acquire ownership of
sock lock which lead the iSCSI can not reset the connection correctly.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo <lubo.zhang@intel.com>
Cc: Wu Jiaxin <jiaxin.wu@intel.com>
Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Wu Jiaxin <jiaxin.wu@intel.com>
(cherry picked from commit 597cf8a19f)
2017-05-02 11:14:30 +08:00
5b3b1e00dc MdeModulePkg: Fix issue the iSCSI client can not send reset packet correctly.
if we already established a iSCSI connection from initiator to target
based on IPv4 stack, after using reconnect -r command, we can not rebuild
the session with the windows target, since the server thought the session
is still exist.  This issue is caused by wrong place of acquire ownership of
sock lock which lead the iSCSI can not reset the connection correctly.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo <lubo.zhang@intel.com>
Cc: Wu Jiaxin <jiaxin.wu@intel.com>
Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Wu Jiaxin <jiaxin.wu@intel.com>
(cherry picked from commit e3793f9834)
2017-05-02 11:14:24 +08:00
905190af42 CryptoPkg/SmmCryptLib: Enable HMAC-SHA256 support for SMM.
Enable HMAC-SHA256 cipher support in SmmCryptLib instance.

Cc: Ting Ye <ting.ye@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Qin Long <qin.long@intel.com>
Reviewed-by: Ting Ye <ting.ye@intel.com>
(cherry picked from commit 25942a4026)
2017-05-02 09:07:08 +08:00
0c0490ecaa MdePkg/dsc: add SmmIoLib
Cc: Jeff Fan <jeff.fan@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Jeff Fan <jeff.fan@intel.com>
2017-04-28 16:44:27 +08:00
ed906ffb84 MdePkg/dec: Add SmmIoLib.
Cc: Jeff Fan <jeff.fan@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Jeff Fan <jeff.fan@intel.com>
2017-04-28 16:44:26 +08:00
20237f4854 MdePkg/SmmIoLib: Add sample instance.
The sample instance check if IO resource is valid
one defined in GCD.
A platform may choose add more check to exclude some
other IO resource.

Cc: Jeff Fan <jeff.fan@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Jeff Fan <jeff.fan@intel.com>
2017-04-28 16:44:24 +08:00
d64de223f7 MdePkg/SmmIoLib: Add header file.
This SmmIoLib is used to check if an IO resource
is valid in SMM.

Cc: Jeff Fan <jeff.fan@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Jeff Fan <jeff.fan@intel.com>
2017-04-28 16:44:22 +08:00
7a4b6b1688 MdeModulePkg/Ip4Dxe: Fix the incorrect RemoveEntryList
Cc: Subramanian Sriram <sriram-s@hpe.com>
Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Cc: Zhang Lubo <lubo.zhang@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com>
Reviewed-by: Zhang Lubo <lubo.zhang@intel.com>
Reviewed-by: Sriram Subramanian <sriram-s@hpe.com>
(cherry picked from commit ad18ec9543)
2017-04-28 08:24:13 +08:00
11a4e7057b BaseTools: Rsa2048Sha256GenerateKeys to support OPENSSL_PATH has space
Update Rsa2048Sha256GenerateKeys Tool to support the case that
OPENSSL_PATH has space characters.

Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
2017-04-27 21:27:46 +08:00
ffd2cde5d2 BaseTools: Rsa2048Sha256Sign Tool to support OPENSSL_PATH has space
Update Rsa2048Sha256Sign Tool to support the case that OPENSSL_PATH has
space characters.

Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
2017-04-27 21:26:44 +08:00
1377330367 BaseTools: Pkcs7Sign Tool to support OPENSSL_PATH has space
Update Pkcs7Sign Tool to support the case that OPENSSL_PATH has space
characters.

Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
2017-04-27 21:26:02 +08:00
3b43e9c06a BaseTools/VolInfo: Update OPENSSL_PATH to support space characters
Update OPENSSL_PATH handling to support space characters in the Path.

Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
2017-04-27 21:25:06 +08:00
78fbc8ec8e BaseTools: fix the typo in function name LanuchPostbuild
The patch fix function name typo LanuchPostbuild ==> LaunchPostbuild.

Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Nikolai SAOUKH <nms@otdel-1.org>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
2017-04-27 21:24:31 +08:00
88a0b204ec BaseTools: Fix a bug for BOOLEAN type value in Asbuilt inf
When the PCD value is set to TRUE or FALSE, while it is not exchanged to
its int value, it cause error in the function int(Pcd.DefaultValue, 0).

Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
2017-04-27 21:23:41 +08:00
407a5c55ba PeCoffGetEntryPointLib: Fix spelling issue
*Serach* should be *Search*

Cc: Liming Gao <liming.gao@intel.com>
Cc: Feng Tian <feng.tian@intel.com>
Cc: Michael Kinney <michael.d.kinney@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan <jeff.fan@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit 9e981317be)
2017-04-26 11:30:27 +08:00
44c7d1d40c UefiCpuPkg/MpLib.c: Set AP state after X2APIC mode enabled
After X2APIC mode is enabled, APs need to be set tp IDLE state, otherwise APs
cannot be waken up by MP PPI services.

https://bugzilla.tianocore.org/show_bug.cgi?id=505

Cc: Feng Tian <feng.tian@intel.com>
Cc: Michael Kinney <michael.d.kinney@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan <jeff.fan@intel.com>
Reviewed-by: Feng Tian <feng.tian@intel.com>
(cherry picked from commit 59a119f0fc)
2017-04-26 11:30:26 +08:00
5fc4b658e6 UefiCpuPkg: Move ProgramVirtualWireMode() to MpInitLib
In PEI phase, BSP did not program vitural wired mode while APs did.

Move program virtual wired mode from CpuDxe to MpInitLib, thus it could benefit
on both CpuDxe and CpuMpPei.

https://bugzilla.tianocore.org/show_bug.cgi?id=496

Cc: Feng Tian <feng.tian@intel.com>
Cc: Michael Kinney <michael.d.kinney@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan <jeff.fan@intel.com>
Reviewed-by: Feng Tian <feng.tian@intel.com>
(cherry picked from commit 9d64a9fd9e)
2017-04-26 11:30:25 +08:00
094d3a4142 UefiCpuPkg/MpInitLib: needn't to allocate AP reset vector
Because we will always borrow the AP reset vector space for AP waking up. We
needn't allocate such range to prevent other module to use it. It could simply
the code.

https://bugzilla.tianocore.org/show_bug.cgi?id=500

Cc: Feng Tian <feng.tian@intel.com>
Cc: Michael Kinney <michael.d.kinney@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan <jeff.fan@intel.com>
Reviewed-by: Feng Tian <feng.tian@intel.com>
(cherry picked from commit c934a0a581)
2017-04-26 11:30:24 +08:00
28614a7b7c UefiCpuPkg/MpInitLib: save/restore original contents
If APs is in HLT-LOOP mode, we need AP reset vector for waking up APs. This
updating is to save/restore original contents of AP reset vector around waking
up APs always.

https://bugzilla.tianocore.org/show_bug.cgi?id=500

Cc: Feng Tian <feng.tian@intel.com>
Cc: Michael Kinney <michael.d.kinney@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan <jeff.fan@intel.com>
Reviewed-by: Feng Tian <feng.tian@intel.com>
(cherry picked from commit 9293d6e42e)
2017-04-26 11:30:23 +08:00
9b68006c93 MdeModulePKg/BDS: Build meaningful description for Wi-Fi boot option
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Fan Wang <fan.wang@intel.com>
Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>
(cherry picked from commit 6bbd4a8f5f)
2017-04-26 09:38:15 +08:00
0abf7713aa MdeModulePkg/Ip4Dxe: Refine the IPv4 configuration help info
Below value indicate whether network address configured successfully
or not:
Network Device List->MAC->IPv4 Network Configuration->Configured.

This patch is to refine its help info.

Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com>
Reviewed-by: Ye Ting <ting.ye@intel.com>
(cherry picked from commit d7dd4f0a06)
2017-04-25 18:20:32 +08:00
fa939c26b6 MdeModulePkg: Update PiSmmCore to set correct ImageAddress into LoadedImage
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit d5a67b3da1)
2017-04-25 09:51:18 +08:00
71a9aa1c50 MdeModulePkg PiSmmIpl: Fix the issue in LMFA feature
SmramBase should be got from mLMFAConfigurationTable.

Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit c2aeb66fff)
2017-04-25 09:51:18 +08:00
4d3f4a20f1 MdeModulePkg/UfsPciHc: Avoid overriding return value in BindingStart
In function UfsHcDriverBindingStart(), the return value 'Status' may be
overridden during the original PCI attributes restore process.

This commit refines the logic to avoid such override.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit 1a5ae66175)
2017-04-25 09:10:14 +08:00
9fe5799446 MdeModulePkg/UfsPciHc: Remove unused field in UfsHc private struct
The commit removes the unused field 'EFI_HANDLE  Handle' in Ufs host
controller private data structure 'UFS_HOST_CONTROLLER_PRIVATE_DATA'.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit c36ea72ebd)
2017-04-25 09:10:14 +08:00
5794c3a92c MdeModulePkg/NvmExpressDxe: Handling return of write to sq and cq db
In case of an async command if updating the submission queue tail
doorbell fails then the command will not be picked up by device and
no completion response will be created. This scenario has to be handled.
Also if we create an AsyncRequest element and insert in the async queue,
it will never receive a completion so in the timer routine this element
won't be freed, resulting in memory leak. Also in case of blocking calls
we should capture the status of updating completion queue head doorbell
register and return it to caller of PassThru.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Suman Prakash <suman.p@samsung.com>
Reviewed-by: Hao Wu <hao.a.wu@intel.com>
(cherry picked from commit f6b139bde7)
2017-04-25 09:10:13 +08:00
844a25f983 MdeModulePkg: Discard received broadcast message in DxeIpIoLib.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Ye Ting <ting.ye@intel.com>
Reviewed-by: Wu Jiaxin <jiaxin.wu@intel.com>
(cherry picked from commit dd29d8b356)
2017-04-24 10:13:29 +08:00
b4244d101d MdeModulePkg/PiSmmCore: Remove redundant PoolTail pointer assignment
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit f8f931f632)
2017-04-24 09:02:46 +08:00
f35772deee MdeModulePkg/DeviceManagerUiLib: Fix the network device MAC display issue
v3:
* Add NULL string check.

v2:
* Define new STR_FORM_NETWORK_DEVICE_TITLE_HEAD for L" Network Device "
instead of hard code in the code.

Network device tile (STR_FORM_NETWORK_DEVICE_TITLE) is dynamic adjusted
according the different MAC value. So, the string value shouldn't be treated
as a constant string (Network Device). Otherwise, the display will be
incorrect.

Reproduce: Device Manager->Network Device List, select to enter MAC, then to
press ESC back to previous page, then re-enter, found each enter/ESC operation,
the MAC address display +1.

Cc: Eric Dong <eric.dong@intel.com>
Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com>
Reviewed-by: Ye Ting <ting.ye@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
(cherry picked from commit 205a4b0c15)
2017-04-21 14:05:18 +08:00
7430771ec3 MdeModulePkg/Mtftp4Dxe: Add invalid ServerIp check during MTFTP configuration
Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com>
Reviewed-by: Ye Ting <ting.ye@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
(cherry picked from commit 17b25f5203)
2017-04-21 14:05:11 +08:00
ca740d75d6 NetworkPkg/TlsAuthConfigDxe: Close and free the file related resource
v2:
* Define one new internal function to clean the file content.

TlsAuthConfigDxe open file by FileExplorerLib. It need to close
file handler and free file related resource in some cases.
* User enrolls Cert by escape the Config page.
* The Cert is not X509 type.
* User chooses another file after he selected a file.

Cc: Zhang Chao B <chao.b.zhang@intel.com>
Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com>
Reviewed-by: Chao Zhang<chao.b.zhang@intel.com>
(cherry picked from commit 8ca4176883)
2017-04-21 14:05:04 +08:00
d1ffb4e436 NetworkPkg: Correct the proxy DHCP offer handing
When PXE10/WFM11a offer received, we should only cache
the first PXE10/WFM11a offer, and discard the others. But
Current we discard all PXE10/WFM11a offer. This patch is
to fix this issue.

Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Cc: Zhang Lubo <lubo.zhang@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com>
Reviewed-by: Ye Ting <ting.ye@intel.com>
(cherry picked from commit 8cdd559be6)
2017-04-21 14:04:57 +08:00
e51b591e2d NetworkPkg/HttpDxe: Fix HTTP download OS image over 4G size failure
UINT32 integer overflow will happen once the download OS image over
4G size. This patch is to fix this issue.

Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Cc: Zhang Lubo <lubo.zhang@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Ye Ting <ting.ye@intel.com>
Reviewed-by: Sriram Subramanian <sriram-s@hpe.com>
(cherry picked from commit 6893b16fb9)
2017-04-21 14:04:50 +08:00
6d644dd0d0 MdeModulePkg/FirmwarePerformanceDxe: Error Level is not used correctly
Cc: Feng Tian <feng.tian@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan <jeff.fan@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit d3d562b904)
2017-04-21 10:48:30 +08:00
250c5b2aaa MdeModulePkg/UefiBootManagerLib: Avoid buggy USB short-form expanding
When a load option points to a physical UsbIo controller, whose
device path contains UsbClass or UsbWwid node, old logic
unconditionally treats it as a short-form device path and expands
it. But the expanding gets the exactly same device path, and the
device path is passed to BmGetNextLoadOptionDevicePath() which
then passes this device path to BmExpandUsbDevicePath() again.
This causes a infinite recursion.

The patch avoids the USB short-form expanding when the device path
points to a physical UsbIo controller.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Feng Tian <feng.tian@intel.com>
Reviewed-by: Jeff Fan <jeff.fan@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Michael Turner <Michael.Turner@microsoft.com>
(cherry picked from commit 21e359dcca)
2017-04-20 16:33:52 +08:00
c0b1ed569f NetworkPkg: Fix bug related DAD issue in IP6 driver.
If we set PXEv6 as the first boot option and reboot immediately
after the first successful boot, it will assert. the root cause is
when we set the policy from manual to automatic in PXE driver,
the ip6 Configure item size is already set to zero and other
structures are also released, So it is not needed to perform DAD call
back function which is invoked by Ip6ConfigSetMaunualAddress.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo <lubo.zhang@intel.com>
Cc: Wu Jiaxin <jiaxin.wu@intel.com>
Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>
(cherry picked from commit 52cad7d0d8)
2017-04-20 15:55:04 +08:00
d7c94fca2f NetworkPkg: Add check logic for iSCSI driver.
Need to check variable of mPrivate whether is
null before used and redefine the array length
of target address for keyword.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo <lubo.zhang@intel.com>
Cc: Wu Jiaxin <jiaxin.wu@intel.com>
Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>
Reviewed-by: Ye Ting <ting.ye@intel.com>
(cherry picked from commit b28bf4143d)
2017-04-20 15:54:57 +08:00
b4221a2e9e MdeModulePkg PiSmmCore: Enhance SMM FreePool to catch buffer overflow
This solution is equivalent to DXE core.

AllocatePool() allocates POOL_TAIL after the buffer.
This POOL_TAIL is checked at FreePool().
If the there is buffer overflow, the issue can be caught at FreePool().

This patch could also handle the eight-byte aligned allocation
requirement. The discussion related to the eight-byte aligned
allocation requirement is at
https://lists.01.org/pipermail/edk2-devel/2017-April/009995.html.

According to the PI spec (Vol 4, Section 3.2 SmmAllocatePool()):
The SmmAllocatePool() function ... All allocations are eight-byte aligned.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Hao Wu <hao.a.wu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Hao Wu <hao.a.wu@intel.com>
(cherry picked from commit 861c8dff2f)
2017-04-20 14:13:53 +08:00
ce0f811c28 MdeModulePkg/Ufs: Wait fDeviceInit be cleared by devices during init
In the origin codes, the host sets the fDeviceInit flag to initiate device
initialization, but does not check whether the device resets this flag
to indicate the device initialization is completed.

Details can be referred at UFS 2.0 Spec Section 14.2 - Flags.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Mateusz Albecki <mateusz.albecki@intel.com>
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Feng Tian <feng.tian@intel.com>
(cherry picked from commit 95ad8f7f6a)
2017-04-20 13:11:49 +08:00
c29973b789 MdeModulePkg/UfsPassThruDxe: Replace 'EFI_D_XXX' with 'DEBUG_XXX'
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Feng Tian <feng.tian@intel.com>
(cherry picked from commit edd94e74c8)
2017-04-20 13:11:48 +08:00
0a69072ca0 ShellPkg/pci: Fix VS2012 build failure
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
Cc: Dandan Bi <dandan.bi@intel.com>
(cherry picked from commit f1894fa294)
2017-04-20 11:19:19 +08:00
66cbba1044 ShellPkg/comp: Fix file tag name.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Chen A Chen <chen.a.chen@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
(cherry picked from commit a32c1a5b1c)
2017-04-20 11:19:19 +08:00
5359955ddb MdeModulePkg/TerminalDxe: Avoid always append device path to *Dev
When TerminalDxe Start() is called multiple times, the old logic
unconditionally appended the terminal device path candidates to
*Dev (ConInDev/ConOutDev/ErrOutDev), resulting the volatile storage
is full.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit b9c04b88a1)
2017-04-20 10:25:21 +08:00
f76eb7c132 MdeModulePkg DxeCore: Fix issue to print GUID value %g without pointer
https://bugzilla.tianocore.org/show_bug.cgi?id=474

Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
(cherry picked from commit e061798895)
2017-04-19 14:19:24 +08:00
d012503729 UefiCpuPkg/PiSmmCpuDxeSmm: Lock should be acquired
SMM BSP's *busy* state should be acquired. We could use AcquireSpinLock()
instead of AcquireSpinLockOrFail().

Cc: Hao Wu <hao.a.wu@intel.com>
Cc: Feng Tian <feng.tian@intel.com>
Cc: Michael Kinney <michael.d.kinney@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan <jeff.fan@intel.com>
Reviewed-by: Hao Wu <hao.a.wu@intel.com>
(cherry picked from commit 170a3c1e0f)
2017-04-19 11:20:12 +08:00
ffb4af3b5a ShellPkg/Pci: Always dump the extended config space for PCIE
It is to align to the original behavior before "-ec" option was
added.

The patch also refines the code to make it more readable.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
Cc: Jim Dailey <Jim.Dailey@dell.com>
(cherry picked from commit 33cc487c26)
2017-04-19 10:55:36 +08:00
4a75bfb5a0 MdeModulePkg/HiiDB: Avoid incorrect results of multiplication
An example:
The codes in function Output8bitPixel in Image.c:
OffsetY = BITMAP_LEN_8_BIT ((UINT32) Image->Width, Ypos);

Both Image->Width and Ypos are of type UINT16. They will be promoted to
int (signed) first, and then perform the multiplication defined by macro
BITMAP_LEN_8_BIT. If the result of multiplication between Image->Width and
Ypos exceeds the range of type int, a potential incorrect results
will be assigned to OffsetY.

This commit adds explicit UINT32 type cast for 'Image->Width' to avoid
possible overflow in the int range. And also fix similar issues in
HiiDatabase.

Cc: Eric Dong <eric.dong@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Hao Wu <hao.a.wu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
Reviewed-by: Hao Wu <hao.a.wu@intel.com>
(cherry picked from commit f76bc44362)
2017-04-18 15:58:18 +08:00
757decbd53 MdeModulePkg/BMMUiLib: Update codes of initializing ConsoleXXXCheck array
When initializing ConsoleOutCheck/ConsoleInCheck/ConsoleErrCheck array in
BMM_FAKE_NV_DATA structure, also need to consider whether the terminal
device is ConOut/ConIn/ConErr or not.

Cc: Eric Dong <eric.dong@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
(cherry picked from commit d508fe87fe)
2017-04-18 15:58:18 +08:00
870f872bad UefiCpuPkg/MtrrLib: Avoid running unnecessary code
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
(cherry picked from commit c9b4492133)
2017-04-18 10:49:43 +08:00
d999d6c8e4 BaseTools: Update the Conf directory to use the absolute path
Update the Conf directory to use the absolute path for build_rule.txt
and tools_def.txt.

Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
2017-04-18 10:44:15 +08:00
cbdde352d1 ShellPkg/ConsistMapping: Remove unneeded memory reallocation
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Michael Turner <Michael.Turner@microsoft.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
(cherry picked from commit 17c3dc1939)
2017-04-18 10:26:25 +08:00
6efcd38566 MdeModulePkg/BootManagerMenu: Add assertion to indicate no DIV by 0
BootMenuSelectItem() contains code to DIV BootMenuData->ItemCount.
When BootMenuData->ItemCount can be 0, the DIV operation may
trigger CPU exception.
But in logic, this case won't happen. So add assertion to indicate
it.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
(cherry picked from commit 51a1db9b24)
2017-04-17 16:04:47 +08:00
03b4f340d7 CryptoPkg: Correct some minor issues in function comments
Correct some minor comment issues in BaseCryptLib.h and
CryptPkcs7Verify.c, including:
  - missed "out" in parameter property for ARC4 interfaces;
  - Wrong Comment tail in Pkcs7GetAttachedContent function

Cc: Ting Ye <ting.ye@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Qin Long <qin.long@intel.com>
Reviewed-by: Ye Ting <ting.ye@intel.com>
(cherry picked from commit 0c9fc4b167)
2017-04-14 16:45:51 +08:00
6e5dc5541b MdeModulePkg CapsuleApp: Add directory support
Current CapsuleApp only supports input/output file from rootdirectory.
If the CapsuleApp and related file are put into subdirectory,
below message will be shown when running the CapsuleApp in shell.

"CapsuleApp: capsule image (Capsule image file name) is not found."

This patch is to add directory support for CapsuleApp
by using shell protocol.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Feng Tian <feng.tian@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
(cherry picked from commit 8b17683a27)
2017-04-14 13:49:44 +08:00
53ae831443 IntelFrameworkPkg/UefiLib: Avoid mis-calculate of graphic console size
The commit adds check in function InternalPrintGraphic() to ensure that
the expression:

Blt->Width * Blt->Height * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)

will not overflow in the UINTN range.

The commit also adds an explicit UINT32 type cast for 'Blt->Width' to
avoid possible overflow in the int range for:

Blt->Width * Blt->Height

Since both Blt->Width and Blt->Height are of type UINT16. They will be
promoted to int (signed) first, and then perform the multiplication
operation. If the result of multiplication between Blt->Width and
Blt->Height exceeds the range of type int, a potential incorrect size will
be passed into function AllocateZeroPool().

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit 9c0e4db3db)
2017-04-14 13:25:01 +08:00
591c1bed31 MdePkg/UefiLib: Avoid mis-calculate of graphic console size
The commit adds check in function InternalPrintGraphic() to ensure that
the expression:

Blt->Width * Blt->Height * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)

will not overflow in the UINTN range.

The commit also adds an explicit UINT32 type cast for 'Blt->Width' to
avoid possible overflow in the int range for:

Blt->Width * Blt->Height

Since both Blt->Width and Blt->Height are of type UINT16. They will be
promoted to int (signed) first, and then perform the multiplication
operation. If the result of multiplication between Blt->Width and
Blt->Height exceeds the range of type int, a potential incorrect size will
be passed into function AllocateZeroPool().

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit 458cd568b6)
2017-04-14 13:25:00 +08:00
abf1027b09 MdeModulePkg/DxeCore: Add ASSERT to ensure no subtract underflow
For function SplitRecord() in file PropertiesTable.c, there is a
potential subtract underflow case for line:

  return TotalNewRecordCount - 1;

However, such case will not happen since the logic in function
SplitTable() ensure that when calling SplitRecord(), the variable
'TotalNewRecordCount' will not be zero when performing the subtraction.
It will be handled in the previous if statement:

  if (MaxSplitRecordCount == 0) {
    CopyMem (NewRecord, OldRecord, DescriptorSize);
    return 0;
  }

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
(cherry picked from commit 1860cb00c1)
2017-04-14 13:25:00 +08:00
729b6b5164 MdeModulePkg/PiSmmCore: Fix potentially uninitialized local variable
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
(cherry picked from commit 89558f1653)
2017-04-14 13:25:00 +08:00
adeef88496 BaseTools/Bin: Update the BaseTools Win32 binaries version information
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
2017-04-14 10:55:39 +08:00
321ec73af7 MdeModulePkg BrotliLib: Fix the regression logic issue in loop
In V2, change logic to avoid use mtf[-1] style to get value.

Roll back to previous logic, and use point + offset to get byte value.

Cc: Bell Song <binx.song@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Bell Song <binx.song@intel.com>
(cherry picked from commit 2c8d2545f5)
2017-04-14 10:53:21 +08:00
fc3ce2f30c BaseTools: Add option in CLANG38 to disable warning unknown-warning-option
https://bugzilla.tianocore.org/show_bug.cgi?id=466

Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
(cherry picked from commit ab200776cd)
2017-04-13 13:26:35 +08:00
7dbcca8820 MdeModulePkg: Fix BrotliCustomDecompressLib potential issue
- Fix BrotliCustomDecompressLib potential issue

Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Bell Song <binx.song@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit 36a0d5cab8)
2017-04-13 13:25:43 +08:00
6aecbe2de8 BaseTools/ECC: Add a new checkpoint
Add a new checkpoint to check if the SMM communication parameter has
a correct buffer type.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hess Chen <hesheng.chen@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
2017-04-13 10:33:06 +08:00
e83897e90c BaseTools: Fix re-build issue after tools_def/build_rule updated.
Add tools_def.txt and build_rule.txt to workspace autogen timestamp file.
Now it will not skip autogen if this two file is updated.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Derek Lin <derek.lin2@hpe.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
2017-04-13 10:31:24 +08:00
4df1410641 BaseTools: Fix build fail after clean or cleanall target.
Remove module AutoGenTimeStamp file during clean or cleanall.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Derek Lin <derek.lin2@hpe.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
2017-04-13 10:30:44 +08:00
fca6831ae4 IntelFrameworkModulePkg/IdeBusDxe: Fix undefined behavior in signed left shift
In function AtapiReadCapacity(), the following expression:
IdeDev->BlkIo.Media->LastBlock = (Data.LastLba3 << 24) |
  (Data.LastLba2 << 16) |
  (Data.LastLba1 << 8) |
  Data.LastLba0;

(There is also a similar case in this function.)

will involve undefined behavior in signed left shift operations.

Since Data.LastLbaX is of type UINT8, and
IdeDev->BlkIo.Media->LastBlock is of type UINT64. Therefore,
Data.LastLbaX will be promoted to int (32 bits, signed) first,
and then perform the left shift operation.

According to the C11 spec, Section 6.5.7:
4 The result of E1 << E2 is E1 left-shifted E2 bit positions; vacated
  bits are filled with zeros. If E1 has an unsigned type, the value
  of the result is E1 * 2^E2 , reduced modulo one more than the
  maximum value representable in the result type. If E1 has a signed
  type and nonnegative value, and E1 * 2^E2 is representable in the
  result type, then that is the resulting value; otherwise, the
  behavior is undefined.

So if bit 7 of Data.LastLba3 is 1, (Data.LastLba3 << 24) will be out of
the range within int type. The undefined behavior of the signed left shift
will lead to a potential of setting the high 32 bits of
IdeDev->BlkIo.Media->LastBlock to 1 during the cast from type int to type
UINT64.

This commit will add an explicit UINT32 type cast for Data.LastLba3 to
resolve this issue.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Feng Tian <feng.tian@intel.com>
(cherry picked from commit f90c4fff00)
2017-04-13 09:10:50 +08:00
549a342e1e MdeModulePkg/UsbBotPei: Fix undefined behavior in signed left shift
In function PeiUsbReadCapacity(), the following expression:
LastBlock = (Data.LastLba3 << 24) |
  (Data.LastLba2 << 16) |
  (Data.LastLba1 << 8) |
  Data.LastLba0;

(There is also a similar case in function PeiUsbReadFormattedCapacity().)

will involve undefined behavior in signed left shift operations.

Since Data.LastLbaX is of type UINT8, they will be promoted to int (32
bits, signed) first, and then perform the left shift operation.

According to the C11 spec, Section 6.5.7:
4 The result of E1 << E2 is E1 left-shifted E2 bit positions; vacated
  bits are filled with zeros. If E1 has an unsigned type, the value
  of the result is E1 * 2^E2 , reduced modulo one more than the
  maximum value representable in the result type. If E1 has a signed
  type and nonnegative value, and E1 * 2^E2 is representable in the
  result type, then that is the resulting value; otherwise, the
  behavior is undefined.

So if bit 7 of Data.LastLba3 is 1, (Data.LastLba3 << 24) will be out of
the range within int type. The undefined behavior of the signed left shift
might incur potential issues.

This commit will add an explicit UINT32 type cast for Data.LastLba3 to
refine the codes.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Feng Tian <feng.tian@intel.com>
(cherry picked from commit a2617ed627)
2017-04-13 09:10:49 +08:00
602b573d61 MdeModulePkg/UfsBlkIoPei: Fix undefined behavior in signed left shift
In function UfsBlockIoPeimGetMediaInfo(), the following expression:
Private->Media[DeviceIndex].LastBlock  = (Capacity16.LastLba3 << 24) |
  (Capacity16.LastLba2 << 16) |
  (Capacity16.LastLba1 << 8) |
  Capacity16.LastLba0;

(There is also a similar case in this function.)

will involve undefined behavior in signed left shift operations.

Since Capacity16.LastLbaX is of type UINT8, and
Private->Media[DeviceIndex].LastBlock is of type UINT64. Therefore,
Capacity16.LastLbaX will be promoted to int (32 bits, signed) first, and
then perform the left shift operation.

According to the C11 spec, Section 6.5.7:
4 The result of E1 << E2 is E1 left-shifted E2 bit positions; vacated
  bits are filled with zeros. If E1 has an unsigned type, the value
  of the result is E1 * 2^E2 , reduced modulo one more than the
  maximum value representable in the result type. If E1 has a signed
  type and nonnegative value, and E1 * 2^E2 is representable in the
  result type, then that is the resulting value; otherwise, the
  behavior is undefined.

So if bit 7 of Capacity16.LastLba3 is 1, (Capacity16.LastLba3 << 24) will
be out of the range within int type. The undefined behavior of the signed
left shift will lead to a potential of setting the high 32 bits of
Private->Media[DeviceIndex].LastBlock to 1 during the cast from type int
to type UINT64.

This commit will add an explicit UINT32 type cast for Capacity16.LastLba3
to resolve this issue.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Feng Tian <feng.tian@intel.com>
(cherry picked from commit da117dda23)
2017-04-13 09:10:48 +08:00
bfbcd7e4b2 MdeModulePkg/IdeBusPei: Fix undefined behavior in signed left shift
In function ReadCapacity(), the following expression:
MediaInfo->LastBlock = (Data.LastLba3 << 24) |
  (Data.LastLba2 << 16) |
  (Data.LastLba1 << 8) |
  Data.LastLba0;

(There is also a similar case in this function.)

will involve undefined behavior in signed left shift operations.

Since Data.LastLbaX is of type UINT8, and MediaInfo->LastBlock is of type
UINTN. Therefore, Data.LastLbaX will be promoted to int (32 bits, signed)
first, and then perform the left shift operation.

According to the C11 spec, Section 6.5.7:
4 The result of E1 << E2 is E1 left-shifted E2 bit positions; vacated
  bits are filled with zeros. If E1 has an unsigned type, the value
  of the result is E1 * 2^E2 , reduced modulo one more than the
  maximum value representable in the result type. If E1 has a signed
  type and nonnegative value, and E1 * 2^E2 is representable in the
  result type, then that is the resulting value; otherwise, the
  behavior is undefined.

So if bit 7 of Data.LastLba3 is 1, (Data.LastLba3 << 24) will be out of
the range within int type. The undefined behavior of the signed left shift
will lead to a potential of setting the high 32 bits of
MediaInfo->LastBlock to 1 during the cast from type int to type UINT64
for X64 builds.

This commit will add an explicit UINT32 type cast for Data.LastLba3 to
resolve this issue.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Feng Tian <feng.tian@intel.com>
(cherry picked from commit 3778a4dfcd)
2017-04-13 09:10:48 +08:00
1e2d930951 MdeModulePkg/ScsiDiskDxe: Fix undefined behavior in signed left shift
In function GetMediaInfo(), the following expression:
ScsiDiskDevice->BlkIo.Media->LastBlock =  (Capacity10->LastLba3 << 24) |
                                          (Capacity10->LastLba2 << 16) |
                                          (Capacity10->LastLba1 << 8)  |
                                           Capacity10->LastLba0;
will involve undefined behavior in signed left shift operations.

Since Capacity10->LastLbaX is of type UINT8, and
ScsiDiskDevice->BlkIo.Media->LastBlock is of type UINT64. Therefore,
Capacity10->LastLbaX will be promoted to int (32 bits, signed) first,
and then perform the left shift operation.

According to the C11 spec, Section 6.5.7:
4 The result of E1 << E2 is E1 left-shifted E2 bit positions; vacated
  bits are filled with zeros. If E1 has an unsigned type, the value
  of the result is E1 * 2^E2 , reduced modulo one more than the
  maximum value representable in the result type. If E1 has a signed
  type and nonnegative value, and E1 * 2^E2 is representable in the
  result type, then that is the resulting value; otherwise, the
  behavior is undefined.

So if bit 7 of Capacity10->LastLba3 is 1, (Capacity10->LastLba3 << 24)
will be out of the range within int type. The undefined behavior of the
signed left shift will lead to a potential of setting the high 32 bits
of ScsiDiskDevice->BlkIo.Media->LastBlock to 1 during the cast from type
int to type UINT64.

This commit will add an explicit UINT32 type cast for
Capacity10->LastLba3 to resolve this issue.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Feng Tian <feng.tian@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
(cherry picked from commit 7c115e775b)
2017-04-13 09:10:48 +08:00
df082f757a MdeModulePkg/Dxe/Image: Restore mCurrentImage on all paths
This commit makes sure that in function CoreStartImage(), module
variable 'mCurrentImage' is restored to the current start image context
on all code paths.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
(cherry picked from commit 7a14d54f6c)
2017-04-13 09:10:47 +08:00
0b75171b76 SecurityPkg/SecurityPkg.dec: Update PcdPkcs7CertBuffer PCD.
This patch updates the PcdPkcs7CertBuffer PCD to use the new
generated test certificate data for PKCS7 verification. This
was used as sample trusted certificate in the verification of
Signed Capsule Update.
(The updated value is still only for test purpose.)

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Chao Zhang <chao.b.zhang@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Long Qin <qin.long@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Chao Zhang <chao.b.zhang@intel.com>
(cherry picked from commit d3e0c996d5)
2017-04-12 13:42:00 +08:00
0ffecbead1 BaseTools/Pkcs7Sign: Update the test certificates & Readme.md
The old TestRoot certificate used for Pkcs7Sign is not compliant to
Root CA certificate requirement with incorrect basic constraints and
key usage setting.
When OpenSSL in CryptoPkg was updated from 1.0.2xx to the latest
1.1.0xx, the CA certificate checking was enforced for more extension
validations, which will raise the verification failure when stilling
using the old sample certificates.

This patch re-generated one set of test certificates used in
Pkcs7Sign demo, and updated the corresponding Readme.md to describe
how to set the options in openssl configuration file.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Long Qin <qin.long@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
(cherry picked from commit f536d7c3ed)
2017-04-12 13:41:27 +08:00
ca41ee781d BaseTools/ECC: Change check rule for Ifndef statement
Remove the check of Ifndef statement on .c files, only check on .h
files.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hess Chen <hesheng.chen@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
2017-04-12 09:39:59 +08:00
c69a51ce65 UefiCpuPkg: Error Level is not used correctly
Cc: Feng Tian <feng.tian@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan <jeff.fan@intel.com>
Reviewed-by: Feng Tian <feng.tian@intel.com>
2017-04-12 09:00:37 +08:00
ae480c61f4 SecurityPkg: Error Level is not used correctly
Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan <jeff.fan@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
2017-04-12 09:00:32 +08:00
cbfd09a014 MdeModulePkg: Error Level is not used correctly
Cc: Feng Tian <feng.tian@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan <jeff.fan@intel.com>
Reviewed-by: Feng Tian <feng.tian@intel.com>
2017-04-12 09:00:29 +08:00
6770 changed files with 447088 additions and 397010 deletions

3
.gitmodules vendored
View File

@ -1,3 +0,0 @@
[submodule "CryptoPkg/Library/OpensslLib/openssl"]
path = CryptoPkg/Library/OpensslLib/openssl
url = https://github.com/openssl/openssl

View File

@ -7,7 +7,7 @@
# for important information about configuring this package for your
# environment.
#
# Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
@ -40,6 +40,8 @@
gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|$(DEBUG_PROPERTY_MASK)
gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|$(DEBUG_PRINT_ERROR_LEVEL)
[PcdsFixedAtBuild.IPF]
[LibraryClasses]
#
# Entry Point Libraries

View File

@ -9,7 +9,7 @@
# NOTE: Improvements gratefully received. Please mention the version.
# "http://www.cwi.nl/~steven/enquire.html"
#
# Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
@ -29,7 +29,7 @@
ENTRY_POINT = ShellCEntryLib
#
# VALID_ARCHITECTURES = IA32 X64
# VALID_ARCHITECTURES = IA32 X64 IPF
#
[Sources]

View File

@ -1,7 +1,7 @@
## @file
# A simple, basic, EDK II native, "hello" application.
#
# Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
@ -21,7 +21,7 @@
ENTRY_POINT = ShellCEntryLib
#
# VALID_ARCHITECTURES = IA32 X64
# VALID_ARCHITECTURES = IA32 X64 IPF
#
[Sources]

View File

@ -3,7 +3,7 @@
# from the standard input, and writing results to the standard output.
#
# Copyright (C) 2014, Red Hat, Inc.
# Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
#
# This program and the accompanying materials are licensed and made available
# under the terms and conditions of the BSD License which accompanies this
@ -24,7 +24,7 @@
ENTRY_POINT = ShellCEntryLib
#
# VALID_ARCHITECTURES = IA32 X64
# VALID_ARCHITECTURES = IA32 X64 IPF
#
[Sources]

File diff suppressed because it is too large Load Diff

View File

@ -1289,7 +1289,7 @@ The file must be an open file object such as sys.stdout or returned by\n\
open() or os.popen(). It must be opened in binary mode ('wb' or 'w+b').\n\
\n\
If the value has (or contains an object that has) an unsupported type, a\n\
ValueError exception is raised - but garbage data will also be written\n\
ValueError exception is raised but garbage data will also be written\n\
to the file. The object will not be properly read back by load()\n\
\n\
New in version 2.4: The version argument indicates the data format that\n\
@ -1317,7 +1317,7 @@ PyDoc_STRVAR(load_doc,
"load(file)\n\
\n\
Read one value from the open file and return it. If no valid value is\n\
read (e.g. because the data has a different Python version's\n\
read (e.g. because the data has a different Python versions\n\
incompatible marshal format), raise EOFError, ValueError or TypeError.\n\
The file must be an open file object opened in binary mode ('rb' or\n\
'r+b').\n\

View File

@ -2,7 +2,7 @@
# PythonCore.inf
#
# Copyright (c) 2015, Daryl McDaniel. All rights reserved.<BR>
# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2011-2012, Intel Corporation. All rights reserved.<BR>
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
@ -24,7 +24,7 @@
DEFINE PYTHON_VERSION = 2.7.2
#
# VALID_ARCHITECTURES = IA32 X64
# VALID_ARCHITECTURES = IA32 X64 IPF
#
[Packages]
@ -252,3 +252,4 @@
MSFT:*_*_X64_CC_FLAGS = /Oi- /wd4018 /wd4054 /wd4055 /wd4101 /wd4131 /wd4152 /wd4204 /wd4210 /wd4244 /wd4267 /wd4305 /wd4310 /wd4389 /wd4701 /wd4702 /wd4706 /I$(WORKSPACE)\AppPkg\Applications\Python\X64 /I$(WORKSPACE)\AppPkg\Applications\Python\Efi /I$(WORKSPACE)\AppPkg\Applications\Python\Python-$(PYTHON_VERSION)\Include /DHAVE_MEMMOVE /DUSE_PYEXPAT_CAPI /DXML_STATIC
GCC:*_*_IA32_CC_FLAGS = -fno-builtin -Wno-format -I$(WORKSPACE)/AppPkg/Applications/Python/Ia32 -I$(WORKSPACE)/AppPkg/Applications/Python/Python-$(PYTHON_VERSION)/Include -DHAVE_MEMMOVE -DUSE_PYEXPAT_CAPI -DXML_STATIC
GCC:*_*_X64_CC_FLAGS = -Wno-format -I$(WORKSPACE)/AppPkg/Applications/Python/X64 -I$(WORKSPACE)/AppPkg/Applications/Python/Python-$(PYTHON_VERSION)/Include -DHAVE_MEMMOVE -DUSE_PYEXPAT_CAPI -DXML_STATIC
GCC:*_*_IPF_SYMRENAME_FLAGS = --redefine-syms=$(WORKSPACE)/StdLib/GccSymRename.txt

View File

@ -1,7 +1,7 @@
## @file
# DataSink Application
#
# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2011-2012, Intel Corporation
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
@ -24,7 +24,7 @@
#
# The following information is for reference only and not required by the build tools.
#
# VALID_ARCHITECTURES = IA32 X64 EBC
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
#
[Sources]

View File

@ -1,7 +1,7 @@
## @file
# DataSource Application
#
# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2011-2012, Intel Corporation
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
@ -24,7 +24,7 @@
#
# The following information is for reference only and not required by the build tools.
#
# VALID_ARCHITECTURES = IA32 X64 EBC
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
#
[Sources]

View File

@ -1,7 +1,7 @@
## @file
# GetAddrInfo Application
#
# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2011-2012, Intel Corporation
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
@ -24,7 +24,7 @@
#
# The following information is for reference only and not required by the build tools.
#
# VALID_ARCHITECTURES = IA32 X64 EBC
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
#
[Sources]

View File

@ -1,7 +1,7 @@
## @file
# GetHostByAddr Application
#
# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2011-2012, Intel Corporation
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
@ -24,7 +24,7 @@
#
# The following information is for reference only and not required by the build tools.
#
# VALID_ARCHITECTURES = IA32 X64 EBC
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
#
[Sources]

View File

@ -1,7 +1,7 @@
## @file
# GetHostByDns Application
#
# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2011-2012, Intel Corporation
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
@ -24,7 +24,7 @@
#
# The following information is for reference only and not required by the build tools.
#
# VALID_ARCHITECTURES = IA32 X64 EBC
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
#
[Sources]

View File

@ -1,7 +1,7 @@
## @file
# GetHostByName Application
#
# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2011-2012, Intel Corporation
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
@ -24,7 +24,7 @@
#
# The following information is for reference only and not required by the build tools.
#
# VALID_ARCHITECTURES = IA32 X64 EBC
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
#
[Sources]

View File

@ -1,7 +1,7 @@
## @file
# GetNameInfo Application
#
# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2011-2012, Intel Corporation
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
@ -24,7 +24,7 @@
#
# The following information is for reference only and not required by the build tools.
#
# VALID_ARCHITECTURES = IA32 X64 EBC
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
#
[Sources]

View File

@ -1,7 +1,7 @@
## @file
# GetNetByAddr Application
#
# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2011-2012, Intel Corporation
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
@ -24,7 +24,7 @@
#
# The following information is for reference only and not required by the build tools.
#
# VALID_ARCHITECTURES = IA32 X64 EBC
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
#
[Sources]

View File

@ -1,7 +1,7 @@
## @file
# GetNetByName Application
#
# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2011-2012, Intel Corporation
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
@ -24,7 +24,7 @@
#
# The following information is for reference only and not required by the build tools.
#
# VALID_ARCHITECTURES = IA32 X64 EBC
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
#
[Sources]

View File

@ -1,7 +1,7 @@
## @file
# GetServByName Application
#
# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2011-2012, Intel Corporation
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
@ -24,7 +24,7 @@
#
# The following information is for reference only and not required by the build tools.
#
# VALID_ARCHITECTURES = IA32 X64 EBC
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
#
[Sources]

View File

@ -1,7 +1,7 @@
## @file
# GetServByPort Application
#
# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2011-2012, Intel Corporation
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
@ -24,7 +24,7 @@
#
# The following information is for reference only and not required by the build tools.
#
# VALID_ARCHITECTURES = IA32 X64 EBC
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
#
[Sources]

View File

@ -1,7 +1,7 @@
## @file
# OobRx Application
#
# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2011-2012, Intel Corporation
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
@ -24,7 +24,7 @@
#
# The following information is for reference only and not required by the build tools.
#
# VALID_ARCHITECTURES = IA32 X64 EBC
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
#
[Sources]

View File

@ -1,7 +1,7 @@
## @file
# OobTx Application
#
# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2011-2012, Intel Corporation
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
@ -24,7 +24,7 @@
#
# The following information is for reference only and not required by the build tools.
#
# VALID_ARCHITECTURES = IA32 X64 EBC
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
#
[Sources]

View File

@ -1,7 +1,7 @@
## @file
# RawIp4 Application
#
# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2011-2012, Intel Corporation
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
@ -24,7 +24,7 @@
#
# The following information is for reference only and not required by the build tools.
#
# VALID_ARCHITECTURES = IA32 X64 EBC
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
#
[Sources]

View File

@ -1,7 +1,7 @@
## @file
# RawIp4Tx Application
#
# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2011-2012, Intel Corporation
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
@ -24,7 +24,7 @@
#
# The following information is for reference only and not required by the build tools.
#
# VALID_ARCHITECTURES = IA32 X64 EBC
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
#
[Sources]

View File

@ -1,7 +1,7 @@
## @file
# Receive Datagram Application
#
# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2011-2012, Intel Corporation
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
@ -24,7 +24,7 @@
#
# The following information is for reference only and not required by the build tools.
#
# VALID_ARCHITECTURES = IA32 X64 EBC
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
#
[Sources]

View File

@ -1,7 +1,7 @@
## @file
# SetHostName Application
#
# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2011-2012, Intel Corporation
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
@ -24,7 +24,7 @@
#
# The following information is for reference only and not required by the build tools.
#
# VALID_ARCHITECTURES = IA32 X64 EBC
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
#
[Sources]

View File

@ -1,7 +1,7 @@
## @file
# SetHostName Application
#
# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2011-2012, Intel Corporation
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
@ -24,7 +24,7 @@
#
# The following information is for reference only and not required by the build tools.
#
# VALID_ARCHITECTURES = IA32 X64 EBC
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
#
[Sources]

View File

@ -1,7 +1,7 @@
## @file
# TFTP Server Application
#
# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2011-2012, Intel Corporation
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
@ -24,7 +24,7 @@
#
# The following information is for reference only and not required by the build tools.
#
# VALID_ARCHITECTURES = IA32 X64 EBC
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
#
[Sources]

View File

@ -146,12 +146,12 @@ MemoryTypeRegistersPage (
{
UINT64 Addr;
BOOLEAN bValid;
MSR_IA32_MTRRCAP_REGISTER Capabilities;
UINT64 Capabilities;
UINTN Count;
MSR_IA32_MTRR_DEF_TYPE_REGISTER DefType;
UINT64 DefType;
UINTN Index;
UINT64 Mask;
UINT64 MaxMtrrs;
CONST UINT64 mFixedAddresses [( 8 * MTRR_NUMBER_OF_FIXED_MTRR ) + 1 ] = {
0ULL,
0x10000ULL,
@ -302,8 +302,8 @@ MemoryTypeRegistersPage (
//
// Get the capabilities
//
Capabilities.Uint64 = AsmReadMsr64 ( MSR_IA32_MTRRCAP );
DefType.Uint64 = AsmReadMsr64 ( MSR_IA32_MTRR_DEF_TYPE );
Capabilities = AsmReadMsr64 ( MTRR_LIB_IA32_MTRR_CAP );
DefType = AsmReadMsr64 ( MTRR_LIB_IA32_MTRR_DEF_TYPE );
//
// Display the capabilities
@ -316,7 +316,7 @@ MemoryTypeRegistersPage (
}
Status = HttpSendHexValue ( SocketFD,
pPort,
Capabilities.Uint64 );
Capabilities );
if ( EFI_ERROR ( Status )) {
break;
}
@ -338,7 +338,7 @@ MemoryTypeRegistersPage (
}
Status = HttpSendHexValue ( SocketFD,
pPort,
DefType.Uint64);
DefType );
if ( EFI_ERROR ( Status )) {
break;
}
@ -350,7 +350,7 @@ MemoryTypeRegistersPage (
}
Status = HttpSendAnsiString ( SocketFD,
pPort,
( 0 != DefType.Bits.E )
( 0 != ( DefType & MTRR_LIB_CACHE_MTRR_ENABLED ))
? "Enabled"
: "Disabled" );
if ( EFI_ERROR ( Status )) {
@ -364,7 +364,7 @@ MemoryTypeRegistersPage (
}
Status = HttpSendAnsiString ( SocketFD,
pPort,
( 0 != DefType.Bits.FE )
( 0 != ( DefType & MTRR_LIB_CACHE_FIXED_MTRR_ENABLED ))
? "Enabled"
: "Disabled" );
if ( EFI_ERROR ( Status )) {
@ -376,7 +376,7 @@ MemoryTypeRegistersPage (
if ( EFI_ERROR ( Status )) {
break;
}
Type = DefType.Uint64 & 0xff;
Type = DefType & 0xff;
Status = HttpSendAnsiString ( SocketFD,
pPort,
( DIM ( mMemoryType ) > Type )
@ -395,7 +395,7 @@ MemoryTypeRegistersPage (
//
// Determine if MTRRs are enabled
//
if ( 0 == DefType.Bits.E ) {
if ( 0 == ( DefType & MTRR_LIB_CACHE_MTRR_ENABLED )) {
Status = HttpSendAnsiString ( SocketFD,
pPort,
"<p>All memory is uncached!</p>\r\n" );
@ -412,8 +412,8 @@ MemoryTypeRegistersPage (
//
// Determine if the fixed MTRRs are supported
//
if (( 0 != Capabilities.Bits.FIX )
&& ( 0 != DefType.Bits.FE)) {
if (( 0 != ( Capabilities & 0x100 ))
&& ( 0 != ( DefType & MTRR_LIB_CACHE_FIXED_MTRR_ENABLED ))) {
//
// Beginning of table
@ -615,7 +615,8 @@ MemoryTypeRegistersPage (
//
// Determine if the variable MTRRs are supported
//
if ( 0 < Capabilities.Bits.VCNT ) {
MaxMtrrs = Capabilities & MTRR_LIB_IA32_MTRR_CAP_VCNT_MASK;
if ( 0 < MaxMtrrs ) {
//
// Beginning of table
//
@ -631,7 +632,7 @@ MemoryTypeRegistersPage (
//
// Display the variable MTRRs
//
for ( Count = 0; Capabilities.Bits.VCNT > Count; Count++ ) {
for ( Count = 0; MaxMtrrs > Count; Count++ ) {
//
// Start the row
//

View File

@ -20,7 +20,6 @@
#include <Guid/EventGroup.h>
#include <Register/Msr.h>
#include <Library/BaseMemoryLib.h>
#include <Library/DebugLib.h>
#include <Library/MemoryAllocationLib.h>

View File

@ -1,7 +1,7 @@
## @file
# Web Server Application
#
# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2011-2012, Intel Corporation
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
@ -24,7 +24,7 @@
#
# The following information is for reference only and not required by the build tools.
#
# VALID_ARCHITECTURES = IA32 X64 EBC
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
#
[Sources]

218
AppPkg/Contributions.txt Normal file
View File

@ -0,0 +1,218 @@
======================
= Code Contributions =
======================
To make a contribution to a TianoCore project, follow these steps.
1. Create a change description in the format specified below to
use in the source control commit log.
2. Your commit message must include your "Signed-off-by" signature,
and "Contributed-under" message.
3. Your "Contributed-under" message explicitly states that the
contribution is made under the terms of the specified
contribution agreement. Your "Contributed-under" message
must include the name of contribution agreement and version.
For example: Contributed-under: TianoCore Contribution Agreement 1.0
The "TianoCore Contribution Agreement" is included below in
this document.
4. Submit your code to the TianoCore project using the process
that the project documents on its web page. If the process is
not documented, then submit the code on development email list
for the project.
5. It is preferred that contributions are submitted using the same
copyright license as the base project. When that is not possible,
then contributions using the following licenses can be accepted:
* BSD (2-clause): http://opensource.org/licenses/BSD-2-Clause
* BSD (3-clause): http://opensource.org/licenses/BSD-3-Clause
* MIT: http://opensource.org/licenses/MIT
* Python-2.0: http://opensource.org/licenses/Python-2.0
* Zlib: http://opensource.org/licenses/Zlib
Contributions of code put into the public domain can also be
accepted.
Contributions using other licenses might be accepted, but further
review will be required.
=====================================================
= Change Description / Commit Message / Patch Email =
=====================================================
Your change description should use the standard format for a
commit message, and must include your "Signed-off-by" signature
and the "Contributed-under" message.
== Sample Change Description / Commit Message =
=== Start of sample patch email message ===
From: Contributor Name <contributor@example.com>
Subject: [PATCH] CodeModule: Brief-single-line-summary
Full-commit-message
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Contributor Name <contributor@example.com>
---
An extra message for the patch email which will not be considered part
of the commit message can be added here.
Patch content inline or attached
=== End of sample patch email message ===
=== Notes for sample patch email ===
* The first line of commit message is taken from the email's subject
line following [PATCH]. The remaining portion of the commit message
is the email's content until the '---' line.
* git format-patch is one way to create this format
=== Definitions for sample patch email ===
* "CodeModule" is a short idenfier for the affected code. For
example MdePkg, or MdeModulePkg UsbBusDxe.
* "Brief-single-line-summary" is a short summary of the change.
* The entire first line should be less than ~70 characters.
* "Full-commit-message" a verbose multiple line comment describing
the change. Each line should be less than ~70 characters.
* "Contributed-under" explicitely states that the contribution is
made under the terms of the contribtion agreement. This
agreement is included below in this document.
* "Signed-off-by" is the contributor's signature identifying them
by their real/legal name and their email address.
========================================
= TianoCore Contribution Agreement 1.0 =
========================================
INTEL CORPORATION ("INTEL") MAKES AVAILABLE SOFTWARE, DOCUMENTATION,
INFORMATION AND/OR OTHER MATERIALS FOR USE IN THE TIANOCORE OPEN SOURCE
PROJECT (COLLECTIVELY "CONTENT"). USE OF THE CONTENT IS GOVERNED BY THE
TERMS AND CONDITIONS OF THIS AGREEMENT BETWEEN YOU AND INTEL AND/OR THE
TERMS AND CONDITIONS OF LICENSE AGREEMENTS OR NOTICES INDICATED OR
REFERENCED BELOW. BY USING THE CONTENT, YOU AGREE THAT YOUR USE OF THE
CONTENT IS GOVERNED BY THIS AGREEMENT AND/OR THE TERMS AND CONDITIONS
OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED
BELOW. IF YOU DO NOT AGREE TO THE TERMS AND CONDITIONS OF THIS
AGREEMENT AND THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE
AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW, THEN YOU MAY NOT
USE THE CONTENT.
Unless otherwise indicated, all Content made available on the TianoCore
site is provided to you under the terms and conditions of the BSD
License ("BSD"). A copy of the BSD License is available at
http://opensource.org/licenses/bsd-license.php
or when applicable, in the associated License.txt file.
Certain other content may be made available under other licenses as
indicated in or with such Content. (For example, in a License.txt file.)
You accept and agree to the following terms and conditions for Your
present and future Contributions submitted to TianoCore site. Except
for the license granted to Intel hereunder, You reserve all right,
title, and interest in and to Your Contributions.
== SECTION 1: Definitions ==
* "You" or "Contributor" shall mean the copyright owner or legal
entity authorized by the copyright owner that is making a
Contribution hereunder. All other entities that control, are
controlled by, or are under common control with that entity are
considered to be a single Contributor. For the purposes of this
definition, "control" means (i) the power, direct or indirect, to
cause the direction or management of such entity, whether by
contract or otherwise, or (ii) ownership of fifty percent (50%)
or more of the outstanding shares, or (iii) beneficial ownership
of such entity.
* "Contribution" shall mean any original work of authorship,
including any modifications or additions to an existing work,
that is intentionally submitted by You to the TinaoCore site for
inclusion in, or documentation of, any of the Content. For the
purposes of this definition, "submitted" means any form of
electronic, verbal, or written communication sent to the
TianoCore site or its representatives, including but not limited
to communication on electronic mailing lists, source code
control systems, and issue tracking systems that are managed by,
or on behalf of, the TianoCore site for the purpose of
discussing and improving the Content, but excluding
communication that is conspicuously marked or otherwise
designated in writing by You as "Not a Contribution."
== SECTION 2: License for Contributions ==
* Contributor hereby agrees that redistribution and use of the
Contribution in source and binary forms, with or without
modification, are permitted provided that the following
conditions are met:
** Redistributions of source code must retain the Contributor's
copyright notice, this list of conditions and the following
disclaimer.
** Redistributions in binary form must reproduce the Contributor's
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Disclaimer. None of the names of Contributor, Intel, or the names
of their respective contributors may be used to endorse or
promote products derived from this software without specific
prior written permission.
* Contributor grants a license (with the right to sublicense) under
claims of Contributor's patents that Contributor can license that
are infringed by the Contribution (as delivered by Contributor) to
make, use, distribute, sell, offer for sale, and import the
Contribution and derivative works thereof solely to the minimum
extent necessary for licensee to exercise the granted copyright
license; this patent license applies solely to those portions of
the Contribution that are unmodified. No hardware per se is
licensed.
* EXCEPT AS EXPRESSLY SET FORTH IN SECTION 3 BELOW, THE
CONTRIBUTION IS PROVIDED BY THE CONTRIBUTOR "AS IS" AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
CONTRIBUTOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE
CONTRIBUTION, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
DAMAGE.
== SECTION 3: Representations ==
* You represent that You are legally entitled to grant the above
license. If your employer(s) has rights to intellectual property
that You create that includes Your Contributions, You represent
that You have received permission to make Contributions on behalf
of that employer, that Your employer has waived such rights for
Your Contributions.
* You represent that each of Your Contributions is Your original
creation (see Section 4 for submissions on behalf of others).
You represent that Your Contribution submissions include complete
details of any third-party license or other restriction
(including, but not limited to, related patents and trademarks)
of which You are personally aware and which are associated with
any part of Your Contributions.
== SECTION 4: Third Party Contributions ==
* Should You wish to submit work that is not Your original creation,
You may submit it to TianoCore site separately from any
Contribution, identifying the complete details of its source
and of any license or other restriction (including, but not
limited to, related patents, trademarks, and license agreements)
of which You are personally aware, and conspicuously marking the
work as "Submitted on behalf of a third-party: [named here]".
== SECTION 5: Miscellaneous ==
* Applicable Laws. Any claims arising under or relating to this
Agreement shall be governed by the internal substantive laws of
the State of Delaware or federal courts located in Delaware,
without regard to principles of conflict of laws.
* Language. This Agreement is in the English language only, which
language shall be controlling in all respects, and all versions
of this Agreement in any other language shall be for accommodation
only and shall not be binding. All communications and notices made
or given pursuant to this Agreement, and all documentation and
support to be provided, unless otherwise noted, shall be in the
English language.

25
AppPkg/License.txt Normal file
View File

@ -0,0 +1,25 @@
Copyright (c) 2012, Intel Corporation. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.

View File

@ -2,7 +2,7 @@
# ARM processor package.
#
# Copyright (c) 2009 - 2010, Apple Inc. All rights reserved.<BR>
# Copyright (c) 2011 - 2018, ARM Limited. All rights reserved.
# Copyright (c) 2011 - 2017, ARM Limited. All rights reserved.
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
@ -36,13 +36,10 @@
ArmLib|Include/Library/ArmLib.h
ArmMmuLib|Include/Library/ArmMmuLib.h
SemihostLib|Include/Library/Semihosting.h
UncachedMemoryAllocationLib|Include/Library/UncachedMemoryAllocationLib.h
DefaultExceptionHandlerLib|Include/Library/DefaultExceptionHandlerLib.h
ArmDisassemblerLib|Include/Library/ArmDisassemblerLib.h
ArmGicArchLib|Include/Library/ArmGicArchLib.h
ArmMtlLib|ArmPlatformPkg/Include/Library/ArmMtlLib.h
ArmSvcLib|Include/Library/ArmSvcLib.h
OpteeLib|Include/Library/OpteeLib.h
StandaloneMmMmuLib|Include/Library/StandaloneMmMmuLib.h
[Guids.common]
gArmTokenSpaceGuid = { 0xBB11ECFE, 0x820F, 0x4968, { 0xBB, 0xA6, 0xF7, 0x6A, 0xFE, 0x30, 0x25, 0x96 } }
@ -51,20 +48,6 @@
# Include/Guid/ArmMpCoreInfo.h
gArmMpCoreInfoGuid = { 0xa4ee0728, 0xe5d7, 0x4ac5, {0xb2, 0x1e, 0x65, 0x8e, 0xd8, 0x57, 0xe8, 0x34} }
[Protocols.common]
## Arm System Control and Management Interface(SCMI) Base protocol
## ArmPkg/Include/Protocol/ArmScmiBaseProtocol.h
gArmScmiBaseProtocolGuid = { 0xd7e5abe9, 0x33ab, 0x418e, { 0x9f, 0x91, 0x72, 0xda, 0xe2, 0xba, 0x8e, 0x2f } }
## Arm System Control and Management Interface(SCMI) Clock management protocol
## ArmPkg/Include/Protocol/ArmScmiClockProtocol.h
gArmScmiClockProtocolGuid = { 0x91ce67a8, 0xe0aa, 0x4012, { 0xb9, 0x9f, 0xb6, 0xfc, 0xf3, 0x4, 0x8e, 0xaa } }
gArmScmiClock2ProtocolGuid = { 0xb8d8caf2, 0x9e94, 0x462c, { 0xa8, 0x34, 0x6c, 0x99, 0xfc, 0x05, 0xef, 0xcf } }
## Arm System Control and Management Interface(SCMI) Clock management protocol
## ArmPkg/Include/Protocol/ArmScmiPerformanceProtocol.h
gArmScmiPerformanceProtocolGuid = { 0x9b8ba84, 0x3dd3, 0x49a6, { 0xa0, 0x5a, 0x31, 0x34, 0xa5, 0xf0, 0x7b, 0xad } }
[Ppis]
## Include/Ppi/ArmMpCoreInfo.h
gArmMpCoreInfoPpiGuid = { 0x6847cc74, 0xe9ec, 0x4f8f, {0xa2, 0x9d, 0xab, 0x44, 0xe7, 0x54, 0xa8, 0xfc} }
@ -81,13 +64,13 @@
# it has been configured by the CPU DXE
gArmTokenSpaceGuid.PcdDebuggerExceptionSupport|FALSE|BOOLEAN|0x00000032
# Define if the spin-table mechanism is used by the secondary cores when booting
# Linux (instead of PSCI)
gArmTokenSpaceGuid.PcdArmLinuxSpinTable|FALSE|BOOLEAN|0x00000033
# Define if the GICv3 controller should use the GICv2 legacy
gArmTokenSpaceGuid.PcdArmGicV3WithV2Legacy|FALSE|BOOLEAN|0x00000042
# Whether to implement warm reboot for capsule update using a jump back to the
# PEI entry point with caches and interrupts disabled.
gArmTokenSpaceGuid.PcdArmReenterPeiForCapsuleWarmReboot|FALSE|BOOLEAN|0x0000001F
[PcdsFeatureFlag.ARM]
# Whether to map normal memory as non-shareable. FALSE is the safe choice, but
# TRUE may be appropriate to fix performance problems if you don't care about
@ -101,6 +84,9 @@
# Using a FeaturePcd make a '(BOOLEAN) casting for its value which is not understood by the preprocessor.
gArmTokenSpaceGuid.PcdVFPEnabled|0|UINT32|0x00000024
# This PCD will free the unallocated buffers if their size reach this threshold.
# We set the default value to 512MB.
gArmTokenSpaceGuid.PcdArmFreeUncachedMemorySizeThreshold|0x20000000|UINT64|0x00000003
gArmTokenSpaceGuid.PcdCpuVectorBaseAddress|0xffff0000|UINT64|0x00000004
gArmTokenSpaceGuid.PcdCpuResetAddress|0x00000000|UINT32|0x00000005
@ -130,6 +116,14 @@
#
gArmTokenSpaceGuid.PcdL2x0ControllerBase|0|UINT32|0x0000001B
#
# BdsLib
#
# The compressed Linux kernel is expected to be under 128MB from the beginning of the System Memory
gArmTokenSpaceGuid.PcdArmLinuxKernelMaxOffset|0x08000000|UINT32|0x0000001F
# Maximum file size for TFTP servers that do not support 'tsize' extension
gArmTokenSpaceGuid.PcdMaxTftpFileSize|0x01000000|UINT32|0x00000000
#
# ARM Normal (or Non Secure) Firmware PCDs
#
@ -170,6 +164,16 @@
# By default we do not do a transition to non-secure mode
gArmTokenSpaceGuid.PcdArmNonSecModeTransition|0x0|UINT32|0x0000003E
# The Linux ATAGs are expected to be under 0x4000 (16KB) from the beginning of the System Memory
gArmTokenSpaceGuid.PcdArmLinuxAtagMaxOffset|0x4000|UINT32|0x00000020
# If the fixed FDT address is not available, then it should be loaded below the kernel.
# The recommendation from the Linux kernel is to have the FDT below 16KB.
# (see the kernel doc: Documentation/arm/Booting)
gArmTokenSpaceGuid.PcdArmLinuxFdtMaxOffset|0x4000|UINT32|0x00000023
# The FDT blob must be loaded at a 64bit aligned address.
gArmTokenSpaceGuid.PcdArmLinuxFdtAlignment|0x8|UINT32|0x00000026
# Non Secure Access Control Register
# - BIT15 : NSASEDIS - Disable Non-secure Advanced SIMD functionality
# - BIT14 : NSD32DIS - Disable Non-secure use of D16-D31
@ -208,6 +212,12 @@
# Other modes include using SP0 or switching to Aarch32, but these are
# not currently supported.
gArmTokenSpaceGuid.PcdArmNonSecModeTransition|0x3c9|UINT32|0x0000003E
# If the fixed FDT address is not available, then it should be loaded above the kernel.
# The recommendation from the AArch64 Linux kernel is to have the FDT below 512MB.
# (see the kernel doc: Documentation/arm64/booting.txt)
gArmTokenSpaceGuid.PcdArmLinuxFdtMaxOffset|0x20000000|UINT32|0x00000023
# The FDT blob must be loaded at a 2MB aligned address.
gArmTokenSpaceGuid.PcdArmLinuxFdtAlignment|0x00200000|UINT32|0x00000026
#
@ -217,14 +227,11 @@
[PcdsFixedAtBuild.common, PcdsDynamic.common, PcdsPatchableInModule.common]
# System Memory (DRAM): These PCDs define the region of in-built system memory
# Some platforms can get DRAM extensions, these additional regions may be
# declared to UEFI using separate resource descriptor HOBs
# Some platforms can get DRAM extensions, these additional regions will be declared
# to UEFI by ArmPlatformLib
gArmTokenSpaceGuid.PcdSystemMemoryBase|0|UINT64|0x00000029
gArmTokenSpaceGuid.PcdSystemMemorySize|0|UINT64|0x0000002A
gArmTokenSpaceGuid.PcdMmBufferBase|0|UINT64|0x00000045
gArmTokenSpaceGuid.PcdMmBufferSize|0|UINT64|0x00000046
[PcdsFixedAtBuild.common, PcdsDynamic.common]
#
# ARM Architectural Timer

View File

@ -2,7 +2,7 @@
# ARM processor package.
#
# Copyright (c) 2009 - 2010, Apple Inc. All rights reserved.<BR>
# Copyright (c) 2011 - 2018, ARM Ltd. All rights reserved.<BR>
# Copyright (c) 2011 - 2015, ARM Ltd. All rights reserved.<BR>
# Copyright (c) 2016, Linaro Ltd. All rights reserved.<BR>
#
# This program and the accompanying materials
@ -27,10 +27,15 @@
DSC_SPECIFICATION = 0x00010005
OUTPUT_DIRECTORY = Build/Arm
SUPPORTED_ARCHITECTURES = ARM|AARCH64
BUILD_TARGETS = DEBUG|RELEASE|NOOPT
BUILD_TARGETS = DEBUG|RELEASE
SKUID_IDENTIFIER = DEFAULT
[BuildOptions]
XCODE:*_*_ARM_PLATFORM_FLAGS == -arch armv7
GCC:*_*_ARM_PLATFORM_FLAGS == -march=armv7-a -mfpu=neon
# We use A15 to get the Secure and Virtualization extensions
RVCT:*_*_ARM_PLATFORM_FLAGS == --cpu Cortex-A15
RELEASE_*_*_CC_FLAGS = -DMDEPKG_NDEBUG
*_*_*_CC_FLAGS = -DDISABLE_NEW_DEPRECATED_INTERFACES
@ -38,7 +43,6 @@
BaseLib|MdePkg/Library/BaseLib/BaseLib.inf
BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf
CacheMaintenanceLib|ArmPkg/Library/ArmCacheMaintenanceLib/ArmCacheMaintenanceLib.inf
CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf
DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf
HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
@ -58,6 +62,7 @@
HiiLib|MdeModulePkg/Library/UefiHiiLib/UefiHiiLib.inf
SemihostLib|ArmPkg/Library/SemihostLib/SemihostLib.inf
UncachedMemoryAllocationLib|ArmPkg/Library/UncachedMemoryAllocationLib/UncachedMemoryAllocationLib.inf
DxeServicesTableLib|MdePkg/Library/DxeServicesTableLib/DxeServicesTableLib.inf
DefaultExceptionHandlerLib|ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerLib.inf
CpuExceptionHandlerLib|ArmPkg/Library/ArmExceptionLib/ArmExceptionLib.inf
@ -68,12 +73,13 @@
ArmGenericTimerCounterLib|ArmPkg/Library/ArmGenericTimerPhyCounterLib/ArmGenericTimerPhyCounterLib.inf
ArmSmcLib|ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf
ArmDisassemblerLib|ArmPkg/Library/ArmDisassemblerLib/ArmDisassemblerLib.inf
OpteeLib|ArmPkg/Library/OpteeLib/OpteeLib.inf
DmaLib|ArmPkg/Library/ArmDmaLib/ArmDmaLib.inf
UefiApplicationEntryPoint|MdePkg/Library/UefiApplicationEntryPoint/UefiApplicationEntryPoint.inf
PerformanceLib|MdePkg/Library/BasePerformanceLibNull/BasePerformanceLibNull.inf
SerialPortLib|MdePkg/Library/BaseSerialPortLibNull/BaseSerialPortLibNull.inf
BdsLib|ArmPkg/Library/BdsLib/BdsLib.inf
FdtLib|EmbeddedPkg/Library/FdtLib/FdtLib.inf
ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf
@ -85,8 +91,6 @@
ArmLib|ArmPkg/Library/ArmLib/ArmBaseLib.inf
ArmMmuLib|ArmPkg/Library/ArmMmuLib/ArmMmuBaseLib.inf
ArmMtlLib|ArmPkg/Library/ArmMtlNullLib/ArmMtlNullLib.inf
[LibraryClasses.common.PEIM]
HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf
PeimEntryPoint|MdePkg/Library/PeimEntryPoint/PeimEntryPoint.inf
@ -103,6 +107,8 @@
[Components.common]
ArmPkg/Library/ArmCacheMaintenanceLib/ArmCacheMaintenanceLib.inf
ArmPkg/Library/ArmDisassemblerLib/ArmDisassemblerLib.inf
ArmPkg/Library/ArmDmaLib/ArmDmaLib.inf
ArmPkg/Library/BdsLib/BdsLib.inf
ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf
ArmPkg/Library/DebugAgentSymbolsBaseLib/DebugAgentSymbolsBaseLib.inf
ArmPkg/Library/DebugPeCoffExtraActionLib/DebugPeCoffExtraActionLib.inf
@ -111,6 +117,7 @@
ArmPkg/Library/SemiHostingDebugLib/SemiHostingDebugLib.inf
ArmPkg/Library/SemiHostingSerialPortLib/SemiHostingSerialPortLib.inf
ArmPkg/Library/SemihostLib/SemihostLib.inf
ArmPkg/Library/UncachedMemoryAllocationLib/UncachedMemoryAllocationLib.inf
ArmPkg/Library/ArmPsciResetSystemLib/ArmPsciResetSystemLib.inf
ArmPkg/Library/ArmExceptionLib/ArmExceptionLib.inf
ArmPkg/Library/ArmExceptionLib/ArmRelocateExceptionLib.inf
@ -119,6 +126,7 @@
ArmPkg/Drivers/CpuPei/CpuPei.inf
ArmPkg/Drivers/ArmGic/ArmGicDxe.inf
ArmPkg/Drivers/ArmGic/ArmGicLib.inf
ArmPkg/Drivers/ArmGic/ArmGicSecLib.inf
ArmPkg/Drivers/GenericWatchdogDxe/GenericWatchdogDxe.inf
ArmPkg/Drivers/TimerDxe/TimerDxe.inf
@ -128,8 +136,6 @@
ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf
ArmPkg/Library/ArmSmcLibNull/ArmSmcLibNull.inf
ArmPkg/Library/ArmHvcLib/ArmHvcLib.inf
ArmPkg/Library/ArmSvcLib/ArmSvcLib.inf
ArmPkg/Library/OpteeLib/OpteeLib.inf
ArmPkg/Filesystem/SemihostFs/SemihostFs.inf
@ -145,8 +151,5 @@
ArmPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf
ArmPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
ArmPkg/Drivers/ArmScmiDxe/ArmScmiDxe.inf
[Components.AARCH64]
ArmPkg/Library/ArmMmuLib/ArmMmuPeiLib.inf
ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.inf

218
ArmPkg/Contributions.txt Normal file
View File

@ -0,0 +1,218 @@
======================
= Code Contributions =
======================
To make a contribution to a TianoCore project, follow these steps.
1. Create a change description in the format specified below to
use in the source control commit log.
2. Your commit message must include your "Signed-off-by" signature,
and "Contributed-under" message.
3. Your "Contributed-under" message explicitly states that the
contribution is made under the terms of the specified
contribution agreement. Your "Contributed-under" message
must include the name of contribution agreement and version.
For example: Contributed-under: TianoCore Contribution Agreement 1.0
The "TianoCore Contribution Agreement" is included below in
this document.
4. Submit your code to the TianoCore project using the process
that the project documents on its web page. If the process is
not documented, then submit the code on development email list
for the project.
5. It is preferred that contributions are submitted using the same
copyright license as the base project. When that is not possible,
then contributions using the following licenses can be accepted:
* BSD (2-clause): http://opensource.org/licenses/BSD-2-Clause
* BSD (3-clause): http://opensource.org/licenses/BSD-3-Clause
* MIT: http://opensource.org/licenses/MIT
* Python-2.0: http://opensource.org/licenses/Python-2.0
* Zlib: http://opensource.org/licenses/Zlib
Contributions of code put into the public domain can also be
accepted.
Contributions using other licenses might be accepted, but further
review will be required.
=====================================================
= Change Description / Commit Message / Patch Email =
=====================================================
Your change description should use the standard format for a
commit message, and must include your "Signed-off-by" signature
and the "Contributed-under" message.
== Sample Change Description / Commit Message =
=== Start of sample patch email message ===
From: Contributor Name <contributor@example.com>
Subject: [PATCH] CodeModule: Brief-single-line-summary
Full-commit-message
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Contributor Name <contributor@example.com>
---
An extra message for the patch email which will not be considered part
of the commit message can be added here.
Patch content inline or attached
=== End of sample patch email message ===
=== Notes for sample patch email ===
* The first line of commit message is taken from the email's subject
line following [PATCH]. The remaining portion of the commit message
is the email's content until the '---' line.
* git format-patch is one way to create this format
=== Definitions for sample patch email ===
* "CodeModule" is a short idenfier for the affected code. For
example MdePkg, or MdeModulePkg UsbBusDxe.
* "Brief-single-line-summary" is a short summary of the change.
* The entire first line should be less than ~70 characters.
* "Full-commit-message" a verbose multiple line comment describing
the change. Each line should be less than ~70 characters.
* "Contributed-under" explicitely states that the contribution is
made under the terms of the contribtion agreement. This
agreement is included below in this document.
* "Signed-off-by" is the contributor's signature identifying them
by their real/legal name and their email address.
========================================
= TianoCore Contribution Agreement 1.0 =
========================================
INTEL CORPORATION ("INTEL") MAKES AVAILABLE SOFTWARE, DOCUMENTATION,
INFORMATION AND/OR OTHER MATERIALS FOR USE IN THE TIANOCORE OPEN SOURCE
PROJECT (COLLECTIVELY "CONTENT"). USE OF THE CONTENT IS GOVERNED BY THE
TERMS AND CONDITIONS OF THIS AGREEMENT BETWEEN YOU AND INTEL AND/OR THE
TERMS AND CONDITIONS OF LICENSE AGREEMENTS OR NOTICES INDICATED OR
REFERENCED BELOW. BY USING THE CONTENT, YOU AGREE THAT YOUR USE OF THE
CONTENT IS GOVERNED BY THIS AGREEMENT AND/OR THE TERMS AND CONDITIONS
OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED
BELOW. IF YOU DO NOT AGREE TO THE TERMS AND CONDITIONS OF THIS
AGREEMENT AND THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE
AGREEMENTS OR NOTICES INDICATED OR REFERENCED BELOW, THEN YOU MAY NOT
USE THE CONTENT.
Unless otherwise indicated, all Content made available on the TianoCore
site is provided to you under the terms and conditions of the BSD
License ("BSD"). A copy of the BSD License is available at
http://opensource.org/licenses/bsd-license.php
or when applicable, in the associated License.txt file.
Certain other content may be made available under other licenses as
indicated in or with such Content. (For example, in a License.txt file.)
You accept and agree to the following terms and conditions for Your
present and future Contributions submitted to TianoCore site. Except
for the license granted to Intel hereunder, You reserve all right,
title, and interest in and to Your Contributions.
== SECTION 1: Definitions ==
* "You" or "Contributor" shall mean the copyright owner or legal
entity authorized by the copyright owner that is making a
Contribution hereunder. All other entities that control, are
controlled by, or are under common control with that entity are
considered to be a single Contributor. For the purposes of this
definition, "control" means (i) the power, direct or indirect, to
cause the direction or management of such entity, whether by
contract or otherwise, or (ii) ownership of fifty percent (50%)
or more of the outstanding shares, or (iii) beneficial ownership
of such entity.
* "Contribution" shall mean any original work of authorship,
including any modifications or additions to an existing work,
that is intentionally submitted by You to the TinaoCore site for
inclusion in, or documentation of, any of the Content. For the
purposes of this definition, "submitted" means any form of
electronic, verbal, or written communication sent to the
TianoCore site or its representatives, including but not limited
to communication on electronic mailing lists, source code
control systems, and issue tracking systems that are managed by,
or on behalf of, the TianoCore site for the purpose of
discussing and improving the Content, but excluding
communication that is conspicuously marked or otherwise
designated in writing by You as "Not a Contribution."
== SECTION 2: License for Contributions ==
* Contributor hereby agrees that redistribution and use of the
Contribution in source and binary forms, with or without
modification, are permitted provided that the following
conditions are met:
** Redistributions of source code must retain the Contributor's
copyright notice, this list of conditions and the following
disclaimer.
** Redistributions in binary form must reproduce the Contributor's
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Disclaimer. None of the names of Contributor, Intel, or the names
of their respective contributors may be used to endorse or
promote products derived from this software without specific
prior written permission.
* Contributor grants a license (with the right to sublicense) under
claims of Contributor's patents that Contributor can license that
are infringed by the Contribution (as delivered by Contributor) to
make, use, distribute, sell, offer for sale, and import the
Contribution and derivative works thereof solely to the minimum
extent necessary for licensee to exercise the granted copyright
license; this patent license applies solely to those portions of
the Contribution that are unmodified. No hardware per se is
licensed.
* EXCEPT AS EXPRESSLY SET FORTH IN SECTION 3 BELOW, THE
CONTRIBUTION IS PROVIDED BY THE CONTRIBUTOR "AS IS" AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
CONTRIBUTOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE
CONTRIBUTION, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
DAMAGE.
== SECTION 3: Representations ==
* You represent that You are legally entitled to grant the above
license. If your employer(s) has rights to intellectual property
that You create that includes Your Contributions, You represent
that You have received permission to make Contributions on behalf
of that employer, that Your employer has waived such rights for
Your Contributions.
* You represent that each of Your Contributions is Your original
creation (see Section 4 for submissions on behalf of others).
You represent that Your Contribution submissions include complete
details of any third-party license or other restriction
(including, but not limited to, related patents and trademarks)
of which You are personally aware and which are associated with
any part of Your Contributions.
== SECTION 4: Third Party Contributions ==
* Should You wish to submit work that is not Your original creation,
You may submit it to TianoCore site separately from any
Contribution, identifying the complete details of its source
and of any license or other restriction (including, but not
limited to, related patents, trademarks, and license agreements)
of which You are personally aware, and conspicuously marking the
work as "Submitted on behalf of a third-party: [named here]".
== SECTION 5: Miscellaneous ==
* Applicable Laws. Any claims arising under or relating to this
Agreement shall be governed by the internal substantive laws of
the State of Delaware or federal courts located in Delaware,
without regard to principles of conflict of laws.
* Language. This Agreement is in the English language only, which
language shall be controlling in all respects, and all versions
of this Agreement in any other language shall be for accommodation
only and shall not be binding. All communications and notices made
or given pursuant to this Agreement, and all documentation and
support to be provided, unless otherwise noted, shall be in the
English language.

View File

@ -1,38 +0,0 @@
/** @file
Copyright (c) 2017, Linaro, Ltd. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include <PiDxe.h>
#include <Library/DebugLib.h>
#include <Library/DefaultExceptionHandlerLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Protocol/Cpu.h>
STATIC EFI_CPU_ARCH_PROTOCOL *mCpu;
EFI_STATUS
EFIAPI
ArmCrashDumpDxeInitialize (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
Status = gBS->LocateProtocol (&gEfiCpuArchProtocolGuid, NULL, (VOID **)&mCpu);
ASSERT_EFI_ERROR(Status);
return mCpu->RegisterInterruptHandler (mCpu,
EXCEPT_AARCH64_SYNCHRONOUS_EXCEPTIONS,
&DefaultExceptionHandler);
}

View File

@ -1,56 +0,0 @@
#/** @file
#
# Copyright (c) 2017, Linaro Ltd. All rights reserved.<BR>
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
#**/
################################################################################
#
# Defines Section - statements that will be processed to create a Makefile.
#
################################################################################
[Defines]
PLATFORM_NAME = ArmCrashDumpDxe
PLATFORM_GUID = 8dc3c2f8-988e-4e32-8fb7-0df43f6d0d8a
PLATFORM_VERSION = 0.1
DSC_SPECIFICATION = 0x00010019
OUTPUT_DIRECTORY = Build/ArmCrashDumpDxe
SUPPORTED_ARCHITECTURES = AARCH64
BUILD_TARGETS = DEBUG
SKUID_IDENTIFIER = DEFAULT
[PcdsFixedAtBuild]
gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x8000004F
gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x27
[LibraryClasses]
ArmDisassemblerLib|ArmPkg/Library/ArmDisassemblerLib/ArmDisassemblerLib.inf
BaseLib|MdePkg/Library/BaseLib/BaseLib.inf
BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf
DebugLib|MdePkg/Library/UefiDebugLibConOut/UefiDebugLibConOut.inf
DebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintErrorLevelLib/BaseDebugPrintErrorLevelLib.inf
DefaultExceptionHandlerLib|ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerLib.inf
DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf
MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
PeCoffGetEntryPointLib|MdePkg/Library/BasePeCoffGetEntryPointLib/BasePeCoffGetEntryPointLib.inf
PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf
SerialPortLib|MdePkg/Library/BaseSerialPortLibNull/BaseSerialPortLibNull.inf
UefiBootServicesTableLib|MdePkg/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.inf
UefiDriverEntryPoint|MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntryPoint.inf
UefiLib|MdePkg/Library/UefiLib/UefiLib.inf
UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf
NULL|ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf
NULL|MdePkg/Library/BaseStackCheckLib/BaseStackCheckLib.inf
[Components.common]
ArmPkg/Drivers/ArmCrashDumpDxe/ArmCrashDumpDxe.inf

View File

@ -1,40 +0,0 @@
#/** @file
#
# Copyright (c) 2017, Linaro, Ltd. All rights reserved.<BR>
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
#**/
[Defines]
INF_VERSION = 0x00010018
BASE_NAME = ArmCrashDumpDxe
FILE_GUID = 0bda00b0-05d6-4bb8-bfc7-058ad13615cf
MODULE_TYPE = DXE_DRIVER
VERSION_STRING = 1.0
ENTRY_POINT = ArmCrashDumpDxeInitialize
[Sources]
ArmCrashDumpDxe.c
[Packages]
ArmPkg/ArmPkg.dec
MdePkg/MdePkg.dec
[LibraryClasses]
DebugLib
DefaultExceptionHandlerLib
UefiBootServicesTableLib
UefiDriverEntryPoint
[Protocols]
gEfiCpuArchProtocolGuid
[Depex]
gEfiCpuArchProtocolGuid

View File

@ -1,6 +1,6 @@
/*++
Copyright (c) 2013-2017, ARM Ltd. All rights reserved.<BR>
Copyright (c) 2013-2014, ARM Ltd. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
@ -28,10 +28,14 @@ ExitBootServicesEvent (
IN VOID *Context
);
//
// Making this global saves a few bytes in image size
//
EFI_HANDLE gHardwareInterruptHandle = NULL;
//
// Notifications
//
EFI_EVENT EfiExitBootServicesEvent = (EFI_EVENT)NULL;
// Maximum Number of Interrupts
@ -39,46 +43,6 @@ UINTN mGicNumInterrupts = 0;
HARDWARE_INTERRUPT_HANDLER *gRegisteredInterruptHandlers = NULL;
/**
Calculate GICD_ICFGRn base address and corresponding bit
field Int_config[1] of the GIC distributor register.
@param Source Hardware source of the interrupt.
@param RegAddress Corresponding GICD_ICFGRn base address.
@param Config1Bit Bit number of F Int_config[1] bit in the register.
@retval EFI_SUCCESS Source interrupt supported.
@retval EFI_UNSUPPORTED Source interrupt is not supported.
**/
EFI_STATUS
GicGetDistributorIcfgBaseAndBit (
IN HARDWARE_INTERRUPT_SOURCE Source,
OUT UINTN *RegAddress,
OUT UINTN *Config1Bit
)
{
UINTN RegIndex;
UINTN Field;
if (Source >= mGicNumInterrupts) {
ASSERT(Source < mGicNumInterrupts);
return EFI_UNSUPPORTED;
}
RegIndex = Source / ARM_GIC_ICDICFR_F_STRIDE; // NOTE: truncation is significant
Field = Source % ARM_GIC_ICDICFR_F_STRIDE;
*RegAddress = PcdGet64 (PcdGicDistributorBase)
+ ARM_GIC_ICDICFR
+ (ARM_GIC_ICDICFR_BYTES * RegIndex);
*Config1Bit = ((Field * ARM_GIC_ICDICFR_F_WIDTH)
+ ARM_GIC_ICDICFR_F_CONFIG1_BIT);
return EFI_SUCCESS;
}
/**
Register Handler for the specified interrupt source.
@ -121,68 +85,25 @@ RegisterInterruptSource (
}
}
STATIC VOID *mCpuArchProtocolNotifyEventRegistration;
STATIC
VOID
EFIAPI
CpuArchEventProtocolNotify (
IN EFI_EVENT Event,
IN VOID *Context
)
{
EFI_CPU_ARCH_PROTOCOL *Cpu;
EFI_STATUS Status;
// Get the CPU protocol that this driver requires.
Status = gBS->LocateProtocol (&gEfiCpuArchProtocolGuid, NULL, (VOID **)&Cpu);
if (EFI_ERROR (Status)) {
return;
}
// Unregister the default exception handler.
Status = Cpu->RegisterInterruptHandler (Cpu, ARM_ARCH_EXCEPTION_IRQ, NULL);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a: Cpu->RegisterInterruptHandler() - %r\n",
__FUNCTION__, Status));
return;
}
// Register to receive interrupts
Status = Cpu->RegisterInterruptHandler (Cpu, ARM_ARCH_EXCEPTION_IRQ,
Context);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a: Cpu->RegisterInterruptHandler() - %r\n",
__FUNCTION__, Status));
}
gBS->CloseEvent (Event);
}
EFI_STATUS
InstallAndRegisterInterruptService (
IN EFI_HARDWARE_INTERRUPT_PROTOCOL *InterruptProtocol,
IN EFI_HARDWARE_INTERRUPT2_PROTOCOL *Interrupt2Protocol,
IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler,
IN EFI_EVENT_NOTIFY ExitBootServicesEvent
)
{
EFI_STATUS Status;
CONST UINTN RihArraySize =
(sizeof(HARDWARE_INTERRUPT_HANDLER) * mGicNumInterrupts);
EFI_CPU_ARCH_PROTOCOL *Cpu;
// Initialize the array for the Interrupt Handlers
gRegisteredInterruptHandlers = AllocateZeroPool (RihArraySize);
gRegisteredInterruptHandlers = (HARDWARE_INTERRUPT_HANDLER*)AllocateZeroPool (sizeof(HARDWARE_INTERRUPT_HANDLER) * mGicNumInterrupts);
if (gRegisteredInterruptHandlers == NULL) {
return EFI_OUT_OF_RESOURCES;
}
Status = gBS->InstallMultipleProtocolInterfaces (
&gHardwareInterruptHandle,
&gHardwareInterruptProtocolGuid,
InterruptProtocol,
&gHardwareInterrupt2ProtocolGuid,
Interrupt2Protocol,
&gHardwareInterruptProtocolGuid, InterruptProtocol,
NULL
);
if (EFI_ERROR (Status)) {
@ -190,23 +111,31 @@ InstallAndRegisterInterruptService (
}
//
// Install the interrupt handler as soon as the CPU arch protocol appears.
// Get the CPU protocol that this driver requires.
//
EfiCreateProtocolNotifyEvent (
&gEfiCpuArchProtocolGuid,
TPL_CALLBACK,
CpuArchEventProtocolNotify,
InterruptHandler,
&mCpuArchProtocolNotifyEventRegistration);
Status = gBS->LocateProtocol (&gEfiCpuArchProtocolGuid, NULL, (VOID **)&Cpu);
if (EFI_ERROR (Status)) {
return Status;
}
//
// Unregister the default exception handler.
//
Status = Cpu->RegisterInterruptHandler (Cpu, ARM_ARCH_EXCEPTION_IRQ, NULL);
if (EFI_ERROR (Status)) {
return Status;
}
//
// Register to receive interrupts
//
Status = Cpu->RegisterInterruptHandler (Cpu, ARM_ARCH_EXCEPTION_IRQ, InterruptHandler);
if (EFI_ERROR (Status)) {
return Status;
}
// Register for an ExitBootServicesEvent
Status = gBS->CreateEvent (
EVT_SIGNAL_EXIT_BOOT_SERVICES,
TPL_NOTIFY,
ExitBootServicesEvent,
NULL,
&EfiExitBootServicesEvent
);
Status = gBS->CreateEvent (EVT_SIGNAL_EXIT_BOOT_SERVICES, TPL_NOTIFY, ExitBootServicesEvent, NULL, &EfiExitBootServicesEvent);
return Status;
}

View File

@ -1,6 +1,6 @@
/*++
Copyright (c) 2013-2017, ARM Ltd. All rights reserved.<BR>
Copyright (c) 2013-2014, ARM Ltd. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
@ -21,20 +21,19 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Library/IoLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiLib.h>
#include <Protocol/Cpu.h>
#include <Protocol/HardwareInterrupt.h>
#include <Protocol/HardwareInterrupt2.h>
extern UINTN mGicNumInterrupts;
extern HARDWARE_INTERRUPT_HANDLER *gRegisteredInterruptHandlers;
//
// Common API
//
EFI_STATUS
InstallAndRegisterInterruptService (
IN EFI_HARDWARE_INTERRUPT_PROTOCOL *InterruptProtocol,
IN EFI_HARDWARE_INTERRUPT2_PROTOCOL *Interrupt2Protocol,
IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler,
IN EFI_EVENT_NOTIFY ExitBootServicesEvent
);
@ -47,39 +46,22 @@ RegisterInterruptSource (
IN HARDWARE_INTERRUPT_HANDLER Handler
);
//
// GicV2 API
//
EFI_STATUS
GicV2DxeInitialize (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
);
//
// GicV3 API
//
EFI_STATUS
GicV3DxeInitialize (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
);
// Shared code
/**
Calculate GICD_ICFGRn base address and corresponding bit
field Int_config[1] of the GIC distributor register.
@param Source Hardware source of the interrupt.
@param RegAddress Corresponding GICD_ICFGRn base address.
@param Config1Bit Bit number of F Int_config[1] bit in the register.
@retval EFI_SUCCESS Source interrupt supported.
@retval EFI_UNSUPPORTED Source interrupt is not supported.
**/
EFI_STATUS
GicGetDistributorIcfgBaseAndBit (
IN HARDWARE_INTERRUPT_SOURCE Source,
OUT UINTN *RegAddress,
OUT UINTN *Config1Bit
);
#endif

View File

@ -1,7 +1,7 @@
#/** @file
#
# Copyright (c) 2008 - 2010, Apple Inc. All rights reserved.<BR>
# Copyright (c) 2012 - 2017, ARM Ltd. All rights reserved.<BR>
# Copyright (c) 2012 - 2015, ARM Ltd. All rights reserved.<BR>
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
@ -45,12 +45,10 @@
UefiDriverEntryPoint
IoLib
PcdLib
UefiLib
[Protocols]
gHardwareInterruptProtocolGuid ## PRODUCES
gHardwareInterrupt2ProtocolGuid ## PRODUCES
gEfiCpuArchProtocolGuid ## CONSUMES ## NOTIFY
gHardwareInterruptProtocolGuid
gEfiCpuArchProtocolGuid
[Pcd.common]
gArmTokenSpaceGuid.PcdGicDistributorBase
@ -59,4 +57,4 @@
gArmTokenSpaceGuid.PcdArmGicV3WithV2Legacy
[Depex]
TRUE
gEfiCpuArchProtocolGuid

View File

@ -1,6 +1,6 @@
/** @file
*
* Copyright (c) 2011-2018, ARM Limited. All rights reserved.
* Copyright (c) 2011-2015, ARM Limited. All rights reserved.
*
* This program and the accompanying materials
* are licensed and made available under the terms and conditions of the BSD License
@ -19,23 +19,6 @@
#include <Library/IoLib.h>
#include <Library/PcdLib.h>
// In GICv3, there are 2 x 64KB frames:
// Redistributor control frame + SGI Control & Generation frame
#define GIC_V3_REDISTRIBUTOR_GRANULARITY (ARM_GICR_CTLR_FRAME_SIZE \
+ ARM_GICR_SGI_PPI_FRAME_SIZE)
// In GICv4, there are 2 additional 64KB frames:
// VLPI frame + Reserved page frame
#define GIC_V4_REDISTRIBUTOR_GRANULARITY (GIC_V3_REDISTRIBUTOR_GRANULARITY \
+ ARM_GICR_SGI_VLPI_FRAME_SIZE \
+ ARM_GICR_SGI_RESERVED_FRAME_SIZE)
#define ISENABLER_ADDRESS(base,offset) ((base) + \
ARM_GICR_CTLR_FRAME_SIZE + ARM_GICR_ISENABLER + (4 * offset))
#define ICENABLER_ADDRESS(base,offset) ((base) + \
ARM_GICR_CTLR_FRAME_SIZE + ARM_GICR_ICENABLER + (4 * offset))
/**
*
* Return whether the Source interrupt index refers to a shared interrupt (SPI)
@ -64,43 +47,37 @@ GicGetCpuRedistributorBase (
IN ARM_GIC_ARCH_REVISION Revision
)
{
UINTN Index;
UINTN MpId;
UINTN CpuAffinity;
UINTN Affinity;
UINTN GicRedistributorGranularity;
UINTN GicCpuRedistributorBase;
UINT64 TypeRegister;
MpId = ArmReadMpidr ();
// Define CPU affinity as:
// Affinity0[0:8], Affinity1[9:15], Affinity2[16:23], Affinity3[24:32]
// Define CPU affinity as Affinity0[0:8], Affinity1[9:15], Affinity2[16:23], Affinity3[24:32]
// whereas Affinity3 is defined at [32:39] in MPIDR
CpuAffinity = (MpId & (ARM_CORE_AFF0 | ARM_CORE_AFF1 | ARM_CORE_AFF2)) |
((MpId & ARM_CORE_AFF3) >> 8);
CpuAffinity = (MpId & (ARM_CORE_AFF0 | ARM_CORE_AFF1 | ARM_CORE_AFF2)) | ((MpId & ARM_CORE_AFF3) >> 8);
if (Revision < ARM_GIC_ARCH_REVISION_3) {
if (Revision == ARM_GIC_ARCH_REVISION_3) {
// 2 x 64KB frame: Redistributor control frame + SGI Control & Generation frame
GicRedistributorGranularity = ARM_GICR_CTLR_FRAME_SIZE + ARM_GICR_SGI_PPI_FRAME_SIZE;
} else {
ASSERT_EFI_ERROR (EFI_UNSUPPORTED);
return 0;
}
GicCpuRedistributorBase = GicRedistributorBase;
do {
TypeRegister = MmioRead64 (GicCpuRedistributorBase + ARM_GICR_TYPER);
Affinity = ARM_GICR_TYPER_GET_AFFINITY (TypeRegister);
for (Index = 0; Index < PcdGet32 (PcdCoreCount); Index++) {
Affinity = MmioRead64 (GicCpuRedistributorBase + ARM_GICR_TYPER) >> 32;
if (Affinity == CpuAffinity) {
return GicCpuRedistributorBase;
}
// Move to the next GIC Redistributor frame.
// The GIC specification does not forbid a mixture of redistributors
// with or without support for virtual LPIs, so we test Virtual LPIs
// Support (VLPIS) bit for each frame to decide the granularity.
// Note: The assumption here is that the redistributors are adjacent
// for all CPUs. However this may not be the case for NUMA systems.
GicCpuRedistributorBase += (((ARM_GICR_TYPER_VLPIS & TypeRegister) != 0)
? GIC_V4_REDISTRIBUTOR_GRANULARITY
: GIC_V3_REDISTRIBUTOR_GRANULARITY);
} while ((TypeRegister & ARM_GICR_TYPER_LAST) == 0);
// Move to the next GIC Redistributor frame
GicCpuRedistributorBase += GicRedistributorGranularity;
}
// The Redistributor has not been found for the current CPU
ASSERT_EFI_ERROR (EFI_NOT_FOUND);
@ -135,10 +112,7 @@ ArmGicSendSgiTo (
IN INTN SgiId
)
{
MmioWrite32 (
GicDistributorBase + ARM_GIC_ICDSGIR,
((TargetListFilter & 0x3) << 24) | ((CPUTargetList & 0xFF) << 16) | SgiId
);
MmioWrite32 (GicDistributorBase + ARM_GIC_ICDSGIR, ((TargetListFilter & 0x3) << 24) | ((CPUTargetList & 0xFF) << 16) | SgiId);
}
/*
@ -149,8 +123,7 @@ ArmGicSendSgiTo (
* in the GICv3 the register value is only the InterruptId.
*
* @param GicInterruptInterfaceBase Base Address of the GIC CPU Interface
* @param InterruptId InterruptId read from the Interrupt
* Acknowledge Register
* @param InterruptId InterruptId read from the Interrupt Acknowledge Register
*
* @retval value returned by the Interrupt Acknowledge Register
*
@ -227,25 +200,16 @@ ArmGicEnableInterrupt (
FeaturePcdGet (PcdArmGicV3WithV2Legacy) ||
SourceIsSpi (Source)) {
// Write set-enable register
MmioWrite32 (
GicDistributorBase + ARM_GIC_ICDISER + (4 * RegOffset),
1 << RegShift
);
MmioWrite32 (GicDistributorBase + ARM_GIC_ICDISER + (4 * RegOffset), 1 << RegShift);
} else {
GicCpuRedistributorBase = GicGetCpuRedistributorBase (
GicRedistributorBase,
Revision
);
GicCpuRedistributorBase = GicGetCpuRedistributorBase (GicRedistributorBase, Revision);
if (GicCpuRedistributorBase == 0) {
ASSERT_EFI_ERROR (EFI_NOT_FOUND);
return;
}
// Write set-enable register
MmioWrite32 (
ISENABLER_ADDRESS(GicCpuRedistributorBase, RegOffset),
1 << RegShift
);
MmioWrite32 (GicCpuRedistributorBase + ARM_GICR_CTLR_FRAME_SIZE + ARM_GICR_ISENABLER + (4 * RegOffset), 1 << RegShift);
}
}
@ -271,24 +235,15 @@ ArmGicDisableInterrupt (
FeaturePcdGet (PcdArmGicV3WithV2Legacy) ||
SourceIsSpi (Source)) {
// Write clear-enable register
MmioWrite32 (
GicDistributorBase + ARM_GIC_ICDICER + (4 * RegOffset),
1 << RegShift
);
MmioWrite32 (GicDistributorBase + ARM_GIC_ICDICER + (4 * RegOffset), 1 << RegShift);
} else {
GicCpuRedistributorBase = GicGetCpuRedistributorBase (
GicRedistributorBase,
Revision
);
GicCpuRedistributorBase = GicGetCpuRedistributorBase (GicRedistributorBase, Revision);
if (GicCpuRedistributorBase == 0) {
return;
}
// Write clear-enable register
MmioWrite32 (
ICENABLER_ADDRESS(GicCpuRedistributorBase, RegOffset),
1 << RegShift
);
MmioWrite32 (GicCpuRedistributorBase + ARM_GICR_CTLR_FRAME_SIZE + ARM_GICR_ICENABLER + (4 * RegOffset), 1 << RegShift);
}
}
@ -314,23 +269,15 @@ ArmGicIsInterruptEnabled (
if ((Revision == ARM_GIC_ARCH_REVISION_2) ||
FeaturePcdGet (PcdArmGicV3WithV2Legacy) ||
SourceIsSpi (Source)) {
Interrupts = ((MmioRead32 (
GicDistributorBase + ARM_GIC_ICDISER + (4 * RegOffset)
)
& (1 << RegShift)) != 0);
Interrupts = ((MmioRead32 (GicDistributorBase + ARM_GIC_ICDISER + (4 * RegOffset)) & (1 << RegShift)) != 0);
} else {
GicCpuRedistributorBase = GicGetCpuRedistributorBase (
GicRedistributorBase,
Revision
);
GicCpuRedistributorBase = GicGetCpuRedistributorBase (GicRedistributorBase, Revision);
if (GicCpuRedistributorBase == 0) {
return 0;
}
// Read set-enable register
Interrupts = MmioRead32 (
ISENABLER_ADDRESS(GicCpuRedistributorBase, RegOffset)
);
Interrupts = MmioRead32 (GicCpuRedistributorBase + ARM_GICR_CTLR_FRAME_SIZE + ARM_GICR_ISENABLER + (4 * RegOffset));
}
return ((Interrupts & (1 << RegShift)) != 0);

View File

@ -1,5 +1,5 @@
#/* @file
# Copyright (c) 2011-2018, ARM Limited. All rights reserved.
# Copyright (c) 2011-2015, ARM Limited. All rights reserved.
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
@ -44,5 +44,8 @@
ArmPlatformPkg/ArmPlatformPkg.dec
MdePkg/MdePkg.dec
[Pcd]
gArmPlatformTokenSpaceGuid.PcdCoreCount
[FeaturePcd]
gArmTokenSpaceGuid.PcdArmGicV3WithV2Legacy

View File

@ -0,0 +1,52 @@
#/* @file
# Copyright (c) 2011-2015, ARM Limited. All rights reserved.
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
#*/
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = ArmGicSecLib
FILE_GUID = 85f3cf80-b5f4-11df-9855-0002a5d5c51b
MODULE_TYPE = SEC
VERSION_STRING = 1.0
LIBRARY_CLASS = ArmGicLib
[Sources]
ArmGicLib.c
ArmGicSecLib.c
GicV2/ArmGicV2Lib.c
GicV2/ArmGicV2SecLib.c
[Sources.ARM]
GicV3/Arm/ArmGicV3.S | GCC
GicV3/Arm/ArmGicV3.asm | RVCT
[Sources.AARCH64]
GicV3/AArch64/ArmGicV3.S
[Packages]
ArmPkg/ArmPkg.dec
ArmPlatformPkg/ArmPlatformPkg.dec
MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec
[LibraryClasses]
ArmLib
DebugLib
IoLib
ArmGicArchLib
[Pcd]
gArmPlatformTokenSpaceGuid.PcdCoreCount
[FeaturePcd]
gArmTokenSpaceGuid.PcdArmGicV3WithV2Legacy

View File

@ -2,7 +2,7 @@
Copyright (c) 2009, Hewlett-Packard Company. All rights reserved.<BR>
Portions copyright (c) 2010, Apple Inc. All rights reserved.<BR>
Portions copyright (c) 2011-2017, ARM Ltd. All rights reserved.<BR>
Portions copyright (c) 2011-2016, ARM Ltd. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
@ -29,7 +29,6 @@ Abstract:
#define ARM_GIC_DEFAULT_PRIORITY 0x80
extern EFI_HARDWARE_INTERRUPT_PROTOCOL gHardwareInterruptV2Protocol;
extern EFI_HARDWARE_INTERRUPT2_PROTOCOL gHardwareInterrupt2V2Protocol;
STATIC UINT32 mGicInterruptInterfaceBase;
STATIC UINT32 mGicDistributorBase;
@ -44,7 +43,6 @@ STATIC UINT32 mGicDistributorBase;
@retval EFI_UNSUPPORTED Source interrupt is not supported
**/
STATIC
EFI_STATUS
EFIAPI
GicV2EnableInterruptSource (
@ -72,7 +70,6 @@ GicV2EnableInterruptSource (
@retval EFI_UNSUPPORTED Source interrupt is not supported
**/
STATIC
EFI_STATUS
EFIAPI
GicV2DisableInterruptSource (
@ -101,7 +98,6 @@ GicV2DisableInterruptSource (
@retval EFI_UNSUPPORTED Source interrupt is not supported
**/
STATIC
EFI_STATUS
EFIAPI
GicV2GetInterruptSourceState (
@ -131,7 +127,6 @@ GicV2GetInterruptSourceState (
@retval EFI_UNSUPPORTED Source interrupt is not supported
**/
STATIC
EFI_STATUS
EFIAPI
GicV2EndOfInterrupt (
@ -152,15 +147,13 @@ GicV2EndOfInterrupt (
EFI_CPU_INTERRUPT_HANDLER that is called when a processor interrupt occurs.
@param InterruptType Defines the type of interrupt or exception that
occurred on the processor.This parameter is
processor architecture specific.
occurred on the processor.This parameter is processor architecture specific.
@param SystemContext A pointer to the processor context when
the interrupt occurred on the processor.
@return None
**/
STATIC
VOID
EFIAPI
GicV2IrqInterruptHandler (
@ -173,10 +166,9 @@ GicV2IrqInterruptHandler (
GicInterrupt = ArmGicV2AcknowledgeInterrupt (mGicInterruptInterfaceBase);
// Special Interrupts (ID1020-ID1023) have an Interrupt ID greater than the
// number of interrupt (ie: Spurious interrupt).
// Special Interrupts (ID1020-ID1023) have an Interrupt ID greater than the number of interrupt (ie: Spurious interrupt).
if ((GicInterrupt & ARM_GIC_ICCIAR_ACKINTID) >= mGicNumInterrupts) {
// The special interrupts do not need to be acknowledged
// The special interrupt do not need to be acknowledge
return;
}
@ -185,12 +177,14 @@ GicV2IrqInterruptHandler (
// Call the registered interrupt handler.
InterruptHandler (GicInterrupt, SystemContext);
} else {
DEBUG ((DEBUG_ERROR, "Spurious GIC interrupt: 0x%x\n", GicInterrupt));
DEBUG ((EFI_D_ERROR, "Spurious GIC interrupt: 0x%x\n", GicInterrupt));
GicV2EndOfInterrupt (&gHardwareInterruptV2Protocol, GicInterrupt);
}
}
//
// The protocol instance produced by this driver
//
EFI_HARDWARE_INTERRUPT_PROTOCOL gHardwareInterruptV2Protocol = {
RegisterInterruptSource,
GicV2EnableInterruptSource,
@ -199,151 +193,15 @@ EFI_HARDWARE_INTERRUPT_PROTOCOL gHardwareInterruptV2Protocol = {
GicV2EndOfInterrupt
};
/**
Get interrupt trigger type of an interrupt
@param This Instance pointer for this protocol
@param Source Hardware source of the interrupt.
@param TriggerType Returns interrupt trigger type.
@retval EFI_SUCCESS Source interrupt supported.
@retval EFI_UNSUPPORTED Source interrupt is not supported.
**/
STATIC
EFI_STATUS
EFIAPI
GicV2GetTriggerType (
IN EFI_HARDWARE_INTERRUPT2_PROTOCOL *This,
IN HARDWARE_INTERRUPT_SOURCE Source,
OUT EFI_HARDWARE_INTERRUPT2_TRIGGER_TYPE *TriggerType
)
{
UINTN RegAddress;
UINTN Config1Bit;
EFI_STATUS Status;
Status = GicGetDistributorIcfgBaseAndBit (
Source,
&RegAddress,
&Config1Bit
);
if (EFI_ERROR (Status)) {
return Status;
}
if ((MmioRead32 (RegAddress) & (1 << Config1Bit)) == 0) {
*TriggerType = EFI_HARDWARE_INTERRUPT2_TRIGGER_LEVEL_HIGH;
} else {
*TriggerType = EFI_HARDWARE_INTERRUPT2_TRIGGER_EDGE_RISING;
}
return EFI_SUCCESS;
}
/**
Set interrupt trigger type of an interrupt
@param This Instance pointer for this protocol
@param Source Hardware source of the interrupt.
@param TriggerType Interrupt trigger type.
@retval EFI_SUCCESS Source interrupt supported.
@retval EFI_UNSUPPORTED Source interrupt is not supported.
**/
STATIC
EFI_STATUS
EFIAPI
GicV2SetTriggerType (
IN EFI_HARDWARE_INTERRUPT2_PROTOCOL *This,
IN HARDWARE_INTERRUPT_SOURCE Source,
IN EFI_HARDWARE_INTERRUPT2_TRIGGER_TYPE TriggerType
)
{
UINTN RegAddress;
UINTN Config1Bit;
UINT32 Value;
EFI_STATUS Status;
BOOLEAN SourceEnabled;
if ( (TriggerType != EFI_HARDWARE_INTERRUPT2_TRIGGER_EDGE_RISING)
&& (TriggerType != EFI_HARDWARE_INTERRUPT2_TRIGGER_LEVEL_HIGH)) {
DEBUG ((DEBUG_ERROR, "Invalid interrupt trigger type: %d\n", \
TriggerType));
ASSERT (FALSE);
return EFI_UNSUPPORTED;
}
Status = GicGetDistributorIcfgBaseAndBit (
Source,
&RegAddress,
&Config1Bit
);
if (EFI_ERROR (Status)) {
return Status;
}
Status = GicV2GetInterruptSourceState (
(EFI_HARDWARE_INTERRUPT_PROTOCOL*)This,
Source,
&SourceEnabled
);
if (EFI_ERROR (Status)) {
return Status;
}
Value = (TriggerType == EFI_HARDWARE_INTERRUPT2_TRIGGER_EDGE_RISING)
? ARM_GIC_ICDICFR_EDGE_TRIGGERED
: ARM_GIC_ICDICFR_LEVEL_TRIGGERED;
// Before changing the value, we must disable the interrupt,
// otherwise GIC behavior is UNPREDICTABLE.
if (SourceEnabled) {
GicV2DisableInterruptSource (
(EFI_HARDWARE_INTERRUPT_PROTOCOL*)This,
Source
);
}
MmioAndThenOr32 (
RegAddress,
~(0x1 << Config1Bit),
Value << Config1Bit
);
// Restore interrupt state
if (SourceEnabled) {
GicV2EnableInterruptSource (
(EFI_HARDWARE_INTERRUPT_PROTOCOL*)This,
Source
);
}
return EFI_SUCCESS;
}
EFI_HARDWARE_INTERRUPT2_PROTOCOL gHardwareInterrupt2V2Protocol = {
(HARDWARE_INTERRUPT2_REGISTER)RegisterInterruptSource,
(HARDWARE_INTERRUPT2_ENABLE)GicV2EnableInterruptSource,
(HARDWARE_INTERRUPT2_DISABLE)GicV2DisableInterruptSource,
(HARDWARE_INTERRUPT2_INTERRUPT_STATE)GicV2GetInterruptSourceState,
(HARDWARE_INTERRUPT2_END_OF_INTERRUPT)GicV2EndOfInterrupt,
GicV2GetTriggerType,
GicV2SetTriggerType
};
/**
Shutdown our hardware
DXE Core will disable interrupts and turn off the timer and disable
interrupts after all the event handlers have run.
DXE Core will disable interrupts and turn off the timer and disable interrupts
after all the event handlers have run.
@param[in] Event The Event that is being processed
@param[in] Context Event Context
**/
STATIC
VOID
EFIAPI
GicV2ExitBootServicesEvent (
@ -398,8 +256,7 @@ GicV2DxeInitialize (
UINTN RegShift;
UINT32 CpuTarget;
// Make sure the Interrupt Controller Protocol is not already installed in
// the system.
// Make sure the Interrupt Controller Protocol is not already installed in the system.
ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gHardwareInterruptProtocolGuid);
mGicInterruptInterfaceBase = PcdGet64 (PcdGicInterruptInterfaceBase);
@ -419,27 +276,25 @@ GicV2DxeInitialize (
);
}
//
// Targets the interrupts to the Primary Cpu
//
// Only Primary CPU will run this code. We can identify our GIC CPU ID by
// reading the GIC Distributor Target register. The 8 first GICD_ITARGETSRn
// are banked to each connected CPU. These 8 registers hold the CPU targets
// fields for interrupts 0-31. More Info in the GIC Specification about
// "Interrupt Processor Targets Registers"
// Read the first Interrupt Processor Targets Register (that corresponds to
// the 4 first SGIs)
// Only Primary CPU will run this code. We can identify our GIC CPU ID by reading
// the GIC Distributor Target register. The 8 first GICD_ITARGETSRn are banked to each
// connected CPU. These 8 registers hold the CPU targets fields for interrupts 0-31.
// More Info in the GIC Specification about "Interrupt Processor Targets Registers"
//
// Read the first Interrupt Processor Targets Register (that corresponds to the 4
// first SGIs)
CpuTarget = MmioRead32 (mGicDistributorBase + ARM_GIC_ICDIPTR);
// The CPU target is a bit field mapping each CPU to a GIC CPU Interface.
// This value is 0 when we run on a uniprocessor platform.
// The CPU target is a bit field mapping each CPU to a GIC CPU Interface. This value
// is 0 when we run on a uniprocessor platform.
if (CpuTarget != 0) {
// The 8 first Interrupt Processor Targets Registers are read-only
for (Index = 8; Index < (mGicNumInterrupts / 4); Index++) {
MmioWrite32 (
mGicDistributorBase + ARM_GIC_ICDIPTR + (Index * 4),
CpuTarget
);
MmioWrite32 (mGicDistributorBase + ARM_GIC_ICDIPTR + (Index * 4), CpuTarget);
}
}
@ -456,11 +311,7 @@ GicV2DxeInitialize (
ArmGicEnableDistributor (mGicDistributorBase);
Status = InstallAndRegisterInterruptService (
&gHardwareInterruptV2Protocol,
&gHardwareInterrupt2V2Protocol,
GicV2IrqInterruptHandler,
GicV2ExitBootServicesEvent
);
&gHardwareInterruptV2Protocol, GicV2IrqInterruptHandler, GicV2ExitBootServicesEvent);
return Status;
}

View File

@ -0,0 +1,100 @@
/** @file
*
* Copyright (c) 2011-2014, ARM Limited. All rights reserved.
*
* This program and the accompanying materials
* are licensed and made available under the terms and conditions of the BSD License
* which accompanies this distribution. The full text of the license may be found at
* http://opensource.org/licenses/bsd-license.php
*
* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
*
**/
#include <Base.h>
#include <Library/ArmLib.h>
#include <Library/ArmPlatformLib.h>
#include <Library/DebugLib.h>
#include <Library/IoLib.h>
#include <Library/ArmGicLib.h>
/*
* This function configures the all interrupts to be Non-secure.
*
*/
VOID
EFIAPI
ArmGicV2SetupNonSecure (
IN UINTN MpId,
IN INTN GicDistributorBase,
IN INTN GicInterruptInterfaceBase
)
{
UINTN InterruptId;
UINTN CachedPriorityMask;
UINTN Index;
UINTN MaxInterrupts;
CachedPriorityMask = MmioRead32 (GicInterruptInterfaceBase + ARM_GIC_ICCPMR);
// Set priority Mask so that no interrupts get through to CPU
MmioWrite32 (GicInterruptInterfaceBase + ARM_GIC_ICCPMR, 0);
InterruptId = MmioRead32 (GicInterruptInterfaceBase + ARM_GIC_ICCIAR);
MaxInterrupts = ArmGicGetMaxNumInterrupts (GicDistributorBase);
// Only try to clear valid interrupts. Ignore spurious interrupts.
while ((InterruptId & 0x3FF) < MaxInterrupts) {
// Some of the SGI's are still pending, read Ack register and send End of Interrupt Signal
ArmGicEndOfInterrupt (GicInterruptInterfaceBase, InterruptId);
// Next
InterruptId = MmioRead32 (GicInterruptInterfaceBase + ARM_GIC_ICCIAR);
}
// Only the primary core should set the Non Secure bit to the SPIs (Shared Peripheral Interrupt).
if (ArmPlatformIsPrimaryCore (MpId)) {
// Ensure all GIC interrupts are Non-Secure
for (Index = 0; Index < (MaxInterrupts / 32); Index++) {
MmioWrite32 (GicDistributorBase + ARM_GIC_ICDISR + (Index * 4), 0xffffffff);
}
} else {
// The secondary cores only set the Non Secure bit to their banked PPIs
MmioWrite32 (GicDistributorBase + ARM_GIC_ICDISR, 0xffffffff);
}
// Ensure all interrupts can get through the priority mask
MmioWrite32 (GicInterruptInterfaceBase + ARM_GIC_ICCPMR, CachedPriorityMask);
}
VOID
EFIAPI
ArmGicV2EnableInterruptInterface (
IN INTN GicInterruptInterfaceBase
)
{
// Set Priority Mask to allow interrupts
MmioWrite32 (GicInterruptInterfaceBase + ARM_GIC_ICCPMR, 0x000000FF);
// Enable CPU interface in Secure world
// Enable CPU interface in Non-secure World
// Signal Secure Interrupts to CPU using FIQ line *
MmioWrite32 (GicInterruptInterfaceBase + ARM_GIC_ICCICR,
ARM_GIC_ICCICR_ENABLE_SECURE |
ARM_GIC_ICCICR_ENABLE_NS |
ARM_GIC_ICCICR_SIGNAL_SECURE_TO_FIQ);
}
VOID
EFIAPI
ArmGicV2DisableInterruptInterface (
IN INTN GicInterruptInterfaceBase
)
{
UINT32 ControlValue;
// Disable CPU interface in Secure world and Non-secure World
ControlValue = MmioRead32 (GicInterruptInterfaceBase + ARM_GIC_ICCICR);
MmioWrite32 (GicInterruptInterfaceBase + ARM_GIC_ICCICR, ControlValue & ~(ARM_GIC_ICCICR_ENABLE_SECURE | ARM_GIC_ICCICR_ENABLE_NS));
}

View File

@ -66,7 +66,7 @@ ASM_FUNC(ArmGicV3EndOfInterrupt)
// VOID
// );
ASM_FUNC(ArmGicV3AcknowledgeInterrupt)
mrc p15, 0, r0, c12, c12, 0 //ICC_IAR1
mrc p15, 0, r0, c12, c8, 0 //ICC_IAR1
bx lr
//VOID

View File

@ -66,7 +66,7 @@
// VOID
// );
RVCT_ASM_EXPORT ArmGicV3AcknowledgeInterrupt
mrc p15, 0, r0, c12, c12, 0 //ICC_IAR1
mrc p15, 0, r0, c12, c8, 0 //ICC_IAR1
bx lr
//VOID

View File

@ -1,6 +1,6 @@
/** @file
*
* Copyright (c) 2011-2017, ARM Limited. All rights reserved.
* Copyright (c) 2011-2016, ARM Limited. All rights reserved.
*
* This program and the accompanying materials
* are licensed and made available under the terms and conditions of the BSD License
@ -19,7 +19,6 @@
#define ARM_GIC_DEFAULT_PRIORITY 0x80
extern EFI_HARDWARE_INTERRUPT_PROTOCOL gHardwareInterruptV3Protocol;
extern EFI_HARDWARE_INTERRUPT2_PROTOCOL gHardwareInterrupt2V3Protocol;
STATIC UINTN mGicDistributorBase;
STATIC UINTN mGicRedistributorsBase;
@ -34,7 +33,6 @@ STATIC UINTN mGicRedistributorsBase;
@retval EFI_DEVICE_ERROR Hardware could not be programmed.
**/
STATIC
EFI_STATUS
EFIAPI
GicV3EnableInterruptSource (
@ -62,7 +60,6 @@ GicV3EnableInterruptSource (
@retval EFI_DEVICE_ERROR Hardware could not be programmed.
**/
STATIC
EFI_STATUS
EFIAPI
GicV3DisableInterruptSource (
@ -91,7 +88,6 @@ GicV3DisableInterruptSource (
@retval EFI_DEVICE_ERROR InterruptState is not valid
**/
STATIC
EFI_STATUS
EFIAPI
GicV3GetInterruptSourceState (
@ -105,11 +101,7 @@ GicV3GetInterruptSourceState (
return EFI_UNSUPPORTED;
}
*InterruptState = ArmGicIsInterruptEnabled (
mGicDistributorBase,
mGicRedistributorsBase,
Source
);
*InterruptState = ArmGicIsInterruptEnabled (mGicDistributorBase, mGicRedistributorsBase, Source);
return EFI_SUCCESS;
}
@ -125,7 +117,6 @@ GicV3GetInterruptSourceState (
@retval EFI_DEVICE_ERROR Hardware could not be programmed.
**/
STATIC
EFI_STATUS
EFIAPI
GicV3EndOfInterrupt (
@ -146,15 +137,13 @@ GicV3EndOfInterrupt (
EFI_CPU_INTERRUPT_HANDLER that is called when a processor interrupt occurs.
@param InterruptType Defines the type of interrupt or exception that
occurred on the processor. This parameter is
processor architecture specific.
occurred on the processor.This parameter is processor architecture specific.
@param SystemContext A pointer to the processor context when
the interrupt occurred on the processor.
@return None
**/
STATIC
VOID
EFIAPI
GicV3IrqInterruptHandler (
@ -179,12 +168,14 @@ GicV3IrqInterruptHandler (
// Call the registered interrupt handler.
InterruptHandler (GicInterrupt, SystemContext);
} else {
DEBUG ((DEBUG_ERROR, "Spurious GIC interrupt: 0x%x\n", GicInterrupt));
DEBUG ((EFI_D_ERROR, "Spurious GIC interrupt: 0x%x\n", GicInterrupt));
GicV3EndOfInterrupt (&gHardwareInterruptV3Protocol, GicInterrupt);
}
}
//
// The protocol instance produced by this driver
//
EFI_HARDWARE_INTERRUPT_PROTOCOL gHardwareInterruptV3Protocol = {
RegisterInterruptSource,
GicV3EnableInterruptSource,
@ -193,140 +184,6 @@ EFI_HARDWARE_INTERRUPT_PROTOCOL gHardwareInterruptV3Protocol = {
GicV3EndOfInterrupt
};
/**
Get interrupt trigger type of an interrupt
@param This Instance pointer for this protocol
@param Source Hardware source of the interrupt.
@param TriggerType Returns interrupt trigger type.
@retval EFI_SUCCESS Source interrupt supported.
@retval EFI_UNSUPPORTED Source interrupt is not supported.
**/
STATIC
EFI_STATUS
EFIAPI
GicV3GetTriggerType (
IN EFI_HARDWARE_INTERRUPT2_PROTOCOL *This,
IN HARDWARE_INTERRUPT_SOURCE Source,
OUT EFI_HARDWARE_INTERRUPT2_TRIGGER_TYPE *TriggerType
)
{
UINTN RegAddress;
UINTN Config1Bit;
EFI_STATUS Status;
Status = GicGetDistributorIcfgBaseAndBit (
Source,
&RegAddress,
&Config1Bit
);
if (EFI_ERROR (Status)) {
return Status;
}
if ((MmioRead32 (RegAddress) & (1 << Config1Bit)) == 0) {
*TriggerType = EFI_HARDWARE_INTERRUPT2_TRIGGER_LEVEL_HIGH;
} else {
*TriggerType = EFI_HARDWARE_INTERRUPT2_TRIGGER_EDGE_RISING;
}
return EFI_SUCCESS;
}
/**
Set interrupt trigger type of an interrupt
@param This Instance pointer for this protocol
@param Source Hardware source of the interrupt.
@param TriggerType Interrupt trigger type.
@retval EFI_SUCCESS Source interrupt supported.
@retval EFI_UNSUPPORTED Source interrupt is not supported.
**/
STATIC
EFI_STATUS
EFIAPI
GicV3SetTriggerType (
IN EFI_HARDWARE_INTERRUPT2_PROTOCOL *This,
IN HARDWARE_INTERRUPT_SOURCE Source,
IN EFI_HARDWARE_INTERRUPT2_TRIGGER_TYPE TriggerType
)
{
UINTN RegAddress;
UINTN Config1Bit;
UINT32 Value;
EFI_STATUS Status;
BOOLEAN SourceEnabled;
if ( (TriggerType != EFI_HARDWARE_INTERRUPT2_TRIGGER_EDGE_RISING)
&& (TriggerType != EFI_HARDWARE_INTERRUPT2_TRIGGER_LEVEL_HIGH)) {
DEBUG ((DEBUG_ERROR, "Invalid interrupt trigger type: %d\n", \
TriggerType));
ASSERT (FALSE);
return EFI_UNSUPPORTED;
}
Status = GicGetDistributorIcfgBaseAndBit (
Source,
&RegAddress,
&Config1Bit
);
if (EFI_ERROR (Status)) {
return Status;
}
Status = GicV3GetInterruptSourceState (
(EFI_HARDWARE_INTERRUPT_PROTOCOL*)This,
Source,
&SourceEnabled
);
if (EFI_ERROR (Status)) {
return Status;
}
Value = (TriggerType == EFI_HARDWARE_INTERRUPT2_TRIGGER_EDGE_RISING)
? ARM_GIC_ICDICFR_EDGE_TRIGGERED
: ARM_GIC_ICDICFR_LEVEL_TRIGGERED;
// Before changing the value, we must disable the interrupt,
// otherwise GIC behavior is UNPREDICTABLE.
if (SourceEnabled) {
GicV3DisableInterruptSource (
(EFI_HARDWARE_INTERRUPT_PROTOCOL*)This,
Source
);
}
MmioAndThenOr32 (
RegAddress,
~(0x1 << Config1Bit),
Value << Config1Bit
);
// Restore interrupt state
if (SourceEnabled) {
GicV3EnableInterruptSource (
(EFI_HARDWARE_INTERRUPT_PROTOCOL*)This,
Source
);
}
return EFI_SUCCESS;
}
EFI_HARDWARE_INTERRUPT2_PROTOCOL gHardwareInterrupt2V3Protocol = {
(HARDWARE_INTERRUPT2_REGISTER)RegisterInterruptSource,
(HARDWARE_INTERRUPT2_ENABLE)GicV3EnableInterruptSource,
(HARDWARE_INTERRUPT2_DISABLE)GicV3DisableInterruptSource,
(HARDWARE_INTERRUPT2_INTERRUPT_STATE)GicV3GetInterruptSourceState,
(HARDWARE_INTERRUPT2_END_OF_INTERRUPT)GicV3EndOfInterrupt,
GicV3GetTriggerType,
GicV3SetTriggerType
};
/**
Shutdown our hardware
@ -385,16 +242,17 @@ GicV3DxeInitialize (
UINT64 CpuTarget;
UINT64 MpId;
// Make sure the Interrupt Controller Protocol is not already installed in
// the system.
// Make sure the Interrupt Controller Protocol is not already installed in the system.
ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gHardwareInterruptProtocolGuid);
mGicDistributorBase = PcdGet64 (PcdGicDistributorBase);
mGicRedistributorsBase = PcdGet64 (PcdGicRedistributorsBase);
mGicNumInterrupts = ArmGicGetMaxNumInterrupts (mGicDistributorBase);
//
// We will be driving this GIC in native v3 mode, i.e., with Affinity
// Routing enabled. So ensure that the ARE bit is set.
//
if (!FeaturePcdGet (PcdArmGicV3WithV2Legacy)) {
MmioOr32 (mGicDistributorBase + ARM_GIC_ICDDCR, ARM_GIC_ICDDCR_ARE);
}
@ -412,65 +270,51 @@ GicV3DxeInitialize (
);
}
//
// Targets the interrupts to the Primary Cpu
//
if (FeaturePcdGet (PcdArmGicV3WithV2Legacy)) {
// Only Primary CPU will run this code. We can identify our GIC CPU ID by
// reading the GIC Distributor Target register. The 8 first
// GICD_ITARGETSRn are banked to each connected CPU. These 8 registers
// hold the CPU targets fields for interrupts 0-31. More Info in the GIC
// Specification about "Interrupt Processor Targets Registers"
// Read the first Interrupt Processor Targets Register (that corresponds
// to the 4 first SGIs)
// Only Primary CPU will run this code. We can identify our GIC CPU ID by reading
// the GIC Distributor Target register. The 8 first GICD_ITARGETSRn are banked to each
// connected CPU. These 8 registers hold the CPU targets fields for interrupts 0-31.
// More Info in the GIC Specification about "Interrupt Processor Targets Registers"
//
// Read the first Interrupt Processor Targets Register (that corresponds to the 4
// first SGIs)
CpuTarget = MmioRead32 (mGicDistributorBase + ARM_GIC_ICDIPTR);
// The CPU target is a bit field mapping each CPU to a GIC CPU Interface.
// This value is 0 when we run on a uniprocessor platform.
// The CPU target is a bit field mapping each CPU to a GIC CPU Interface. This value
// is 0 when we run on a uniprocessor platform.
if (CpuTarget != 0) {
// The 8 first Interrupt Processor Targets Registers are read-only
for (Index = 8; Index < (mGicNumInterrupts / 4); Index++) {
MmioWrite32 (
mGicDistributorBase + ARM_GIC_ICDIPTR + (Index * 4),
CpuTarget
);
MmioWrite32 (mGicDistributorBase + ARM_GIC_ICDIPTR + (Index * 4), CpuTarget);
}
}
} else {
MpId = ArmReadMpidr ();
CpuTarget = MpId &
(ARM_CORE_AFF0 | ARM_CORE_AFF1 | ARM_CORE_AFF2 | ARM_CORE_AFF3);
if ((MmioRead32 (
mGicDistributorBase + ARM_GIC_ICDDCR
) & ARM_GIC_ICDDCR_DS) != 0) {
CpuTarget = MpId & (ARM_CORE_AFF0 | ARM_CORE_AFF1 | ARM_CORE_AFF2 | ARM_CORE_AFF3);
if ((MmioRead32 (mGicDistributorBase + ARM_GIC_ICDDCR) & ARM_GIC_ICDDCR_DS) != 0) {
//
// If the Disable Security (DS) control bit is set, we are dealing with a
// GIC that has only one security state. In this case, let's assume we are
// executing in non-secure state (which is appropriate for DXE modules)
// and that no other firmware has performed any configuration on the GIC.
// This means we need to reconfigure all interrupts to non-secure Group 1
// first.
MmioWrite32 (
mGicRedistributorsBase + ARM_GICR_CTLR_FRAME_SIZE + ARM_GIC_ICDISR,
0xffffffff
);
//
MmioWrite32 (mGicRedistributorsBase + ARM_GICR_CTLR_FRAME_SIZE + ARM_GIC_ICDISR, 0xffffffff);
for (Index = 32; Index < mGicNumInterrupts; Index += 32) {
MmioWrite32 (
mGicDistributorBase + ARM_GIC_ICDISR + Index / 8,
0xffffffff
);
MmioWrite32 (mGicDistributorBase + ARM_GIC_ICDISR + Index / 8, 0xffffffff);
}
}
// Route the SPIs to the primary CPU. SPIs start at the INTID 32
for (Index = 0; Index < (mGicNumInterrupts - 32); Index++) {
MmioWrite32 (
mGicDistributorBase + ARM_GICD_IROUTER + (Index * 8),
CpuTarget
);
MmioWrite32 (mGicDistributorBase + ARM_GICD_IROUTER + (Index * 8), CpuTarget | ARM_GICD_IROUTER_IRM);
}
}
@ -487,11 +331,7 @@ GicV3DxeInitialize (
ArmGicEnableDistributor (mGicDistributorBase);
Status = InstallAndRegisterInterruptService (
&gHardwareInterruptV3Protocol,
&gHardwareInterrupt2V3Protocol,
GicV3IrqInterruptHandler,
GicV3ExitBootServicesEvent
);
&gHardwareInterruptV3Protocol, GicV3IrqInterruptHandler, GicV3ExitBootServicesEvent);
return Status;
}

View File

@ -1,46 +0,0 @@
/** @file
Copyright (c) 2017-2018, Arm Limited. All rights reserved.
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
System Control and Management Interface V1.0
http://infocenter.arm.com/help/topic/com.arm.doc.den0056a/
DEN0056A_System_Control_and_Management_Interface.pdf
**/
#ifndef ARM_SCMI_BASE_PROTOCOL_PRIVATE_H_
#define ARM_SCMI_BASE_PROTOCOL_PRIVATE_H_
// Return values of BASE_DISCOVER_LIST_PROTOCOLS command.
typedef struct {
UINT32 NumProtocols;
// Array of four protocols in each element
// Total elements = 1 + (NumProtocols-1)/4
// NOTE: Since EDK2 does not allow flexible array member [] we declare
// here array of 1 element length. However below is used as a variable
// length array.
UINT8 Protocols[1];
} BASE_DISCOVER_LIST;
/** Initialize Base protocol and install protocol on a given handle.
@param[in] Handle Handle to install Base protocol.
@retval EFI_SUCCESS Base protocol interface installed
successfully.
**/
EFI_STATUS
ScmiBaseProtocolInit (
IN OUT EFI_HANDLE* Handle
);
#endif /* ARM_SCMI_BASE_PROTOCOL_PRIVATE_H_ */

View File

@ -1,91 +0,0 @@
/** @file
Copyright (c) 2017-2018, Arm Limited. All rights reserved.
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
System Control and Management Interface V1.0
http://infocenter.arm.com/help/topic/com.arm.doc.den0056a/
DEN0056A_System_Control_and_Management_Interface.pdf
**/
#ifndef ARM_SCMI_CLOCK_PROTOCOL_PRIVATE_H_
#define ARM_SCMI_CLOCK_PROTOCOL_PRIVATE_H_
#pragma pack(1)
// Clock rate in two 32bit words.
typedef struct {
UINT32 Low;
UINT32 High;
} CLOCK_RATE_DWORD;
// Format of the returned rate array. Linear or Non-linear,.RatesFlag Bit[12]
#define RATE_FORMAT_SHIFT 12
#define RATE_FORMAT_MASK 0x0001
#define RATE_FORMAT(RatesFlags) ((RatesFlags >> RATE_FORMAT_SHIFT) \
& RATE_FORMAT_MASK)
// Number of remaining rates after a call to the SCP, RatesFlag Bits[31:16]
#define NUM_REMAIN_RATES_SHIFT 16
#define NUM_REMAIN_RATES(RatesFlags) ((RatesFlags >> NUM_REMAIN_RATES_SHIFT))
// Number of rates that are returned by a call.to the SCP, RatesFlag Bits[11:0]
#define NUM_RATES_MASK 0x0FFF
#define NUM_RATES(RatesFlags) (RatesFlags & NUM_RATES_MASK)
// Return values for the CLOCK_DESCRIBER_RATE command.
typedef struct {
UINT32 NumRatesFlags;
// NOTE: Since EDK2 does not allow flexible array member [] we declare
// here array of 1 element length. However below is used as a variable
// length array.
CLOCK_RATE_DWORD Rates[1];
} CLOCK_DESCRIBE_RATES;
#define CLOCK_SET_DEFAULT_FLAGS 0
// Message parameters for CLOCK_RATE_SET command.
typedef struct {
UINT32 Flags;
UINT32 ClockId;
CLOCK_RATE_DWORD Rate;
} CLOCK_RATE_SET_ATTRIBUTES;
// Message parameters for CLOCK_CONFIG_SET command.
typedef struct {
UINT32 ClockId;
UINT32 Attributes;
} CLOCK_CONFIG_SET_ATTRIBUTES;
// if ClockAttr Bit[0] is set then clock device is enabled.
#define CLOCK_ENABLE_MASK 0x1
#define CLOCK_ENABLED(ClockAttr) ((ClockAttr & CLOCK_ENABLE_MASK) == 1)
typedef struct {
UINT32 Attributes;
UINT8 ClockName[SCMI_MAX_STR_LEN];
} CLOCK_ATTRIBUTES;
#pragma pack()
/** Initialize clock management protocol and install protocol on a given handle.
@param[in] Handle Handle to install clock management protocol.
@retval EFI_SUCCESS Clock protocol interface installed successfully.
**/
EFI_STATUS
ScmiClockProtocolInit (
IN EFI_HANDLE *Handle
);
#endif /* ARM_SCMI_CLOCK_PROTOCOL_PRIVATE_H_ */

View File

@ -1,54 +0,0 @@
#/** @file
#
# Copyright (c) 2017-2018, Arm Limited. All rights reserved.
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
# System Control and Management Interface V1.0
# http://infocenter.arm.com/help/topic/com.arm.doc.den0056a/
# DEN0056A_System_Control_and_Management_Interface.pdf
#**/
[Defines]
INF_VERSION = 0x00010019
BASE_NAME = ArmScmiDxe
FILE_GUID = 9585984C-F027-45E9-AFDF-ADAA6DFAAAC7
MODULE_TYPE = DXE_DRIVER
VERSION_STRING = 1.0
ENTRY_POINT = ArmScmiDxeEntryPoint
[Sources.common]
Scmi.c
ScmiBaseProtocol.c
ScmiClockProtocol.c
ScmiDxe.c
ScmiPerformanceProtocol.c
[Packages]
ArmPkg/ArmPkg.dec
ArmPlatformPkg/ArmPlatformPkg.dec
MdePkg/MdePkg.dec
[LibraryClasses]
ArmLib
ArmMtlLib
DebugLib
IoLib
UefiBootServicesTableLib
UefiDriverEntryPoint
[Protocols]
gArmScmiBaseProtocolGuid
gArmScmiClockProtocolGuid
gArmScmiClock2ProtocolGuid
gArmScmiPerformanceProtocolGuid
[Depex]
TRUE

View File

@ -1,55 +0,0 @@
/** @file
Copyright (c) 2017-2018, Arm Limited. All rights reserved.
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
System Control and Management Interface V1.0
http://infocenter.arm.com/help/topic/com.arm.doc.den0056a/
DEN0056A_System_Control_and_Management_Interface.pdf
**/
#ifndef ARM_SCMI_PERFORMANCE_PROTOCOL_PRIVATE_H_
#define ARM_SCMI_PERFORMANCE_PROTOCOL_PRIVATE_H_
#include <Protocol/ArmScmiPerformanceProtocol.h>
// Number of performance levels returned by a call to the SCP, Lvls Bits[11:0]
#define NUM_PERF_LEVELS_MASK 0x0FFF
#define NUM_PERF_LEVELS(Lvls) (Lvls & NUM_PERF_LEVELS_MASK)
// Number of performance levels remaining after a call to the SCP, Lvls Bits[31:16]
#define NUM_REMAIN_PERF_LEVELS_SHIFT 16
#define NUM_REMAIN_PERF_LEVELS(Lvls) (Lvls >> NUM_REMAIN_PERF_LEVELS_SHIFT)
/** Return values for SCMI_MESSAGE_ID_PERFORMANCE_DESCRIBE_LEVELS command.
SCMI Spec <20> 4.5.2.5
**/
typedef struct {
UINT32 NumLevels;
// NOTE: Since EDK2 does not allow flexible array member [] we declare
// here array of 1 element length. However below is used as a variable
// length array.
SCMI_PERFORMANCE_LEVEL PerfLevel[1]; // Offset to array of performance levels
} PERF_DESCRIBE_LEVELS;
/** Initialize performance management protocol and install on a given Handle.
@param[in] Handle Handle to install performance management
protocol.
@retval EFI_SUCCESS Performance protocol installed successfully.
**/
EFI_STATUS
ScmiPerformanceProtocolInit (
IN EFI_HANDLE* Handle
);
#endif /* ARM_SCMI_PERFORMANCE_PROTOCOL_PRIVATE_H_ */

View File

@ -1,257 +0,0 @@
/** @file
Copyright (c) 2017-2018, Arm Limited. All rights reserved.
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
System Control and Management Interface V1.0
http://infocenter.arm.com/help/topic/com.arm.doc.den0056a/
DEN0056A_System_Control_and_Management_Interface.pdf
**/
#include <Library/ArmMtlLib.h>
#include <Library/DebugLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include "ScmiPrivate.h"
// Arbitrary timeout value 20ms.
#define RESPONSE_TIMEOUT 20000
/** Return a pointer to the message payload.
@param[out] Payload Holds pointer to the message payload.
@retval EFI_SUCCESS Payload holds a valid message payload pointer.
@retval EFI_TIMEOUT Time out error if MTL channel is busy.
@retval EFI_UNSUPPORTED If MTL channel is unsupported.
**/
EFI_STATUS
ScmiCommandGetPayload (
OUT UINT32** Payload
)
{
EFI_STATUS Status;
MTL_CHANNEL *Channel;
// Get handle to the Channel.
Status = MtlGetChannel (MTL_CHANNEL_TYPE_LOW, &Channel);
if (EFI_ERROR (Status)) {
return Status;
}
// Payload will not be populated until channel is free.
Status = MtlWaitUntilChannelFree (Channel, RESPONSE_TIMEOUT);
if (EFI_ERROR (Status)) {
return Status;
}
// Get the address of the payload.
*Payload = MtlGetChannelPayload (Channel);
return EFI_SUCCESS;
}
/** Execute a SCMI command and receive a response.
This function uses a MTL channel to transfer message to SCP
and waits for a response.
@param[in] Command Pointer to the SCMI command (Protocol ID
and Message ID)
@param[in,out] PayloadLength SCMI command message length.
@param[out] OPTIONAL ReturnValues Pointer to SCMI response.
@retval OUT EFI_SUCCESS Command sent and message received successfully.
@retval OUT EFI_UNSUPPORTED Channel not supported.
@retval OUT EFI_TIMEOUT Timeout on the channel.
@retval OUT EFI_DEVICE_ERROR Channel not ready.
@retval OUT EFI_DEVICE_ERROR Message Header corrupted.
@retval OUT EFI_DEVICE_ERROR SCMI error.
**/
EFI_STATUS
ScmiCommandExecute (
IN SCMI_COMMAND *Command,
IN OUT UINT32 *PayloadLength,
OUT UINT32 **ReturnValues OPTIONAL
)
{
EFI_STATUS Status;
SCMI_MESSAGE_RESPONSE *Response;
UINT32 MessageHeader;
UINT32 ResponseHeader;
MTL_CHANNEL *Channel;
ASSERT (PayloadLength != NULL);
Status = MtlGetChannel (MTL_CHANNEL_TYPE_LOW, &Channel);
if (EFI_ERROR (Status)) {
return Status;
}
// Fill in message header.
MessageHeader = SCMI_MESSAGE_HEADER (
Command->MessageId,
SCMI_MESSAGE_TYPE_COMMAND,
Command->ProtocolId
);
// Send payload using MTL channel.
Status = MtlSendMessage (
Channel,
MessageHeader,
*PayloadLength
);
if (EFI_ERROR (Status)) {
return Status;
}
// Wait for the response on the channel.
Status = MtlReceiveMessage (Channel, &ResponseHeader, PayloadLength);
if (EFI_ERROR (Status)) {
return Status;
}
// SCMI must return MessageHeader unmodified.
if (MessageHeader != ResponseHeader) {
ASSERT (FALSE);
return EFI_DEVICE_ERROR;
}
Response = (SCMI_MESSAGE_RESPONSE*)MtlGetChannelPayload (Channel);
if (Response->Status != SCMI_SUCCESS) {
DEBUG ((DEBUG_ERROR, "SCMI error: ProtocolId = 0x%x, MessageId = 0x%x, error = %d\n",
Command->ProtocolId,
Command->MessageId,
Response->Status
));
ASSERT (FALSE);
return EFI_DEVICE_ERROR;
}
if (ReturnValues != NULL) {
*ReturnValues = Response->ReturnValues;
}
return EFI_SUCCESS;
}
/** Internal common function useful for common protocol discovery messages.
@param[in] ProtocolId Protocol Id of the the protocol.
@param[in] MesaageId Message Id of the message.
@param[out] ReturnValues SCMI response return values.
@retval EFI_SUCCESS Success with valid return values.
@retval EFI_DEVICE_ERROR SCMI error.
@retval !(EFI_SUCCESS) Other errors.
**/
STATIC
EFI_STATUS
ScmiProtocolDiscoveryCommon (
IN SCMI_PROTOCOL_ID ProtocolId,
IN SCMI_MESSAGE_ID MessageId,
OUT UINT32 **ReturnValues
)
{
SCMI_COMMAND Command;
UINT32 PayloadLength = 0;
Command.ProtocolId = ProtocolId;
Command.MessageId = MessageId;
return ScmiCommandExecute (
&Command,
&PayloadLength,
ReturnValues
);
}
/** Return protocol version from SCP for a given protocol ID.
@param[in] Protocol ID Protocol ID.
@param[out] Version Pointer to version of the protocol.
@retval EFI_SUCCESS Version holds a valid version received
from the SCP.
@retval EFI_DEVICE_ERROR SCMI error.
@retval !(EFI_SUCCESS) Other errors.
**/
EFI_STATUS
ScmiGetProtocolVersion (
IN SCMI_PROTOCOL_ID ProtocolId,
OUT UINT32 *Version
)
{
EFI_STATUS Status;
UINT32 *ProtocolVersion;
Status = ScmiProtocolDiscoveryCommon (
ProtocolId,
SCMI_MESSAGE_ID_PROTOCOL_VERSION,
(UINT32**)&ProtocolVersion
);
if (EFI_ERROR (Status)) {
return Status;
}
*Version = *ProtocolVersion;
return EFI_SUCCESS;
}
/** Return protocol attributes from SCP for a given protocol ID.
@param[in] Protocol ID Protocol ID.
@param[out] ReturnValues Pointer to attributes of the protocol.
@retval EFI_SUCCESS ReturnValues points to protocol attributes.
@retval EFI_DEVICE_ERROR SCMI error.
@retval !(EFI_SUCCESS) Other errors.
**/
EFI_STATUS
ScmiGetProtocolAttributes (
IN SCMI_PROTOCOL_ID ProtocolId,
OUT UINT32 **ReturnValues
)
{
return ScmiProtocolDiscoveryCommon (
ProtocolId,
SCMI_MESSAGE_ID_PROTOCOL_ATTRIBUTES,
ReturnValues
);
}
/** Return protocol message attributes from SCP for a given protocol ID.
@param[in] Protocol ID Protocol ID.
@param[out] Attributes Pointer to attributes of the protocol.
@retval EFI_SUCCESS ReturnValues points to protocol message attributes.
@retval EFI_DEVICE_ERROR SCMI error.
@retval !(EFI_SUCCESS) Other errors.
**/
EFI_STATUS
ScmiGetProtocolMessageAttributes (
IN SCMI_PROTOCOL_ID ProtocolId,
OUT UINT32 **ReturnValues
)
{
return ScmiProtocolDiscoveryCommon (
ProtocolId,
SCMI_MESSAGE_ID_PROTOCOL_MESSAGE_ATTRIBUTES,
ReturnValues
);
}

View File

@ -1,318 +0,0 @@
/** @file
Copyright (c) 2017-2018, Arm Limited. All rights reserved.
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
System Control and Management Interface V1.0
http://infocenter.arm.com/help/topic/com.arm.doc.den0056a/
DEN0056A_System_Control_and_Management_Interface.pdf
**/
#include <Library/BaseLib.h>
#include <Library/DebugLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Protocol/ArmScmiBaseProtocol.h>
#include "ArmScmiBaseProtocolPrivate.h"
#include "ScmiPrivate.h"
/** Return version of the Base protocol supported by SCP firmware.
@param[in] This A Pointer to SCMI_BASE_PROTOCOL Instance.
@param[out] Version Version of the supported SCMI Base protocol.
@retval EFI_SUCCESS The version of the protocol is returned.
@retval EFI_DEVICE_ERROR SCP returns an SCMI error.
@retval !(EFI_SUCCESS) Other errors.
**/
STATIC
EFI_STATUS
BaseGetVersion (
IN SCMI_BASE_PROTOCOL *This,
OUT UINT32 *Version
)
{
return ScmiGetProtocolVersion (SCMI_PROTOCOL_ID_BASE, Version);
}
/** Return total number of SCMI protocols supported by the SCP firmware.
@param[in] This A Pointer to SCMI_BASE_PROTOCOL Instance.
@param[out] TotalProtocols Total number of SCMI protocols supported.
@retval EFI_SUCCESS Total number of protocols supported are returned.
@retval EFI_DEVICE_ERROR SCP returns a SCMI error.
@retval !(EFI_SUCCESS) Other errors.
**/
STATIC
EFI_STATUS
BaseGetTotalProtocols (
IN SCMI_BASE_PROTOCOL *This,
OUT UINT32 *TotalProtocols
)
{
EFI_STATUS Status;
UINT32 *ReturnValues;
Status = ScmiGetProtocolAttributes (SCMI_PROTOCOL_ID_BASE, &ReturnValues);
if (EFI_ERROR (Status)) {
return Status;
}
*TotalProtocols = SCMI_TOTAL_PROTOCOLS (ReturnValues[0]);
return EFI_SUCCESS;
}
/** Common function which returns vendor details.
@param[in] MessageId SCMI_MESSAGE_ID_BASE_DISCOVER_VENDOR
OR
SCMI_MESSAGE_ID_BASE_DISCOVER_SUB_VENDOR
@param[out] VendorIdentifier ASCII name of the vendor/subvendor.
@retval EFI_SUCCESS VendorIdentifier is returned.
@retval EFI_DEVICE_ERROR SCP returns an SCMI error.
@retval !(EFI_SUCCESS) Other errors.
**/
STATIC
EFI_STATUS
BaseDiscoverVendorDetails (
IN SCMI_MESSAGE_ID_BASE MessageId,
OUT UINT8 VendorIdentifier[SCMI_MAX_STR_LEN]
)
{
EFI_STATUS Status;
UINT32 *ReturnValues;
SCMI_COMMAND Cmd;
UINT32 PayloadLength;
Cmd.ProtocolId = SCMI_PROTOCOL_ID_BASE;
Cmd.MessageId = MessageId;
PayloadLength = 0;
Status = ScmiCommandExecute (
&Cmd,
&PayloadLength,
&ReturnValues
);
if (EFI_ERROR (Status)) {
return Status;
}
AsciiStrCpyS (
(CHAR8*)VendorIdentifier,
SCMI_MAX_STR_LEN,
(CONST CHAR8*)ReturnValues
);
return EFI_SUCCESS;
}
/** Return vendor name.
@param[in] This A Pointer to SCMI_BASE_PROTOCOL Instance.
@param[out] VendorIdentifier Null terminated ASCII string of up to
16 bytes with a vendor name.
@retval EFI_SUCCESS VendorIdentifier is returned.
@retval EFI_DEVICE_ERROR SCP returns a SCMI error.
@retval !(EFI_SUCCESS) Other errors.
**/
STATIC
EFI_STATUS
BaseDiscoverVendor (
IN SCMI_BASE_PROTOCOL *This,
OUT UINT8 VendorIdentifier[SCMI_MAX_STR_LEN]
)
{
return BaseDiscoverVendorDetails (
SCMI_MESSAGE_ID_BASE_DISCOVER_VENDOR,
VendorIdentifier
);
}
/** Return sub vendor name.
@param[in] This A Pointer to SCMI_BASE_PROTOCOL Instance.
@param[out] VendorIdentifier Null terminated ASCII string of up to
16 bytes with a sub vendor name.
@retval EFI_SUCCESS VendorIdentifier is returned.
@retval EFI_DEVICE_ERROR SCP returns a SCMI error.
@retval !(EFI_SUCCESS) Other errors.
**/
EFI_STATUS
BaseDiscoverSubVendor (
IN SCMI_BASE_PROTOCOL *This,
OUT UINT8 VendorIdentifier[SCMI_MAX_STR_LEN]
)
{
return BaseDiscoverVendorDetails (
SCMI_MESSAGE_ID_BASE_DISCOVER_SUB_VENDOR,
VendorIdentifier
);
}
/** Return implementation version.
@param[in] This A Pointer to SCMI_BASE_PROTOCOL Instance.
@param[out] ImplementationVersion Vendor specific implementation version.
@retval EFI_SUCCESS Implementation version is returned.
@retval EFI_DEVICE_ERROR SCP returns a SCMI error.
@retval !(EFI_SUCCESS) Other errors.
**/
STATIC
EFI_STATUS
BaseDiscoverImplVersion (
IN SCMI_BASE_PROTOCOL *This,
OUT UINT32 *ImplementationVersion
)
{
EFI_STATUS Status;
UINT32 *ReturnValues;
SCMI_COMMAND Cmd;
UINT32 PayloadLength;
Cmd.ProtocolId = SCMI_PROTOCOL_ID_BASE;
Cmd.MessageId = SCMI_MESSAGE_ID_BASE_DISCOVER_IMPLEMENTATION_VERSION;
PayloadLength = 0;
Status = ScmiCommandExecute (
&Cmd,
&PayloadLength,
&ReturnValues
);
if (EFI_ERROR (Status)) {
return Status;
}
*ImplementationVersion = ReturnValues[0];
return EFI_SUCCESS;
}
/** Return list of protocols.
@param[in] This A Pointer to SCMI_BASE_PROTOCOL Instance.
@param[out] ProtocolListSize Size of the ProtocolList.
@param[out] ProtocolList Protocol list.
@retval EFI_SUCCESS List of protocols is returned.
@retval EFI_BUFFER_TOO_SMALL ProtocolListSize is too small for the result.
It has been updated to the size needed.
@retval EFI_DEVICE_ERROR SCP returns a SCMI error.
@retval !(EFI_SUCCESS) Other errors.
**/
STATIC
EFI_STATUS
BaseDiscoverListProtocols (
IN SCMI_BASE_PROTOCOL *This,
IN OUT UINT32 *ProtocolListSize,
OUT UINT8 *ProtocolList
)
{
EFI_STATUS Status;
UINT32 TotalProtocols;
UINT32 *MessageParams;
BASE_DISCOVER_LIST *DiscoverList;
UINT32 Skip;
UINT32 Index;
SCMI_COMMAND Cmd;
UINT32 PayloadLength;
UINT32 RequiredSize;
Status = BaseGetTotalProtocols (This, &TotalProtocols);
if (EFI_ERROR (Status)) {
return Status;
}
Status = ScmiCommandGetPayload (&MessageParams);
if (EFI_ERROR (Status)) {
return Status;
}
RequiredSize = sizeof (UINT8) * TotalProtocols;
if (*ProtocolListSize < RequiredSize) {
*ProtocolListSize = RequiredSize;
return EFI_BUFFER_TOO_SMALL;
}
Cmd.ProtocolId = SCMI_PROTOCOL_ID_BASE;
Cmd.MessageId = SCMI_MESSAGE_ID_BASE_DISCOVER_LIST_PROTOCOLS;
Skip = 0;
while (Skip < TotalProtocols) {
*MessageParams = Skip;
// Note PayloadLength is a IN/OUT parameter.
PayloadLength = sizeof (Skip);
Status = ScmiCommandExecute (
&Cmd,
&PayloadLength,
(UINT32**)&DiscoverList
);
if (EFI_ERROR (Status)) {
return Status;
}
for (Index = 0; Index < DiscoverList->NumProtocols; Index++) {
ProtocolList[Skip++] = DiscoverList->Protocols[Index];
}
}
*ProtocolListSize = RequiredSize;
return EFI_SUCCESS;
}
// Instance of the SCMI Base protocol.
STATIC CONST SCMI_BASE_PROTOCOL BaseProtocol = {
BaseGetVersion,
BaseGetTotalProtocols,
BaseDiscoverVendor,
BaseDiscoverSubVendor,
BaseDiscoverImplVersion,
BaseDiscoverListProtocols
};
/** Initialize Base protocol and install protocol on a given handle.
@param[in] Handle Handle to install Base protocol.
@retval EFI_SUCCESS Base protocol interface installed
successfully.
**/
EFI_STATUS
ScmiBaseProtocolInit (
IN OUT EFI_HANDLE* Handle
)
{
return gBS->InstallMultipleProtocolInterfaces (
Handle,
&gArmScmiBaseProtocolGuid,
&BaseProtocol,
NULL
);
}

View File

@ -1,480 +0,0 @@
/** @file
Copyright (c) 2017-2018, Arm Limited. All rights reserved.
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
System Control and Management Interface V1.0
http://infocenter.arm.com/help/topic/com.arm.doc.den0056a/
DEN0056A_System_Control_and_Management_Interface.pdf
**/
#include <Library/BaseLib.h>
#include <Library/DebugLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Protocol/ArmScmiClockProtocol.h>
#include <Protocol/ArmScmiClock2Protocol.h>
#include "ArmScmiClockProtocolPrivate.h"
#include "ScmiPrivate.h"
/** Convert to 64 bit value from two 32 bit words.
@param[in] Low Lower 32 bits.
@param[in] High Higher 32 bits.
@retval UINT64 64 bit value.
**/
STATIC
UINT64
ConvertTo64Bit (
IN UINT32 Low,
IN UINT32 High
)
{
return (Low | ((UINT64)High << 32));
}
/** Return version of the clock management protocol supported by SCP firmware.
@param[in] This A Pointer to SCMI_CLOCK_PROTOCOL Instance.
@param[out] Version Version of the supported SCMI Clock management protocol.
@retval EFI_SUCCESS The version is returned.
@retval EFI_DEVICE_ERROR SCP returns an SCMI error.
@retval !(EFI_SUCCESS) Other errors.
**/
STATIC
EFI_STATUS
ClockGetVersion (
IN SCMI_CLOCK_PROTOCOL *This,
OUT UINT32 *Version
)
{
return ScmiGetProtocolVersion (SCMI_PROTOCOL_ID_CLOCK, Version);
}
/** Return total number of clock devices supported by the clock management
protocol.
@param[in] This A Pointer to SCMI_CLOCK_PROTOCOL Instance.
@param[out] TotalClocks Total number of clocks supported.
@retval EFI_SUCCESS Total number of clocks supported is returned.
@retval EFI_DEVICE_ERROR SCP returns an SCMI error.
@retval !(EFI_SUCCESS) Other errors.
**/
STATIC
EFI_STATUS
ClockGetTotalClocks (
IN SCMI_CLOCK_PROTOCOL *This,
OUT UINT32 *TotalClocks
)
{
EFI_STATUS Status;
UINT32 *ReturnValues;
Status = ScmiGetProtocolAttributes (SCMI_PROTOCOL_ID_CLOCK, &ReturnValues);
if (EFI_ERROR (Status)) {
return Status;
}
*TotalClocks = SCMI_CLOCK_PROTOCOL_TOTAL_CLKS (ReturnValues[0]);
return EFI_SUCCESS;
}
/** Return attributes of a clock device.
@param[in] This A Pointer to SCMI_CLOCK_PROTOCOL Instance.
@param[in] ClockId Identifier for the clock device.
@param[out] Enabled If TRUE, the clock device is enabled.
@param[out] ClockAsciiName A NULL terminated ASCII string with the clock
name, of up to 16 bytes.
@retval EFI_SUCCESS Clock device attributes are returned.
@retval EFI_DEVICE_ERROR SCP returns an SCMI error.
@retval !(EFI_SUCCESS) Other errors.
**/
STATIC
EFI_STATUS
ClockGetClockAttributes (
IN SCMI_CLOCK_PROTOCOL *This,
IN UINT32 ClockId,
OUT BOOLEAN *Enabled,
OUT CHAR8 *ClockAsciiName
)
{
EFI_STATUS Status;
UINT32 *MessageParams;
CLOCK_ATTRIBUTES *ClockAttributes;
SCMI_COMMAND Cmd;
UINT32 PayloadLength;
Status = ScmiCommandGetPayload (&MessageParams);
if (EFI_ERROR (Status)) {
return Status;
}
*MessageParams = ClockId;
Cmd.ProtocolId = SCMI_PROTOCOL_ID_CLOCK;
Cmd.MessageId = SCMI_MESSAGE_ID_CLOCK_ATTRIBUTES;
PayloadLength = sizeof (ClockId);
Status = ScmiCommandExecute (
&Cmd,
&PayloadLength,
(UINT32**)&ClockAttributes
);
if (EFI_ERROR (Status)) {
return Status;
}
// TRUE if bit 0 of ClockAttributes->Attributes is set.
*Enabled = CLOCK_ENABLED (ClockAttributes->Attributes);
AsciiStrCpyS (
ClockAsciiName,
SCMI_MAX_STR_LEN,
(CONST CHAR8*)ClockAttributes->ClockName
);
return EFI_SUCCESS;
}
/** Return list of rates supported by a given clock device.
@param[in] This A pointer to SCMI_CLOCK_PROTOCOL Instance.
@param[in] ClockId Identifier for the clock device.
@param[out] Format SCMI_CLOCK_RATE_FORMAT_DISCRETE: Clock device
supports range of clock rates which are non-linear.
SCMI_CLOCK_RATE_FORMAT_LINEAR: Clock device supports
range of linear clock rates from Min to Max in steps.
@param[out] TotalRates Total number of rates.
@param[in,out] RateArraySize Size of the RateArray.
@param[out] RateArray List of clock rates.
@retval EFI_SUCCESS List of clock rates is returned.
@retval EFI_DEVICE_ERROR SCP returns an SCMI error.
@retval EFI_BUFFER_TOO_SMALL RateArraySize is too small for the result.
It has been updated to the size needed.
@retval !(EFI_SUCCESS) Other errors.
**/
STATIC
EFI_STATUS
ClockDescribeRates (
IN SCMI_CLOCK_PROTOCOL *This,
IN UINT32 ClockId,
OUT SCMI_CLOCK_RATE_FORMAT *Format,
OUT UINT32 *TotalRates,
IN OUT UINT32 *RateArraySize,
OUT SCMI_CLOCK_RATE *RateArray
)
{
EFI_STATUS Status;
UINT32 PayloadLength;
SCMI_COMMAND Cmd;
UINT32 *MessageParams;
CLOCK_DESCRIBE_RATES *DescribeRates;
CLOCK_RATE_DWORD *Rate;
UINT32 RequiredArraySize = 0;
UINT32 RateIndex = 0;
UINT32 RateNo;
UINT32 RateOffset;
*TotalRates = 0;
Status = ScmiCommandGetPayload (&MessageParams);
if (EFI_ERROR (Status)) {
return Status;
}
Cmd.ProtocolId = SCMI_PROTOCOL_ID_CLOCK;
Cmd.MessageId = SCMI_MESSAGE_ID_CLOCK_DESCRIBE_RATES;
*MessageParams++ = ClockId;
do {
*MessageParams = RateIndex;
// Set Payload length, note PayloadLength is a IN/OUT parameter.
PayloadLength = sizeof (ClockId) + sizeof (RateIndex);
// Execute and wait for response on a SCMI channel.
Status = ScmiCommandExecute (
&Cmd,
&PayloadLength,
(UINT32**)&DescribeRates
);
if (EFI_ERROR (Status)) {
return Status;
}
if (*TotalRates == 0) {
// In the first iteration we will get number of returned rates and number
// of remaining rates. With this information calculate required size
// for rate array. If provided RateArraySize is less, return an
// error.
*Format = RATE_FORMAT (DescribeRates->NumRatesFlags);
*TotalRates = NUM_RATES (DescribeRates->NumRatesFlags)
+ NUM_REMAIN_RATES (DescribeRates->NumRatesFlags);
if (*Format == SCMI_CLOCK_RATE_FORMAT_DISCRETE) {
RequiredArraySize = (*TotalRates) * sizeof (UINT64);
} else {
// We need to return triplet of 64 bit value for each rate
RequiredArraySize = (*TotalRates) * 3 * sizeof (UINT64);
}
if (RequiredArraySize > (*RateArraySize)) {
*RateArraySize = RequiredArraySize;
return EFI_BUFFER_TOO_SMALL;
}
}
RateOffset = 0;
if (*Format == SCMI_CLOCK_RATE_FORMAT_DISCRETE) {
for (RateNo = 0; RateNo < NUM_RATES (DescribeRates->NumRatesFlags); RateNo++) {
Rate = &DescribeRates->Rates[RateOffset++];
// Non-linear discrete rates.
RateArray[RateIndex++].Rate = ConvertTo64Bit (Rate->Low, Rate->High);
}
} else {
for (RateNo = 0; RateNo < NUM_RATES (DescribeRates->NumRatesFlags); RateNo++) {
// Linear clock rates from minimum to maximum in steps
// Minimum clock rate.
Rate = &DescribeRates->Rates[RateOffset++];
RateArray[RateIndex].Min = ConvertTo64Bit (Rate->Low, Rate->High);
Rate = &DescribeRates->Rates[RateOffset++];
// Maximum clock rate.
RateArray[RateIndex].Max = ConvertTo64Bit (Rate->Low, Rate->High);
Rate = &DescribeRates->Rates[RateOffset++];
// Step.
RateArray[RateIndex++].Step = ConvertTo64Bit (Rate->Low, Rate->High);
}
}
} while (NUM_REMAIN_RATES (DescribeRates->NumRatesFlags) != 0);
// Update RateArraySize with RequiredArraySize.
*RateArraySize = RequiredArraySize;
return EFI_SUCCESS;
}
/** Get clock rate.
@param[in] This A Pointer to SCMI_CLOCK_PROTOCOL Instance.
@param[in] ClockId Identifier for the clock device.
@param[out] Rate Clock rate.
@retval EFI_SUCCESS Clock rate is returned.
@retval EFI_DEVICE_ERROR SCP returns an SCMI error.
@retval !(EFI_SUCCESS) Other errors.
**/
STATIC
EFI_STATUS
ClockRateGet (
IN SCMI_CLOCK_PROTOCOL *This,
IN UINT32 ClockId,
OUT UINT64 *Rate
)
{
EFI_STATUS Status;
UINT32 *MessageParams;
CLOCK_RATE_DWORD *ClockRate;
SCMI_COMMAND Cmd;
UINT32 PayloadLength;
Status = ScmiCommandGetPayload (&MessageParams);
if (EFI_ERROR (Status)) {
return Status;
}
// Fill arguments for clock protocol command.
*MessageParams = ClockId;
Cmd.ProtocolId = SCMI_PROTOCOL_ID_CLOCK;
Cmd.MessageId = SCMI_MESSAGE_ID_CLOCK_RATE_GET;
PayloadLength = sizeof (ClockId);
// Execute and wait for response on a SCMI channel.
Status = ScmiCommandExecute (
&Cmd,
&PayloadLength,
(UINT32**)&ClockRate
);
if (EFI_ERROR (Status)) {
return Status;
}
*Rate = ConvertTo64Bit (ClockRate->Low, ClockRate->High);
return EFI_SUCCESS;
}
/** Set clock rate.
@param[in] This A Pointer to SCMI_CLOCK_PROTOCOL Instance.
@param[in] ClockId Identifier for the clock device.
@param[in] Rate Clock rate.
@retval EFI_SUCCESS Clock rate set success.
@retval EFI_DEVICE_ERROR SCP returns an SCMI error.
@retval !(EFI_SUCCESS) Other errors.
**/
STATIC
EFI_STATUS
ClockRateSet (
IN SCMI_CLOCK_PROTOCOL *This,
IN UINT32 ClockId,
IN UINT64 Rate
)
{
EFI_STATUS Status;
CLOCK_RATE_SET_ATTRIBUTES *ClockRateSetAttributes;
SCMI_COMMAND Cmd;
UINT32 PayloadLength;
Status = ScmiCommandGetPayload ((UINT32**)&ClockRateSetAttributes);
if (EFI_ERROR (Status)) {
return Status;
}
// Fill arguments for clock protocol command.
ClockRateSetAttributes->ClockId = ClockId;
ClockRateSetAttributes->Flags = CLOCK_SET_DEFAULT_FLAGS;
ClockRateSetAttributes->Rate.Low = (UINT32)Rate;
ClockRateSetAttributes->Rate.High = (UINT32)(Rate >> 32);
Cmd.ProtocolId = SCMI_PROTOCOL_ID_CLOCK;
Cmd.MessageId = SCMI_MESSAGE_ID_CLOCK_RATE_SET;
PayloadLength = sizeof (CLOCK_RATE_SET_ATTRIBUTES);
// Execute and wait for response on a SCMI channel.
Status = ScmiCommandExecute (
&Cmd,
&PayloadLength,
NULL
);
return Status;
}
/** Enable/Disable specified clock.
@param[in] This A Pointer to SCMI_CLOCK_PROTOCOL Instance.
@param[in] ClockId Identifier for the clock device.
@param[in] Enable TRUE to enable, FALSE to disable.
@retval EFI_SUCCESS Clock enable/disable successful.
@retval EFI_DEVICE_ERROR SCP returns an SCMI error.
@retval !(EFI_SUCCESS) Other errors.
**/
STATIC
EFI_STATUS
ClockEnable (
IN SCMI_CLOCK2_PROTOCOL *This,
IN UINT32 ClockId,
IN BOOLEAN Enable
)
{
EFI_STATUS Status;
CLOCK_CONFIG_SET_ATTRIBUTES *ClockConfigSetAttributes;
SCMI_COMMAND Cmd;
UINT32 PayloadLength;
Status = ScmiCommandGetPayload ((UINT32**)&ClockConfigSetAttributes);
if (EFI_ERROR (Status)) {
return Status;
}
// Fill arguments for clock protocol command.
ClockConfigSetAttributes->ClockId = ClockId;
ClockConfigSetAttributes->Attributes = Enable ? BIT0 : 0;
Cmd.ProtocolId = SCMI_PROTOCOL_ID_CLOCK;
Cmd.MessageId = SCMI_MESSAGE_ID_CLOCK_CONFIG_SET;
PayloadLength = sizeof (CLOCK_CONFIG_SET_ATTRIBUTES);
// Execute and wait for response on a SCMI channel.
Status = ScmiCommandExecute (
&Cmd,
&PayloadLength,
NULL
);
return Status;
}
// Instance of the SCMI clock management protocol.
STATIC CONST SCMI_CLOCK_PROTOCOL ScmiClockProtocol = {
ClockGetVersion,
ClockGetTotalClocks,
ClockGetClockAttributes,
ClockDescribeRates,
ClockRateGet,
ClockRateSet
};
// Instance of the SCMI clock management protocol.
STATIC CONST SCMI_CLOCK2_PROTOCOL ScmiClock2Protocol = {
(SCMI_CLOCK2_GET_VERSION)ClockGetVersion,
(SCMI_CLOCK2_GET_TOTAL_CLOCKS)ClockGetTotalClocks,
(SCMI_CLOCK2_GET_CLOCK_ATTRIBUTES)ClockGetClockAttributes,
(SCMI_CLOCK2_DESCRIBE_RATES)ClockDescribeRates,
(SCMI_CLOCK2_RATE_GET)ClockRateGet,
(SCMI_CLOCK2_RATE_SET)ClockRateSet,
SCMI_CLOCK2_PROTOCOL_VERSION,
ClockEnable
};
/** Initialize clock management protocol and install protocol on a given handle.
@param[in] Handle Handle to install clock management protocol.
@retval EFI_SUCCESS Clock protocol interface installed successfully.
**/
EFI_STATUS
ScmiClockProtocolInit (
IN EFI_HANDLE* Handle
)
{
return gBS->InstallMultipleProtocolInterfaces (
Handle,
&gArmScmiClockProtocolGuid,
&ScmiClockProtocol,
&gArmScmiClock2ProtocolGuid,
&ScmiClock2Protocol,
NULL
);
}

View File

@ -1,153 +0,0 @@
/** @file
Copyright (c) 2017-2018, Arm Limited. All rights reserved.
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
System Control and Management Interface V1.0
http://infocenter.arm.com/help/topic/com.arm.doc.den0056a/
DEN0056A_System_Control_and_Management_Interface.pdf
**/
#include <Base.h>
#include <Library/DebugLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Protocol/ArmScmiBaseProtocol.h>
#include <Protocol/ArmScmiClockProtocol.h>
#include <Protocol/ArmScmiPerformanceProtocol.h>
#include "ArmScmiBaseProtocolPrivate.h"
#include "ArmScmiClockProtocolPrivate.h"
#include "ArmScmiPerformanceProtocolPrivate.h"
#include "ScmiDxe.h"
#include "ScmiPrivate.h"
STATIC CONST SCMI_PROTOCOL_ENTRY Protocols[] = {
{ SCMI_PROTOCOL_ID_BASE, ScmiBaseProtocolInit },
{ SCMI_PROTOCOL_ID_PERFORMANCE, ScmiPerformanceProtocolInit },
{ SCMI_PROTOCOL_ID_CLOCK, ScmiClockProtocolInit }
};
/** ARM SCMI driver entry point function.
This function installs the SCMI Base protocol and a list of other
protocols is queried using the Base protocol. If protocol is supported,
driver will call each protocol init function to install the protocol on
the ImageHandle.
@param[in] ImageHandle Handle to this EFI Image which will be used to
install Base, Clock and Performance protocols.
@param[in] SystemTable A pointer to boot time system table.
@retval EFI_SUCCESS Driver initalized successfully.
@retval EFI_UNSUPPORTED If SCMI base protocol version is not supported.
@retval !(EFI_SUCCESS) Other errors.
**/
EFI_STATUS
EFIAPI
ArmScmiDxeEntryPoint (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
SCMI_BASE_PROTOCOL *BaseProtocol;
UINT32 Version;
UINT32 Index;
UINT32 NumProtocols;
UINT32 ProtocolIndex;
UINT8 *SupportedList;
UINT32 SupportedListSize;
// Every SCMI implementation must implement the base protocol.
ASSERT (Protocols[0].Id == SCMI_PROTOCOL_ID_BASE);
Status = ScmiBaseProtocolInit (&ImageHandle);
if (EFI_ERROR (Status)) {
ASSERT (FALSE);
return Status;
}
Status = gBS->LocateProtocol (
&gArmScmiBaseProtocolGuid,
NULL,
(VOID**)&BaseProtocol
);
if (EFI_ERROR (Status)) {
ASSERT (FALSE);
return Status;
}
// Get SCMI Base protocol version.
Status = BaseProtocol->GetVersion (BaseProtocol, &Version);
if (EFI_ERROR (Status)) {
ASSERT (FALSE);
return Status;
}
if (Version != BASE_PROTOCOL_VERSION) {
ASSERT (FALSE);
return EFI_UNSUPPORTED;
}
// Apart from Base protocol, SCMI may implement various other protocols,
// query total protocols implemented by the SCP firmware.
NumProtocols = 0;
Status = BaseProtocol->GetTotalProtocols (BaseProtocol, &NumProtocols);
if (EFI_ERROR (Status)) {
ASSERT (FALSE);
return Status;
}
ASSERT (NumProtocols != 0);
SupportedListSize = (NumProtocols * sizeof (*SupportedList));
Status = gBS->AllocatePool (
EfiBootServicesData,
SupportedListSize,
(VOID**)&SupportedList
);
if (EFI_ERROR (Status)) {
ASSERT (FALSE);
return Status;
}
// Get the list of protocols supported by SCP firmware on the platform.
Status = BaseProtocol->DiscoverListProtocols (
BaseProtocol,
&SupportedListSize,
SupportedList
);
if (EFI_ERROR (Status)) {
gBS->FreePool (SupportedList);
ASSERT (FALSE);
return Status;
}
// Install supported protocol on ImageHandle.
for (ProtocolIndex = 1; ProtocolIndex < ARRAY_SIZE (Protocols);
ProtocolIndex++) {
for (Index = 0; Index < NumProtocols; Index++) {
if (Protocols[ProtocolIndex].Id == SupportedList[Index]) {
Status = Protocols[ProtocolIndex].InitFn (&ImageHandle);
if (EFI_ERROR (Status)) {
ASSERT_EFI_ERROR (Status);
return Status;
}
break;
}
}
}
gBS->FreePool (SupportedList);
return EFI_SUCCESS;
}

View File

@ -1,42 +0,0 @@
/** @file
Copyright (c) 2017-2018, Arm Limited. All rights reserved.
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
System Control and Management Interface V1.0
http://infocenter.arm.com/help/topic/com.arm.doc.den0056a/
DEN0056A_System_Control_and_Management_Interface.pdf
**/
#ifndef SCMI_DXE_H_
#define SCMI_DXE_H_
#include "ScmiPrivate.h"
#define MAX_VENDOR_LEN SCMI_MAX_STR_LEN
/** Pointer to protocol initialization function.
@param[in] Handle A pointer to the EFI_HANDLE on which the protocol
interface is to be installed.
@retval EFI_SUCCESS Protocol interface installed successfully.
**/
typedef
EFI_STATUS
(EFIAPI *SCMI_PROTOCOL_INIT_FXN)(
IN EFI_HANDLE *Handle
);
typedef struct {
SCMI_PROTOCOL_ID Id; // Protocol Id.
SCMI_PROTOCOL_INIT_FXN InitFn; // Protocol init function.
} SCMI_PROTOCOL_ENTRY;
#endif /* SCMI_DXE_H_ */

View File

@ -1,457 +0,0 @@
/** @file
Copyright (c) 2017-2018, Arm Limited. All rights reserved.
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
System Control and Management Interface V1.0
http://infocenter.arm.com/help/topic/com.arm.doc.den0056a/
DEN0056A_System_Control_and_Management_Interface.pdf
**/
#include <Library/BaseMemoryLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Protocol/ArmScmiPerformanceProtocol.h>
#include "ArmScmiPerformanceProtocolPrivate.h"
#include "ScmiPrivate.h"
/** Return version of the performance management protocol supported by SCP.
firmware.
@param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL Instance.
@param[out] Version Version of the supported SCMI performance management
protocol.
@retval EFI_SUCCESS The version is returned.
@retval EFI_DEVICE_ERROR SCP returns an SCMI error.
@retval !(EFI_SUCCESS) Other errors.
**/
STATIC
EFI_STATUS
PerformanceGetVersion (
IN SCMI_PERFORMANCE_PROTOCOL *This,
OUT UINT32 *Version
)
{
return ScmiGetProtocolVersion (SCMI_PROTOCOL_ID_PERFORMANCE, Version);
}
/** Return protocol attributes of the performance management protocol.
@param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL Instance.
@param[out] Attributes Protocol attributes.
@retval EFI_SUCCESS Protocol attributes are returned.
@retval EFI_DEVICE_ERROR SCP returns an SCMI error.
@retval !(EFI_SUCCESS) Other errors.
**/
STATIC
EFI_STATUS
PerformanceGetAttributes (
IN SCMI_PERFORMANCE_PROTOCOL *This,
OUT SCMI_PERFORMANCE_PROTOCOL_ATTRIBUTES *Attributes
)
{
EFI_STATUS Status;
UINT32* ReturnValues;
Status = ScmiGetProtocolAttributes (
SCMI_PROTOCOL_ID_PERFORMANCE,
&ReturnValues
);
if (EFI_ERROR (Status)) {
return Status;
}
CopyMem (
Attributes,
ReturnValues,
sizeof (SCMI_PERFORMANCE_PROTOCOL_ATTRIBUTES)
);
return EFI_SUCCESS;
}
/** Return performance domain attributes.
@param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL Instance.
@param[in] DomainId Identifier for the performance domain.
@param[out] Attributes Performance domain attributes.
@retval EFI_SUCCESS Domain attributes are returned.
@retval EFI_DEVICE_ERROR SCP returns an SCMI error.
@retval !(EFI_SUCCESS) Other errors.
**/
STATIC
EFI_STATUS
PerformanceDomainAttributes (
IN SCMI_PERFORMANCE_PROTOCOL *This,
IN UINT32 DomainId,
OUT SCMI_PERFORMANCE_DOMAIN_ATTRIBUTES *DomainAttributes
)
{
EFI_STATUS Status;
UINT32 *MessageParams;
UINT32 *ReturnValues;
UINT32 PayloadLength;
SCMI_COMMAND Cmd;
Status = ScmiCommandGetPayload (&MessageParams);
if (EFI_ERROR (Status)) {
return Status;
}
*MessageParams = DomainId;
Cmd.ProtocolId = SCMI_PROTOCOL_ID_PERFORMANCE;
Cmd.MessageId = SCMI_MESSAGE_ID_PERFORMANCE_DOMAIN_ATTRIBUTES;
PayloadLength = sizeof (DomainId);
Status = ScmiCommandExecute (
&Cmd,
&PayloadLength,
&ReturnValues
);
if (EFI_ERROR (Status)) {
return Status;
}
CopyMem (
DomainAttributes,
ReturnValues,
sizeof (SCMI_PERFORMANCE_DOMAIN_ATTRIBUTES)
);
return EFI_SUCCESS;
}
/** Return list of performance domain levels of a given domain.
@param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL Instance.
@param[in] DomainId Identifier for the performance domain.
@param[out] NumLevels Total number of levels a domain can support.
@param[in,out] LevelArraySize Size of the performance level array.
@param[out] LevelArray Array of the performance levels.
@retval EFI_SUCCESS Domain levels are returned.
@retval EFI_DEVICE_ERROR SCP returns an SCMI error.
@retval EFI_BUFFER_TOO_SMALL LevelArraySize is too small for the result.
It has been updated to the size needed.
@retval !(EFI_SUCCESS) Other errors.
**/
STATIC
EFI_STATUS
PerformanceDescribeLevels (
IN SCMI_PERFORMANCE_PROTOCOL *This,
IN UINT32 DomainId,
OUT UINT32 *NumLevels,
IN OUT UINT32 *LevelArraySize,
OUT SCMI_PERFORMANCE_LEVEL *LevelArray
)
{
EFI_STATUS Status;
UINT32 PayloadLength;
SCMI_COMMAND Cmd;
UINT32* MessageParams;
UINT32 LevelIndex;
UINT32 RequiredSize;
UINT32 LevelNo;
UINT32 ReturnNumLevels;
UINT32 ReturnRemainNumLevels;
PERF_DESCRIBE_LEVELS *Levels;
Status = ScmiCommandGetPayload (&MessageParams);
if (EFI_ERROR (Status)) {
return Status;
}
LevelIndex = 0;
RequiredSize = 0;
*MessageParams++ = DomainId;
Cmd.ProtocolId = SCMI_PROTOCOL_ID_PERFORMANCE;
Cmd.MessageId = SCMI_MESSAGE_ID_PERFORMANCE_DESCRIBE_LEVELS;
do {
*MessageParams = LevelIndex;
// Note, PayloadLength is an IN/OUT parameter.
PayloadLength = sizeof (DomainId) + sizeof (LevelIndex);
Status = ScmiCommandExecute (
&Cmd,
&PayloadLength,
(UINT32**)&Levels
);
if (EFI_ERROR (Status)) {
return Status;
}
ReturnNumLevels = NUM_PERF_LEVELS (Levels->NumLevels);
ReturnRemainNumLevels = NUM_REMAIN_PERF_LEVELS (Levels->NumLevels);
if (RequiredSize == 0) {
*NumLevels = ReturnNumLevels + ReturnRemainNumLevels;
RequiredSize = (*NumLevels) * sizeof (SCMI_PERFORMANCE_LEVEL);
if (RequiredSize > (*LevelArraySize)) {
// Update LevelArraySize with required size.
*LevelArraySize = RequiredSize;
return EFI_BUFFER_TOO_SMALL;
}
}
for (LevelNo = 0; LevelNo < ReturnNumLevels; LevelNo++) {
CopyMem (
&LevelArray[LevelIndex++],
&Levels->PerfLevel[LevelNo],
sizeof (SCMI_PERFORMANCE_LEVEL)
);
}
} while (ReturnRemainNumLevels != 0);
*LevelArraySize = RequiredSize;
return EFI_SUCCESS;
}
/** Set performance limits of a domain.
@param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL Instance.
@param[in] DomainId Identifier for the performance domain.
@param[in] Limit Performance limit to set.
@retval EFI_SUCCESS Performance limits set successfully.
@retval EFI_DEVICE_ERROR SCP returns an SCMI error.
@retval !(EFI_SUCCESS) Other errors.
**/
EFI_STATUS
PerformanceLimitsSet (
IN SCMI_PERFORMANCE_PROTOCOL *This,
IN UINT32 DomainId,
IN SCMI_PERFORMANCE_LIMITS *Limits
)
{
EFI_STATUS Status;
UINT32 PayloadLength;
SCMI_COMMAND Cmd;
UINT32 *MessageParams;
Status = ScmiCommandGetPayload (&MessageParams);
if (EFI_ERROR (Status)) {
return Status;
}
*MessageParams++ = DomainId;
*MessageParams++ = Limits->RangeMax;
*MessageParams = Limits->RangeMin;
Cmd.ProtocolId = SCMI_PROTOCOL_ID_PERFORMANCE;
Cmd.MessageId = SCMI_MESSAGE_ID_PERFORMANCE_LIMITS_SET;
PayloadLength = sizeof (DomainId) + sizeof (SCMI_PERFORMANCE_LIMITS);
Status = ScmiCommandExecute (
&Cmd,
&PayloadLength,
NULL
);
return Status;
}
/** Get performance limits of a domain.
@param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL Instance.
@param[in] DomainId Identifier for the performance domain.
@param[out] Limit Performance Limits of the domain.
@retval EFI_SUCCESS Performance limits are returned.
@retval EFI_DEVICE_ERROR SCP returns an SCMI error.
@retval !(EFI_SUCCESS) Other errors.
**/
EFI_STATUS
PerformanceLimitsGet (
SCMI_PERFORMANCE_PROTOCOL *This,
UINT32 DomainId,
SCMI_PERFORMANCE_LIMITS *Limits
)
{
EFI_STATUS Status;
UINT32 PayloadLength;
SCMI_COMMAND Cmd;
UINT32 *MessageParams;
SCMI_PERFORMANCE_LIMITS *ReturnValues;
Status = ScmiCommandGetPayload (&MessageParams);
if (EFI_ERROR (Status)) {
return Status;
}
*MessageParams = DomainId;
Cmd.ProtocolId = SCMI_PROTOCOL_ID_PERFORMANCE;
Cmd.MessageId = SCMI_MESSAGE_ID_PERFORMANCE_LIMITS_GET;
PayloadLength = sizeof (DomainId);
Status = ScmiCommandExecute (
&Cmd,
&PayloadLength,
(UINT32**)&ReturnValues
);
if (EFI_ERROR (Status)) {
return Status;
}
Limits->RangeMax = ReturnValues->RangeMax;
Limits->RangeMin = ReturnValues->RangeMin;
return EFI_SUCCESS;
}
/** Set performance level of a domain.
@param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL Instance.
@param[in] DomainId Identifier for the performance domain.
@param[in] Level Performance level of the domain.
@retval EFI_SUCCESS Performance level set successfully.
@retval EFI_DEVICE_ERROR SCP returns an SCMI error.
@retval !(EFI_SUCCESS) Other errors.
**/
EFI_STATUS
PerformanceLevelSet (
IN SCMI_PERFORMANCE_PROTOCOL *This,
IN UINT32 DomainId,
IN UINT32 Level
)
{
EFI_STATUS Status;
UINT32 PayloadLength;
SCMI_COMMAND Cmd;
UINT32 *MessageParams;
Status = ScmiCommandGetPayload (&MessageParams);
if (EFI_ERROR (Status)) {
return Status;
}
*MessageParams++ = DomainId;
*MessageParams = Level;
Cmd.ProtocolId = SCMI_PROTOCOL_ID_PERFORMANCE;
Cmd.MessageId = SCMI_MESSAGE_ID_PERFORMANCE_LEVEL_SET;
PayloadLength = sizeof (DomainId) + sizeof (Level);
Status = ScmiCommandExecute (
&Cmd,
&PayloadLength,
NULL
);
return Status;
}
/** Get performance level of a domain.
@param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL Instance.
@param[in] DomainId Identifier for the performance domain.
@param[out] Level Performance level of the domain.
@retval EFI_SUCCESS Performance level got successfully.
@retval EFI_DEVICE_ERROR SCP returns an SCMI error.
@retval !(EFI_SUCCESS) Other errors.
**/
EFI_STATUS
PerformanceLevelGet (
IN SCMI_PERFORMANCE_PROTOCOL *This,
IN UINT32 DomainId,
OUT UINT32 *Level
)
{
EFI_STATUS Status;
UINT32 PayloadLength;
SCMI_COMMAND Cmd;
UINT32 *ReturnValues;
UINT32 *MessageParams;
Status = ScmiCommandGetPayload (&MessageParams);
if (EFI_ERROR (Status)) {
return Status;
}
*MessageParams = DomainId;
Cmd.ProtocolId = SCMI_PROTOCOL_ID_PERFORMANCE;
Cmd.MessageId = SCMI_MESSAGE_ID_PERFORMANCE_LEVEL_GET;
PayloadLength = sizeof (DomainId);
Status = ScmiCommandExecute (
&Cmd,
&PayloadLength,
&ReturnValues
);
if (EFI_ERROR (Status)) {
return Status;
}
*Level = *ReturnValues;
return EFI_SUCCESS;
}
// Instance of the SCMI performance management protocol.
STATIC CONST SCMI_PERFORMANCE_PROTOCOL PerformanceProtocol = {
PerformanceGetVersion,
PerformanceGetAttributes,
PerformanceDomainAttributes,
PerformanceDescribeLevels,
PerformanceLimitsSet,
PerformanceLimitsGet,
PerformanceLevelSet,
PerformanceLevelGet
};
/** Initialize performance management protocol and install on a given Handle.
@param[in] Handle Handle to install performance management
protocol.
@retval EFI_SUCCESS Performance protocol installed successfully.
**/
EFI_STATUS
ScmiPerformanceProtocolInit (
IN EFI_HANDLE* Handle
)
{
return gBS->InstallMultipleProtocolInterfaces (
Handle,
&gArmScmiPerformanceProtocolGuid,
&PerformanceProtocol,
NULL
);
}

View File

@ -1,174 +0,0 @@
/** @file
Copyright (c) 2017-2018, Arm Limited. All rights reserved.
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
System Control and Management Interface V1.0
http://infocenter.arm.com/help/topic/com.arm.doc.den0056a/
DEN0056A_System_Control_and_Management_Interface.pdf
**/
#ifndef SCMI_PRIVATE_H_
#define SCMI_PRIVATE_H_
// SCMI protocol IDs.
typedef enum {
SCMI_PROTOCOL_ID_BASE = 0x10,
SCMI_PROTOCOL_ID_POWER_DOMAIN = 0x11,
SCMI_PROTOCOL_ID_SYSTEM_POWER = 0x12,
SCMI_PROTOCOL_ID_PERFORMANCE = 0x13,
SCMI_PROTOCOL_ID_CLOCK = 0x14,
SCMI_PROTOCOL_ID_SENSOR = 0x15
} SCMI_PROTOCOL_ID;
// SCMI message types.
typedef enum {
SCMI_MESSAGE_TYPE_COMMAND = 0,
SCMI_MESSAGE_TYPE_DELAYED_RESPONSE = 2, // Skipping 1 is deliberate.
SCMI_MESSAGE_TYPE_NOTIFICATION = 3
} SCMI_MESSAGE_TYPE;
// SCMI response error codes.
typedef enum {
SCMI_SUCCESS = 0,
SCMI_NOT_SUPPORTED = -1,
SCMI_INVALID_PARAMETERS = -2,
SCMI_DENIED = -3,
SCMI_NOT_FOUND = -4,
SCMI_OUT_OF_RANGE = -5,
SCMI_BUSY = -6,
SCMI_COMMS_ERROR = -7,
SCMI_GENERIC_ERROR = -8,
SCMI_HARDWARE_ERROR = -9,
SCMI_PROTOCOL_ERROR = -10
} SCMI_STATUS;
// SCMI message IDs common to all protocols.
typedef enum {
SCMI_MESSAGE_ID_PROTOCOL_VERSION = 0x0,
SCMI_MESSAGE_ID_PROTOCOL_ATTRIBUTES = 0x1,
SCMI_MESSAGE_ID_PROTOCOL_MESSAGE_ATTRIBUTES = 0x2
} SCMI_MESSAGE_ID;
// Not defined in SCMI specification but will help to identify a message.
typedef struct {
SCMI_PROTOCOL_ID ProtocolId;
UINT32 MessageId;
} SCMI_COMMAND;
#pragma pack(1)
// Response to a SCMI command.
typedef struct {
INT32 Status;
UINT32 ReturnValues[];
} SCMI_MESSAGE_RESPONSE;
// Message header. MsgId[7:0], MsgType[9:8], ProtocolId[17:10]
#define MESSAGE_TYPE_SHIFT 8
#define PROTOCOL_ID_SHIFT 10
#define SCMI_MESSAGE_HEADER(MsgId, MsgType, ProtocolId) ( \
MsgType << MESSAGE_TYPE_SHIFT | \
ProtocolId << PROTOCOL_ID_SHIFT | \
MsgId \
)
// SCMI message header.
typedef struct {
UINT32 MessageHeader;
} SCMI_MESSAGE_HEADER;
#pragma pack()
/** Return a pointer to the message payload.
@param[out] Payload Holds pointer to the message payload.
@retval EFI_SUCCESS Payload holds a valid message payload pointer.
@retval EFI_TIMEOUT Time out error if MTL channel is busy.
@retval EFI_UNSUPPORTED If MTL channel is unsupported.
**/
EFI_STATUS
ScmiCommandGetPayload (
OUT UINT32** Payload
);
/** Execute a SCMI command and receive a response.
This function uses a MTL channel to transfer message to SCP
and waits for a response.
@param[in] Command Pointer to the SCMI command (Protocol ID
and Message ID)
@param[in,out] PayloadLength SCMI command message length.
@param[out] OPTIONAL ReturnValues Pointer to SCMI response.
@retval OUT EFI_SUCCESS Command sent and message received successfully.
@retval OUT EFI_UNSUPPORTED Channel not supported.
@retval OUT EFI_TIMEOUT Timeout on the channel.
@retval OUT EFI_DEVICE_ERROR Channel not ready.
@retval OUT EFI_DEVICE_ERROR Message Header corrupted.
@retval OUT EFI_DEVICE_ERROR SCMI error.
**/
EFI_STATUS
ScmiCommandExecute (
IN SCMI_COMMAND *Command,
IN OUT UINT32 *PayloadLength,
OUT UINT32 **ReturnValues OPTIONAL
);
/** Return protocol version from SCP for a given protocol ID.
@param[in] Protocol ID Protocol ID.
@param[out] Version Pointer to version of the protocol.
@retval EFI_SUCCESS Version holds a valid version received
from the SCP.
@retval EFI_DEVICE_ERROR SCMI error.
@retval !(EFI_SUCCESS) Other errors.
**/
EFI_STATUS
ScmiGetProtocolVersion (
IN SCMI_PROTOCOL_ID ProtocolId,
OUT UINT32 *Version
);
/** Return protocol attributes from SCP for a given protocol ID.
@param[in] Protocol ID Protocol ID.
@param[out] ReturnValues Pointer to attributes of the protocol.
@retval EFI_SUCCESS ReturnValues points to protocol attributes.
@retval EFI_DEVICE_ERROR SCMI error.
@retval !(EFI_SUCCESS) Other errors.
**/
EFI_STATUS
ScmiGetProtocolAttributes (
IN SCMI_PROTOCOL_ID ProtocolId,
OUT UINT32 **ReturnValues
);
/** Return protocol message attributes from SCP for a given protocol ID.
@param[in] Protocol ID Protocol ID.
@param[out] Attributes Pointer to attributes of the protocol.
@retval EFI_SUCCESS ReturnValues points to protocol message attributes.
@retval EFI_DEVICE_ERROR SCMI error.
@retval !(EFI_SUCCESS) Other errors.
**/
EFI_STATUS
ScmiGetProtocolMessageAttributes (
IN SCMI_PROTOCOL_ID ProtocolId,
OUT UINT32 **ReturnValues
);
#endif /* SCMI_PRIVATE_H_ */

View File

@ -457,9 +457,6 @@ GetMemoryRegion (
// Get the section at the given index
SectionDescriptor = FirstLevelTable[TableIndex];
if (!SectionDescriptor) {
return EFI_NOT_FOUND;
}
// If 'BaseAddress' belongs to the section then round it to the section boundary
if (((SectionDescriptor & TT_DESCRIPTOR_SECTION_TYPE_MASK) == TT_DESCRIPTOR_SECTION_TYPE_SECTION) ||

View File

@ -35,6 +35,7 @@
#include <Guid/DebugImageInfoTable.h>
#include <Protocol/Cpu.h>
#include <Protocol/DebugSupport.h>
#include <Protocol/DebugSupportPeriodicCallback.h>
#include <Protocol/LoadedImage.h>
extern BOOLEAN mIsFlushingGCD;

View File

@ -60,6 +60,7 @@
[Protocols]
gEfiCpuArchProtocolGuid
gEfiDebugSupportPeriodicCallbackProtocolGuid
[Guids]
gEfiDebugImageInfoTableGuid
@ -71,7 +72,8 @@
gArmTokenSpaceGuid.PcdVFPEnabled
[FeaturePcd.common]
gArmTokenSpaceGuid.PcdCpuDxeProduceDebugSupport
gArmTokenSpaceGuid.PcdDebuggerExceptionSupport
[Depex]
gHardwareInterruptProtocolGuid OR gHardwareInterrupt2ProtocolGuid
TRUE

View File

@ -73,7 +73,7 @@ InitializeCpuPeim (
ArmEnableBranchPrediction ();
// Publish the CPU memory and io spaces sizes
BuildCpuHob (ArmGetPhysicalAddressBits (), PcdGet8 (PcdPrePiCpuIoSize));
BuildCpuHob (PcdGet8 (PcdPrePiCpuMemorySize), PcdGet8 (PcdPrePiCpuIoSize));
// Only MP Core platform need to produce gArmMpCoreInfoPpiGuid
Status = PeiServicesLocatePpi (&gArmMpCoreInfoPpiGuid, 0, NULL, (VOID**)&ArmMpCoreInfoPpi);

View File

@ -50,6 +50,7 @@
gArmMpCoreInfoGuid
[FixedPcd]
gEmbeddedTokenSpaceGuid.PcdPrePiCpuMemorySize
gEmbeddedTokenSpaceGuid.PcdPrePiCpuIoSize
[Depex]

View File

@ -20,8 +20,7 @@
// Control Frame:
#define GENERIC_WDOG_CONTROL_STATUS_REG ((UINTN)FixedPcdGet64 (PcdGenericWatchdogControlBase) + 0x000)
#define GENERIC_WDOG_OFFSET_REG ((UINTN)FixedPcdGet64 (PcdGenericWatchdogControlBase) + 0x008)
#define GENERIC_WDOG_COMPARE_VALUE_REG_LOW ((UINTN)FixedPcdGet64 (PcdGenericWatchdogControlBase) + 0x010)
#define GENERIC_WDOG_COMPARE_VALUE_REG_HIGH ((UINTN)FixedPcdGet64 (PcdGenericWatchdogControlBase) + 0x014)
#define GENERIC_WDOG_COMPARE_VALUE_REG ((UINTN)FixedPcdGet64 (PcdGenericWatchdogControlBase) + 0x010)
// Values of bit 0 of the Control/Status Register
#define GENERIC_WDOG_ENABLED 1

View File

@ -1,6 +1,6 @@
/** @file
*
* Copyright (c) 2013-2018, ARM Limited. All rights reserved.
* Copyright (c) 2013-2014, ARM Limited. All rights reserved.
*
* This program and the accompanying materials
* are licensed and made available under the terms and conditions of the BSD
@ -24,67 +24,61 @@
#include <Library/UefiLib.h>
#include <Library/ArmGenericTimerCounterLib.h>
#include <Protocol/HardwareInterrupt2.h>
#include <Protocol/WatchdogTimer.h>
#include <Protocol/HardwareInterrupt.h>
#include "GenericWatchdog.h"
/* The number of 100ns periods (the unit of time passed to these functions)
in a second */
// The number of 100ns periods (the unit of time passed to these functions)
// in a second
#define TIME_UNITS_PER_SECOND 10000000
// Tick frequency of the generic timer basis of the generic watchdog.
STATIC UINTN mTimerFrequencyHz = 0;
// Tick frequency of the generic timer that is the basis of the generic watchdog
UINTN mTimerFrequencyHz = 0;
/* In cases where the compare register was set manually, information about
how long the watchdog was asked to wait cannot be retrieved from hardware.
It is therefore stored here. 0 means the timer is not running. */
STATIC UINT64 mNumTimerTicks = 0;
// In cases where the compare register was set manually, information about
// how long the watchdog was asked to wait cannot be retrieved from hardware.
// It is therefore stored here. 0 means the timer is not running.
UINT64 mNumTimerTicks = 0;
STATIC EFI_HARDWARE_INTERRUPT2_PROTOCOL *mInterruptProtocol;
STATIC EFI_WATCHDOG_TIMER_NOTIFY mWatchdogNotify;
EFI_HARDWARE_INTERRUPT_PROTOCOL *mInterruptProtocol;
STATIC
VOID
EFI_STATUS
WatchdogWriteOffsetRegister (
UINT32 Value
)
{
MmioWrite32 (GENERIC_WDOG_OFFSET_REG, Value);
return MmioWrite32 (GENERIC_WDOG_OFFSET_REG, Value);
}
STATIC
VOID
EFI_STATUS
WatchdogWriteCompareRegister (
UINT64 Value
)
{
MmioWrite32 (GENERIC_WDOG_COMPARE_VALUE_REG_LOW, Value & MAX_UINT32);
MmioWrite32 (GENERIC_WDOG_COMPARE_VALUE_REG_HIGH, (Value >> 32) & MAX_UINT32);
return MmioWrite64 (GENERIC_WDOG_COMPARE_VALUE_REG, Value);
}
STATIC
VOID
EFI_STATUS
WatchdogEnable (
VOID
)
{
MmioWrite32 (GENERIC_WDOG_CONTROL_STATUS_REG, GENERIC_WDOG_ENABLED);
return MmioWrite32 (GENERIC_WDOG_CONTROL_STATUS_REG, GENERIC_WDOG_ENABLED);
}
STATIC
VOID
EFI_STATUS
WatchdogDisable (
VOID
)
{
MmioWrite32 (GENERIC_WDOG_CONTROL_STATUS_REG, GENERIC_WDOG_DISABLED);
return MmioWrite32 (GENERIC_WDOG_CONTROL_STATUS_REG, GENERIC_WDOG_DISABLED);
}
/** On exiting boot services we must make sure the Watchdog Timer
/**
On exiting boot services we must make sure the Watchdog Timer
is stopped.
**/
STATIC
VOID
EFIAPI
WatchdogExitBootServicesEvent (
@ -96,10 +90,10 @@ WatchdogExitBootServicesEvent (
mNumTimerTicks = 0;
}
/* This function is called when the watchdog's first signal (WS0) goes high.
/*
This function is called when the watchdog's first signal (WS0) goes high.
It uses the ResetSystem Runtime Service to reset the board.
*/
STATIC
VOID
EFIAPI
WatchdogInterruptHandler (
@ -107,26 +101,18 @@ WatchdogInterruptHandler (
IN EFI_SYSTEM_CONTEXT SystemContext
)
{
STATIC CONST CHAR16 ResetString[]= L"The generic watchdog timer ran out.";
UINT64 TimerPeriod;
STATIC CONST CHAR16 ResetString[] = L"The generic watchdog timer ran out.";
WatchdogDisable ();
mInterruptProtocol->EndOfInterrupt (mInterruptProtocol, Source);
//
// The notify function should be called with the elapsed number of ticks
// since the watchdog was armed, which should exceed the timer period.
// We don't actually know the elapsed number of ticks, so let's return
// the timer period plus 1.
//
if (mWatchdogNotify != NULL) {
TimerPeriod = ((TIME_UNITS_PER_SECOND / mTimerFrequencyHz) * mNumTimerTicks);
mWatchdogNotify (TimerPeriod + 1);
}
gRT->ResetSystem (EfiResetCold, EFI_TIMEOUT, StrSize (ResetString),
(CHAR16 *)ResetString);
gRT->ResetSystem (
EfiResetCold,
EFI_TIMEOUT,
StrSize (ResetString),
(VOID *) &ResetString
);
// If we got here then the reset didn't work
ASSERT (FALSE);
@ -140,10 +126,10 @@ WatchdogInterruptHandler (
then the new handler is registered and EFI_SUCCESS is returned.
If NotifyFunction is NULL, and a handler is already registered,
then that handler is unregistered.
If an attempt is made to register a handler when a handler is already
registered, then EFI_ALREADY_STARTED is returned.
If an attempt is made to unregister a handler when a handler is not
registered, then EFI_INVALID_PARAMETER is returned.
If an attempt is made to register a handler when a handler is already registered,
then EFI_ALREADY_STARTED is returned.
If an attempt is made to unregister a handler when a handler is not registered,
then EFI_INVALID_PARAMETER is returned.
@param This The EFI_TIMER_ARCH_PROTOCOL instance.
@param NotifyFunction The function to call when a timer interrupt fires.
@ -153,92 +139,96 @@ WatchdogInterruptHandler (
information is used to signal timer based events.
NULL will unregister the handler.
@retval EFI_UNSUPPORTED The code does not support NotifyFunction.
@retval EFI_SUCCESS The watchdog timer handler was registered.
@retval EFI_ALREADY_STARTED NotifyFunction is not NULL, and a handler is already
registered.
@retval EFI_INVALID_PARAMETER NotifyFunction is NULL, and a handler was not
previously registered.
**/
STATIC
EFI_STATUS
EFIAPI
WatchdogRegisterHandler (
IN EFI_WATCHDOG_TIMER_ARCH_PROTOCOL *This,
IN CONST EFI_WATCHDOG_TIMER_ARCH_PROTOCOL *This,
IN EFI_WATCHDOG_TIMER_NOTIFY NotifyFunction
)
{
if (mWatchdogNotify == NULL && NotifyFunction == NULL) {
return EFI_INVALID_PARAMETER;
}
if (mWatchdogNotify != NULL && NotifyFunction != NULL) {
return EFI_ALREADY_STARTED;
}
mWatchdogNotify = NotifyFunction;
return EFI_SUCCESS;
// ERROR: This function is not supported.
// The watchdog will reset the board
return EFI_UNSUPPORTED;
}
/**
This function sets the amount of time to wait before firing the watchdog
timer to TimerPeriod 100ns units. If TimerPeriod is 0, then the watchdog
timer to TimerPeriod 100 nS units. If TimerPeriod is 0, then the watchdog
timer is disabled.
@param This The EFI_WATCHDOG_TIMER_ARCH_PROTOCOL instance.
@param TimerPeriod The amount of time in 100ns units to wait before
the watchdog timer is fired. If TimerPeriod is zero,
then the watchdog timer is disabled.
@param TimerPeriod The amount of time in 100 nS units to wait before the watchdog
timer is fired. If TimerPeriod is zero, then the watchdog
timer is disabled.
@retval EFI_SUCCESS The watchdog timer has been programmed to fire
in TimerPeriod 100ns units.
@retval EFI_SUCCESS The watchdog timer has been programmed to fire in Time
100 nS units.
@retval EFI_DEVICE_ERROR A watchdog timer could not be programmed due to a device
error.
**/
STATIC
EFI_STATUS
EFIAPI
WatchdogSetTimerPeriod (
IN EFI_WATCHDOG_TIMER_ARCH_PROTOCOL *This,
IN CONST EFI_WATCHDOG_TIMER_ARCH_PROTOCOL *This,
IN UINT64 TimerPeriod // In 100ns units
)
{
UINTN SystemCount;
EFI_STATUS Status;
// if TimerPeriod is 0, this is a request to stop the watchdog.
// if TimerPerdiod is 0, this is a request to stop the watchdog.
if (TimerPeriod == 0) {
mNumTimerTicks = 0;
WatchdogDisable ();
return EFI_SUCCESS;
return WatchdogDisable ();
}
// Work out how many timer ticks will equate to TimerPeriod
mNumTimerTicks = (mTimerFrequencyHz * TimerPeriod) / TIME_UNITS_PER_SECOND;
/* If the number of required ticks is greater than the max the watchdog's
offset register (WOR) can hold, we need to manually compute and set
the compare register (WCV) */
//
// If the number of required ticks is greater than the max number the
// watchdog's offset register (WOR) can hold, we need to manually compute and
// set the compare register (WCV)
//
if (mNumTimerTicks > MAX_UINT32) {
/* We need to enable the watchdog *before* writing to the compare register,
because enabling the watchdog causes an "explicit refresh", which
clobbers the compare register (WCV). In order to make sure this doesn't
trigger an interrupt, set the offset to max. */
WatchdogWriteOffsetRegister (MAX_UINT32);
//
// We need to enable the watchdog *before* writing to the compare register,
// because enabling the watchdog causes an "explicit refresh", which
// clobbers the compare register (WCV). In order to make sure this doesn't
// trigger an interrupt, set the offset to max.
//
Status = WatchdogWriteOffsetRegister (MAX_UINT32);
if (EFI_ERROR (Status)) {
return Status;
}
WatchdogEnable ();
SystemCount = ArmGenericTimerGetSystemCount ();
WatchdogWriteCompareRegister (SystemCount + mNumTimerTicks);
Status = WatchdogWriteCompareRegister (SystemCount + mNumTimerTicks);
} else {
WatchdogWriteOffsetRegister ((UINT32)mNumTimerTicks);
Status = WatchdogWriteOffsetRegister ((UINT32)mNumTimerTicks);
WatchdogEnable ();
}
return EFI_SUCCESS;
return Status;
}
/**
This function retrieves the period of timer interrupts in 100ns units,
This function retrieves the period of timer interrupts in 100 ns units,
returns that value in TimerPeriod, and returns EFI_SUCCESS. If TimerPeriod
is NULL, then EFI_INVALID_PARAMETER is returned. If a TimerPeriod of 0 is
returned, then the timer is currently disabled.
@param This The EFI_TIMER_ARCH_PROTOCOL instance.
@param TimerPeriod A pointer to the timer period to retrieve in
100ns units. If 0 is returned, then the timer is
@param TimerPeriod A pointer to the timer period to retrieve in 100
ns units. If 0 is returned, then the timer is
currently disabled.
@ -246,11 +236,10 @@ WatchdogSetTimerPeriod (
@retval EFI_INVALID_PARAMETER TimerPeriod is NULL.
**/
STATIC
EFI_STATUS
EFIAPI
WatchdogGetTimerPeriod (
IN EFI_WATCHDOG_TIMER_ARCH_PROTOCOL *This,
IN CONST EFI_WATCHDOG_TIMER_ARCH_PROTOCOL *This,
OUT UINT64 *TimerPeriod
)
{
@ -286,22 +275,22 @@ WatchdogGetTimerPeriod (
this function will not have any chance of executing.
@param SetTimerPeriod
Sets the period of the timer interrupt in 100ns units.
Sets the period of the timer interrupt in 100 nS units.
This function is optional, and may return EFI_UNSUPPORTED.
If this function is supported, then the timer period will
be rounded up to the nearest supported timer period.
@param GetTimerPeriod
Retrieves the period of the timer interrupt in 100ns units.
Retrieves the period of the timer interrupt in 100 nS units.
**/
STATIC EFI_WATCHDOG_TIMER_ARCH_PROTOCOL mWatchdogTimer = {
WatchdogRegisterHandler,
WatchdogSetTimerPeriod,
WatchdogGetTimerPeriod
EFI_WATCHDOG_TIMER_ARCH_PROTOCOL gWatchdogTimer = {
(EFI_WATCHDOG_TIMER_REGISTER_HANDLER) WatchdogRegisterHandler,
(EFI_WATCHDOG_TIMER_SET_TIMER_PERIOD) WatchdogSetTimerPeriod,
(EFI_WATCHDOG_TIMER_GET_TIMER_PERIOD) WatchdogGetTimerPeriod
};
STATIC EFI_EVENT mEfiExitBootServicesEvent;
EFI_EVENT EfiExitBootServicesEvent = (EFI_EVENT)NULL;
EFI_STATUS
EFIAPI
@ -313,57 +302,53 @@ GenericWatchdogEntry (
EFI_STATUS Status;
EFI_HANDLE Handle;
Status = gBS->LocateProtocol (&gHardwareInterrupt2ProtocolGuid, NULL,
(VOID **)&mInterruptProtocol);
ASSERT_EFI_ERROR (Status);
/* Make sure the Watchdog Timer Architectural Protocol has not been installed
in the system yet.
This will avoid conflicts with the universal watchdog */
//
// Make sure the Watchdog Timer Architectural Protocol has not been installed
// in the system yet.
// This will avoid conflicts with the universal watchdog
//
ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiWatchdogTimerArchProtocolGuid);
mTimerFrequencyHz = ArmGenericTimerGetTimerFreq ();
ASSERT (mTimerFrequencyHz != 0);
// Register for an ExitBootServicesEvent
Status = gBS->CreateEvent (
EVT_SIGNAL_EXIT_BOOT_SERVICES, TPL_NOTIFY,
WatchdogExitBootServicesEvent, NULL, &EfiExitBootServicesEvent
);
if (!EFI_ERROR (Status)) {
// Install interrupt handler
Status = mInterruptProtocol->RegisterInterruptSource (mInterruptProtocol,
Status = gBS->LocateProtocol (
&gHardwareInterruptProtocolGuid,
NULL,
(VOID **)&mInterruptProtocol
);
if (!EFI_ERROR (Status)) {
Status = mInterruptProtocol->RegisterInterruptSource (
mInterruptProtocol,
FixedPcdGet32 (PcdGenericWatchdogEl2IntrNum),
WatchdogInterruptHandler);
if (EFI_ERROR (Status)) {
return Status;
}
Status = mInterruptProtocol->SetTriggerType (mInterruptProtocol,
FixedPcdGet32 (PcdGenericWatchdogEl2IntrNum),
EFI_HARDWARE_INTERRUPT2_TRIGGER_EDGE_RISING);
if (EFI_ERROR (Status)) {
goto UnregisterHandler;
}
WatchdogInterruptHandler
);
if (!EFI_ERROR (Status)) {
// Install the Timer Architectural Protocol onto a new handle
Handle = NULL;
Status = gBS->InstallMultipleProtocolInterfaces (&Handle,
&gEfiWatchdogTimerArchProtocolGuid, &mWatchdogTimer,
NULL);
if (EFI_ERROR (Status)) {
goto UnregisterHandler;
Status = gBS->InstallMultipleProtocolInterfaces (
&Handle,
&gEfiWatchdogTimerArchProtocolGuid, &gWatchdogTimer,
NULL
);
}
}
}
// Register for an ExitBootServicesEvent
Status = gBS->CreateEvent (EVT_SIGNAL_EXIT_BOOT_SERVICES, TPL_NOTIFY,
WatchdogExitBootServicesEvent, NULL,
&mEfiExitBootServicesEvent);
ASSERT_EFI_ERROR (Status);
if (EFI_ERROR (Status)) {
// The watchdog failed to initialize
ASSERT (FALSE);
}
mNumTimerTicks = 0;
WatchdogDisable ();
return EFI_SUCCESS;
UnregisterHandler:
// Unregister the handler
mInterruptProtocol->RegisterInterruptSource (mInterruptProtocol,
FixedPcdGet32 (PcdGenericWatchdogEl2IntrNum),
NULL);
return Status;
}

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2013-2017, ARM Limited. All rights reserved.
# Copyright (c) 2013-2014, ARM Limited. All rights reserved.
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
@ -16,16 +16,17 @@
FILE_GUID = 0619f5c2-4858-4caa-a86a-73a21a18df6b
MODULE_TYPE = DXE_DRIVER
VERSION_STRING = 1.0
ENTRY_POINT = GenericWatchdogEntry
[Sources.common]
GenericWatchdogDxe.c
[Packages]
MdePkg/MdePkg.dec
EmbeddedPkg/EmbeddedPkg.dec
ArmPkg/ArmPkg.dec
ArmPlatformPkg/ArmPlatformPkg.dec
EmbeddedPkg/EmbeddedPkg.dec
MdePkg/MdePkg.dec
[LibraryClasses]
ArmGenericTimerCounterLib
@ -45,8 +46,8 @@
gArmTokenSpaceGuid.PcdGenericWatchdogEl2IntrNum
[Protocols]
gEfiWatchdogTimerArchProtocolGuid ## ALWAYS_PRODUCES
gHardwareInterrupt2ProtocolGuid ## ALWAYS_CONSUMES
gEfiWatchdogTimerArchProtocolGuid
gHardwareInterruptProtocolGuid
[Depex]
gHardwareInterrupt2ProtocolGuid
gHardwareInterruptProtocolGuid

View File

@ -1,28 +0,0 @@
/** @file
Copyright (c) 2016-2018, ARM Limited. All rights reserved.
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#if !defined _MM_COMMUNICATE_H_
#define _MM_COMMUNICATE_H_
#define MM_MAJOR_VER_MASK 0xEFFF0000
#define MM_MINOR_VER_MASK 0x0000FFFF
#define MM_MAJOR_VER_SHIFT 16
#define MM_MAJOR_VER(x) (((x) & MM_MAJOR_VER_MASK) >> MM_MAJOR_VER_SHIFT)
#define MM_MINOR_VER(x) ((x) & MM_MINOR_VER_MASK)
#define MM_CALLER_MAJOR_VER 0x1UL
#define MM_CALLER_MINOR_VER 0x0
#endif /* _MM_COMMUNICATE_H_ */

View File

@ -1,372 +0,0 @@
/** @file
Copyright (c) 2016-2018, ARM Limited. All rights reserved.
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include <Library/ArmLib.h>
#include <Library/ArmSmcLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/DebugLib.h>
#include <Library/DxeServicesTableLib.h>
#include <Library/HobLib.h>
#include <Library/PcdLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiRuntimeServicesTableLib.h>
#include <Protocol/MmCommunication.h>
#include <IndustryStandard/ArmStdSmc.h>
#include "MmCommunicate.h"
//
// Address, Length of the pre-allocated buffer for communication with the secure
// world.
//
STATIC ARM_MEMORY_REGION_DESCRIPTOR mNsCommBuffMemRegion;
// Notification event when virtual address map is set.
STATIC EFI_EVENT mSetVirtualAddressMapEvent;
//
// Handle to install the MM Communication Protocol
//
STATIC EFI_HANDLE mMmCommunicateHandle;
/**
Communicates with a registered handler.
This function provides an interface to send and receive messages to the
Standalone MM environment on behalf of UEFI services. This function is part
of the MM Communication Protocol that may be called in physical mode prior to
SetVirtualAddressMap() and in virtual mode after SetVirtualAddressMap().
@param[in] This The EFI_MM_COMMUNICATION_PROTOCOL
instance.
@param[in, out] CommBuffer A pointer to the buffer to convey
into MMRAM.
@param[in, out] CommSize The size of the data buffer being
passed in. This is optional.
@retval EFI_SUCCESS The message was successfully posted.
@retval EFI_INVALID_PARAMETER The CommBuffer was NULL.
@retval EFI_BAD_BUFFER_SIZE The buffer size is incorrect for the MM
implementation. If this error is
returned, the MessageLength field in
the CommBuffer header or the integer
pointed by CommSize are updated to reflect
the maximum payload size the
implementation can accommodate.
@retval EFI_ACCESS_DENIED The CommunicateBuffer parameter
or CommSize parameter, if not omitted,
are in address range that cannot be
accessed by the MM environment
**/
STATIC
EFI_STATUS
EFIAPI
MmCommunicationCommunicate (
IN CONST EFI_MM_COMMUNICATION_PROTOCOL *This,
IN OUT VOID *CommBuffer,
IN OUT UINTN *CommSize OPTIONAL
)
{
EFI_MM_COMMUNICATE_HEADER *CommunicateHeader;
ARM_SMC_ARGS CommunicateSmcArgs;
EFI_STATUS Status;
UINTN BufferSize;
Status = EFI_ACCESS_DENIED;
BufferSize = 0;
ZeroMem (&CommunicateSmcArgs, sizeof (ARM_SMC_ARGS));
//
// Check parameters
//
if (CommBuffer == NULL) {
return EFI_INVALID_PARAMETER;
}
CommunicateHeader = CommBuffer;
// CommBuffer is a mandatory parameter. Hence, Rely on
// MessageLength + Header to ascertain the
// total size of the communication payload rather than
// rely on optional CommSize parameter
BufferSize = CommunicateHeader->MessageLength +
sizeof (CommunicateHeader->HeaderGuid) +
sizeof (CommunicateHeader->MessageLength);
// If the length of the CommBuffer is 0 then return the expected length.
if (CommSize) {
// This case can be used by the consumer of this driver to find out the
// max size that can be used for allocating CommBuffer.
if ((*CommSize == 0) ||
(*CommSize > mNsCommBuffMemRegion.Length)) {
*CommSize = mNsCommBuffMemRegion.Length;
return EFI_BAD_BUFFER_SIZE;
}
//
// CommSize must match MessageLength + sizeof (EFI_MM_COMMUNICATE_HEADER);
//
if (*CommSize != BufferSize) {
return EFI_INVALID_PARAMETER;
}
}
//
// If the buffer size is 0 or greater than what can be tolerated by the MM
// environment then return the expected size.
//
if ((BufferSize == 0) ||
(BufferSize > mNsCommBuffMemRegion.Length)) {
CommunicateHeader->MessageLength = mNsCommBuffMemRegion.Length -
sizeof (CommunicateHeader->HeaderGuid) -
sizeof (CommunicateHeader->MessageLength);
return EFI_BAD_BUFFER_SIZE;
}
// SMC Function ID
CommunicateSmcArgs.Arg0 = ARM_SMC_ID_MM_COMMUNICATE_AARCH64;
// Cookie
CommunicateSmcArgs.Arg1 = 0;
// Copy Communication Payload
CopyMem ((VOID *)mNsCommBuffMemRegion.VirtualBase, CommBuffer, BufferSize);
// comm_buffer_address (64-bit physical address)
CommunicateSmcArgs.Arg2 = (UINTN)mNsCommBuffMemRegion.PhysicalBase;
// comm_size_address (not used, indicated by setting to zero)
CommunicateSmcArgs.Arg3 = 0;
// Call the Standalone MM environment.
ArmCallSmc (&CommunicateSmcArgs);
switch (CommunicateSmcArgs.Arg0) {
case ARM_SMC_MM_RET_SUCCESS:
ZeroMem (CommBuffer, BufferSize);
// On successful return, the size of data being returned is inferred from
// MessageLength + Header.
CommunicateHeader = (EFI_MM_COMMUNICATE_HEADER *)mNsCommBuffMemRegion.VirtualBase;
BufferSize = CommunicateHeader->MessageLength +
sizeof (CommunicateHeader->HeaderGuid) +
sizeof (CommunicateHeader->MessageLength);
CopyMem (
CommBuffer,
(VOID *)mNsCommBuffMemRegion.VirtualBase,
BufferSize
);
Status = EFI_SUCCESS;
break;
case ARM_SMC_MM_RET_INVALID_PARAMS:
Status = EFI_INVALID_PARAMETER;
break;
case ARM_SMC_MM_RET_DENIED:
Status = EFI_ACCESS_DENIED;
break;
case ARM_SMC_MM_RET_NO_MEMORY:
// Unexpected error since the CommSize was checked for zero length
// prior to issuing the SMC
Status = EFI_OUT_OF_RESOURCES;
ASSERT (0);
break;
default:
Status = EFI_ACCESS_DENIED;
ASSERT (0);
}
return Status;
}
//
// MM Communication Protocol instance
//
EFI_MM_COMMUNICATION_PROTOCOL mMmCommunication = {
MmCommunicationCommunicate
};
/**
Notification callback on SetVirtualAddressMap event.
This function notifies the MM communication protocol interface on
SetVirtualAddressMap event and converts pointers used in this driver
from physical to virtual address.
@param Event SetVirtualAddressMap event.
@param Context A context when the SetVirtualAddressMap triggered.
@retval EFI_SUCCESS The function executed successfully.
@retval Other Some error occurred when executing this function.
**/
STATIC
VOID
EFIAPI
NotifySetVirtualAddressMap (
IN EFI_EVENT Event,
IN VOID *Context
)
{
EFI_STATUS Status;
Status = gRT->ConvertPointer (
EFI_OPTIONAL_PTR,
(VOID **)&mNsCommBuffMemRegion.VirtualBase
);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "NotifySetVirtualAddressMap():"
" Unable to convert MM runtime pointer. Status:0x%r\n", Status));
}
}
STATIC
EFI_STATUS
GetMmCompatibility ()
{
EFI_STATUS Status;
UINT32 MmVersion;
ARM_SMC_ARGS MmVersionArgs;
// MM_VERSION uses SMC32 calling conventions
MmVersionArgs.Arg0 = ARM_SMC_ID_MM_VERSION_AARCH32;
ArmCallSmc (&MmVersionArgs);
MmVersion = MmVersionArgs.Arg0;
if ((MM_MAJOR_VER(MmVersion) == MM_CALLER_MAJOR_VER) &&
(MM_MINOR_VER(MmVersion) >= MM_CALLER_MINOR_VER)) {
DEBUG ((DEBUG_INFO, "MM Version: Major=0x%x, Minor=0x%x\n",
MM_MAJOR_VER(MmVersion), MM_MINOR_VER(MmVersion)));
Status = EFI_SUCCESS;
} else {
DEBUG ((DEBUG_ERROR, "Incompatible MM Versions.\n Current Version: Major=0x%x, Minor=0x%x.\n Expected: Major=0x%x, Minor>=0x%x.\n",
MM_MAJOR_VER(MmVersion), MM_MINOR_VER(MmVersion), MM_CALLER_MAJOR_VER, MM_CALLER_MINOR_VER));
Status = EFI_UNSUPPORTED;
}
return Status;
}
/**
The Entry Point for MM Communication
This function installs the MM communication protocol interface and finds out
what type of buffer management will be required prior to invoking the
communication SMC.
@param ImageHandle The firmware allocated handle for the EFI image.
@param SystemTable A pointer to the EFI System Table.
@retval EFI_SUCCESS The entry point is executed successfully.
@retval Other Some error occurred when executing this entry point.
**/
EFI_STATUS
EFIAPI
MmCommunicationInitialize (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
// Check if we can make the MM call
Status = GetMmCompatibility ();
if (EFI_ERROR(Status)) {
goto ReturnErrorStatus;
}
mNsCommBuffMemRegion.PhysicalBase = PcdGet64 (PcdMmBufferBase);
// During boot , Virtual and Physical are same
mNsCommBuffMemRegion.VirtualBase = mNsCommBuffMemRegion.PhysicalBase;
mNsCommBuffMemRegion.Length = PcdGet64 (PcdMmBufferSize);
ASSERT (mNsCommBuffMemRegion.PhysicalBase != 0);
ASSERT (mNsCommBuffMemRegion.Length != 0);
Status = gDS->AddMemorySpace (
EfiGcdMemoryTypeReserved,
mNsCommBuffMemRegion.PhysicalBase,
mNsCommBuffMemRegion.Length,
EFI_MEMORY_WB |
EFI_MEMORY_XP |
EFI_MEMORY_RUNTIME
);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "MmCommunicateInitialize: "
"Failed to add MM-NS Buffer Memory Space\n"));
goto ReturnErrorStatus;
}
Status = gDS->SetMemorySpaceAttributes (
mNsCommBuffMemRegion.PhysicalBase,
mNsCommBuffMemRegion.Length,
EFI_MEMORY_WB | EFI_MEMORY_XP | EFI_MEMORY_RUNTIME
);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "MmCommunicateInitialize: "
"Failed to set MM-NS Buffer Memory attributes\n"));
goto CleanAddedMemorySpace;
}
// Install the communication protocol
Status = gBS->InstallProtocolInterface (
&mMmCommunicateHandle,
&gEfiMmCommunicationProtocolGuid,
EFI_NATIVE_INTERFACE,
&mMmCommunication
);
if (EFI_ERROR(Status)) {
DEBUG ((DEBUG_ERROR, "MmCommunicationInitialize: "
"Failed to install MM communication protocol\n"));
goto CleanAddedMemorySpace;
}
// Register notification callback when virtual address is associated
// with the physical address.
// Create a Set Virtual Address Map event.
Status = gBS->CreateEvent (
EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE,
TPL_NOTIFY,
NotifySetVirtualAddressMap,
NULL,
&mSetVirtualAddressMapEvent
);
if (Status == EFI_SUCCESS) {
return Status;
}
gBS->UninstallProtocolInterface (
mMmCommunicateHandle,
&gEfiMmCommunicationProtocolGuid,
&mMmCommunication
);
CleanAddedMemorySpace:
gDS->RemoveMemorySpace (
mNsCommBuffMemRegion.PhysicalBase,
mNsCommBuffMemRegion.Length
);
ReturnErrorStatus:
return EFI_INVALID_PARAMETER;
}

View File

@ -1,56 +0,0 @@
#/** @file
#
# DXE MM Communicate driver
#
# Copyright (c) 2016 - 2018, ARM Limited. All rights reserved.
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
#**/
[Defines]
INF_VERSION = 0x0001001A
BASE_NAME = ArmMmCommunication
FILE_GUID = 09EE81D3-F15E-43F4-85B4-CB9873DA5D6B
MODULE_TYPE = DXE_RUNTIME_DRIVER
VERSION_STRING = 1.0
ENTRY_POINT = MmCommunicationInitialize
#
# The following is for reference only and not required by
# build tools
#
# VALID_ARCHITECTURES = AARCH64
#
[Sources.AARCH64]
MmCommunication.c
[Packages]
ArmPkg/ArmPkg.dec
MdePkg/MdePkg.dec
[LibraryClasses]
ArmLib
ArmSmcLib
BaseMemoryLib
DebugLib
DxeServicesTableLib
HobLib
UefiDriverEntryPoint
[Protocols]
gEfiMmCommunicationProtocolGuid ## PRODUCES
[Pcd.common]
gArmTokenSpaceGuid.PcdMmBufferBase
gArmTokenSpaceGuid.PcdMmBufferSize
[Depex]
gEfiCpuArchProtocolGuid

View File

@ -306,13 +306,12 @@ TimerInterruptHandler (
//
OriginalTPL = gBS->RaiseTPL (TPL_HIGH_LEVEL);
// Signal end of interrupt early to help avoid losing subsequent ticks
// from long duration handlers
gInterrupt->EndOfInterrupt (gInterrupt, Source);
// Check if the timer interrupt is active
if ((ArmGenericTimerGetTimerCtrlReg () ) & ARM_ARCH_TIMER_ISTATUS) {
// Signal end of interrupt early to help avoid losing subsequent ticks from long duration handlers
gInterrupt->EndOfInterrupt (gInterrupt, Source);
if (mTimerNotifyFunction) {
mTimerNotifyFunction (mTimerPeriod * mElapsedPeriod);
}
@ -337,10 +336,12 @@ TimerInterruptHandler (
// Set next compare value
ArmGenericTimerSetCompareVal (CompareValue);
ArmGenericTimerReenableTimer ();
ArmInstructionSynchronizationBarrier ();
ArmGenericTimerEnableTimer ();
}
// Enable timer interrupts
gInterrupt->EnableInterruptSource (gInterrupt, Source);
gBS->RestoreTPL (OriginalTPL);
}

View File

@ -1,7 +1,7 @@
/** @file
Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
Copyright (c) 2011 - 2017, ARM Ltd. All rights reserved.<BR>
Copyright (c) 2011 - 2015, ARM Ltd. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
@ -235,14 +235,4 @@ ArmWriteCptr (
IN UINT64 Cptr
);
UINT32
ArmReadCntHctl (
VOID
);
VOID
ArmWriteCntHctl (
IN UINT32 CntHctl
);
#endif // __AARCH64_H__

View File

@ -1,50 +0,0 @@
/** @file
*
* Copyright (c) 2012-2017, ARM Limited. All rights reserved.
*
* This program and the accompanying materials
* are licensed and made available under the terms and conditions of the BSD License
* which accompanies this distribution. The full text of the license may be found at
* http://opensource.org/licenses/bsd-license.php
*
* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
*
**/
#ifndef __ARM_MM_SVC_H__
#define __ARM_MM_SVC_H__
/*
* SVC IDs to allow the MM secure partition to initialise itself, handle
* delegated events and request the Secure partition manager to perform
* privileged operations on its behalf.
*/
#define ARM_SVC_ID_SPM_VERSION_AARCH32 0x84000060
#define ARM_SVC_ID_SP_EVENT_COMPLETE_AARCH64 0xC4000061
#define ARM_SVC_ID_SP_GET_MEM_ATTRIBUTES_AARCH64 0xC4000064
#define ARM_SVC_ID_SP_SET_MEM_ATTRIBUTES_AARCH64 0xC4000065
#define SET_MEM_ATTR_DATA_PERM_MASK 0x3
#define SET_MEM_ATTR_DATA_PERM_SHIFT 0
#define SET_MEM_ATTR_DATA_PERM_NO_ACCESS 0
#define SET_MEM_ATTR_DATA_PERM_RW 1
#define SET_MEM_ATTR_DATA_PERM_RO 3
#define SET_MEM_ATTR_CODE_PERM_MASK 0x1
#define SET_MEM_ATTR_CODE_PERM_SHIFT 2
#define SET_MEM_ATTR_CODE_PERM_X 0
#define SET_MEM_ATTR_CODE_PERM_XN 1
#define SET_MEM_ATTR_MAKE_PERM_REQUEST(d_perm, c_perm) \
((((c_perm) & SET_MEM_ATTR_CODE_PERM_MASK) << SET_MEM_ATTR_CODE_PERM_SHIFT) | \
(( (d_perm) & SET_MEM_ATTR_DATA_PERM_MASK) << SET_MEM_ATTR_DATA_PERM_SHIFT))
/* MM SVC Return error codes */
#define ARM_SVC_SPM_RET_SUCCESS 0
#define ARM_SVC_SPM_RET_NOT_SUPPORTED -1
#define ARM_SVC_SPM_RET_INVALID_PARAMS -2
#define ARM_SVC_SPM_RET_DENIED -3
#define ARM_SVC_SPM_RET_NO_MEMORY -5
#endif

View File

@ -1,6 +1,6 @@
/** @file
*
* Copyright (c) 2012-2017, ARM Limited. All rights reserved.
* Copyright (c) 2012-2014, ARM Limited. All rights reserved.
*
* This program and the accompanying materials
* are licensed and made available under the terms and conditions of the BSD License
@ -40,24 +40,6 @@
#define ARM_SMC_STD_REVISION_MAJOR 0x0
#define ARM_SMC_STD_REVISION_MINOR 0x1
/*
* Management Mode (MM) calls cover a subset of the Standard Service Call range.
* The list below is not exhaustive.
*/
#define ARM_SMC_ID_MM_VERSION_AARCH32 0x84000040
#define ARM_SMC_ID_MM_VERSION_AARCH64 0xC4000040
// Request service from secure standalone MM environment
#define ARM_SMC_ID_MM_COMMUNICATE_AARCH32 0x84000041
#define ARM_SMC_ID_MM_COMMUNICATE_AARCH64 0xC4000041
/* MM return error codes */
#define ARM_SMC_MM_RET_SUCCESS 0
#define ARM_SMC_MM_RET_NOT_SUPPORTED -1
#define ARM_SMC_MM_RET_INVALID_PARAMS -2
#define ARM_SMC_MM_RET_DENIED -3
#define ARM_SMC_MM_RET_NO_MEMORY -4
/*
* Power State Coordination Interface (PSCI) calls cover a subset of the
* Standard Service Call range.
@ -111,12 +93,4 @@
#define ARM_SMC_ID_PSCI_AFFINITY_INFO_OFF 1
#define ARM_SMC_ID_PSCI_AFFINITY_INFO_ON_PENDING 2
/*
* SMC function IDs for Trusted OS Service queries
*/
#define ARM_SMC_ID_TOS_CALL_COUNT 0xbf00ff00
#define ARM_SMC_ID_TOS_UID 0xbf00ff01
/* 0xbf00ff02 is reserved */
#define ARM_SMC_ID_TOS_REVISION 0xbf00ff03
#endif

View File

@ -22,12 +22,6 @@ ArmGenericTimerEnableTimer (
VOID
);
VOID
EFIAPI
ArmGenericTimerReenableTimer (
VOID
);
VOID
EFIAPI
ArmGenericTimerDisableTimer (

View File

@ -1,6 +1,6 @@
/** @file
*
* Copyright (c) 2011-2018, ARM Limited. All rights reserved.
* Copyright (c) 2011-2015, ARM Limited. All rights reserved.
*
* This program and the accompanying materials
* are licensed and made available under the terms and conditions of the BSD License
@ -17,7 +17,9 @@
#include <Library/ArmGicArchLib.h>
//
// GIC Distributor
//
#define ARM_GIC_ICDDCR 0x000 // Distributor Control Register
#define ARM_GIC_ICDICTR 0x004 // Interrupt Controller Type Register
#define ARM_GIC_ICDIIDR 0x008 // Implementer Identification Register
@ -49,44 +51,23 @@
#define ARM_GIC_ICDDCR_ARE (1 << 4) // Affinity Routing Enable (ARE)
#define ARM_GIC_ICDDCR_DS (1 << 6) // Disable Security (DS)
// GICD_ICDICFR bits
#define ARM_GIC_ICDICFR_WIDTH 32 // ICDICFR is a 32 bit register
#define ARM_GIC_ICDICFR_BYTES (ARM_GIC_ICDICFR_WIDTH / 8)
#define ARM_GIC_ICDICFR_F_WIDTH 2 // Each F field is 2 bits
#define ARM_GIC_ICDICFR_F_STRIDE 16 // (32/2) F fields per register
#define ARM_GIC_ICDICFR_F_CONFIG1_BIT 1 // Bit number within F field
#define ARM_GIC_ICDICFR_LEVEL_TRIGGERED 0x0 // Level triggered interrupt
#define ARM_GIC_ICDICFR_EDGE_TRIGGERED 0x1 // Edge triggered interrupt
//
// GIC Redistributor
//
#define ARM_GICR_CTLR_FRAME_SIZE SIZE_64KB
#define ARM_GICR_SGI_PPI_FRAME_SIZE SIZE_64KB
#define ARM_GICR_SGI_VLPI_FRAME_SIZE SIZE_64KB
#define ARM_GICR_SGI_RESERVED_FRAME_SIZE SIZE_64KB
// GIC Redistributor Control frame
#define ARM_GICR_TYPER 0x0008 // Redistributor Type Register
// GIC Redistributor TYPER bit assignments
#define ARM_GICR_TYPER_PLPIS (1 << 0) // Physical LPIs
#define ARM_GICR_TYPER_VLPIS (1 << 1) // Virtual LPIs
#define ARM_GICR_TYPER_DIRECTLPI (1 << 3) // Direct LPIs
#define ARM_GICR_TYPER_LAST (1 << 4) // Last Redistributor in series
#define ARM_GICR_TYPER_DPGS (1 << 5) // Disable Processor Group
// Selection Support
#define ARM_GICR_TYPER_PROCNO (0xFFFF << 8) // Processor Number
#define ARM_GICR_TYPER_COMMONLPIAFF (0x3 << 24) // Common LPI Affinity
#define ARM_GICR_TYPER_AFFINITY (0xFFFFFFFFULL << 32) // Redistributor Affinity
#define ARM_GICR_TYPER_GET_AFFINITY(TypeReg) (((TypeReg) & \
ARM_GICR_TYPER_AFFINITY) >> 32)
// GIC SGI & PPI Redistributor frame
#define ARM_GICR_ISENABLER 0x0100 // Interrupt Set-Enable Registers
#define ARM_GICR_ICENABLER 0x0180 // Interrupt Clear-Enable Registers
//
// GIC Cpu interface
//
#define ARM_GIC_ICCICR 0x00 // CPU Interface Control Register
#define ARM_GIC_ICCPMR 0x04 // Interrupt Priority Mask Register
#define ARM_GIC_ICCBPR 0x08 // Binary Point Register
@ -123,7 +104,9 @@ ArmGicGetInterfaceIdentification (
IN INTN GicInterruptInterfaceBase
);
//
// GIC Secure interfaces
//
VOID
EFIAPI
ArmGicSetupNonSecure (
@ -187,8 +170,7 @@ ArmGicSendSgiTo (
* in the GICv3 the register value is only the InterruptId.
*
* @param GicInterruptInterfaceBase Base Address of the GIC CPU Interface
* @param InterruptId InterruptId read from the Interrupt
* Acknowledge Register
* @param InterruptId InterruptId read from the Interrupt Acknowledge Register
*
* @retval value returned by the Interrupt Acknowledge Register
*
@ -238,12 +220,12 @@ ArmGicIsInterruptEnabled (
IN UINTN Source
);
//
// GIC revision 2 specific declarations
//
// Interrupts from 1020 to 1023 are considered as special interrupts
// (eg: spurious interrupts)
#define ARM_GIC_IS_SPECIAL_INTERRUPTS(Interrupt) \
(((Interrupt) >= 1020) && ((Interrupt) <= 1023))
// Interrupts from 1020 to 1023 are considered as special interrupts (eg: spurious interrupts)
#define ARM_GIC_IS_SPECIAL_INTERRUPTS(Interrupt) (((Interrupt) >= 1020) && ((Interrupt) <= 1023))
VOID
EFIAPI
@ -278,7 +260,9 @@ ArmGicV2EndOfInterrupt (
IN UINTN Source
);
//
// GIC revision 3 specific declarations
//
#define ICC_SRE_EL2_SRE (1 << 0)

View File

@ -41,14 +41,6 @@ typedef enum {
ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_UNCACHED_UNBUFFERED,
ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK,
ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_WRITE_BACK,
// On some platforms, memory mapped flash region is designed as not supporting
// shareable attribute, so WRITE_BACK_NONSHAREABLE is added for such special
// need.
// Do NOT use below two attributes if you are not sure.
ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK_NONSHAREABLE,
ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_WRITE_BACK_NONSHAREABLE,
ARM_MEMORY_REGION_ATTRIBUTE_WRITE_THROUGH,
ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_WRITE_THROUGH,
ARM_MEMORY_REGION_ATTRIBUTE_DEVICE,
@ -558,12 +550,6 @@ ArmReadSctlr (
VOID
);
VOID
EFIAPI
ArmWriteSctlr (
IN UINT32 Value
);
UINTN
EFIAPI
ArmReadHVBar (
@ -733,10 +719,4 @@ ArmWriteCntvOff (
UINT64 Val
);
UINTN
EFIAPI
ArmGetPhysicalAddressBits (
VOID
);
#endif // __ARM_LIB__

View File

@ -1,137 +0,0 @@
/** @file
Copyright (c) 2017-2018, Arm Limited. All rights reserved.
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
System Control and Management Interface V1.0
http://infocenter.arm.com/help/topic/com.arm.doc.den0056a/
DEN0056A_System_Control_and_Management_Interface.pdf
**/
#ifndef ARM_MTL_LIB_H_
#define ARM_MTL_LIB_H_
#include <Uefi/UefiBaseType.h>
// Ideally we don't need packed struct. However we can't rely on compilers.
#pragma pack(1)
typedef struct {
UINT32 Reserved1;
UINT32 ChannelStatus;
UINT64 Reserved2;
UINT32 Flags;
UINT32 Length;
UINT32 MessageHeader;
// NOTE: Since EDK2 does not allow flexible array member [] we declare
// here array of 1 element length. However below is used as a variable
// length array.
UINT32 Payload[1]; // size less object gives offset to payload.
} MTL_MAILBOX;
#pragma pack()
// Channel Type, Low-priority, and High-priority
typedef enum {
MTL_CHANNEL_TYPE_LOW = 0,
MTL_CHANNEL_TYPE_HIGH = 1
} MTL_CHANNEL_TYPE;
typedef struct {
UINT64 PhysicalAddress;
UINT32 ModifyMask;
UINT32 PreserveMask;
} MTL_DOORBELL;
typedef struct {
MTL_CHANNEL_TYPE ChannelType;
MTL_MAILBOX * CONST MailBox;
MTL_DOORBELL DoorBell;
} MTL_CHANNEL;
/** Wait until channel is free.
@param[in] Channel Pointer to a channel.
@param[in] TimeOutInMicroSeconds Time out in micro seconds.
@retval EFI_SUCCESS Channel is free.
@retval EFI_TIMEOUT Time out error.
**/
EFI_STATUS
MtlWaitUntilChannelFree (
IN MTL_CHANNEL *Channel,
IN UINTN TimeOutInMicroSeconds
);
/** Return the address of the message payload.
@param[in] Channel Pointer to a channel.
@retval UINT32* Pointer to the payload.
**/
UINT32*
MtlGetChannelPayload (
IN MTL_CHANNEL *Channel
);
/** Return pointer to a channel for the requested channel type.
@param[in] ChannelType ChannelType, Low or High priority channel.
MTL_CHANNEL_TYPE_LOW or
MTL_CHANNEL_TYPE_HIGH
@param[out] Channel Holds pointer to the channel.
@retval EFI_SUCCESS Pointer to channel is returned.
@retval EFI_UNSUPPORTED Requested channel type not supported.
**/
EFI_STATUS
MtlGetChannel (
IN MTL_CHANNEL_TYPE ChannelType,
OUT MTL_CHANNEL **Channel
);
/** Mark the channel busy and ring the doorbell.
@param[in] Channel Pointer to a channel.
@param[in] MessageHeader Message header.
@param[out] PayloadLength Message length.
@retval EFI_SUCCESS Message sent successfully.
@retval EFI_DEVICE_ERROR Channel is busy.
**/
EFI_STATUS
MtlSendMessage (
IN MTL_CHANNEL *Channel,
IN UINT32 MessageHeader,
OUT UINT32 PayloadLength
);
/** Wait for a response on a channel.
If channel is free after sending message, it implies SCP responded
with a response on the channel.
@param[in] Channel Pointer to a channel.
@retval EFI_SUCCESS Message received successfully.
@retval EFI_TIMEOUT Time out error.
**/
EFI_STATUS
MtlReceiveMessage (
IN MTL_CHANNEL *Channel,
OUT UINT32 *MessageHeader,
OUT UINT32 *PayloadLength
);
#endif /* ARM_MTL_LIB_H_ */

View File

@ -1,46 +0,0 @@
/** @file
*
* Copyright (c) 2016 - 2017, ARM Limited. All rights reserved.
*
* This program and the accompanying materials
* are licensed and made available under the terms and conditions of the BSD License
* which accompanies this distribution. The full text of the license may be found at
* http://opensource.org/licenses/bsd-license.php
*
* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
*
**/
#ifndef __ARM_SVC_LIB__
#define __ARM_SVC_LIB__
/**
* The size of the SVC arguments are different between AArch64 and AArch32.
* The native size is used for the arguments.
*/
typedef struct {
UINTN Arg0;
UINTN Arg1;
UINTN Arg2;
UINTN Arg3;
UINTN Arg4;
UINTN Arg5;
UINTN Arg6;
UINTN Arg7;
} ARM_SVC_ARGS;
/**
Trigger an SVC call
SVC calls can take up to 7 arguments and return up to 4 return values.
Therefore, the 4 first fields in the ARM_SVC_ARGS structure are used
for both input and output values.
**/
VOID
ArmCallSvc (
IN OUT ARM_SVC_ARGS *Args
);
#endif

View File

@ -0,0 +1,209 @@
/** @file
*
* Copyright (c) 2013-2015, ARM Limited. All rights reserved.
*
* This program and the accompanying materials
* are licensed and made available under the terms and conditions of the BSD License
* which accompanies this distribution. The full text of the license may be found at
* http://opensource.org/licenses/bsd-license.php
*
* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
*
**/
#ifndef __BDS_ENTRY_H__
#define __BDS_ENTRY_H__
/**
This is defined by the UEFI specs, don't change it
**/
typedef struct {
UINT16 LoadOptionIndex;
EFI_LOAD_OPTION *LoadOption;
UINTN LoadOptionSize;
UINT32 Attributes;
UINT16 FilePathListLength;
CHAR16 *Description;
EFI_DEVICE_PATH_PROTOCOL *FilePathList;
VOID* OptionalData;
UINTN OptionalDataSize;
} BDS_LOAD_OPTION;
/**
Connect a Device Path and return the handle of the driver that support this DevicePath
@param DevicePath Device Path of the File to connect
@param Handle Handle of the driver that support this DevicePath
@param RemainingDevicePath Remaining DevicePath nodes that do not match the driver DevicePath
@retval EFI_SUCCESS A driver that matches the Device Path has been found
@retval EFI_NOT_FOUND No handles match the search.
@retval EFI_INVALID_PARAMETER DevicePath or Handle is NULL
**/
EFI_STATUS
BdsConnectDevicePath (
IN EFI_DEVICE_PATH_PROTOCOL* DevicePath,
OUT EFI_HANDLE *Handle,
OUT EFI_DEVICE_PATH_PROTOCOL **RemainingDevicePath
);
/**
Connect all DXE drivers
@retval EFI_SUCCESS All drivers have been connected
@retval EFI_NOT_FOUND No handles match the search.
@retval EFI_OUT_OF_RESOURCES There is not resource pool memory to store the matching results.
**/
EFI_STATUS
BdsConnectAllDrivers (
VOID
);
/**
Return the value of a global variable defined by its VariableName.
The variable must be defined with the VendorGuid gEfiGlobalVariableGuid.
@param VariableName A Null-terminated string that is the name of the vendor's
variable.
@param DefaultValue Value returned by the function if the variable does not exist
@param DataSize On input, the size in bytes of the return Data buffer.
On output the size of data returned in Data.
@param Value Value read from the UEFI Variable or copy of the default value
if the UEFI Variable does not exist
@retval EFI_SUCCESS All drivers have been connected
@retval EFI_NOT_FOUND No handles match the search.
@retval EFI_OUT_OF_RESOURCES There is not resource pool memory to store the matching results.
**/
EFI_STATUS
GetGlobalEnvironmentVariable (
IN CONST CHAR16* VariableName,
IN VOID* DefaultValue,
IN OUT UINTN* Size,
OUT VOID** Value
);
/**
Return the value of the variable defined by its VariableName and VendorGuid
@param VariableName A Null-terminated string that is the name of the vendor's
variable.
@param VendorGuid A unique identifier for the vendor.
@param DefaultValue Value returned by the function if the variable does not exist
@param DataSize On input, the size in bytes of the return Data buffer.
On output the size of data returned in Data.
@param Value Value read from the UEFI Variable or copy of the default value
if the UEFI Variable does not exist
@retval EFI_SUCCESS All drivers have been connected
@retval EFI_NOT_FOUND No handles match the search.
@retval EFI_OUT_OF_RESOURCES There is not resource pool memory to store the matching results.
**/
EFI_STATUS
GetEnvironmentVariable (
IN CONST CHAR16* VariableName,
IN EFI_GUID* VendorGuid,
IN VOID* DefaultValue,
IN OUT UINTN* Size,
OUT VOID** Value
);
EFI_STATUS
BootOptionFromLoadOptionIndex (
IN UINT16 LoadOptionIndex,
OUT BDS_LOAD_OPTION** BdsLoadOption
);
EFI_STATUS
BootOptionFromLoadOptionVariable (
IN CHAR16* BootVariableName,
OUT BDS_LOAD_OPTION** BdsLoadOption
);
EFI_STATUS
BootOptionToLoadOptionVariable (
IN BDS_LOAD_OPTION* BdsLoadOption
);
UINT16
BootOptionAllocateBootIndex (
VOID
);
/**
Start an EFI Application from a Device Path
@param ParentImageHandle Handle of the calling image
@param DevicePath Location of the EFI Application
@retval EFI_SUCCESS All drivers have been connected
@retval EFI_NOT_FOUND The Linux kernel Device Path has not been found
@retval EFI_OUT_OF_RESOURCES There is not enough resource memory to store the matching results.
**/
EFI_STATUS
BdsStartEfiApplication (
IN EFI_HANDLE ParentImageHandle,
IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
IN UINTN LoadOptionsSize,
IN VOID* LoadOptions
);
EFI_STATUS
BdsLoadImage (
IN EFI_DEVICE_PATH *DevicePath,
IN EFI_ALLOCATE_TYPE Type,
IN OUT EFI_PHYSICAL_ADDRESS* Image,
OUT UINTN *FileSize
);
/**
* Call BS.ExitBootServices with the appropriate Memory Map information
*/
EFI_STATUS
ShutdownUefiBootServices (
VOID
);
/**
Locate an EFI application in a the Firmware Volumes by its name
@param EfiAppGuid Guid of the EFI Application into the Firmware Volume
@param DevicePath EFI Device Path of the EFI application
@return EFI_SUCCESS The function completed successfully.
@return EFI_NOT_FOUND The protocol could not be located.
@return EFI_OUT_OF_RESOURCES There are not enough resources to find the protocol.
**/
EFI_STATUS
LocateEfiApplicationInFvByName (
IN CONST CHAR16* EfiAppName,
OUT EFI_DEVICE_PATH **DevicePath
);
/**
Locate an EFI application in a the Firmware Volumes by its GUID
@param EfiAppGuid Guid of the EFI Application into the Firmware Volume
@param DevicePath EFI Device Path of the EFI application
@return EFI_SUCCESS The function completed successfully.
@return EFI_NOT_FOUND The protocol could not be located.
@return EFI_OUT_OF_RESOURCES There are not enough resources to find the protocol.
**/
EFI_STATUS
LocateEfiApplicationInFvByGuid (
IN CONST EFI_GUID *EfiAppGuid,
OUT EFI_DEVICE_PATH **DevicePath
);
#endif

View File

@ -1,123 +0,0 @@
/** @file
OP-TEE specific header file.
Copyright (c) 2018, Linaro Ltd. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#ifndef _OPTEE_H_
#define _OPTEE_H_
/*
* The 'Trusted OS Call UID' is supposed to return the following UUID for
* OP-TEE OS. This is a 128-bit value.
*/
#define OPTEE_OS_UID0 0x384fb3e0
#define OPTEE_OS_UID1 0xe7f811e3
#define OPTEE_OS_UID2 0xaf630002
#define OPTEE_OS_UID3 0xa5d5c51b
#define OPTEE_MESSAGE_ATTRIBUTE_TYPE_NONE 0x0
#define OPTEE_MESSAGE_ATTRIBUTE_TYPE_VALUE_INPUT 0x1
#define OPTEE_MESSAGE_ATTRIBUTE_TYPE_VALUE_OUTPUT 0x2
#define OPTEE_MESSAGE_ATTRIBUTE_TYPE_VALUE_INOUT 0x3
#define OPTEE_MESSAGE_ATTRIBUTE_TYPE_MEMORY_INPUT 0x9
#define OPTEE_MESSAGE_ATTRIBUTE_TYPE_MEMORY_OUTPUT 0xa
#define OPTEE_MESSAGE_ATTRIBUTE_TYPE_MEMORY_INOUT 0xb
#define OPTEE_MESSAGE_ATTRIBUTE_TYPE_MASK 0xff
#define OPTEE_SUCCESS 0x00000000
#define OPTEE_ORIGIN_COMMUNICATION 0x00000002
#define OPTEE_ERROR_COMMUNICATION 0xFFFF000E
typedef struct {
UINT64 BufferAddress;
UINT64 Size;
UINT64 SharedMemoryReference;
} OPTEE_MESSAGE_PARAM_MEMORY;
typedef struct {
UINT64 A;
UINT64 B;
UINT64 C;
} OPTEE_MESSAGE_PARAM_VALUE;
typedef struct {
UINT64 Attribute;
union {
OPTEE_MESSAGE_PARAM_MEMORY Memory;
OPTEE_MESSAGE_PARAM_VALUE Value;
} Union;
} OPTEE_MESSAGE_PARAM;
#define OPTEE_MAX_CALL_PARAMS 4
typedef struct {
UINT32 Command;
UINT32 Function;
UINT32 Session;
UINT32 CancelId;
UINT32 Pad;
UINT32 Return;
UINT32 ReturnOrigin;
UINT32 NumParams;
// NumParams tells the actual number of element in Params
OPTEE_MESSAGE_PARAM Params[OPTEE_MAX_CALL_PARAMS];
} OPTEE_MESSAGE_ARG;
typedef struct {
EFI_GUID Uuid; // [in] GUID/UUID of the Trusted Application
UINT32 Session; // [out] Session id
UINT32 Return; // [out] Return value
UINT32 ReturnOrigin; // [out] Origin of the return value
} OPTEE_OPEN_SESSION_ARG;
typedef struct {
UINT32 Function; // [in] Trusted Application function, specific to the TA
UINT32 Session; // [in] Session id
UINT32 Return; // [out] Return value
UINT32 ReturnOrigin; // [out] Origin of the return value
OPTEE_MESSAGE_PARAM Params[OPTEE_MAX_CALL_PARAMS]; // Params for function to be invoked
} OPTEE_INVOKE_FUNCTION_ARG;
BOOLEAN
EFIAPI
IsOpteePresent (
VOID
);
EFI_STATUS
EFIAPI
OpteeInit (
VOID
);
EFI_STATUS
EFIAPI
OpteeOpenSession (
IN OUT OPTEE_OPEN_SESSION_ARG *OpenSessionArg
);
EFI_STATUS
EFIAPI
OpteeCloseSession (
IN UINT32 Session
);
EFI_STATUS
EFIAPI
OpteeInvokeFunction (
IN OUT OPTEE_INVOKE_FUNCTION_ARG *InvokeFunctionArg
);
#endif

View File

@ -1,42 +0,0 @@
/** @file
Copyright (c) 2018, ARM Ltd. All rights reserved.
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#ifndef __STANDALONEMM_MMU_LIB__
#define __STANDALONEMM_MMU_LIB__
EFI_STATUS
ArmSetMemoryRegionNoExec (
IN EFI_PHYSICAL_ADDRESS BaseAddress,
IN UINT64 Length
);
EFI_STATUS
ArmClearMemoryRegionNoExec (
IN EFI_PHYSICAL_ADDRESS BaseAddress,
IN UINT64 Length
);
EFI_STATUS
ArmSetMemoryRegionReadOnly (
IN EFI_PHYSICAL_ADDRESS BaseAddress,
IN UINT64 Length
);
EFI_STATUS
ArmClearMemoryRegionReadOnly (
IN EFI_PHYSICAL_ADDRESS BaseAddress,
IN UINT64 Length
);
#endif /* __STANDALONEMM_MMU_LIB__ */

View File

@ -0,0 +1,665 @@
/** @file
Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#ifndef __UNCACHED_MEMORY_ALLOCATION_LIB_H__
#define __UNCACHED_MEMORY_ALLOCATION_LIB_H__
/**
Converts a cached or uncached address to a physical address suitable for use in SoC registers.
@param VirtualAddress The pointer to convert.
@return The physical address of the supplied virtual pointer.
**/
EFI_PHYSICAL_ADDRESS
ConvertToPhysicalAddress (
IN VOID *VirtualAddress
);
/**
Converts a cached or uncached address to a cached address.
@param Address The pointer to convert.
@return The address of the cached memory location corresponding to the input address.
**/
VOID *
ConvertToCachedAddress (
IN VOID *Address
);
/**
Converts a cached or uncached address to an uncached address.
@param Address The pointer to convert.
@return The address of the uncached memory location corresponding to the input address.
**/
VOID *
ConvertToUncachedAddress (
IN VOID *Address
);
/**
Allocates one or more 4KB pages of type EfiBootServicesData.
Allocates the number of 4KB pages of type EfiBootServicesData and returns a pointer to the
allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL
is returned. If there is not enough memory remaining to satisfy the request, then NULL is
returned.
@param Pages The number of 4 KB pages to allocate.
@return A pointer to the allocated buffer or NULL if allocation fails.
**/
VOID *
EFIAPI
UncachedAllocatePages (
IN UINTN Pages
);
/**
Allocates one or more 4KB pages of type EfiRuntimeServicesData.
Allocates the number of 4KB pages of type EfiRuntimeServicesData and returns a pointer to the
allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL
is returned. If there is not enough memory remaining to satisfy the request, then NULL is
returned.
@param Pages The number of 4 KB pages to allocate.
@return A pointer to the allocated buffer or NULL if allocation fails.
**/
VOID *
EFIAPI
UncachedAllocateRuntimePages (
IN UINTN Pages
);
/**
Allocates one or more 4KB pages of type EfiReservedMemoryType.
Allocates the number of 4KB pages of type EfiReservedMemoryType and returns a pointer to the
allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL
is returned. If there is not enough memory remaining to satisfy the request, then NULL is
returned.
@param Pages The number of 4 KB pages to allocate.
@return A pointer to the allocated buffer or NULL if allocation fails.
**/
VOID *
EFIAPI
UncachedAllocateReservedPages (
IN UINTN Pages
);
/**
Frees one or more 4KB pages that were previously allocated with one of the page allocation
functions in the Memory Allocation Library.
Frees the number of 4KB pages specified by Pages from the buffer specified by Buffer. Buffer
must have been allocated on a previous call to the page allocation services of the Memory
Allocation Library.
If Buffer was not allocated with a page allocation function in the Memory Allocation Library,
then ASSERT().
If Pages is zero, then ASSERT().
@param Buffer Pointer to the buffer of pages to free.
@param Pages The number of 4 KB pages to free.
**/
VOID
EFIAPI
UncachedFreePages (
IN VOID *Buffer,
IN UINTN Pages
);
/**
Allocates one or more 4KB pages of type EfiBootServicesData at a specified alignment.
Allocates the number of 4KB pages specified by Pages of type EfiBootServicesData with an
alignment specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is
returned. If there is not enough memory at the specified alignment remaining to satisfy the
request, then NULL is returned.
If Alignment is not a power of two and Alignment is not zero, then ASSERT().
@param Pages The number of 4 KB pages to allocate.
@param Alignment The requested alignment of the allocation. Must be a power of two.
If Alignment is zero, then byte alignment is used.
@return A pointer to the allocated buffer or NULL if allocation fails.
**/
VOID *
EFIAPI
UncachedAllocateAlignedPages (
IN UINTN Pages,
IN UINTN Alignment
);
/**
Allocates one or more 4KB pages of type EfiRuntimeServicesData at a specified alignment.
Allocates the number of 4KB pages specified by Pages of type EfiRuntimeServicesData with an
alignment specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is
returned. If there is not enough memory at the specified alignment remaining to satisfy the
request, then NULL is returned.
If Alignment is not a power of two and Alignment is not zero, then ASSERT().
@param Pages The number of 4 KB pages to allocate.
@param Alignment The requested alignment of the allocation. Must be a power of two.
If Alignment is zero, then byte alignment is used.
@return A pointer to the allocated buffer or NULL if allocation fails.
**/
VOID *
EFIAPI
UncachedAllocateAlignedRuntimePages (
IN UINTN Pages,
IN UINTN Alignment
);
/**
Allocates one or more 4KB pages of type EfiReservedMemoryType at a specified alignment.
Allocates the number of 4KB pages specified by Pages of type EfiReservedMemoryType with an
alignment specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is
returned. If there is not enough memory at the specified alignment remaining to satisfy the
request, then NULL is returned.
If Alignment is not a power of two and Alignment is not zero, then ASSERT().
@param Pages The number of 4 KB pages to allocate.
@param Alignment The requested alignment of the allocation. Must be a power of two.
If Alignment is zero, then byte alignment is used.
@return A pointer to the allocated buffer or NULL if allocation fails.
**/
VOID *
EFIAPI
UncachedAllocateAlignedReservedPages (
IN UINTN Pages,
IN UINTN Alignment
);
/**
Frees one or more 4KB pages that were previously allocated with one of the aligned page
allocation functions in the Memory Allocation Library.
Frees the number of 4KB pages specified by Pages from the buffer specified by Buffer. Buffer
must have been allocated on a previous call to the aligned page allocation services of the Memory
Allocation Library.
If Buffer was not allocated with an aligned page allocation function in the Memory Allocation
Library, then ASSERT().
If Pages is zero, then ASSERT().
@param Buffer Pointer to the buffer of pages to free.
@param Pages The number of 4 KB pages to free.
**/
VOID
EFIAPI
UncachedFreeAlignedPages (
IN VOID *Buffer,
IN UINTN Pages
);
/**
Allocates a buffer of type EfiBootServicesData.
Allocates the number bytes specified by AllocationSize of type EfiBootServicesData and returns a
pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is
returned. If there is not enough memory remaining to satisfy the request, then NULL is returned.
@param AllocationSize The number of bytes to allocate.
@return A pointer to the allocated buffer or NULL if allocation fails.
**/
VOID *
EFIAPI
UncachedAllocatePool (
IN UINTN AllocationSize
);
/**
Allocates a buffer of type EfiRuntimeServicesData.
Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData and returns
a pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is
returned. If there is not enough memory remaining to satisfy the request, then NULL is returned.
@param AllocationSize The number of bytes to allocate.
@return A pointer to the allocated buffer or NULL if allocation fails.
**/
VOID *
EFIAPI
UncachedAllocateRuntimePool (
IN UINTN AllocationSize
);
/**
Allocates a buffer of type EfieservedMemoryType.
Allocates the number bytes specified by AllocationSize of type EfieservedMemoryType and returns
a pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is
returned. If there is not enough memory remaining to satisfy the request, then NULL is returned.
@param AllocationSize The number of bytes to allocate.
@return A pointer to the allocated buffer or NULL if allocation fails.
**/
VOID *
EFIAPI
UncachedAllocateReservedPool (
IN UINTN AllocationSize
);
/**
Allocates and zeros a buffer of type EfiBootServicesData.
Allocates the number bytes specified by AllocationSize of type EfiBootServicesData, clears the
buffer with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a
valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the
request, then NULL is returned.
@param AllocationSize The number of bytes to allocate and zero.
@return A pointer to the allocated buffer or NULL if allocation fails.
**/
VOID *
EFIAPI
UncachedAllocateZeroPool (
IN UINTN AllocationSize
);
/**
Allocates and zeros a buffer of type EfiRuntimeServicesData.
Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData, clears the
buffer with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a
valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the
request, then NULL is returned.
@param AllocationSize The number of bytes to allocate and zero.
@return A pointer to the allocated buffer or NULL if allocation fails.
**/
VOID *
EFIAPI
UncachedAllocateRuntimeZeroPool (
IN UINTN AllocationSize
);
/**
Allocates and zeros a buffer of type EfiReservedMemoryType.
Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType, clears the
buffer with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a
valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the
request, then NULL is returned.
@param AllocationSize The number of bytes to allocate and zero.
@return A pointer to the allocated buffer or NULL if allocation fails.
**/
VOID *
EFIAPI
UncachedAllocateReservedZeroPool (
IN UINTN AllocationSize
);
/**
Copies a buffer to an allocated buffer of type EfiBootServicesData.
Allocates the number bytes specified by AllocationSize of type EfiBootServicesData, copies
AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the
allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there
is not enough memory remaining to satisfy the request, then NULL is returned.
If Buffer is NULL, then ASSERT().
If AllocationSize is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT().
@param AllocationSize The number of bytes to allocate and zero.
@param Buffer The buffer to copy to the allocated buffer.
@return A pointer to the allocated buffer or NULL if allocation fails.
**/
VOID *
EFIAPI
UncachedAllocateCopyPool (
IN UINTN AllocationSize,
IN CONST VOID *Buffer
);
/**
Copies a buffer to an allocated buffer of type EfiRuntimeServicesData.
Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData, copies
AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the
allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there
is not enough memory remaining to satisfy the request, then NULL is returned.
If Buffer is NULL, then ASSERT().
If AllocationSize is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT().
@param AllocationSize The number of bytes to allocate and zero.
@param Buffer The buffer to copy to the allocated buffer.
@return A pointer to the allocated buffer or NULL if allocation fails.
**/
VOID *
EFIAPI
UncachedAllocateRuntimeCopyPool (
IN UINTN AllocationSize,
IN CONST VOID *Buffer
);
/**
Copies a buffer to an allocated buffer of type EfiReservedMemoryType.
Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType, copies
AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the
allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there
is not enough memory remaining to satisfy the request, then NULL is returned.
If Buffer is NULL, then ASSERT().
If AllocationSize is greater than (MAX_ADDRESS ? Buffer + 1), then ASSERT().
@param AllocationSize The number of bytes to allocate and zero.
@param Buffer The buffer to copy to the allocated buffer.
@return A pointer to the allocated buffer or NULL if allocation fails.
**/
VOID *
EFIAPI
UncachedAllocateReservedCopyPool (
IN UINTN AllocationSize,
IN CONST VOID *Buffer
);
/**
Frees a buffer that was previously allocated with one of the pool allocation functions in the
Memory Allocation Library.
Frees the buffer specified by Buffer. Buffer must have been allocated on a previous call to the
pool allocation services of the Memory Allocation Library.
If Buffer was not allocated with a pool allocation function in the Memory Allocation Library,
then ASSERT().
@param Buffer Pointer to the buffer to free.
**/
VOID
EFIAPI
UncachedFreePool (
IN VOID *Buffer
);
/**
Allocates a buffer of type EfiBootServicesData at a specified alignment.
Allocates the number bytes specified by AllocationSize of type EfiBootServicesData with an
alignment specified by Alignment. The allocated buffer is returned. If AllocationSize is 0,
then a valid buffer of 0 size is returned. If there is not enough memory at the specified
alignment remaining to satisfy the request, then NULL is returned.
If Alignment is not a power of two and Alignment is not zero, then ASSERT().
@param AllocationSize The number of bytes to allocate.
@param Alignment The requested alignment of the allocation. Must be a power of two.
If Alignment is zero, then byte alignment is used.
@return A pointer to the allocated buffer or NULL if allocation fails.
**/
VOID *
EFIAPI
UncachedAllocateAlignedPool (
IN UINTN AllocationSize,
IN UINTN Alignment
);
/**
Allocates a buffer of type EfiRuntimeServicesData at a specified alignment.
Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData with an
alignment specified by Alignment. The allocated buffer is returned. If AllocationSize is 0,
then a valid buffer of 0 size is returned. If there is not enough memory at the specified
alignment remaining to satisfy the request, then NULL is returned.
If Alignment is not a power of two and Alignment is not zero, then ASSERT().
@param AllocationSize The number of bytes to allocate.
@param Alignment The requested alignment of the allocation. Must be a power of two.
If Alignment is zero, then byte alignment is used.
@return A pointer to the allocated buffer or NULL if allocation fails.
**/
VOID *
EFIAPI
UncachedAllocateAlignedRuntimePool (
IN UINTN AllocationSize,
IN UINTN Alignment
);
/**
Allocates a buffer of type EfieservedMemoryType at a specified alignment.
Allocates the number bytes specified by AllocationSize of type EfieservedMemoryType with an
alignment specified by Alignment. The allocated buffer is returned. If AllocationSize is 0,
then a valid buffer of 0 size is returned. If there is not enough memory at the specified
alignment remaining to satisfy the request, then NULL is returned.
If Alignment is not a power of two and Alignment is not zero, then ASSERT().
@param AllocationSize The number of bytes to allocate.
@param Alignment The requested alignment of the allocation. Must be a power of two.
If Alignment is zero, then byte alignment is used.
@return A pointer to the allocated buffer or NULL if allocation fails.
**/
VOID *
EFIAPI
UncachedAllocateAlignedReservedPool (
IN UINTN AllocationSize,
IN UINTN Alignment
);
/**
Allocates and zeros a buffer of type EfiBootServicesData at a specified alignment.
Allocates the number bytes specified by AllocationSize of type EfiBootServicesData with an
alignment specified by Alignment, clears the buffer with zeros, and returns a pointer to the
allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there
is not enough memory at the specified alignment remaining to satisfy the request, then NULL is
returned.
If Alignment is not a power of two and Alignment is not zero, then ASSERT().
@param AllocationSize The number of bytes to allocate.
@param Alignment The requested alignment of the allocation. Must be a power of two.
If Alignment is zero, then byte alignment is used.
@return A pointer to the allocated buffer or NULL if allocation fails.
**/
VOID *
EFIAPI
UncachedAllocateAlignedZeroPool (
IN UINTN AllocationSize,
IN UINTN Alignment
);
/**
Allocates and zeros a buffer of type EfiRuntimeServicesData at a specified alignment.
Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData with an
alignment specified by Alignment, clears the buffer with zeros, and returns a pointer to the
allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there
is not enough memory at the specified alignment remaining to satisfy the request, then NULL is
returned.
If Alignment is not a power of two and Alignment is not zero, then ASSERT().
@param AllocationSize The number of bytes to allocate.
@param Alignment The requested alignment of the allocation. Must be a power of two.
If Alignment is zero, then byte alignment is used.
@return A pointer to the allocated buffer or NULL if allocation fails.
**/
VOID *
EFIAPI
UncachedAllocateAlignedRuntimeZeroPool (
IN UINTN AllocationSize,
IN UINTN Alignment
);
/**
Allocates and zeros a buffer of type EfieservedMemoryType at a specified alignment.
Allocates the number bytes specified by AllocationSize of type EfieservedMemoryType with an
alignment specified by Alignment, clears the buffer with zeros, and returns a pointer to the
allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there
is not enough memory at the specified alignment remaining to satisfy the request, then NULL is
returned.
If Alignment is not a power of two and Alignment is not zero, then ASSERT().
@param AllocationSize The number of bytes to allocate.
@param Alignment The requested alignment of the allocation. Must be a power of two.
If Alignment is zero, then byte alignment is used.
@return A pointer to the allocated buffer or NULL if allocation fails.
**/
VOID *
EFIAPI
UncachedAllocateAlignedReservedZeroPool (
IN UINTN AllocationSize,
IN UINTN Alignment
);
/**
Copies a buffer to an allocated buffer of type EfiBootServicesData at a specified alignment.
Allocates the number bytes specified by AllocationSize of type EfiBootServicesData type with an
alignment specified by Alignment. The allocated buffer is returned. If AllocationSize is 0,
then a valid buffer of 0 size is returned. If there is not enough memory at the specified
alignment remaining to satisfy the request, then NULL is returned.
If Alignment is not a power of two and Alignment is not zero, then ASSERT().
@param AllocationSize The number of bytes to allocate.
@param Buffer The buffer to copy to the allocated buffer.
@param Alignment The requested alignment of the allocation. Must be a power of two.
If Alignment is zero, then byte alignment is used.
@return A pointer to the allocated buffer or NULL if allocation fails.
**/
VOID *
EFIAPI
UncachedAllocateAlignedCopyPool (
IN UINTN AllocationSize,
IN CONST VOID *Buffer,
IN UINTN Alignment
);
/**
Copies a buffer to an allocated buffer of type EfiRuntimeServicesData at a specified alignment.
Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData type with an
alignment specified by Alignment. The allocated buffer is returned. If AllocationSize is 0,
then a valid buffer of 0 size is returned. If there is not enough memory at the specified
alignment remaining to satisfy the request, then NULL is returned.
If Alignment is not a power of two and Alignment is not zero, then ASSERT().
@param AllocationSize The number of bytes to allocate.
@param Buffer The buffer to copy to the allocated buffer.
@param Alignment The requested alignment of the allocation. Must be a power of two.
If Alignment is zero, then byte alignment is used.
@return A pointer to the allocated buffer or NULL if allocation fails.
**/
VOID *
EFIAPI
UncachedAllocateAlignedRuntimeCopyPool (
IN UINTN AllocationSize,
IN CONST VOID *Buffer,
IN UINTN Alignment
);
/**
Copies a buffer to an allocated buffer of type EfiReservedMemoryType at a specified alignment.
Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType type with an
alignment specified by Alignment. The allocated buffer is returned. If AllocationSize is 0,
then a valid buffer of 0 size is returned. If there is not enough memory at the specified
alignment remaining to satisfy the request, then NULL is returned.
If Alignment is not a power of two and Alignment is not zero, then ASSERT().
@param AllocationSize The number of bytes to allocate.
@param Buffer The buffer to copy to the allocated buffer.
@param Alignment The requested alignment of the allocation. Must be a power of two.
If Alignment is zero, then byte alignment is used.
@return A pointer to the allocated buffer or NULL if allocation fails.
**/
VOID *
EFIAPI
UncachedAllocateAlignedReservedCopyPool (
IN UINTN AllocationSize,
IN CONST VOID *Buffer,
IN UINTN Alignment
);
/**
Frees a buffer that was previously allocated with one of the aligned pool allocation functions
in the Memory Allocation Library.
Frees the buffer specified by Buffer. Buffer must have been allocated on a previous call to the
aligned pool allocation services of the Memory Allocation Library.
If Buffer was not allocated with an aligned pool allocation function in the Memory Allocation
Library, then ASSERT().
@param Buffer Pointer to the buffer to free.
**/
VOID
EFIAPI
UncachedFreeAlignedPool (
IN VOID *Buffer
);
VOID
EFIAPI
UncachedSafeFreePool (
IN VOID *Buffer
);
#endif // __UNCACHED_MEMORY_ALLOCATION_LIB_H__

View File

@ -1,27 +0,0 @@
/** @file
Copyright (c) 2017-2018, Arm Limited. All rights reserved.
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
System Control and Management Interface V1.0
http://infocenter.arm.com/help/topic/com.arm.doc.den0056a/
DEN0056A_System_Control_and_Management_Interface.pdf
**/
#ifndef ARM_SCMI_H_
#define ARM_SCMI_H_
/* As per SCMI specification, maximum allowed ASCII string length
for various return values/parameters of a SCMI message.
*/
#define SCMI_MAX_STR_LEN 16
#endif /* ARM_SCMI_H_ */

View File

@ -1,174 +0,0 @@
/** @file
Copyright (c) 2017-2018, Arm Limited. All rights reserved.
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
System Control and Management Interface V1.0
http://infocenter.arm.com/help/topic/com.arm.doc.den0056a/
DEN0056A_System_Control_and_Management_Interface.pdf
**/
#ifndef ARM_SCMI_BASE_PROTOCOL_H_
#define ARM_SCMI_BASE_PROTOCOL_H_
#include <Protocol/ArmScmi.h>
#define BASE_PROTOCOL_VERSION 0x10000
#define NUM_PROTOCOL_MASK 0xFFU
#define NUM_AGENT_MASK 0xFFU
#define NUM_AGENT_SHIFT 0x8
/** Returns total number of protocols that are
implemented (excluding the Base protocol)
*/
#define SCMI_TOTAL_PROTOCOLS(Attr) (Attr & NUM_PROTOCOL_MASK)
// Returns total number of agents in the system.
#define SCMI_TOTAL_AGENTS(Attr) ((Attr >> NUM_AGENT_SHIFT) & NUM_AGENT_MASK)
#define ARM_SCMI_BASE_PROTOCOL_GUID { \
0xd7e5abe9, 0x33ab, 0x418e, {0x9f, 0x91, 0x72, 0xda, 0xe2, 0xba, 0x8e, 0x2f} \
}
extern EFI_GUID gArmScmiBaseProtocolGuid;
typedef struct _SCMI_BASE_PROTOCOL SCMI_BASE_PROTOCOL;
/** Return version of the Base protocol supported by SCP firmware.
@param[in] This A Pointer to SCMI_BASE_PROTOCOL Instance.
@param[out] Version Version of the supported SCMI Base protocol.
@retval EFI_SUCCESS The version of the protocol is returned.
@retval EFI_DEVICE_ERROR SCP returns an SCMI error.
@retval !(EFI_SUCCESS) Other errors.
**/
typedef
EFI_STATUS
(EFIAPI *SCMI_BASE_GET_VERSION) (
IN SCMI_BASE_PROTOCOL *This,
OUT UINT32 *Version
);
/** Return total number of SCMI protocols supported by the SCP firmware.
@param[in] This A Pointer to SCMI_BASE_PROTOCOL Instance.
@param[out] TotalProtocols Total number of SCMI protocols supported.
@retval EFI_SUCCESS Total number of protocols supported are returned.
@retval EFI_DEVICE_ERROR SCP returns a SCMI error.
@retval !(EFI_SUCCESS) Other errors.
**/
typedef
EFI_STATUS
(EFIAPI *SCMI_BASE_GET_TOTAL_PROTOCOLS) (
IN SCMI_BASE_PROTOCOL *This,
OUT UINT32 *TotalProtocols
);
/** Return vendor name.
@param[in] This A Pointer to SCMI_BASE_PROTOCOL Instance.
@param[out] VendorIdentifier Null terminated ASCII string of up to
16 bytes with a vendor name.
@retval EFI_SUCCESS VendorIdentifier is returned.
@retval EFI_DEVICE_ERROR SCP returns a SCMI error.
@retval !(EFI_SUCCESS) Other errors.
**/
typedef
EFI_STATUS
(EFIAPI *SCMI_BASE_DISCOVER_VENDOR) (
IN SCMI_BASE_PROTOCOL *This,
OUT UINT8 VendorIdentifier[SCMI_MAX_STR_LEN]
);
/** Return sub vendor name.
@param[in] This A Pointer to SCMI_BASE_PROTOCOL Instance.
@param[out] VendorIdentifier Null terminated ASCII string of up to
16 bytes with a vendor name.
@retval EFI_SUCCESS VendorIdentifier is returned.
@retval EFI_DEVICE_ERROR SCP returns a SCMI error.
@retval !(EFI_SUCCESS) Other errors.
**/
typedef
EFI_STATUS
(EFIAPI *SCMI_BASE_DISCOVER_SUB_VENDOR) (
IN SCMI_BASE_PROTOCOL *This,
OUT UINT8 VendorIdentifier[SCMI_MAX_STR_LEN]
);
/** Return implementation version.
@param[in] This A Pointer to SCMI_BASE_PROTOCOL Instance.
@param[out] ImplementationVersion Vendor specific implementation version.
@retval EFI_SUCCESS Implementation version is returned.
@retval EFI_DEVICE_ERROR SCP returns a SCMI error.
@retval !(EFI_SUCCESS) Other errors.
**/
typedef
EFI_STATUS
(EFIAPI *SCMI_BASE_DISCOVER_IMPLEMENTATION_VERSION) (
IN SCMI_BASE_PROTOCOL *This,
OUT UINT32 *ImplementationVersion
);
/** Return list of protocols.
@param[in] This A Pointer to SCMI_BASE_PROTOCOL Instance.
@param[out] ProtocolListSize Size of the ProtocolList.
@param[out] ProtocolList Protocol list.
@retval EFI_SUCCESS List of protocols is returned.
@retval EFI_BUFFER_TOO_SMALL ProtocolListSize is too small for the result.
It has been updated to the size needed.
@retval EFI_DEVICE_ERROR SCP returns a SCMI error.
@retval !(EFI_SUCCESS) Other errors.
**/
typedef
EFI_STATUS
(EFIAPI *SCMI_BASE_DISCOVER_LIST_PROTOCOLS) (
IN SCMI_BASE_PROTOCOL *This,
IN OUT UINT32 *ProtocolListSize,
OUT UINT8 *ProtocolList
);
// Base protocol.
typedef struct _SCMI_BASE_PROTOCOL {
SCMI_BASE_GET_VERSION GetVersion;
SCMI_BASE_GET_TOTAL_PROTOCOLS GetTotalProtocols;
SCMI_BASE_DISCOVER_VENDOR DiscoverVendor;
SCMI_BASE_DISCOVER_SUB_VENDOR DiscoverSubVendor;
SCMI_BASE_DISCOVER_IMPLEMENTATION_VERSION DiscoverImplementationVersion;
SCMI_BASE_DISCOVER_LIST_PROTOCOLS DiscoverListProtocols;
} SCMI_BASE_PROTOCOL;
// SCMI Message IDs for Base protocol.
typedef enum {
SCMI_MESSAGE_ID_BASE_DISCOVER_VENDOR = 0x3,
SCMI_MESSAGE_ID_BASE_DISCOVER_SUB_VENDOR = 0x4,
SCMI_MESSAGE_ID_BASE_DISCOVER_IMPLEMENTATION_VERSION = 0x5,
SCMI_MESSAGE_ID_BASE_DISCOVER_LIST_PROTOCOLS = 0x6
} SCMI_MESSAGE_ID_BASE;
#endif /* ARM_SCMI_BASE_PROTOCOL_H_ */

View File

@ -1,197 +0,0 @@
/** @file
Copyright (c) 2017-2018, Arm Limited. All rights reserved.
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
System Control and Management Interface V1.0
http://infocenter.arm.com/help/topic/com.arm.doc.den0056a/
DEN0056A_System_Control_and_Management_Interface.pdf
**/
#ifndef ARM_SCMI_CLOCK2_PROTOCOL_H_
#define ARM_SCMI_CLOCK2_PROTOCOL_H_
#include <Protocol/ArmScmi.h>
#include <Protocol/ArmScmiClockProtocol.h>
#define ARM_SCMI_CLOCK2_PROTOCOL_GUID { \
0xb8d8caf2, 0x9e94, 0x462c, { 0xa8, 0x34, 0x6c, 0x99, 0xfc, 0x05, 0xef, 0xcf } \
}
extern EFI_GUID gArmScmiClock2ProtocolGuid;
#define SCMI_CLOCK2_PROTOCOL_VERSION 1
typedef struct _SCMI_CLOCK2_PROTOCOL SCMI_CLOCK2_PROTOCOL;
// Protocol Interface functions.
/** Return version of the clock management protocol supported by SCP firmware.
@param[in] This A Pointer to SCMI_CLOCK2_PROTOCOL Instance.
@param[out] Version Version of the supported SCMI Clock management protocol.
@retval EFI_SUCCESS The version is returned.
@retval EFI_DEVICE_ERROR SCP returns an SCMI error.
@retval !(EFI_SUCCESS) Other errors.
**/
typedef
EFI_STATUS
(EFIAPI *SCMI_CLOCK2_GET_VERSION) (
IN SCMI_CLOCK2_PROTOCOL *This,
OUT UINT32 *Version
);
/** Return total number of clock devices supported by the clock management
protocol.
@param[in] This A Pointer to SCMI_CLOCK2_PROTOCOL Instance.
@param[out] TotalClocks Total number of clocks supported.
@retval EFI_SUCCESS Total number of clocks supported is returned.
@retval EFI_DEVICE_ERROR SCP returns an SCMI error.
@retval !(EFI_SUCCESS) Other errors.
**/
typedef
EFI_STATUS
(EFIAPI *SCMI_CLOCK2_GET_TOTAL_CLOCKS) (
IN SCMI_CLOCK2_PROTOCOL *This,
OUT UINT32 *TotalClocks
);
/** Return attributes of a clock device.
@param[in] This A Pointer to SCMI_CLOCK2_PROTOCOL Instance.
@param[in] ClockId Identifier for the clock device.
@param[out] Enabled If TRUE, the clock device is enabled.
@param[out] ClockAsciiName A NULL terminated ASCII string with the clock
name, of up to 16 bytes.
@retval EFI_SUCCESS Clock device attributes are returned.
@retval EFI_DEVICE_ERROR SCP returns an SCMI error.
@retval !(EFI_SUCCESS) Other errors.
**/
typedef
EFI_STATUS
(EFIAPI *SCMI_CLOCK2_GET_CLOCK_ATTRIBUTES) (
IN SCMI_CLOCK2_PROTOCOL *This,
IN UINT32 ClockId,
OUT BOOLEAN *Enabled,
OUT CHAR8 *ClockAsciiName
);
/** Return list of rates supported by a given clock device.
@param[in] This A pointer to SCMI_CLOCK2_PROTOCOL Instance.
@param[in] ClockId Identifier for the clock device.
@param[out] Format SCMI_CLOCK_RATE_FORMAT_DISCRETE: Clock device
supports range of clock rates which are non-linear.
SCMI_CLOCK_RATE_FORMAT_LINEAR: Clock device supports
range of linear clock rates from Min to Max in steps.
@param[out] TotalRates Total number of rates.
@param[in,out] RateArraySize Size of the RateArray.
@param[out] RateArray List of clock rates.
@retval EFI_SUCCESS List of clock rates are returned.
@retval EFI_DEVICE_ERROR SCP returns an SCMI error.
@retval EFI_BUFFER_TOO_SMALL RateArraySize is too small for the result.
It has been updated to the size needed.
@retval !(EFI_SUCCESS) Other errors.
**/
typedef
EFI_STATUS
(EFIAPI *SCMI_CLOCK2_DESCRIBE_RATES) (
IN SCMI_CLOCK2_PROTOCOL *This,
IN UINT32 ClockId,
OUT SCMI_CLOCK_RATE_FORMAT *Format,
OUT UINT32 *TotalRates,
IN OUT UINT32 *RateArraySize,
OUT SCMI_CLOCK_RATE *RateArray
);
/** Get clock rate.
@param[in] This A Pointer to SCMI_CLOCK2_PROTOCOL Instance.
@param[in] ClockId Identifier for the clock device.
@param[out] Rate Clock rate.
@retval EFI_SUCCESS Clock rate is returned.
@retval EFI_DEVICE_ERROR SCP returns an SCMI error.
@retval !(EFI_SUCCESS) Other errors.
**/
typedef
EFI_STATUS
(EFIAPI *SCMI_CLOCK2_RATE_GET) (
IN SCMI_CLOCK2_PROTOCOL *This,
IN UINT32 ClockId,
OUT UINT64 *Rate
);
/** Set clock rate.
@param[in] This A Pointer to SCMI_CLOCK2_PROTOCOL Instance.
@param[in] ClockId Identifier for the clock device.
@param[in] Rate Clock rate.
@retval EFI_SUCCESS Clock rate set success.
@retval EFI_DEVICE_ERROR SCP returns an SCMI error.
@retval !(EFI_SUCCESS) Other errors.
**/
typedef
EFI_STATUS
(EFIAPI *SCMI_CLOCK2_RATE_SET) (
IN SCMI_CLOCK2_PROTOCOL *This,
IN UINT32 ClockId,
IN UINT64 Rate
);
/** Enable/Disable specified clock.
Function is only available under gArmScmiClock2ProtocolGuid
@param[in] This A Pointer to SCMI_CLOCK2_PROTOCOL Instance.
@param[in] ClockId Identifier for the clock device.
@param[in] Enable TRUE to enable, FALSE to disable.
@retval EFI_SUCCESS Clock enable/disable successful.
@retval EFI_DEVICE_ERROR SCP returns an SCMI error.
@retval !(EFI_SUCCESS) Other errors.
**/
typedef
EFI_STATUS
(EFIAPI *SCMI_CLOCK2_ENABLE) (
IN SCMI_CLOCK2_PROTOCOL *This,
IN UINT32 ClockId,
IN BOOLEAN Enable
);
typedef struct _SCMI_CLOCK2_PROTOCOL {
SCMI_CLOCK2_GET_VERSION GetVersion;
SCMI_CLOCK2_GET_TOTAL_CLOCKS GetTotalClocks;
SCMI_CLOCK2_GET_CLOCK_ATTRIBUTES GetClockAttributes;
SCMI_CLOCK2_DESCRIBE_RATES DescribeRates;
SCMI_CLOCK2_RATE_GET RateGet;
SCMI_CLOCK2_RATE_SET RateSet;
// Extension to original ClockProtocol, added here so SCMI_CLOCK2_PROTOCOL
// can be cast to SCMI_CLOCK_PROTOCOL
UINTN Version; // For future expandability
SCMI_CLOCK2_ENABLE Enable;
} SCMI_CLOCK2_PROTOCOL;
#endif /* ARM_SCMI_CLOCK2_PROTOCOL_H_ */

View File

@ -1,218 +0,0 @@
/** @file
Copyright (c) 2017-2018, Arm Limited. All rights reserved.
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
System Control and Management Interface V1.0
http://infocenter.arm.com/help/topic/com.arm.doc.den0056a/
DEN0056A_System_Control_and_Management_Interface.pdf
**/
#ifndef ARM_SCMI_CLOCK_PROTOCOL_H_
#define ARM_SCMI_CLOCK_PROTOCOL_H_
#include <Protocol/ArmScmi.h>
#define ARM_SCMI_CLOCK_PROTOCOL_GUID { \
0x91ce67a8, 0xe0aa, 0x4012, {0xb9, 0x9f, 0xb6, 0xfc, 0xf3, 0x4, 0x8e, 0xaa} \
}
extern EFI_GUID gArmScmiClockProtocolGuid;
// Message Type for clock management protocol.
typedef enum {
SCMI_MESSAGE_ID_CLOCK_ATTRIBUTES = 0x3,
SCMI_MESSAGE_ID_CLOCK_DESCRIBE_RATES = 0x4,
SCMI_MESSAGE_ID_CLOCK_RATE_SET = 0x5,
SCMI_MESSAGE_ID_CLOCK_RATE_GET = 0x6,
SCMI_MESSAGE_ID_CLOCK_CONFIG_SET = 0x7
} SCMI_MESSAGE_ID_CLOCK;
typedef enum {
SCMI_CLOCK_RATE_FORMAT_DISCRETE, // Non-linear range.
SCMI_CLOCK_RATE_FORMAT_LINEAR // Linear range.
} SCMI_CLOCK_RATE_FORMAT;
// Clock management protocol version.
#define SCMI_CLOCK_PROTOCOL_VERSION 0x10000
#define SCMI_CLOCK_PROTOCOL_PENDING_ASYNC_RATES_MASK 0xFFU
#define SCMI_CLOCK_PROTOCOL_PENDING_ASYNC_RATES_SHIFT 16
#define SCMI_CLOCK_PROTOCOL_NUM_CLOCKS_MASK 0xFFFFU
/** Total number of pending asynchronous clock rates changes
supported by the SCP, Attr Bits[23:16]
*/
#define SCMI_CLOCK_PROTOCOL_MAX_ASYNC_CLK_RATES(Attr) ( \
(Attr >> SCMI_CLOCK_PROTOCOL_PENDING_ASYNC_RATES_SHIFT) && \
SCMI_CLOCK_PROTOCOL_PENDING_ASYNC_RATES_MASK)
// Total of clock devices supported by the SCP, Attr Bits[15:0]
#define SCMI_CLOCK_PROTOCOL_TOTAL_CLKS(Attr) (Attr & SCMI_CLOCK_PROTOCOL_NUM_CLOCKS_MASK)
#pragma pack(1)
/* Depending on the format (linear/non-linear) supported by a clock device
either Rate or Min/Max/Step triplet is valid.
*/
typedef struct {
union {
UINT64 Min;
UINT64 Rate;
};
UINT64 Max;
UINT64 Step;
} SCMI_CLOCK_RATE;
#pragma pack()
typedef struct _SCMI_CLOCK_PROTOCOL SCMI_CLOCK_PROTOCOL;
// Protocol Interface functions.
/** Return version of the clock management protocol supported by SCP firmware.
@param[in] This A Pointer to SCMI_CLOCK_PROTOCOL Instance.
@param[out] Version Version of the supported SCMI Clock management protocol.
@retval EFI_SUCCESS The version is returned.
@retval EFI_DEVICE_ERROR SCP returns an SCMI error.
@retval !(EFI_SUCCESS) Other errors.
**/
typedef
EFI_STATUS
(EFIAPI *SCMI_CLOCK_GET_VERSION) (
IN SCMI_CLOCK_PROTOCOL *This,
OUT UINT32 *Version
);
/** Return total number of clock devices supported by the clock management
protocol.
@param[in] This A Pointer to SCMI_CLOCK_PROTOCOL Instance.
@param[out] TotalClocks Total number of clocks supported.
@retval EFI_SUCCESS Total number of clocks supported is returned.
@retval EFI_DEVICE_ERROR SCP returns an SCMI error.
@retval !(EFI_SUCCESS) Other errors.
**/
typedef
EFI_STATUS
(EFIAPI *SCMI_CLOCK_GET_TOTAL_CLOCKS) (
IN SCMI_CLOCK_PROTOCOL *This,
OUT UINT32 *TotalClocks
);
/** Return attributes of a clock device.
@param[in] This A Pointer to SCMI_CLOCK_PROTOCOL Instance.
@param[in] ClockId Identifier for the clock device.
@param[out] Enabled If TRUE, the clock device is enabled.
@param[out] ClockAsciiName A NULL terminated ASCII string with the clock
name, of up to 16 bytes.
@retval EFI_SUCCESS Clock device attributes are returned.
@retval EFI_DEVICE_ERROR SCP returns an SCMI error.
@retval !(EFI_SUCCESS) Other errors.
**/
typedef
EFI_STATUS
(EFIAPI *SCMI_CLOCK_GET_CLOCK_ATTRIBUTES) (
IN SCMI_CLOCK_PROTOCOL *This,
IN UINT32 ClockId,
OUT BOOLEAN *Enabled,
OUT CHAR8 *ClockAsciiName
);
/** Return list of rates supported by a given clock device.
@param[in] This A pointer to SCMI_CLOCK_PROTOCOL Instance.
@param[in] ClockId Identifier for the clock device.
@param[out] Format SCMI_CLOCK_RATE_FORMAT_DISCRETE: Clock device
supports range of clock rates which are non-linear.
SCMI_CLOCK_RATE_FORMAT_LINEAR: Clock device supports
range of linear clock rates from Min to Max in steps.
@param[out] TotalRates Total number of rates.
@param[in,out] RateArraySize Size of the RateArray.
@param[out] RateArray List of clock rates.
@retval EFI_SUCCESS List of clock rates are returned.
@retval EFI_DEVICE_ERROR SCP returns an SCMI error.
@retval EFI_BUFFER_TOO_SMALL RateArraySize is too small for the result.
It has been updated to the size needed.
@retval !(EFI_SUCCESS) Other errors.
**/
typedef
EFI_STATUS
(EFIAPI *SCMI_CLOCK_DESCRIBE_RATES) (
IN SCMI_CLOCK_PROTOCOL *This,
IN UINT32 ClockId,
OUT SCMI_CLOCK_RATE_FORMAT *Format,
OUT UINT32 *TotalRates,
IN OUT UINT32 *RateArraySize,
OUT SCMI_CLOCK_RATE *RateArray
);
/** Get clock rate.
@param[in] This A Pointer to SCMI_CLOCK_PROTOCOL Instance.
@param[in] ClockId Identifier for the clock device.
@param[out] Rate Clock rate.
@retval EFI_SUCCESS Clock rate is returned.
@retval EFI_DEVICE_ERROR SCP returns an SCMI error.
@retval !(EFI_SUCCESS) Other errors.
**/
typedef
EFI_STATUS
(EFIAPI *SCMI_CLOCK_RATE_GET) (
IN SCMI_CLOCK_PROTOCOL *This,
IN UINT32 ClockId,
OUT UINT64 *Rate
);
/** Set clock rate.
@param[in] This A Pointer to SCMI_CLOCK_PROTOCOL Instance.
@param[in] ClockId Identifier for the clock device.
@param[in] Rate Clock rate.
@retval EFI_SUCCESS Clock rate set success.
@retval EFI_DEVICE_ERROR SCP returns an SCMI error.
@retval !(EFI_SUCCESS) Other errors.
**/
typedef
EFI_STATUS
(EFIAPI *SCMI_CLOCK_RATE_SET) (
IN SCMI_CLOCK_PROTOCOL *This,
IN UINT32 ClockId,
IN UINT64 Rate
);
typedef struct _SCMI_CLOCK_PROTOCOL {
SCMI_CLOCK_GET_VERSION GetVersion;
SCMI_CLOCK_GET_TOTAL_CLOCKS GetTotalClocks;
SCMI_CLOCK_GET_CLOCK_ATTRIBUTES GetClockAttributes;
SCMI_CLOCK_DESCRIBE_RATES DescribeRates;
SCMI_CLOCK_RATE_GET RateGet;
SCMI_CLOCK_RATE_SET RateSet;
} SCMI_CLOCK_PROTOCOL;
#endif /* ARM_SCMI_CLOCK_PROTOCOL_H_ */

View File

@ -1,265 +0,0 @@
/** @file
Copyright (c) 2017-2018, Arm Limited. All rights reserved.
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
System Control and Management Interface V1.0
http://infocenter.arm.com/help/topic/com.arm.doc.den0056a/
DEN0056A_System_Control_and_Management_Interface.pdf
**/
#ifndef ARM_SCMI_PERFORMANCE_PROTOCOL_H_
#define ARM_SCMI_PERFORMANCE_PROTOCOL_H_
#include <Protocol/ArmScmi.h>
#define PERFORMANCE_PROTOCOL_VERSION 0x10000
#define ARM_SCMI_PERFORMANCE_PROTOCOL_GUID { \
0x9b8ba84, 0x3dd3, 0x49a6, {0xa0, 0x5a, 0x31, 0x34, 0xa5, 0xf0, 0x7b, 0xad} \
}
extern EFI_GUID gArmScmiPerformanceProtocolGuid;
typedef struct _SCMI_PERFORMANCE_PROTOCOL SCMI_PERFORMANCE_PROTOCOL;
#pragma pack(1)
#define POWER_IN_MW_SHIFT 16
#define POWER_IN_MW_MASK 0x1
#define NUM_PERF_DOMAINS_MASK 0xFFFF
// Total number of performance domains, Attr Bits [15:0]
#define SCMI_PERF_TOTAL_DOMAINS(Attr) (Attr & NUM_PERF_DOMAINS_MASK)
// A flag to express power values in mW or platform specific way, Attr Bit [16]
#define SCMI_PERF_POWER_IN_MW(Attr) ((Attr >> POWER_IN_MW_SHIFT) & \
POWER_IN_MW_MASK)
// Performance protocol attributes return values.
typedef struct {
UINT32 Attributes;
UINT64 StatisticsAddress;
UINT32 StatisticsLen;
} SCMI_PERFORMANCE_PROTOCOL_ATTRIBUTES;
#define SCMI_PERF_SUPPORT_LVL_CHANGE_NOTIFY(Attr) ((Attr >> 28) & 0x1)
#define SCMI_PERF_SUPPORT_LIM_CHANGE_NOTIFY(Attr) ((Attr >> 29) & 0x1)
#define SCMI_PERF_SUPPORT_SET_LVL(Attr) ((Attr >> 30) & 0x1)
#define SCMI_PERF_SUPPORT_SET_LIM(Attr) ((Attr >> 31) & 0x1)
#define SCMI_PERF_RATE_LIMIT(RateLimit) (RateLimit & 0xFFF)
// Performance protocol domain attributes.
typedef struct {
UINT32 Attributes;
UINT32 RateLimit;
UINT32 SustainedFreq;
UINT32 SustainedPerfLevel;
UINT8 Name[SCMI_MAX_STR_LEN];
} SCMI_PERFORMANCE_DOMAIN_ATTRIBUTES;
// Worst case latency in microseconds, Bits[15:0]
#define PERF_LATENCY_MASK 0xFFFF
#define SCMI_PERFORMANCE_PROTOCOL_LATENCY(Latency) (Latency & PERF_LATENCY_MASK)
// Performance protocol performance level.
typedef struct {
UINT32 Level;
UINT32 PowerCost;
UINT32 Latency;
} SCMI_PERFORMANCE_LEVEL;
// Performance protocol performance limit.
typedef struct {
UINT32 RangeMax;
UINT32 RangeMin;
} SCMI_PERFORMANCE_LIMITS;
#pragma pack()
/** Return version of the performance management protocol supported by SCP.
firmware.
@param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL Instance.
@param[out] Version Version of the supported SCMI performance management
protocol.
@retval EFI_SUCCESS The version is returned.
@retval EFI_DEVICE_ERROR SCP returns an SCMI error.
@retval !(EFI_SUCCESS) Other errors.
**/
typedef
EFI_STATUS
(EFIAPI *SCMI_PERFORMANCE_GET_VERSION) (
IN SCMI_PERFORMANCE_PROTOCOL *This,
OUT UINT32 *Version
);
/** Return protocol attributes of the performance management protocol.
@param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL Instance.
@param[out] Attributes Protocol attributes.
@retval EFI_SUCCESS Protocol attributes are returned.
@retval EFI_DEVICE_ERROR SCP returns an SCMI error.
@retval !(EFI_SUCCESS) Other errors.
**/
typedef
EFI_STATUS
(EFIAPI *SCMI_PERFORMANCE_GET_ATTRIBUTES) (
IN SCMI_PERFORMANCE_PROTOCOL *This,
OUT SCMI_PERFORMANCE_PROTOCOL_ATTRIBUTES *Attributes
);
/** Return performance domain attributes.
@param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL Instance.
@param[in] DomainId Identifier for the performance domain.
@param[out] Attributes Performance domain attributes.
@retval EFI_SUCCESS Domain attributes are returned.
@retval EFI_DEVICE_ERROR SCP returns an SCMI error.
@retval !(EFI_SUCCESS) Other errors.
**/
typedef
EFI_STATUS
(EFIAPI *SCMI_PERFORMANCE_GET_DOMAIN_ATTRIBUTES) (
IN SCMI_PERFORMANCE_PROTOCOL *This,
IN UINT32 DomainId,
OUT SCMI_PERFORMANCE_DOMAIN_ATTRIBUTES *DomainAttributes
);
/** Return list of performance domain levels of a given domain.
@param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL Instance.
@param[in] DomainId Identifier for the performance domain.
@param[out] NumLevels Total number of levels a domain can support.
@param[in,out] LevelArraySize Size of the performance level array.
@param[out] LevelArray Array of the performance levels.
@retval EFI_SUCCESS Domain levels are returned.
@retval EFI_DEVICE_ERROR SCP returns an SCMI error.
@retval EFI_BUFFER_TOO_SMALL LevelArraySize is too small for the result.
It has been updated to the size needed.
@retval !(EFI_SUCCESS) Other errors.
**/
typedef
EFI_STATUS
(EFIAPI *SCMI_PERFORMANCE_DESCRIBE_LEVELS) (
IN SCMI_PERFORMANCE_PROTOCOL *This,
IN UINT32 DomainId,
OUT UINT32 *NumLevels,
IN OUT UINT32 *LevelArraySize,
OUT SCMI_PERFORMANCE_LEVEL *LevelArray
);
/** Set performance limits of a domain.
@param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL Instance.
@param[in] DomainId Identifier for the performance domain.
@param[in] Limit Performance limit to set.
@retval EFI_SUCCESS Performance limits set successfully.
@retval EFI_DEVICE_ERROR SCP returns an SCMI error.
@retval !(EFI_SUCCESS) Other errors.
**/
typedef
EFI_STATUS
(EFIAPI *SCMI_PERFORMANCE_LIMITS_SET) (
IN SCMI_PERFORMANCE_PROTOCOL *This,
IN UINT32 DomainId,
IN SCMI_PERFORMANCE_LIMITS *Limits
);
/** Get performance limits of a domain.
@param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL Instance.
@param[in] DomainId Identifier for the performance domain.
@param[out] Limit Performance Limits of the domain.
@retval EFI_SUCCESS Performance limits are returned.
@retval EFI_DEVICE_ERROR SCP returns an SCMI error.
@retval !(EFI_SUCCESS) Other errors.
**/
typedef
EFI_STATUS
(EFIAPI *SCMI_PERFORMANCE_LIMITS_GET) (
SCMI_PERFORMANCE_PROTOCOL *This,
UINT32 DomainId,
SCMI_PERFORMANCE_LIMITS *Limits
);
/** Set performance level of a domain.
@param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL Instance.
@param[in] DomainId Identifier for the performance domain.
@param[in] Level Performance level of the domain.
@retval EFI_SUCCESS Performance level set successfully.
@retval EFI_DEVICE_ERROR SCP returns an SCMI error.
@retval !(EFI_SUCCESS) Other errors.
**/
typedef
EFI_STATUS
(EFIAPI *SCMI_PERFORMANCE_LEVEL_SET) (
IN SCMI_PERFORMANCE_PROTOCOL *This,
IN UINT32 DomainId,
IN UINT32 Level
);
/** Get performance level of a domain.
@param[in] This A Pointer to SCMI_PERFORMANCE_PROTOCOL Instance.
@param[in] DomainId Identifier for the performance domain.
@param[out] Level Performance level of the domain.
@retval EFI_SUCCESS Performance level got successfully.
@retval EFI_DEVICE_ERROR SCP returns an SCMI error.
@retval !(EFI_SUCCESS) Other errors.
**/
typedef
EFI_STATUS
(EFIAPI *SCMI_PERFORMANCE_LEVEL_GET) (
IN SCMI_PERFORMANCE_PROTOCOL *This,
IN UINT32 DomainId,
OUT UINT32 *Level
);
typedef struct _SCMI_PERFORMANCE_PROTOCOL {
SCMI_PERFORMANCE_GET_VERSION GetVersion;
SCMI_PERFORMANCE_GET_ATTRIBUTES GetProtocolAttributes;
SCMI_PERFORMANCE_GET_DOMAIN_ATTRIBUTES GetDomainAttributes;
SCMI_PERFORMANCE_DESCRIBE_LEVELS DescribeLevels;
SCMI_PERFORMANCE_LIMITS_SET LimitsSet;
SCMI_PERFORMANCE_LIMITS_GET LimitsGet;
SCMI_PERFORMANCE_LEVEL_SET LevelSet;
SCMI_PERFORMANCE_LEVEL_GET LevelGet;
} SCMI_PERFORMANCE_PROTOCOL;
typedef enum {
SCMI_MESSAGE_ID_PERFORMANCE_DOMAIN_ATTRIBUTES = 0x3,
SCMI_MESSAGE_ID_PERFORMANCE_DESCRIBE_LEVELS = 0x4,
SCMI_MESSAGE_ID_PERFORMANCE_LIMITS_SET = 0x5,
SCMI_MESSAGE_ID_PERFORMANCE_LIMITS_GET = 0x6,
SCMI_MESSAGE_ID_PERFORMANCE_LEVEL_SET = 0x7,
SCMI_MESSAGE_ID_PERFORMANCE_LEVEL_GET = 0x8,
} SCMI_MESSAGE_ID_PERFORMANCE;
#endif /* ARM_SCMI_PERFORMANCE_PROTOCOL_H_ */

View File

@ -394,7 +394,7 @@ DisassembleArmInstruction (
}
if ((OpCode & 0x0db00000) == 0x01200000) {
if ((OpCode & 0x0db00000) == 0x03200000) {
// A4.1.38 MSR{<cond>} CPSR_<fields>, #<immediate> MSR{<cond>} CPSR_<fields>, <Rm>
if (I) {
// MSR{<cond>} CPSR_<fields>, #<immediate>

View File

@ -0,0 +1,342 @@
/** @file
Generic ARM implementation of DmaLib.h
Copyright (c) 2008 - 2010, Apple Inc. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include <PiDxe.h>
#include <Library/DebugLib.h>
#include <Library/DmaLib.h>
#include <Library/DxeServicesTableLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UncachedMemoryAllocationLib.h>
#include <Library/IoLib.h>
#include <Library/BaseMemoryLib.h>
#include <Protocol/Cpu.h>
typedef struct {
EFI_PHYSICAL_ADDRESS HostAddress;
VOID *BufferAddress;
UINTN NumberOfBytes;
DMA_MAP_OPERATION Operation;
BOOLEAN DoubleBuffer;
} MAP_INFO_INSTANCE;
STATIC EFI_CPU_ARCH_PROTOCOL *mCpu;
STATIC
PHYSICAL_ADDRESS
HostToDeviceAddress (
IN PHYSICAL_ADDRESS HostAddress
)
{
return HostAddress + PcdGet64 (PcdArmDmaDeviceOffset);
}
/**
Provides the DMA controller-specific addresses needed to access system memory.
Operation is relative to the DMA bus master.
@param Operation Indicates if the bus master is going to read or write to system memory.
@param HostAddress The system memory address to map to the DMA controller.
@param NumberOfBytes On input the number of bytes to map. On output the number of bytes
that were mapped.
@param DeviceAddress The resulting map address for the bus master controller to use to
access the hosts HostAddress.
@param Mapping A resulting value to pass to Unmap().
@retval EFI_SUCCESS The range was mapped for the returned NumberOfBytes.
@retval EFI_UNSUPPORTED The HostAddress cannot be mapped as a common buffer.
@retval EFI_INVALID_PARAMETER One or more parameters are invalid.
@retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
@retval EFI_DEVICE_ERROR The system hardware could not map the requested address.
**/
EFI_STATUS
EFIAPI
DmaMap (
IN DMA_MAP_OPERATION Operation,
IN VOID *HostAddress,
IN OUT UINTN *NumberOfBytes,
OUT PHYSICAL_ADDRESS *DeviceAddress,
OUT VOID **Mapping
)
{
EFI_STATUS Status;
MAP_INFO_INSTANCE *Map;
VOID *Buffer;
EFI_GCD_MEMORY_SPACE_DESCRIPTOR GcdDescriptor;
if (HostAddress == NULL || NumberOfBytes == NULL || DeviceAddress == NULL || Mapping == NULL ) {
return EFI_INVALID_PARAMETER;
}
if (Operation >= MapOperationMaximum) {
return EFI_INVALID_PARAMETER;
}
//
// The debug implementation of UncachedMemoryAllocationLib in ArmPkg returns
// a virtual uncached alias, and unmaps the cached ID mapping of the buffer,
// in order to catch inadvertent references to the cached mapping.
// Since HostToDeviceAddress () expects ID mapped input addresses, convert
// the host address to an ID mapped address first.
//
*DeviceAddress = HostToDeviceAddress (ConvertToPhysicalAddress (HostAddress));
// Remember range so we can flush on the other side
Map = AllocatePool (sizeof (MAP_INFO_INSTANCE));
if (Map == NULL) {
return EFI_OUT_OF_RESOURCES;
}
if ((((UINTN)HostAddress & (mCpu->DmaBufferAlignment - 1)) != 0) ||
((*NumberOfBytes & (mCpu->DmaBufferAlignment - 1)) != 0)) {
// Get the cacheability of the region
Status = gDS->GetMemorySpaceDescriptor ((UINTN)HostAddress, &GcdDescriptor);
if (EFI_ERROR(Status)) {
goto FreeMapInfo;
}
// If the mapped buffer is not an uncached buffer
if ((GcdDescriptor.Attributes & (EFI_MEMORY_WB | EFI_MEMORY_WT)) != 0) {
//
// Operations of type MapOperationBusMasterCommonBuffer are only allowed
// on uncached buffers.
//
if (Operation == MapOperationBusMasterCommonBuffer) {
DEBUG ((EFI_D_ERROR,
"%a: Operation type 'MapOperationBusMasterCommonBuffer' is only supported\n"
"on memory regions that were allocated using DmaAllocateBuffer ()\n",
__FUNCTION__));
Status = EFI_UNSUPPORTED;
goto FreeMapInfo;
}
//
// If the buffer does not fill entire cache lines we must double buffer into
// uncached memory. Device (PCI) address becomes uncached page.
//
Map->DoubleBuffer = TRUE;
Status = DmaAllocateBuffer (EfiBootServicesData, EFI_SIZE_TO_PAGES (*NumberOfBytes), &Buffer);
if (EFI_ERROR (Status)) {
goto FreeMapInfo;
}
if (Operation == MapOperationBusMasterRead) {
CopyMem (Buffer, HostAddress, *NumberOfBytes);
}
*DeviceAddress = HostToDeviceAddress (ConvertToPhysicalAddress (Buffer));
Map->BufferAddress = Buffer;
} else {
Map->DoubleBuffer = FALSE;
}
} else {
Map->DoubleBuffer = FALSE;
DEBUG_CODE_BEGIN ();
//
// The operation type check above only executes if the buffer happens to be
// misaligned with respect to CWG, but even if it is aligned, we should not
// allow arbitrary buffers to be used for creating consistent mappings.
// So duplicate the check here when running in DEBUG mode, just to assert
// that we are not trying to create a consistent mapping for cached memory.
//
Status = gDS->GetMemorySpaceDescriptor ((UINTN)HostAddress, &GcdDescriptor);
ASSERT_EFI_ERROR(Status);
ASSERT (Operation != MapOperationBusMasterCommonBuffer ||
(GcdDescriptor.Attributes & (EFI_MEMORY_WB | EFI_MEMORY_WT)) == 0);
DEBUG_CODE_END ();
// Flush the Data Cache (should not have any effect if the memory region is uncached)
mCpu->FlushDataCache (mCpu, (UINTN)HostAddress, *NumberOfBytes,
EfiCpuFlushTypeWriteBackInvalidate);
}
Map->HostAddress = (UINTN)HostAddress;
Map->NumberOfBytes = *NumberOfBytes;
Map->Operation = Operation;
*Mapping = Map;
return EFI_SUCCESS;
FreeMapInfo:
FreePool (Map);
return Status;
}
/**
Completes the DmaMapBusMasterRead(), DmaMapBusMasterWrite(), or DmaMapBusMasterCommonBuffer()
operation and releases any corresponding resources.
@param Mapping The mapping value returned from DmaMap*().
@retval EFI_SUCCESS The range was unmapped.
@retval EFI_DEVICE_ERROR The data was not committed to the target system memory.
@retval EFI_INVALID_PARAMETER An inconsistency was detected between the mapping type
and the DoubleBuffer field
**/
EFI_STATUS
EFIAPI
DmaUnmap (
IN VOID *Mapping
)
{
MAP_INFO_INSTANCE *Map;
EFI_STATUS Status;
if (Mapping == NULL) {
ASSERT (FALSE);
return EFI_INVALID_PARAMETER;
}
Map = (MAP_INFO_INSTANCE *)Mapping;
Status = EFI_SUCCESS;
if (Map->DoubleBuffer) {
ASSERT (Map->Operation != MapOperationBusMasterCommonBuffer);
if (Map->Operation == MapOperationBusMasterCommonBuffer) {
Status = EFI_INVALID_PARAMETER;
} else if (Map->Operation == MapOperationBusMasterWrite) {
CopyMem ((VOID *)(UINTN)Map->HostAddress, Map->BufferAddress,
Map->NumberOfBytes);
}
DmaFreeBuffer (EFI_SIZE_TO_PAGES (Map->NumberOfBytes), Map->BufferAddress);
} else {
if (Map->Operation == MapOperationBusMasterWrite) {
//
// Make sure we read buffer from uncached memory and not the cache
//
mCpu->FlushDataCache (mCpu, Map->HostAddress, Map->NumberOfBytes,
EfiCpuFlushTypeInvalidate);
}
}
FreePool (Map);
return Status;
}
/**
Allocates pages that are suitable for an DmaMap() of type MapOperationBusMasterCommonBuffer.
mapping.
@param MemoryType The type of memory to allocate, EfiBootServicesData or
EfiRuntimeServicesData.
@param Pages The number of pages to allocate.
@param HostAddress A pointer to store the base system memory address of the
allocated range.
@retval EFI_SUCCESS The requested memory pages were allocated.
@retval EFI_UNSUPPORTED Attributes is unsupported. The only legal attribute bits are
MEMORY_WRITE_COMBINE and MEMORY_CACHED.
@retval EFI_INVALID_PARAMETER One or more parameters are invalid.
@retval EFI_OUT_OF_RESOURCES The memory pages could not be allocated.
**/
EFI_STATUS
EFIAPI
DmaAllocateBuffer (
IN EFI_MEMORY_TYPE MemoryType,
IN UINTN Pages,
OUT VOID **HostAddress
)
{
VOID *Allocation;
if (HostAddress == NULL) {
return EFI_INVALID_PARAMETER;
}
//
// The only valid memory types are EfiBootServicesData and EfiRuntimeServicesData
//
// We used uncached memory to keep coherency
//
if (MemoryType == EfiBootServicesData) {
Allocation = UncachedAllocatePages (Pages);
} else if (MemoryType == EfiRuntimeServicesData) {
Allocation = UncachedAllocateRuntimePages (Pages);
} else {
return EFI_INVALID_PARAMETER;
}
if (Allocation == NULL) {
return EFI_OUT_OF_RESOURCES;
}
*HostAddress = Allocation;
return EFI_SUCCESS;
}
/**
Frees memory that was allocated with DmaAllocateBuffer().
@param Pages The number of pages to free.
@param HostAddress The base system memory address of the allocated range.
@retval EFI_SUCCESS The requested memory pages were freed.
@retval EFI_INVALID_PARAMETER The memory range specified by HostAddress and Pages
was not allocated with DmaAllocateBuffer().
**/
EFI_STATUS
EFIAPI
DmaFreeBuffer (
IN UINTN Pages,
IN VOID *HostAddress
)
{
if (HostAddress == NULL) {
return EFI_INVALID_PARAMETER;
}
UncachedFreePages (HostAddress, Pages);
return EFI_SUCCESS;
}
EFI_STATUS
EFIAPI
ArmDmaLibConstructor (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
EFI_STATUS Status;
// Get the Cpu protocol for later use
Status = gBS->LocateProtocol (&gEfiCpuArchProtocolGuid, NULL, (VOID **)&mCpu);
ASSERT_EFI_ERROR(Status);
return Status;
}

View File

@ -0,0 +1,50 @@
#/** @file
#
# Copyright (c) 2008 - 2010, Apple Inc. All rights reserved.<BR>
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
#**/
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = ArmDmaLib
FILE_GUID = F1BD6B36-B705-43aa-8A28-33F58ED85EFB
MODULE_TYPE = UEFI_DRIVER
VERSION_STRING = 1.0
LIBRARY_CLASS = DmaLib
CONSTRUCTOR = ArmDmaLibConstructor
[Sources.common]
ArmDmaLib.c
[Packages]
MdePkg/MdePkg.dec
EmbeddedPkg/EmbeddedPkg.dec
ArmPkg/ArmPkg.dec
[LibraryClasses]
DebugLib
DxeServicesTableLib
UefiBootServicesTableLib
MemoryAllocationLib
UncachedMemoryAllocationLib
IoLib
BaseMemoryLib
[Protocols]
gEfiCpuArchProtocolGuid
[Guids]
[Pcd]
gArmTokenSpaceGuid.PcdArmDmaDeviceOffset
[Depex]
gEfiCpuArchProtocolGuid

View File

@ -320,36 +320,3 @@ CommonCExceptionHandler(
DefaultExceptionHandler(ExceptionType, SystemContext);
}
/**
Initializes all CPU exceptions entries with optional extra initializations.
By default, this method should include all functionalities implemented by
InitializeCpuExceptionHandlers(), plus extra initialization works, if any.
This could be done by calling InitializeCpuExceptionHandlers() directly
in this method besides the extra works.
InitData is optional and its use and content are processor arch dependent.
The typical usage of it is to convey resources which have to be reserved
elsewhere and are necessary for the extra initializations of exception.
@param[in] VectorInfo Pointer to reserved vector list.
@param[in] InitData Pointer to data optional for extra initializations
of exception.
@retval EFI_SUCCESS The exceptions have been successfully
initialized.
@retval EFI_INVALID_PARAMETER VectorInfo or InitData contains invalid
content.
**/
EFI_STATUS
EFIAPI
InitializeCpuExceptionHandlersEx (
IN EFI_VECTOR_HANDOFF_INFO *VectorInfo OPTIONAL,
IN CPU_EXCEPTION_INIT_DATA *InitData OPTIONAL
)
{
return InitializeCpuExceptionHandlers (VectorInfo);
}

View File

@ -29,14 +29,6 @@ ArmGenericTimerEnableTimer (
ArmWriteCntpCtl (TimerCtrlReg);
}
VOID
EFIAPI
ArmGenericTimerReenableTimer (
VOID
)
{
}
VOID
EFIAPI
ArmGenericTimerDisableTimer (

View File

@ -26,15 +26,17 @@ ArmGenericTimerEnableTimer (
TimerCtrlReg = ArmReadCntvCtl ();
TimerCtrlReg |= ARM_ARCH_TIMER_ENABLE;
ArmWriteCntvCtl (TimerCtrlReg);
}
VOID
EFIAPI
ArmGenericTimerReenableTimer (
VOID
)
{
//
// When running under KVM, we need to unmask the interrupt on the timer side
// as KVM will mask it when servicing the interrupt at the hypervisor level
// and delivering the virtual timer interrupt to the guest. Otherwise, the
// interrupt will fire again, trapping into the hypervisor again, etc. etc.
// This is scheduled to be fixed on the KVM side, but there is no harm in
// leaving this in once KVM gets fixed.
//
TimerCtrlReg &= ~ARM_ARCH_TIMER_IMASK;
ArmWriteCntvCtl (TimerCtrlReg);
}
VOID

View File

@ -12,7 +12,7 @@
//
//
#include <AsmMacroIoLib.h>
#include <AsmMacroIoLibV8.h>
.arch_extension virt

View File

@ -30,6 +30,3 @@
[Packages]
MdePkg/MdePkg.dec
ArmPkg/ArmPkg.dec
[BuildOptions]
RVCT:*_*_ARM_PLATFORM_FLAGS == --cpu Cortex-A15

View File

@ -1,7 +1,7 @@
#------------------------------------------------------------------------------
#
# Copyright (c) 2008 - 2010, Apple Inc. All rights reserved.<BR>
# Copyright (c) 2011 - 2017, ARM Limited. All rights reserved.
# Copyright (c) 2011 - 2014, ARM Limited. All rights reserved.
# Copyright (c) 2016, Linaro Limited. All rights reserved.
#
# This program and the accompanying materials
@ -403,11 +403,9 @@ ASM_FUNC(ArmEnableVFP)
mov x1, x30 // Save LR
bl ArmReadIdPfr0 // Read EL1 Processor Feature Register (PFR0)
mov x30, x1 // Restore LR
ubfx x0, x0, #16, #4 // Extract the FP bits 16:19
cmp x0, #0xF // Check if FP bits are '1111b',
// i.e. Floating Point not implemented
b.eq 4f // Exit when VFP is not implemented.
ands x0, x0, #AARCH64_PFR0_FP// Extract bits indicating VFP implementation
cmp x0, #0 // VFP is implemented if '0'.
b.ne 4f // Exit if VFP not implemented.
// FVP is implemented.
// Make sure VFP exceptions are not trapped (to any exception level).
mrs x0, cpacr_el1 // Read EL1 Coprocessor Access Control Register (CPACR)
@ -482,14 +480,4 @@ ASM_FUNC(ArmReadCurrentEL)
mrs x0, CurrentEL
ret
// UINT32 ArmReadCntHctl(VOID)
ASM_FUNC(ArmReadCntHctl)
mrs x0, cnthctl_el2
ret
// VOID ArmWriteCntHctl(UINT32 CntHctl)
ASM_FUNC(ArmWriteCntHctl)
msr cnthctl_el2, x0
ret
ASM_FUNCTION_REMOVE_IF_UNREFERENCED

View File

@ -187,30 +187,4 @@ ASM_FUNC(ArmReadSctlr)
3:mrs x0, sctlr_el3
4:ret
ASM_FUNC(ArmWriteSctlr)
EL1_OR_EL2_OR_EL3(x1)
1:msr sctlr_el1, x0
ret
2:msr sctlr_el2, x0
ret
3:msr sctlr_el3, x0
4:ret
ASM_FUNC(ArmGetPhysicalAddressBits)
mrs x0, id_aa64mmfr0_el1
adr x1, .LPARanges
and x0, x0, #0xf
ldrb w0, [x1, x0]
ret
//
// Bits 0..3 of the AA64MFR0_EL1 system register encode the size of the
// physical address space support on this CPU:
// 0 == 32 bits, 1 == 36 bits, etc etc
// 7 and up are reserved
//
.LPARanges:
.byte 32, 36, 40, 42, 44, 48, 52, 0
.byte 0, 0, 0, 0, 0, 0, 0, 0
ASM_FUNCTION_REMOVE_IF_UNREFERENCED

View File

@ -100,6 +100,8 @@ ASM_FUNC(ArmGetTTBR0BaseAddress)
// IN VOID *MVA // R1
// );
ASM_FUNC(ArmUpdateTranslationTableEntry)
mcr p15,0,R0,c7,c14,1 @ DCCIMVAC Clean data cache by MVA
dsb
mcr p15,0,R1,c8,c7,1 @ TLBIMVA TLB Invalidate MVA
mcr p15,0,R9,c7,c5,6 @ BPIALL Invalidate Branch predictor array. R9 == NoOp
dsb
@ -151,10 +153,6 @@ ASM_FUNC(ArmReadSctlr)
mrc p15, 0, r0, c1, c0, 0 @ Read SCTLR into R0 (Read control register configuration data)
bx lr
ASM_FUNC(ArmWriteSctlr)
mcr p15, 0, r0, c1, c0, 0
bx lr
ASM_FUNC(ArmReadCpuActlr)
mrc p15, 0, r0, c1, c0, 1
bx lr
@ -165,12 +163,4 @@ ASM_FUNC(ArmWriteCpuActlr)
isb
bx lr
ASM_FUNC (ArmGetPhysicalAddressBits)
mrc p15, 0, r0, c0, c1, 4 // MMFR0
and r0, r0, #0xf // VMSA [3:0]
cmp r0, #5 // >= 5 implies LPAE support
movlt r0, #32 // 32 bits if no LPAE
movge r0, #40 // 40 bits if LPAE
bx lr
ASM_FUNCTION_REMOVE_IF_UNREFERENCED

Some files were not shown because too many files have changed in this diff Show More