From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:400c:c09::243; helo=mail-wm0-x243.google.com; envelope-from=graeme.gregory@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wm0-x243.google.com (mail-wm0-x243.google.com [IPv6:2a00:1450:400c:c09::243]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id C2CDD22364880 for ; Tue, 30 Jan 2018 06:23:23 -0800 (PST) Received: by mail-wm0-x243.google.com with SMTP id t74so1523030wme.3 for ; Tue, 30 Jan 2018 06:28:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=Yi8TzvYJaKK8Mqu0IdUA1BaAIabvSphP2a88YdlfFWU=; b=UIZNr8OpE62nYKjmjsA7nX2fZrDQ/zFL4SlFl8I+BghHWIbRixQFjXrDlEGZA7jPgc TBuhBpkCxA6/TGymuU1V0fpkI/4H7k/b20qv4Qwgd+kwQWuw+pluPpyWhuVXp1F7zP1z zXw+EOojgCW4lNPbgekZGM4rmQkTBfe3f+eDg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=Yi8TzvYJaKK8Mqu0IdUA1BaAIabvSphP2a88YdlfFWU=; b=CLUweCmThidB4j9wH/mv2ctzhQGCMzFpZKCyHW3VhgjaBQtBDFSIfTKhRv7YrOI8gh sGFVXGUgQvbFMIA/SmVtoBzA5yt8S4W1rQhzkFHy2lmKTEZJOqZeLnzSMfq9T0d+1jhn EeSl+A9Rh4OZU+jUQ8pM8ZHRPqwoZqsw04djluiAv/iNcKWgfVmT8os9W60IUeszq+AM H1cdb/x1TB3MKJ59ZyglbGn0zL8mABQoTGC5UxYCinXJYCVwcpc1TM7ArURRoR6o4Fjs /7lTDKSSu9fNxQRURdPk/oN9Zzai/OJDhVevnJbCZGPcd37g4Sboxxc0q8vbvpNYk9/F Qmmg== X-Gm-Message-State: AKwxytdv9+qgOdn/d5KLIGR5iZcY95wgoIYb+TfvkuEhqX/b6opIQhu4 mHSjcW22aqG3Gz1lS3V3yn/ZSg== X-Google-Smtp-Source: AH8x225aJ38t8/fPRk/eYEMTw07hlarj4WG9Xo7/8Tia1FRDEAjRTmVzqwxxjpZFDjT3hDIdn2ILaA== X-Received: by 10.28.140.9 with SMTP id o9mr20939469wmd.28.1517322537195; Tue, 30 Jan 2018 06:28:57 -0800 (PST) Received: from localhost (host-92-20-151-143.as13285.net. [92.20.151.143]) by smtp.gmail.com with ESMTPSA id c49sm21523217wrc.48.2018.01.30.06.28.56 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 30 Jan 2018 06:28:56 -0800 (PST) Date: Tue, 30 Jan 2018 14:28:55 +0000 From: graeme.gregory@linaro.org To: Ming Huang Cc: leif.lindholm@linaro.org, linaro-uefi@lists.linaro.org, edk2-devel@lists.01.org, ard.biesheuvel@linaro.org, guoheyi@huawei.com, wanghuiqiang@huawei.com, huangming23@huawei.com, zhangjinsong2@huawei.com, mengfanrong@huawei.com, huangdaode@hisilicon.com, waip23@126.com Message-ID: <20180130142855.GB26342@xora-haswell> References: <1516953650-57980-1-git-send-email-huangming23@huawei.com> <1516953650-57980-3-git-send-email-huangming23@huawei.com> MIME-Version: 1.0 In-Reply-To: <1516953650-57980-3-git-send-email-huangming23@huawei.com> User-Agent: Mutt/1.9.2 (2017-12-15) Subject: Re: [PATCH edk2-platforms v2 02/15] Hisilicon/D05: Add PPTT support X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Jan 2018 14:23:24 -0000 X-Groupsio-MsgNum: 20703 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="rJwd6BRFiFCcLxzm" Content-Disposition: inline --rJwd6BRFiFCcLxzm Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Jan 26, 2018 at 04:00:37PM +0800, Ming Huang wrote: > Add Processor Properties Topology Table, PPTT include > Processor hierarchy node, Cache Type Structure and ID structure. >=20 > PPTT is needed for lscpu command to show socket information correctly. > https://bugs.linaro.org/show_bug.cgi?id=3D3206 >=20 > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Ming Huang > Signed-off-by: Heyi Guo > --- Code looks sane enough to me, but I cant give an indepth review of the PPTT bit. Reviewed-by: Graeme Gregory > Platform/Hisilicon/D05/D05.dsc | 1 + > Platform/Hisilicon/D05/D05.fdf | 1 + > Silicon/Hisilicon/Hi1616/Pptt/Pptt.c | 540 ++++++++++++++++++++ > Silicon/Hisilicon/Hi1616/Pptt/Pptt.h | 88 ++++ > Silicon/Hisilicon/Hi1616/Pptt/Pptt.inf | 48 ++ > 5 files changed, 678 insertions(+) >=20 > diff --git a/Platform/Hisilicon/D05/D05.dsc b/Platform/Hisilicon/D05/D05.= dsc > index 77a89fd..710339c 100644 > --- a/Platform/Hisilicon/D05/D05.dsc > +++ b/Platform/Hisilicon/D05/D05.dsc > @@ -506,6 +506,7 @@ > MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf > =20 > Silicon/Hisilicon/Hi1616/D05AcpiTables/AcpiTablesHi1616.inf > + Silicon/Hisilicon/Hi1616/Pptt/Pptt.inf > Silicon/Hisilicon/Drivers/AcpiPlatformDxe/AcpiPlatformDxe.inf > =20 > # > diff --git a/Platform/Hisilicon/D05/D05.fdf b/Platform/Hisilicon/D05/D05.= fdf > index 78ab0c8..97de4d2 100644 > --- a/Platform/Hisilicon/D05/D05.fdf > +++ b/Platform/Hisilicon/D05/D05.fdf > @@ -241,6 +241,7 @@ READ_LOCK_STATUS =3D TRUE > INF Silicon/Hisilicon/Drivers/HisiAcpiPlatformDxe/AcpiPlatformDxe.inf > =20 > INF RuleOverride=3DACPITABLE Silicon/Hisilicon/Hi1616/D05AcpiTables/Ac= piTablesHi1616.inf > + INF Silicon/Hisilicon/Hi1616/Pptt/Pptt.inf > INF Silicon/Hisilicon/Drivers/AcpiPlatformDxe/AcpiPlatformDxe.inf > =20 > # > diff --git a/Silicon/Hisilicon/Hi1616/Pptt/Pptt.c b/Silicon/Hisilicon/Hi1= 616/Pptt/Pptt.c > new file mode 100644 > index 0000000..71c456c > --- /dev/null > +++ b/Silicon/Hisilicon/Hi1616/Pptt/Pptt.c > @@ -0,0 +1,540 @@ > +/** @file > +* > +* Copyright (c) 2018, Hisilicon Limited. All rights reserved. > +* Copyright (c) 2018, Linaro Limited. All rights reserved. > +* > +* This program and the accompanying materials > +* are licensed and made available under the terms and conditions of the= BSD License > +* which accompanies this distribution. The full text of the license ma= y be found at > +* http://opensource.org/licenses/bsd-license.php > +* > +* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, > +* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR = IMPLIED. > +* > +* Based on the files under Platform/ARM/JunoPkg/AcpiTables/ > +* > +**/ > + > +#include "Pptt.h" > + > +EFI_ACPI_TABLE_PROTOCOL *mAcpiTableProtocol =3D NULL; > +EFI_ACPI_SDT_PROTOCOL *mAcpiSdtProtocol =3D NULL; > + > +EFI_ACPI_DESCRIPTION_HEADER mPpttHeader =3D > + ARM_ACPI_HEADER ( > + EFI_ACPI_6_2_PROCESSOR_PROPERTIES_TOPOLOGY_TABLE_STRUCTURE_SIGNATURE, > + EFI_ACPI_DESCRIPTION_HEADER, > + EFI_ACPI_6_2_PROCESSOR_PROPERTIES_TOPOLOGY_TABLE_REVISION > + ); > + > +EFI_ACPI_6_2_PPTT_STRUCTURE_ID mPpttSocketType2[PPTT_SOCKET_COMPONENT_NO= ] =3D > +{ > + {2, sizeof (EFI_ACPI_6_2_PPTT_STRUCTURE_ID), {0, 0}, 0, 0, 0, 0, 0, 0} > +}; > + > +EFI_ACPI_6_2_PPTT_STRUCTURE_CACHE mPpttCacheType1[PPTT_CACHE_NO]; > + > + > +STATIC > +VOID > +InitCacheInfo ( > + VOID > + ) > +{ > + UINT8 Index; > + EFI_ACPI_6_2_PPTT_STRUCTURE_CACHE_ATTRIBUTES Type1Attributes; > + CSSELR_DATA CsselrData; > + CCSIDR_DATA CcsidrData; > + > + for (Index =3D 0; Index < PPTT_CACHE_NO; Index++) { > + CsselrData.Data =3D 0; > + CcsidrData.Data =3D 0; > + SetMem ( > + &Type1Attributes, > + sizeof (EFI_ACPI_6_2_PPTT_STRUCTURE_CACHE_ATTRIBUTES), > + 0 > + ); > + > + if (Index =3D=3D 0) { //L1I > + CsselrData.Bits.InD =3D 1; > + CsselrData.Bits.Level =3D 0; > + Type1Attributes.CacheType =3D 1; > + } else if (Index =3D=3D 1) { > + Type1Attributes.CacheType =3D 0; > + CsselrData.Bits.Level =3D Index - 1; > + } else { > + Type1Attributes.CacheType =3D 2; > + CsselrData.Bits.Level =3D Index - 1; > + } > + > + CcsidrData.Data =3D ReadCCSIDR (CsselrData.Data); > + > + if (CcsidrData.Bits.Wa =3D=3D 1) { > + Type1Attributes.AllocationType =3D PPTT_TYPE1_ALLOCATION_WRITE; > + if (CcsidrData.Bits.Ra =3D=3D 1) { > + Type1Attributes.AllocationType =3D PPTT_TYPE1_ALLOCATION_READ_W= RITE; > + } > + } > + > + if (CcsidrData.Bits.Wt =3D=3D 1) { > + Type1Attributes.WritePolicy =3D 1; > + } > + DEBUG ((DEBUG_INFO, > + "[Acpi PPTT] Level =3D %x!CcsidrData =3D %x!\n", > + CsselrData.Bits.Level, > + CcsidrData.Data)); > + > + mPpttCacheType1[Index].Type =3D EFI_ACPI_6_2_PPTT_TYPE_CACHE; > + mPpttCacheType1[Index].Length =3D sizeof (EFI_ACPI_6_2_PPTT_STRUCTUR= E_CACHE); > + mPpttCacheType1[Index].Reserved[0] =3D 0; > + mPpttCacheType1[Index].Reserved[1] =3D 0; > + mPpttCacheType1[Index].Flags.SizePropertyValid =3D 1; > + mPpttCacheType1[Index].Flags.NumberOfSetsValid =3D 1; > + mPpttCacheType1[Index].Flags.AssociativityValid =3D 1; > + mPpttCacheType1[Index].Flags.AllocationTypeValid =3D 1; > + mPpttCacheType1[Index].Flags.CacheTypeValid =3D 1; > + mPpttCacheType1[Index].Flags.WritePolicyValid =3D 1; > + mPpttCacheType1[Index].Flags.LineSizeValid =3D 1; > + mPpttCacheType1[Index].Flags.Reserved =3D 0; > + mPpttCacheType1[Index].NextLevelOfCache =3D 0; > + > + if (Index !=3D PPTT_CACHE_NO - 1) { > + mPpttCacheType1[Index].NumberOfSets =3D (UINT16)CcsidrData.Bits.Nu= mSets + 1; > + mPpttCacheType1[Index].Associativity =3D (UINT16)CcsidrData.Bits.A= ssociativity + 1; > + mPpttCacheType1[Index].LineSize =3D (UINT16)( 1 << (CcsidrData.Bit= s.LineSize + 4)); > + mPpttCacheType1[Index].Size =3D mPpttCacheType1[Index].LineSize * = \ > + mPpttCacheType1[Index].Associativity= * \ > + mPpttCacheType1[Index].NumberOfSets; > + CopyMem ( > + &mPpttCacheType1[Index].Attributes, > + &Type1Attributes, > + sizeof (EFI_ACPI_6_2_PPTT_STRUCTURE_CACHE_ATTRIBUTES) > + ); > + } else { > + // L3 cache > + mPpttCacheType1[Index].Size =3D 0x1000000; // 16m > + mPpttCacheType1[Index].NumberOfSets =3D 0x2000; > + mPpttCacheType1[Index].Associativity =3D 0x10; // CacheAssociati= vity16Way > + SetMem ( > + &mPpttCacheType1[Index].Attributes, > + sizeof (EFI_ACPI_6_2_PPTT_STRUCTURE_CACHE_ATTRIBUTES), > + 0x0A > + ); > + mPpttCacheType1[Index].LineSize =3D 0x80; // 128byte > + } > + } > +} > + > +STATIC > +EFI_STATUS > +AddCoreTable ( > + IN EFI_ACPI_DESCRIPTION_HEADER *PpttTable, > + IN OUT UINT32 *PpttTableLengthRemain, > + IN UINT32 Flags, > + IN UINT32 Parent, > + IN UINT32 ResourceNo, > + IN UINT32 ProcessorId > + ) > +{ > + EFI_ACPI_6_2_PPTT_TYPE0 *PpttType0; > + EFI_ACPI_6_2_PPTT_STRUCTURE_CACHE *PpttType1; > + UINT32 *PrivateResource; > + UINT8 Index; > + > + if (*PpttTableLengthRemain < > + (sizeof (EFI_ACPI_6_2_PPTT_TYPE0) + ResourceNo * 4)) { > + return EFI_OUT_OF_RESOURCES; > + } > + PpttType0 =3D (EFI_ACPI_6_2_PPTT_TYPE0 *)((UINT8 *)PpttTable + > + PpttTable->Lengt= h); > + PpttType0->Type =3D 0; > + CopyMem (&PpttType0->Flags, &Flags, sizeof(PpttType0->Flags));; > + PpttType0->Parent=3D Parent; > + PpttType0->AcpiProcessorId =3D ProcessorId; > + PpttType0->NumberOfPrivateResources =3D ResourceNo; > + PpttType0->Length =3D sizeof (EFI_ACPI_6_2_PPTT_TYPE0) + > + ResourceNo * 4; > + > + *PpttTableLengthRemain -=3D (UINTN)PpttType0->Length; > + PpttTable->Length +=3D PpttType0->Length; > + PrivateResource =3D (UINT32 *)((UINT8 *)PpttType0 + > + sizeof (EFI_ACPI_6_2_PPTT_TYPE0)); > + > + // Add cache type structure > + for (Index =3D 0; Index < ResourceNo; Index++, PrivateResource++) { > + if (*PpttTableLengthRemain < sizeof (EFI_ACPI_6_2_PPTT_STRUCTURE_CAC= HE)) { > + return EFI_OUT_OF_RESOURCES; > + } > + *PrivateResource =3D PpttTable->Length; > + PpttType1 =3D (EFI_ACPI_6_2_PPTT_STRUCTURE_CACHE *)((UINT8 *)PpttTab= le + > + PpttTable->Length); > + gBS->CopyMem ( > + PpttType1, > + &mPpttCacheType1[Index], > + sizeof (EFI_ACPI_6_2_PPTT_STRUCTURE_CACHE) > + ); > + *PpttTableLengthRemain -=3D PpttType1->Length; > + PpttTable->Length +=3D PpttType1->Length; > + } > + > + return EFI_SUCCESS; > +} > + > +STATIC > +EFI_STATUS > +AddClusterTable ( > + IN EFI_ACPI_DESCRIPTION_HEADER *PpttTable, > + IN OUT UINT32 *PpttTableLengthRemain, > + IN UINT32 Flags, > + IN UINT32 Parent, > + IN UINT32 ResourceNo > + ) > +{ > + EFI_ACPI_6_2_PPTT_TYPE0 *PpttType0; > + EFI_ACPI_6_2_PPTT_STRUCTURE_CACHE *PpttType1; > + UINT32 *PrivateResource; > + > + if ((*PpttTableLengthRemain) < > + (sizeof (EFI_ACPI_6_2_PPTT_TYPE0) + ResourceNo * 4)) { > + return EFI_OUT_OF_RESOURCES; > + } > + PpttType0 =3D (EFI_ACPI_6_2_PPTT_TYPE0 *)((UINT8 *)PpttTable + > + PpttTable->Lengt= h); > + PpttType0->Type =3D 0; > + CopyMem (&PpttType0->Flags, &Flags, sizeof(PpttType0->Flags));; > + PpttType0->Parent=3D Parent; > + PpttType0->NumberOfPrivateResources =3D ResourceNo; > + PpttType0->Length =3D sizeof (EFI_ACPI_6_2_PPTT_TYPE0) + > + ResourceNo * 4; > + > + *PpttTableLengthRemain -=3D PpttType0->Length; > + PpttTable->Length +=3D PpttType0->Length; > + PrivateResource =3D (UINT32 *)((UINT8 *)PpttType0 + > + sizeof (EFI_ACPI_6_2_PPTT_TYPE0)); > + > + // Add cache type structure > + if (*PpttTableLengthRemain < sizeof (EFI_ACPI_6_2_PPTT_STRUCTURE_CACHE= )) { > + return EFI_OUT_OF_RESOURCES; > + } > + *PrivateResource =3D PpttTable->Length; > + PpttType1 =3D (EFI_ACPI_6_2_PPTT_STRUCTURE_CACHE *)((UINT8 *)PpttTable= + > + PpttTable->Length); > + gBS->CopyMem ( > + PpttType1, > + &mPpttCacheType1[2], > + sizeof (EFI_ACPI_6_2_PPTT_STRUCTURE_CACHE) > + ); > + *PpttTableLengthRemain -=3D PpttType1->Length; > + PpttTable->Length +=3D PpttType1->Length; > + > + return EFI_SUCCESS; > +} > + > +STATIC > +EFI_STATUS > +AddScclTable ( > + IN EFI_ACPI_DESCRIPTION_HEADER *PpttTable, > + IN OUT UINT32 *PpttTableLengthRemain, > + IN UINT32 Flags, > + IN UINT32 Parent, > + IN UINT32 ResourceNo > + ) > +{ > + EFI_ACPI_6_2_PPTT_TYPE0 *PpttType0; > + EFI_ACPI_6_2_PPTT_STRUCTURE_CACHE *PpttType1; > + UINT32 *PrivateResource; > + > + if (*PpttTableLengthRemain < > + (sizeof (EFI_ACPI_6_2_PPTT_TYPE0) + ResourceNo * 4)) { > + return EFI_OUT_OF_RESOURCES; > + } > + PpttType0 =3D (EFI_ACPI_6_2_PPTT_TYPE0 *)((UINT8 *)PpttTable + > + PpttTable->Lengt= h); > + PpttType0->Type =3D 0; > + CopyMem (&PpttType0->Flags, &Flags, sizeof(PpttType0->Flags));; > + PpttType0->Parent=3D Parent; > + PpttType0->NumberOfPrivateResources =3D ResourceNo; > + PpttType0->Length =3D sizeof (EFI_ACPI_6_2_PPTT_TYPE0) + > + ResourceNo * 4; > + > + *PpttTableLengthRemain -=3D PpttType0->Length; > + PpttTable->Length +=3D PpttType0->Length; > + PrivateResource =3D (UINT32 *)((UINT8 *)PpttType0 + > + sizeof (EFI_ACPI_6_2_PPTT_TYPE0)); > + > + // Add cache type structure > + if (*PpttTableLengthRemain < sizeof (EFI_ACPI_6_2_PPTT_STRUCTURE_CACHE= )) { > + return EFI_OUT_OF_RESOURCES; > + } > + *PrivateResource =3D PpttTable->Length; > + PpttType1 =3D (EFI_ACPI_6_2_PPTT_STRUCTURE_CACHE *)((UINT8 *)PpttTable= + > + PpttTable->Length); > + gBS->CopyMem ( > + PpttType1, > + &mPpttCacheType1[3], > + sizeof (EFI_ACPI_6_2_PPTT_STRUCTURE_CACHE) > + ); > + *PpttTableLengthRemain -=3D PpttType1->Length; > + PpttTable->Length +=3D PpttType1->Length; > + > + return EFI_SUCCESS; > +} > + > +STATIC > +EFI_STATUS > +AddSocketTable ( > + IN EFI_ACPI_DESCRIPTION_HEADER *PpttTable, > + IN OUT UINT32 *PpttTableLengthRemain, > + IN UINT32 Flags, > + IN UINT32 Parent, > + IN UINT32 ResourceNo > + ) > +{ > + EFI_ACPI_6_2_PPTT_TYPE0 *PpttType0; > + EFI_ACPI_6_2_PPTT_STRUCTURE_ID *PpttType2; > + UINT32 *PrivateResource; > + UINT8 Index; > + > + if (*PpttTableLengthRemain < sizeof (EFI_ACPI_6_2_PPTT_TYPE0)) { > + return EFI_OUT_OF_RESOURCES; > + } > + PpttType0 =3D (EFI_ACPI_6_2_PPTT_TYPE0 *)((UINT8 *)PpttTable + > + PpttTable->Lengt= h); > + PpttType0->Type =3D 0; > + CopyMem (&PpttType0->Flags, &Flags, sizeof(PpttType0->Flags));; > + PpttType0->Parent=3D Parent; > + PpttType0->NumberOfPrivateResources =3D ResourceNo; > + PpttType0->Length =3D sizeof (EFI_ACPI_6_2_PPTT_TYPE0) + > + ResourceNo * 4; > + PpttTable->Length +=3D PpttType0->Length; > + > + *PpttTableLengthRemain -=3D PpttType0->Length; > + if (*PpttTableLengthRemain < ResourceNo * 4) { > + return EFI_OUT_OF_RESOURCES; > + } > + PrivateResource =3D (UINT32 *)((UINT8 *)PpttType0 + > + sizeof (EFI_ACPI_6_2_PPTT_TYPE0)); > + DEBUG ((DEBUG_INFO, > + "[Acpi PPTT] sizeof(EFI_ACPI_6_2_PPTT_STRUCTURE_ID) =3D %x!\n= ", > + sizeof (EFI_ACPI_6_2_PPTT_STRUCTURE_ID))); > + > + for (Index =3D 0; Index < ResourceNo; Index++, PrivateResource++) { > + if (*PpttTableLengthRemain < sizeof (EFI_ACPI_6_2_PPTT_STRUCTURE_ID)= ) { > + return EFI_OUT_OF_RESOURCES; > + } > + *PrivateResource =3D PpttTable->Length; > + PpttType2 =3D (EFI_ACPI_6_2_PPTT_STRUCTURE_ID *)((UINT8 *)PpttTable + > + PpttTable->Length); > + gBS->CopyMem ( > + PpttType2, > + &mPpttSocketType2[Index], > + sizeof (EFI_ACPI_6_2_PPTT_STRUCTURE_ID) > + ); > + *PpttTableLengthRemain -=3D PpttType2->Length; > + PpttTable->Length +=3D PpttType2->Length; > + } > + > + return EFI_SUCCESS; > +} > + > +STATIC > +VOID > +GetApic ( > + IN EFI_ACPI_6_1_MULTIPLE_APIC_DESCRIPTION_TABLE *ApicTable, > + IN OUT EFI_ACPI_DESCRIPTION_HEADER *PpttTable, > + IN UINT32 PpttTableLengthRem= ain, > + IN UINT32 Index1 > +) > +{ > + UINT32 IndexSocket, IndexSccl, IndexCluster, IndexCore; > + UINT32 SocketOffset, ScclOffset, ClusterOffset; > + UINT32 Parent =3D 0; > + UINT32 Flags =3D 0; > + UINT32 ResourceNo =3D 0; > + > + // Get APIC data > + for (IndexSocket =3D 0; IndexSocket < PPTT_SOCKET_NO; IndexSocket++) { > + SocketOffset =3D 0; > + for (IndexSccl =3D 0; IndexSccl < PPTT_SCCL_NO; IndexSccl++) { > + ScclOffset =3D 0; > + for (IndexCluster =3D 0; IndexCluster < PPTT_CLUSTER_NO; IndexClus= ter++) { > + ClusterOffset =3D 0; > + for (IndexCore =3D 0; IndexCore < PPTT_CORE_NO; IndexCore++) { > + if (ApicTable->GicInterfaces[Index1].AcpiProcessorUid !=3D Ind= ex1) { > + // This processor is unusable > + DEBUG ((DEBUG_ERROR, "[Acpi PPTT] Please check MADT table fo= r UID!\n")); > + return; > + } > + if ((ApicTable->GicInterfaces[Index1].Flags & BIT0) =3D=3D 0) { > + // This processor is unusable > + Index1++; > + continue; > + } > + > + if (SocketOffset =3D=3D 0) { > + // Add socket0 for type0 table > + ResourceNo =3D PPTT_SOCKET_COMPONENT_NO; > + SocketOffset =3D PpttTable->Length; > + Parent =3D 0; > + Flags =3D PPTT_TYPE0_SOCKET_FLAG; > + AddSocketTable ( > + PpttTable, > + &PpttTableLengthRemain, > + Flags, > + Parent, > + ResourceNo > + ); > + } > + if (ScclOffset =3D=3D 0) { > + // Add socket0sccl0 for type0 table > + ResourceNo =3D 1; > + ScclOffset =3D PpttTable->Length; > + Parent =3D SocketOffset; > + Flags =3D PPTT_TYPE0_SCCL_FLAG; > + AddScclTable ( > + PpttTable, > + &PpttTableLengthRemain, > + Flags, > + Parent, > + ResourceNo > + ); > + } > + if (ClusterOffset =3D=3D 0) { > + // Add socket0sccl0ClusterId for type0 table > + ResourceNo =3D 1; > + ClusterOffset =3D PpttTable->Length ; > + Parent =3D ScclOffset; > + Flags =3D PPTT_TYPE0_CLUSTER_FLAG; > + AddClusterTable ( > + PpttTable, > + &PpttTableLengthRemain, > + Flags, > + Parent, > + ResourceNo > + ); > + } > + > + // Add socket0sccl0ClusterIdCoreId for type0 table > + ResourceNo =3D 2; > + Parent =3D ClusterOffset; > + Flags =3D PPTT_TYPE0_CORE_FLAG; > + AddCoreTable ( > + PpttTable, > + &PpttTableLengthRemain, > + Flags, > + Parent, > + ResourceNo, > + Index1 > + ); > + > + Index1++; > + } > + } > + } > + } > + return ; > +} > + > +STATIC > +VOID > +PpttSetAcpiTable ( > + IN EFI_EVENT Event, > + IN VOID *Context > + ) > +{ > + UINTN AcpiTableHandle; > + EFI_STATUS Status; > + UINT8 Checksum; > + EFI_ACPI_SDT_HEADER *Table; > + EFI_ACPI_6_1_MULTIPLE_APIC_DESCRIPTION_TABLE *ApicTable; > + EFI_ACPI_TABLE_VERSION TableVersion; > + EFI_ACPI_DESCRIPTION_HEADER *PpttTable; > + UINTN TableKey; > + UINT32 Index0, Index1; > + UINT32 PpttTableLengthRemain = =3D 0; > + > + gBS->CloseEvent (Event); > + > + InitCacheInfo (); > + > + PpttTable =3D (EFI_ACPI_DESCRIPTION_HEADER *)AllocateZeroPool (PPTT_TA= BLE_MAX_LEN); > + gBS->CopyMem ( > + (VOID *)PpttTable, > + &mPpttHeader, > + sizeof (EFI_ACPI_DESCRIPTION_HEADER) > + ); > + PpttTableLengthRemain =3D PPTT_TABLE_MAX_LEN - sizeof (EFI_ACPI_DESCRI= PTION_HEADER); > + > + for (Index0 =3D 0; Index0 < EFI_ACPI_MAX_NUM_TABLES; Index0++) { > + Status =3D mAcpiSdtProtocol->GetAcpiTable ( > + Index0, > + &Table, > + &TableVersion, > + &TableKey > + ); > + if (EFI_ERROR (Status)) { > + break; > + } > + > + // Find APIC table > + if (Table->Signature =3D=3D EFI_ACPI_6_1_MULTIPLE_APIC_DESCRIPTION_T= ABLE_SIGNATURE) { > + break; > + } > + > + } > + > + if (!EFI_ERROR (Status) && (Index0 !=3D EFI_ACPI_MAX_NUM_TABLES)) { > + ApicTable =3D (EFI_ACPI_6_1_MULTIPLE_APIC_DESCRIPTION_TABLE *)Table; > + Index1 =3D 0; > + > + GetApic (ApicTable, PpttTable, PpttTableLengthRemain, Index1); > + > + Checksum =3D CalculateCheckSum8 ((UINT8 *)(PpttTable), PpttTable->Le= ngth); > + PpttTable->Checksum =3D Checksum; > + > + AcpiTableHandle =3D 0; > + Status =3D mAcpiTableProtocol->InstallAcpiTable ( > + mAcpiTableProtocol, > + PpttTable, > + PpttTable->Length, > + &AcpiTableHandle); > + } > + > + FreePool (PpttTable); > + return ; > +} > + > +EFI_STATUS > +EFIAPI > +PpttEntryPoint( > + IN EFI_HANDLE ImageHandle, > + IN EFI_SYSTEM_TABLE *SystemTable > + ) > +{ > + EFI_STATUS Status; > + EFI_EVENT ReadyToBootEvent; > + > + Status =3D gBS->LocateProtocol ( > + &gEfiAcpiTableProtocolGuid, > + NULL, > + (VOID **)&mAcpiTableProtocol); > + ASSERT_EFI_ERROR (Status); > + > + Status =3D gBS->LocateProtocol ( > + &gEfiAcpiSdtProtocolGuid, > + NULL, > + (VOID **)&mAcpiSdtProtocol); > + ASSERT_EFI_ERROR (Status); > + > + Status =3D EfiCreateEventReadyToBootEx ( > + TPL_NOTIFY, > + PpttSetAcpiTable, > + NULL, > + &ReadyToBootEvent > + ); > + ASSERT_EFI_ERROR (Status); > + > + DEBUG ((DEBUG_INFO, "Acpi Pptt init done.\n")); > + > + return Status; > +} > diff --git a/Silicon/Hisilicon/Hi1616/Pptt/Pptt.h b/Silicon/Hisilicon/Hi1= 616/Pptt/Pptt.h > new file mode 100644 > index 0000000..57f8386 > --- /dev/null > +++ b/Silicon/Hisilicon/Hi1616/Pptt/Pptt.h > @@ -0,0 +1,88 @@ > +/** @file > +* > +* Copyright (c) 2018, Hisilicon Limited. All rights reserved. > +* Copyright (c) 2018, Linaro Limited. All rights reserved. > +* > +* This program and the accompanying materials > +* are licensed and made available under the terms and conditions of the= BSD License > +* which accompanies this distribution. The full text of the license ma= y be found at > +* http://opensource.org/licenses/bsd-license.php > +* > +* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, > +* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR = IMPLIED. > +* > +* Based on the files under Platform/ARM/JunoPkg/AcpiTables/ > +* > +**/ > + > +#ifndef _PPTT_H_ > +#define _PPTT_H_ > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include "../D05AcpiTables/Hi1616Platform.h" > + > +#define EFI_ACPI_MAX_NUM_TABLES 20 > + > +#define PPTT_TABLE_MAX_LEN 0x6000 > +#define PPTT_SOCKET_NO 0x2 > +#define PPTT_SCCL_NO 0x2 > +#define PPTT_CLUSTER_NO 0x4 > +#define PPTT_CORE_NO 0x4 > +#define PPTT_SOCKET_COMPONENT_NO 0x1 > +#define PPTT_CACHE_NO 0x4 > + > +#define PPTT_TYPE0_PHYSICAL_PKG BIT0 > +#define PPTT_TYPE0_PROCESSORID_VALID BIT1 > +#define PPTT_TYPE0_SOCKET_FLAG PPTT_TYPE0_PHYSICAL_PKG > +#define PPTT_TYPE0_SCCL_FLAG 0 > +#define PPTT_TYPE0_CLUSTER_FLAG 0 > +#define PPTT_TYPE0_CORE_FLAG PPTT_TYPE0_PROCESSORID_VALID > + > +#define PPTT_TYPE1_ALLOCATION_WRITE 0x1 > +#define PPTT_TYPE1_ALLOCATION_READ_WRITE 0x2 > + > +typedef union { > + struct { > + UINT32 InD :1; > + UINT32 Level :3; > + UINT32 Reserved :28; > + } Bits; > + UINT32 Data; > +} CSSELR_DATA; > + > +typedef union { > + struct { > + UINT32 LineSize :3; > + UINT32 Associativity :10; > + UINT32 NumSets :15; > + UINT32 Wa :1; > + UINT32 Ra :1; > + UINT32 Wb :1; > + UINT32 Wt :1; > + } Bits; > + UINT32 Data; > +} CCSIDR_DATA; > + > +// > +// Processor Hierarchy Node Structure > +// > +typedef struct { > + UINT8 Type; > + UINT8 Length; > + UINT8 Reserved[2]; > + UINT32 Flags; > + UINT32 Parent; > + UINT32 AcpiProcessorId; > + UINT32 NumberOfPrivateResources; > +} EFI_ACPI_6_2_PPTT_TYPE0; > + > +#endif // _PPTT_H_ > + > diff --git a/Silicon/Hisilicon/Hi1616/Pptt/Pptt.inf b/Silicon/Hisilicon/H= i1616/Pptt/Pptt.inf > new file mode 100644 > index 0000000..ff6f772 > --- /dev/null > +++ b/Silicon/Hisilicon/Hi1616/Pptt/Pptt.inf > @@ -0,0 +1,48 @@ > +/** @file > +* > +* Copyright (c) 2018, Hisilicon Limited. All rights reserved. > +* Copyright (c) 2018, Linaro Limited. All rights reserved. > +* > +* This program and the accompanying materials > +* are licensed and made available under the terms and conditions of the= BSD License > +* which accompanies this distribution. The full text of the license ma= y be found at > +* http://opensource.org/licenses/bsd-license.php > +* > +* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, > +* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR = IMPLIED. > +* > +* Based on the files under Platform/ARM/JunoPkg/AcpiTables/ > +* > +**/ > + > +[Defines] > + INF_VERSION =3D 0x0001001A > + BASE_NAME =3D AcpiPptt > + FILE_GUID =3D AAB14F90-DC2E-4f33-A594-C7894A5B412D > + MODULE_TYPE =3D DXE_DRIVER > + VERSION_STRING =3D 1.0 > + ENTRY_POINT =3D PpttEntryPoint > + > +[Sources.common] > + Pptt.c > + > +[Packages] > + ArmPkg/ArmPkg.dec > + MdePkg/MdePkg.dec > + Silicon/Hisilicon/HisiPkg.dec > + > +[LibraryClasses] > + ArmLib > + BaseMemoryLib > + DebugLib > + HobLib > + UefiDriverEntryPoint > + UefiRuntimeServicesTableLib > + > +[Protocols] > + gEfiAcpiSdtProtocolGuid ## PROTOCOL ALWAYS_CONSU= MED > + gEfiAcpiTableProtocolGuid ## PROTOCOL ALWAYS_CONSU= MED > + > +[Depex] > + gEfiAcpiTableProtocolGuid AND gEfiAcpiSdtProtocolGuid > + > --=20 > 1.9.1 >=20 --rJwd6BRFiFCcLxzm Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEenb+qYJ1KjE/UpmZkGKawB22KXYFAlpwgScACgkQkGKawB22 KXa9iA//cvJ85TDcuzBPelPTcHu7VlSF3zyc/EQC3X0ou6PSEoP9BSsU74KRrWfE EWuSnyfbaHjlUIEGLIyX8eCVSc8OvF1whstSji5x16afPQOJ9/ZqMmtdIZpdrwJg TBc6VlnFt4kBeO1CaD971ZPRYeNeGtjmNYXToS7LKhrXsEWtDfrFEoq0KtIzAIFA ahgLeaDIWNY61pIZvV9ETVhKte0+bOI13K3lX0frFem/HIdKasw2F2a8gF93u7tr 6eIHHp07gbMOkUkiEDexUUFH5QeI4CoAnRPExPiRg1Rpoj6X7tLdjUyhOHLN+A+C O7yNaTDl2tH/zexbQ+Eu503OEoyM75WnD6UqGHLNbcY0gH7G3hrkQpDBvi4pyz94 q08a8r2/zxSTJMiyknYvCIctRfNKGpr4Xpt3YS0+ixlUZT/f7aNdH2CKlNOCEfvN QJnb22hmcToiRIDu+GIeEJpoM32MTgvlUvbUqwGAqa2i7FAtsrPBWLx31jUPcVry Bs5yhwYq11LXUFrjvVuCWwNYaMVOFdxG9P/OKDiyoN9EJuBtzWcV3v6YVCyJy8OE M8BVEyE6adR/9GMhqHsGI0YDT1K2ynBj3sebjHlkGb7Iwixyso3gX5P5gijix/Nk 7MFKJuCzntQZXD6dC/xvioQ2P9+wdnRRJihfTKHaEPSjuikyUQQ= =5LV7 -----END PGP SIGNATURE----- --rJwd6BRFiFCcLxzm--