From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from loongson.cn (loongson.cn [114.242.206.163]) by mx.groups.io with SMTP id smtpd.web10.5362.1646210697056842834 for ; Wed, 02 Mar 2022 00:45:08 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: loongson.cn, ip: 114.242.206.163, mailfrom: lixianglai@loongson.cn) Received: from localhost.localdomain (unknown [10.2.5.185]) by mail.loongson.cn (Coremail) with SMTP id AQAAf9Dxn89_Lh9i7TkBAA--.6283S7; Wed, 02 Mar 2022 16:44:50 +0800 (CST) From: "xianglai" To: devel@edk2.groups.io Subject: [edk2-platforms][PATCH V1 05/15] Platform/Loongson: Add BpiLib. Date: Wed, 2 Mar 2022 03:44:37 -0500 Message-Id: <20220302084447.2991355-6-lixianglai@loongson.cn> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220302084447.2991355-1-lixianglai@loongson.cn> References: <20220302084447.2991355-1-lixianglai@loongson.cn> MIME-Version: 1.0 X-CM-TRANSID: AQAAf9Dxn89_Lh9i7TkBAA--.6283S7 X-Coremail-Antispam: 1UD129KBjvAXoW3tFy3WF47WFy3XF18Wr4Uurg_yoW8Wr47Zo W7Ja4Ik3y8Gr1rZr1rWrs3Gr48XF1Sgayaqr4rZa4Yq3Z0yrn8GFWUXayfJr1rta4vvr98 C34rt3yxAayagryrn29KB7ZKAUJUUUU8529EdanIXcx71UUUUU7v73VFW2AGmfu7bjvjm3 AaLaJ3UjIYCTnIWjDUYxBIdaVFxhVjvjDU0xZFpf9x0zRUUUUUUUUU= X-CM-SenderInfo: 5ol0xt5qjotxo6or00hjvr0hdfq/ Content-Transfer-Encoding: quoted-printable This library provides interfaces for creating kernel boot parameters. Signed-off-by: xianglai li --- .../LoongArchQemuPkg/Include/Library/Bpi.h | 77 +++ .../LoongArchQemuPkg/Library/BpiLib/Bpi.c | 492 ++++++++++++++++++ .../Library/BpiLib/BpiLib.inf | 38 ++ 3 files changed, 607 insertions(+) create mode 100644 Platform/Loongson/LoongArchQemuPkg/Include/Library/Bpi.h create mode 100644 Platform/Loongson/LoongArchQemuPkg/Library/BpiLib/Bpi.c create mode 100644 Platform/Loongson/LoongArchQemuPkg/Library/BpiLib/BpiLi= b.inf diff --git a/Platform/Loongson/LoongArchQemuPkg/Include/Library/Bpi.h b/Pla= tform/Loongson/LoongArchQemuPkg/Include/Library/Bpi.h new file mode 100644 index 0000000000..cb2585ccb7 --- /dev/null +++ b/Platform/Loongson/LoongArchQemuPkg/Include/Library/Bpi.h @@ -0,0 +1,77 @@ +/** @file=0D +=0D + Copyright (c) 2021 Loongson Technology Corporation Limited. All rights r= eserved.
=0D +=0D + SPDX-License-Identifier: BSD-2-Clause-Patent=0D +=0D + @par Glossary:=0D + - BPI or Bpi - Boot Parameter Interface=0D + - MEM or Mem - Memory=0D + - info or INFO - Information=0D + - SINFO - Screen information=0D +**/=0D +#ifndef BPI_H_=0D +#define BPI_H_=0D +=0D +#include =0D +#define SYSTEM_RAM 1=0D +#define SYSTEM_RAM_RESERVED 2=0D +#define ACPI_TABLE 3=0D +#define ACPI_NVS 4=0D +#define SYSTEM_PMEM 5=0D +=0D +#define MAX_MEM_MAP 128=0D +=0D +#define DEBUG_BPI=0D +=0D +#define MAP_ENTRY(Entry, Type, Start, Size) \=0D + MemMap->Map[(Entry)].MemType =3D (Type), \=0D + MemMap->Map[(Entry)].MemStart =3D (Start), \=0D + MemMap->Map[(Entry)].MemSize =3D (Size), \=0D + Entry++=0D +=0D +#pragma pack(1)=0D +typedef struct _extension_list_hdr{=0D + UINT64 Signature;=0D + UINT32 Length;=0D + UINT8 Revision;=0D + UINT8 CheckSum;=0D + struct _extension_list_hdr *next;=0D +}EXT_LIST;=0D +=0D +typedef struct _BootParams_Interface {=0D + UINT64 Signature; //{'B', 'P', 'I', '0', '1', '0', '0', '1'}= =0D + EFI_SYSTEM_TABLE *SystemTable;=0D + EXT_LIST *ExtList;=0D +}BootParamsInterface;=0D +=0D +typedef struct _MEMMAP_ {=0D + UINT32 MemType;=0D + UINT64 MemStart;=0D + UINT64 MemSize;=0D +}MEMMAP;=0D +=0D +typedef struct _MEM_MAP_ {=0D + EXT_LIST Header; // {'M', 'E', 'M'}=0D + UINT8 MapCount;=0D + MEMMAP Map[MAX_MEM_MAP];=0D +} MEM_MAP;=0D +=0D +typedef struct {=0D + EXT_LIST Header; // {SI}=0D + struct screen_info si;=0D +}SINFO;=0D +=0D +typedef struct {=0D + UINT64 BaseAddr;=0D + UINT64 Length;=0D + UINT32 Type;=0D + UINT32 Reserved;=0D +} LOONGARCH_MEMMAP_ENTRY;=0D +=0D +#pragma pack()=0D +=0D +typedef struct screen_info SCREEN_INFO;=0D +=0D +#endif=0D +=0D diff --git a/Platform/Loongson/LoongArchQemuPkg/Library/BpiLib/Bpi.c b/Plat= form/Loongson/LoongArchQemuPkg/Library/BpiLib/Bpi.c new file mode 100644 index 0000000000..c36ade6be9 --- /dev/null +++ b/Platform/Loongson/LoongArchQemuPkg/Library/BpiLib/Bpi.c @@ -0,0 +1,492 @@ +/** @file=0D +=0D + Copyright (c) 2021 Loongson Technology Corporation Limited. All rights r= eserved.
=0D +=0D + SPDX-License-Identifier: BSD-2-Clause-Patent=0D +=0D + @par Glossary:=0D + - Bpi - Boot Parameter Interface=0D + - Calc - Calculation=0D + - Mem - memory=0D + - Ext - Exist=0D + - FwCfg - firmWare Configure=0D + - si - Screen Information=0D + - pos - Position=0D +**/=0D +#include "Uefi.h"=0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +=0D +/*=0D + Calculates the checksum and saves the result at the end of the data.=0D +=0D + @param Buffer A pointer to the data to calculate the checksum.=0D + @param Size The number of data involved in calculating the checksum.= =0D +=0D + @retval VOID=0D + */=0D +VOID=0D +BpiChecksum (=0D + IN UINT8 *Buffer,=0D + IN UINTN Size=0D + )=0D +{=0D + UINTN ChecksumOffset;=0D +=0D + //=0D + // CheckSum's offset in EXT_LIST is the same as in EXT_LIST's container = (Buffer).=0D + //=0D + ChecksumOffset =3D OFFSET_OF (EXT_LIST, CheckSum);=0D +=0D + //=0D + // set checksum to 0 first=0D + //=0D + Buffer[ChecksumOffset] =3D 0;=0D +=0D + //=0D + // Update checksum value=0D + //=0D + Buffer[ChecksumOffset] =3D CalculateCheckSum8 (Buffer, Size);=0D +}=0D +=0D +/*=0D + Add a linked list node to the linked list.=0D +=0D + @param Bpi A pointer to the structure that holds the header of the l= inked list.=0D + @param Header The address of the node to join the linked list.=0D +=0D + @retval VOID=0D + */=0D +VOID=0D +EFIAPI=0D +AddToList (=0D + IN BootParamsInterface *Bpi,=0D + OUT EXT_LIST *Header=0D + )=0D +{=0D + EXT_LIST *LastHeader;=0D +=0D + if (Bpi->ExtList =3D=3D NULL) {=0D + Bpi->ExtList =3D Header;=0D + } else {=0D + for (LastHeader =3D Bpi->ExtList; LastHeader->next; LastHeader =3D Las= tHeader->next) {=0D + }=0D + LastHeader->next =3D Header;=0D + BpiChecksum ((UINT8 *)LastHeader, LastHeader->Length);=0D + }=0D + Header->next =3D NULL;=0D + BpiChecksum ((UINT8 *)Header, Header->Length);=0D +}=0D +=0D +#ifdef DEBUG_BPI=0D +/*=0D + Iterates through the linked list and prints the data in all linked list= nodes.=0D +=0D + @param Bpi A pointer to the structure that holds the header of the l= inked list.=0D +=0D + @retval VOID=0D + */=0D +VOID=0D +EFIAPI=0D +ShowList (=0D + IN BootParamsInterface *Bpi=0D + )=0D +{=0D + EXT_LIST *LastHeader;=0D +=0D + if (Bpi->ExtList =3D=3D NULL) {=0D + DEBUG ((DEBUG_INFO, "List is null\n"));=0D + } else {=0D + for (LastHeader =3D Bpi->ExtList; LastHeader; LastHeader =3D LastHeade= r->next) {=0D + DEBUG ((DEBUG_INFO, "Header: 0x%llx, Legth: 0x%x, CheckSum: 0x%x\n",= LastHeader, LastHeader->Length,=0D + LastHeader->CheckSum));=0D + }=0D + }=0D +}=0D +#endif=0D +/*=0D + Read fwCfg to get the memory-mapped information and add it to the linked= list.=0D +=0D + @param Bpi A pointer to the structure that holds the header of the l= inked list.=0D + @param MemMap A pointer to a memory-mapped struct.=0D +=0D + @retval VOID=0D + */=0D +VOID=0D +EFIAPI=0D +InitMemMap (=0D + IN OUT BootParamsInterface *Bpi,=0D + OUT MEM_MAP *MemMap=0D + )=0D +{=0D + UINT64 RamSize;=0D + UINT8 Data[8] =3D {'M', 'E', 'M'};=0D + INTN i =3D 0;=0D + EFI_STATUS Status;=0D + FIRMWARE_CONFIG_ITEM FwCfgItem;=0D + UINTN FwCfgSize;=0D + LOONGARCH_MEMMAP_ENTRY MemMapEntry;=0D + LOONGARCH_MEMMAP_ENTRY *StartEntry;=0D + LOONGARCH_MEMMAP_ENTRY *pEntry;=0D + UINTN Processed;=0D +=0D + SetMem (&MemMap->Header, sizeof (EXT_LIST), 0);=0D +=0D + CopyMem (&MemMap->Header.Signature, Data, sizeof (EXT_LIST));=0D + MemMap->Header.Revision =3D 0;=0D + MemMap->Header.Length =3D sizeof (MEM_MAP);=0D +=0D + RamSize =3D PcdGet64 (PcdRamSize); //in Byte=0D +=0D + ASSERT (RamSize !=3D 0);=0D + DEBUG ((DEBUG_INFO, "RamSize %lld Byte\n", RamSize));=0D +=0D + /*=0D + * 1. The lowest 2M region cannot record in MemMap, cause Linux ram regi= on should begin with usable ram.=0D + * MAP_ENTRY (i, SYSTEM_RAM_RESERVED, 0x0, 0x200000); // 0x0-0x20000= 0=0D + */=0D +=0D + /* 2. Available SYSTEM_RAM area. */=0D + MAP_ENTRY (i, SYSTEM_RAM, 0x200000, 0xf000000 - 0x200000); // 0x200000~= 0xf000000=0D +=0D + /* 3. Reserved low memory highest 16M. */=0D + MAP_ENTRY (i, SYSTEM_RAM_RESERVED, 0xf000000, 0x1000000); // 0xf000000~= 0x10000000=0D + /*=0D + * 0x90000000 -- 0xC0000000 is used by uefi bios=0D + */=0D + //MAP_ENTRY (i, SYSTEM_RAM, 0x90000000, 0x30000000);=0D +=0D +=0D + /* Read memmap from QEMU when RamSize is larger than 1G */=0D + if (RamSize > SIZE_1GB) {=0D + Status =3D QemuFwCfgFindFile ("etc/memmap", &FwCfgItem, &FwCfgSize);=0D + if (EFI_ERROR (Status)) {=0D + DEBUG ((DEBUG_ERROR, "fw read etc/la_memmap error Status %d \n", Sta= tus));=0D + }=0D + if (FwCfgSize % sizeof MemMapEntry !=3D 0) {=0D + DEBUG ((DEBUG_ERROR, "no MemMapEntry FwCfgSize:%d\n", FwCfgSize));=0D + }=0D +=0D + QemuFwCfgSelectItem (FwCfgItem);=0D + StartEntry =3D AllocateZeroPool (FwCfgSize);=0D + QemuFwCfgReadBytes (FwCfgSize, StartEntry);=0D + for (Processed =3D 0; Processed < (FwCfgSize / sizeof MemMapEntry); Pr= ocessed++) {=0D + pEntry =3D StartEntry + Processed;=0D + DEBUG ((=0D + DEBUG_INFO,=0D + "%a:%d Base=3D0x%Lx Length=3D0x%Lx Type=3D%u sizeof (MemMapEntry):= %d, Processed:%d, FwCfgSize:%d\n",=0D + __FUNCTION__,=0D + __LINE__,=0D + pEntry->BaseAddr,=0D + pEntry->Length,=0D + pEntry->Type,=0D + sizeof MemMapEntry,=0D + Processed,=0D + FwCfgSize=0D + ));=0D + MAP_ENTRY (i, pEntry->Type, pEntry->BaseAddr, pEntry->Length);=0D + }=0D + }=0D +=0D + MemMap->MapCount =3D i;=0D + AddToList (Bpi, &MemMap->Header);=0D +#ifdef DEBUG_BPI=0D + INTN j;=0D + for (j =3D 0; j < i; j++) {=0D + DEBUG ((DEBUG_INFO, "%d: type: 0x%x, start: 0x%llx, size: 0x%llx\n", j= , MemMap->Map[j].MemType,=0D + MemMap->Map[j].MemStart, MemMap->Map[j].MemSize));=0D + }=0D +#endif=0D +}=0D +/*=0D + Find the first bit field with 1 and get its starting position and length= .=0D +=0D + @param Mask To find data for the bit field.=0D + @param Pos Find the starting location of the bit domain.=0D + @param Size The length of the bit domain found.=0D +=0D + @retval VOID=0D + */=0D +VOID=0D +FindBits (=0D + IN UINT64 Mask,=0D + OUT UINT8 *Pos,=0D + OUT UINT8 *Size=0D + )=0D +{=0D + UINT8 First;=0D + UINT8 Len;=0D +=0D + First =3D 0;=0D + Len =3D 0;=0D +=0D + if (Mask) {=0D + while (!(Mask & 0x1)) {=0D + Mask =3D Mask >> 1;=0D + First++;=0D + }=0D +=0D + while (Mask & 0x1) {=0D + Mask =3D Mask >> 1;=0D + Len++;=0D + }=0D + }=0D + *Pos =3D First;=0D + *Size =3D Len;=0D +}=0D +=0D +/*=0D + Establish graph-related parameters by EFI_GRAPHICS_OUTPUT_PROTOCOL.=0D +=0D + @param Si A pointer to the SCREEN_INFO struct.=0D + @param Gop A pointer to the EFI_GRAPHICS_OUTPUT_PROTOCOL structure.=0D +=0D + @retval VOID=0D + */=0D +EFI_STATUS=0D +SetupGraphicsFromGop (=0D + OUT SCREEN_INFO *Si,=0D + IN EFI_GRAPHICS_OUTPUT_PROTOCOL *Gop=0D + )=0D +{=0D + EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info;=0D + EFI_STATUS Status;=0D + UINTN Size;=0D +=0D + Status =3D Gop->QueryMode (Gop, Gop->Mode->Mode, &Size, &Info);=0D + if (EFI_ERROR (Status)) {=0D + return Status;=0D + }=0D +=0D + /* We found a GOP */=0D +=0D + /* EFI framebuffer */=0D + Si->orig_video_isVGA =3D 0x70;=0D +=0D + Si->orig_x =3D 0;=0D + Si->orig_y =3D 0;=0D + Si->orig_video_page =3D 0;=0D + Si->orig_video_mode =3D 0;=0D + Si->orig_video_cols =3D 0;=0D + Si->orig_video_lines =3D 0;=0D + Si->orig_video_ega_bx =3D 0;=0D + Si->orig_video_points =3D 0;=0D +=0D + Si->lfb_base =3D (UINT32) Gop->Mode->FrameBufferBase;=0D + Si->lfb_size =3D (UINT32) Gop->Mode->FrameBufferSize;=0D + Si->lfb_width =3D (UINT16) Info->HorizontalResolution;=0D + Si->lfb_height =3D (UINT16) Info->VerticalResolution;=0D + Si->pages =3D 1;=0D + Si->vesapm_seg =3D 0;=0D + Si->vesapm_off =3D 0;=0D +=0D + if (Info->PixelFormat =3D=3D PixelRedGreenBlueReserved8BitPerColor) {=0D + Si->lfb_depth =3D 32;=0D + Si->red_size =3D 8;=0D + Si->red_pos =3D 0;=0D + Si->green_size =3D 8;=0D + Si->green_pos =3D 8;=0D + Si->blue_size =3D 8;=0D + Si->blue_pos =3D 16;=0D + Si->rsvd_size =3D 8;=0D + Si->rsvd_pos =3D 24;=0D + Si->lfb_linelength =3D (UINT16) (Info->PixelsPerScanLine * 4);=0D + } else if (Info->PixelFormat =3D=3D PixelBlueGreenRedReserved8BitPerColo= r) {=0D + Si->lfb_depth =3D 32;=0D + Si->red_size =3D 8;=0D + Si->red_pos =3D 16;=0D + Si->green_size =3D 8;=0D + Si->green_pos =3D 8;=0D + Si->blue_size =3D 8;=0D + Si->blue_pos =3D 0;=0D + Si->rsvd_size =3D 8;=0D + Si->rsvd_pos =3D 24;=0D + Si->lfb_linelength =3D (UINT16) (Info->PixelsPerScanLine * 4);=0D + } else if (Info->PixelFormat =3D=3D PixelBitMask) {=0D + FindBits (Info->PixelInformation.RedMask,=0D + &Si->red_pos, &Si->red_size);=0D + FindBits (Info->PixelInformation.GreenMask,=0D + &Si->green_pos, &Si->green_size);=0D + FindBits (Info->PixelInformation.BlueMask,=0D + &Si->blue_pos, &Si->blue_size);=0D + FindBits (Info->PixelInformation.ReservedMask,=0D + &Si->rsvd_pos, &Si->rsvd_size);=0D + Si->lfb_depth =3D Si->red_size + Si->green_size +=0D + Si->blue_size + Si->rsvd_size;=0D + Si->lfb_linelength =3D (UINT16) ((Info->PixelsPerScanLine * Si->lfb_de= pth) / 8);=0D + } else {=0D + Si->lfb_depth =3D 4;=0D + Si->red_size =3D 0;=0D + Si->red_pos =3D 0;=0D + Si->green_size =3D 0;=0D + Si->green_pos =3D 0;=0D + Si->blue_size =3D 0;=0D + Si->blue_pos =3D 0;=0D + Si->rsvd_size =3D 0;=0D + Si->rsvd_pos =3D 0;=0D + Si->lfb_linelength =3D Si->lfb_width / 2;=0D + }=0D +=0D + return Status;=0D +}=0D +/*=0D + Get graph-related parameters.=0D +=0D + @param Si A pointer to the SCREEN_INFO struct.=0D +=0D + @retval VOID=0D + */=0D +EFI_STATUS=0D +SetupGraphics (=0D + IN OUT SCREEN_INFO *si=0D + )=0D +{=0D + EFI_STATUS Status;=0D + EFI_HANDLE *HandleBuffer;=0D + UINTN HandleCount;=0D + UINTN Index;=0D + EFI_GRAPHICS_OUTPUT_PROTOCOL *Gop;=0D +=0D + ZeroMem ((VOID*)si, sizeof (SCREEN_INFO));=0D +=0D + Status =3D gBS->LocateHandleBuffer (=0D + ByProtocol,=0D + &gEfiGraphicsOutputProtocolGuid,=0D + NULL,=0D + &HandleCount,=0D + &HandleBuffer=0D + );=0D + if (!EFI_ERROR (Status)) {=0D + for (Index =3D 0; Index < HandleCount; Index++) {=0D + Status =3D gBS->HandleProtocol (=0D + HandleBuffer[Index],=0D + &gEfiGraphicsOutputProtocolGuid,=0D + (VOID*) &Gop=0D + );=0D + if (EFI_ERROR (Status)) {=0D + continue;=0D + }=0D +=0D + Status =3D SetupGraphicsFromGop (si, Gop);=0D + if (!EFI_ERROR (Status)) {=0D + FreePool (HandleBuffer);=0D + return EFI_SUCCESS;=0D + }=0D + }=0D + FreePool (HandleBuffer);=0D + }=0D + return EFI_NOT_FOUND;=0D +}=0D +/*=0D + Initialize screen information.=0D +=0D + @param Bpi A pointer to the BootParamsInterface struct.=0D + @param si A pointer to the SCREEN_INFO struct.=0D +=0D + @retval VOID=0D + */=0D +VOID=0D +EFIAPI=0D +InitScreenInfo (=0D + IN BootParamsInterface *Bpi,=0D + OUT SINFO *si=0D + )=0D +{=0D +=0D +// UINTN Addr;=0D + UINT8 Data[8] =3D {'S', 'I', 'N', 'F', 'O'};=0D +=0D + SetMem (&si->Header, sizeof (EXT_LIST), 0);=0D +=0D + CopyMem (&si->Header.Signature, Data, sizeof (UINT64));=0D + si->Header.Revision =3D 0;=0D + si->Header.Length =3D sizeof (SINFO);=0D +=0D + SetupGraphics (&si->si);=0D + AddToList (Bpi, &si->Header);=0D +}=0D +/*=0D + Initialize the boot parameter interface.=0D +=0D + @param Bpi A pointer to the BootParamsInterface struct.=0D + @param SystemTable A pointer to the EFI_SYSTEM_TABLE struct.=0D +=0D + @retval VOID=0D + */=0D +VOID=0D +EFIAPI=0D +InitializeBpi (=0D + IN BootParamsInterface *Bpi,=0D + IN EFI_SYSTEM_TABLE *SystemTable=0D + )=0D +{=0D + DEBUG ((DEBUG_INFO, "New BPI addr: 0x%llx\n", (UINTN)Bpi));=0D + UINT8 Data[8] =3D {'B', 'P', 'I', '0', '1', '0', '0', '1'};=0D + CopyMem (&Bpi->Signature, Data, sizeof (UINT64));=0D + Bpi->SystemTable =3D SystemTable;=0D + Bpi->ExtList =3D NULL;=0D +}=0D +/*=0D + Setup the boot parameter.=0D +=0D + @param VOID=0D +=0D + @retval EFI_SUCCESS The boot parameter was established su= ccessfully.=0D + @retval EFI_INVALID_PARAMETER Input GUID is NULL.=0D + @retval EFI_NOT_FOUND Attempted to delete non-existant entr= y=0D + @retval EFI_OUT_OF_RESOURCES Not enough memory available=0D + */=0D +EFI_STATUS=0D +EFIAPI=0D +SetBootParams (VOID)=0D +{=0D + EFI_STATUS Status;=0D + UINTN Size;=0D + VOID *BufferAddress;=0D + BootParamsInterface *Bpi;=0D + MEM_MAP *MemMap;=0D + SINFO *si;=0D + EFI_SYSTEM_TABLE *SystemTable;=0D +=0D + SystemTable =3D gST;=0D + Size =3D sizeof (BootParamsInterface);=0D + Size +=3D sizeof (MEM_MAP);=0D + Size +=3D sizeof (SINFO);=0D +=0D + Status =3D SystemTable->BootServices->AllocatePool (=0D + EfiRuntimeServicesData,=0D + Size,=0D + &BufferAddress=0D + );=0D + if (EFI_ERROR (Status)) {=0D + return EFI_OUT_OF_RESOURCES;=0D + }=0D +=0D + ZeroMem (BufferAddress, Size);=0D + Bpi =3D (BootParamsInterface *) BufferAddress;=0D + InitializeBpi (Bpi, SystemTable);=0D +=0D + MemMap =3D (MEM_MAP *) (Bpi + 1);=0D + InitMemMap (Bpi, MemMap);=0D +=0D + si =3D (SINFO*) (MemMap + 1);=0D + InitScreenInfo (Bpi, si);=0D +=0D +#ifdef DEBUG_BPI=0D + ShowList (Bpi);=0D +#endif=0D + Status =3D SystemTable->BootServices->InstallConfigurationTable (=0D + &gEfiLoongsonBootparamsTableGuid,= =0D + Bpi=0D + );=0D +=0D + return Status;=0D +}=0D diff --git a/Platform/Loongson/LoongArchQemuPkg/Library/BpiLib/BpiLib.inf b= /Platform/Loongson/LoongArchQemuPkg/Library/BpiLib/BpiLib.inf new file mode 100644 index 0000000000..c00a2e24fb --- /dev/null +++ b/Platform/Loongson/LoongArchQemuPkg/Library/BpiLib/BpiLib.inf @@ -0,0 +1,38 @@ +## @file=0D +#=0D +# Copyright (c) 2021 Loongson Technology Corporation Limited. All rights = reserved.
=0D +#=0D +# SPDX-License-Identifier: BSD-2-Clause-Patent=0D +#=0D +##=0D +[Defines]=0D + INF_VERSION =3D 0x00010005=0D + BASE_NAME =3D BpiLib=0D + FILE_GUID =3D e15244d6-6df0-485f-9deb-190e21c57020= =0D + MODULE_TYPE =3D BASE=0D + VERSION_STRING =3D 1.0=0D + LIBRARY_CLASS =3D BpiLib=0D +=0D +[Sources]=0D + Bpi.c=0D +=0D +[Packages]=0D + MdePkg/MdePkg.dec=0D + MdeModulePkg/MdeModulePkg.dec=0D + Platform/Loongson/LoongArchQemuPkg/Loongson.dec=0D + OvmfPkg/OvmfPkg.dec=0D +=0D +[LibraryClasses]=0D + UefiBootServicesTableLib=0D + MemoryAllocationLib=0D + BaseMemoryLib=0D + BaseLib=0D + UefiLib=0D + UefiDriverEntryPoint=0D + DebugLib=0D +=0D +[Pcd]=0D + gLoongArchQemuPkgTokenSpaceGuid.PcdRamSize=0D +=0D +[Guids]=0D + gEfiLoongsonBootparamsTableGuid ## SOMETIM= ES_PRODUCES ## SystemTable=0D --=20 2.27.0