From patchwork Fri Nov 10 14:20:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 118538 Delivered-To: patch@linaro.org Received: by 10.80.225.132 with SMTP id k4csp2257788edl; Fri, 10 Nov 2017 06:22:09 -0800 (PST) X-Google-Smtp-Source: AGs4zMYwIP6hxw20pAeA35c73Mac22+rlNqgK+NaGOV2acSLyy6MQZc44bf9J+fVVEM5DGHx1hdY X-Received: by 10.98.202.131 with SMTP id y3mr528564pfk.199.1510323729382; Fri, 10 Nov 2017 06:22:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510323729; cv=none; d=google.com; s=arc-20160816; b=cN4KEOWwOBhMRcNgQhjw0kc4Y/9MYgkmp6OVaowwb25MIoY49gPzjOJkiz6eESX8DE 5szyd4vmP+86K6IeUECoBgi0d5FF2NtxG7OGj3OiaIKQJb+JzDbfjWs5YBIM0QjEPLhE NsMMeI1xV1+Yl2Ivpdm1vLmrvCLKmHoK45PCNiEltlQ1yJJkANhK6poVyQSwW46RHNfN 3Go/7A0SUt4LQZ9klfx4Z91tfSyjVpV8ihxS3gk/bt35bNPbwfj0HD3Ns3x1HoxKWqgA WlLT0Mfe+RZwpMXbuwck0M5VdT2qnvr0Sfb7hEaiEtXp+H3IqqBiKsiBI/DfVfmvc6At OzfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to:arc-authentication-results; bh=eG7hBLLz3pNtma9al1Sh5+DjYyPED1S3Qx6oLZ2J3tU=; b=XYTGFfAQxYBmNMCMl5m77Iztk9gNr3tUsz/rfgYhP4nIAyROEVIw4vMHpeEsbPlM2M C0nbTaAb1BTwzJF/8LWZOKujjul2qn1cfMTJ/TuSOj4rX/xAB1SpE7EOel7L+J1KxoxW Vr7paDkLjxPqpMbZI+D+eFDcFWgFmyFbKwrRBRLraSJQg2i8va20svKjLU7SITKD55ir lOmxH+Q0yNqKgp51vRNuH39WZCJ4P7eMAO4aiecHaiUh0mjbdHH/g39HkqRksUCvh1mB q1kF+gZHd/y+XKAeh3SDh5B4FfTCrRqtkGmaccvHlMjLp/QfDl7nwjWXRAKBRAgL01X+ wtmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=I3akhPv/; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id z188si8602244pgb.121.2017.11.10.06.22.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Nov 2017 06:22:09 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) client-ip=2001:19d0:306:5::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=I3akhPv/; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id CD90721B00DCC; Fri, 10 Nov 2017 06:17:59 -0800 (PST) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:400c:c09::242; helo=mail-wm0-x242.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wm0-x242.google.com (mail-wm0-x242.google.com [IPv6:2a00:1450:400c:c09::242]) (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 F2F8A2035521F for ; Fri, 10 Nov 2017 06:17:58 -0800 (PST) Received: by mail-wm0-x242.google.com with SMTP id r68so6055198wmr.0 for ; Fri, 10 Nov 2017 06:22:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=/1fqbGb9r6GsQY8j9YGPb5EXzLZFFkjBUbuaMa2wm1E=; b=I3akhPv/gHKIhBwMeumE+heZ48Z6eAMk19aDDas8pDDtYI+FA/RvzI/71sNX48E0Ax g/XQhlwsNwUMLcBmWiU0Bhr+SvTmR6l0OkCNLQmC6jzr8TyMEv2voF77ZixWDJPQhDMM m1zufeKEybu01tCBVX5DMufq3Reg1ali6zUmE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=/1fqbGb9r6GsQY8j9YGPb5EXzLZFFkjBUbuaMa2wm1E=; b=pnE3zS6CGMHIk2+Q9qliLk9Jm9LYq8Q4jUfNxLa23AkDZkecbjSE4hw35M0q2CW7X+ CSyI72/Sdq547j+dwlRNGCe6FKs+4L75yPupfKfGGNKrLtAAGeRHz1aSsU9Vpui5Ph9E t5jtSDJOPuDFYE+OyCZBSPXrP/ps/tQD60G8/3Gpn1pTSwGV85bUqUMvRRf6xi9ZybTb ofT0UzkRSpSjl7Dxfc4B2OBJ1a493iHgOwf6SHpqrkKS0wfDOnoVdG+XEq6wqu2TLf+L H4ZigN3ARdcwysSRWP6UlBje5sv0WWcG1KubchDIm+nrwAbjkJo+tpFle3rO03ooCQdM cAyA== X-Gm-Message-State: AJaThX5B7/7jftCWfqbSo0XXrfH4dOa0dRg7umOvsz6tx1XM5GAHiqPG 0/SbTiu5XouFD3G7l2yCidlQ6a+W9bM= X-Received: by 10.28.193.66 with SMTP id r63mr375449wmf.18.1510323719888; Fri, 10 Nov 2017 06:21:59 -0800 (PST) Received: from localhost.localdomain ([160.167.170.128]) by smtp.gmail.com with ESMTPSA id e131sm1036477wmg.15.2017.11.10.06.21.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Nov 2017 06:21:59 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org, leif.lindholm@linaro.org, daniel.thompson@linaro.org Date: Fri, 10 Nov 2017 14:20:57 +0000 Message-Id: <20171110142127.12018-5-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171110142127.12018-1-ard.biesheuvel@linaro.org> References: <20171110142127.12018-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH edk2-platforms v4 04/34] Silicon/SynQuacer: implement a platform DXE driver X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: masahisa.kojima@linaro.org, masami.hiramatsu@linaro.org, Ard Biesheuvel MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" This implements a driver that will take care of platform specific initialization, such as declaring non-discoverable devices, and installing the device tree blob as a configuration table. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel Reviewed-by: Leif Lindholm --- Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.c | 122 ++++++++++++++++++++ Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.inf | 55 +++++++++ Silicon/Socionext/SynQuacer/SynQuacer.dec | 3 + 3 files changed, 180 insertions(+) -- 2.11.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.c b/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.c new file mode 100644 index 000000000000..9639ffffc09f --- /dev/null +++ b/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.c @@ -0,0 +1,122 @@ +/** @file + SynQuacer DXE platform driver. + + Copyright (c) 2017, Linaro, Ltd. 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 may 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. +**/ + +#include +#include +#include +#include +#include +#include +#include +#include + +STATIC EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR mNetsecDesc[] = { + { + ACPI_ADDRESS_SPACE_DESCRIPTOR, // Desc + sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR) - 3, // Len + ACPI_ADDRESS_SPACE_TYPE_MEM, // ResType + 0, // GenFlag + 0, // SpecificFlag + 32, // AddrSpaceGranularity + SYNQUACER_NETSEC1_BASE, // AddrRangeMin + SYNQUACER_NETSEC1_BASE + + SYNQUACER_NETSEC1_BASE_SZ - 1, // AddrRangeMax + 0, // AddrTranslationOffset + SYNQUACER_NETSEC1_BASE_SZ, // AddrLen + }, { + ACPI_ADDRESS_SPACE_DESCRIPTOR, // Desc + sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR) - 3, // Len + ACPI_ADDRESS_SPACE_TYPE_MEM, // ResType + 0, // GenFlag + 0, // SpecificFlag + 32, // AddrSpaceGranularity + FixedPcdGet32 (PcdNetsecEepromBase), // AddrRangeMin + FixedPcdGet32 (PcdNetsecEepromBase) + + SYNQUACER_EEPROM_BASE_SZ - 1, // AddrRangeMax + 0, // AddrTranslationOffset + SYNQUACER_EEPROM_BASE_SZ, // AddrLen + }, { + ACPI_ADDRESS_SPACE_DESCRIPTOR, // Desc + sizeof (EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR) - 3, // Len + ACPI_ADDRESS_SPACE_TYPE_MEM, // ResType + 0, // GenFlag + 0, // SpecificFlag + 32, // AddrSpaceGranularity + FixedPcdGet32 (PcdNetsecPhyAddress), // AddrRangeMin + FixedPcdGet32 (PcdNetsecPhyAddress), // AddrRangeMax + 0, // AddrTranslationOffset + 1, // AddrLen + }, { + ACPI_END_TAG_DESCRIPTOR // Desc + } +}; + +STATIC +EFI_STATUS +RegisterNetsec ( + VOID + ) +{ + NON_DISCOVERABLE_DEVICE *Device; + EFI_STATUS Status; + EFI_HANDLE Handle; + + Device = (NON_DISCOVERABLE_DEVICE *)AllocateZeroPool (sizeof (*Device)); + if (Device == NULL) { + return EFI_OUT_OF_RESOURCES; + } + + Device->Type = &gNetsecNonDiscoverableDeviceGuid; + Device->DmaType = NonDiscoverableDeviceDmaTypeNonCoherent; + Device->Resources = mNetsecDesc; + + Handle = NULL; + Status = gBS->InstallMultipleProtocolInterfaces (&Handle, + &gEdkiiNonDiscoverableDeviceProtocolGuid, Device, + NULL); + if (EFI_ERROR (Status)) { + goto FreeDevice; + } + return EFI_SUCCESS; + +FreeDevice: + FreePool (Device); + + return Status; +} + +EFI_STATUS +EFIAPI +PlatformDxeEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + VOID *Dtb; + UINTN DtbSize; + + Dtb = NULL; + Status = DtPlatformLoadDtb (&Dtb, &DtbSize); + if (!EFI_ERROR (Status)) { + Status = gBS->InstallConfigurationTable (&gFdtTableGuid, Dtb); + } + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, + "%a: failed to install FDT configuration table - %r\n", __FUNCTION__, + Status)); + } + + return RegisterNetsec (); +} diff --git a/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.inf b/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.inf new file mode 100644 index 000000000000..25e6248f1c61 --- /dev/null +++ b/Silicon/Socionext/SynQuacer/Drivers/PlatformDxe/PlatformDxe.inf @@ -0,0 +1,55 @@ +## @file +# +# Component description file for the SynQuacer DXE platform driver. +# +# Copyright (c) 2017, Linaro, Ltd. 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 may 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. +# +## + +[Defines] + INF_VERSION = 0x0001001A + BASE_NAME = PlatformDxe + FILE_GUID = ac422cc1-d916-489a-b165-536fdfc633c2 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + ENTRY_POINT = PlatformDxeEntryPoint + +[Sources] + PlatformDxe.c + +[Packages] + EmbeddedPkg/EmbeddedPkg.dec + MdeModulePkg/MdeModulePkg.dec + MdePkg/MdePkg.dec + Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/NetsecDxe.dec + Silicon/Socionext/SynQuacer/SynQuacer.dec + +[LibraryClasses] + BaseMemoryLib + DebugLib + DtPlatformDtbLoaderLib + MemoryAllocationLib + UefiBootServicesTableLib + UefiDriverEntryPoint + +[Guids] + gFdtTableGuid + gNetsecNonDiscoverableDeviceGuid + +[Protocols] + gEdkiiNonDiscoverableDeviceProtocolGuid ## PRODUCES + +[FixedPcd] + gSynQuacerTokenSpaceGuid.PcdNetsecEepromBase + gSynQuacerTokenSpaceGuid.PcdNetsecPhyAddress + +[Depex] + TRUE diff --git a/Silicon/Socionext/SynQuacer/SynQuacer.dec b/Silicon/Socionext/SynQuacer/SynQuacer.dec index 1249ce688600..1a683b81521b 100644 --- a/Silicon/Socionext/SynQuacer/SynQuacer.dec +++ b/Silicon/Socionext/SynQuacer/SynQuacer.dec @@ -27,3 +27,6 @@ [Ppis] [PcdsFixedAtBuild] gSynQuacerTokenSpaceGuid.PcdDramInfoBase|0|UINT64|0x00000001 + + gSynQuacerTokenSpaceGuid.PcdNetsecEepromBase|0|UINT32|0x00000002 + gSynQuacerTokenSpaceGuid.PcdNetsecPhyAddress|0|UINT8|0x00000003