Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upl #10570

Draft
wants to merge 28 commits into
base: master
Choose a base branch
from
Draft

Upl #10570

Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
e925cdf
MdeModulePkg: HobPrintLib: Fix CPU HOB format specifiers
benjamindoron Oct 18, 2024
f07203a
UefiPayloadPkg: Fix FIT image's FDT property names
benjamindoron Oct 18, 2024
eb915bc
UefiPayloadPkg: Fix unnecessary arch-specific DSC lines and bugs
benjamindoron Oct 28, 2024
fde5dec
UefiPayloadPkg: HobParseLib: Strip down library's imports
benjamindoron Oct 28, 2024
f9d008c
UefiPayloadPkg: CustomFdtNodeParserLib: Make "hoblistptr" optional
benjamindoron Oct 28, 2024
891f0ba
UefiPayloadPkg: FdtParserLib: Don't accept reserved-memory
benjamindoron Oct 28, 2024
1fda1d0
UefiPayloadPkg: FdtParserLib: Improve handling of cross-node dependency
benjamindoron Oct 28, 2024
748ed6a
UefiPayloadPkg: FdtParserLib: Handling "serial" FDT nodes
benjamindoron Oct 28, 2024
0b6e89e
UefiPayloadPkg: FdtParserLib: Cleanup the function a little
benjamindoron Oct 28, 2024
30a676b
UefiPayloadPkg: "load" property should reflect image, not whole FIT
benjamindoron Dec 10, 2024
00815b4
UefiPayloadPkg: FdtParserLib: Make "pci-rb" optional
benjamindoron Dec 10, 2024
a769797
UefiPayloadPkg: Add support for finding FVs in the UPL FDT
benjamindoron Dec 12, 2024
de74337
UefiPayloadPkg: Change "entry-start" prop to "entry"
benjamindoron Dec 17, 2024
cf49140
DNM: UefiPayloadPkg: FdtParserLib: Support coreboot memory nodes
benjamindoron Oct 28, 2024
fb56700
Tianocore: Move libfdt to the latest version
sjg20 Dec 25, 2024
71bf1a3
UefiPayloadPkg: Convert to use Fdt class
sjg20 Dec 25, 2024
50583c8
UefiPayloadPkg: Set the loadables property
sjg20 Dec 25, 2024
8c92b74
UefiPayloadPkg: Use the correct 'firmware' type
sjg20 Dec 25, 2024
da883d0
UefiPayloadPkg: Set the OS type
sjg20 Dec 25, 2024
510d4ff
UefiPayloadPkg: Use i386 for the architecture
sjg20 Dec 25, 2024
b16de57
UefiPayloadPkg: Raise an exception on error
sjg20 Dec 25, 2024
98be596
UefiPayloadPkg: Correct data-offset property
sjg20 Dec 26, 2024
cc71486
UefiPayloadPkg: Set the architecture type
sjg20 Dec 26, 2024
b8196d1
UefiPayloadPkg: Improve debugging messages in CustomFdtNodeParserLib
sjg20 Jan 3, 2025
4bea365
UefiPayloadPkg: Use UPL description rather than name
sjg20 Jan 3, 2025
14e69b8
UefiPayloadPkg: Fix up serial debugging
sjg20 Jan 3, 2025
6b96c9e
UefiPayloadPkg: Use an assumed FIT totalsize of 4K
sjg20 Dec 29, 2024
3826c86
WIP: Debugging
sjg20 Dec 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions UefiPayloadPkg/Tools/MkFitImage.py
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is going to break PayloadLoaderPeim and coreboot. If the changes have to be made, I'll likely be making coreboot's, but please sync this with FitPayloadLoaderPeim. This is also getting hard to read, (well, harder, after what I did to load) and I'm not sure if we can avoid that

Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ def BuildFvImageNode(Fdt, InfoHeader, ParentNode, DataOffset, DataSize, Descript
Fdt.setprop_str(ParentNode, 'project', 'tianocore')
Fdt.setprop_str(ParentNode, 'arch',Arch)
Fdt.setprop_str(ParentNode, 'type', 'firmware')
Fdt.setprop_u64(ParentNode, 'load', InfoHeader.LoadAddr + DataOffset - InfoHeader.DataOffset)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FVs aren't place-specific. Do we need a load property if we don't care?

Fdt.setprop_str(ParentNode, 'description', Description)

def BuildTianoImageNode(Fdt, InfoHeader, ParentNode, DataOffset, DataSize, Description, Arch):
Expand All @@ -79,7 +80,7 @@ def BuildTianoImageNode(Fdt, InfoHeader, ParentNode, DataOffset, DataSize, Descr
if InfoHeader.DataSize is not None:
Fdt.setprop_u32(ParentNode, 'data-size', DataSize)
if InfoHeader.DataOffset is not None:
Fdt.setprop_u32(ParentNode, 'data-offset', DataOffset)
Fdt.setprop_u32(ParentNode, 'data-offset', DataOffset - InfoHeader.DataOffset)
if InfoHeader.Producer is not None:
Fdt.setprop_str(ParentNode, 'producer', InfoHeader.Producer)
if InfoHeader.Capabilities is not None:
Expand Down Expand Up @@ -170,7 +171,7 @@ def MakeFitImage(InfoHeader, Arch):
#
return BuildFitImage(Fdt, InfoHeader, Arch)

def ReplaceFv (UplBinary, SectionFvFile, SectionName, Arch):
def ReplaceFv (UplBinary, SectionFvFile, SectionName, Arch, DataOffset):
try:
#
# Get Original Multi Fv
Expand Down Expand Up @@ -198,7 +199,7 @@ def ReplaceFv (UplBinary, SectionFvFile, SectionName, Arch):
MultiFvList = []
for Item in LoadablesList:
ImageNode = libfdt.fdt_subnode_offset(NewFitHeader, ImagesNode, Item)
ImageOffset = int.from_bytes (libfdt.fdt_getprop (NewFitHeader, ImageNode, 'data-offset')[0], 'big')
ImageOffset = int.from_bytes (libfdt.fdt_getprop (NewFitHeader, ImageNode, 'data-offset')[0], 'big') + DataOffset
ImageSize = int.from_bytes (libfdt.fdt_getprop (NewFitHeader, ImageNode, 'data-size')[0], 'big')
MultiFvList.append ([Item, Dtb[ImageOffset:ImageOffset + ImageSize]])

Expand Down Expand Up @@ -229,9 +230,9 @@ def ReplaceFv (UplBinary, SectionFvFile, SectionName, Arch):
else:
for Index in range (0, len (MultiFvList)):
ImageNode = libfdt.fdt_subnode_offset(NewFitHeader, ImagesNode, MultiFvList[Index][0])
ImageOffset = int.from_bytes (libfdt.fdt_getprop (NewFitHeader, ImageNode, 'data-offset')[0], 'big')
ImageOffset = int.from_bytes (libfdt.fdt_getprop (NewFitHeader, ImageNode, 'data-offset')[0], 'big') + DataOffset
if ImageOffset > ReplaceOffset:
libfdt.fdt_setprop_u32(NewFitHeader, ImageNode, 'data-offset', ImageOffset + OffsetDelta)
libfdt.fdt_setprop_u32(NewFitHeader, ImageNode, 'data-offset', ImageOffset + OffsetDelta - DataOffset)

ConfNodes = libfdt.fdt_subnode_offset(NewFitHeader, 0, 'configurations')
libfdt.fdt_setprop(NewFitHeader, ConfNodes, 'default', bytes('conf-1', 'utf-8'), len('conf-1') + 1)
Expand All @@ -244,7 +245,7 @@ def ReplaceFv (UplBinary, SectionFvFile, SectionName, Arch):
#
ImagesNode = libfdt.fdt_subnode_offset(NewFitHeader, 0, 'images')
TianoNode = libfdt.fdt_subnode_offset(NewFitHeader, ImagesNode, 'tianocore')
TianoOffset = int.from_bytes (libfdt.fdt_getprop (NewFitHeader, TianoNode, 'data-offset')[0], 'big')
TianoOffset = int.from_bytes (libfdt.fdt_getprop (NewFitHeader, TianoNode, 'data-offset')[0], 'big') + DataOffset
TianoSize = int.from_bytes (libfdt.fdt_getprop (NewFitHeader, TianoNode, 'data-size')[0], 'big')
TianoBinary = Dtb[TianoOffset:TianoOffset + TianoSize]

Expand All @@ -256,7 +257,7 @@ def ReplaceFv (UplBinary, SectionFvFile, SectionName, Arch):
NewUplBinary[len(NewFitHeader):len(NewFitHeader) + len(TianoBinary)] = TianoBinary
for Index in range (0, len (MultiFvList)):
ImageNode = libfdt.fdt_subnode_offset(NewFitHeader, ImagesNode, MultiFvList[Index][0])
ImageOffset = int.from_bytes (libfdt.fdt_getprop (NewFitHeader, ImageNode, 'data-offset')[0], 'big')
ImageOffset = int.from_bytes (libfdt.fdt_getprop (NewFitHeader, ImageNode, 'data-offset')[0], 'big') + DataOffset
ImageSize = int.from_bytes (libfdt.fdt_getprop (NewFitHeader, ImageNode, 'data-size')[0], 'big')
NewUplBinary[ImageOffset:ImageOffset + ImageSize] = MultiFvList[Index][1]
print("Update " + MultiFvList[Index][0] + "\t\t to " + str(hex(ImageOffset)) + "\t ~ " + str(hex(ImageOffset + ImageSize)))
Expand Down
7 changes: 5 additions & 2 deletions UefiPayloadPkg/UniversalPayloadBuild.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ def __init__(self):
self.ImageId = b'UEFI'
self.ProducerId = b'INTEL'

# Start of image data in FIT
DATA_OFFSET = 0x1000

def ValidateSpecRevision (Argument):
try:
(MajorStr, MinorStr) = Argument.split('.')
Expand Down Expand Up @@ -239,7 +242,7 @@ def BuildUniversalPayload(Args):
fit_image_info_header.BdsfvPath = BdsFvOutputDir
fit_image_info_header.SecfvPath = SecFvOutputDir
fit_image_info_header.NetworkfvPath = NetworkFvOutputDir
fit_image_info_header.DataOffset = 0x1000
fit_image_info_header.DataOffset = DATA_OFFSET
fit_image_info_header.LoadAddr = Args.LoadAddress
fit_image_info_header.Project = 'tianocore'

Expand Down Expand Up @@ -347,7 +350,7 @@ def ReplaceFv (UplBinary, SectionFvFile, SectionName, Arch):
return ElfFv.ReplaceFv (UplBinary, SectionFvFile, '.upld.{}'.format (SectionName))
else:
import Tools.MkFitImage as MkFitImage
return MkFitImage.ReplaceFv (UplBinary, SectionFvFile, SectionName, Arch)
return MkFitImage.ReplaceFv (UplBinary, SectionFvFile, SectionName, Arch, DATA_OFFSET)

if (UniversalPayloadBinary != None):
for (SectionName, SectionFvFile) in MultiFvList:
Expand Down