public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Ming Huang <heyi.guo@linaro.org>
To: leif.lindholm@linaro.org, linaro-uefi@lists.linaro.org,
	edk2-devel@lists.01.org, graeme.gregory@linaro.org
Cc: 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,
	Heyi Guo <heyi.guo@linaro.org>
Subject: [PATCH edk2-platforms v2 07/15] Hisilicon D03/D05: Open SnpPlatform source code
Date: Fri, 26 Jan 2018 16:00:42 +0800	[thread overview]
Message-ID: <1516953650-57980-8-git-send-email-huangming23@huawei.com> (raw)
In-Reply-To: <1516953650-57980-1-git-send-email-huangming23@huawei.com>

From: Jason Zhang <zhangjinsong2@huawei.com>

1. This driver install a protocol for SnpPV600Dxe driver.
   The protocol indicate which ethernet port to use and port sequence.
2. Fixed bug:Confusing Ethernet port sequence.
   Move the most right Ethernet port (when looking from the front
   of the chassis) to the first one in BootManage for PXE boot.
   https://bugs.linaro.org/show_bug.cgi?id=2657

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jason Zhang <zhangjinsong2@huawei.com>
Signed-off-by: Ming Huang <huangming23@huawei.com>
Signed-off-by: Heyi Guo <heyi.guo@linaro.org>
---
 Platform/Hisilicon/D03/D03.dsc                           |   2 +
 Platform/Hisilicon/D03/D03.fdf                           |   2 +-
 Platform/Hisilicon/D05/D05.dsc                           |   2 +
 Platform/Hisilicon/D05/D05.fdf                           |   2 +-
 Silicon/Hisilicon/Drivers/SnpPlatform/SnpPlatform.c      | 115 ++++++++++++++++++++
 Silicon/Hisilicon/Drivers/SnpPlatform/SnpPlatform.inf    |  46 ++++++++
 Silicon/Hisilicon/HisiPkg.dec                            |   1 +
 Silicon/Hisilicon/Include/Protocol/SnpPlatformProtocol.h |  32 ++++++
 8 files changed, 200 insertions(+), 2 deletions(-)

diff --git a/Platform/Hisilicon/D03/D03.dsc b/Platform/Hisilicon/D03/D03.dsc
index 07da597..947a8a5 100644
--- a/Platform/Hisilicon/D03/D03.dsc
+++ b/Platform/Hisilicon/D03/D03.dsc
@@ -399,6 +399,8 @@
 
   Platform/Hisilicon/D03/Drivers/Ipmi/ipmiInterfaceDxe/IpmiInterfaceDxe.inf
 
+  Silicon/Hisilicon/Drivers/SnpPlatform/SnpPlatform.inf
+
   MdeModulePkg/Universal/Network/ArpDxe/ArpDxe.inf
   MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Dxe.inf
   MdeModulePkg/Universal/Network/DpcDxe/DpcDxe.inf
diff --git a/Platform/Hisilicon/D03/D03.fdf b/Platform/Hisilicon/D03/D03.fdf
index 919f9d7..1c55761 100644
--- a/Platform/Hisilicon/D03/D03.fdf
+++ b/Platform/Hisilicon/D03/D03.fdf
@@ -242,7 +242,7 @@ READ_LOCK_STATUS   = TRUE
   #Network
   #
 
-  INF Platform/Hisilicon/D03/Drivers/Net/SnpPlatform/SnpPlatform.inf
+  INF Silicon/Hisilicon/Drivers/SnpPlatform/SnpPlatform.inf
   INF Platform/Hisilicon/D03/Drivers/Net/SnpPV600Dxe/SnpPV600Dxe.inf
 
   INF MdeModulePkg/Universal/Network/ArpDxe/ArpDxe.inf
diff --git a/Platform/Hisilicon/D05/D05.dsc b/Platform/Hisilicon/D05/D05.dsc
index b279c9e..6e44041 100644
--- a/Platform/Hisilicon/D05/D05.dsc
+++ b/Platform/Hisilicon/D05/D05.dsc
@@ -537,6 +537,8 @@
 
   Platform/Hisilicon/D05/Drivers/Ipmi/IpmiInterfaceDxe/IpmiInterfaceDxe.inf
 
