Date   

Re: [PATCH 05/23] MdePkg: Add TdxProbeLib to probe Intel Tdx

Gerd Hoffmann
 

On Tue, Aug 17, 2021 at 12:14:44AM +0000, Min Xu wrote:
On Monday, August 16, 2021 5:43 PM, Gerd Hoffmann wrote:
+++ b/MdePkg/Library/TdxProbeLib/X64/TdProbe.nasm
Any specific reason why you code up your own instead of using the existing
cpuid functions in BaseLib ?
Actually there is no specific reason. I am not sure if AsmCpuid is a preferred way
in this situation?
I'm pretty sure it is preferred over duplicating code.

Early setup code (before stack setup where you can't do calls)
is a different story.

Also: Why there are separate TdxProbeLib + TdxLib libs?

take care,
Gerd


[PATCH] IntelFsp2Pkg: Support Config File and Binary delta comparison

 

From: "Loo, Tung Lun" <tung.lun.loo@...>

BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3567

This patch is to enable config editor to have a new feature that
can spell out the delta between the default configuration files'
data, such as YAML and BSF, against the data stored in the binary.
This can help users understand and track the difference when
modifications are made.

Cc: Maurice Ma <maurice.ma@...>
Cc: Nate DeSimone <nathaniel.l.desimone@...>
Cc: Star Zeng <star.zeng@...>
Cc: Chasel Chiu <chasel.chiu@...>
Signed-off-by: Loo Tung Lun <tung.lun.loo@...>
---
IntelFsp2Pkg/Tools/ConfigEditor/ConfigEditor.py | 43 ++++++++++++++++++++=
++++++++++++++++++-----
IntelFsp2Pkg/Tools/ConfigEditor/GenYamlCfg.py | 121 ++++++++++++++++++++=
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
+++++++++++++++++---------
2 files changed, 150 insertions(+), 14 deletions(-)

diff --git a/IntelFsp2Pkg/Tools/ConfigEditor/ConfigEditor.py b/IntelFsp2Pkg=
/Tools/ConfigEditor/ConfigEditor.py
index 008c7d7a16..680b90e09d 100644
--- a/IntelFsp2Pkg/Tools/ConfigEditor/ConfigEditor.py
+++ b/IntelFsp2Pkg/Tools/ConfigEditor/ConfigEditor.py
@@ -807,12 +807,12 @@ class application(tkinter.Frame):
self.page_id =3D ''=0D
self.page_list =3D {}=0D
self.conf_list =3D {}=0D
+ self.cfg_page_dict =3D {}=0D
self.cfg_data_obj =3D None=0D
self.org_cfg_data_bin =3D None=0D
self.in_left =3D state()=0D
self.in_right =3D state()=0D
self.search_text =3D ''=0D
- self.binseg_dict =3D {}=0D
=0D
# Check if current directory contains a file with a .yaml extensio=
n=0D
# if not default self.last_dir to a Platform directory where it is=
=0D
@@ -1009,10 +1009,17 @@ class application(tkinter.Frame):
return visible=0D
if self.cfg_data_obj.binseg_dict:=0D
str_split =3D item['path'].split('.')=0D
- if self.cfg_data_obj.binseg_dict[str_split[-2]] =3D=3D -1:=0D
- visible =3D False=0D
- widget.grid_remove()=0D
- return visible=0D
+ if str_split[-2] not in CGenYamlCfg.available_fv and \=0D
+ str_split[-2] not in CGenYamlCfg.missing_fv:=0D
+ if self.cfg_data_obj.binseg_dict[str_split[-3]] =3D=3D -1:=
=0D
+ visible =3D False=0D
+ widget.grid_remove()=0D
+ return visible=0D
+ else:=0D
+ if self.cfg_data_obj.binseg_dict[str_split[-2]] =3D=3D -1:=
=0D
+ visible =3D False=0D
+ widget.grid_remove()=0D
+ return visible=0D
result =3D 1=0D
if item['condition']:=0D
result =3D self.evaluate_condition(item)=0D
@@ -1371,8 +1378,34 @@ class application(tkinter.Frame):
self.clear_widgets_inLayout()=0D
self.on_config_page_select_change(None)=0D
=0D
+ def set_config_data_page(self):=0D
+ page_id_list =3D []=0D
+ for idx, page in enumerate(=0D
+ self.cfg_data_obj._cfg_page['root']['child']):=0D
+ page_id_list.append(list(page.keys())[0])=0D
+ page_list =3D self.cfg_data_obj.get_cfg_list(page_id_list[idx]=
)=0D
+ self.cfg_page_dict[page_id_list[idx]] =3D 0=0D
+ for item in page_list:=0D
+ str_split =3D item['path'].split('.')=0D
+ if str_split[-2] not in CGenYamlCfg.available_fv and \=0D
+ str_split[-2] not in CGenYamlCfg.missing_fv:=0D
+ if self.cfg_data_obj.binseg_dict[str_split[-3]] !=3D -=
1:=0D
+ self.cfg_page_dict[page_id_list[idx]] +=3D 1=0D
+ else:=0D
+ if self.cfg_data_obj.binseg_dict[str_split[-2]] !=3D -=
1:=0D
+ self.cfg_page_dict[page_id_list[idx]] +=3D 1=0D
+ removed_page =3D 0=0D
+ for idx, id in enumerate(page_id_list):=0D
+ if self.cfg_page_dict[id] =3D=3D 0:=0D
+ del self.cfg_data_obj._cfg_page['root']['child'][idx-remov=
ed_page] # noqa: E501=0D
+ removed_page +=3D 1=0D
+=0D
def reload_config_data_from_bin(self, bin_dat):=0D
self.cfg_data_obj.load_default_from_bin(bin_dat)=0D
+ self.set_config_data_page()=0D
+ self.left.delete(*self.left.get_children())=0D
+ self.build_config_page_tree(self.cfg_data_obj.get_cfg_page()['root=
'],=0D
+ '')=0D
self.refresh_config_data_page()=0D
=0D
def set_config_item_value(self, item, value_str):=0D
diff --git a/IntelFsp2Pkg/Tools/ConfigEditor/GenYamlCfg.py b/IntelFsp2Pkg/T=
ools/ConfigEditor/GenYamlCfg.py
index 611a9a9c72..b593885807 100644
--- a/IntelFsp2Pkg/Tools/ConfigEditor/GenYamlCfg.py
+++ b/IntelFsp2Pkg/Tools/ConfigEditor/GenYamlCfg.py
@@ -13,6 +13,7 @@ import string
import operator as op=0D
import ast=0D
import tkinter.messagebox as messagebox=0D
+import tkinter=0D
=0D
from datetime import date=0D
from collections import OrderedDict=0D
@@ -583,7 +584,6 @@ class CGenYamlCfg:
self._mode =3D ''=0D
self._debug =3D False=0D
self._macro_dict =3D {}=0D
- self.bin_offset =3D []=0D
self.binseg_dict =3D {}=0D
self.initialize()=0D
=0D
@@ -1046,6 +1046,7 @@ option format '%s' !" % option)
try:=0D
value =3D self.reformat_value_str(act_cfg['value'],=0D
act_cfg['length'])=0D
+=0D
except Exception:=0D
value =3D act_cfg['value']=0D
length =3D bit_len // 8=0D
@@ -1298,18 +1299,85 @@ option format '%s' !" % option)
self.traverse_cfg_tree(_get_field_value, top)=0D
return result=0D
=0D
+ data_diff =3D ''=0D
+=0D
+ def find_data_difference(self, act_val, act_cfg):=0D
+ # checks for any difference between BSF and Binary file=0D
+ config_val =3D ''=0D
+ if act_val !=3D act_cfg['value']:=0D
+=0D
+ if 'DEC' in act_cfg['type']:=0D
+ bsf_val =3D '0x%x' % int(act_val)=0D
+ if bsf_val !=3D act_cfg['value']:=0D
+ config_val =3D bsf_val=0D
+ else:=0D
+ config_val =3D ''=0D
+ else:=0D
+ config_val =3D act_val=0D
+=0D
+ available_fv1 =3D 'none'=0D
+ available_fv2 =3D 'none'=0D
+=0D
+ if self.detect_fsp():=0D
+ if len(self.available_fv) >=3D 1:=0D
+ if len(self.available_fv) > 1:=0D
+ available_fv1 =3D self.available_fv[1]=0D
+ if self.available_fv[2]:=0D
+ available_fv2 =3D self.available_fv[2]=0D
+ else:=0D
+ available_fv1 =3D self.available_fv[1]=0D
+ if act_cfg['length'] =3D=3D 16:=0D
+ config_val =3D int(config_val, 16)=0D
+ config_val =3D '0x%x' % config_val=0D
+ act_cfg['value'] =3D int(=0D
+ act_cfg['value'], 16)=0D
+ act_cfg['value'] =3D '0x%x' % \=0D
+ act_cfg['value']=0D
+=0D
+ if config_val:=0D
+ string =3D ('.' + act_cfg['cname'])=0D
+ if (act_cfg['path'].endswith(self.available_fv[0] + string=
)=0D
+ or act_cfg['path'].endswith(available_fv1 + string)=0D
+ or act_cfg['path'].endswith(available_fv2 + string)) \=
=0D
+ and 'BsfSkip' not in act_cfg['cname'] \=0D
+ and 'Reserved' not in act_cfg['name']:=0D
+ if act_cfg['option'] !=3D '':=0D
+ if act_cfg['length'] =3D=3D 8:=0D
+ config_val =3D int(config_val, 16)=0D
+ config_val =3D '0x%x' % config_val=0D
+ act_cfg['value'] =3D int(=0D
+ act_cfg['value'], 16)=0D
+ act_cfg['value'] =3D '0x%x' % \=0D
+ act_cfg['value']=0D
+ option =3D act_cfg['option']=0D
+=0D
+ cfg_val =3D ''=0D
+ bin_val =3D ''=0D
+ for i in option.split(','):=0D
+ if act_cfg['value'] in i:=0D
+ bin_val =3D i=0D
+ elif config_val in i:=0D
+ cfg_val =3D i=0D
+ if cfg_val !=3D '' and bin_val !=3D '':=0D
+ self.data_diff +=3D '\n\nBinary: ' \=0D
+ + act_cfg['name'] \=0D
+ + ': ' + bin_val.replace(' ', '') \=0D
+ + '\nConfig file: ' \=0D
+ + act_cfg['name'] + ': ' \=0D
+ + cfg_val.replace(' ', '') + '\n'=0D
+ else:=0D
+ self.data_diff +=3D '\n\nBinary: ' \=0D
+ + act_cfg['name'] + ': ' + act_cfg['value'] \=
=0D
+ + '\nConfig file: ' + act_cfg['name'] \=0D
+ + ': ' + config_val + '\n'=0D
+=0D
def set_field_value(self, top, value_bytes, force=3DFalse):=0D
def _set_field_value(name, cfgs, level):=0D
if 'indx' not in cfgs:=0D
return=0D
act_cfg =3D self.get_item_by_index(cfgs['indx'])=0D
actual_offset =3D act_cfg['offset'] - struct_info['offset']=0D
- set_value =3D True=0D
- for each in self.bin_offset:=0D
- if actual_offset in range(each[0], (each[0] + each[2]) * 8=
):=0D
- if each[1] < 0:=0D
- set_value =3D False=0D
- if set_value and force or act_cfg['value'] =3D=3D '':=0D
+ if force or act_cfg['value'] =3D=3D '':=0D
value =3D get_bits_from_bytes(full_bytes,=0D
actual_offset,=0D
act_cfg['length'])=0D
@@ -1321,6 +1389,7 @@ option format '%s' !" % option)
act_val)=0D
act_cfg['value'] =3D self.format_value_to_str(=0D
value, act_cfg['length'], act_val)=0D
+ self.find_data_difference(act_val, act_cfg)=0D
=0D
if 'indx' in top:=0D
# it is config option=0D
@@ -1438,6 +1507,9 @@ for '%s' !" % (act_cfg['value'], act_cfg['path']))
=0D
return bin_segs=0D
=0D
+ available_fv =3D []=0D
+ missing_fv =3D []=0D
+=0D
def extract_cfg_from_bin(self, bin_data):=0D
# get cfg bin length=0D
cfg_bins =3D bytearray()=0D
@@ -1445,12 +1517,12 @@ for '%s' !" % (act_cfg['value'], act_cfg['path']))
Dummy_offset =3D 0=0D
for each in bin_segs:=0D
if each[1] !=3D -1:=0D
- self.bin_offset.append([Dummy_offset, each[1], each[2]])=0D
cfg_bins.extend(bin_data[each[1]:each[1] + each[2]])=0D
+ self.available_fv.append(each[0])=0D
else:=0D
+ self.missing_fv.append(each[0])=0D
string =3D each[0] + ' is not availabe.'=0D
messagebox.showinfo('', string)=0D
- self.bin_offset.append([Dummy_offset, each[1], each[2]])=0D
cfg_bins.extend(bytearray(each[2]))=0D
Dummy_offset +=3D each[2]=0D
return cfg_bins=0D
@@ -1476,10 +1548,41 @@ for '%s' !" % (act_cfg['value'], act_cfg['path']))
print('Patched the loaded binary successfully !')=0D
return bin_data=0D
=0D
+ def show_data_difference(self, data_diff):=0D
+ # Displays if any data difference detected in BSF and Binary file=
=0D
+ pop_up_text =3D 'There are differences in Config file and binary '=
\=0D
+ 'data detected!\n'=0D
+ pop_up_text +=3D data_diff=0D
+=0D
+ window =3D tkinter.Tk()=0D
+ window.title("Data Difference")=0D
+ window.resizable(1, 1)=0D
+ # Window Size=0D
+ window.geometry("800x400")=0D
+ frame =3D tkinter.Frame(window, height=3D800, width=3D700)=0D
+ frame.pack(side=3Dtkinter.BOTTOM)=0D
+ # Vertical (y) Scroll Bar=0D
+ scroll =3D tkinter.Scrollbar(window)=0D
+ scroll.pack(side=3Dtkinter.RIGHT, fill=3Dtkinter.Y)=0D
+=0D
+ text =3D tkinter.Text(window, wrap=3Dtkinter.NONE,=0D
+ yscrollcommand=3Dscroll.set,=0D
+ width=3D700, height=3D400)=0D
+ text.insert(tkinter.INSERT, pop_up_text)=0D
+ text.pack()=0D
+ # Configure the scrollbars=0D
+ scroll.config(command=3Dtext.yview)=0D
+ exit_button =3D tkinter.Button(=0D
+ window, text=3D"Close", command=3Dwindow.destroy)=0D
+ exit_button.pack(in_=3Dframe, side=3Dtkinter.RIGHT, padx=3D20, pad=
y=3D10)=0D
+=0D
def load_default_from_bin(self, bin_data):=0D
self._old_bin =3D bin_data=0D
cfg_bins =3D self.extract_cfg_from_bin(bin_data)=0D
self.set_field_value(self._cfg_tree, cfg_bins, True)=0D
+=0D
+ if self.data_diff:=0D
+ self.show_data_difference(self.data_diff)=0D
return cfg_bins=0D
=0D
def generate_binary_array(self, path=3D''):=0D
--=20
2.26.2.windows.1


[edk2-platforms PATCH v2] Platform/RaspberryPi: Remove unnecessary files.

Grzegorz Bernacki <gjb@...>
 

Commit 2f0188b56ef4 ("Revert "Platform/RaspberryPi: Setup option for...")
mistakenly introduced to files which are residues from a
conflict resolution. Fix that.

Signed-off-by: Grzegorz Bernacki <gjb@...>
---
Platform/RaspberryPi/Library/DualSerialPortLib/DualSerialPortLib.c.orig | 613 ----------------
Platform/RaspberryPi/Library/DualSerialPortLib/DualSerialPortLib.c.rej | 31 -
Platform/RaspberryPi/Library/PlatformLib/AArch64/RaspberryPiHelper.S.orig | 180 -----
Platform/RaspberryPi/Library/PlatformLib/AArch64/RaspberryPiHelper.S.rej | 32 -
Platform/RaspberryPi/RPi4/RPi4.dsc.orig | 760 --------------------
Platform/RaspberryPi/RPi4/RPi4.dsc.rej | 29 -
6 files changed, 1645 deletions(-)
delete mode 100644 Platform/RaspberryPi/Library/DualSerialPortLib/DualSerialPortLib.c.orig
delete mode 100644 Platform/RaspberryPi/Library/DualSerialPortLib/DualSerialPortLib.c.rej
delete mode 100644 Platform/RaspberryPi/Library/PlatformLib/AArch64/RaspberryPiHelper.S.orig
delete mode 100644 Platform/RaspberryPi/Library/PlatformLib/AArch64/RaspberryPiHelper.S.rej
delete mode 100644 Platform/RaspberryPi/RPi4/RPi4.dsc.orig
delete mode 100644 Platform/RaspberryPi/RPi4/RPi4.dsc.rej

diff --git a/Platform/RaspberryPi/Library/DualSerialPortLib/DualSerialPortLib.c.orig b/Platform/RaspberryPi/Library/DualSerialPortLib/DualSerialPortLib.c.orig
deleted file mode 100644
index 5e83bbf022..0000000000
--- a/Platform/RaspberryPi/Library/DualSerialPortLib/DualSerialPortLib.c.orig
+++ /dev/null
@@ -1,613 +0,0 @@
-/** @file
- 16550 and PL011 Serial Port library functions for Raspberry Pi
-
- Copyright (c) 2020, Pete Batard <pete@...>
- Copyright (c) 2018, AMD Incorporated. All rights reserved.<BR>
- Copyright (c) 2014, Hewlett-Packard Development Company, L.P.<BR>
- Copyright (c) 2012 - 2016, ARM Ltd. All rights reserved.<BR>
- Copyright (c) 2008 - 2010, Apple Inc. All rights reserved.<BR>
- Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
-
- SPDX-License-Identifier: BSD-2-Clause-Patent
-
-**/
-
-#include <Base.h>
-#include <Library/IoLib.h>
-#include <Library/PcdLib.h>
-#include <Library/PL011UartClockLib.h>
-#include <Library/PL011UartLib.h>
-#include <Library/SerialPortLib.h>
-
-#include "DualSerialPortLib.h"
-
-/**
- Return the baud generator divisor to use for 16650 setup.
-
- @param SerialBaudRate The desired baud rate.
-
- @return The baud generator divisor.
-**/
-STATIC
-UINT32
-SerialPortGetDivisor (
- UINT32 SerialBaudRate
-)
-{
- UINT64 BaseClockRate;
- UINT32 Divisor;
-
- //
- // On the Raspberry Pi, the clock to use for the 16650-compatible UART
- // is the base clock divided by the 12.12 fixed point VPU clock divisor.
- //
- BaseClockRate = (UINT64)PcdGet32 (PcdSerialClockRate);
-#if (RPI_MODEL == 4)
- Divisor = MmioRead32(BCM2836_CM_BASE + BCM2836_CM_VPU_CLOCK_DIVISOR) & 0xFFFFFF;
- if (Divisor != 0)
- BaseClockRate = (BaseClockRate << 12) / Divisor;
-#endif
-
- //
- // As per the BCM2xxx datasheets:
- // baudrate = system_clock_freq / (8 * (divisor + 1)).
- //
- Divisor = (UINT32)BaseClockRate / (SerialBaudRate * 8);
- if (Divisor != 0) {
- Divisor--;
- }
- return Divisor;
-}
-
-/**
- Initialize the serial device hardware.
-
- If no initialization is required, then return RETURN_SUCCESS.
- If the serial device was successfully initialized, then return RETURN_SUCCESS.
- If the serial device could not be initialized, then return RETURN_DEVICE_ERROR.
-
- @retval RETURN_SUCCESS The serial device was initialized.
- @retval RETURN_DEVICE_ERROR The serial device could not be initialized.
-
-**/
-RETURN_STATUS
-EFIAPI
-SerialPortInitialize (
- VOID
- )
-{
- UINTN SerialRegisterBase;
- UINT32 Divisor;
- UINT32 CurrentDivisor;
- BOOLEAN Initialized;
- UINT64 BaudRate;
- UINT32 ReceiveFifoDepth;
- EFI_PARITY_TYPE Parity;
- UINT8 DataBits;
- EFI_STOP_BITS_TYPE StopBits;
-
- //
- // First thing we need to do is determine which of PL011 or miniUART is selected
- //
- if (!UsePl011UartSet) {
- UsePl011Uart = ((MmioRead32(GPIO_BASE_ADDRESS + 4) & 0x0003F000) == 0x00024000);
- UsePl011UartSet = TRUE;
- }
-
- if (UsePl011Uart) {
- BaudRate = FixedPcdGet64 (PcdUartDefaultBaudRate);
- ReceiveFifoDepth = 0; // Use default FIFO depth
- Parity = (EFI_PARITY_TYPE)FixedPcdGet8 (PcdUartDefaultParity);
- DataBits = FixedPcdGet8 (PcdUartDefaultDataBits);
- StopBits = (EFI_STOP_BITS_TYPE) FixedPcdGet8 (PcdUartDefaultStopBits);
-
- return PL011UartInitializePort (
- PL011_UART_REGISTER_BASE,
- PL011UartClockGetFreq(),
- &BaudRate,
- &ReceiveFifoDepth,
- &Parity,
- &DataBits,
- &StopBits
- );
- } else {
- SerialRegisterBase = MINI_UART_REGISTER_BASE;
- Divisor = SerialPortGetDivisor (PcdGet32 (PcdSerialBaudRate));
-
- //
- // See if the serial port is already initialized
- //
- Initialized = TRUE;
- if ((SerialPortReadRegister (SerialRegisterBase, R_UART_LCR) & 0x3F) != (PcdGet8 (PcdSerialLineControl) & 0x3F)) {
- Initialized = FALSE;
- }
- SerialPortWriteRegister (SerialRegisterBase, R_UART_LCR, (UINT8)(SerialPortReadRegister (SerialRegisterBase, R_UART_LCR) | B_UART_LCR_DLAB));
- CurrentDivisor = SerialPortReadRegister (SerialRegisterBase, R_UART_BAUD_HIGH) << 8;
- CurrentDivisor |= (UINT32) SerialPortReadRegister (SerialRegisterBase, R_UART_BAUD_LOW);
- SerialPortWriteRegister (SerialRegisterBase, R_UART_LCR, (UINT8)(SerialPortReadRegister (SerialRegisterBase, R_UART_LCR) & ~B_UART_LCR_DLAB));
- if (CurrentDivisor != Divisor) {
- Initialized = FALSE;
- }
- if (Initialized) {
- return RETURN_SUCCESS;
- }
-
- //
- // Wait for the serial port to be ready.
- // Verify that both the transmit FIFO and the shift register are empty.
- //
- while ((SerialPortReadRegister (SerialRegisterBase, R_UART_LSR) & (B_UART_LSR_TEMT | B_UART_LSR_TXRDY)) != (B_UART_LSR_TEMT | B_UART_LSR_TXRDY));
-
- //
- // Configure baud rate
- //
- SerialPortWriteRegister (SerialRegisterBase, R_UART_LCR, B_UART_LCR_DLAB);
- SerialPortWriteRegister (SerialRegisterBase, R_UART_BAUD_HIGH, (UINT8) (Divisor >> 8));
- SerialPortWriteRegister (SerialRegisterBase, R_UART_BAUD_LOW, (UINT8) (Divisor & 0xff));
-
- //
- // Clear DLAB and configure Data Bits, Parity, and Stop Bits.
- // Strip reserved bits from PcdSerialLineControl
- //
- SerialPortWriteRegister (SerialRegisterBase, R_UART_LCR, (UINT8)(PcdGet8 (PcdSerialLineControl) & 0x3F));
-
- //
- // Enable and reset FIFOs
- // Strip reserved bits from PcdSerialFifoControl
- //
- SerialPortWriteRegister (SerialRegisterBase, R_UART_FCR, 0x00);
- SerialPortWriteRegister (SerialRegisterBase, R_UART_FCR, (UINT8)(PcdGet8 (PcdSerialFifoControl) & (B_UART_FCR_FIFOE | B_UART_FCR_FIFO64)));
-
- //
- // Set FIFO Polled Mode by clearing IER after setting FCR
- //
- SerialPortWriteRegister (SerialRegisterBase, R_UART_IER, 0x00);
-
- //
- // Put Modem Control Register(MCR) into its reset state of 0x00.
- //
- SerialPortWriteRegister (SerialRegisterBase, R_UART_MCR, 0x00);
-
- return RETURN_SUCCESS;
- }
-}
-
-/**
- Reads data from a serial device into a buffer.
-
- @param Buffer Pointer to the data buffer to store the data read from the serial device.
- @param NumberOfBytes Number of bytes to read from the serial device.
-
- @retval 0 NumberOfBytes is 0.
- @retval >0 The number of bytes read from the serial device.
- If this value is less than NumberOfBytes, then the read operation failed.
-
-**/
-UINTN
-EFIAPI
-SerialPortRead (
- OUT UINT8 *Buffer,
- IN UINTN NumberOfBytes
- )
-{
- UINTN SerialRegisterBase;
- UINTN Result;
- UINT8 Mcr;
-
- if (UsePl011Uart) {
- return PL011UartRead (PL011_UART_REGISTER_BASE, Buffer, NumberOfBytes);
- } else {
- if (NULL == Buffer) {
- return 0;
- }
-
- SerialRegisterBase = MINI_UART_REGISTER_BASE;
-
- Mcr = (UINT8)(SerialPortReadRegister (SerialRegisterBase, R_UART_MCR) & ~B_UART_MCR_RTS);
-
- for (Result = 0; NumberOfBytes-- != 0; Result++, Buffer++) {
- //
- // Wait for the serial port to have some data.
- //
- while ((SerialPortReadRegister (SerialRegisterBase, R_UART_LSR) & B_UART_LSR_RXRDY) == 0) {
- if (PcdGetBool (PcdSerialUseHardwareFlowControl)) {
- //
- // Set RTS to let the peer send some data
- //
- SerialPortWriteRegister (SerialRegisterBase, R_UART_MCR, (UINT8)(Mcr | B_UART_MCR_RTS));
- }
- }
- if (PcdGetBool (PcdSerialUseHardwareFlowControl)) {
- //
- // Clear RTS to prevent peer from sending data
- //
- SerialPortWriteRegister (SerialRegisterBase, R_UART_MCR, Mcr);
- }
-
- //
- // Read byte from the receive buffer.
- //
- *Buffer = SerialPortReadRegister (SerialRegisterBase, R_UART_RXBUF);
- }
-
- return Result;
- }
-}
-
-/**
- Polls a serial device to see if there is any data waiting to be read.
-
- Polls aserial device to see if there is any data waiting to be read.
- If there is data waiting to be read from the serial device, then TRUE is returned.
- If there is no data waiting to be read from the serial device, then FALSE is returned.
-
- @retval TRUE Data is waiting to be read from the serial device.
- @retval FALSE There is no data waiting to be read from the serial device.
-
-**/
-BOOLEAN
-EFIAPI
-SerialPortPoll (
- VOID
- )
-{
- UINTN SerialRegisterBase;
-
- if (UsePl011Uart) {
- return PL011UartPoll (PL011_UART_REGISTER_BASE);
- } else {
- SerialRegisterBase = MINI_UART_REGISTER_BASE;
-
- //
- // Read the serial port status
- //
- if ((SerialPortReadRegister (SerialRegisterBase, R_UART_LSR) & B_UART_LSR_RXRDY) != 0) {
- if (PcdGetBool (PcdSerialUseHardwareFlowControl)) {
- //
- // Clear RTS to prevent peer from sending data
- //
- SerialPortWriteRegister (SerialRegisterBase, R_UART_MCR, (UINT8)(SerialPortReadRegister (SerialRegisterBase, R_UART_MCR) & ~B_UART_MCR_RTS));
- }
- return TRUE;
- }
-
- if (PcdGetBool (PcdSerialUseHardwareFlowControl)) {
- //
- // Set RTS to let the peer send some data
- //
- SerialPortWriteRegister (SerialRegisterBase, R_UART_MCR, (UINT8)(SerialPortReadRegister (SerialRegisterBase, R_UART_MCR) | B_UART_MCR_RTS));
- }
-
- return FALSE;
- }
-}
-
-/**
- Sets the control bits on a serial device.
-
- @param Control Sets the bits of Control that are settable.
-
- @retval RETURN_SUCCESS The new control bits were set on the serial device.
- @retval RETURN_UNSUPPORTED The serial device does not support this operation.
- @retval RETURN_DEVICE_ERROR The serial device is not functioning correctly.
-
-**/
-RETURN_STATUS
-EFIAPI
-SerialPortSetControl (
- IN UINT32 Control
- )
-{
- UINTN SerialRegisterBase;
- UINT8 Mcr;
-
- if (UsePl011Uart) {
- return PL011UartSetControl (PL011_UART_REGISTER_BASE, Control);
- } else {
- //
- // First determine the parameter is invalid.
- //
- if ((Control & (~(EFI_SERIAL_REQUEST_TO_SEND | EFI_SERIAL_DATA_TERMINAL_READY |
- EFI_SERIAL_HARDWARE_FLOW_CONTROL_ENABLE))) != 0) {
- return RETURN_UNSUPPORTED;
- }
-
- SerialRegisterBase = MINI_UART_REGISTER_BASE;
-
- //
- // Read the Modem Control Register.
- //
- Mcr = SerialPortReadRegister (SerialRegisterBase, R_UART_MCR);
- Mcr &= (~(B_UART_MCR_DTRC | B_UART_MCR_RTS));
-
- if ((Control & EFI_SERIAL_DATA_TERMINAL_READY) == EFI_SERIAL_DATA_TERMINAL_READY) {
- Mcr |= B_UART_MCR_DTRC;
- }
-
- if ((Control & EFI_SERIAL_REQUEST_TO_SEND) == EFI_SERIAL_REQUEST_TO_SEND) {
- Mcr |= B_UART_MCR_RTS;
- }
-
- //
- // Write the Modem Control Register.
- //
- SerialPortWriteRegister (SerialRegisterBase, R_UART_MCR, Mcr);
-
- return RETURN_SUCCESS;
- }
-}
-
-/**
- Retrieve the status of the control bits on a serial device.
-
- @param Control A pointer to return the current control signals from the serial device.
-
- @retval RETURN_SUCCESS The control bits were read from the serial device.
- @retval RETURN_UNSUPPORTED The serial device does not support this operation.
- @retval RETURN_DEVICE_ERROR The serial device is not functioning correctly.
-
-**/
-RETURN_STATUS
-EFIAPI
-SerialPortGetControl (
- OUT UINT32 *Control
- )
-{
- UINTN SerialRegisterBase;
- UINT8 Msr;
- UINT8 Mcr;
- UINT8 Lsr;
-
- if (UsePl011Uart) {
- return PL011UartGetControl (PL011_UART_REGISTER_BASE, Control);
- } else {
- SerialRegisterBase = MINI_UART_REGISTER_BASE;
-
- *Control = 0;
-
- //
- // Read the Modem Status Register.
- //
- Msr = SerialPortReadRegister (SerialRegisterBase, R_UART_MSR);
-
- if ((Msr & B_UART_MSR_CTS) == B_UART_MSR_CTS) {
- *Control |= EFI_SERIAL_CLEAR_TO_SEND;
- }
-
- if ((Msr & B_UART_MSR_DSR) == B_UART_MSR_DSR) {
- *Control |= EFI_SERIAL_DATA_SET_READY;
- }
-
- if ((Msr & B_UART_MSR_RI) == B_UART_MSR_RI) {
- *Control |= EFI_SERIAL_RING_INDICATE;
- }
-
- if ((Msr & B_UART_MSR_DCD) == B_UART_MSR_DCD) {
- *Control |= EFI_SERIAL_CARRIER_DETECT;
- }
-
- //
- // Read the Modem Control Register.
- //
- Mcr = SerialPortReadRegister (SerialRegisterBase, R_UART_MCR);
-
- if ((Mcr & B_UART_MCR_DTRC) == B_UART_MCR_DTRC) {
- *Control |= EFI_SERIAL_DATA_TERMINAL_READY;
- }
-
- if ((Mcr & B_UART_MCR_RTS) == B_UART_MCR_RTS) {
- *Control |= EFI_SERIAL_REQUEST_TO_SEND;
- }
-
- if (PcdGetBool (PcdSerialUseHardwareFlowControl)) {
- *Control |= EFI_SERIAL_HARDWARE_FLOW_CONTROL_ENABLE;
- }
-
- //
- // Read the Line Status Register.
- //
- Lsr = SerialPortReadRegister (SerialRegisterBase, R_UART_LSR);
-
- if ((Lsr & (B_UART_LSR_TEMT | B_UART_LSR_TXRDY)) == (B_UART_LSR_TEMT | B_UART_LSR_TXRDY)) {
- *Control |= EFI_SERIAL_OUTPUT_BUFFER_EMPTY;
- }
-
- if ((Lsr & B_UART_LSR_RXRDY) == 0) {
- *Control |= EFI_SERIAL_INPUT_BUFFER_EMPTY;
- }
-
- return RETURN_SUCCESS;
- }
-}
-
-/**
- Sets the baud rate, receive FIFO depth, transmit/receice time out, parity,
- data bits, and stop bits on a serial device.
-
- @param BaudRate The requested baud rate. A BaudRate value of 0 will use the
- device's default interface speed.
- On output, the value actually set.
- @param ReveiveFifoDepth The requested depth of the FIFO on the receive side of the
- serial interface. A ReceiveFifoDepth value of 0 will use
- the device's default FIFO depth.
- On output, the value actually set.
- @param Timeout The requested time out for a single character in microseconds.
- This timeout applies to both the transmit and receive side of the
- interface. A Timeout value of 0 will use the device's default time
- out value.
- On output, the value actually set.
- @param Parity The type of parity to use on this serial device. A Parity value of
- DefaultParity will use the device's default parity value.
- On output, the value actually set.
- @param DataBits The number of data bits to use on the serial device. A DataBits
- vaule of 0 will use the device's default data bit setting.
- On output, the value actually set.
- @param StopBits The number of stop bits to use on this serial device. A StopBits
- value of DefaultStopBits will use the device's default number of
- stop bits.
- On output, the value actually set.
-
- @retval RETURN_SUCCESS The new attributes were set on the serial device.
- @retval RETURN_UNSUPPORTED The serial device does not support this operation.
- @retval RETURN_INVALID_PARAMETER One or more of the attributes has an unsupported value.
- @retval RETURN_DEVICE_ERROR The serial device is not functioning correctly.
-
-**/
-RETURN_STATUS
-EFIAPI
-SerialPortSetAttributes (
- IN OUT UINT64 *BaudRate,
- IN OUT UINT32 *ReceiveFifoDepth,
- IN OUT UINT32 *Timeout,
- IN OUT EFI_PARITY_TYPE *Parity,
- IN OUT UINT8 *DataBits,
- IN OUT EFI_STOP_BITS_TYPE *StopBits
- )
-{
- UINTN SerialRegisterBase;
- UINT32 SerialBaudRate;
- UINTN Divisor;
- UINT8 Lcr;
- UINT8 LcrData;
- UINT8 LcrParity;
- UINT8 LcrStop;
-
- if (UsePl011Uart) {
- return PL011UartInitializePort (
- PL011_UART_REGISTER_BASE,
- PL011UartClockGetFreq(),
- BaudRate,
- ReceiveFifoDepth,
- Parity,
- DataBits,
- StopBits
- );
- } else {
- SerialRegisterBase = MINI_UART_REGISTER_BASE;
-
- //
- // Check for default settings and fill in actual values.
- //
- if (*BaudRate == 0) {
- *BaudRate = PcdGet32 (PcdSerialBaudRate);
- }
- SerialBaudRate = (UINT32) *BaudRate;
-
- if (*DataBits == 0) {
- LcrData = (UINT8) (PcdGet8 (PcdSerialLineControl) & 0x3);
- *DataBits = LcrData + 5;
- } else {
- if ((*DataBits < 5) || (*DataBits > 8)) {
- return RETURN_INVALID_PARAMETER;
- }
- //
- // Map 5..8 to 0..3
- //
- LcrData = (UINT8) (*DataBits - (UINT8) 5);
- }
-
- if (*Parity == DefaultParity) {
- LcrParity = (UINT8) ((PcdGet8 (PcdSerialLineControl) >> 3) & 0x7);
- switch (LcrParity) {
- case 0:
- *Parity = NoParity;
- break;
-
- case 3:
- *Parity = EvenParity;
- break;
-
- case 1:
- *Parity = OddParity;
- break;
-
- case 7:
- *Parity = SpaceParity;
- break;
-
- case 5:
- *Parity = MarkParity;
- break;
-
- default:
- break;
- }
- } else {
- switch (*Parity) {
- case NoParity:
- LcrParity = 0;
- break;
-
- case EvenParity:
- LcrParity = 3;
- break;
-
- case OddParity:
- LcrParity = 1;
- break;
-
- case SpaceParity:
- LcrParity = 7;
- break;
-
- case MarkParity:
- LcrParity = 5;
- break;
-
- default:
- return RETURN_INVALID_PARAMETER;
- }
- }
-
- if (*StopBits == DefaultStopBits) {
- LcrStop = (UINT8) ((PcdGet8 (PcdSerialLineControl) >> 2) & 0x1);
- switch (LcrStop) {
- case 0:
- *StopBits = OneStopBit;
- break;
-
- case 1:
- if (*DataBits == 5) {
- *StopBits = OneFiveStopBits;
- } else {
- *StopBits = TwoStopBits;
- }
- break;
-
- default:
- break;
- }
- } else {
- switch (*StopBits) {
- case OneStopBit:
- LcrStop = 0;
- break;
-
- case OneFiveStopBits:
- case TwoStopBits:
- LcrStop = 1;
- break;
-
- default:
- return RETURN_INVALID_PARAMETER;
- }
- }
-
- //
- // Configure baud rate
- //
- Divisor = SerialPortGetDivisor (SerialBaudRate);
- SerialPortWriteRegister (SerialRegisterBase, R_UART_LCR, B_UART_LCR_DLAB);
- SerialPortWriteRegister (SerialRegisterBase, R_UART_BAUD_HIGH, (UINT8) (Divisor >> 8));
- SerialPortWriteRegister (SerialRegisterBase, R_UART_BAUD_LOW, (UINT8) (Divisor & 0xff));
-
- //
- // Clear DLAB and configure Data Bits, Parity, and Stop Bits.
- // Strip reserved bits from line control value
- //
- Lcr = (UINT8) ((LcrParity << 3) | (LcrStop << 2) | LcrData);
- SerialPortWriteRegister (SerialRegisterBase, R_UART_LCR, (UINT8) (Lcr & 0x3F));
-
- return RETURN_SUCCESS;
- }
-}
diff --git a/Platform/RaspberryPi/Library/DualSerialPortLib/DualSerialPortLib.c.rej b/Platform/RaspberryPi/Library/DualSerialPortLib/DualSerialPortLib.c.rej
deleted file mode 100644
index fd8a1b2f20..0000000000
--- a/Platform/RaspberryPi/Library/DualSerialPortLib/DualSerialPortLib.c.rej
+++ /dev/null
@@ -1,31 +0,0 @@
---- Platform/RaspberryPi/Library/DualSerialPortLib/DualSerialPortLib.c
-+++ Platform/RaspberryPi/Library/DualSerialPortLib/DualSerialPortLib.c
-@@ -34,25 +34,16 @@ SerialPortGetDivisor (
- UINT32 SerialBaudRate
- )
- {
-- UINT64 BaseClockRate;
-+ UINT32 BaseClockRate;
- UINT32 Divisor;
-
-- //
-- // On the Raspberry Pi, the clock to use for the 16650-compatible UART
-- // is the base clock divided by the 12.12 fixed point VPU clock divisor.
-- //
-- BaseClockRate = (UINT64)PcdGet32 (PcdSerialClockRate);
--#if (RPI_MODEL == 4)
-- Divisor = MmioRead32(BCM2836_CM_BASE + BCM2836_CM_VPU_CLOCK_DIVISOR) & 0xFFFFFF;
-- if (Divisor != 0)
-- BaseClockRate = (BaseClockRate << 12) / Divisor;
--#endif
-+ BaseClockRate = PcdGet32 (PcdSerialClockRate);
-
- //
- // As per the BCM2xxx datasheets:
- // baudrate = system_clock_freq / (8 * (divisor + 1)).
- //
-- Divisor = (UINT32)BaseClockRate / (SerialBaudRate * 8);
-+ Divisor = BaseClockRate / (SerialBaudRate * 8);
- if (Divisor != 0) {
- Divisor--;
- }
diff --git a/Platform/RaspberryPi/Library/PlatformLib/AArch64/RaspberryPiHelper.S.orig b/Platform/RaspberryPi/Library/PlatformLib/AArch64/RaspberryPiHelper.S.orig
deleted file mode 100644
index 58351e4fb8..0000000000
--- a/Platform/RaspberryPi/Library/PlatformLib/AArch64/RaspberryPiHelper.S.orig
+++ /dev/null
@@ -1,180 +0,0 @@
-/** @file
- *
- * Copyright (c) 2020, Andrei Warkentin <andrey.warkentin@...>
- * Copyright (c) 2019-2020, Pete Batard <pete@...>
- * Copyright (c) 2016, Linaro Limited. All rights reserved.
- * Copyright (c) 2011-2020, ARM Limited. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-2-Clause-Patent
- *
- **/
-
-#include <AsmMacroIoLibV8.h>
-#include <Library/ArmLib.h>
-#include <IndustryStandard/Bcm2836.h>
-#include <IndustryStandard/RpiMbox.h>
-
- .macro drain
- mov x5, #RPI_MBOX_MAX_TRIES
-0: ldr w6, [x4, #BCM2836_MBOX_STATUS_OFFSET]
- tbnz w6, #BCM2836_MBOX_STATUS_EMPTY, 1f
- dmb ld
- ldr wzr, [x4, #BCM2836_MBOX_READ_OFFSET]
- subs x5, x5, #1
- b.ne 0b
-1:
- .endm
-
- .macro poll, status
- mov x5, #RPI_MBOX_MAX_TRIES
-0: ldr w6, [x4, #BCM2836_MBOX_STATUS_OFFSET]
- tbz w6, #\status, 1f
- dmb ld
- subs x5, x5, #1
- b.ne 0b
-1:
- .endm
-
- .macro run, command_buffer
- adr x0, \command_buffer
- orr x0, x0, #RPI_MBOX_VC_CHANNEL
- add x0, x0, x1
-
- poll BCM2836_MBOX_STATUS_FULL
- str w0, [x4, #BCM2836_MBOX_WRITE_OFFSET]
- dmb sy
- poll BCM2836_MBOX_STATUS_EMPTY
- dmb sy
- ldr wzr, [x4, #BCM2836_MBOX_READ_OFFSET]
- dmb ld
- .endm
-
-ASM_FUNC (ArmPlatformPeiBootAction)
- mov x1, #FixedPcdGet64 (PcdDmaDeviceOffset)
- orr x0, x0, #RPI_MBOX_VC_CHANNEL
- // x1 holds the value of PcdDmaDeviceOffset throughout this function
-
- MOV32 (x4, BCM2836_MBOX_BASE_ADDRESS)
-
- drain
-
- run .Lmeminfo_buffer
-
- ldr w0, .Lmembase
- adr x2, mSystemMemoryBase
- str x0, [x2]
-
- ldr w0, .Lmemsize
- sub x0, x0, #1
- adr x2, mSystemMemoryEnd
- str x0, [x2]
-
- run .Lvcinfo_buffer
-
- ldr w0, .Lvcbase
- adr x2, mVideoCoreBase
- str x0, [x2]
-
- ldr w0, .Lvcsize
- adr x2, mVideoCoreSize
- str x0, [x2]
-
- run .Lrevinfo_buffer
-
- ldr w0, .Lrevision
- adr x2, mBoardRevision
- str w0, [x2]
-
-#if (RPI_MODEL == 3)
- run .Lclkinfo_buffer
-
- ldr w0, .Lfrequency
- adr x2, _gPcd_BinaryPatch_PcdSerialClockRate
- str w0, [x2]
-#endif
-
- ret
-
- .align 4
-.Lmeminfo_buffer:
- .long .Lmeminfo_size
- .long 0x0
- .long RPI_MBOX_GET_ARM_MEMSIZE
- .long 8 // buf size
- .long 0 // input len
-.Lmembase:
- .long 0 // mem base
-.Lmemsize:
- .long 0 // mem size
- .long 0 // end tag
- .set .Lmeminfo_size, . - .Lmeminfo_buffer
-
- .align 4
-.Lvcinfo_buffer:
- .long .Lvcinfo_size
- .long 0x0
- .long RPI_MBOX_GET_VC_MEMSIZE
- .long 8 // buf size
- .long 0 // input len
-.Lvcbase:
- .long 0 // videocore base
-.Lvcsize:
- .long 0 // videocore size
- .long 0 // end tag
- .set .Lvcinfo_size, . - .Lvcinfo_buffer
-
- .align 4
-.Lrevinfo_buffer:
- .long .Lrevinfo_size
- .long 0x0
- .long RPI_MBOX_GET_BOARD_REVISION
- .long 4 // buf size
- .long 0 // input len
-.Lrevision:
- .long 0 // revision
- .long 0 // end tag
- .set .Lrevinfo_size, . - .Lrevinfo_buffer
-
-#if (RPI_MODEL == 3)
- .align 4
-.Lclkinfo_buffer:
- .long .Lclkinfo_size
- .long 0x0
- .long RPI_MBOX_GET_CLOCK_RATE
- .long 8 // buf size
- .long 4 // input len
- .long 4 // clock id: 0x04 = Core/VPU
-.Lfrequency:
- .long 0 // frequency
- .long 0 // end tag
- .set .Lclkinfo_size, . - .Lclkinfo_buffer
-#endif
-
-//UINTN
-//ArmPlatformGetPrimaryCoreMpId (
-// VOID
-// );
-ASM_FUNC (ArmPlatformGetPrimaryCoreMpId)
- MOV32 (w0, FixedPcdGet32 (PcdArmPrimaryCore))
- ret
-
-//UINTN
-//ArmPlatformIsPrimaryCore (
-// IN UINTN MpId
-// );
-ASM_FUNC (ArmPlatformIsPrimaryCore)
- mov x0, #1
- ret
-
-//UINTN
-//ArmPlatformGetCorePosition (
-// IN UINTN MpId
-// );
-// With this function: CorePos = (ClusterId * 4) + CoreId
-ASM_FUNC (ArmPlatformGetCorePosition)
- and x1, x0, #ARM_CORE_MASK
- and x0, x0, #ARM_CLUSTER_MASK
- add x0, x1, x0, LSR #6
- ret
-
-ASM_FUNCTION_REMOVE_IF_UNREFERENCED
diff --git a/Platform/RaspberryPi/Library/PlatformLib/AArch64/RaspberryPiHelper.S.rej b/Platform/RaspberryPi/Library/PlatformLib/AArch64/RaspberryPiHelper.S.rej
deleted file mode 100644
index e42851fafe..0000000000
--- a/Platform/RaspberryPi/Library/PlatformLib/AArch64/RaspberryPiHelper.S.rej
+++ /dev/null
@@ -1,32 +0,0 @@
---- Platform/RaspberryPi/Library/PlatformLib/AArch64/RaspberryPiHelper.S
-+++ Platform/RaspberryPi/Library/PlatformLib/AArch64/RaspberryPiHelper.S
-@@ -85,13 +85,11 @@ ASM_FUNC (ArmPlatformPeiBootAction)
- adr x2, mBoardRevision
- str w0, [x2]
-
--#if (RPI_MODEL == 3)
- run .Lclkinfo_buffer
-
- ldr w0, .Lfrequency
- adr x2, _gPcd_BinaryPatch_PcdSerialClockRate
- str w0, [x2]
--#endif
-
- ret
-
-@@ -135,7 +133,6 @@ ASM_FUNC (ArmPlatformPeiBootAction)
- .long 0 // end tag
- .set .Lrevinfo_size, . - .Lrevinfo_buffer
-
--#if (RPI_MODEL == 3)
- .align 4
- .Lclkinfo_buffer:
- .long .Lclkinfo_size
-@@ -148,7 +145,6 @@ ASM_FUNC (ArmPlatformPeiBootAction)
- .long 0 // frequency
- .long 0 // end tag
- .set .Lclkinfo_size, . - .Lclkinfo_buffer
--#endif
-
- //UINTN
- //ArmPlatformGetPrimaryCoreMpId (
diff --git a/Platform/RaspberryPi/RPi4/RPi4.dsc.orig b/Platform/RaspberryPi/RPi4/RPi4.dsc.orig
deleted file mode 100644
index 2c05c31118..0000000000
--- a/Platform/RaspberryPi/RPi4/RPi4.dsc.orig
+++ /dev/null
@@ -1,760 +0,0 @@
-# @file
-#
-# Copyright (c) 2011 - 2020, ARM Limited. All rights reserved.
-# Copyright (c) 2017 - 2018, Andrei Warkentin <andrey.warkentin@...>
-# Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.
-# Copyright (c) 2014, Linaro Limited. All rights reserved.
-#
-# SPDX-License-Identifier: BSD-2-Clause-Patent
-#
-##
-
-################################################################################
-#
-# Defines Section - statements that will be processed to create a Makefile.
-#
-################################################################################
-[Defines]
- PLATFORM_NAME = RPi4
- PLATFORM_GUID = a7eca3b4-21b0-4989-8c18-c08f3ae87837
- PLATFORM_VERSION = 1.0
- DSC_SPECIFICATION = 0x0001001A
- OUTPUT_DIRECTORY = Build/$(PLATFORM_NAME)
- SUPPORTED_ARCHITECTURES = AARCH64
- BUILD_TARGETS = DEBUG|RELEASE|NOOPT
- SKUID_IDENTIFIER = DEFAULT
- FLASH_DEFINITION = Platform/RaspberryPi/$(PLATFORM_NAME)/$(PLATFORM_NAME).fdf
-
- #
- # Defines for default states. These can be changed on the command line.
- # -D FLAG=VALUE
- #
- DEFINE SECURE_BOOT_ENABLE = FALSE
- DEFINE INCLUDE_TFTP_COMMAND = FALSE
- DEFINE DEBUG_PRINT_ERROR_LEVEL = 0x8000004F
-
-!ifndef TFA_BUILD_ARTIFACTS
- #
- # Default TF-A binary checked into edk2-non-osi.
- #
- DEFINE TFA_BUILD_BL31 = Platform/RaspberryPi/$(PLATFORM_NAME)/TrustedFirmware/bl31.bin
-!else
- #
- # Usually we use the checked-in binaries, but for developers working
- # on the firmware, being able to use a local TF-A build without extra copy
- # operations ends up being very helpful.
- #
- DEFINE TFA_BUILD_BL31 = $(TFA_BUILD_ARTIFACTS)/bl31.bin
-!endif
-
-################################################################################
-#
-# Library Class section - list of all Library Classes needed by this Platform.
-#
-################################################################################
-
-!include MdePkg/MdeLibs.dsc.inc
-
-[LibraryClasses.common]
-!if $(TARGET) == RELEASE
- DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf
-!else
- DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
-!endif
- DebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintErrorLevelLib/BaseDebugPrintErrorLevelLib.inf
-
- BaseLib|MdePkg/Library/BaseLib/BaseLib.inf
- SafeIntLib|MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf
- BmpSupportLib|MdeModulePkg/Library/BaseBmpSupportLib/BaseBmpSupportLib.inf
- SynchronizationLib|MdePkg/Library/BaseSynchronizationLib/BaseSynchronizationLib.inf
- PerformanceLib|MdePkg/Library/BasePerformanceLibNull/BasePerformanceLibNull.inf
- ReportStatusCodeLib|MdePkg/Library/BaseReportStatusCodeLibNull/BaseReportStatusCodeLibNull.inf
- PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf
- PeCoffGetEntryPointLib|MdePkg/Library/BasePeCoffGetEntryPointLib/BasePeCoffGetEntryPointLib.inf
- PeCoffLib|MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf
- IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf
- UefiDecompressLib|MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.inf
- CpuLib|MdePkg/Library/BaseCpuLib/BaseCpuLib.inf
-
- UefiLib|MdePkg/Library/UefiLib/UefiLib.inf
- HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
- UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf
- DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf
- UefiBootServicesTableLib|MdePkg/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.inf
- DxeServicesTableLib|MdePkg/Library/DxeServicesTableLib/DxeServicesTableLib.inf
- DxeServicesLib|MdePkg/Library/DxeServicesLib/DxeServicesLib.inf
- UefiDriverEntryPoint|MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntryPoint.inf
- UefiApplicationEntryPoint|MdePkg/Library/UefiApplicationEntryPoint/UefiApplicationEntryPoint.inf
- HiiLib|MdeModulePkg/Library/UefiHiiLib/UefiHiiLib.inf
- UefiHiiServicesLib|MdeModulePkg/Library/UefiHiiServicesLib/UefiHiiServicesLib.inf
- SortLib|MdeModulePkg/Library/UefiSortLib/UefiSortLib.inf
-
- UefiRuntimeLib|MdePkg/Library/UefiRuntimeLib/UefiRuntimeLib.inf
- OrderedCollectionLib|MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.inf
-
- #
- # Ramdisk Requirements
- #
- FileExplorerLib|MdeModulePkg/Library/FileExplorerLib/FileExplorerLib.inf
-
- # Allow dynamic PCDs
- #
- PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
-
- # use the accelerated BaseMemoryLibOptDxe by default, overrides for SEC/PEI below
- BaseMemoryLib|MdePkg/Library/BaseMemoryLibOptDxe/BaseMemoryLibOptDxe.inf
-
- #
- # It is not possible to prevent the ARM compiler from inserting calls to intrinsic functions.
- # This library provides the instrinsic functions such a compiler may generate calls to.
- #
- NULL|ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf
-
- # Add support for GCC stack protector
- NULL|MdePkg/Library/BaseStackCheckLib/BaseStackCheckLib.inf
-
- # ARM Architectural Libraries
- CacheMaintenanceLib|ArmPkg/Library/ArmCacheMaintenanceLib/ArmCacheMaintenanceLib.inf
- DefaultExceptionHandlerLib|ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerLib.inf
- CpuExceptionHandlerLib|ArmPkg/Library/ArmExceptionLib/ArmExceptionLib.inf
- ArmDisassemblerLib|ArmPkg/Library/ArmDisassemblerLib/ArmDisassemblerLib.inf
- ArmGicLib|ArmPkg/Drivers/ArmGic/ArmGicLib.inf
- ArmGicArchLib|ArmPkg/Library/ArmGicArchLib/ArmGicArchLib.inf
- DmaLib|EmbeddedPkg/Library/NonCoherentDmaLib/NonCoherentDmaLib.inf
- TimeBaseLib|EmbeddedPkg/Library/TimeBaseLib/TimeBaseLib.inf
- ArmPlatformStackLib|ArmPlatformPkg/Library/ArmPlatformStackLib/ArmPlatformStackLib.inf
- ArmSmcLib|ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf
- ArmHvcLib|ArmPkg/Library/ArmHvcLib/ArmHvcLib.inf
- ArmGenericTimerCounterLib|ArmPkg/Library/ArmGenericTimerPhyCounterLib/ArmGenericTimerPhyCounterLib.inf
-
- # Dual serial port library
- PL011UartClockLib|ArmPlatformPkg/Library/PL011UartClockLib/PL011UartClockLib.inf
- PL011UartLib|ArmPlatformPkg/Library/PL011UartLib/PL011UartLib.inf
- SerialPortLib|Platform/RaspberryPi/Library/DualSerialPortLib/DebugDualSerialPortLib.inf
-
- # Cryptographic libraries
- RngLib|MdePkg/Library/DxeRngLib/DxeRngLib.inf
- IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
- BaseCryptLib|CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf
- OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLib.inf
- TlsLib|CryptoPkg/Library/TlsLib/TlsLib.inf
-
- #
- # Uncomment (and comment out the next line) For RealView Debugger. The Standard IO window
- # in the debugger will show load and unload commands for symbols. You can cut and paste this
- # into the command window to load symbols. We should be able to use a script to do this, but
- # the version of RVD I have does not support scripts accessing system memory.
- #
- #PeCoffExtraActionLib|ArmPkg/Library/RvdPeCoffExtraActionLib/RvdPeCoffExtraActionLib.inf
- PeCoffExtraActionLib|ArmPkg/Library/DebugPeCoffExtraActionLib/DebugPeCoffExtraActionLib.inf
- #PeCoffExtraActionLib|MdePkg/Library/BasePeCoffExtraActionLibNull/BasePeCoffExtraActionLibNull.inf
-
- DebugAgentLib|MdeModulePkg/Library/DebugAgentLibNull/DebugAgentLibNull.inf
- DebugAgentTimerLib|EmbeddedPkg/Library/DebugAgentTimerLibNull/DebugAgentTimerLibNull.inf
-
- # Flattened Device Tree (FDT) access library
- FdtLib|EmbeddedPkg/Library/FdtLib/FdtLib.inf
-
- # USB Libraries
- UefiUsbLib|MdePkg/Library/UefiUsbLib/UefiUsbLib.inf
-
- #
- # Secure Boot dependencies
- #
-!if $(SECURE_BOOT_ENABLE) == TRUE
- TpmMeasurementLib|SecurityPkg/Library/DxeTpmMeasurementLib/DxeTpmMeasurementLib.inf
- AuthVariableLib|SecurityPkg/Library/AuthVariableLib/AuthVariableLib.inf
-
- # re-use the UserPhysicalPresent() dummy implementation from the ovmf tree
- PlatformSecureLib|OvmfPkg/Library/PlatformSecureLib/PlatformSecureLib.inf
-!else
- TpmMeasurementLib|MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasurementLibNull.inf
- AuthVariableLib|MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.inf
-!endif
- VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf
- VariablePolicyLib|MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLib.inf
- VariablePolicyHelperLib|MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.inf
- GpioLib|Silicon/Broadcom/Bcm283x/Library/GpioLib/GpioLib.inf
-
- #
- # PCI dependencies
- #
- # PCI root port configuation and description
- PciHostBridgeLib|Silicon/Broadcom/Bcm27xx/Library/Bcm2711PciHostBridgeLib/Bcm2711PciHostBridgeLib.inf
- # The "segment lib" provides the CAM accessors/etc when they aren't ECAM standard
- PciSegmentLib|Silicon/Broadcom/Bcm27xx/Library/Bcm2711PciSegmentLib/PciSegmentLib.inf
-
-[LibraryClasses.common.SEC]
- PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
- BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf
- MemoryInitPeiLib|Platform/RaspberryPi/Library/MemoryInitPeiLib/MemoryInitPeiLib.inf
- PlatformPeiLib|ArmPlatformPkg/PlatformPei/PlatformPeiLib.inf
- ExtractGuidedSectionLib|EmbeddedPkg/Library/PrePiExtractGuidedSectionLib/PrePiExtractGuidedSectionLib.inf
- LzmaDecompressLib|MdeModulePkg/Library/LzmaCustomDecompressLib/LzmaCustomDecompressLib.inf
- PrePiLib|EmbeddedPkg/Library/PrePiLib/PrePiLib.inf
- HobLib|EmbeddedPkg/Library/PrePiHobLib/PrePiHobLib.inf
- PrePiHobListPointerLib|ArmPlatformPkg/Library/PrePiHobListPointerLib/PrePiHobListPointerLib.inf
- MemoryAllocationLib|EmbeddedPkg/Library/PrePiMemoryAllocationLib/PrePiMemoryAllocationLib.inf
-
-[LibraryClasses.common.DXE_CORE]
- HobLib|MdePkg/Library/DxeCoreHobLib/DxeCoreHobLib.inf
- MemoryAllocationLib|MdeModulePkg/Library/DxeCoreMemoryAllocationLib/DxeCoreMemoryAllocationLib.inf
- DxeCoreEntryPoint|MdePkg/Library/DxeCoreEntryPoint/DxeCoreEntryPoint.inf
- ExtractGuidedSectionLib|MdePkg/Library/DxeExtractGuidedSectionLib/DxeExtractGuidedSectionLib.inf
- PerformanceLib|MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.inf
-
-[LibraryClasses.common.DXE_DRIVER]
- SecurityManagementLib|MdeModulePkg/Library/DxeSecurityManagementLib/DxeSecurityManagementLib.inf
- PerformanceLib|MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.inf
- MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
-!if $(INCLUDE_TFTP_COMMAND) == TRUE
- ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf
- FileHandleLib|MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf
-!endif
-
-[LibraryClasses.common.UEFI_APPLICATION]
- PerformanceLib|MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.inf
- MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
- HiiLib|MdeModulePkg/Library/UefiHiiLib/UefiHiiLib.inf
- ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf
- FileHandleLib|MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf
-
-[LibraryClasses.common.UEFI_DRIVER]
- ExtractGuidedSectionLib|MdePkg/Library/DxeExtractGuidedSectionLib/DxeExtractGuidedSectionLib.inf
- PerformanceLib|MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.inf
- MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
-
-[LibraryClasses.common.DXE_RUNTIME_DRIVER]
- # Runtime debug messages may crash an OS unless serial output to MMIO mapped UARTs is inhibited
- DebugLib|MdePkg/Library/DxeRuntimeDebugLibSerialPort/DxeRuntimeDebugLibSerialPort.inf
- MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
- CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf
- EfiResetSystemLib|Platform/RaspberryPi/Library/ResetLib/ResetLib.inf
- ArmSmcLib|ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf
- VariablePolicyLib|MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLibRuntimeDxe.inf
-
-!if $(SECURE_BOOT_ENABLE) == TRUE
- BaseCryptLib|CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf
-!endif
-
-###################################################################################################
-# BuildOptions Section - Define the module specific tool chain flags that should be used as
-# the default flags for a module. These flags are appended to any
-# standard flags that are defined by the build process.
-###################################################################################################
-
-[BuildOptions]
- GCC:*_*_*_CC_FLAGS = -DRPI_MODEL=4
- GCC:*_*_*_PP_FLAGS = -DRPI_MODEL=4
- GCC:*_*_*_ASLPP_FLAGS = -DRPI_MODEL=4
- GCC:*_*_*_ASLCC_FLAGS = -DRPI_MODEL=4
- GCC:*_*_*_VFRPP_FLAGS = -DRPI_MODEL=4
- GCC:RELEASE_*_*_CC_FLAGS = -DMDEPKG_NDEBUG -DNDEBUG
-
-[BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER]
- GCC:*_*_AARCH64_DLINK_FLAGS = -z common-page-size=0x10000
-
-################################################################################
-#
-# Pcd Section - list of all EDK II PCD Entries defined by this Platform
-#
-################################################################################
-
-[PcdsFeatureFlag.common]
- # Use the Vector Table location in CpuDxe. We will not copy the Vector Table at PcdCpuVectorBaseAddress
- gArmTokenSpaceGuid.PcdRelocateVectorTable|FALSE
-
- gEmbeddedTokenSpaceGuid.PcdPrePiProduceMemoryTypeInformationHob|TRUE
- gEfiMdeModulePkgTokenSpaceGuid.PcdTurnOffUsbLegacySupport|TRUE
-
- ## If TRUE, Graphics Output Protocol will be installed on virtual handle created by ConsplitterDxe.
- # It could be set FALSE to save size.
- gEfiMdeModulePkgTokenSpaceGuid.PcdConOutGopSupport|TRUE
- gEfiMdeModulePkgTokenSpaceGuid.PcdConOutUgaSupport|FALSE
- gEfiMdePkgTokenSpaceGuid.PcdUgaConsumeSupport|FALSE
-
-[PcdsFixedAtBuild.common]
- gEfiMdePkgTokenSpaceGuid.PcdMaximumUnicodeStringLength|1000000
- gEfiMdePkgTokenSpaceGuid.PcdMaximumAsciiStringLength|1000000
- gEfiMdePkgTokenSpaceGuid.PcdMaximumLinkedListLength|1000000
- gEfiMdePkgTokenSpaceGuid.PcdSpinLockTimeout|10000000
- gEfiMdePkgTokenSpaceGuid.PcdDebugClearMemoryValue|0xAF
- gEfiMdePkgTokenSpaceGuid.PcdPerformanceLibraryPropertyMask|1
- gEfiMdePkgTokenSpaceGuid.PcdPostCodePropertyMask|0
- gEfiMdePkgTokenSpaceGuid.PcdUefiLibMaxPrintBufferSize|320
-
- # DEBUG_ASSERT_ENABLED 0x01
- # DEBUG_PRINT_ENABLED 0x02
- # DEBUG_CODE_ENABLED 0x04
- # CLEAR_MEMORY_ENABLED 0x08
- # ASSERT_BREAKPOINT_ENABLED 0x10
- # ASSERT_DEADLOOP_ENABLED 0x20
-!if $(TARGET) == RELEASE
- gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x21
-!else
- gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x2f
-!endif
-
- # DEBUG_INIT 0x00000001 // Initialization
- # DEBUG_WARN 0x00000002 // Warnings
- # DEBUG_LOAD 0x00000004 // Load events
- # DEBUG_FS 0x00000008 // EFI File system
- # DEBUG_POOL 0x00000010 // Alloc & Free (pool)
- # DEBUG_PAGE 0x00000020 // Alloc & Free (page)
- # DEBUG_INFO 0x00000040 // Informational debug messages
- # DEBUG_DISPATCH 0x00000080 // PEI/DXE/SMM Dispatchers
- # DEBUG_VARIABLE 0x00000100 // Variable
- # DEBUG_BM 0x00000400 // Boot Manager
- # DEBUG_BLKIO 0x00001000 // BlkIo Driver
- # DEBUG_NET 0x00004000 // SNP Driver
- # DEBUG_UNDI 0x00010000 // UNDI Driver
- # DEBUG_LOADFILE 0x00020000 // LoadFile
- # DEBUG_EVENT 0x00080000 // Event messages
- # DEBUG_GCD 0x00100000 // Global Coherency Database changes
- # DEBUG_CACHE 0x00200000 // Memory range cachability changes
- # DEBUG_VERBOSE 0x00400000 // Detailed debug messages that may
- # // significantly impact boot performance
- # DEBUG_ERROR 0x80000000 // Error
- gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|$(DEBUG_PRINT_ERROR_LEVEL)
-
- gEfiMdePkgTokenSpaceGuid.PcdReportStatusCodePropertyMask|0x07
-
- #
- # Optional feature to help prevent EFI memory map fragments
- # Turned on and off via: PcdPrePiProduceMemoryTypeInformationHob
- # Values are in EFI Pages (4K). DXE Core will make sure that
- # at least this much of each type of memory can be allocated
- # from a single memory range. This way you only end up with
- # maximum of two fragments for each type in the memory map
- # (the memory used, and the free memory that was prereserved
- # but not used).
- #
- gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiACPIReclaimMemory|0
- gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiACPIMemoryNVS|0
- gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiReservedMemoryType|0
-!if $(SECURE_BOOT_ENABLE) == TRUE
- gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiRuntimeServicesData|600
- gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiRuntimeServicesCode|400
- gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiBootServicesCode|1500
-!else
- gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiRuntimeServicesData|300
- gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiRuntimeServicesCode|150
- gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiBootServicesCode|1000
-!endif
- gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiBootServicesData|12000
- gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiLoaderCode|20
- gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiLoaderData|0
-
- gEmbeddedTokenSpaceGuid.PcdDmaDeviceOffset|0xc0000000
- gEmbeddedTokenSpaceGuid.PcdDmaDeviceLimit|0xffffffff
-
- gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVersionString|L"EDK2-DEV"
-
-!if $(SECURE_BOOT_ENABLE) == TRUE
- # override the default values from SecurityPkg to ensure images from all sources are verified in secure boot
- gEfiSecurityPkgTokenSpaceGuid.PcdOptionRomImageVerificationPolicy|0x04
- gEfiSecurityPkgTokenSpaceGuid.PcdFixedMediaImageVerificationPolicy|0x04
- gEfiSecurityPkgTokenSpaceGuid.PcdRemovableMediaImageVerificationPolicy|0x04
-!endif
-
- gEfiNetworkPkgTokenSpaceGuid.PcdAllowHttpConnections|TRUE
-
- # Default platform supported RFC 4646 languages: (American) English
- gEfiMdePkgTokenSpaceGuid.PcdUefiVariableDefaultPlatformLangCodes|"en-US"
-
-[LibraryClasses.common]
- ArmLib|ArmPkg/Library/ArmLib/ArmBaseLib.inf
- ArmMmuLib|ArmPkg/Library/ArmMmuLib/ArmMmuBaseLib.inf
- ArmPlatformLib|Platform/RaspberryPi/Library/PlatformLib/PlatformLib.inf
- TimerLib|ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.inf
- CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf
- UefiBootManagerLib|MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf
- BootLogoLib|MdeModulePkg/Library/BootLogoLib/BootLogoLib.inf
- PlatformBootManagerLib|Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
- CustomizedDisplayLib|MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.inf
- FileExplorerLib|MdeModulePkg/Library/FileExplorerLib/FileExplorerLib.inf
- AcpiLib|EmbeddedPkg/Library/AcpiLib/AcpiLib.inf
-
-[LibraryClasses.common.UEFI_DRIVER]
- UefiScsiLib|MdePkg/Library/UefiScsiLib/UefiScsiLib.inf
-
-################################################################################
-#
-# Pcd Section - list of all EDK II PCD Entries defined by this Platform
-#
-################################################################################
-
-[PcdsFeatureFlag.common]
- gEfiMdeModulePkgTokenSpaceGuid.PcdConOutGopSupport|TRUE
- gEfiMdeModulePkgTokenSpaceGuid.PcdConOutUgaSupport|FALSE
- gEfiMdeModulePkgTokenSpaceGuid.PcdInstallAcpiSdtProtocol|TRUE
-
-[PcdsFixedAtBuild.common]
- gArmPlatformTokenSpaceGuid.PcdCoreCount|4
- gArmTokenSpaceGuid.PcdVFPEnabled|1
-
- gArmPlatformTokenSpaceGuid.PcdCPUCorePrimaryStackSize|0x4000
- gEfiMdeModulePkgTokenSpaceGuid.PcdMaxVariableSize|0x2000
- gEfiMdeModulePkgTokenSpaceGuid.PcdMaxAuthVariableSize|0x2800
-
- # Size of the region used by UEFI in permanent memory (Reserved 64MB)
- gArmPlatformTokenSpaceGuid.PcdSystemMemoryUefiRegionSize|0x04000000
- #
- # 0x00000000 - 0x001F0000 FD (PcdFdBaseAddress, PcdFdSize)
- # 0x001F0000 - 0x00200000 DTB (PcdFdtBaseAddress, PcdFdtSize)
- # 0x00200000 - ... RAM (PcdSystemMemoryBase, PcdSystemMemorySize)
- #
- # This matches PcdFvBaseAddress, since everything less is the FD, and
- # will be reserved away.
- #
- gArmTokenSpaceGuid.PcdSystemMemoryBase|0x00200000
- gArmTokenSpaceGuid.PcdSystemMemorySize|0x3fe00000
-
- #
- # Device specific addresses
- #
- gBcm27xxTokenSpaceGuid.PcdBcm27xxRegistersAddress|0xfc000000
- gBcm27xxTokenSpaceGuid.PcdBcmGenetRegistersAddress|0xfd580000
- gBcm283xTokenSpaceGuid.PcdBcm283xRegistersAddress|0xfe000000
-
- # PCIe specific addresses
- gBcm27xxTokenSpaceGuid.PcdBcm27xxPciRegBase|0xfd500000
- gBcm27xxTokenSpaceGuid.PcdBcm27xxPciBusMmioAdr|0xf8000000
- gBcm27xxTokenSpaceGuid.PcdBcm27xxPciBusMmioLen|0x3ffffff
- gBcm27xxTokenSpaceGuid.PcdBcm27xxPciCpuMmioAdr|0x600000000
-
- # UARTs
- gArmPlatformTokenSpaceGuid.PL011UartInteger|0
- gArmPlatformTokenSpaceGuid.PL011UartFractional|0
- gArmPlatformTokenSpaceGuid.PL011UartClkInHz|48000000
- gEfiMdeModulePkgTokenSpaceGuid.PcdSerialUseMmio|TRUE
- gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterStride|4
- gEfiMdeModulePkgTokenSpaceGuid.PcdSerialClockRate|1000000000
- gEfiMdeModulePkgTokenSpaceGuid.PcdSerialFifoControl|0x27
- gEfiMdeModulePkgTokenSpaceGuid.PcdSerialExtendedTxFifoSize|8
- gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate|115200
- gEfiMdePkgTokenSpaceGuid.PcdUartDefaultReceiveFifoDepth|0
-
- #
- # ARM General Interrupt Controller
- #
- gArmTokenSpaceGuid.PcdGicDistributorBase|0xFF841000
- gArmTokenSpaceGuid.PcdGicInterruptInterfaceBase|0xFF842000
- gRaspberryPiTokenSpaceGuid.PcdGicInterruptInterfaceHBase|0xFF844000
- gRaspberryPiTokenSpaceGuid.PcdGicInterruptInterfaceVBase|0xFF846000
- gRaspberryPiTokenSpaceGuid.PcdGicGsivId|0x19
- gRaspberryPiTokenSpaceGuid.PcdGicPmuIrq0|0x30
- gRaspberryPiTokenSpaceGuid.PcdGicPmuIrq1|0x31
- gRaspberryPiTokenSpaceGuid.PcdGicPmuIrq2|0x32
- gRaspberryPiTokenSpaceGuid.PcdGicPmuIrq3|0x33
-
- #
- # Fixed CPU settings.
- #
- gRaspberryPiTokenSpaceGuid.PcdCpuLowSpeedMHz|800
- gRaspberryPiTokenSpaceGuid.PcdCpuDefSpeedMHz|1500
- gRaspberryPiTokenSpaceGuid.PcdCpuMaxSpeedMHz|2200
-
- ## Default Terminal Type
- ## 0-PCANSI, 1-VT100, 2-VT00+, 3-UTF8, 4-TTYTERM
- gEfiMdePkgTokenSpaceGuid.PcdDefaultTerminalType|4
-
- gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange|FALSE
- gEfiMdeModulePkgTokenSpaceGuid.PcdBootManagerMenuFile|{ 0x21, 0xaa, 0x2c, 0x46, 0x14, 0x76, 0x03, 0x45, 0x83, 0x6e, 0x8a, 0xb6, 0xf4, 0x66, 0x23, 0x31 }
-
- gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVendor|L"EDK2"
- gEfiMdeModulePkgTokenSpaceGuid.PcdSetNxForStack|TRUE
-
-[PcdsDynamicHii.common.DEFAULT]
-
- #
- # Clock overrides.
- #
-
- gRaspberryPiTokenSpaceGuid.PcdCpuClock|L"CpuClock"|gConfigDxeFormSetGuid|0x0|1
- gRaspberryPiTokenSpaceGuid.PcdCustomCpuClock|L"CustomCpuClock"|gConfigDxeFormSetGuid|0x0|gRaspberryPiTokenSpaceGuid.PcdCpuDefSpeedMHz
-
- #
- # SD-related.
- #
-
- gRaspberryPiTokenSpaceGuid.PcdSdIsArasan|L"SdIsArasan"|gConfigDxeFormSetGuid|0x0|0
- gRaspberryPiTokenSpaceGuid.PcdMmcForce1Bit|L"MmcForce1Bit"|gConfigDxeFormSetGuid|0x0|0
- gRaspberryPiTokenSpaceGuid.PcdMmcForceDefaultSpeed|L"MmcForceDefaultSpeed"|gConfigDxeFormSetGuid|0x0|0
- gRaspberryPiTokenSpaceGuid.PcdMmcSdDefaultSpeedMHz|L"MmcSdDefaultSpeedMHz"|gConfigDxeFormSetGuid|0x0|25
- gRaspberryPiTokenSpaceGuid.PcdMmcSdHighSpeedMHz|L"MmcSdHighSpeedMHz"|gConfigDxeFormSetGuid|0x0|50
- gRaspberryPiTokenSpaceGuid.PcdMmcDisableMulti|L"MmcDisableMulti"|gConfigDxeFormSetGuid|0x0|0
- gRaspberryPiTokenSpaceGuid.PcdMmcEnableDma|L"MmcEnableDma"|gConfigDxeFormSetGuid|0x0|0
-
- #
- # Debug-related.
- #
-
- gRaspberryPiTokenSpaceGuid.PcdDebugEnableJTAG|L"DebugEnableJTAG"|gConfigDxeFormSetGuid|0x0|0
-
- #
- # Display-related.
- #
-
- #
- # Just enable native resolution by default.
- #
- gRaspberryPiTokenSpaceGuid.PcdDisplayEnableScaledVModes|L"DisplayEnableScaledVModes"|gConfigDxeFormSetGuid|0x0|0x20
- gRaspberryPiTokenSpaceGuid.PcdDisplayEnableSShot|L"DisplayEnableSShot"|gConfigDxeFormSetGuid|0x0|1
-
- #
- # Supporting > 3GB of memory.
- #
- gRaspberryPiTokenSpaceGuid.PcdRamMoreThan3GB|L"RamMoreThan3GB"|gConfigDxeFormSetGuid|0x0|0
- gRaspberryPiTokenSpaceGuid.PcdRamLimitTo3GB|L"RamLimitTo3GB"|gConfigDxeFormSetGuid|0x0|1
-
- #
- # Device Tree and ACPI selection.
- #
- # 0 - SYSTEM_TABLE_MODE_ACPI (default)
- # 1 - SYSTEM_TABLE_MODE_BOTH
- # 2 - SYSTEM_TABLE_MODE_DT
- #
- gRaspberryPiTokenSpaceGuid.PcdSystemTableMode|L"SystemTableMode"|gConfigDxeFormSetGuid|0x0|0
-
- #
- # Enable a fan in the ACPI thermal zone on GPIO pin #
- #
- # 0 - DISABLED
- # 19 - Enabled on pin 19
- #
- gRaspberryPiTokenSpaceGuid.PcdFanOnGpio|L"FanOnGpio"|gConfigDxeFormSetGuid|0x0|0
- gRaspberryPiTokenSpaceGuid.PcdFanTemp|L"FanTemp"|gConfigDxeFormSetGuid|0x0|60
-
- #
- # Reset-related.
- #
-
- gRaspberryPiTokenSpaceGuid.PcdPlatformResetDelay|L"ResetDelay"|gRaspberryPiTokenSpaceGuid|0x0|0
-
- #
- # Common UEFI ones.
- #
-
- gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut|L"Timeout"|gEfiGlobalVariableGuid|0x0|5
- #
- # This is silly, but by pointing SetupConXXX and ConXXX PCDs to
- # the same variables, I can use the graphical configuration to
- # change the mode used by ConSplitter.
- #
- gEfiMdeModulePkgTokenSpaceGuid.PcdSetupConOutColumn|L"Columns"|gRaspberryPiTokenSpaceGuid|0x0|80
- gEfiMdeModulePkgTokenSpaceGuid.PcdConOutColumn|L"Columns"|gRaspberryPiTokenSpaceGuid|0x0|80
- gEfiMdeModulePkgTokenSpaceGuid.PcdSetupConOutRow|L"Rows"|gRaspberryPiTokenSpaceGuid|0x0|25
- gEfiMdeModulePkgTokenSpaceGuid.PcdConOutRow|L"Rows"|gRaspberryPiTokenSpaceGuid|0x0|25
-
-[PcdsDynamicDefault.common]
- #
- # Set video resolution for boot options and for text setup.
- #
- gEfiMdeModulePkgTokenSpaceGuid.PcdVideoHorizontalResolution|0
- gEfiMdeModulePkgTokenSpaceGuid.PcdVideoVerticalResolution|0
- gEfiMdeModulePkgTokenSpaceGuid.PcdSetupVideoHorizontalResolution|640
- gEfiMdeModulePkgTokenSpaceGuid.PcdSetupVideoVerticalResolution|480
- gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64|0
- gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase|0
- gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase|0
-
-################################################################################
-#
-# Components Section - list of all EDK II Modules needed by this Platform
-#
-################################################################################
-[Components.common]
- #
- # PEI Phase modules
- #
- ArmPlatformPkg/PrePi/PeiUniCore.inf {
- <LibraryClasses>
- SerialPortLib|Platform/RaspberryPi/Library/DualSerialPortLib/DualSerialPortLib.inf
- }
-
- #
- # DXE
- #
- MdeModulePkg/Core/Dxe/DxeMain.inf {
- <LibraryClasses>
- NULL|MdeModulePkg/Library/DxeCrc32GuidedSectionExtractLib/DxeCrc32GuidedSectionExtractLib.inf
- }
- MdeModulePkg/Universal/PCD/Dxe/Pcd.inf {
- <LibraryClasses>
- PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
- }
-
- #
- # Architectural Protocols
- #
- ArmPkg/Drivers/CpuDxe/CpuDxe.inf
- MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf
- Platform/RaspberryPi/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.inf
- MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf
- MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf {
- <LibraryClasses>
- NULL|MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.inf
- DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf
- }
-!if $(SECURE_BOOT_ENABLE) == TRUE
- MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf {
- <LibraryClasses>
- NULL|SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.inf
- }
- SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigDxe.inf
-!else
- MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf
-!endif
- MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
- MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf
- EmbeddedPkg/ResetRuntimeDxe/ResetRuntimeDxe.inf
- EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf {
- <LibraryClasses>
- RealTimeClockLib|EmbeddedPkg/Library/VirtualRealTimeClockLib/VirtualRealTimeClockLib.inf
- }
- EmbeddedPkg/MetronomeDxe/MetronomeDxe.inf
-
- MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf
- MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf
- MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf
- MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf
- MdeModulePkg/Universal/SerialDxe/SerialDxe.inf {
- <LibraryClasses>
- SerialPortLib|Platform/RaspberryPi/Library/DualSerialPortLib/DualSerialPortLib.inf
- }
- Platform/RaspberryPi/Drivers/DisplayDxe/DisplayDxe.inf
- EmbeddedPkg/Drivers/ConsolePrefDxe/ConsolePrefDxe.inf
-
- MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf
-
- ArmPkg/Drivers/ArmGic/ArmGicDxe.inf
- Platform/RaspberryPi/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.inf
- Platform/RaspberryPi/Drivers/FdtDxe/FdtDxe.inf
- Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf
- ArmPkg/Drivers/TimerDxe/TimerDxe.inf
- MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf
- MdeModulePkg/Universal/EbcDxe/EbcDxe.inf
-
- #
- # FAT filesystem + GPT/MBR partitioning
- #
- MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf
- MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf
- MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf
- FatPkg/EnhancedFatDxe/Fat.inf
-
- #
- # ACPI Support
- #
- MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf
- MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGraphicsResourceTableDxe.inf
- Platform/RaspberryPi/AcpiTables/AcpiTables.inf
-
- #
- # SMBIOS Support
- #
- Platform/RaspberryPi/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.inf
- MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf
-
- #
- # RAM Disk Support
- #
- MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskDxe.inf
-
- #
- # Bds
- #
- MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf
- MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf
- MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf
- MdeModulePkg/Universal/DriverHealthManagerDxe/DriverHealthManagerDxe.inf
- MdeModulePkg/Universal/BdsDxe/BdsDxe.inf
- Platform/RaspberryPi/Drivers/LogoDxe/LogoDxe.inf
- MdeModulePkg/Application/UiApp/UiApp.inf {
- <LibraryClasses>
- NULL|MdeModulePkg/Library/DeviceManagerUiLib/DeviceManagerUiLib.inf
- NULL|MdeModulePkg/Library/BootManagerUiLib/BootManagerUiLib.inf
- NULL|Platform/RaspberryPi/Library/PlatformUiAppLib/PlatformUiAppLib.inf
- NULL|MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenanceManagerUiLib.inf
- }
-
- #
- # SCSI Bus and Disk Driver
- #
- MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf
- MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf
-
- #
- # USB Support
- #
- MdeModulePkg/Bus/Pci/XhciDxe/XhciDxe.inf
- Platform/RaspberryPi/Drivers/DwUsbHostDxe/DwUsbHostDxe.inf
- MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBusDxe.inf
- MdeModulePkg/Bus/Usb/UsbKbDxe/UsbKbDxe.inf
- MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassStorageDxe.inf
-
- #
- # SD/MMC support
- #
- # Platform/RaspberryPi/Drivers/SdHostDxe/SdHostDxe.inf
- Platform/RaspberryPi/Drivers/ArasanMmcHostDxe/ArasanMmcHostDxe.inf
- Platform/RaspberryPi/Drivers/MmcDxe/MmcDxe.inf
-
- #
- # Networking stack
- #
-!include NetworkPkg/Network.dsc.inc
- Silicon/Broadcom/Drivers/Net/BcmGenetDxe/BcmGenetDxe.inf {
- <PcdsFixedAtBuild>
- gEmbeddedTokenSpaceGuid.PcdDmaDeviceOffset|0x00000000
- gEmbeddedTokenSpaceGuid.PcdDmaDeviceLimit|0xffffffff
- }
-
- #
- # RNG
- #
- Silicon/Broadcom/Bcm283x/Drivers/Bcm2838RngDxe/Bcm2838RngDxe.inf
-
- #
- # PCI Support
- #
- ArmPkg/Drivers/ArmPciCpuIo2Dxe/ArmPciCpuIo2Dxe.inf
- MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf
- MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf
- EmbeddedPkg/Drivers/NonCoherentIoMmuDxe/NonCoherentIoMmuDxe.inf {
- <PcdsFixedAtBuild>
- gEmbeddedTokenSpaceGuid.PcdDmaDeviceOffset|0x00000000
- gEmbeddedTokenSpaceGuid.PcdDmaDeviceLimit|0xbfffffff
- }
-
- #
- # UEFI application (Shell Embedded Boot Loader)
- #
- ShellPkg/Application/Shell/Shell.inf {
- <LibraryClasses>
- ShellCommandLib|ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.inf
- NULL|ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.inf
- NULL|ShellPkg/Library/UefiShellLevel1CommandsLib/UefiShellLevel1CommandsLib.inf
- NULL|ShellPkg/Library/UefiShellLevel3CommandsLib/UefiShellLevel3CommandsLib.inf
- NULL|ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1CommandsLib.inf
- NULL|ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.inf
- NULL|ShellPkg/Library/UefiShellInstall1CommandsLib/UefiShellInstall1CommandsLib.inf
- NULL|ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1CommandsLib.inf
- NULL|ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.inf
- HandleParsingLib|ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingLib.inf
- PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf
- BcfgCommandLib|ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.inf
-
- <PcdsFixedAtBuild>
- gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0xFF
- gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE
- gEfiMdePkgTokenSpaceGuid.PcdUefiLibMaxPrintBufferSize|8000
- gEfiShellPkgTokenSpaceGuid.PcdShellFileOperationSize|0x200000
- }
-!if $(INCLUDE_TFTP_COMMAND) == TRUE
- ShellPkg/DynamicCommand/TftpDynamicCommand/TftpDynamicCommand.inf {
- <PcdsFixedAtBuild>
- gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE
- }
-!endif
diff --git a/Platform/RaspberryPi/RPi4/RPi4.dsc.rej b/Platform/RaspberryPi/RPi4/RPi4.dsc.rej
deleted file mode 100644
index 0b40df6896..0000000000
--- a/Platform/RaspberryPi/RPi4/RPi4.dsc.rej
+++ /dev/null
@@ -1,29 +0,0 @@
---- Platform/RaspberryPi/RPi4/RPi4.dsc
-+++ Platform/RaspberryPi/RPi4/RPi4.dsc
-@@ -429,7 +429,6 @@ [PcdsFixedAtBuild.common]
- gArmPlatformTokenSpaceGuid.PL011UartClkInHz|48000000
- gEfiMdeModulePkgTokenSpaceGuid.PcdSerialUseMmio|TRUE
- gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterStride|4
-- gEfiMdeModulePkgTokenSpaceGuid.PcdSerialClockRate|1000000000
- gEfiMdeModulePkgTokenSpaceGuid.PcdSerialFifoControl|0x27
- gEfiMdeModulePkgTokenSpaceGuid.PcdSerialExtendedTxFifoSize|8
- gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate|115200
-@@ -465,6 +464,9 @@ [PcdsFixedAtBuild.common]
- gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVendor|L"EDK2"
- gEfiMdeModulePkgTokenSpaceGuid.PcdSetNxForStack|TRUE
-
-+[PcdsPatchableInModule]
-+ gEfiMdeModulePkgTokenSpaceGuid.PcdSerialClockRate|500000000
-+
- [PcdsDynamicHii.common.DEFAULT]
-
- #
-@@ -621,7 +623,7 @@ [Components.common]
- MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf
- MdeModulePkg/Universal/SerialDxe/SerialDxe.inf {
- <LibraryClasses>
-- SerialPortLib|Platform/RaspberryPi/Library/DualSerialPortLib/DualSerialPortLib.inf
-+ SerialPortLib|Platform/RaspberryPi/Library/DualSerialPortLib/DualSerialPortDxeLib.inf
- }
- Platform/RaspberryPi/Drivers/DisplayDxe/DisplayDxe.inf
- EmbeddedPkg/Drivers/ConsolePrefDxe/ConsolePrefDxe.inf
--
2.25.1


Re: SecCore evacuation in PeiCore?

Marvin Häuser <mhaeuser@...>
 

On 16/08/2021 18:18, Michael Kubacki wrote:
Hi Marvin,

Your understanding of SecMigrationPei is correct. It is not ideal as it's an unfamiliar pattern that could give the false impression that it is a universal SEC migration solution, which it is not. But if platforms understand that any additional data published in SecCore must be explicitly migrated (potentially via library extension to SecMigrationPei), it can be used to serve the SEC post-memory migration role.

I assumed it was related to the reset vector due to the 16-bit alignment. I think it would be great to have SecCore aligned properly if possible.
I could probably write a patch, but OVMF does not use this SecCore (and still something is misaligned :) ), and I don't have any other platform. Maybe I can ask Bret to test it as part of some PE loader validation in the future. :)

Would the old solution, which is being removed, be universal? Would it be beneficial? I know that the ARM world does not use this SecCore either, but I generally don't have a good idea about how their stuff works.

Thanks!

Best regards,
Marvin


Thanks,
Michael

On 8/14/2021 8:29 AM, Marvin Häuser wrote:
Hey Michael,

Thank you for your response! It was actually quicker than I imagined. :)

I think I understand, but please let me try to get this absolutely right. Can I think of "SecMigrationPei" as a sort of "SecCorePostMem", which either is loaded into permanent RAM directly or is shadowed because it is a PEIM unlike SecCore - and it republishes all public data, most especially PPIs, such that the entire PEI stage no longer has any references to the original SecCore at all, and the SecCore module basically just sits there in the ROM, and its exposed data is either discarded or orphaned? Is that about right?

I think I hit the alignment issue of SecCore too, but only for X64 builds (likely just because the size happens to be lucky for IA32) of OVMF. Pretty much sure it's just ResetVector positioning. What would be the issue with moving the ResetVector into a separate component, with its fixed position in FD (this is actually how UefiCpuPkg/VTF0 works), and having SecCore aligned correctly? Not specifically to restore MigrateSecModulesInFv(), but as future-proofing to ensure expected outputs. In fact, I noticed because my new PE loader code was upset about the unaligned XIP load address.

Also thanks for your patch!

Best regards,
Marvin

On 13/08/2021 18:51, Michael Kubacki wrote:
Hi Marvin,

I apologize for the delayed response, I missed this message earlier. The function was called from EvacuateTempRam() in the initial set of patches:
[PATCH 1/6] MdeModulePkg/PeiCore: Enable T-RAM evacuation in PeiCore (CVE-2019-11098) (groups.io) <https://edk2.groups.io/g/devel/message/61823>

I was not involved in the patch series on the mailing list (job role change at the time) but as a comment in that patch notes, there was an inconsistency observed in PE32 section alignment in SEC modules. I don't see where this was resolved other than the calls being removed later in the series. SecCore migration would not occur implicitly in the PeiCore flow but there is functionality for SEC data migration in UefiCpuPkg/SecMigrationPei.

Based on what I see now, I'd be happy to send a patch to remove MigrateSecModulesInFv().

Thanks,
Michael

On 8/7/2021 2:54 PM, Marvin Häuser wrote:
Good day everyone,
Good day Michael,

The commit that introduced T-RAM evacuation [1] also introduced the function "MigrateSecModulesInFv()". It also is explicitly mentioned as part of the control flow in the commit message. As far as I can see, since then till today this function has never been called anywhere. Was this some draft function that accidentally made it into the patch, or did the caller get lost somewhere? The description makes sense to me and I'm not experienced enough with the PeiCore control flow to tell whether the PEIM migration somehow covers SecCore implicitly. Also I noticed it only supports SecCore in a PE/COFF section, not a TE section. Is there a rationale for that?

Thank you for your time!

Best regards,
Marvin


[1] https://github.com/tianocore/edk2/commit/9bedaec05b7b8ba9aee248361bb61a85a26726cb



Re: [edk2-platforms PATCH] Platform/RaspberryPi: Remove unnecessary files

Grzegorz Bernacki <gjb@...>
 

Hi,

Please do not merge this patch. Unfortunately, I added a few more
unnecessary files under Commit 2f0188b56ef4. I will send the new
version of the patch soon.
thanks,
greg

pt., 13 sie 2021 o 16:52 Samer El-Haj-Mahmoud
<Samer.El-Haj-Mahmoud@...> napisał(a):


Thanks!

Reviewed-by: Samer El-Haj-Mahmoud <Samer.El-Haj-Mahmoud@...>


-----Original Message-----
From: Marcin Wojtas <mw@...>
Sent: Friday, August 13, 2021 10:42 AM
To: devel@edk2.groups.io
Cc: leif@...; ardb+tianocore@...; Samer El-Haj-Mahmoud
<Samer.El-Haj-Mahmoud@...>; Sunny Wang
<Sunny.Wang@...>; gjb@...; upstream@...;
pete@...; Marcin Wojtas <mw@...>
Subject: [edk2-platforms PATCH] Platform/RaspberryPi: Remove
unnecessary files

Commit 2f0188b56ef4 ("Revert "Platform/RaspberryPi: Setup option for...")
mistakenly introduced to files which are residues from a
conflict resolution. Fix that.

Signed-off-by: Marcin Wojtas <mw@...>
---
Platform/RaspberryPi/RPi4/RPi4.dsc.orig | 760 --------------------
Platform/RaspberryPi/RPi4/RPi4.dsc.rej | 29 -
2 files changed, 789 deletions(-)
delete mode 100644 Platform/RaspberryPi/RPi4/RPi4.dsc.orig
delete mode 100644 Platform/RaspberryPi/RPi4/RPi4.dsc.rej

diff --git a/Platform/RaspberryPi/RPi4/RPi4.dsc.orig
b/Platform/RaspberryPi/RPi4/RPi4.dsc.orig
deleted file mode 100644
index 2c05c31118..0000000000
--- a/Platform/RaspberryPi/RPi4/RPi4.dsc.orig
+++ /dev/null
@@ -1,760 +0,0 @@
-# @file

-#

-# Copyright (c) 2011 - 2020, ARM Limited. All rights reserved.

-# Copyright (c) 2017 - 2018, Andrei Warkentin
<andrey.warkentin@...>

-# Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.

-# Copyright (c) 2014, Linaro Limited. All rights reserved.

-#

-# SPDX-License-Identifier: BSD-2-Clause-Patent

-#

-##

-

-
##########################################################
######################

-#

-# Defines Section - statements that will be processed to create a Makefile.

-#

-
##########################################################
######################

-[Defines]

- PLATFORM_NAME = RPi4

- PLATFORM_GUID = a7eca3b4-21b0-4989-8c18-c08f3ae87837

- PLATFORM_VERSION = 1.0

- DSC_SPECIFICATION = 0x0001001A

- OUTPUT_DIRECTORY = Build/$(PLATFORM_NAME)

- SUPPORTED_ARCHITECTURES = AARCH64

- BUILD_TARGETS = DEBUG|RELEASE|NOOPT

- SKUID_IDENTIFIER = DEFAULT

- FLASH_DEFINITION =
Platform/RaspberryPi/$(PLATFORM_NAME)/$(PLATFORM_NAME).fdf

-

- #

- # Defines for default states. These can be changed on the command line.

- # -D FLAG=VALUE

- #

- DEFINE SECURE_BOOT_ENABLE = FALSE

- DEFINE INCLUDE_TFTP_COMMAND = FALSE

- DEFINE DEBUG_PRINT_ERROR_LEVEL = 0x8000004F

-

-!ifndef TFA_BUILD_ARTIFACTS

- #

- # Default TF-A binary checked into edk2-non-osi.

- #

- DEFINE TFA_BUILD_BL31 =
Platform/RaspberryPi/$(PLATFORM_NAME)/TrustedFirmware/bl31.bin

-!else

- #

- # Usually we use the checked-in binaries, but for developers working

- # on the firmware, being able to use a local TF-A build without extra copy

- # operations ends up being very helpful.

- #

- DEFINE TFA_BUILD_BL31 = $(TFA_BUILD_ARTIFACTS)/bl31.bin

-!endif

-

-
##########################################################
######################

-#

-# Library Class section - list of all Library Classes needed by this Platform.

-#

-
##########################################################
######################

-

-!include MdePkg/MdeLibs.dsc.inc

-

-[LibraryClasses.common]

-!if $(TARGET) == RELEASE

- DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf

-!else

-
DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.
inf

-!endif

-
DebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintErrorLevelLib/Bas
eDebugPrintErrorLevelLib.inf

-

- BaseLib|MdePkg/Library/BaseLib/BaseLib.inf

- SafeIntLib|MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf

-
BmpSupportLib|MdeModulePkg/Library/BaseBmpSupportLib/BaseBmpSupp
ortLib.inf

-
SynchronizationLib|MdePkg/Library/BaseSynchronizationLib/BaseSynchroniz
ationLib.inf

-
PerformanceLib|MdePkg/Library/BasePerformanceLibNull/BasePerformanc
eLibNull.inf

-
ReportStatusCodeLib|MdePkg/Library/BaseReportStatusCodeLibNull/BaseR
eportStatusCodeLibNull.inf

- PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf

-
PeCoffGetEntryPointLib|MdePkg/Library/BasePeCoffGetEntryPointLib/Base
PeCoffGetEntryPointLib.inf

- PeCoffLib|MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf

- IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf

-
UefiDecompressLib|MdePkg/Library/BaseUefiDecompressLib/BaseUefiDeco
mpressLib.inf

- CpuLib|MdePkg/Library/BaseCpuLib/BaseCpuLib.inf

-

- UefiLib|MdePkg/Library/UefiLib/UefiLib.inf

- HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf

-
UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeServicesTableLib
/UefiRuntimeServicesTableLib.inf

- DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf

-
UefiBootServicesTableLib|MdePkg/Library/UefiBootServicesTableLib/UefiBo
otServicesTableLib.inf

-
DxeServicesTableLib|MdePkg/Library/DxeServicesTableLib/DxeServicesTabl
eLib.inf

- DxeServicesLib|MdePkg/Library/DxeServicesLib/DxeServicesLib.inf

-
UefiDriverEntryPoint|MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntry
Point.inf

-
UefiApplicationEntryPoint|MdePkg/Library/UefiApplicationEntryPoint/UefiA
pplicationEntryPoint.inf

- HiiLib|MdeModulePkg/Library/UefiHiiLib/UefiHiiLib.inf

-
UefiHiiServicesLib|MdeModulePkg/Library/UefiHiiServicesLib/UefiHiiService
sLib.inf

- SortLib|MdeModulePkg/Library/UefiSortLib/UefiSortLib.inf

-

- UefiRuntimeLib|MdePkg/Library/UefiRuntimeLib/UefiRuntimeLib.inf

-
OrderedCollectionLib|MdePkg/Library/BaseOrderedCollectionRedBlackTreeL
ib/BaseOrderedCollectionRedBlackTreeLib.inf

-

- #

- # Ramdisk Requirements

- #

- FileExplorerLib|MdeModulePkg/Library/FileExplorerLib/FileExplorerLib.inf

-

- # Allow dynamic PCDs

- #

- PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf

-

- # use the accelerated BaseMemoryLibOptDxe by default, overrides for
SEC/PEI below

-
BaseMemoryLib|MdePkg/Library/BaseMemoryLibOptDxe/BaseMemoryLib
OptDxe.inf

-

- #

- # It is not possible to prevent the ARM compiler from inserting calls to
intrinsic functions.

- # This library provides the instrinsic functions such a compiler may generate
calls to.

- #

- NULL|ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf

-

- # Add support for GCC stack protector

- NULL|MdePkg/Library/BaseStackCheckLib/BaseStackCheckLib.inf

-

- # ARM Architectural Libraries

-
CacheMaintenanceLib|ArmPkg/Library/ArmCacheMaintenanceLib/ArmCach
eMaintenanceLib.inf

-
DefaultExceptionHandlerLib|ArmPkg/Library/DefaultExceptionHandlerLib/D
efaultExceptionHandlerLib.inf

-
CpuExceptionHandlerLib|ArmPkg/Library/ArmExceptionLib/ArmExceptionLib
.inf

-
ArmDisassemblerLib|ArmPkg/Library/ArmDisassemblerLib/ArmDisassembler
Lib.inf

- ArmGicLib|ArmPkg/Drivers/ArmGic/ArmGicLib.inf

- ArmGicArchLib|ArmPkg/Library/ArmGicArchLib/ArmGicArchLib.inf

-
DmaLib|EmbeddedPkg/Library/NonCoherentDmaLib/NonCoherentDmaLib.i
nf

- TimeBaseLib|EmbeddedPkg/Library/TimeBaseLib/TimeBaseLib.inf

-
ArmPlatformStackLib|ArmPlatformPkg/Library/ArmPlatformStackLib/ArmPla
tformStackLib.inf

- ArmSmcLib|ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf

- ArmHvcLib|ArmPkg/Library/ArmHvcLib/ArmHvcLib.inf

-
ArmGenericTimerCounterLib|ArmPkg/Library/ArmGenericTimerPhyCounter
Lib/ArmGenericTimerPhyCounterLib.inf

-

- # Dual serial port library

-
PL011UartClockLib|ArmPlatformPkg/Library/PL011UartClockLib/PL011UartClo
ckLib.inf

- PL011UartLib|ArmPlatformPkg/Library/PL011UartLib/PL011UartLib.inf

-
SerialPortLib|Platform/RaspberryPi/Library/DualSerialPortLib/DebugDualSeri
alPortLib.inf

-

- # Cryptographic libraries

- RngLib|MdePkg/Library/DxeRngLib/DxeRngLib.inf

- IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf

- BaseCryptLib|CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf

- OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLib.inf

- TlsLib|CryptoPkg/Library/TlsLib/TlsLib.inf

-

- #

- # Uncomment (and comment out the next line) For RealView Debugger.
The Standard IO window

- # in the debugger will show load and unload commands for symbols. You
can cut and paste this

- # into the command window to load symbols. We should be able to use a
script to do this, but

- # the version of RVD I have does not support scripts accessing system
memory.

- #

-
#PeCoffExtraActionLib|ArmPkg/Library/RvdPeCoffExtraActionLib/RvdPeCoff
ExtraActionLib.inf

-
PeCoffExtraActionLib|ArmPkg/Library/DebugPeCoffExtraActionLib/DebugPe
CoffExtraActionLib.inf

-
#PeCoffExtraActionLib|MdePkg/Library/BasePeCoffExtraActionLibNull/Base
PeCoffExtraActionLibNull.inf

-

-
DebugAgentLib|MdeModulePkg/Library/DebugAgentLibNull/DebugAgentLi
bNull.inf

-
DebugAgentTimerLib|EmbeddedPkg/Library/DebugAgentTimerLibNull/Debu
gAgentTimerLibNull.inf

-

- # Flattened Device Tree (FDT) access library

- FdtLib|EmbeddedPkg/Library/FdtLib/FdtLib.inf

-

- # USB Libraries

- UefiUsbLib|MdePkg/Library/UefiUsbLib/UefiUsbLib.inf

-

- #

- # Secure Boot dependencies

- #

-!if $(SECURE_BOOT_ENABLE) == TRUE

-
TpmMeasurementLib|SecurityPkg/Library/DxeTpmMeasurementLib/DxeTp
mMeasurementLib.inf

- AuthVariableLib|SecurityPkg/Library/AuthVariableLib/AuthVariableLib.inf

-

- # re-use the UserPhysicalPresent() dummy implementation from the ovmf
tree

-
PlatformSecureLib|OvmfPkg/Library/PlatformSecureLib/PlatformSecureLib.i
nf

-!else

-
TpmMeasurementLib|MdeModulePkg/Library/TpmMeasurementLibNull/Tp
mMeasurementLibNull.inf

-
AuthVariableLib|MdeModulePkg/Library/AuthVariableLibNull/AuthVariableL
ibNull.inf

-!endif

- VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf

-
VariablePolicyLib|MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLi
b.inf

-
VariablePolicyHelperLib|MdeModulePkg/Library/VariablePolicyHelperLib/Va
riablePolicyHelperLib.inf

- GpioLib|Silicon/Broadcom/Bcm283x/Library/GpioLib/GpioLib.inf

-

- #

- # PCI dependencies

- #

- # PCI root port configuation and description

-
PciHostBridgeLib|Silicon/Broadcom/Bcm27xx/Library/Bcm2711PciHostBridge
Lib/Bcm2711PciHostBridgeLib.inf

- # The "segment lib" provides the CAM accessors/etc when they aren't
ECAM standard

-
PciSegmentLib|Silicon/Broadcom/Bcm27xx/Library/Bcm2711PciSegmentLib/
PciSegmentLib.inf

-

-[LibraryClasses.common.SEC]

- PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf

- BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf

-
MemoryInitPeiLib|Platform/RaspberryPi/Library/MemoryInitPeiLib/Memory
InitPeiLib.inf

- PlatformPeiLib|ArmPlatformPkg/PlatformPei/PlatformPeiLib.inf

-
ExtractGuidedSectionLib|EmbeddedPkg/Library/PrePiExtractGuidedSectionL
ib/PrePiExtractGuidedSectionLib.inf

-
LzmaDecompressLib|MdeModulePkg/Library/LzmaCustomDecompressLib/L
zmaCustomDecompressLib.inf

- PrePiLib|EmbeddedPkg/Library/PrePiLib/PrePiLib.inf

- HobLib|EmbeddedPkg/Library/PrePiHobLib/PrePiHobLib.inf

-
PrePiHobListPointerLib|ArmPlatformPkg/Library/PrePiHobListPointerLib/Pre
PiHobListPointerLib.inf

-
MemoryAllocationLib|EmbeddedPkg/Library/PrePiMemoryAllocationLib/Pre
PiMemoryAllocationLib.inf

-

-[LibraryClasses.common.DXE_CORE]

- HobLib|MdePkg/Library/DxeCoreHobLib/DxeCoreHobLib.inf

-
MemoryAllocationLib|MdeModulePkg/Library/DxeCoreMemoryAllocationLi
b/DxeCoreMemoryAllocationLib.inf

-
DxeCoreEntryPoint|MdePkg/Library/DxeCoreEntryPoint/DxeCoreEntryPoint
.inf

-
ExtractGuidedSectionLib|MdePkg/Library/DxeExtractGuidedSectionLib/DxeE
xtractGuidedSectionLib.inf

-
PerformanceLib|MdeModulePkg/Library/DxeCorePerformanceLib/DxeCore
PerformanceLib.inf

-

-[LibraryClasses.common.DXE_DRIVER]

-
SecurityManagementLib|MdeModulePkg/Library/DxeSecurityManagementL
ib/DxeSecurityManagementLib.inf

-
PerformanceLib|MdeModulePkg/Library/DxePerformanceLib/DxePerforma
nceLib.inf

-
MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemo
ryAllocationLib.inf

-!if $(INCLUDE_TFTP_COMMAND) == TRUE

- ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf

- FileHandleLib|MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf

-!endif

-

-[LibraryClasses.common.UEFI_APPLICATION]

-
PerformanceLib|MdeModulePkg/Library/DxePerformanceLib/DxePerforma
nceLib.inf

-
MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemo
ryAllocationLib.inf

- HiiLib|MdeModulePkg/Library/UefiHiiLib/UefiHiiLib.inf

- ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf

- FileHandleLib|MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf

-

-[LibraryClasses.common.UEFI_DRIVER]

-
ExtractGuidedSectionLib|MdePkg/Library/DxeExtractGuidedSectionLib/DxeE
xtractGuidedSectionLib.inf

-
PerformanceLib|MdeModulePkg/Library/DxePerformanceLib/DxePerforma
nceLib.inf

-
MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemo
ryAllocationLib.inf

-

-[LibraryClasses.common.DXE_RUNTIME_DRIVER]

- # Runtime debug messages may crash an OS unless serial output to MMIO
mapped UARTs is inhibited

-
DebugLib|MdePkg/Library/DxeRuntimeDebugLibSerialPort/DxeRuntimeDeb
ugLibSerialPort.inf

-
MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemo
ryAllocationLib.inf

-
CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.i
nf

- EfiResetSystemLib|Platform/RaspberryPi/Library/ResetLib/ResetLib.inf

- ArmSmcLib|ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf

-
VariablePolicyLib|MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLi
bRuntimeDxe.inf

-

-!if $(SECURE_BOOT_ENABLE) == TRUE

- BaseCryptLib|CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf

-!endif

-

-
##########################################################
#########################################

-# BuildOptions Section - Define the module specific tool chain flags that
should be used as

-# the default flags for a module. These flags are appended to any

-# standard flags that are defined by the build process.

-
##########################################################
#########################################

-

-[BuildOptions]

- GCC:*_*_*_CC_FLAGS = -DRPI_MODEL=4

- GCC:*_*_*_PP_FLAGS = -DRPI_MODEL=4

- GCC:*_*_*_ASLPP_FLAGS = -DRPI_MODEL=4

- GCC:*_*_*_ASLCC_FLAGS = -DRPI_MODEL=4

- GCC:*_*_*_VFRPP_FLAGS = -DRPI_MODEL=4

- GCC:RELEASE_*_*_CC_FLAGS = -DMDEPKG_NDEBUG -DNDEBUG

-

-[BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER]

- GCC:*_*_AARCH64_DLINK_FLAGS = -z common-page-size=0x10000

-

-
##########################################################
######################

-#

-# Pcd Section - list of all EDK II PCD Entries defined by this Platform

-#

-
##########################################################
######################

-

-[PcdsFeatureFlag.common]

- # Use the Vector Table location in CpuDxe. We will not copy the Vector
Table at PcdCpuVectorBaseAddress

- gArmTokenSpaceGuid.PcdRelocateVectorTable|FALSE

-

-
gEmbeddedTokenSpaceGuid.PcdPrePiProduceMemoryTypeInformationHob
|TRUE

- gEfiMdeModulePkgTokenSpaceGuid.PcdTurnOffUsbLegacySupport|TRUE

-

- ## If TRUE, Graphics Output Protocol will be installed on virtual handle
created by ConsplitterDxe.

- # It could be set FALSE to save size.

- gEfiMdeModulePkgTokenSpaceGuid.PcdConOutGopSupport|TRUE

- gEfiMdeModulePkgTokenSpaceGuid.PcdConOutUgaSupport|FALSE

- gEfiMdePkgTokenSpaceGuid.PcdUgaConsumeSupport|FALSE

-

-[PcdsFixedAtBuild.common]

- gEfiMdePkgTokenSpaceGuid.PcdMaximumUnicodeStringLength|1000000

- gEfiMdePkgTokenSpaceGuid.PcdMaximumAsciiStringLength|1000000

- gEfiMdePkgTokenSpaceGuid.PcdMaximumLinkedListLength|1000000

- gEfiMdePkgTokenSpaceGuid.PcdSpinLockTimeout|10000000

- gEfiMdePkgTokenSpaceGuid.PcdDebugClearMemoryValue|0xAF

- gEfiMdePkgTokenSpaceGuid.PcdPerformanceLibraryPropertyMask|1

- gEfiMdePkgTokenSpaceGuid.PcdPostCodePropertyMask|0

- gEfiMdePkgTokenSpaceGuid.PcdUefiLibMaxPrintBufferSize|320

-

- # DEBUG_ASSERT_ENABLED 0x01

- # DEBUG_PRINT_ENABLED 0x02

- # DEBUG_CODE_ENABLED 0x04

- # CLEAR_MEMORY_ENABLED 0x08

- # ASSERT_BREAKPOINT_ENABLED 0x10

- # ASSERT_DEADLOOP_ENABLED 0x20

-!if $(TARGET) == RELEASE

- gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x21

-!else

- gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x2f

-!endif

-

- # DEBUG_INIT 0x00000001 // Initialization

- # DEBUG_WARN 0x00000002 // Warnings

- # DEBUG_LOAD 0x00000004 // Load events

- # DEBUG_FS 0x00000008 // EFI File system

- # DEBUG_POOL 0x00000010 // Alloc & Free (pool)

- # DEBUG_PAGE 0x00000020 // Alloc & Free (page)

- # DEBUG_INFO 0x00000040 // Informational debug messages

- # DEBUG_DISPATCH 0x00000080 // PEI/DXE/SMM Dispatchers

- # DEBUG_VARIABLE 0x00000100 // Variable

- # DEBUG_BM 0x00000400 // Boot Manager

- # DEBUG_BLKIO 0x00001000 // BlkIo Driver

- # DEBUG_NET 0x00004000 // SNP Driver

- # DEBUG_UNDI 0x00010000 // UNDI Driver

- # DEBUG_LOADFILE 0x00020000 // LoadFile

- # DEBUG_EVENT 0x00080000 // Event messages

- # DEBUG_GCD 0x00100000 // Global Coherency Database changes

- # DEBUG_CACHE 0x00200000 // Memory range cachability changes

- # DEBUG_VERBOSE 0x00400000 // Detailed debug messages that may

- # // significantly impact boot performance

- # DEBUG_ERROR 0x80000000 // Error

-
gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|$(DEBUG_PRINT_ER
ROR_LEVEL)

-

- gEfiMdePkgTokenSpaceGuid.PcdReportStatusCodePropertyMask|0x07

-

- #

- # Optional feature to help prevent EFI memory map fragments

- # Turned on and off via: PcdPrePiProduceMemoryTypeInformationHob

- # Values are in EFI Pages (4K). DXE Core will make sure that

- # at least this much of each type of memory can be allocated

- # from a single memory range. This way you only end up with

- # maximum of two fragments for each type in the memory map

- # (the memory used, and the free memory that was prereserved

- # but not used).

- #

- gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiACPIReclaimMemory|0

- gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiACPIMemoryNVS|0

- gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiReservedMemoryType|0

-!if $(SECURE_BOOT_ENABLE) == TRUE

- gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiRuntimeServicesData|600

-
gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiRuntimeServicesCode|400

- gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiBootServicesCode|1500

-!else

- gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiRuntimeServicesData|300

-
gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiRuntimeServicesCode|150

- gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiBootServicesCode|1000

-!endif

- gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiBootServicesData|12000

- gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiLoaderCode|20

- gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiLoaderData|0

-

- gEmbeddedTokenSpaceGuid.PcdDmaDeviceOffset|0xc0000000

- gEmbeddedTokenSpaceGuid.PcdDmaDeviceLimit|0xffffffff

-

- gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVersionString|L"EDK2-
DEV"

-

-!if $(SECURE_BOOT_ENABLE) == TRUE

- # override the default values from SecurityPkg to ensure images from all
sources are verified in secure boot

-
gEfiSecurityPkgTokenSpaceGuid.PcdOptionRomImageVerificationPolicy|0x04

-
gEfiSecurityPkgTokenSpaceGuid.PcdFixedMediaImageVerificationPolicy|0x0
4

-
gEfiSecurityPkgTokenSpaceGuid.PcdRemovableMediaImageVerificationPolic
y|0x04

-!endif

-

- gEfiNetworkPkgTokenSpaceGuid.PcdAllowHttpConnections|TRUE

-

- # Default platform supported RFC 4646 languages: (American) English

-
gEfiMdePkgTokenSpaceGuid.PcdUefiVariableDefaultPlatformLangCodes|"e
n-US"

-

-[LibraryClasses.common]

- ArmLib|ArmPkg/Library/ArmLib/ArmBaseLib.inf

- ArmMmuLib|ArmPkg/Library/ArmMmuLib/ArmMmuBaseLib.inf

- ArmPlatformLib|Platform/RaspberryPi/Library/PlatformLib/PlatformLib.inf

- TimerLib|ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.inf

-
CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.i
nf

-
UefiBootManagerLib|MdeModulePkg/Library/UefiBootManagerLib/UefiBoo
tManagerLib.inf

- BootLogoLib|MdeModulePkg/Library/BootLogoLib/BootLogoLib.inf

-
PlatformBootManagerLib|Platform/RaspberryPi/Library/PlatformBootManag
erLib/PlatformBootManagerLib.inf

-
CustomizedDisplayLib|MdeModulePkg/Library/CustomizedDisplayLib/Custo
mizedDisplayLib.inf

- FileExplorerLib|MdeModulePkg/Library/FileExplorerLib/FileExplorerLib.inf

- AcpiLib|EmbeddedPkg/Library/AcpiLib/AcpiLib.inf

-

-[LibraryClasses.common.UEFI_DRIVER]

- UefiScsiLib|MdePkg/Library/UefiScsiLib/UefiScsiLib.inf

-

-
##########################################################
######################

-#

-# Pcd Section - list of all EDK II PCD Entries defined by this Platform

-#

-
##########################################################
######################

-

-[PcdsFeatureFlag.common]

- gEfiMdeModulePkgTokenSpaceGuid.PcdConOutGopSupport|TRUE

- gEfiMdeModulePkgTokenSpaceGuid.PcdConOutUgaSupport|FALSE

- gEfiMdeModulePkgTokenSpaceGuid.PcdInstallAcpiSdtProtocol|TRUE

-

-[PcdsFixedAtBuild.common]

- gArmPlatformTokenSpaceGuid.PcdCoreCount|4

- gArmTokenSpaceGuid.PcdVFPEnabled|1

-

- gArmPlatformTokenSpaceGuid.PcdCPUCorePrimaryStackSize|0x4000

- gEfiMdeModulePkgTokenSpaceGuid.PcdMaxVariableSize|0x2000

- gEfiMdeModulePkgTokenSpaceGuid.PcdMaxAuthVariableSize|0x2800

-

- # Size of the region used by UEFI in permanent memory (Reserved 64MB)

-
gArmPlatformTokenSpaceGuid.PcdSystemMemoryUefiRegionSize|0x040000
00

- #

- # 0x00000000 - 0x001F0000 FD (PcdFdBaseAddress, PcdFdSize)

- # 0x001F0000 - 0x00200000 DTB (PcdFdtBaseAddress, PcdFdtSize)

- # 0x00200000 - ... RAM (PcdSystemMemoryBase,
PcdSystemMemorySize)

- #

- # This matches PcdFvBaseAddress, since everything less is the FD, and

- # will be reserved away.

- #

- gArmTokenSpaceGuid.PcdSystemMemoryBase|0x00200000

- gArmTokenSpaceGuid.PcdSystemMemorySize|0x3fe00000

-

- #

- # Device specific addresses

- #

- gBcm27xxTokenSpaceGuid.PcdBcm27xxRegistersAddress|0xfc000000

- gBcm27xxTokenSpaceGuid.PcdBcmGenetRegistersAddress|0xfd580000

- gBcm283xTokenSpaceGuid.PcdBcm283xRegistersAddress|0xfe000000

-

- # PCIe specific addresses

- gBcm27xxTokenSpaceGuid.PcdBcm27xxPciRegBase|0xfd500000

- gBcm27xxTokenSpaceGuid.PcdBcm27xxPciBusMmioAdr|0xf8000000

- gBcm27xxTokenSpaceGuid.PcdBcm27xxPciBusMmioLen|0x3ffffff

- gBcm27xxTokenSpaceGuid.PcdBcm27xxPciCpuMmioAdr|0x600000000

-

- # UARTs

- gArmPlatformTokenSpaceGuid.PL011UartInteger|0

- gArmPlatformTokenSpaceGuid.PL011UartFractional|0

- gArmPlatformTokenSpaceGuid.PL011UartClkInHz|48000000

- gEfiMdeModulePkgTokenSpaceGuid.PcdSerialUseMmio|TRUE

- gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterStride|4

- gEfiMdeModulePkgTokenSpaceGuid.PcdSerialClockRate|1000000000

- gEfiMdeModulePkgTokenSpaceGuid.PcdSerialFifoControl|0x27

- gEfiMdeModulePkgTokenSpaceGuid.PcdSerialExtendedTxFifoSize|8

- gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate|115200

- gEfiMdePkgTokenSpaceGuid.PcdUartDefaultReceiveFifoDepth|0

-

- #

- # ARM General Interrupt Controller

- #

- gArmTokenSpaceGuid.PcdGicDistributorBase|0xFF841000

- gArmTokenSpaceGuid.PcdGicInterruptInterfaceBase|0xFF842000

- gRaspberryPiTokenSpaceGuid.PcdGicInterruptInterfaceHBase|0xFF844000

- gRaspberryPiTokenSpaceGuid.PcdGicInterruptInterfaceVBase|0xFF846000

- gRaspberryPiTokenSpaceGuid.PcdGicGsivId|0x19

- gRaspberryPiTokenSpaceGuid.PcdGicPmuIrq0|0x30

- gRaspberryPiTokenSpaceGuid.PcdGicPmuIrq1|0x31

- gRaspberryPiTokenSpaceGuid.PcdGicPmuIrq2|0x32

- gRaspberryPiTokenSpaceGuid.PcdGicPmuIrq3|0x33

-

- #

- # Fixed CPU settings.

- #

- gRaspberryPiTokenSpaceGuid.PcdCpuLowSpeedMHz|800

- gRaspberryPiTokenSpaceGuid.PcdCpuDefSpeedMHz|1500

- gRaspberryPiTokenSpaceGuid.PcdCpuMaxSpeedMHz|2200

-

- ## Default Terminal Type

- ## 0-PCANSI, 1-VT100, 2-VT00+, 3-UTF8, 4-TTYTERM

- gEfiMdePkgTokenSpaceGuid.PcdDefaultTerminalType|4

-

-
gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationC
hange|FALSE

- gEfiMdeModulePkgTokenSpaceGuid.PcdBootManagerMenuFile|{ 0x21,
0xaa, 0x2c, 0x46, 0x14, 0x76, 0x03, 0x45, 0x83, 0x6e, 0x8a, 0xb6, 0xf4, 0x66,
0x23, 0x31 }

-

- gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVendor|L"EDK2"

- gEfiMdeModulePkgTokenSpaceGuid.PcdSetNxForStack|TRUE

-

-[PcdsDynamicHii.common.DEFAULT]

-

- #

- # Clock overrides.

- #

-

-
gRaspberryPiTokenSpaceGuid.PcdCpuClock|L"CpuClock"|gConfigDxeFormSe
tGuid|0x0|1

-
gRaspberryPiTokenSpaceGuid.PcdCustomCpuClock|L"CustomCpuClock"|gCo
nfigDxeFormSetGuid|0x0|gRaspberryPiTokenSpaceGuid.PcdCpuDefSpeedM
Hz

-

- #

- # SD-related.

- #

-

-
gRaspberryPiTokenSpaceGuid.PcdSdIsArasan|L"SdIsArasan"|gConfigDxeFor
mSetGuid|0x0|0

-
gRaspberryPiTokenSpaceGuid.PcdMmcForce1Bit|L"MmcForce1Bit"|gConfig
DxeFormSetGuid|0x0|0

-
gRaspberryPiTokenSpaceGuid.PcdMmcForceDefaultSpeed|L"MmcForceDef
aultSpeed"|gConfigDxeFormSetGuid|0x0|0

-
gRaspberryPiTokenSpaceGuid.PcdMmcSdDefaultSpeedMHz|L"MmcSdDefau
ltSpeedMHz"|gConfigDxeFormSetGuid|0x0|25

-
gRaspberryPiTokenSpaceGuid.PcdMmcSdHighSpeedMHz|L"MmcSdHighSpe
edMHz"|gConfigDxeFormSetGuid|0x0|50

-
gRaspberryPiTokenSpaceGuid.PcdMmcDisableMulti|L"MmcDisableMulti"|gC
onfigDxeFormSetGuid|0x0|0

-
gRaspberryPiTokenSpaceGuid.PcdMmcEnableDma|L"MmcEnableDma"|gCo
nfigDxeFormSetGuid|0x0|0

-

- #

- # Debug-related.

- #

-

-
gRaspberryPiTokenSpaceGuid.PcdDebugEnableJTAG|L"DebugEnableJTAG"|
gConfigDxeFormSetGuid|0x0|0

-

- #

- # Display-related.

- #

-

- #

- # Just enable native resolution by default.

- #

-
gRaspberryPiTokenSpaceGuid.PcdDisplayEnableScaledVModes|L"DisplayEna
bleScaledVModes"|gConfigDxeFormSetGuid|0x0|0x20

-
gRaspberryPiTokenSpaceGuid.PcdDisplayEnableSShot|L"DisplayEnableSShot
"|gConfigDxeFormSetGuid|0x0|1

-

- #

- # Supporting > 3GB of memory.

- #

-
gRaspberryPiTokenSpaceGuid.PcdRamMoreThan3GB|L"RamMoreThan3GB"
|gConfigDxeFormSetGuid|0x0|0

-
gRaspberryPiTokenSpaceGuid.PcdRamLimitTo3GB|L"RamLimitTo3GB"|gConf
igDxeFormSetGuid|0x0|1

-

- #

- # Device Tree and ACPI selection.

- #

- # 0 - SYSTEM_TABLE_MODE_ACPI (default)

- # 1 - SYSTEM_TABLE_MODE_BOTH

- # 2 - SYSTEM_TABLE_MODE_DT

- #

-
gRaspberryPiTokenSpaceGuid.PcdSystemTableMode|L"SystemTableMode"
|gConfigDxeFormSetGuid|0x0|0

-

- #

- # Enable a fan in the ACPI thermal zone on GPIO pin #

- #

- # 0 - DISABLED

- # 19 - Enabled on pin 19

- #

-
gRaspberryPiTokenSpaceGuid.PcdFanOnGpio|L"FanOnGpio"|gConfigDxeFor
mSetGuid|0x0|0

-
gRaspberryPiTokenSpaceGuid.PcdFanTemp|L"FanTemp"|gConfigDxeFormS
etGuid|0x0|60

-

- #

- # Reset-related.

- #

-

-
gRaspberryPiTokenSpaceGuid.PcdPlatformResetDelay|L"ResetDelay"|gRasp
berryPiTokenSpaceGuid|0x0|0

-

- #

- # Common UEFI ones.

- #

-

-
gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut|L"Timeout"|gEfiGlo
balVariableGuid|0x0|5

- #

- # This is silly, but by pointing SetupConXXX and ConXXX PCDs to

- # the same variables, I can use the graphical configuration to

- # change the mode used by ConSplitter.

- #

-
gEfiMdeModulePkgTokenSpaceGuid.PcdSetupConOutColumn|L"Columns"|
gRaspberryPiTokenSpaceGuid|0x0|80

-
gEfiMdeModulePkgTokenSpaceGuid.PcdConOutColumn|L"Columns"|gRasp
berryPiTokenSpaceGuid|0x0|80

-
gEfiMdeModulePkgTokenSpaceGuid.PcdSetupConOutRow|L"Rows"|gRaspb
erryPiTokenSpaceGuid|0x0|25

-
gEfiMdeModulePkgTokenSpaceGuid.PcdConOutRow|L"Rows"|gRaspberryPi
TokenSpaceGuid|0x0|25

-

-[PcdsDynamicDefault.common]

- #

- # Set video resolution for boot options and for text setup.

- #

- gEfiMdeModulePkgTokenSpaceGuid.PcdVideoHorizontalResolution|0

- gEfiMdeModulePkgTokenSpaceGuid.PcdVideoVerticalResolution|0

-
gEfiMdeModulePkgTokenSpaceGuid.PcdSetupVideoHorizontalResolution|64
0

-
gEfiMdeModulePkgTokenSpaceGuid.PcdSetupVideoVerticalResolution|480

- gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64|0

-
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase|0

- gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase|0

-

-
##########################################################
######################

-#

-# Components Section - list of all EDK II Modules needed by this Platform

-#

-
##########################################################
######################

-[Components.common]

- #

- # PEI Phase modules

- #

- ArmPlatformPkg/PrePi/PeiUniCore.inf {

- <LibraryClasses>

-
SerialPortLib|Platform/RaspberryPi/Library/DualSerialPortLib/DualSerialPortL
ib.inf

- }

-

- #

- # DXE

- #

- MdeModulePkg/Core/Dxe/DxeMain.inf {

- <LibraryClasses>

-
NULL|MdeModulePkg/Library/DxeCrc32GuidedSectionExtractLib/DxeCrc32G
uidedSectionExtractLib.inf

- }

- MdeModulePkg/Universal/PCD/Dxe/Pcd.inf {

- <LibraryClasses>

- PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf

- }

-

- #

- # Architectural Protocols

- #

- ArmPkg/Drivers/CpuDxe/CpuDxe.inf

- MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf

- Platform/RaspberryPi/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.inf

-
MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.in
f

- MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf
{

- <LibraryClasses>

- NULL|MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.inf

- DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf

- }

-!if $(SECURE_BOOT_ENABLE) == TRUE

- MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf {

- <LibraryClasses>

-
NULL|SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib
.inf

- }

-
SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfi
gDxe.inf

-!else

- MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf

-!endif

- MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf

-
MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCoun
terRuntimeDxe.inf

- EmbeddedPkg/ResetRuntimeDxe/ResetRuntimeDxe.inf

- EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf {

- <LibraryClasses>

-
RealTimeClockLib|EmbeddedPkg/Library/VirtualRealTimeClockLib/VirtualRea
lTimeClockLib.inf

- }

- EmbeddedPkg/MetronomeDxe/MetronomeDxe.inf

-

- MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf

- MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf

-
MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleD
xe.inf

- MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf

- MdeModulePkg/Universal/SerialDxe/SerialDxe.inf {

- <LibraryClasses>

-
SerialPortLib|Platform/RaspberryPi/Library/DualSerialPortLib/DualSerialPortL
ib.inf

- }

- Platform/RaspberryPi/Drivers/DisplayDxe/DisplayDxe.inf

- EmbeddedPkg/Drivers/ConsolePrefDxe/ConsolePrefDxe.inf

-

- MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf

-

- ArmPkg/Drivers/ArmGic/ArmGicDxe.inf

- Platform/RaspberryPi/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.inf

- Platform/RaspberryPi/Drivers/FdtDxe/FdtDxe.inf

- Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf

- ArmPkg/Drivers/TimerDxe/TimerDxe.inf

- MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf

- MdeModulePkg/Universal/EbcDxe/EbcDxe.inf

-

- #

- # FAT filesystem + GPT/MBR partitioning

- #

- MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf

- MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf

-
MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf

- FatPkg/EnhancedFatDxe/Fat.inf

-

- #

- # ACPI Support

- #

- MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf

-
MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGraph
icsResourceTableDxe.inf

- Platform/RaspberryPi/AcpiTables/AcpiTables.inf

-

- #

- # SMBIOS Support

- #

- Platform/RaspberryPi/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.inf

- MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf

-

- #

- # RAM Disk Support

- #

- MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskDxe.inf

-

- #

- # Bds

- #

- MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf

- MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf

- MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf

-
MdeModulePkg/Universal/DriverHealthManagerDxe/DriverHealthManager
Dxe.inf

- MdeModulePkg/Universal/BdsDxe/BdsDxe.inf

- Platform/RaspberryPi/Drivers/LogoDxe/LogoDxe.inf

- MdeModulePkg/Application/UiApp/UiApp.inf {

- <LibraryClasses>

-
NULL|MdeModulePkg/Library/DeviceManagerUiLib/DeviceManagerUiLib.inf

- NULL|MdeModulePkg/Library/BootManagerUiLib/BootManagerUiLib.inf

-
NULL|Platform/RaspberryPi/Library/PlatformUiAppLib/PlatformUiAppLib.inf

-
NULL|MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMainte
nanceManagerUiLib.inf

- }

-

- #

- # SCSI Bus and Disk Driver

- #

- MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf

- MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf

-

- #

- # USB Support

- #

- MdeModulePkg/Bus/Pci/XhciDxe/XhciDxe.inf

- Platform/RaspberryPi/Drivers/DwUsbHostDxe/DwUsbHostDxe.inf

- MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBusDxe.inf

- MdeModulePkg/Bus/Usb/UsbKbDxe/UsbKbDxe.inf

- MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassStorageDxe.inf

-

- #

- # SD/MMC support

- #

- # Platform/RaspberryPi/Drivers/SdHostDxe/SdHostDxe.inf

-
Platform/RaspberryPi/Drivers/ArasanMmcHostDxe/ArasanMmcHostDxe.inf

- Platform/RaspberryPi/Drivers/MmcDxe/MmcDxe.inf

-

- #

- # Networking stack

- #

-!include NetworkPkg/Network.dsc.inc

- Silicon/Broadcom/Drivers/Net/BcmGenetDxe/BcmGenetDxe.inf {

- <PcdsFixedAtBuild>

- gEmbeddedTokenSpaceGuid.PcdDmaDeviceOffset|0x00000000

- gEmbeddedTokenSpaceGuid.PcdDmaDeviceLimit|0xffffffff

- }

-

- #

- # RNG

- #

- Silicon/Broadcom/Bcm283x/Drivers/Bcm2838RngDxe/Bcm2838RngDxe.inf

-

- #

- # PCI Support

- #

- ArmPkg/Drivers/ArmPciCpuIo2Dxe/ArmPciCpuIo2Dxe.inf

- MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridgeDxe.inf

- MdeModulePkg/Bus/Pci/PciBusDxe/PciBusDxe.inf

-
EmbeddedPkg/Drivers/NonCoherentIoMmuDxe/NonCoherentIoMmuDxe.i
nf {

- <PcdsFixedAtBuild>

- gEmbeddedTokenSpaceGuid.PcdDmaDeviceOffset|0x00000000

- gEmbeddedTokenSpaceGuid.PcdDmaDeviceLimit|0xbfffffff

- }

-

- #

- # UEFI application (Shell Embedded Boot Loader)

- #

- ShellPkg/Application/Shell/Shell.inf {

- <LibraryClasses>

-
ShellCommandLib|ShellPkg/Library/UefiShellCommandLib/UefiShellComma
ndLib.inf

-
NULL|ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2Comma
ndsLib.inf

-
NULL|ShellPkg/Library/UefiShellLevel1CommandsLib/UefiShellLevel1Comma
ndsLib.inf

-
NULL|ShellPkg/Library/UefiShellLevel3CommandsLib/UefiShellLevel3Comma
ndsLib.inf

-
NULL|ShellPkg/Library/UefiShellDriver1CommandsLib/UefiShellDriver1Com
mandsLib.inf

-
NULL|ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1Com
mandsLib.inf

-
NULL|ShellPkg/Library/UefiShellInstall1CommandsLib/UefiShellInstall1Com
mandsLib.inf

-
NULL|ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1
CommandsLib.inf

-
NULL|ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCo
mmandLib.inf

-
HandleParsingLib|ShellPkg/Library/UefiHandleParsingLib/UefiHandleParsingL
ib.inf

- PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf

-
BcfgCommandLib|ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfg
CommandLib.inf

-

- <PcdsFixedAtBuild>

- gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0xFF

- gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE

- gEfiMdePkgTokenSpaceGuid.PcdUefiLibMaxPrintBufferSize|8000

- gEfiShellPkgTokenSpaceGuid.PcdShellFileOperationSize|0x200000

- }

-!if $(INCLUDE_TFTP_COMMAND) == TRUE

-
ShellPkg/DynamicCommand/TftpDynamicCommand/TftpDynamicCommand.
inf {

- <PcdsFixedAtBuild>

- gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE

- }

-!endif

diff --git a/Platform/RaspberryPi/RPi4/RPi4.dsc.rej
b/Platform/RaspberryPi/RPi4/RPi4.dsc.rej
deleted file mode 100644
index 0b40df6896..0000000000
--- a/Platform/RaspberryPi/RPi4/RPi4.dsc.rej
+++ /dev/null
@@ -1,29 +0,0 @@
---- Platform/RaspberryPi/RPi4/RPi4.dsc
-+++ Platform/RaspberryPi/RPi4/RPi4.dsc
-@@ -429,7 +429,6 @@ [PcdsFixedAtBuild.common]
- gArmPlatformTokenSpaceGuid.PL011UartClkInHz|48000000
- gEfiMdeModulePkgTokenSpaceGuid.PcdSerialUseMmio|TRUE
- gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterStride|4
-- gEfiMdeModulePkgTokenSpaceGuid.PcdSerialClockRate|1000000000
- gEfiMdeModulePkgTokenSpaceGuid.PcdSerialFifoControl|0x27
- gEfiMdeModulePkgTokenSpaceGuid.PcdSerialExtendedTxFifoSize|8
- gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate|115200
-@@ -465,6 +464,9 @@ [PcdsFixedAtBuild.common]
- gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVendor|L"EDK2"
- gEfiMdeModulePkgTokenSpaceGuid.PcdSetNxForStack|TRUE
-
-+[PcdsPatchableInModule]
-+ gEfiMdeModulePkgTokenSpaceGuid.PcdSerialClockRate|500000000
-+
- [PcdsDynamicHii.common.DEFAULT]
-
- #
-@@ -621,7 +623,7 @@ [Components.common]
- MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf
- MdeModulePkg/Universal/SerialDxe/SerialDxe.inf {
- <LibraryClasses>
--
SerialPortLib|Platform/RaspberryPi/Library/DualSerialPortLib/DualSerialPortL
ib.inf
-+
SerialPortLib|Platform/RaspberryPi/Library/DualSerialPortLib/DualSerialPort
DxeLib.inf
- }
- Platform/RaspberryPi/Drivers/DisplayDxe/DisplayDxe.inf
- EmbeddedPkg/Drivers/ConsolePrefDxe/ConsolePrefDxe.inf
--
2.29.0
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.


[PATCH 1/1] BaseTools/GenFds: Change FV Header to FileSystemGuid3, edk2-stable202108

Yuwei Chen
 

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

Following PI spec: when there has Ffs with EFI_FFS_FILE_HEADER2,
the Parent Fv of the Ffs need set to FileSystemGuid3; when all
the Ffs with EFI_FFS_FILE_HEADER, the Parent Fv of the Ffs need
set to FileSystemGuid2.
Currently, when changing the Ffs in Fv from EFI_FFS_FILE_HEADER
to EFI_FFS_FILE_HEADER2, the Fv FileSystemGuid does not changed
consistent with Ffs type.That caused build issue.

This patch fixes this issue.
As FileSystemGuid3 is compatible with FileSystemGuid2, change all
the Fv header to FileSystemGuid3.

Signed-off-by: Yuwei Chen <yuwei.chen@...>
Cc: Bob Feng <bob.c.feng@...>
Cc: Liming Gao <gaoliming@...>
Cc: Andrew Fish <afish@...>
Cc: Leif Lindholm <leif@...>
Cc: Michael D Kinney <michael.d.kinney@...>
---
BaseTools/Source/C/GenFv/GenFv.c | 2 +-
BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py | 2 ++
2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/BaseTools/Source/C/GenFv/GenFv.c b/BaseTools/Source/C/GenFv/GenFv.c
index 43cc5cd3fe82..af0c21db062a 100644
--- a/BaseTools/Source/C/GenFv/GenFv.c
+++ b/BaseTools/Source/C/GenFv/GenFv.c
@@ -225,7 +225,7 @@ Routine Description:
//
// Set the default FvGuid
//
- memcpy (&mFvDataInfo.FvFileSystemGuid, &mEfiFirmwareFileSystem2Guid, sizeof (EFI_GUID));
+ memcpy (&mFvDataInfo.FvFileSystemGuid, &mEfiFirmwareFileSystem3Guid, sizeof (EFI_GUID));
mFvDataInfo.ForceRebase = -1;

//
diff --git a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py
index 25f9d54874d3..fa559793824d 100644
--- a/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py
+++ b/BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py
@@ -599,6 +599,8 @@ class GenFdsGlobalVariable:
if MapFile:
Cmd += ("-m", MapFile)
if FileSystemGuid:
+ if FileSystemGuid == EFI_FIRMWARE_FILE_SYSTEM2_GUID:
+ FileSystemGuid = EFI_FIRMWARE_FILE_SYSTEM3_GUID
Cmd += ("-g", FileSystemGuid)
Cmd += ("-o", Output)
for I in Input:
--
2.26.1.windows.1


Re: [PATCH v3 2/7] MdePkg: MmCommunication: Introduce EFI_MM_COMMUNICATE_HEADER_V3 to MdePkg

Kun Qin
 

Hi Ray,

This same header will be commonly used for both MM communicate PPI and Protocol. If including this definition in MmCommunicate protocol header, the potential PEIM that installs MM communicate PPI will need to include a PPI header as well as the aforementioned protocol header, which to me seems counter-intuitive.

I think PiMultiPhase header seems to be a file more ideal to resolve the entanglement above, as this structure indeed covers multiple phases during boot process.

Please let me know if you have any other thoughts.

Thanks,
Kun

On 08/16/2021 22:50, Ni, Ray wrote:
Can you kindly explain why you choose to define the definitions in PiMultiPhase.h instead of MmCommunication.h?
Thanks,
Ray

-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Kun Qin
Sent: Tuesday, August 17, 2021 1:08 PM
To: devel@edk2.groups.io
Cc: Kinney, Michael D <michael.d.kinney@...>; Liming Gao <gaoliming@...>; Liu, Zhiguang
<zhiguang.liu@...>; Wu, Hao A <hao.a.wu@...>; Marvin Häuser <mhaeuser@...>; Bret Barkelew
<Bret.Barkelew@...>; Michael Kubacki <michael.kubacki@...>
Subject: [edk2-devel] [PATCH v3 2/7] MdePkg: MmCommunication: Introduce EFI_MM_COMMUNICATE_HEADER_V3 to
MdePkg

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

This change introduces a new definition for MM communicate header
structure, intending to provide better portability between different
architectures (IA32 & X64) and adapt to flexible array supported by
modern compilers.

The original MessageLength field of EFI_MM_COMMUNICATE_HEADER, as a
generic definition, was used for both PEI and DXE MM communication. On a
system that supports PEI MM launch, but operates PEI in 32bit mode and MM
foundation in 64bit, the current EFI_MM_COMMUNICATE_HEADER definition
will cause structure parse error due to UINTN used. This introduction
removes the architecture dependent field by defining this field as
UINT64.

The new signature could help identifying whether the data received is
compiliant with this new data structure, which will help for binary
release modules to identify usage of legacy data structure.

Version field is also added to indicate the current version of header in
case there is need for minor modification in the future.

The data field of MM communicate message is replaced with flexible array
to allow users not having to consume extra data during communicate and
author code more intrinsically.

Cc: Michael D Kinney <michael.d.kinney@...>
Cc: Liming Gao <gaoliming@...>
Cc: Zhiguang Liu <zhiguang.liu@...>
Cc: Hao A Wu <hao.a.wu@...>
Cc: Marvin Häuser <mhaeuser@...>
Cc: Bret Barkelew <Bret.Barkelew@...>
Cc: Michael Kubacki <michael.kubacki@...>

Signed-off-by: Kun Qin <kuqin12@...>
---

Notes:
v3:
- Newly introduced communicate v3
- Used flexible arrays [Marvin]
- Added static assert [Michael]

MdePkg/Include/Pi/PiMultiPhase.h | 55 ++++++++++++++++++++
MdePkg/MdePkg.dec | 5 ++
2 files changed, 60 insertions(+)

diff --git a/MdePkg/Include/Pi/PiMultiPhase.h b/MdePkg/Include/Pi/PiMultiPhase.h
index 89280d9d3506..8c60338091b3 100644
--- a/MdePkg/Include/Pi/PiMultiPhase.h
+++ b/MdePkg/Include/Pi/PiMultiPhase.h
@@ -103,6 +103,17 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#define EFI_SMRAM_CLOSED EFI_MMRAM_CLOSED
#define EFI_SMRAM_LOCKED EFI_MMRAM_LOCKED

+///
+/// MM Communicate header constants
+///
+#define COMMUNICATE_HEADER_V3_GUID \
+ { \
+ 0x68e8c853, 0x2ba9, 0x4dd7, { 0x9a, 0xc0, 0x91, 0xe1, 0x61, 0x55, 0xc9, 0x35 } \
+ }
+
+#define EFI_MM_COMMUNICATE_HEADER_V3_SIGNATURE 0x4D434833 // "MCH3"
+#define EFI_MM_COMMUNICATE_HEADER_V3_VERSION 3
+
///
/// Structure describing a MMRAM region and its accessibility attributes.
///
@@ -149,6 +160,48 @@ typedef struct _EFI_MM_RESERVED_MMRAM_REGION {
UINT64 MmramReservedSize;
} EFI_MM_RESERVED_MMRAM_REGION;

+#pragma pack(1)
+
+///
+/// To avoid confusion in interpreting frames, the buffer communicating to MM core through
+/// EFI_MM_COMMUNICATE3 or later should always start with EFI_MM_COMMUNICATE_HEADER_V3.
+///
+typedef struct {
+ ///
+ /// Indicator GUID for MM core that the communication buffer is compliant with this v3 header.
+ /// Must be gCommunicateHeaderV3Guid.
+ ///
+ EFI_GUID HeaderGuid;
+ ///
+ /// Signature to indicate data is compliant with new MM communicate header structure.
+ /// Must be "MCH3".
+ ///
+ UINT32 Signature;
+ ///
+ /// MM communicate data format version, MM foundation entry point should check if incoming
+ /// data is a supported format before proceeding.
+ /// Must be 3.
+ ///
+ UINT32 Version;
+ ///
+ /// Allows for disambiguation of the message format.
+ ///
+ EFI_GUID MessageGuid;
+ ///
+ /// Describes the size of MessageData (in bytes) and does not include the size of the header.
+ ///
+ UINT64 MessageSize;
+ ///
+ /// Designates an array of bytes that is MessageSize in size.
+ ///
+ UINT8 MessageData[];
+} EFI_MM_COMMUNICATE_HEADER_V3;
+
+#pragma pack()
+
+STATIC_ASSERT ((sizeof (EFI_MM_COMMUNICATE_HEADER_V3) == OFFSET_OF (EFI_MM_COMMUNICATE_HEADER_V3,
MessageData)), \
+ "sizeof (EFI_MM_COMMUNICATE_HEADER_V3) does not align with the beginning of flexible array MessageData");
+
typedef enum {
EFI_PCD_TYPE_8,
EFI_PCD_TYPE_16,
@@ -208,4 +261,6 @@ EFI_STATUS
IN VOID *ProcedureArgument
);

+extern EFI_GUID gCommunicateHeaderV3Guid;
+
#endif
diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec
index a28a2daaffa8..411079a4343e 100644
--- a/MdePkg/MdePkg.dec
+++ b/MdePkg/MdePkg.dec
@@ -823,6 +823,11 @@ [Guids]
#
gLinuxEfiInitrdMediaGuid = {0x5568e427, 0x68fc, 0x4f3d, {0xac, 0x74, 0xca, 0x55, 0x52, 0x31, 0xcc, 0x68}}

+ #
+ # GUID indicates the MM communication data is compliant with v3 communication header.
+ #
+ gCommunicateHeaderV3Guid = { 0x68e8c853, 0x2ba9, 0x4dd7, { 0x9a, 0xc0, 0x91, 0xe1, 0x61, 0x55, 0xc9, 0x35 } }
+
[Guids.IA32, Guids.X64]
## Include/Guid/Cper.h
gEfiIa32X64ErrorTypeCacheCheckGuid = { 0xA55701F5, 0xE3EF, 0x43de, { 0xAC, 0x72, 0x24, 0x9B, 0x57, 0x3F, 0xAD, 0x2C }}
--
2.32.0.windows.1




Re: [PATCH v3 2/7] MdePkg: MmCommunication: Introduce EFI_MM_COMMUNICATE_HEADER_V3 to MdePkg

Ni, Ray
 

Can you kindly explain why you choose to define the definitions in PiMultiPhase.h instead of MmCommunication.h?

Thanks,
Ray

-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Kun Qin
Sent: Tuesday, August 17, 2021 1:08 PM
To: devel@edk2.groups.io
Cc: Kinney, Michael D <michael.d.kinney@...>; Liming Gao <gaoliming@...>; Liu, Zhiguang
<zhiguang.liu@...>; Wu, Hao A <hao.a.wu@...>; Marvin Häuser <mhaeuser@...>; Bret Barkelew
<Bret.Barkelew@...>; Michael Kubacki <michael.kubacki@...>
Subject: [edk2-devel] [PATCH v3 2/7] MdePkg: MmCommunication: Introduce EFI_MM_COMMUNICATE_HEADER_V3 to
MdePkg

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

This change introduces a new definition for MM communicate header
structure, intending to provide better portability between different
architectures (IA32 & X64) and adapt to flexible array supported by
modern compilers.

The original MessageLength field of EFI_MM_COMMUNICATE_HEADER, as a
generic definition, was used for both PEI and DXE MM communication. On a
system that supports PEI MM launch, but operates PEI in 32bit mode and MM
foundation in 64bit, the current EFI_MM_COMMUNICATE_HEADER definition
will cause structure parse error due to UINTN used. This introduction
removes the architecture dependent field by defining this field as
UINT64.

The new signature could help identifying whether the data received is
compiliant with this new data structure, which will help for binary
release modules to identify usage of legacy data structure.

Version field is also added to indicate the current version of header in
case there is need for minor modification in the future.

The data field of MM communicate message is replaced with flexible array
to allow users not having to consume extra data during communicate and
author code more intrinsically.

Cc: Michael D Kinney <michael.d.kinney@...>
Cc: Liming Gao <gaoliming@...>
Cc: Zhiguang Liu <zhiguang.liu@...>
Cc: Hao A Wu <hao.a.wu@...>
Cc: Marvin Häuser <mhaeuser@...>
Cc: Bret Barkelew <Bret.Barkelew@...>
Cc: Michael Kubacki <michael.kubacki@...>

Signed-off-by: Kun Qin <kuqin12@...>
---

Notes:
v3:
- Newly introduced communicate v3
- Used flexible arrays [Marvin]
- Added static assert [Michael]

MdePkg/Include/Pi/PiMultiPhase.h | 55 ++++++++++++++++++++
MdePkg/MdePkg.dec | 5 ++
2 files changed, 60 insertions(+)

diff --git a/MdePkg/Include/Pi/PiMultiPhase.h b/MdePkg/Include/Pi/PiMultiPhase.h
index 89280d9d3506..8c60338091b3 100644
--- a/MdePkg/Include/Pi/PiMultiPhase.h
+++ b/MdePkg/Include/Pi/PiMultiPhase.h
@@ -103,6 +103,17 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#define EFI_SMRAM_CLOSED EFI_MMRAM_CLOSED
#define EFI_SMRAM_LOCKED EFI_MMRAM_LOCKED

+///
+/// MM Communicate header constants
+///
+#define COMMUNICATE_HEADER_V3_GUID \
+ { \
+ 0x68e8c853, 0x2ba9, 0x4dd7, { 0x9a, 0xc0, 0x91, 0xe1, 0x61, 0x55, 0xc9, 0x35 } \
+ }
+
+#define EFI_MM_COMMUNICATE_HEADER_V3_SIGNATURE 0x4D434833 // "MCH3"
+#define EFI_MM_COMMUNICATE_HEADER_V3_VERSION 3
+
///
/// Structure describing a MMRAM region and its accessibility attributes.
///
@@ -149,6 +160,48 @@ typedef struct _EFI_MM_RESERVED_MMRAM_REGION {
UINT64 MmramReservedSize;
} EFI_MM_RESERVED_MMRAM_REGION;

+#pragma pack(1)
+
+///
+/// To avoid confusion in interpreting frames, the buffer communicating to MM core through
+/// EFI_MM_COMMUNICATE3 or later should always start with EFI_MM_COMMUNICATE_HEADER_V3.
+///
+typedef struct {
+ ///
+ /// Indicator GUID for MM core that the communication buffer is compliant with this v3 header.
+ /// Must be gCommunicateHeaderV3Guid.
+ ///
+ EFI_GUID HeaderGuid;
+ ///
+ /// Signature to indicate data is compliant with new MM communicate header structure.
+ /// Must be "MCH3".
+ ///
+ UINT32 Signature;
+ ///
+ /// MM communicate data format version, MM foundation entry point should check if incoming
+ /// data is a supported format before proceeding.
+ /// Must be 3.
+ ///
+ UINT32 Version;
+ ///
+ /// Allows for disambiguation of the message format.
+ ///
+ EFI_GUID MessageGuid;
+ ///
+ /// Describes the size of MessageData (in bytes) and does not include the size of the header.
+ ///
+ UINT64 MessageSize;
+ ///
+ /// Designates an array of bytes that is MessageSize in size.
+ ///
+ UINT8 MessageData[];
+} EFI_MM_COMMUNICATE_HEADER_V3;
+
+#pragma pack()
+
+STATIC_ASSERT ((sizeof (EFI_MM_COMMUNICATE_HEADER_V3) == OFFSET_OF (EFI_MM_COMMUNICATE_HEADER_V3,
MessageData)), \
+ "sizeof (EFI_MM_COMMUNICATE_HEADER_V3) does not align with the beginning of flexible array MessageData");
+
typedef enum {
EFI_PCD_TYPE_8,
EFI_PCD_TYPE_16,
@@ -208,4 +261,6 @@ EFI_STATUS
IN VOID *ProcedureArgument
);

+extern EFI_GUID gCommunicateHeaderV3Guid;
+
#endif
diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec
index a28a2daaffa8..411079a4343e 100644
--- a/MdePkg/MdePkg.dec
+++ b/MdePkg/MdePkg.dec
@@ -823,6 +823,11 @@ [Guids]
#
gLinuxEfiInitrdMediaGuid = {0x5568e427, 0x68fc, 0x4f3d, {0xac, 0x74, 0xca, 0x55, 0x52, 0x31, 0xcc, 0x68}}

+ #
+ # GUID indicates the MM communication data is compliant with v3 communication header.
+ #
+ gCommunicateHeaderV3Guid = { 0x68e8c853, 0x2ba9, 0x4dd7, { 0x9a, 0xc0, 0x91, 0xe1, 0x61, 0x55, 0xc9, 0x35 } }
+
[Guids.IA32, Guids.X64]
## Include/Guid/Cper.h
gEfiIa32X64ErrorTypeCacheCheckGuid = { 0xA55701F5, 0xE3EF, 0x43de, { 0xAC, 0x72, 0x24, 0x9B, 0x57, 0x3F, 0xAD, 0x2C }}
--
2.32.0.windows.1





[PATCH v3 7/7] MdeModulePkg: PiSmmIpl: Update MessageLength calculation for MmCommunicate

Kun Qin
 

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

This change added support of installing `EFI_MM_COMMUNICATION3_PROTOCOL`.

MmCommunicate v3 routine that calculates message length is also updated
to remove ambiguity in contrast to v1 routine.

Cc: Jian J Wang <jian.j.wang@...>
Cc: Hao A Wu <hao.a.wu@...>
Cc: Eric Dong <eric.dong@...>
Cc: Ray Ni <ray.ni@...>

Signed-off-by: Kun Qin <kuqin12@...>
---

Notes:
v3:
- Newly added v3 communicate protocol instance

MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c | 187 ++++++++++++++++++++
MdeModulePkg/Core/PiSmmCore/PiSmmIpl.inf | 2 +
2 files changed, 189 insertions(+)

diff --git a/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c b/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c
index 599a0cd01d80..356efa172cfd 100644
--- a/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c
+++ b/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c
@@ -11,6 +11,7 @@
#include <Protocol/SmmBase2.h>
#include <Protocol/SmmCommunication.h>
#include <Protocol/MmCommunication2.h>
+#include <Protocol/MmCommunication3.h>
#include <Protocol/SmmAccess2.h>
#include <Protocol/SmmConfiguration.h>
#include <Protocol/SmmControl2.h>
@@ -34,6 +35,7 @@
#include <Library/UefiRuntimeLib.h>
#include <Library/PcdLib.h>
#include <Library/ReportStatusCodeLib.h>
+#include <Library/SafeIntLib.h>

#include "PiSmmCorePrivateData.h"

@@ -146,6 +148,41 @@ SmmCommunicationMmCommunicate2 (
IN OUT UINTN *CommSize OPTIONAL
);

+/**
+ Communicates with a registered handler.
+
+ This function provides a service to send and receive messages from a registered UEFI service.
+
+ @param[in] This The EFI_MM_COMMUNICATION3_PROTOCOL instance.
+ @param[in, out] CommBufferPhysical Physical address of the MM communication buffer, of which content must
+ start with EFI_MM_COMMUNICATE_HEADER_V3.
+ @param[in, out] CommBufferVirtual Virtual address of the MM communication buffer, of which content must
+ start with EFI_MM_COMMUNICATE_HEADER_V3.
+ @param[in, out] CommSize The size of the data buffer being passed in. On exit, the size of data
+ being returned. Zero if the handler does not wish to reply with any data.
+ This parameter is optional and may be NULL.
+
+ @retval EFI_SUCCESS The message was successfully posted.
+ @retval EFI_INVALID_PARAMETER CommBufferPhysical was NULL or CommBufferVirtual was NULL.
+ @retval EFI_BAD_BUFFER_SIZE The buffer is too large 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.
+
+**/
+EFI_STATUS
+EFIAPI
+MmCommunicationMmCommunicate3 (
+ IN CONST EFI_MM_COMMUNICATION3_PROTOCOL *This,
+ IN OUT VOID *CommBufferPhysical,
+ IN OUT VOID *CommBufferVirtual,
+ IN OUT UINTN *CommSize OPTIONAL
+ );
+
/**
Event notification that is fired every time a gEfiSmmConfigurationProtocol installs.

@@ -275,6 +312,13 @@ EFI_MM_COMMUNICATION2_PROTOCOL mMmCommunication2 = {
SmmCommunicationMmCommunicate2
};

+//
+// PI 1.7 MM Communication Protocol 3 instance
+//
+EFI_MM_COMMUNICATION3_PROTOCOL mMmCommunication3 = {
+ MmCommunicationMmCommunicate3
+};
+
//
// SMM Core Private Data structure that contains the data shared between
// the SMM IPL and the SMM Core.
@@ -649,6 +693,148 @@ SmmCommunicationMmCommunicate2 (
CommSize);
}

+/**
+ Communicates with a registered handler.
+
+ This function provides a service to send and receive messages from a registered UEFI service.
+
+ @param[in] This The EFI_MM_COMMUNICATION3_PROTOCOL instance.
+ @param[in, out] CommBufferPhysical Physical address of the MM communication buffer, of which content must
+ start with EFI_MM_COMMUNICATE_HEADER_V3.
+ @param[in, out] CommBufferVirtual Virtual address of the MM communication buffer, of which content must
+ start with EFI_MM_COMMUNICATE_HEADER_V3.
+ @param[in, out] CommSize The size of the data buffer being passed in. On exit, the size of data
+ being returned. Zero if the handler does not wish to reply with any data.
+ This parameter is optional and may be NULL.
+
+ @retval EFI_SUCCESS The message was successfully posted.
+ @retval EFI_INVALID_PARAMETER CommBufferPhysical was NULL or CommBufferVirtual was NULL.
+ @retval EFI_BAD_BUFFER_SIZE The buffer is too large 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.
+
+**/
+EFI_STATUS
+EFIAPI
+MmCommunicationMmCommunicate3 (
+ IN CONST EFI_MM_COMMUNICATION3_PROTOCOL *This,
+ IN OUT VOID *CommBufferPhysical,
+ IN OUT VOID *CommBufferVirtual,
+ IN OUT UINTN *CommSize OPTIONAL
+ )
+{
+ EFI_STATUS Status;
+ EFI_MM_COMMUNICATE_HEADER_V3 *CommunicateHeader;
+ BOOLEAN OldInSmm;
+ UINTN TempCommSize;
+ UINT64 LongCommSize;
+
+ //
+ // Check parameters
+ //
+ if (CommBufferPhysical == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ CommunicateHeader = (EFI_MM_COMMUNICATE_HEADER_V3 *) CommBufferPhysical;
+
+ if (CommSize == NULL) {
+ Status = SafeUint64Add (sizeof (EFI_MM_COMMUNICATE_HEADER_V3), CommunicateHeader->MessageSize, &LongCommSize);
+ if (EFI_ERROR (Status)) {
+ return EFI_INVALID_PARAMETER;
+ }
+ Status = SafeUint64ToUintn (LongCommSize, &TempCommSize);
+ if (EFI_ERROR (Status)) {
+ return EFI_INVALID_PARAMETER;
+ }
+ } else {
+ TempCommSize = *CommSize;
+ //
+ // CommSize must hold the entire EFI_MM_COMMUNICATE_HEADER_V3
+ //
+ if (TempCommSize < sizeof (EFI_MM_COMMUNICATE_HEADER_V3)) {
+ return EFI_INVALID_PARAMETER;
+ }
+ }
+
+ //
+ // If not already in SMM, then generate a Software SMI
+ //
+ if (!gSmmCorePrivate->InSmm && gSmmCorePrivate->SmmEntryPointRegistered) {
+ //
+ // Put arguments for Software SMI in gSmmCorePrivate
+ //
+ gSmmCorePrivate->CommunicationBuffer = CommBufferPhysical;
+ gSmmCorePrivate->BufferSize = TempCommSize;
+
+ //
+ // Generate Software SMI
+ //
+ Status = mSmmControl2->Trigger (mSmmControl2, NULL, NULL, FALSE, 0);
+ if (EFI_ERROR (Status)) {
+ return EFI_UNSUPPORTED;
+ }
+
+ //
+ // Return status from software SMI
+ //
+ if (CommSize != NULL) {
+ *CommSize = gSmmCorePrivate->BufferSize;
+ }
+ return gSmmCorePrivate->ReturnStatus;
+ }
+
+ //
+ // If we are in SMM, then the execution mode must be physical, which means that
+ // OS established virtual addresses can not be used. If SetVirtualAddressMap()
+ // has been called, then a direct invocation of the Software SMI is not allowed,
+ // so return EFI_INVALID_PARAMETER.
+ //
+ if (EfiGoneVirtual()) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ //
+ // If we are not in SMM, don't allow call SmiManage() directly when SMRAM is closed or locked.
+ //
+ if ((!gSmmCorePrivate->InSmm) && (!mSmmAccess->OpenState || mSmmAccess->LockState)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ //
+ // Save current InSmm state and set InSmm state to TRUE
+ //
+ OldInSmm = gSmmCorePrivate->InSmm;
+ gSmmCorePrivate->InSmm = TRUE;
+
+ //
+ // Before SetVirtualAddressMap(), we are in SMM or SMRAM is open and unlocked, call SmiManage() directly.
+ //
+ TempCommSize -= sizeof (EFI_MM_COMMUNICATE_HEADER_V3);
+ Status = gSmmCorePrivate->Smst->SmiManage (
+ &CommunicateHeader->MessageGuid,
+ NULL,
+ CommunicateHeader->MessageData,
+ &TempCommSize
+ );
+ TempCommSize += sizeof (EFI_MM_COMMUNICATE_HEADER_V3);
+ if (CommSize != NULL) {
+ *CommSize = TempCommSize;
+ }
+
+ //
+ // Restore original InSmm state
+ //
+ gSmmCorePrivate->InSmm = OldInSmm;
+
+ return (Status == EFI_SUCCESS) ? EFI_SUCCESS : EFI_NOT_FOUND;
+}
+
/**
Event notification that is fired when GUIDed Event Group is signaled.

@@ -1832,6 +2018,7 @@ SmmIplEntry (
&gEfiSmmBase2ProtocolGuid, &mSmmBase2,
&gEfiSmmCommunicationProtocolGuid, &mSmmCommunication,
&gEfiMmCommunication2ProtocolGuid, &mMmCommunication2,
+ &gEfiMmCommunication3ProtocolGuid, &mMmCommunication3,
NULL
);
ASSERT_EFI_ERROR (Status);
diff --git a/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.inf b/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.inf
index 6109d6b5449c..afab228cc04c 100644
--- a/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.inf
+++ b/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.inf
@@ -46,11 +46,13 @@ [LibraryClasses]
DxeServicesLib
PcdLib
ReportStatusCodeLib
+ SafeIntLib

[Protocols]
gEfiSmmBase2ProtocolGuid ## PRODUCES
gEfiSmmCommunicationProtocolGuid ## PRODUCES
gEfiMmCommunication2ProtocolGuid ## PRODUCES
+ gEfiMmCommunication3ProtocolGuid ## PRODUCES
gEfiSmmAccess2ProtocolGuid ## CONSUMES
## NOTIFY
## CONSUMES
--
2.32.0.windows.1


[PATCH v3 6/7] StandaloneMmPkg: StandaloneMmCore: Parsing new MM communicate header

Kun Qin
 

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

MM communicate protocols are expanded with EFI_MM_COMMUNICATE_HEADER_V3
structure that cooperates with updated field types and flexible array.
The PiSmmCore implementation is updated to detect and process incoming
data accordingly.

Two checks are also performed to prevent legacy communicate data or
unsupported data is fed into MM core under agreed header guid.

Cc: Ard Biesheuvel <ardb+tianocore@...>
Cc: Sami Mujawar <sami.mujawar@...>
Cc: Jiewen Yao <jiewen.yao@...>
Cc: Supreeth Venkatesh <supreeth.venkatesh@...>

Signed-off-by: Kun Qin <kuqin12@...>
---

Notes:
v3:
- Newly added

StandaloneMmPkg/Core/StandaloneMmCore.c | 34 ++++++++++++++++----
StandaloneMmPkg/Core/StandaloneMmCore.inf | 1 +
2 files changed, 28 insertions(+), 7 deletions(-)

diff --git a/StandaloneMmPkg/Core/StandaloneMmCore.c b/StandaloneMmPkg/Core/StandaloneMmCore.c
index fbb0ec75e557..000aca098cc8 100644
--- a/StandaloneMmPkg/Core/StandaloneMmCore.c
+++ b/StandaloneMmPkg/Core/StandaloneMmCore.c
@@ -340,8 +340,12 @@ MmEntryPoint (
IN CONST EFI_MM_ENTRY_CONTEXT *MmEntryContext
)
{
- EFI_STATUS Status;
- EFI_MM_COMMUNICATE_HEADER *CommunicateHeader;
+ EFI_STATUS Status;
+ EFI_MM_COMMUNICATE_HEADER_V3 *CommunicateHeader;
+ EFI_MM_COMMUNICATE_HEADER *LegacyCommunicateHeader;
+ EFI_GUID *CommGuid;
+ VOID *CommData;
+ UINTN CommHeaderSize;

DEBUG ((DEBUG_INFO, "MmEntryPoint ...\n"));

@@ -379,19 +383,35 @@ MmEntryPoint (
gMmCorePrivate->CommunicationBuffer = 0;
gMmCorePrivate->ReturnStatus = EFI_INVALID_PARAMETER;
} else {
- CommunicateHeader = (EFI_MM_COMMUNICATE_HEADER *)(UINTN)gMmCorePrivate->CommunicationBuffer;
- gMmCorePrivate->BufferSize -= OFFSET_OF (EFI_MM_COMMUNICATE_HEADER, Data);
+ CommGuid = &((EFI_MM_COMMUNICATE_HEADER_V3 *)(UINTN)gMmCorePrivate->CommunicationBuffer)->HeaderGuid;
+ //
+ // Check if the signature matches EFI_MM_COMMUNICATE_HEADER_V3 definition
+ //
+ if (CompareGuid (CommGuid, &gCommunicateHeaderV3Guid)) {
+ CommunicateHeader = (EFI_MM_COMMUNICATE_HEADER_V3 *)(UINTN)gMmCorePrivate->CommunicationBuffer;
+ ASSERT (CommunicateHeader->Signature == EFI_MM_COMMUNICATE_HEADER_V3_SIGNATURE);
+ ASSERT (CommunicateHeader->Version <= EFI_MM_COMMUNICATE_HEADER_V3_VERSION);
+ CommGuid = &CommunicateHeader->MessageGuid;
+ CommData = CommunicateHeader->MessageData;
+ CommHeaderSize = sizeof (EFI_MM_COMMUNICATE_HEADER_V3);
+ } else {
+ LegacyCommunicateHeader = (EFI_MM_COMMUNICATE_HEADER *)(UINTN)gMmCorePrivate->CommunicationBuffer;
+ CommGuid = &LegacyCommunicateHeader->HeaderGuid;
+ CommData = LegacyCommunicateHeader->Data;
+ CommHeaderSize = OFFSET_OF (EFI_MM_COMMUNICATE_HEADER, Data);
+ }
+ gMmCorePrivate->BufferSize -= CommHeaderSize;
Status = MmiManage (
- &CommunicateHeader->HeaderGuid,
+ CommGuid,
NULL,
- CommunicateHeader->Data,
+ CommData,
(UINTN *)&gMmCorePrivate->BufferSize
);
//
// Update CommunicationBuffer, BufferSize and ReturnStatus
// Communicate service finished, reset the pointer to CommBuffer to NULL
//
- gMmCorePrivate->BufferSize += OFFSET_OF (EFI_MM_COMMUNICATE_HEADER, Data);
+ gMmCorePrivate->BufferSize += CommHeaderSize;
gMmCorePrivate->CommunicationBuffer = 0;
gMmCorePrivate->ReturnStatus = (Status == EFI_SUCCESS) ? EFI_SUCCESS : EFI_NOT_FOUND;
}
diff --git a/StandaloneMmPkg/Core/StandaloneMmCore.inf b/StandaloneMmPkg/Core/StandaloneMmCore.inf
index 56042b7b39f4..41a49e23fa8f 100644
--- a/StandaloneMmPkg/Core/StandaloneMmCore.inf
+++ b/StandaloneMmPkg/Core/StandaloneMmCore.inf
@@ -75,6 +75,7 @@ [Guids]
gEfiEventLegacyBootGuid
gEfiEventExitBootServicesGuid
gEfiEventReadyToBootGuid
+ gCommunicateHeaderV3Guid ## CONSUMES ## GUID # Communicate header

[BuildOptions]
GCC:*_*_*_CC_FLAGS = -fpie
--
2.32.0.windows.1


[PATCH v3 5/7] MdeModulePkg: PiSmmCore: Added parser of new MM communicate header

Kun Qin
 

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

MM communicate protocols are expanded with EFI_MM_COMMUNICATE_HEADER_V3
structure that cooperates with updated field types and flexible array.
The PiSmmCore implementation is updated to detect and process incoming
data accordingly.

Two checks are also performed to prevent legacy communicate data or
unsupported data is fed into MM core under agreed header guid.

Cc: Jian J Wang <jian.j.wang@...>
Cc: Hao A Wu <hao.a.wu@...>
Cc: Eric Dong <eric.dong@...>
Cc: Ray Ni <ray.ni@...>

Signed-off-by: Kun Qin <kuqin12@...>
---

Notes:
v3:
- Newly added

MdeModulePkg/Core/PiSmmCore/PiSmmCore.c | 42 +++++++++++++++-----
MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf | 1 +
2 files changed, 32 insertions(+), 11 deletions(-)

diff --git a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.c b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.c
index cfa9922cbdb5..63ac2b5fcbbd 100644
--- a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.c
+++ b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.c
@@ -646,12 +646,16 @@ SmmEntryPoint (
IN CONST EFI_SMM_ENTRY_CONTEXT *SmmEntryContext
)
{
- EFI_STATUS Status;
- EFI_SMM_COMMUNICATE_HEADER *CommunicateHeader;
- BOOLEAN InLegacyBoot;
- BOOLEAN IsOverlapped;
- VOID *CommunicationBuffer;
- UINTN BufferSize;
+ EFI_STATUS Status;
+ EFI_MM_COMMUNICATE_HEADER_V3 *CommunicateHeader;
+ EFI_SMM_COMMUNICATE_HEADER *LegacyCommunicateHeader;
+ BOOLEAN InLegacyBoot;
+ BOOLEAN IsOverlapped;
+ VOID *CommunicationBuffer;
+ UINTN BufferSize;
+ EFI_GUID *CommGuid;
+ VOID *CommData;
+ UINTN CommHeaderSize;

//
// Update SMST with contents of the SmmEntryContext structure
@@ -707,19 +711,35 @@ SmmEntryPoint (
gSmmCorePrivate->CommunicationBuffer = NULL;
gSmmCorePrivate->ReturnStatus = EFI_ACCESS_DENIED;
} else {
- CommunicateHeader = (EFI_SMM_COMMUNICATE_HEADER *)CommunicationBuffer;
- BufferSize -= OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data);
+ CommGuid = &((EFI_MM_COMMUNICATE_HEADER_V3 *)CommunicationBuffer)->HeaderGuid;
+ //
+ // Check if the signature matches EFI_MM_COMMUNICATE_HEADER_V3 definition
+ //
+ if (CompareGuid (CommGuid, &gCommunicateHeaderV3Guid)) {
+ CommunicateHeader = (EFI_MM_COMMUNICATE_HEADER_V3 *)CommunicationBuffer;
+ ASSERT (CommunicateHeader->Signature == EFI_MM_COMMUNICATE_HEADER_V3_SIGNATURE);
+ ASSERT (CommunicateHeader->Version <= EFI_MM_COMMUNICATE_HEADER_V3_VERSION);
+ CommGuid = &CommunicateHeader->MessageGuid;
+ CommData = CommunicateHeader->MessageData;
+ CommHeaderSize = sizeof (EFI_MM_COMMUNICATE_HEADER_V3);
+ } else {
+ LegacyCommunicateHeader = (EFI_SMM_COMMUNICATE_HEADER *)CommunicationBuffer;
+ CommGuid = &LegacyCommunicateHeader->HeaderGuid;
+ CommData = LegacyCommunicateHeader->Data;
+ CommHeaderSize = OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data);
+ }
+ BufferSize -= CommHeaderSize;
Status = SmiManage (
- &CommunicateHeader->HeaderGuid,
+ CommGuid,
NULL,
- CommunicateHeader->Data,
+ CommData,
&BufferSize
);
//
// Update CommunicationBuffer, BufferSize and ReturnStatus
// Communicate service finished, reset the pointer to CommBuffer to NULL
//
- gSmmCorePrivate->BufferSize = BufferSize + OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data);
+ gSmmCorePrivate->BufferSize = BufferSize + CommHeaderSize;
gSmmCorePrivate->CommunicationBuffer = NULL;
gSmmCorePrivate->ReturnStatus = (Status == EFI_SUCCESS) ? EFI_SUCCESS : EFI_NOT_FOUND;
}
diff --git a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf
index c8bfae3860fc..5a0929a45e19 100644
--- a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf
+++ b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf
@@ -118,6 +118,7 @@ [Guids]
gSmiHandlerProfileGuid
gEdkiiEndOfS3ResumeGuid ## SOMETIMES_PRODUCES ## GUID # Install protocol
gEdkiiS3SmmInitDoneGuid ## SOMETIMES_PRODUCES ## GUID # Install protocol
+ gCommunicateHeaderV3Guid ## CONSUMES ## GUID # Communicate header

[UserExtensions.TianoCore."ExtraFiles"]
PiSmmCoreExtra.uni
--
2.32.0.windows.1


[PATCH v3 4/7] MdePkg: MmCommunication: Introduce EFI_PEI_MM_COMMUNICATION3_PPI to MdePkg

Kun Qin
 

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

This change introduces a new definition for MM communicate PPI v3.

This PPI will be installed under a new GUID in contrast to exisiting
EFI_PEI_MM_COMMUNICATION_PPI.

Data communicated to MM through EFI_PEI_MM_COMMUNICATION3_PPI should
always start with EFI_MM_COMMUNICATE_HEADER_V3 with its HeaderGuid,
Signature and Version fields properly populated.

Cc: Michael D Kinney <michael.d.kinney@...>
Cc: Liming Gao <gaoliming@...>
Cc: Zhiguang Liu <zhiguang.liu@...>
Cc: Hao A Wu <hao.a.wu@...>
Cc: Marvin Häuser <mhaeuser@...>
Cc: Bret Barkelew <Bret.Barkelew@...>
Cc: Michael Kubacki <michael.kubacki@...>

Signed-off-by: Kun Qin <kuqin12@...>
---

Notes:
v3:
- Newly introduced v3 communicate PPI

MdePkg/Include/Ppi/MmCommunication3.h | 58 ++++++++++++++++++++
MdePkg/MdePkg.dec | 3 +
2 files changed, 61 insertions(+)

diff --git a/MdePkg/Include/Ppi/MmCommunication3.h b/MdePkg/Include/Ppi/MmCommunication3.h
new file mode 100644
index 000000000000..11924099b4c3
--- /dev/null
+++ b/MdePkg/Include/Ppi/MmCommunication3.h
@@ -0,0 +1,58 @@
+/** @file
+ EFI MM Communication v3 PPI definition.
+
+ This Ppi provides a means of communicating between PEIM and MMI
+ handlers inside of MM.
+
+Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.<BR>
+Copyright (c) Microsoft Corporation.
+
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+
+#ifndef MM_COMMUNICATION3_PPI_H_
+#define MM_COMMUNICATION3_PPI_H_
+
+#include <Pi/PiMultiPhase.h>
+
+#define EFI_PEI_MM_COMMUNICATION3_PPI_GUID \
+ { \
+ 0xe70febf6, 0x13ef, 0x4a21, { 0x89, 0x9e, 0xb2, 0x36, 0xf8, 0x25, 0xff, 0xc9 } \
+ }
+
+typedef struct _EFI_PEI_MM_COMMUNICATION3_PPI EFI_PEI_MM_COMMUNICATION3_PPI;
+
+/**
+ Communicates with a registered handler.
+
+ This function provides a service to send and receive messages from a registered UEFI service.
+
+ @param[in] This The EFI_PEI_MM_COMMUNICATE3 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.On exit, the size of data
+ being returned. Zero if the handler does not wish to reply with any data.
+
+ @retval EFI_SUCCESS The message was successfully posted.
+ @retval EFI_INVALID_PARAMETER The CommBuffer was NULL.
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PEI_MM_COMMUNICATE3)(
+ IN CONST EFI_PEI_MM_COMMUNICATION3_PPI *This,
+ IN OUT VOID *CommBuffer,
+ IN OUT UINTN *CommSize
+ );
+
+///
+/// EFI MM Communication PPI provides runtime services for communicating
+/// between DXE drivers and a registered SMI handler.
+///
+struct _EFI_PEI_MM_COMMUNICATION3_PPI {
+ EFI_PEI_MM_COMMUNICATE3 Communicate;
+};
+
+extern EFI_GUID gEfiPeiMmCommunication3PpiGuid;
+
+#endif
diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec
index 3168534951c1..c194d6225501 100644
--- a/MdePkg/MdePkg.dec
+++ b/MdePkg/MdePkg.dec
@@ -1006,6 +1006,9 @@ [Ppis]
## Include/Ppi/DelayedDispatch.h
gEfiPeiDelayedDispatchPpiGuid = { 0x869c711d, 0x649c, 0x44fe, { 0x8b, 0x9e, 0x2c, 0xbb, 0x29, 0x11, 0xc3, 0xe6 }}

+ ## Include/Ppi/MmCommunication3.h
+ gEfiPeiMmCommunication3PpiGuid = { 0xe70febf6, 0x13ef, 0x4a21, { 0x89, 0x9e, 0xb2, 0x36, 0xf8, 0x25, 0xff, 0xc9 }}
+
[Protocols]
## Include/Protocol/Pcd.h
gPcdProtocolGuid = { 0x11B34006, 0xD85B, 0x4D0A, { 0xA2, 0x90, 0xD5, 0xA5, 0x71, 0x31, 0x0E, 0xF7 }}
--
2.32.0.windows.1


[PATCH v3 3/7] MdePkg: MmCommunication: Introduce EFI_MM_COMMUNICATION3_PROTOCOL to MdePkg

Kun Qin
 

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

This change introduces a new definition for MM communicate protocol v3.

This protocol will be installed under a new GUID in contrast to exisiting
EFI_MM_COMMUNICATION_PROTOCOL.

Data communicated to MM through EFI_MM_COMMUNICATION3_PROTOCOL should
always start with EFI_MM_COMMUNICATE_HEADER_V3 with its HeaderGuid,
Signature and Version fields properly populated.

Cc: Michael D Kinney <michael.d.kinney@...>
Cc: Liming Gao <gaoliming@...>
Cc: Zhiguang Liu <zhiguang.liu@...>
Cc: Hao A Wu <hao.a.wu@...>
Cc: Marvin Häuser <mhaeuser@...>
Cc: Bret Barkelew <Bret.Barkelew@...>
Cc: Michael Kubacki <michael.kubacki@...>

Signed-off-by: Kun Qin <kuqin12@...>
---

Notes:
v3:
- Newly introduced v3 of communicate protocol

MdePkg/Include/Protocol/MmCommunication3.h | 70 ++++++++++++++++++++
MdePkg/MdePkg.dec | 3 +
2 files changed, 73 insertions(+)

diff --git a/MdePkg/Include/Protocol/MmCommunication3.h b/MdePkg/Include/Protocol/MmCommunication3.h
new file mode 100644
index 000000000000..1dfebbdddb5e
--- /dev/null
+++ b/MdePkg/Include/Protocol/MmCommunication3.h
@@ -0,0 +1,70 @@
+/** @file
+ EFI MM Communication Protocol 2 as defined in the PI 1.7 errata A specification.
+
+ This protocol provides a means of communicating between drivers outside of MM and MMI
+ handlers inside of MM.
+
+ Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2019, Arm Limited. All rights reserved.<BR>
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef MM_COMMUNICATION3_H_
+#define MM_COMMUNICATION3_H_
+
+#include <Pi/PiMultiPhase.h>
+
+#define EFI_MM_COMMUNICATION3_PROTOCOL_GUID \
+ { \
+ 0xf7234a14, 0xdf2, 0x46c0, { 0xad, 0x28, 0x90, 0xe6, 0xb8, 0x83, 0xa7, 0x2f } \
+ }
+
+typedef struct _EFI_MM_COMMUNICATION3_PROTOCOL EFI_MM_COMMUNICATION3_PROTOCOL;
+
+/**
+ Communicates with a registered handler.
+
+ This function provides a service to send and receive messages from a registered UEFI service.
+
+ @param[in] This The EFI_MM_COMMUNICATION3_PROTOCOL instance.
+ @param[in, out] CommBufferPhysical Physical address of the MM communication buffer, of which content must
+ start with EFI_MM_COMMUNICATE_HEADER_V3.
+ @param[in, out] CommBufferVirtual Virtual address of the MM communication buffer, of which content must
+ start with EFI_MM_COMMUNICATE_HEADER_V3.
+ @param[in, out] CommSize The size of the data buffer being passed in. On exit, the size of data
+ being returned. Zero if the handler does not wish to reply with any data.
+ This parameter is optional and may be NULL.
+
+ @retval EFI_SUCCESS The message was successfully posted.
+ @retval EFI_INVALID_PARAMETER CommBufferPhysical was NULL or CommBufferVirtual was NULL.
+ @retval EFI_BAD_BUFFER_SIZE The buffer is too large 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.
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_MM_COMMUNICATE3)(
+ IN CONST EFI_MM_COMMUNICATION3_PROTOCOL *This,
+ IN OUT VOID *CommBufferPhysical,
+ IN OUT VOID *CommBufferVirtual,
+ IN OUT UINTN *CommSize OPTIONAL
+ );
+
+///
+/// EFI MM Communication Protocol provides runtime services for communicating
+/// between DXE drivers and a registered MMI handler.
+///
+struct _EFI_MM_COMMUNICATION3_PROTOCOL {
+ EFI_MM_COMMUNICATE3 Communicate;
+};
+
+extern EFI_GUID gEfiMmCommunication3ProtocolGuid;
+
+#endif
diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec
index 411079a4343e..3168534951c1 100644
--- a/MdePkg/MdePkg.dec
+++ b/MdePkg/MdePkg.dec
@@ -1348,6 +1348,9 @@ [Protocols]
## Include/Protocol/MmCommunication2.h
gEfiMmCommunication2ProtocolGuid = { 0x378daedc, 0xf06b, 0x4446, { 0x83, 0x14, 0x40, 0xab, 0x93, 0x3c, 0x87, 0xa3 }}

+ ## Include/Protocol/MmCommunication3.h
+ gEfiMmCommunication3ProtocolGuid = { 0xf7234a14, 0xdf2, 0x46c0, { 0xad, 0x28, 0x90, 0xe6, 0xb8, 0x83, 0xa7, 0x2f }}
+
#
# Protocols defined in UEFI2.1/UEFI2.0/EFI1.1
#
--
2.32.0.windows.1


[PATCH v3 2/7] MdePkg: MmCommunication: Introduce EFI_MM_COMMUNICATE_HEADER_V3 to MdePkg

Kun Qin
 

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

This change introduces a new definition for MM communicate header
structure, intending to provide better portability between different
architectures (IA32 & X64) and adapt to flexible array supported by
modern compilers.

The original MessageLength field of EFI_MM_COMMUNICATE_HEADER, as a
generic definition, was used for both PEI and DXE MM communication. On a
system that supports PEI MM launch, but operates PEI in 32bit mode and MM
foundation in 64bit, the current EFI_MM_COMMUNICATE_HEADER definition
will cause structure parse error due to UINTN used. This introduction
removes the architecture dependent field by defining this field as
UINT64.

The new signature could help identifying whether the data received is
compiliant with this new data structure, which will help for binary
release modules to identify usage of legacy data structure.

Version field is also added to indicate the current version of header in
case there is need for minor modification in the future.

The data field of MM communicate message is replaced with flexible array
to allow users not having to consume extra data during communicate and
author code more intrinsically.

Cc: Michael D Kinney <michael.d.kinney@...>
Cc: Liming Gao <gaoliming@...>
Cc: Zhiguang Liu <zhiguang.liu@...>
Cc: Hao A Wu <hao.a.wu@...>
Cc: Marvin Häuser <mhaeuser@...>
Cc: Bret Barkelew <Bret.Barkelew@...>
Cc: Michael Kubacki <michael.kubacki@...>

Signed-off-by: Kun Qin <kuqin12@...>
---

Notes:
v3:
- Newly introduced communicate v3
- Used flexible arrays [Marvin]
- Added static assert [Michael]

MdePkg/Include/Pi/PiMultiPhase.h | 55 ++++++++++++++++++++
MdePkg/MdePkg.dec | 5 ++
2 files changed, 60 insertions(+)

diff --git a/MdePkg/Include/Pi/PiMultiPhase.h b/MdePkg/Include/Pi/PiMultiPhase.h
index 89280d9d3506..8c60338091b3 100644
--- a/MdePkg/Include/Pi/PiMultiPhase.h
+++ b/MdePkg/Include/Pi/PiMultiPhase.h
@@ -103,6 +103,17 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#define EFI_SMRAM_CLOSED EFI_MMRAM_CLOSED
#define EFI_SMRAM_LOCKED EFI_MMRAM_LOCKED

+///
+/// MM Communicate header constants
+///
+#define COMMUNICATE_HEADER_V3_GUID \
+ { \
+ 0x68e8c853, 0x2ba9, 0x4dd7, { 0x9a, 0xc0, 0x91, 0xe1, 0x61, 0x55, 0xc9, 0x35 } \
+ }
+
+#define EFI_MM_COMMUNICATE_HEADER_V3_SIGNATURE 0x4D434833 // "MCH3"
+#define EFI_MM_COMMUNICATE_HEADER_V3_VERSION 3
+
///
/// Structure describing a MMRAM region and its accessibility attributes.
///
@@ -149,6 +160,48 @@ typedef struct _EFI_MM_RESERVED_MMRAM_REGION {
UINT64 MmramReservedSize;
} EFI_MM_RESERVED_MMRAM_REGION;

+#pragma pack(1)
+
+///
+/// To avoid confusion in interpreting frames, the buffer communicating to MM core through
+/// EFI_MM_COMMUNICATE3 or later should always start with EFI_MM_COMMUNICATE_HEADER_V3.
+///
+typedef struct {
+ ///
+ /// Indicator GUID for MM core that the communication buffer is compliant with this v3 header.
+ /// Must be gCommunicateHeaderV3Guid.
+ ///
+ EFI_GUID HeaderGuid;
+ ///
+ /// Signature to indicate data is compliant with new MM communicate header structure.
+ /// Must be "MCH3".
+ ///
+ UINT32 Signature;
+ ///
+ /// MM communicate data format version, MM foundation entry point should check if incoming
+ /// data is a supported format before proceeding.
+ /// Must be 3.
+ ///
+ UINT32 Version;
+ ///
+ /// Allows for disambiguation of the message format.
+ ///
+ EFI_GUID MessageGuid;
+ ///
+ /// Describes the size of MessageData (in bytes) and does not include the size of the header.
+ ///
+ UINT64 MessageSize;
+ ///
+ /// Designates an array of bytes that is MessageSize in size.
+ ///
+ UINT8 MessageData[];
+} EFI_MM_COMMUNICATE_HEADER_V3;
+
+#pragma pack()
+
+STATIC_ASSERT ((sizeof (EFI_MM_COMMUNICATE_HEADER_V3) == OFFSET_OF (EFI_MM_COMMUNICATE_HEADER_V3, MessageData)), \
+ "sizeof (EFI_MM_COMMUNICATE_HEADER_V3) does not align with the beginning of flexible array MessageData");
+
typedef enum {
EFI_PCD_TYPE_8,
EFI_PCD_TYPE_16,
@@ -208,4 +261,6 @@ EFI_STATUS
IN VOID *ProcedureArgument
);

+extern EFI_GUID gCommunicateHeaderV3Guid;
+
#endif
diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec
index a28a2daaffa8..411079a4343e 100644
--- a/MdePkg/MdePkg.dec
+++ b/MdePkg/MdePkg.dec
@@ -823,6 +823,11 @@ [Guids]
#
gLinuxEfiInitrdMediaGuid = {0x5568e427, 0x68fc, 0x4f3d, {0xac, 0x74, 0xca, 0x55, 0x52, 0x31, 0xcc, 0x68}}

+ #
+ # GUID indicates the MM communication data is compliant with v3 communication header.
+ #
+ gCommunicateHeaderV3Guid = { 0x68e8c853, 0x2ba9, 0x4dd7, { 0x9a, 0xc0, 0x91, 0xe1, 0x61, 0x55, 0xc9, 0x35 } }
+
[Guids.IA32, Guids.X64]
## Include/Guid/Cper.h
gEfiIa32X64ErrorTypeCacheCheckGuid = { 0xA55701F5, 0xE3EF, 0x43de, { 0xAC, 0x72, 0x24, 0x9B, 0x57, 0x3F, 0xAD, 0x2C }}
--
2.32.0.windows.1


[PATCH v3 1/7] EDK2 Code First: PI Specification: New communicate header and interfaces

Kun Qin
 

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

This change includes specification update markdown file that describes
the proposed PI Specification v1.7 Errata A in detail and potential
impact to the existing codebase.

Cc: Michael D Kinney <michael.d.kinney@...>
Cc: Liming Gao <gaoliming@...>
Cc: Zhiguang Liu <zhiguang.liu@...>
Cc: Andrew Fish <afish@...>
Cc: Leif Lindholm <leif@...>
Cc: Hao A Wu <hao.a.wu@...>
Cc: Marvin Häuser <mhaeuser@...>
Cc: Bret Barkelew <Bret.Barkelew@...>

Signed-off-by: Kun Qin <kuqin12@...>
---

Notes:
v3:
- switched to use communicate v3 instead of sprinkle structure updates

CodeFirst/BZ3430-SpecChange.md | 277 ++++++++++++++++++++
1 file changed, 277 insertions(+)

diff --git a/CodeFirst/BZ3430-SpecChange.md b/CodeFirst/BZ3430-SpecChange.md
new file mode 100644
index 000000000000..39a96b9a44f0
--- /dev/null
+++ b/CodeFirst/BZ3430-SpecChange.md
@@ -0,0 +1,277 @@
+# Title: Introduction of `EFI_MM_COMMUNICATE_HEADER_V3` and `MM_COMMUNICATE3_*` interface
+
+## Status: Draft
+
+## Document: UEFI Platform Initialization Specification Version 1.7 Errata A
+
+## License
+
+SPDX-License-Identifier: CC-BY-4.0
+
+## Submitter: [TianoCore Community](https://www.tianocore.org)
+
+## Summary of the change
+
+Introduce `EFI_PEI_MM_COMMUNICATION3_PPI` and `EFI_MM_COMMUNICATE3_PROTOCOL` that works with communication buffer starts with `EFI_MM_COMMUNICATE_HEADER_V3` to provide better portability between different architectures (IA32 & X64) and adapt to flexible array supported by modern compilers.
+
+## Benefits of the change
+
+In PI Spec v1.7 Errata A, Vol.4, Sec 5.7 MM Communication Protocol, the MessageLength field of `EFI_MM_COMMUNICATE_HEADER` (also defined as `EFI_SMM_COMMUNICATE_HEADER`) is defined as type UINTN.
+
+But this structure, as a generic definition, could be used for both PEI and DXE MM communication. Thus for a system that supports PEI Standalone MM launch, but operates PEI in 32bit mode and MM foundation in 64bit, the current `EFI_MM_COMMUNICATE_HEADER` definition will cause structure parse error due to UINTN used.
+
+This proposed data structure resolved it by introducing `EFI_MM_COMMUNICATE_HEADER_V3` that defines the MessageSize as UINT64 to remove data size ambiguity.
+
+The data structure still starts with a `HeaderGuid` field that is typed as `EFI_GUID`. This will be populated as `gCommunicateHeaderV3Guid` or `COMMUNICATE_HEADER_V3_GUID` as an indicator to differentiate new data format vesus legacy format.
+
+Furthermore, the addition of signature could help identifying whether the data received is compiliant with this new data structure, which will help for binary release modules to identify usage of legacy `EFI_MM_COMMUNICATE_HEADER`.
+
+Version field is also added to indicate the current version of header in case there is need for minor modification in the future.
+
+In addition, the data field of MM communicate message is replaced with flexible array to allow users not having to consume extra data during communicate and author code more intrinsically.
+
+On the non-MM environment side, the Standalone MM DXE IPL agent can add installation of `EFI_MM_COMMUNICATE3_PROTOCOL`, while the Standalone MM PEI IPL agent that launches MM foundation should publish and only publish `EFI_PEI_MM_COMMUNICATION3_PPI` for MM communication during PEI phase.
+
+For communication data that starts with `EFI_MM_COMMUNICATE_HEADER_V3`, callers always need to use V3 protocol/PPI to communicate with updated MM cores. These interface introductions instead of replacement can maintain the compatibility for existing codebase while resolving size mismatching occurred during data transfer between different architectures.
+
+## Impact of the change
+
+This change will impact the MM cores and IPLs:
+
+```bash
+MdeModulePkg/Core/PiSmmCore/PiSmmCore
+StandaloneMmPkg/Core/StandaloneMmCore
+MdeModulePkg/Core/PiSmmCore/PiSmmIpl
+```
+
+To cooporate with the newly proposed data format, existing MM cores need to be updated to parse incoming data properly to tell if the data is compliant with new or legacy format.
+
+The existing PiSmmIpl will need to be updated to publish `EFI_MM_COMMUNICATE3_PROTOCOL` for consumers that would like to invoke MMI with new data format.
+
+For potential proprietary IPLs that launches Standalone MM in PEI phase, if any, the PEIM should change to publish `EFI_PEI_MM_COMMUNICATION3_PPI` instead of `EFI_MM_COMMUNICATE_PPI`.
+
+Accordingly, all consumers in PEI phase that communicate to PEI launched Standalone MM should switch to use `EFI_PEI_MM_COMMUNICATION3_PPI` and `EFI_MM_COMMUNICATE_HEADER_V3`.
+
+## Detailed description of the change [normative updates]
+
+### Specification Changes
+
+1. In PI Specification v1.7 Errata A: Vol. 4-1.5.1 Initializing MM Standalone Mode in PEI phase, the last bullet point of step 3 should be changed to:
+
+ ```c
+ Publishes the EFI_PEI_MM_COMMUNICATION3_PPI
+ ```
+
+1. In PI Specification v1.7 Errata A: Vol. 4, section 6.5 MM Communication PPI, add the following:
+
+ ```markdown
+ # EFI_PEI_MM_COMMUNICATION_PPI
+
+ ## Summary
+
+ This PPI provides a means of communicating between drivers outside of MM and MMI handlers inside of MM in PEI phase.
+
+ ## GUID
+
+ #define EFI_PEI_MM_COMMUNICATION3_PPI_GUID \
+ { \
+ 0xe70febf6, 0x13ef, 0x4a21, { 0x89, 0x9e, 0xb2, 0x36, 0xf8, 0x25, 0xff, 0xc9 } \
+ }
+
+ ## PPI Structure
+
+ typedef struct _EFI_PEI_MM_COMMUNICATION3_PPI {
+ EFI_PEI_MM_COMMUNICATE3 Communicate;
+ } EFI_PEI_MM_COMMUNICATION3_PPI;
+
+ ## Members
+
+ ### Communicate
+
+ Sends/receives a message for a registered handler. See the Communicate() function description.
+
+ ## Description
+
+ This PPI provides services for communicating between PEIM and a registered MMI handler.
+
+ # EFI_PEI_MM_COMMUNICATION_PPI.Communicate()
+
+ ## Summary
+ Communicates with a registered handler.
+
+ ## Prototype
+ typedef
+ EFI_STATUS
+ (EFIAPI *EFI_PEI_MM_COMMUNICATE3)(
+ IN CONST EFI_PEI_MM_COMMUNICATION3_PPI *This,
+ IN OUT VOID *CommBuffer,
+ IN OUT UINTN *CommSize
+ );
+
+ ## Parameters
+
+ ### This
+ The EFI_PEI_MM_COMMUNICATE3 instance.
+
+ ### CommBuffer
+
+ Pointer to the buffer to convey into MMRAM.
+
+ ### CommSize
+
+ The size of the data buffer being passed in. On exit, the size of data being returned. Zero if the handler does not wish to reply with any data.
+
+ ## Description
+
+ This function provides a service to send and receive messages from a registered PEI service. The EFI_PEI_MM_COMMUNICATION3_PPI driver is responsible for doing any of the copies such that the data lives in PEI-service-accessible RAM.
+
+ A given implementation of the EFI_PEI_MM_COMMUNICATION3_PPI may choose to use the EFI_MM_CONTROL_PPI for effecting the mode transition, or it may use some other method.
+
+ The agent invoking the communication interface must be physical/virtually 1:1 mapped.
+
+ To avoid confusion in interpreting frames, the CommBuffer parameter should always begin with EFI_MM_COMMUNICATE_HEADER_V3. The header data is mandatory for messages sent into the MM agent.
+
+ Once inside of MM, the MM infrastructure will call all registered handlers with the same HandlerType as the GUID specified by HeaderGuid and the CommBuffer pointing to Data.
+
+ This function is not reentrant.
+
+ ## Status Codes Returned
+ EFI_SUCCESS The message was successfully posted.
+ EFI_INVALID_PARAMETER The CommBuffer was NULL.
+ ```
+
+1. In PI Specification v1.7 Errata A: Vol. 4, section 6.5 MM Communication PPI, add the following:
+
+ ```markdown
+ # EFI_MM_COMMUNICATION3_PROTOCOL
+
+ ## Summary
+
+ This protocol provides a means of communicating between drivers outside of MM and MMI handlers inside of MM, for communication buffer that is compliant with EFI_MM_COMMUNICATE_HEADER_V3.
+
+ ## GUID
+
+ #define EFI_MM_COMMUNICATION3_PROTOCOL_GUID \
+ { \
+ 0xf7234a14, 0xdf2, 0x46c0, { 0xad, 0x28, 0x90, 0xe6, 0xb8, 0x83, 0xa7, 0x2f } \
+ }
+
+ ## Prototype
+ typedef struct _EFI_MM_COMMUNICATION3_PROTOCOL {
+ EFI_MM_COMMUNICATE3 Communicate;
+ } EFI_MM_COMMUNICATION3_PROTOCOL;
+
+ ## Members
+
+ ### Communicate
+
+ Sends/receives a message for a registered handler. See the Communicate() function description.
+
+ ## Description
+
+ This protocol provides runtime services for communicating between DXE drivers and a registered MMI handler.
+
+ # EFI_MM_COMMUNICATION3_PROTOCOL.Communicate()
+
+ ## Summary
+
+ Communicates with a registered handler.
+
+ ## Prototype
+
+ typedef
+ EFI_STATUS
+ (EFIAPI *EFI_MM_COMMUNICATE3)(
+ IN CONST EFI_MM_COMMUNICATION3_PROTOCOL *This,
+ IN OUT VOID *CommBufferPhysical,
+ IN OUT VOID *CommBufferVirtual,
+ IN OUT UINTN *CommSize OPTIONAL
+ );
+
+ ## Parameters
+
+ ### This
+
+ The EFI_MM_COMMUNICATION3_PROTOCOL instance.
+
+ ### CommBufferPhysical
+
+ Physical address of the buffer to convey into MMRAM, of which content must start with EFI_MM_COMMUNICATE_HEADER_V3.
+
+ ### CommBufferVirtual
+
+ Virtual address of the buffer to convey into MMRAM, of which content must start with EFI_MM_COMMUNICATE_HEADER_V3.
+
+ ### CommSize
+
+ The size of the data buffer being passed in. On exit, the size of data being returned. Zero if the handler does not wish to reply with any data. This parameter is optional and may be NULL.
+
+ ## Description
+
+ Usage is similar to EFI_MM_COMMUNICATION_PROTOCOL.Communicate() except for the notes below:
+
+ * Communication buffer transfer to MM core should start with EFI_MM_COMMUNICATE_HEADER_V3.
+ * Instead of passing just the physical address via the CommBuffer parameter, the caller must pass both the physical and the virtual addresses of the communication buffer.
+ * If no virtual remapping has taken place, the physical address will be equal to the virtual address, and so the caller is required to pass the same value for both parameters.
+
+ ## Related Definitions
+ typedef struct {
+ EFI_GUID HeaderGuid;
+ UINT32 Signature;
+ UINT32 Version;
+ EFI_GUID MessageGuid;
+ UINT64 MessageSize;
+ UINT8 MessageData[ANYSIZE_ARRAY];
+ } EFI_MM_COMMUNICATE_HEADER_V3;
+
+ #define COMMUNICATE_HEADER_V3_GUID \
+ { \
+ 0x68e8c853, 0x2ba9, 0x4dd7, { 0x9a, 0xc0, 0x91, 0xe1, 0x61, 0x55, 0xc9, 0x35 } \
+ }
+
+ #define EFI_MM_COMMUNICATE_HEADER_V3_SIGNATURE 0x4D434833 // "MCH3"
+ #define EFI_MM_COMMUNICATE_HEADER_V3_VERSION 3
+
+ ### HeaderGuid
+
+ Indicator GUID for MM core that the communication buffer is compliant with this v3 header. Must be COMMUNICATE_HEADER_V3_GUID.
+
+ ### Signature
+
+ Signature to indicate data is compliant with new MM communicate header structure. Must be "MCH3".
+
+ ### Version
+
+ MM communicate data format version, MM foundation entry point should check if incoming data is a supported format before proceeding. Must be 3.
+
+ ### MessageGuid
+
+ Allows for disambiguation of the message format.
+
+ ### MessageSize
+
+ Describes the size of MessageData (in bytes) and does not include the size of the header.
+
+ ### MessageData
+
+ Designates an array of bytes that is MessageSize in size.
+
+ ## Status Codes Returned
+
+ EFI_SUCCESS The message was successfully posted.
+ EFI_INVALID_PARAMETER CommBufferPhysical was NULL or CommBufferVirtual was NULL.
+ EFI_BAD_BUFFER_SIZE The buffer is too large 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.
+ EFI_ACCESS_DENIED The CommunicateBuffer parameter or CommSize parameter, if not omitted, are in address range that cannot be accessed by the MM environment.
+ ```
+
+### Code Changes
+
+1. Add data structure and its related definitions in `MdePkg/Include/Pi/PiMultiPhase.h` to match new definition.
+
+1. Add interface definition of `MdePkg/Include/Protocol/MmCommunication3.h` and `MdePkg/Include/Protocol/MmCommunication3.h`, respectively, to match newly proposed interfaces.
+
+1. Extend PiSmmCore to inspect `HeaderGuid` of incoming communication data. If it matches `COMMUNICATE_HEADER_V3_GUID`, parse the incoming data to start with `EFI_MM_COMMUNICATE_HEADER_V3`, otherwise it will be parse as existing way.
+
+1. Extend StandaloneMmCore to inspect `HeaderGuid` of incoming communication data. If it matches `COMMUNICATE_HEADER_V3_GUID`, parse the incoming data to start with `EFI_MM_COMMUNICATE_HEADER_V3`, otherwise it will be parse as existing way.
+
+1. Extend PiSmmIpl to publish `EFI_MM_COMMUNICATION3_PROTOCOL`, the implementation of `EFI_MM_COMMUNICATION3_PROTOCOL.Communicate()` should parse the incoming data as it starts with `EFI_MM_COMMUNICATE_HEADER_V3`, when applicable.
--
2.32.0.windows.1


[PATCH v3 0/7] New MM Communicate header and interfaces

Kun Qin
 

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

This patch series is a follow up of previous submission:
https://edk2.groups.io/g/devel/message/77017

Since the submission of previous patch series, there were suggestions
made to change the entire existing MM communicate header in order to
leverage compilers to catch all potential code that referenced the
original header.

However, although such header structure and/or name change would break
compilers, there are cases where the OFFSET_OF Data fields is calculated
without involving the header structure at all.

Thus patch series v3 introduced MM communicate interface v3 (both
protocol and PPI) to consume the corresponding new header structure. The
new structure fixed ambiguious data field size caused by UINTN, as well
as integrated flexible arrays for data fields, while maintaining the
backwards compatibility for all existing codebases. A specified GUID is
used to differentiate old MM headers from newly defined v3 header.

The specification change is also included in this patch series v3, where
the standalone MM IPL in PEI phase is specified to install new PPI v3
after setting MM foundation.

v3 patch changes include feedback for v1 series:
a. Introduced v3 MM comminucate protocol and PPI;
b. Applied flexible arrays to new communicate header structures;

Patch v3 branch: https://github.com/kuqin12/edk2/tree/BZ3398-MmCommunicate-Length-v3

Cc: Michael D Kinney <michael.d.kinney@...>
Cc: Liming Gao <gaoliming@...>
Cc: Zhiguang Liu <zhiguang.liu@...>
Cc: Andrew Fish <afish@...>
Cc: Leif Lindholm <leif@...>
Cc: Hao A Wu <hao.a.wu@...>
Cc: Marvin Häuser <mhaeuser@...>
Cc: Bret Barkelew <Bret.Barkelew@...>
Cc: Michael Kubacki <michael.kubacki@...>
Cc: Ard Biesheuvel <ardb+tianocore@...>
Cc: Sami Mujawar <sami.mujawar@...>
Cc: Jiewen Yao <jiewen.yao@...>
Cc: Supreeth Venkatesh <supreeth.venkatesh@...>
Cc: Jian J Wang <jian.j.wang@...>
Cc: Eric Dong <eric.dong@...>
Cc: Ray Ni <ray.ni@...>

Kun Qin (7):
EDK2 Code First: PI Specification: New communicate header and
interfaces
MdePkg: MmCommunication: Introduce EFI_MM_COMMUNICATE_HEADER_V3 to
MdePkg
MdePkg: MmCommunication: Introduce EFI_MM_COMMUNICATION3_PROTOCOL to
MdePkg
MdePkg: MmCommunication: Introduce EFI_PEI_MM_COMMUNICATION3_PPI to
MdePkg
MdeModulePkg: PiSmmCore: Added parser of new MM communicate header
StandaloneMmPkg: StandaloneMmCore: Parsing new MM communicate header
MdeModulePkg: PiSmmIpl: Update MessageLength calculation for
MmCommunicate

MdeModulePkg/Core/PiSmmCore/PiSmmCore.c | 42 ++-
MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c | 187 +++++++++++++
StandaloneMmPkg/Core/StandaloneMmCore.c | 34 ++-
CodeFirst/BZ3430-SpecChange.md | 277 ++++++++++++++++++++
MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf | 1 +
MdeModulePkg/Core/PiSmmCore/PiSmmIpl.inf | 2 +
MdePkg/Include/Pi/PiMultiPhase.h | 55 ++++
MdePkg/Include/Ppi/MmCommunication3.h | 58 ++++
MdePkg/Include/Protocol/MmCommunication3.h | 70 +++++
MdePkg/MdePkg.dec | 11 +
StandaloneMmPkg/Core/StandaloneMmCore.inf | 1 +
11 files changed, 720 insertions(+), 18 deletions(-)
create mode 100644 CodeFirst/BZ3430-SpecChange.md
create mode 100644 MdePkg/Include/Ppi/MmCommunication3.h
create mode 100644 MdePkg/Include/Protocol/MmCommunication3.h

--
2.32.0.windows.1


Cancelled Event: TianoCore Bug Triage - APAC / NAMO - Tuesday, August 17, 2021 #cal-cancelled

devel@edk2.groups.io Calendar <noreply@...>
 

Cancelled: TianoCore Bug Triage - APAC / NAMO

This event has been cancelled.

When:
Tuesday, August 17, 2021
6:30pm to 7:30pm
(UTC-07:00) America/Los Angeles

Where:
https://teams.microsoft.com/l/meetup-join/19%3ameeting_OTUyZTg2NjgtNDhlNS00ODVlLTllYTUtYzg1OTNjNjdiZjFh%40thread.v2/0?context=%7b%22Tid%22%3a%2246c98d88-e344-4ed4-8496-4ed7712e255d%22%2c%22Oid%22%3a%22b286b53a-1218-4db3-bfc9-3d4c5aa7669e%22%7d

Organizer: Liming Gao gaoliming@...

Description:

TianoCore Bug Triage - APAC / NAMO

Hosted by Liming Gao

 

________________________________________________________________________________

Microsoft Teams meeting

Join on your computer or mobile app

Click here to join the meeting

Join with a video conferencing device

teams@...

Video Conference ID: 116 062 094 0

Alternate VTC dialing instructions

Or call in (audio only)

+1 916-245-6934,,77463821#   United States, Sacramento

Phone Conference ID: 774 638 21#

Find a local number | Reset PIN

Learn More | Meeting options


回复: [edk2-devel] Event: TianoCore Bug Triage - APAC / NAMO - 08/17/2021 #cal-reminder

gaoliming
 

Few new issues are submitted this week. Let’s cancel the meeting.

 

3549

EDK2

Code

unassigned@...

UNCO

VS2017 build tool compiler flags in StdLib.inc needs to be aligned with the VS2015 compiler flags to ignore certain warnings

2021-08-10

n.jayaprakash@...

3542

EDK2

Code

unassigned@...

UNCO

[MdePkg/BaseLib] Unaligned APIs cannot be called safely

2021-08-09

mhaeuser@...

3528

EDK2

Code

unassigned@...

UNCO

Add SMM NV variable support in universal UEFI payload

2021-08-05

guo.dong@...

3524

Tianocor

Code

unassigned@...

UNCO

Update Openssl to the latest version 1.1.1k

2021-08-03

gaoliming@...

 

Thanks

Liming

 

发件人: devel@edk2.groups.io <devel@edk2.groups.io> 代表 devel@edk2.groups.io Calendar
发送时间: 2021817 9:30
收件人: devel@edk2.groups.io
主题: [edk2-devel] Event: TianoCore Bug Triage - APAC / NAMO - 08/17/2021 #cal-reminder

 

Reminder: TianoCore Bug Triage - APAC / NAMO

When:
08/17/2021
6:30pm to 7:30pm
(UTC-07:00) America/Los Angeles

Where:
https://teams.microsoft.com/l/meetup-join/19%3ameeting_OTUyZTg2NjgtNDhlNS00ODVlLTllYTUtYzg1OTNjNjdiZjFh%40thread.v2/0?context=%7b%22Tid%22%3a%2246c98d88-e344-4ed4-8496-4ed7712e255d%22%2c%22Oid%22%3a%22b286b53a-1218-4db3-bfc9-3d4c5aa7669e%22%7d

Organizer: Liming Gao gaoliming@...

View Event

Description:

TianoCore Bug Triage - APAC / NAMO

Hosted by Liming Gao

 

________________________________________________________________________________

Microsoft Teams meeting

Join on your computer or mobile app

Click here to join the meeting

Join with a video conferencing device

teams@...

Video Conference ID: 116 062 094 0

Alternate VTC dialing instructions

Or call in (audio only)

+1 916-245-6934,,77463821#   United States, Sacramento

Phone Conference ID: 774 638 21#

Find a local number | Reset PIN

Learn More | Meeting options


Event: TianoCore Bug Triage - APAC / NAMO - 08/17/2021 #cal-reminder

devel@edk2.groups.io Calendar <noreply@...>
 

Reminder: TianoCore Bug Triage - APAC / NAMO

When:
08/17/2021
6:30pm to 7:30pm
(UTC-07:00) America/Los Angeles

Where:
https://teams.microsoft.com/l/meetup-join/19%3ameeting_OTUyZTg2NjgtNDhlNS00ODVlLTllYTUtYzg1OTNjNjdiZjFh%40thread.v2/0?context=%7b%22Tid%22%3a%2246c98d88-e344-4ed4-8496-4ed7712e255d%22%2c%22Oid%22%3a%22b286b53a-1218-4db3-bfc9-3d4c5aa7669e%22%7d

Organizer: Liming Gao gaoliming@...

View Event

Description:

TianoCore Bug Triage - APAC / NAMO

Hosted by Liming Gao

 

________________________________________________________________________________

Microsoft Teams meeting

Join on your computer or mobile app

Click here to join the meeting

Join with a video conferencing device

teams@...

Video Conference ID: 116 062 094 0

Alternate VTC dialing instructions

Or call in (audio only)

+1 916-245-6934,,77463821#   United States, Sacramento

Phone Conference ID: 774 638 21#

Find a local number | Reset PIN

Learn More | Meeting options


Re: [PATCH V2 2/3] MdePkg/Base.h: Introduce various alignment-related macros

Ni, Ray
 

I don't have better names.

Reviewed-by: Ray Ni <ray.ni@...>

-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Marvin Häuser
Sent: Monday, August 16, 2021 9:10 PM
To: devel@edk2.groups.io; Ni, Ray <ray.ni@...>
Cc: Kinney, Michael D <michael.d.kinney@...>; Liming Gao <gaoliming@...>; Liu, Zhiguang
<zhiguang.liu@...>; Vitaly Cheptsov <vit9696@...>
Subject: Re: [edk2-devel] [PATCH V2 2/3] MdePkg/Base.h: Introduce various alignment-related macros

Hey Ray,

On 16/08/2021 11:42, Ni, Ray wrote:
Marvin,
So lucky to have you in the edk2 project looking into these fundamentals!
Thank you. :)

+ #define ALIGNOF(TYPE) OFFSET_OF (struct { CHAR8 C; TYPE A; }, A)

1. Does struct{} inside a macro conform to C standard? How is the compatibility with different compilers?
This should work, yes. The C standard defines offsetof as such:

"The macros are [...]

        offsetof(type, member-designator)

which expands to an integer constant expression that has type size_t,
the value of
which is the offset in bytes, to the structure member (designated by
member-designator),
from the beginning of its structure (designated by type). The type and
member designator
shall be such that given

        static type t;

then the expression &(t.member-designator) evaluates to an address
constant. [...]" [1]

If we plug in t:

        static struct { CHAR8 C; TYPE A; } t;

we get a valid static storage duration variable declaration that
satisfies the the last condition because:

"An address constant is [...], a pointer to an lvalue designating an
object of static
storage duration, or [...]" [2]

It worked with all compilers I tinkered with at https://godbolt.org/
I sadly do not have access to any of the compilers where this may be
used effectively (RVCT, EBC).

+#define IS_POW2(Value) ((Value) != 0U && ((Value) & ((Value) - 1U)) ==
+0U)

2. Good to me. I learned this trick when implementing the MtrrLib.

+#define ALIGN_VALUE_ADDEND(Value, Alignment) (((Alignment) - (Value))
+& ((Alignment) - 1U))

3. Is any other open source project using the same macro for the addend?
This is actually a general question to all new macros.
I would like the macros look familiar to developers from other open source projects.
Good question, I never really saw it. I only came up with it because for
the new PE loader, we may align the PE memory within an underaligned
buffer, and for that we need the addend. I initially used to align up
and then subtract, but I saw this could be simplified with
ALIGN_VALUE_ADDEND, which was used in ALIGN_VALUE anyway. If you have a
better name, I'll change it.

Best regards,
Marvin


[1] ISO/IEC 9899:2011, 7.19, 3.

[2] ISO/IEC 9899:2011, 6.6, 9.








15301 - 15320 of 94636