From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2607:f8b0:4001:c06::244; helo=mail-io0-x244.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-io0-x244.google.com (mail-io0-x244.google.com [IPv6:2607:f8b0:4001:c06::244]) (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 4BC9C226EAC8C for ; Sun, 15 Apr 2018 23:25:45 -0700 (PDT) Received: by mail-io0-x244.google.com with SMTP id v13so16763009iob.6 for ; Sun, 15 Apr 2018 23:25:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=BpZB8rKBcmdYAL4YliPKjOAUZCfv8ew5/1ifIW4qTqI=; b=PZ8WB0YVrar8ClNghFXP16hC6cQfzV7+PMAQqPa7aEcx06PQN8xExvKGn3J1Q2ctVI TAbhFV+2IZqL1rPayihsJAnEcZqyBp4aWJyUdCfO59VWQEZ9AeoJ+nEIXAHYum9Tpgfx HReU8E/Mq3Ncd12ZQgkb6RBr5tAxUpzc3JARM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=BpZB8rKBcmdYAL4YliPKjOAUZCfv8ew5/1ifIW4qTqI=; b=U7fLogNCMHK/m85Eza+uumUyoMC1dW1H4U9LhGnf6HIqylZ0cqmuss0FwWKHc9jj02 RLDU6P8ONTOHgrgeLK4jVCZx9ll/0SdPBIwv9AsHl/UVsLyRmadgt6xpdRkYfMHm6W7u 7lIelZaacmA+viNwVaHPOIiY+ObWq6dYp84cSQ3wykf/6XLQHgLRXKg/1PFAukZaaACU aIkyyx98laJEbgJhtLMTKQwgMSo739jH81Jf541XrraI0h4lvW+tLtQsMVrB8AUtG+tB atGqDCGGMqt22usnSp6ZqEmwicJjXfAJxnBdtsk/EDoHjHVSMefSianG+mwIoZjuM8ex zqCA== X-Gm-Message-State: ALQs6tBdPvTTOnaF6k0kLZlxfC8hYorIr8KNDFFCoi2nXBm8t7FiiDxf oFRW7aMZe4sSIhbgqN//IBs5amRi/JN/+W7dGssFig== X-Google-Smtp-Source: AIpwx48HrJM1A5glr3GKBPzhqeTOJl74yJYFR8exRedCTNk8Wo7T2CCdcQEQjJ+XEfEBJXUSarnzqJSPDJa6dZQ6fpw= X-Received: by 10.107.14.136 with SMTP id 130mr21554937ioo.170.1523859944461; Sun, 15 Apr 2018 23:25:44 -0700 (PDT) MIME-Version: 1.0 Received: by 10.107.187.67 with HTTP; Sun, 15 Apr 2018 23:25:44 -0700 (PDT) In-Reply-To: <1523558863-5427-5-git-send-email-thomas.abraham@arm.com> References: <1523558863-5427-1-git-send-email-thomas.abraham@arm.com> <1523558863-5427-5-git-send-email-thomas.abraham@arm.com> From: Ard Biesheuvel Date: Mon, 16 Apr 2018 08:25:44 +0200 Message-ID: To: Thomas Abraham Cc: "edk2-devel@lists.01.org" , Leif Lindholm , Daniil Egranov Subject: Re: [PATCH edk2-platforms v2 4/6] Platform/ARM/Sgi: add support for virtio block device X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Apr 2018 06:25:45 -0000 Content-Type: text/plain; charset="UTF-8" On 12 April 2018 at 20:47, Thomas Abraham wrote: > From: Daniil Egranov > > Add the registration of the virtio block device. > > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Daniil Egranov > Signed-off-by: Thomas Abraham > --- > .../ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c | 18 ++++- > .../ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf | 1 + > .../ARM/SgiPkg/Drivers/PlatformDxe/VirtioBlockIo.c | 76 ++++++++++++++++++++++ > 3 files changed, 94 insertions(+), 1 deletion(-) > create mode 100644 Platform/ARM/SgiPkg/Drivers/PlatformDxe/VirtioBlockIo.c > > diff --git a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c > index 2da768a..5d54f06 100644 > --- a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c > +++ b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c > @@ -15,11 +15,27 @@ > #include > > EFI_STATUS > +InitVirtioBlockIo ( > + IN EFI_HANDLE ImageHandle > + ); > + Can this be STATIC? > +EFI_STATUS > EFIAPI > ArmSgiPkgEntryPoint ( > IN EFI_HANDLE ImageHandle, > IN EFI_SYSTEM_TABLE *SystemTable > ) > { > - return EFI_SUCCESS; > + EFI_STATUS Status; > + > + // Install Virtio Block IO. > + if ( FeaturePcdGet (PcdVirtioSupported) == TRUE ) { No space after ( No boolean compare with TRUE/FALSE -> FeaturePcdGet() already returns a BOOLEAN > + Status = InitVirtioBlockIo (ImageHandle); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "PlatformDxe: Failed to install Virtio Block IO\n")); > + return Status; > + } > + } > + > + return Status; > } > diff --git a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf > index 379d7f4..534947f 100644 > --- a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf > +++ b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf > @@ -20,6 +20,7 @@ > > [Sources.common] > PlatformDxe.c > + VirtioBlockIo.c > > [Packages] > ArmPkg/ArmPkg.dec > diff --git a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/VirtioBlockIo.c b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/VirtioBlockIo.c > new file mode 100644 > index 0000000..eb00225 > --- /dev/null > +++ b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/VirtioBlockIo.c > @@ -0,0 +1,76 @@ > +/** @file > + > + Copyright (c) 2018, ARM 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 > + > +#pragma pack (1) > +typedef struct { > + VENDOR_DEVICE_PATH Vendor; > + EFI_DEVICE_PATH_PROTOCOL End; > +} VIRTIO_BLK_DEVICE_PATH; > +#pragma pack () > + > +STATIC VIRTIO_BLK_DEVICE_PATH mVirtioBlockDevicePath = > +{ > + { > + { > + HARDWARE_DEVICE_PATH, > + HW_VENDOR_DP, > + { > + (UINT8)( sizeof (VENDOR_DEVICE_PATH) ), > + (UINT8)( (sizeof (VENDOR_DEVICE_PATH) ) >> 8) > + } > + }, > + EFI_CALLER_ID_GUID, > + }, > + { > + END_DEVICE_PATH_TYPE, > + END_ENTIRE_DEVICE_PATH_SUBTYPE, > + { > + sizeof (EFI_DEVICE_PATH_PROTOCOL), > + 0 > + } > + } > +}; > + > +/** > + * Entrypoint for 'VirtioBlockIo' driver > + */ > +EFI_STATUS > +InitVirtioBlockIo ( > + IN EFI_HANDLE ImageHandle > + ) > +{ > + EFI_STATUS Status = 0; > + > + Status = gBS->InstallProtocolInterface (&ImageHandle, > + &gEfiDevicePathProtocolGuid, EFI_NATIVE_INTERFACE, > + &mVirtioBlockDevicePath); > + > + if (EFI_ERROR (Status)) { > + return Status; > + } > + > + // Declare the Virtio BlockIo device > + Status = VirtioMmioInstallDevice (SGI_EXP_SYSPH_VIRTIO_BLOCK_BASE, ImageHandle); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "PlatformDxe: Failed to install Virtio block device\n")); > + } > + > + return Status; > +} > -- > 2.7.4 >