+  Silicon/Hisilicon/Drivers/SnpPlatform/SnpPlatform.inf
+
   MdeModulePkg/Universal/Network/ArpDxe/ArpDxe.inf
   MdeModulePkg/Universal/Network/Dhcp4Dxe/Dhcp4Dxe.inf
   MdeModulePkg/Universal/Network/DpcDxe/DpcDxe.inf
diff --git a/Platform/Hisilicon/D05/D05.fdf b/Platform/Hisilicon/D05/D05.fdf
index b105ee2..e829494 100644
--- a/Platform/Hisilicon/D05/D05.fdf
+++ b/Platform/Hisilicon/D05/D05.fdf
@@ -248,7 +248,7 @@ READ_LOCK_STATUS   = TRUE
   #Network
   #
 
-  INF Platform/Hisilicon/D05/Drivers/Net/SnpPlatform/SnpPlatform.inf
+  INF Silicon/Hisilicon/Drivers/SnpPlatform/SnpPlatform.inf
   INF Platform/Hisilicon/D05/Drivers/Net/SnpPV600Dxe/SnpPV600Dxe.inf
 
   INF MdeModulePkg/Universal/Network/ArpDxe/ArpDxe.inf
diff --git a/Silicon/Hisilicon/Drivers/SnpPlatform/SnpPlatform.c b/Silicon/Hisilicon/Drivers/SnpPlatform/SnpPlatform.c
new file mode 100644
index 0000000..0d6e86e
--- /dev/null
+++ b/Silicon/Hisilicon/Drivers/SnpPlatform/SnpPlatform.c
@@ -0,0 +1,115 @@
+/** @file
+*
+*  Copyright (c) 2017, Hisilicon Limited. All rights reserved.
+*  Copyright (c) 2017, 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 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 <PiDxe.h>
+#include <Uefi.h>
+#include <Guid/EventGroup.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/BaseLib.h>
+#include <Library/DebugLib.h>
+#include <Library/DxeServicesTableLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/UefiDriverEntryPoint.h>
+#include <Library/UefiLib.h>
+
+#include <Protocol/SnpPlatformProtocol.h>
+
+typedef struct {
+  UINTN                      Signature;
+  EFI_HANDLE                 Handle;
+  HISI_PLATFORM_SNP_PROTOCOL SnpPlatformProtocol;
+} SNP_PLATFORM_INSTANCE;
+
+STATIC HISI_PLATFORM_SNP_PROTOCOL mSnpPlatformProtocol[] = {
+  {
+    4,
+    1
+  },
+  {
+    5,
+    1
+  },
+  {
+    2,
+    0
+  },
+  {
+    3,
+    0
+  },
+  {
+    0,
+    1
+  },
+ {
+    1,
+    1
+  },
+  {
+    6,
+    0
+  },
+  {
+    7,
+    0
+  }
+};
+
+
+EFI_STATUS
+EFIAPI
+SnpPlatformInitialize (
+  IN EFI_HANDLE         ImageHandle,
+  IN EFI_SYSTEM_TABLE   *SystemTable
+  )
+{
+  UINTN                    Loop;
+  SNP_PLATFORM_INSTANCE    *PrivateData;
+  EFI_STATUS               Status;
+
+  for (Loop = 0; Loop < ARRAY_SIZE (mSnpPlatformProtocol); Loop++) {
+    if(mSnpPlatformProtocol[Loop].Enable != 1) {
+      continue;
+    }
+    PrivateData = AllocateZeroPool (sizeof(SNP_PLATFORM_INSTANCE));
+    if (PrivateData == NULL) {
+      DEBUG ((DEBUG_INFO,"SnpPlatformInitialize  error 1\n"));
+      return EFI_OUT_OF_RESOURCES;
+    }
+
+
+    PrivateData->SnpPlatformProtocol = mSnpPlatformProtocol[Loop];
+
+    //
+    // Install the snp protocol, device path protocol
+    //
+    Status = gBS->InstallMultipleProtocolInterfaces (
+                  &PrivateData->Handle,
+                  &gHisiSnpPlatformProtocolGuid,
+                  &PrivateData->SnpPlatformProtocol,
+                  NULL
+                  );
+    if (EFI_ERROR (Status)) {
+      FreePool (PrivateData);
+      DEBUG ((DEBUG_ERROR, "InstallProtocolInterface fail. %r\n", Status));
+      continue;
+    }
+  }
+
+  DEBUG ((DEBUG_INFO,"SnpPlatformInitialize succes!\n"));
+
+  return EFI_SUCCESS;
+}
diff --git a/Silicon/Hisilicon/Drivers/SnpPlatform/SnpPlatform.inf b/Silicon/Hisilicon/Drivers/SnpPlatform/SnpPlatform.inf
new file mode 100644
index 0000000..3301abf
--- /dev/null
+++ b/Silicon/Hisilicon/Drivers/SnpPlatform/SnpPlatform.inf
@@ -0,0 +1,46 @@
+#/** @file
+#
+#    Copyright (c) 2017, Hisilicon Limited. All rights reserved.
+#    Copyright (c) 2017, 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 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                    = 0x00010019
+  BASE_NAME                      = SnpPlatform
+  FILE_GUID                      = 102D8FC9-20A4-42eb-AC14-1C98BA5B17A8
+  MODULE_TYPE                    = DXE_DRIVER
+  VERSION_STRING                 = 1.0
+  ENTRY_POINT                    = SnpPlatformInitialize
+
+[Sources]
+  SnpPlatform.c
+
+[Packages]
+  MdeModulePkg/MdeModulePkg.dec
+  MdePkg/MdePkg.dec
+  Silicon/Hisilicon/HisiPkg.dec
+
+[LibraryClasses]
+  BaseLib
+  BaseMemoryLib
+  DebugLib
+  DxeServicesTableLib
+  MemoryAllocationLib
+  UefiBootServicesTableLib
+  UefiDriverEntryPoint
+
+[Protocols]
+  gHisiSnpPlatformProtocolGuid
+
+[Depex]
+  TRUE
+
diff --git a/Silicon/Hisilicon/HisiPkg.dec b/Silicon/Hisilicon/HisiPkg.dec
index 4c9d379..35bea97 100644
--- a/Silicon/Hisilicon/HisiPkg.dec
+++ b/Silicon/Hisilicon/HisiPkg.dec
@@ -38,6 +38,7 @@
   gSataEnableFlagProtocolGuid = {0xc2b3c770, 0x8b4a, 0x4796, {0xb2, 0xcf, 0x1d, 0xee, 0x44, 0xd0, 0x32, 0xf3}}
   gPlatformSasProtocolGuid = {0x40e9829f, 0x3a2c, 0x479a, {0x9a, 0x93, 0x45, 0x7d, 0x13, 0x50, 0x96, 0x5d}}
   gHisiPlatformSasProtocolGuid = {0x20e9829f, 0x3a2c, 0x479a, {0x9a, 0x93, 0x45, 0x7d, 0x13, 0x50, 0x96, 0x6d}}
+  gHisiSnpPlatformProtocolGuid = {0x81321f27, 0xff58, 0x4a1d, {0x99, 0x97, 0xd, 0xcc, 0xfa, 0x82, 0xf4, 0x6f}}
 
 [Guids]
   gHisiTokenSpaceGuid = {0xc8bc553e, 0x12bf, 0x11e6, {0x97, 0x4f, 0x87, 0xf7, 0x7c, 0xfd, 0x52, 0x1d}}
diff --git a/Silicon/Hisilicon/Include/Protocol/SnpPlatformProtocol.h b/Silicon/Hisilicon/Include/Protocol/SnpPlatformProtocol.h
new file mode 100644
index 0000000..0d9f0b4
--- /dev/null
+++ b/Silicon/Hisilicon/Include/Protocol/SnpPlatformProtocol.h
@@ -0,0 +1,32 @@
+/** @file
+*
+*  Copyright (c) 2017, Hisilicon Limited. All rights reserved.
+*  Copyright (c) 2017, 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 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.
+*
+**/
+
+#ifndef _SNP_PLATFORM_PROTOCOL_H_
+#define _SNP_PLATFORM_PROTOCOL_H_
+#define HISI_SNP_PLATFORM_PROTOCOL_GUID \
+  { \
+    0x81321f27, 0xff58, 0x4a1d, 0x99, 0x97, 0xd, 0xcc, 0xfa, 0x82, 0xf4, 0x6f  \
+  }
+
+typedef struct _HISI_PLATFORM_SNP_PROTOCOL  HISI_PLATFORM_SNP_PROTOCOL;
+
+struct _HISI_PLATFORM_SNP_PROTOCOL {
+  UINT32        ControllerId;
+  UINT32        Enable;
+};
+
+extern EFI_GUID gHisiSnpPlatformProtocolGuid;
+
+#endif
-- 
1.9.1



  parent reply	other threads:[~2018-01-26  7:57 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-26  8:00 [PATCH edk2-platforms v2 00/15] Improve D0x platforms and bug fix Ming Huang
2018-01-26  8:00 ` [PATCH edk2-platforms v2 01/15] Hisilicon/D05: Move Madt definition to head file Ming Huang
2018-01-30 14:27   ` graeme.gregory
2018-01-26  8:00 ` [PATCH edk2-platforms v2 02/15] Hisilicon/D05: Add PPTT support Ming Huang
2018-01-30 14:28   ` graeme.gregory
2018-02-01  1:11   ` Jeremy Linton
2018-02-02  3:42     ` Huangming (Mark)
2018-02-02 16:17       ` Jeremy Linton
2018-01-26  8:00 ` [PATCH edk2-platforms v2 03/15] Hisilicon/D0x/BDS: Switch to Generic BDS driver Ming Huang
2018-01-26  8:00 ` [PATCH edk2-platforms v2 04/15] Hisilicon/D0x: Break BMC SetBoot option out into separate library Ming Huang
2018-01-26  8:00 ` [PATCH edk2-platforms v2 05/15] Hisilicon D03/D05: Add capsule upgrade support Ming Huang
2018-01-29 19:58   ` Leif Lindholm
2018-01-30 12:48     ` Huangming (Mark)
2018-01-30 13:21       ` Leif Lindholm
2018-01-31  1:14         ` Huangming (Mark)
2018-01-30 12:47   ` Ard Biesheuvel
2018-01-26  8:00 ` [PATCH edk2-platforms v2 06/15] Hisilicon D03/D05: Open SasPlatform source code Ming Huang
2018-01-26  8:00 ` Ming Huang [this message]
2018-01-26  8:00 ` [PATCH edk2-platforms v2 08/15] Hilisicon: Change DmaLib to CoherentDmaLib Ming Huang
2018-01-26  8:00 ` [PATCH edk2-platforms v2 09/15] Hisilicon/Smbios: Indicate use of ProcessorFamily2 in type 4 table Ming Huang
2018-01-26  8:00 ` [PATCH edk2-platforms v2 10/15] Hisilicon/PCIe: Disable PCIe ASPM Ming Huang
2018-01-26  8:00 ` [PATCH edk2-platforms v2 11/15] Hisilicon/D05: Replace SP805Watchdog by WatchdogTimer driver Ming Huang
2018-01-26  8:00 ` [PATCH edk2-platforms v2 12/15] Hisilicon/D03: " Ming Huang
2018-01-26  8:00 ` [PATCH edk2-platforms v2 13/15] Hisilicon/D05/ACPI: Add ITS PXM Ming Huang
2018-01-30 14:30   ` graeme.gregory
2018-01-26  8:00 ` [PATCH edk2-platforms v2 14/15] Hisilicon/D05/ACPI: Add Pcie, HNS and SAS PXM Ming Huang
2018-01-30 14:31   ` graeme.gregory
2018-01-26  8:00 ` [PATCH edk2-platforms v2 15/15] Hisilicon D03/D05: Update firmware version to 18.02 Ming Huang
2018-01-29 17:33 ` [PATCH edk2-platforms v2 00/15] Improve D0x platforms and bug fix Leif Lindholm
2018-02-03  7:50   ` Huangming (Mark)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1516953650-57980-8-git-send-email-huangming23@huawei.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox