sdm845Pkg: Library: SimpleInit: add fdt parser

This commit is contained in:
BigfootACA 2022-02-10 02:16:07 +08:00
parent f98013a0d4
commit 6fc6656b7b
15 changed files with 103 additions and 24 deletions

3
.gitmodules vendored
View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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"

View File

@ -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

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -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"

View File

@ -0,0 +1,71 @@
/** @file
*
* Device Tree Parse Library
*
* Copyright (c) 2021, BigfootACA <bigfoot@classfun.cn>
*
**/
#ifndef _FDT_PARSER_LIB
#define _FDT_PARSER_LIB
#include <Uefi.h>
#include <Library/DebugLib.h>
#include <Library/PrintLib.h>
#include <Library/BaseMemoryLib.h>
#include <fdtparser.h>
#include <param.h>
#include <keyval.h>
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

View File

@ -34,6 +34,7 @@
MdePkg/MdePkg.dec
ShellPkg/ShellPkg.dec
sdm845Pkg/sdm845Pkg.dec
SimpleInit.dec
[LibraryClasses]
BaseLib

@ -1 +1 @@
Subproject commit d64d7db87aa2f7bc1d507ea8d722c7ebe98b3aa4
Subproject commit 2752bcce5e89cd53e6f171e22b3b46bdf9d11fbc

@ -1 +0,0 @@
Subproject commit 0bcd2898750ba29e9faac10c17fc1f1c56070f16

View File

@ -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