From 6fc6656b7bf8455102796c8edfeef1e3acf7354f Mon Sep 17 00:00:00 2001 From: BigfootACA Date: Thu, 10 Feb 2022 02:16:07 +0800 Subject: [PATCH] sdm845Pkg: Library: SimpleInit: add fdt parser --- .gitmodules | 3 - build.sh | 10 +-- sdm845Pkg/CommonDsc.dsc.inc | 2 +- sdm845Pkg/Devices/beryllium.dsc | 5 +- sdm845Pkg/Devices/dipper.dsc | 5 +- sdm845Pkg/Devices/enchilada.dsc | 5 +- sdm845Pkg/Devices/fajita.dsc | 5 +- sdm845Pkg/Devices/odin-base.dsc | 5 +- sdm845Pkg/Devices/perseus.dsc | 5 +- sdm845Pkg/Devices/polaris.dsc | 5 +- sdm845Pkg/Include/Library/FdtParserLib.h | 71 +++++++++++++++++++ .../PlatformBootManagerLib.inf | 1 + sdm845Pkg/Library/SimpleInit | 2 +- sdm845Pkg/Library/StdLib | 1 - sdm845Pkg/sdm845Pkg.dec | 2 - 15 files changed, 103 insertions(+), 24 deletions(-) create mode 100644 sdm845Pkg/Include/Library/FdtParserLib.h delete mode 160000 sdm845Pkg/Library/StdLib diff --git a/.gitmodules b/.gitmodules index 85cbb5b..bd78f7c 100644 --- a/.gitmodules +++ b/.gitmodules @@ -10,9 +10,6 @@ [submodule "sdm845Pkg/AcpiTables"] path = sdm845Pkg/AcpiTables url = https://git.renegade-project.org/edk2-sdm845-acpi.git -[submodule "sdm845Pkg/Library/StdLib"] - path = sdm845Pkg/Library/StdLib - url = https://github.com/edk2-porting/edk2-libc.git [submodule "sdm845Pkg/Library/SimpleInit"] path = sdm845Pkg/Library/SimpleInit url = https://github.com/BigfootACA/simple-init.git diff --git a/build.sh b/build.sh index e9fa610..06d20a3 100755 --- a/build.sh +++ b/build.sh @@ -141,7 +141,6 @@ then set -e then git submodule set-url edk2 https://github.com.cnpmjs.org/tianocore/edk2.git git submodule set-url edk2-platforms https://github.com.cnpmjs.org/tianocore/edk2-platforms.git git submodule set-url sdm845Pkg/Binary https://github.com.cnpmjs.org/edk2-porting/edk2-sdm845-binary.git - git submodule set-url sdm845Pkg/Library/StdLib https://github.com.cnpmjs.org/edk2-porting/edk2-libc.git git submodule set-url sdm845Pkg/Library/SimpleInit https://github.com.cnpmjs.org/BigfootACA/simple-init.git git submodule init;git submodule update --depth 1 pushd edk2 @@ -181,12 +180,6 @@ do if [ -n "${i}" ]&&[ -f "${i}/edksetup.sh" ] break fi done -for i in "${EDK2_LIBC}" sdm845Pkg/Library/StdLib ./edk2-libc ../edk2-libc -do if [ -n "${i}" ]&&[ -d "${i}/StdLib" ] - then _EDK2_LIBC="$(realpath "${i}")" - break - fi -done for i in "${EDK2_PLATFORMS}" ./edk2-platforms ../edk2-platforms do if [ -n "${i}" ]&&[ -d "${i}/Platform" ] then _EDK2_PLATFORMS="$(realpath "${i}")" @@ -200,7 +193,6 @@ do if [ -n "${i}" ]&&[ -f "${i}/SimpleInit.inc" ] fi done [ -n "${_EDK2}" ]||_error "EDK2 not found, please see README.md" -[ -n "${_EDK2_LIBC}" ]||_error "EDK2-LibC not found, please see README.md" [ -n "${_EDK2_PLATFORMS}" ]||_error "EDK2 Platforms not found, please see README.md" [ -n "${_SIMPLE_INIT}" ]||_error "SimpleInit not found, please see README.md" echo "EDK2 Path: ${_EDK2}" @@ -208,7 +200,7 @@ echo "EDK2_PLATFORMS Path: ${_EDK2_PLATFORMS}" export CROSS_COMPILE="${CROSS_COMPILE:-aarch64-linux-gnu-}" export GCC5_AARCH64_PREFIX="${CROSS_COMPILE}" export CLANG38_AARCH64_PREFIX="${CROSS_COMPILE}" -export PACKAGES_PATH="$_EDK2:$_EDK2_PLATFORMS:$_EDK2_LIBC:$_SIMPLE_INIT:$PWD" +export PACKAGES_PATH="$_EDK2:$_EDK2_PLATFORMS:$_SIMPLE_INIT:$PWD" export WORKSPACE="${PWD}/workspace" GITCOMMIT="$(git describe --tags --always)"||GITCOMMIT="unknown" export GITCOMMIT diff --git a/sdm845Pkg/CommonDsc.dsc.inc b/sdm845Pkg/CommonDsc.dsc.inc index 139cc9d..db0c569 100644 --- a/sdm845Pkg/CommonDsc.dsc.inc +++ b/sdm845Pkg/CommonDsc.dsc.inc @@ -14,7 +14,7 @@ # !include MdePkg/MdeLibs.dsc.inc -!include sdm845Pkg/Library/SimpleInit/SimpleInit-EDK2.inc +!include sdm845Pkg/Library/SimpleInit/SimpleInit.inc [LibraryClasses.common] !if $(TARGET) == RELEASE diff --git a/sdm845Pkg/Devices/beryllium.dsc b/sdm845Pkg/Devices/beryllium.dsc index 61ad42c..78d8e13 100644 --- a/sdm845Pkg/Devices/beryllium.dsc +++ b/sdm845Pkg/Devices/beryllium.dsc @@ -12,7 +12,7 @@ !include sdm845Pkg/sdm845Pkg.dsc [BuildOptions.common] - GCC:*_*_AARCH64_CC_FLAGS = -DDISPLAY_DPI=440 -DENABLE_SIMPLE_INIT -DENABLE_LINUX_SIMPLE_MASS_STORAGE + GCC:*_*_AARCH64_CC_FLAGS = -DENABLE_SIMPLE_INIT -DENABLE_LINUX_SIMPLE_MASS_STORAGE [PcdsFixedAtBuild.common] @@ -24,6 +24,9 @@ gsdm845PkgTokenSpaceGuid.PcdDeviceProduct|"Poco F1" gsdm845PkgTokenSpaceGuid.PcdDeviceCodeName|"beryllium" + # Simple Init + gSimpleInitTokenSpaceGuid.PcdGuiDefaultDPI|440 + #uncomment section underneath and comment out the above section to use full display, including the notch gsdm845PkgTokenSpaceGuid.PcdMipiFrameBufferPixelBpp|32|UINT32|0x0000a403 gsdm845PkgTokenSpaceGuid.PcdMipiFrameBufferVisibleWidth|1080|UINT32|0x0000a404 diff --git a/sdm845Pkg/Devices/dipper.dsc b/sdm845Pkg/Devices/dipper.dsc index dfb4f00..91ebe5f 100644 --- a/sdm845Pkg/Devices/dipper.dsc +++ b/sdm845Pkg/Devices/dipper.dsc @@ -12,13 +12,16 @@ !include sdm845Pkg/sdm845Pkg.dsc [BuildOptions.common] - GCC:*_*_AARCH64_CC_FLAGS = -DXIAOMI_PIL_FIXED=1 -DDISPLAY_DPI=410 -DENABLE_SIMPLE_INIT + GCC:*_*_AARCH64_CC_FLAGS = -DXIAOMI_PIL_FIXED=1 -DENABLE_SIMPLE_INIT [PcdsFixedAtBuild.common] gsdm845PkgTokenSpaceGuid.PcdMipiFrameBufferWidth|1080 gsdm845PkgTokenSpaceGuid.PcdMipiFrameBufferHeight|2248 + # Simple Init + gSimpleInitTokenSpaceGuid.PcdGuiDefaultDPI|410 + gsdm845PkgTokenSpaceGuid.PcdDeviceVendor|"Xiaomi" gsdm845PkgTokenSpaceGuid.PcdDeviceProduct|"MI 8" gsdm845PkgTokenSpaceGuid.PcdDeviceCodeName|"dipper" diff --git a/sdm845Pkg/Devices/enchilada.dsc b/sdm845Pkg/Devices/enchilada.dsc index 4793db1..767586e 100644 --- a/sdm845Pkg/Devices/enchilada.dsc +++ b/sdm845Pkg/Devices/enchilada.dsc @@ -15,7 +15,7 @@ !include sdm845Pkg/sdm845Pkg.dsc [BuildOptions.common] - GCC:*_*_AARCH64_CC_FLAGS = -DAB_SLOTS_SUPPORT=1 -DDISPLAY_DPI=440 -DENABLE_SIMPLE_INIT -DENABLE_LINUX_SIMPLE_MASS_STORAGE + GCC:*_*_AARCH64_CC_FLAGS = -DAB_SLOTS_SUPPORT=1 -DENABLE_SIMPLE_INIT -DENABLE_LINUX_SIMPLE_MASS_STORAGE [PcdsFixedAtBuild.common] @@ -25,3 +25,6 @@ gsdm845PkgTokenSpaceGuid.PcdDeviceVendor|"Oneplus" gsdm845PkgTokenSpaceGuid.PcdDeviceProduct|"6" gsdm845PkgTokenSpaceGuid.PcdDeviceCodeName|"enchilada" + + # Simple Init + gSimpleInitTokenSpaceGuid.PcdGuiDefaultDPI|440 diff --git a/sdm845Pkg/Devices/fajita.dsc b/sdm845Pkg/Devices/fajita.dsc index 8174f19..c12b818 100644 --- a/sdm845Pkg/Devices/fajita.dsc +++ b/sdm845Pkg/Devices/fajita.dsc @@ -15,13 +15,16 @@ !include sdm845Pkg/sdm845Pkg.dsc [BuildOptions.common] - GCC:*_*_AARCH64_CC_FLAGS = -DAB_SLOTS_SUPPORT=1 -DDISPLAY_DPI=440 -DENABLE_SIMPLE_INIT -DENABLE_LINUX_SIMPLE_MASS_STORAGE + GCC:*_*_AARCH64_CC_FLAGS = -DAB_SLOTS_SUPPORT=1 -DENABLE_SIMPLE_INIT -DENABLE_LINUX_SIMPLE_MASS_STORAGE [PcdsFixedAtBuild.common] gsdm845PkgTokenSpaceGuid.PcdMipiFrameBufferWidth|1080 gsdm845PkgTokenSpaceGuid.PcdMipiFrameBufferHeight|2340 + # Simple Init + gSimpleInitTokenSpaceGuid.PcdGuiDefaultDPI|440 + gsdm845PkgTokenSpaceGuid.PcdDeviceVendor|"Oneplus" gsdm845PkgTokenSpaceGuid.PcdDeviceProduct|"6T" gsdm845PkgTokenSpaceGuid.PcdDeviceCodeName|"fajita" diff --git a/sdm845Pkg/Devices/odin-base.dsc b/sdm845Pkg/Devices/odin-base.dsc index 682cb14..be96132 100644 --- a/sdm845Pkg/Devices/odin-base.dsc +++ b/sdm845Pkg/Devices/odin-base.dsc @@ -12,13 +12,16 @@ !include sdm845Pkg/sdm845Pkg.dsc [BuildOptions.common] - GCC:*_*_AARCH64_CC_FLAGS = -DAB_SLOTS_SUPPORT=1 -DDISPLAY_DPI=369 -DENABLE_SIMPLE_INIT + GCC:*_*_AARCH64_CC_FLAGS = -DAB_SLOTS_SUPPORT=1 -DENABLE_SIMPLE_INIT [PcdsFixedAtBuild.common] gsdm845PkgTokenSpaceGuid.PcdMipiFrameBufferWidth|1080 gsdm845PkgTokenSpaceGuid.PcdMipiFrameBufferHeight|1920 + # Simple Init + gSimpleInitTokenSpaceGuid.PcdGuiDefaultDPI|369 + gsdm845PkgTokenSpaceGuid.PcdDeviceVendor|"AYN" gsdm845PkgTokenSpaceGuid.PcdDeviceProduct|"Odin" gsdm845PkgTokenSpaceGuid.PcdDeviceCodeName|"ayn-odin" diff --git a/sdm845Pkg/Devices/perseus.dsc b/sdm845Pkg/Devices/perseus.dsc index 7f84d73..337285c 100644 --- a/sdm845Pkg/Devices/perseus.dsc +++ b/sdm845Pkg/Devices/perseus.dsc @@ -12,13 +12,16 @@ !include sdm845Pkg/sdm845Pkg.dsc [BuildOptions.common] - GCC:*_*_AARCH64_CC_FLAGS = -DXIAOMI_PIL_FIXED=1 -DDISPLAY_DPI=403 -DENABLE_SIMPLE_INIT -DENABLE_LINUX_SIMPLE_MASS_STORAGE + GCC:*_*_AARCH64_CC_FLAGS = -DXIAOMI_PIL_FIXED=1 -DENABLE_SIMPLE_INIT -DENABLE_LINUX_SIMPLE_MASS_STORAGE [PcdsFixedAtBuild.common] gsdm845PkgTokenSpaceGuid.PcdMipiFrameBufferWidth|1080 gsdm845PkgTokenSpaceGuid.PcdMipiFrameBufferHeight|2340 + # Simple Init + gSimpleInitTokenSpaceGuid.PcdGuiDefaultDPI|403 + gsdm845PkgTokenSpaceGuid.PcdDeviceVendor|"Xiaomi" gsdm845PkgTokenSpaceGuid.PcdDeviceProduct|"MIX3" gsdm845PkgTokenSpaceGuid.PcdDeviceCodeName|"perseus" diff --git a/sdm845Pkg/Devices/polaris.dsc b/sdm845Pkg/Devices/polaris.dsc index 25255d6..8cab507 100644 --- a/sdm845Pkg/Devices/polaris.dsc +++ b/sdm845Pkg/Devices/polaris.dsc @@ -12,13 +12,16 @@ !include sdm845Pkg/sdm845Pkg.dsc [BuildOptions.common] - GCC:*_*_AARCH64_CC_FLAGS = -DXIAOMI_PIL_FIXED=1 -DDISPLAY_DPI=440 -DENABLE_SIMPLE_INIT -DENABLE_LINUX_SIMPLE_MASS_STORAGE + GCC:*_*_AARCH64_CC_FLAGS = -DXIAOMI_PIL_FIXED=1 -DENABLE_SIMPLE_INIT -DENABLE_LINUX_SIMPLE_MASS_STORAGE [PcdsFixedAtBuild.common] gsdm845PkgTokenSpaceGuid.PcdMipiFrameBufferWidth|1080 gsdm845PkgTokenSpaceGuid.PcdMipiFrameBufferHeight|2160 + # Simple Init + gSimpleInitTokenSpaceGuid.PcdGuiDefaultDPI|440 + gsdm845PkgTokenSpaceGuid.PcdDeviceVendor|"Xiaomi" gsdm845PkgTokenSpaceGuid.PcdDeviceProduct|"MIX2S" gsdm845PkgTokenSpaceGuid.PcdDeviceCodeName|"polaris" diff --git a/sdm845Pkg/Include/Library/FdtParserLib.h b/sdm845Pkg/Include/Library/FdtParserLib.h new file mode 100644 index 0000000..0c8dd93 --- /dev/null +++ b/sdm845Pkg/Include/Library/FdtParserLib.h @@ -0,0 +1,71 @@ +/** @file + * + * Device Tree Parse Library + * + * Copyright (c) 2021, BigfootACA + * + **/ + +#ifndef _FDT_PARSER_LIB +#define _FDT_PARSER_LIB +#include +#include +#include +#include +#include +#include +#include + +STATIC +inline +fdt* +EFIAPI +GetFdt(VOID) +{ + EFI_PHYSICAL_ADDRESS FdtStore = (EFI_PHYSICAL_ADDRESS)FixedPcdGet64(DeviceTreeStore); + EFI_PHYSICAL_ADDRESS FdtAddress = *(EFI_PHYSICAL_ADDRESS*)FdtStore; + + DEBUG((EFI_D_INFO, "Device Tree Address: 0x%016lx\n",FdtAddress)); + + if (FdtAddress < PcdGet64(PcdSystemMemoryBase)){ + DEBUG((EFI_D_INFO, "Invalid Device Tree Address\n")); + return NULL; + } + + return get_fdt_from_pointer ((VOID*)FdtAddress); +} + +STATIC +inline +VOID +EFIAPI +CmdlineDumpItemDebug(IN UINTN Level, IN CHAR8 *Prefix, IN keyval *Item) +{ + if (Item == NULL) return; + DEBUG(( + Level, + "%aKey = \"%a\", Value = \"%a\"\n", + (Prefix != NULL ? Prefix : ""), + Item->key, Item->value + )); +} + +STATIC +inline +VOID +EFIAPI +CmdlineDumpItemsDebug(IN UINTN Level, IN CHAR8 *Prefix, IN keyval **Items) +{ + CHAR8 String[256]; + if (Items == NULL) return; + KVARR_FOREACH (Items, Item, Index) { + ZeroMem(String, sizeof (String)); + AsciiSPrint( + String, sizeof (String), "%aItem %d: ", + (Prefix != NULL ? Prefix : ""), Index + 1 + ); + CmdlineDumpItemDebug(Level, String, Item); + } +} + +#endif diff --git a/sdm845Pkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf b/sdm845Pkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf index 1fc4584..287e88d 100644 --- a/sdm845Pkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf +++ b/sdm845Pkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf @@ -34,6 +34,7 @@ MdePkg/MdePkg.dec ShellPkg/ShellPkg.dec sdm845Pkg/sdm845Pkg.dec + SimpleInit.dec [LibraryClasses] BaseLib diff --git a/sdm845Pkg/Library/SimpleInit b/sdm845Pkg/Library/SimpleInit index d64d7db..2752bcc 160000 --- a/sdm845Pkg/Library/SimpleInit +++ b/sdm845Pkg/Library/SimpleInit @@ -1 +1 @@ -Subproject commit d64d7db87aa2f7bc1d507ea8d722c7ebe98b3aa4 +Subproject commit 2752bcce5e89cd53e6f171e22b3b46bdf9d11fbc diff --git a/sdm845Pkg/Library/StdLib b/sdm845Pkg/Library/StdLib deleted file mode 160000 index 0bcd289..0000000 --- a/sdm845Pkg/Library/StdLib +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 0bcd2898750ba29e9faac10c17fc1f1c56070f16 diff --git a/sdm845Pkg/sdm845Pkg.dec b/sdm845Pkg/sdm845Pkg.dec index ca903a9..be9076f 100644 --- a/sdm845Pkg/sdm845Pkg.dec +++ b/sdm845Pkg/sdm845Pkg.dec @@ -46,8 +46,6 @@ [Guids] gSwitchSlotsAppFileGuid = { 0xD5BC0FB1, 0xA833, 0x4607, { 0xB7, 0xB6, 0x5E, 0xF9, 0xD1, 0x0B, 0xEE, 0xB7 } } - gSimpleInitFileGuid = { 0x6D77B2BB, 0x69EB, 0x42AB, { 0xBE, 0xCF, 0x4F, 0x40, 0xC8, 0x95, 0x68, 0xC3 } } - gLinuxSimpleMassStorageGuid = { 0x2a24787e, 0xe09c, 0x43ce, { 0xb5, 0xcf, 0xd0, 0x30, 0x66, 0xf6, 0x09, 0x2f } } [PcdsFixedAtBuild.common] # Simple FrameBuffer -- 2.45.2